# Cell Summaries

Canonical page: https://www.adaptabletools.com/docs/handbook-summarising-cells

- AdapTable provides comprehensive summary information for selected cells in AG Grid numeric columns
- A table shows summaries of those cells using multiple operations
- Developers can add custom summary operations that are evaluated alongside the built-in ones

AdapTable provides useful summary information about the currently selected cells in AG Grid.

Cell Summaries are provided only for selected cells in a **single numeric column**

This summary information is displayable in 3 locations:

- the Cell Summary [Dashboard Toolbar](https://www.adaptabletools.com/docs/ui-dashboard/index.md#tabs-and-toolbars)
- the Cell Summary [Tool Panel](https://www.adaptabletools.com/docs/ui-tool-panel/index.md)
- the Cell Summary [Status Bar](https://www.adaptabletools.com/docs/ui-status-bar/index.md)

Each of these contains three UI elements:

| Element | Purpose |
| --- | --- |
| **DropDown** | Choose a summary operation (AdapTable remembers the most recently selected) |
| **Label** | Shows the summarised value for the currently selected cells using the chosen operation |
| **Info button** | Opens the Cell Summary page in the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md), listing summaries for every available operation |

- Ensure that the `CellSelectionModule` has been provided in [AG Grid Modules](https://www.adaptabletools.com/docs/getting-started-aggrid-modules/index.md)
- Additionally make sure that the `cellSelection` property in AG Grid GridOptions is not set to *false* or *null*

## Cell Summary Types

There are two kinds of Cell Summaries that can be displayed:

- **System** Summary Operations provided by AdapTable
- **Custom** Summary Operations provided by developers

### Adaptable Cell Summaries

AdapTable provides a number of system Summary Operations which are available by default in the Cell Summary UI.

These are all [Aggregation Scalar Functions](https://www.adaptabletools.com/docs/adaptable-ql-expression-functions/index.md) provided by - and evaluated by - [AdapTableQL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md)

| Operation       | Description of Summarised Data                      |
| --------------- | --------------------------------------------------- |
| `Sum`           | Total of all selected cells                         |
| `Average`       | Average of all selected cells                       |
| `Median`        | Middle (value) of all selected cells (when ordered) |
| `Mode`          | Most common cell value                              |
| `Distinct`      | Count of distinct selected cell values              |
| `Max`           | Highest selected Cell Value                         |
| `Min`           | Lowest selected Cell Value                          |
| `Count`         | Number of selected cells                            |
| `Weighted Avg`  | Weighted Average  |
| `Only`          | Value of all selected cells if they all match       |
| `Std Deviation` | Shows Standard Deviation for selected cells         |

The Weighted Average summary requires a defined Weighted Column, see [Guide to Weighted Averages](https://www.adaptabletools.com/docs/handbook-aggregation-weighted-average/index.md) for more info

**Example: Cell Summary**

Summarising selected cells

- This example selects some cells in the `Github Stars` column (using methods in AdapTable's [Grid API](https://www.adaptabletools.com/docs/handbook-managing-grid-data/index.md))
- It displays the Sum of their values in the Cell Summary Toolbar, Tool Panel and Status Bar

- Select different cell ranges and different Summary Operations in the `Cell Summary` dashboard and see the results
- Alternatively right-click and select Cell Summary to open the Cell Summary page in the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md)
- Switch between the Table and Pivot layouts and note that Cell Summaries are available in both

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Cell Summary',
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      PinnedToolbars: ['CellSummary'],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['CellSummary'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'github_watchers',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo, GridCellRange} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();

  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['github_stars'],
      rowIndexStart: 0,
      rowIndexEnd: 5,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
    adaptableApi.toolPanelApi.setAdaptableToolPanelVisibilityMode(
      'CellSummary',
      'expanded'
    );
  }, 20);
};
```

### Pivot Layouts

Cell Summaries are also available in Pivot Layouts.

Cell Summaries will operate on selected cells in both Pivot Columns and Pivot Aggregation Columns

**Example: Summarising Pivot Cells**

Cell Summary in Pivot Layouts

- This example selects some cells in the pivoted `MIT License / Github Stars` column
- Despite it being an automated pivot column, the `sum` of the selected cells appears in the Cell Summary Toolbar and Status Bar

- Switch to the `Pivot Agg Layout` (which shows Pivot Aggregations but no Pivot Columns) and select some cells

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Cell Summary Pivoting',
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      PinnedToolbars: ['CellSummary', 'Layout'],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['CellSummary', 'Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-number',
          Scope: {
            DataTypes: ['number'],
          },
          DisplayFormat: {
            Formatter: 'NumberFormatter',
            Options: {
              FractionDigits: 0,
            },
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Pivot Cols Layout',
      Layouts: [
        {
          PivotGroupedColumns: ['language'],
          PivotColumns: ['license'],
          PivotAggregationColumns: [
            {ColumnId: 'github_stars', AggFunc: true},
            {ColumnId: 'github_watchers', AggFunc: true},
          ],
          Name: 'Pivot Cols Layout',
        },
        {
          PivotGroupedColumns: ['language'],
          PivotColumns: [],
          PivotAggregationColumns: [
            {ColumnId: 'github_stars', AggFunc: true},
            {ColumnId: 'github_watchers', AggFunc: true},
          ],
          Name: 'Pivot Agg Layout',
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {
  AdaptableReadyInfo,
  AdaptableStateChangedInfo,
  GridCellRange,
} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['pivot_license_MIT License_github_stars'],
      rowIndexStart: 0,
      rowIndexEnd: 1,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
  }, 20);
};
```

### Custom Cell Summaries

Developers can add their own custom summaries to provide bespoke information about selected cells.

Custom Summaries will be added to the Summary Operations shipped by AdapTable and available for selection

This is done via the `customCellSummaryOperations` property in [Cell Summary Options](https://www.adaptabletools.com/docs/technical-reference-summarising/index.md).

### `customCellSummaryOperations`

Custom Cell Summary Operations

  [`CustomCellSummaryOperation[]`](https://www.adaptabletools.com/docs/reference/customcellsummaryoperation.md)

These are Custom Cell Summary Operations which are provided by design-time users.

They will be added to the set of [Summaries](https://www.adaptabletools.com/docs/handbook-summarising/index.md) shipped by AdapTable.

The `CustomCellSummaryOperation` object is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [operationFunction](https://www.adaptabletools.com/docs/reference/customcellsummaryoperation.md#operationfunction) | `(operationContext: `[`CustomCellSummaryOperationContext`](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md)`<TData>) => any` | Function to run when a summary result is required |
| [operationName](https://www.adaptabletools.com/docs/reference/customcellsummaryoperation.md#operationname) | `string` | Name of the Operation - will be displayed in the Cell Summary components |

The `operationFunction` receives a [`CustomCellSummaryOperationContext`](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md) object and can return any value:

```js
operationFunction: (operationContext: CustomCellSummaryOperationContext) => any;
```

The `operationContext` property (of type [`CustomCellSummaryOperationContext`](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md)) provides the selected cell information:

| Property | Type | Description |
| --- | --- | --- |
| [selectedCellInfo](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md#selectedcellinfo) | [`SelectedCellInfo`](https://www.adaptabletools.com/docs/reference/selectedcellinfo.md)`<TData>` | Currently selected cells |
| [selectedColumn](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md#selectedcolumn) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md) | Currently selected Column |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customcellsummaryoperationcontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

The Comparer can be used like this:

```ts {2}
const adaptableOptions: AdaptableOptions = {
    cellSummaryOptions: {
      customCellSummaryOperations: [
       {
        operationName: 'Most Stars',
        operationFunction: (operationContext: CustomCellSummaryOperationContext) => {
          const selectedDataSortedByStars =
            operationContext?.selectedCellInfo?.gridCells
              .map(gridCell => gridCell.rowNode.data)
              .sort((a, b) => b.github_stars - a.github_stars);
          return selectedDataSortedByStars?.[0].name;
        },
      }],
    },
};
```

Each custom operation contains a summary function that will be invoked by AdapTable when it is required.

**Example: Custom Cell Summaries**

Providing Custom Cell Summaries

- This example contains a custom cell Summary called `Most Stars` 
- It returns the `Name` column value for the row in the selected cell range which has the highest `Github Stars` column value
### Expand to see the Custom Cell Summaries

```ts
cellSummaryOptions: {
  customCellSummaryOperations: [
    {
      operationName: 'Most Stars',
      operationFunction: (operationContext: CustomCellSummaryOperationContext) => {
        const selectedDataSortedByStars =
          operationContext?.selectedCellInfo?.gridCells
            .map(gridCell => gridCell.rowNode.data)
            .sort((a, b) => b.github_stars - a.github_stars);
        if (!selectedDataSortedByStars.length) {
          return '';
        }
        return selectedDataSortedByStars?.[0].name;
      },
    },
  ],
},
```

- Select a range of cells in the `Github Stars` column, then choose `Most Stars` from the Cell Summary dropdown

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {CustomCellSummaryOperationContext} from '@adaptabletools/adaptable';
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Custom Summary',
  cellSummaryOptions: {
    customCellSummaryOperations: [
      {
        operationName: 'Most Stars',
        operationFunction: (
          operationContext: CustomCellSummaryOperationContext
        ) => {
          const selectedDataSortedByStars =
            operationContext?.selectedCellInfo?.gridCells
              .map(gridCell => gridCell.rowNode.data)
              .sort((a, b) => b.github_stars - a.github_stars);

          if (!selectedDataSortedByStars.length) {
            return '';
          }

          return selectedDataSortedByStars?.[0].name;
        },
      },
    ],
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['CellSummary'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout', 'ColumnFilter', 'CellSummary'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-date',
          Scope: {
            DataTypes: ['date'],
          },
          DisplayFormat: {
            Formatter: 'DateFormatter',
            Options: {
              Pattern: 'yyyy/MM/dd',
            },
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'license',
            'github_watchers',
            'github_stars',
            'pushed_at',
            'updated_at',
            'topics',
            'created_at',
            'language',
            'has_wiki',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';
import {GridCellRange} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();

  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['github_watchers'],
      rowIndexStart: 1,
      rowIndexEnd: 6,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
    adaptableApi.cellSummaryApi.setCurrentCellSummaryOperation('Most Stars');

    adaptableApi.toolPanelApi.setAdaptableToolPanelVisibilityMode(
      'CellSummary',
      'expanded'
    );
  }, 10);
};
```

## Formatting Cell Summaries

AdapTable will format Cell Summary values by evaluating the following list of rules (in the order given):
- any [Display Formats](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format/index.md) which have been provided for the Column (either by developers or end users)
- a bespoke value supplied for the `numericDisplayFormat` property in [Cell Summary Options](https://www.adaptabletools.com/docs/technical-reference-summarising/index.md)
- using the default format of 2 fraction digits

### `numericDisplayFormat`

Format to use for Cell Summary values

  [`NumberFormatterOptions`](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md)

Provides a value to use when displaying Cell Summary results.

- If not provided, AdapTable's default of 2 fraction digits is used
- Any bespoke display formats for the column take precedence over this property

The value returns a [`NumberFormatterOptions`](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md) object either directly, or via a function.

The `NumberFormatterOptions` object is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [Abs](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#abs) | `boolean` | Returns absolute value of cell value |
| [Ceiling](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#ceiling) | `boolean` | Returns smallest integer greater than cell value |
| [Content](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#content) | `string \| number` | Replaces cell value with supplied value (that can contain Template Literals) |
| [Empty](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#empty) | `boolean` | Show nothing in cell (but underlying value remains) |
| [Floor](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#floor) | `boolean` | Returns largest integer cell value |
| [FractionDigits](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#fractiondigits) | `number` | Number of digits to show in Fractions (up to 20) |
| [FractionSeparator](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#fractionseparator) | `string` | Separator to use in fractions |
| [IntegerDigits](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#integerdigits) | `number` | Number of digits to show for Integers (up to 20) |
| [IntegerSeparator](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#integerseparator) | `string` | Separator to use in Integers |
| [Multiplier](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#multiplier) | `number` | Multiplier to use on cell value |
| [Notation](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#notation) | `'standard' \| 'scientific'` | Numeric notation to use when rendering the value - standard or scientific |
| [Parentheses](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#parentheses) | `boolean` | Shows negative numbers in parentheses |
| [Prefix](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#prefix) | `string` | Prefix to use before cell value |
| [Round](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#round) | `boolean` | Rounds cell value |
| [Suffix](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#suffix) | `string` | Suffix to use after cell value |
| [Truncate](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#truncate) | `boolean` | Truncates cell value |
| [ZeroDisplay](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#zerodisplay) | `string` | What to show when numeric value is zero (after multiplier &amp; rounding) |

<b>Hard-coded value</b>

This implementation returns a `NumberFormatterOptions` directly (which will be used for all summaries):

```ts {2}
cellSummaryOptions: {
  numericDisplayFormat: {
    FractionDigits: 0,
    Prefix: ' [',
    Suffix: ']',
  }
}
```

<b>Function</b>

The function receives an [`AdaptableColumnContext`](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md) object which simply contains the column to evaluate:

| Property | Type | Description |
| --- | --- | --- |
| [column](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#column) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md)`<TData>` | The current Column |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

```ts {2}
cellSummaryOptions: {
  numericDisplayFormat: (context: AdaptableColumnContext) => {
    return context.column.columnId == 'github_watchers'
      ? {FractionDigits: 0, Prefix: '[', Suffix: ']'}
      : {IntegerDigits: 5};
  },
}
```

**Example: Cell Summary Formatting**

Formatting Cell Summary values

- This example provides a custom Display Format for the `Github Stars` Column which is reflected in the Cell Summary (we select some cells using AdapTable's [Grid API](https://www.adaptabletools.com/docs/handbook-managing-grid-data/index.md))
-  We also provide an implementation for `numericDisplayFormat` property in [Cell Summary Options](https://www.adaptabletools.com/docs/technical-reference-summarising/index.md) which is used when cells in other columns are selected 

- Select cells in the `Github Watchers` column and note that the `numericDisplayFormat` property's value is used

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Cell Summary Formatting',
  cellSummaryOptions: {
    numericDisplayFormat: {
      FractionDigits: 0,
      Prefix: ' [',
      Suffix: ']',
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['CellSummary'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['CellSummary'],
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-github_stars',
          Scope: {
            ColumnIds: ['github_stars'],
          },
          DisplayFormat: {
            Formatter: 'NumberFormatter',
            Options: {
              Multiplier: 0.001,
              Suffix: 'K',
              FractionDigits: 2,
            },
          },
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'github_watchers',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo, GridCellRange} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();

  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['github_stars'],
      rowIndexStart: 0,
      rowIndexEnd: 5,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
    adaptableApi.toolPanelApi.setAdaptableToolPanelVisibilityMode(
      'CellSummary',
      'expanded'
    );
  }, 20);
};
```

## Ticking Cell Summaries

AdapTable will update Cell Summaries in real time as the selected cell values change.

**Example: Cell Summary Ticking Data**

Cell Summary values automatic updates

- This example selects a group of cells in the `Github Stars` column and mimics ticking data by periodically updating the column
- We see the Cell Summary update as the values in Selected Cells tick

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts      [template]
  columnDefs.ts         [template]
  gridOptions.ts        [template]
  index.ts              [template]
  onAdaptableReady.ts
  rowData.ts            [template]
  styles.css            [template]
  tickingDataHelper.ts  [template]
index.html              [template]
package.json            [template]
tsconfig.json           [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Cell Summary',
  cellSummaryOptions: {
    numericDisplayFormat: {
      IntegerDigits: 0,
      IntegerSeparator: ',',
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      PinnedToolbars: ['CellSummary', 'Layout'],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['CellSummary', 'Layout'],
        },
      ],
    },
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'flashingCell-numeric-anyChange',
          Scope: {
            DataTypes: ['number'],
          },
          Rule: 'ANY_CHANGE()',
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'github_watchers',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
        {
          PivotGroupedColumns: ['language'],
          PivotColumns: ['license'],
          PivotAggregationColumns: [
            {ColumnId: 'github_stars', AggFunc: true},
            {ColumnId: 'github_watchers', AggFunc: true},
          ],
          Name: 'Pivot Layout',
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo, GridCellRange} from '@adaptabletools/adaptable';
import {tickNumericData} from './tickingDataHelper';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();

  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['github_stars'],
      rowIndexStart: 0,
      rowIndexEnd: 9,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
    adaptableApi.toolPanelApi.setAdaptableToolPanelVisibilityMode(
      'CellSummary',
      'expanded'
    );
  }, 20);

  tickNumericData(adaptableApi, 300, ['github_stars']);
};
```

### FAQ

**Can we add our own Summary Operations?**
Yes — use the `customCellSummaryOperations` property on [`Cell Summary Options`](https://www.adaptabletools.com/docs/reference/cellsummaryoptions.md).

**Can we use Cell Summaries in Pivot Layouts?**
Yes — see the [Pivot Layouts](#pivot-layouts) section above.
