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:

PropertyTypeDescription
chartingOpenStateChartingOpenStateDetails of Open Charts
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext

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

PropertyTypeDescription
chartDefinitionChartDefinitionDefinition of the Chart
containerNamestring | nullContainer where Chart is displayed
isOpenbooleanWhether 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:

PropertyTypeDescription
ChartDefinitionsChartDefinition[]Wrappers around AG Grid Chart Models
ExternalChartDefinitionsExternalChartDefinition<unknown>[]Definitions of External Charts

Chart Definition Object

A ChartDefinition simply wraps an AG Grid Charting Model:

PropertyTypeDescription
ModelChartModelAG Grid Chart Model
NamestringUnique name of the chart (used in UI and layout references, like Layout names)
IsReadOnlybooleanSets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full')

Charting Options

PropertyTypeDescriptionDefault
agGridContainerNamestringName of AG Grid Chart Container'AG Grid Window'
chartContainersChartContainer[]Locations to display saved Charts
externalChartingOptionsExternalChartingOptionsSet of properties for managing behaviour of external (i.e non AG Grid) charts
restoreChartsOnReadyboolean | '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)
saveChartBehaviourSaveChartBehaviourBehaviour for saving Charts: auto, manual (via popup) or none'none'

External Charting Options

PropertyTypeDescription
isChartOpened(context:ExternalChartingContext) => booleanNeeds to be implemented to specify if Chart is opened; used to set Show Button's highlighting
onDeleteChart(context:ExternalChartingContext) => voidCalled when User deletes a persisted Chart
onHideChart(context:ExternalChartingContext) => voidCalled when User clicks on Hide button next to Chart
onPreviewChart(context:ExternalChartingContext) => ExternalChartDefinitionShows Chart in Settings Panel preview (not saved into State); returned definition will be passed to 'onHideChart' when Preview closes
onShowChart(context:ExternalChartingContext) => voidCalled 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:

MethodReturnsDescription
addChartDefinition(chartDefinition)voidAdd new Chart
addExternalChartDefinition(chartDef, options)voidAdd new external chart definition
closeChartDefinition(chartDefinition)voidClose Chart definition
deleteExternalChartDefinition(chartDefinition)voidDelete external chart definition
editChartDefinition(chartDefinition)voidEdit existing Chart
editExternalChartDefinition(chartDef)voidEdit existing external chart definition
getChartDefinitionByName(name)ChartDefinition | undefinedRetrieves Chart definition by name
getChartDefinitionByUuid(uuid)ChartDefinition | undefinedRetrieves Chart definition by uuid
getChartDefinitions()ChartDefinition[]Retrieves all adaptable Chart definitions
getChartingOpenState()ChartingOpenStateGet info about all saved charts, incl. their open state
getChartRef(chartId)ChartRef | undefinedRetrieves AG Grid ChartRef for given ChartId
getCurrentChartModels()ChartModel[]Retrieves current user-generated Charts
getExternalChartDefinitionByName(name)ExternalChartDefinition | undefinedRetrieves Chart definition by name
getExternalChartDefinitions()ExternalChartDefinition[]Retrieves all adaptable external Chart definitions
getOpenChartContainer(chartDefinition)ChartContainer | nullRetrieve name of container in which Chart is open; returns null if Chart is not open
getPersistedCharts()ChartModel[]Retrieves persisted Charts from Adaptable State
isChartingEnabled()booleanWhether AdapTable's Charting functionality is available
saveCurrentCharts()voidSaves all current Charts into Adaptable State
setChartEditable(chartDefinition)voidMake a Chart Editable (i.e. not Read-Only)
setChartReadOnly(chartDefinition)voidMake a Chart Read-Only
showChartDefinition(chartDefinition, container)ChartRefOpens a Chart Definition
showChartDefinitionOnce(chartDefinition, container)ChartRef | undefinedDisplays a Chart; if Chart is already open, 2nd Chart is not opened
showPersistedCharts()ChartRef[]Displays all persisted Charts