Charts Technical Reference

View as Markdown

Charting State

ChartingState

Charting section of Adaptable State, including Initial State.

ChartDefinitions are AG Grid charts (Name + Model). ExternalChartDefinitions are application charts (Name + Data). A layout opens a saved chart by name.

Extends

BaseState

Wrappers around AG Grid Chart Models

ExternalChartDefinitions?

ExternalChartDefinition<unknown>[]

Definitions of External Charts

Chart Definition Object

ChartDefinition

An AG Grid chart saved in Adaptable State.

Distinguished from by Model. Name is unique and is how a layout opens the chart.

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

ChartingOptions

How charts are saved and where they open.

AG Grid chart definitions the user saves are stored in Charting state. These options decide whether that happens automatically, and which element a chart is drawn into.

Name shown for AG Grid's own chart window in the container list.

Default

'AG Grid Window'

Elements a saved chart can be drawn into, offered by name when the user opens a chart.

Omit this to open charts only in AG Grid's own window.

Show, hide, delete and preview for charts that are not AG Grid charts.

Required when the chart is drawn by the application. AdapTable calls these instead of opening an AG Grid chart.

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)

Default

undefined (no charts opened automatically)

Behaviour for saving Charts: auto, manual (via popup) or none

Default

'none'

Chart Containers

ChartContainer

Describes Location to display an AG Grid Chart

chartsDisplay?

'single' | 'multiple'

Whether 1 or more Charts can be displayed in same location

Default

'single'

element

HTMLElement | string

Location - can be HTMLElement or CSS Selector

name

string

Name of Container's Location - used in Dropdowns

Save Chart Behaviour

Value
'auto'
'manual'
'none'

External Charting Options

ExternalChartingOptions

Options for managing External (i.e. non AG Grid) Charts

Needs to be implemented to specify if Chart is opened; used to set Show Button's highlighting

Called when User deletes a persisted Chart

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

Called when User clicks on Show button next to Chart

Each callback receives an ExternalChartingContext:


Charting API

Hint

  • These functions make it easy to save and retrieves charts from Adaptable State
  • But in practice this is more likely to be done at run-time but charts can be defined at design time if required

ChartingApi

Charts saved in AdapTable, and external chart definitions. Includes which charts are open.

Add new Chart

Add new external chart definition

Close Chart definition

Delete external chart definition

Edit existing Chart

Edit existing external chart definition

Retrieves Chart definition by name

Retrieves Chart definition by uuid

Retrieves all adaptable Chart definitions

Get info about all saved charts, incl. their open state

getChartRef(chartId)
returns

ChartRef | undefined

The AG Grid chart reference for a chart AdapTable has open.

getCurrentChartModels()
returns

ChartModel[]

Retrieves current user-generated Charts

getExternalChartDefinitionByName(name)
returns

ExternalChartDefinition | undefined

An external chart definition looked up by name.

getExternalChartDefinitions()
returns

ExternalChartDefinition[]

Retrieves all adaptable external Chart definitions

Retrieve name of container in which Chart is open; returns null if Chart is not open

getPersistedCharts()
returns

ChartModel[]

Retrieves persisted Charts from Adaptable State

isChartingEnabled()
returns

boolean

Whether AdapTable's Charting functionality is available

Saves all current Charts into Adaptable State

Make a Chart Editable (i.e. not Read-Only)

Make a Chart Read-Only

Opens a Chart Definition

Displays a Chart; if Chart is already open, 2nd Chart is not opened

showPersistedCharts()
returns

ChartRef[]

Displays all persisted Charts


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:

This object contains a collection of ChartDisplayedInfo objects which contains details of displayed Charts:

ChartDisplayedInfo

One chart definition and whether it is displayed.

Chart definition this entry describes.

containerName

string | null

Name of the configured chart container whose element contains this chart.

Absent when the chart is closed, shown only in the AG Grid chart container, or no chart containers are configured.

isOpen

boolean

Whether AG Grid currently has this chart open.

chartingOpenState is a ChartingOpenState:

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
});