Charts Technical Reference
Summary
- The Chart Changed Event fires when Charting State changes
- Charting Initial Adaptable State contains chart definitions saved into AdapTable State
- Charting API contains chart-related functions
- Charting Options contains charting properties
Chart Changed Event
The Chart Changed Event fires whenever there are any modifications to any open Charts.
ChartChangedInfo
The event comprises a single ChartChangedInfo object which lists the currently opened Charts:
| Property | Type | Description |
|---|---|---|
| chartingOpenState | ChartingOpenState | Details of Open Charts |
| adaptableContext | any | Custom application Context provided in AdaptableOptions.adaptableContext |
This object contains a collection of ChartDisplayedInfo objects which contains details of displayed Charts:
| Property | Type | Description |
|---|---|---|
| chartDefinition | ChartDefinition | Definition of the Chart |
| containerName | string | null | Container where Chart is displayed |
| isOpen | boolean | Whether Chart is Open |
Event Subscription
Subscribing to the Event is done the same way as with all Adaptable Events:
api.eventApi.on('ChartChanged', (eventInfo: ChartChangedInfo) => {
// do something with the info
});Charting State
The Chart section of Adaptable State contains a single ChartDefinitions collection:
| Property | Type | Description |
|---|---|---|
| ChartDefinitions | ChartDefinition[] | Wrappers around AG Grid Chart Models |
| ExternalChartDefinitions | ExternalChartDefinition<unknown>[] | Definitions of External Charts |
Chart Definition Object
A ChartDefinition simply wraps an AG Grid Charting Model:
| Property | Type | Description |
|---|---|---|
| Model | ChartModel | AG Grid Chart Model |
| Name | string | Unique name of the chart (used in UI and layout references, like Layout names) |
| IsReadOnly | boolean | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full') |
Charting Options
| Property | Type | Description | Default |
|---|---|---|---|
| agGridContainerName | string | Name of AG Grid Chart Container | 'AG Grid Window' |
| chartContainers | ChartContainer[] | Locations to display saved Charts | |
| externalChartingOptions | ExternalChartingOptions | Set of properties for managing behaviour of external (i.e non AG Grid) charts | |
| restoreChartsOnReady | boolean | 'all' | string[] | Opens persisted AG Grid charts when AdapTable is ready. - true or 'all': all charts in Charting.ChartDefinitions - string[]: chart names to open (matches each definition's Name property) | undefined (no charts opened automatically) |
| saveChartBehaviour | SaveChartBehaviour | Behaviour for saving Charts: auto, manual (via popup) or none | 'none' |
External Charting Options
| Property | Type | Description |
|---|---|---|
| isChartOpened | (context:ExternalChartingContext) => boolean | Needs to be implemented to specify if Chart is opened; used to set Show Button's highlighting |
| onDeleteChart | (context:ExternalChartingContext) => void | Called when User deletes a persisted Chart |
| onHideChart | (context:ExternalChartingContext) => void | Called when User clicks on Hide button next to Chart |
| onPreviewChart | (context:ExternalChartingContext) => ExternalChartDefinition | Shows Chart in Settings Panel preview (not saved into State); returned definition will be passed to 'onHideChart' when Preview closes |
| onShowChart | (context:ExternalChartingContext) => void | Called when User clicks on Show button next to Chart |
Charting API
The Charting API section of AdapTable API includes a small number of chart-related functions.
These make it easy to save and retrieves charts from Adaptable State.
Hint
In practice this is more likely to be done at run-time but charts can be defined at design time if required
Charting API includes these functions:
| Method | Returns | Description |
|---|---|---|
| addChartDefinition(chartDefinition) | void | Add new Chart |
| addExternalChartDefinition(chartDef, options) | void | Add new external chart definition |
| closeChartDefinition(chartDefinition) | void | Close Chart definition |
| deleteExternalChartDefinition(chartDefinition) | void | Delete external chart definition |
| editChartDefinition(chartDefinition) | void | Edit existing Chart |
| editExternalChartDefinition(chartDef) | void | Edit existing external chart definition |
| getChartDefinitionByName(name) | ChartDefinition | undefined | Retrieves Chart definition by name |
| getChartDefinitionByUuid(uuid) | ChartDefinition | undefined | Retrieves Chart definition by uuid |
| getChartDefinitions() | ChartDefinition[] | Retrieves all adaptable Chart definitions |
| getChartingOpenState() | ChartingOpenState | Get info about all saved charts, incl. their open state |
| getChartRef(chartId) | ChartRef | undefined | Retrieves AG Grid ChartRef for given ChartId |
| getCurrentChartModels() | ChartModel[] | Retrieves current user-generated Charts |
| getExternalChartDefinitionByName(name) | ExternalChartDefinition | undefined | Retrieves Chart definition by name |
| getExternalChartDefinitions() | ExternalChartDefinition[] | Retrieves all adaptable external Chart definitions |
| getOpenChartContainer(chartDefinition) | ChartContainer | null | Retrieve name of container in which Chart is open; returns null if Chart is not open |
| getPersistedCharts() | ChartModel[] | Retrieves persisted Charts from Adaptable State |
| isChartingEnabled() | boolean | Whether AdapTable's Charting functionality is available |
| saveCurrentCharts() | void | Saves all current Charts into Adaptable State |
| setChartEditable(chartDefinition) | void | Make a Chart Editable (i.e. not Read-Only) |
| setChartReadOnly(chartDefinition) | void | Make a Chart Read-Only |
| showChartDefinition(chartDefinition, container) | ChartRef | Opens a Chart Definition |
| showChartDefinitionOnce(chartDefinition, container) | ChartRef | undefined | Displays a Chart; if Chart is already open, 2nd Chart is not opened |
| showPersistedCharts() | ChartRef[] | Displays all persisted Charts |