Charts can be customised in a number of ways to suit your applications' requirements.
Overriding Chart Options
The primary mechanism for customising charts is via the following
This callback is invoked once, before the chart is created, with
The params object contains a
type property corresponding to the chart about to be created, along with
ChartOptions that are about to be applied.
There are different available options to configure depending on the type of chart. Please refer to the relevant section below for more details:
- General Chart Customisation (these apply to all chart types)
- Bar/Column Chart Customisation
- Line Chart Customisation
- Scatter/Bubble Chart Customisation
- Area Chart Customisation
- Pie/Doughnut Chart Customisation
Example: Customising Charts
The example below demonstrates:
- Stacked Bar, Grouped Bar and Normalized Bar charts have the legend docked to the
- Stacked Column, Grouped Column and Normalized Column charts have the legend docked to the
- Line charts have the legend docked to the
- Scatter charts have the legend docked to the
- Pie charts have the legend docked to the
- Doughnut charts have the legend docked to the
Saving User Preferences
Formatting changes made by users through the Format Panel can be captured, saved and restored through the
ChartOptionsChanged event, see interface below:
chartPalette will be set to the name of the currently selected palette, which will be one of the following:
'borneo', 'material', 'pastel', 'bright', 'flat'
ChartRangeSelectionChanged event will also be raised any time the range that the chart is created from is changed,
whether by using the range selection handle or making changes in the Data tab of the configuration sidebar. This event contains
cellRange object that gives you information about the range and would allow you to recreate the chart:
Example: Saving User Preferences
The example below demonstrates how the
ChartOptionsChanged event can be used to save and restore
user chart formatting preferences. Notice the following:
- Saving Options by Chart Type: format changes (via the format panel) are preserved after leaving and
returning to the chart by using the
savedUserPreferenceByChartTypeobject to keep track of user format changes on a per-chart type basis.
- Saving Global Chart Options: changes made to the legend options are applied to all new charts by using
savedLegendUserPreferenceobject to globally keep track of legend preferences.