import { BasePlugin } from '../base';
import Endpoints from './endpoints';
export declare const PLUGIN_KEY = "columnSummary";
export declare const PLUGIN_PRIORITY = 220;
export interface SummaryEndpoint {
ranges?: number[][];
sourceColumn?: number;
destinationRow?: number;
destinationColumn?: number;
forceNumeric?: boolean;
type?: string;
result?: number | string;
customFunction?: ((this: ColumnSummary, endpoint: SummaryEndpoint) => number | string) | null;
[key: string]: unknown;
}
/**
* @plugin ColumnSummary
* @class ColumnSummary
*
* @description
* The `ColumnSummary` plugin lets you [easily summarize your columns](@/guides/columns/column-summary/column-summary.md).
*
* You can use the [built-in summary functions](@/guides/columns/column-summary/column-summary.md#built-in-summary-functions),
* or implement a [custom summary function](@/guides/columns/column-summary/column-summary.md#implement-a-custom-summary-function).
*
* For each column summary, you can set the following configuration options:
*
* | Option | Required | Type | Default | Description |
* |---|---|---|---|---|
* | `sourceColumn` | No | Number | Same as `destinationColumn` | [Selects a column to summarize](@/guides/columns/column-summary/column-summary.md#step-2-select-cells-that-you-want-to-summarize) |
* | `ranges` | No | Array | - | [Selects ranges of rows to summarize](@/guides/columns/column-summary/column-summary.md#step-2-select-cells-that-you-want-to-summarize) |
* | `type` | Yes | String | - | [Sets a summary function](@/guides/columns/column-summary/column-summary.md#step-3-calculate-your-summary) |
* | `destinationRow` | Yes | Number | - | [Sets the destination cell's row coordinate](@/guides/columns/column-summary/column-summary.md#step-4-provide-the-destination-cell-s-coordinates) |
* | `destinationColumn` | Yes | Number | - | [Sets the destination cell's column coordinate](@/guides/columns/column-summary/column-summary.md#step-4-provide-the-destination-cell-s-coordinates) |
* | `forceNumeric` | No | Boolean | `false` | [Forces the summary to treat non-numerics as numerics](@/guides/columns/column-summary/column-summary.md#force-numeric-values) |
* | `reversedRowCoords` | No | Boolean | `false` | [Reverses the row coordinate, count row coordinates backward](@/guides/columns/column-summary/column-summary.md#step-5-make-room-for-the-destination-cell). Useful when displaying summary results at the bottom of the grid, as it allows you to reference rows relative to the last row (e.g., `destinationRow: 0` refers to the last row when this option is enabled) |
* | `suppressDataTypeErrors` | No | Boolean | `true` | [Suppresses data type errors](@/guides/columns/column-summary/column-summary.md#throw-data-type-errors) |
* | `readOnly` | No | Boolean | `true` | Makes summary cell [read-only](@/api/options.md#readonly) |
* | `roundFloat` | No | Number/
Boolean | - | [Rounds summary result](@/guides/columns/column-summary/column-summary.md#round-a-column-summary-result) |
* | `customFunction` | No | Function | - | [Lets you add a custom summary function](@/guides/columns/column-summary/column-summary.md#implement-a-custom-summary-function) |
*
* @example
* ::: only-for javascript
* ```js
* const container = document.getElementById('example');
* const hot = new Handsontable(container, {
* data: getData(),
* colHeaders: true,
* rowHeaders: true,
* columnSummary: [
* {
* type: 'min',
* destinationRow: 4,
* destinationColumn: 1,
* },
* {
* type: 'max',
* destinationRow: 0,
* destinationColumn: 3,
* reversedRowCoords: true
* },
* {
* type: 'sum',
* destinationRow: 4,
* destinationColumn: 5,
* forceNumeric: true
* }
* ]
* });
* ```
* :::
*
* ::: only-for react
* ```jsx
*
* ```
* :::
*
* ::: only-for angular
* ```ts
* settings = {
* data: getData(),
* colHeaders: true,
* rowHeaders: true,
* columnSummary: [
* {
* type: "min",
* destinationRow: 4,
* destinationColumn: 1,
* },
* {
* type: "max",
* destinationRow: 0,
* destinationColumn: 3,
* reversedRowCoords: true,
* },
* {
* type: "sum",
* destinationRow: 4,
* destinationColumn: 5,
* forceNumeric: true,
* },
* ],
* };
* ```
*
* ```html
*
* ```
* :::
*/
export declare class ColumnSummary extends BasePlugin {
#private;
/**
* Returns the plugin key used to identify this plugin in Handsontable settings.
*/
static get PLUGIN_KEY(): string;
/**
* Returns the priority order used to determine the order in which plugins are initialized.
*/
static get PLUGIN_PRIORITY(): number;
/**
* The Endpoints class instance. Used to make all endpoint-related operations.
*
* @private
* @type {null|Endpoints}
*/
endpoints: Endpoints | null;
/**
* Plugin settings provided by the user, or `null` if none were supplied.
*/
settings: Record | null;
/**
* The endpoint configuration object currently being processed during a summary calculation.
*/
currentEndpoint: unknown;
/**
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
* hook and if it returns `true` then the {@link ColumnSummary#enablePlugin} method is called.
*
* @returns {boolean}
*/
isEnabled(): boolean;
/**
* Enables the plugin functionality for this Handsontable instance.
*/
enablePlugin(): void;
/**
* Disables the plugin functionality for this Handsontable instance.
*/
disablePlugin(): void;
/**
* Updates the plugin's state.
*
* This method is executed when [`updateSettings()`](@/api/core.md#updatesettings) is invoked with any of the following configuration options:
* - [`columnSummary`](@/api/options.md#columnsummary)
*/
updatePlugin(): void;
/**
* Calculates math for a single endpoint.
*
* @private
* @param {object} endpoint Contains information about the endpoint.
*/
calculate(endpoint: SummaryEndpoint): void;
/**
* Calculates sum of the values contained in ranges provided in the plugin config.
*
* @private
* @param {object} endpoint Contains the endpoint information.
* @returns {number} Sum for the selected range.
*/
calculateSum(endpoint: SummaryEndpoint): number;
/**
* Returns partial sum of values from a single row range.
*
* @private
* @param {Array} rowRange Range for the sum.
* @param {number} col Column index.
* @returns {number} The partial sum.
*/
getPartialSum(rowRange: number[], col: number): number;
/**
* Calculates the minimal value for the selected ranges.
*
* @private
* @param {object} endpoint Contains the endpoint information.
* @param {string} type `'min'` or `'max'`.
* @returns {number} Min or Max value.
*/
calculateMinMax(endpoint: SummaryEndpoint, type: 'min' | 'max'): number | string;
/**
* Returns a local minimum of the provided sub-range.
*
* @private
* @param {Array} rowRange Range for the calculation.
* @param {number} col Column index.
* @param {string} type `'min'` or `'max'`.
* @returns {number|null} Min or max value.
*/
getPartialMinMax(rowRange: number[], col: number, type: 'min' | 'max'): number | null;
/**
* Counts empty cells in the provided row range.
*
* @private
* @param {Array} rowRange Row range for the calculation.
* @param {number} col Column index.
* @returns {number} Empty cells count.
*/
countEmpty(rowRange: number[], col: number): number;
/**
* Counts non-empty cells in the provided row range.
*
* @private
* @param {object} endpoint Contains the endpoint information.
* @returns {number} Entry count.
*/
countEntries(endpoint: SummaryEndpoint): number;
/**
* Calculates the average value from the cells in the range.
*
* @private
* @param {object} endpoint Contains the endpoint information.
* @returns {number} Avarage value.
*/
calculateAverage(endpoint: SummaryEndpoint): number;
/**
* Returns a cell value, taking into consideration a basic validation.
*
* @private
* @param {number} row Row index.
* @param {number} col Column index.
* @returns {string} The cell value.
*/
getCellValue(row: number, col: number): number | string | null;
}