Chart
Displays a chart generated from data. Charts are rendered using the third-party Chart.js library (MIT license).
Chart types
The following chart types are supported:
linebar(vertical and horizontal)piedonut(nested pie chart)scatter(X/Y chart)bubble(scatter chart with varying bubble sizes)radar
Configuring data
The chart requires labels and one or more data series to be defined in order to display data. Series are specified as DataSeries objects. In a line chart, each line is one series. Each series normally gets its own color in the chart, except in the case of pie and donut charts, where each series is one full ring, and the colors are assigned to slices (data points) instead.
Data is provided to the chart using the data config. This should be an array of data Models or objects. Data points are drawn from individual fields in the records according to how the series of the chart are configured. For example, one line (series) in a line chart might show data values from the records' field FY2023, and a second line might show values from the field FY2024. In that case there would be two series defined on the chart, each with its field property set to "FY2023" or "FY2024" accordingly.
For chart types that combine multiple data values into a single series, like scatter or bubble, each series must also specify its role and seriesIndex. See DataSeries.
For charts with an X-axis (such as line and bar charts), the labels configuration specifies the data series to use as the ticks on the X-axis. For pie and donut charts, labels defines the slice labels.
The data config is also required; these are the records that supply the actual data values used in the chart.
Customizing appearance
Various configuration options allow you to change the look and feel of the chart. Chart elements can be turned on and off using showTitle, showSubtitle, showLegend, showAxes, and showControls. Spacing can be adjusted with chartPadding, titlePadding, and subtitlePadding. Fonts can be set with titleFont and subtitleFont. Data series line thickness, dash, and opacity can also be configured.
Try using the controls in the demo below to fine-tune the Chart appearance. To enable similar chart customization UI in your app, see the ChartDesigner widget.
Interactivity
By default, the chart can be downloaded as an image file using a button at the top right of the chart. To hide the download button, set showControls to false.
Tooltips appear as you mouse over data points on the chart. They can be disabled using showTooltips.
Animation
Animation is enabled by default. To disable animation, set animate to false.
See also: ChartDesigner.
Fields
Fields belong to a Model class and define the Model data structure-
(Optional) For
'bar'charts, the amount of the available bar area each bar in this series should occupy, from 0 to 1. Default: 0.9. -
The name of the record field containing the data for this series.
-
(Optional) The name of a field in the chart data to use as the background color for each data element (e.g. bar).
-
The name of the series to display in the legend.
-
(Optional) Required when using certain chart types, for example
scatter, where series can be arbitrarily assigned to different axes. Theroledetermines how this series is used in the chart.
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Basic type of chart.
Has a corresponding runtime chartType property.
-
The chart subtitle.
Has a corresponding runtime subtitle property.
-
The chart title.
Has a corresponding runtime title property.
-
Max value for the Y axis, for chart types that have one.
Has a corresponding runtime max property.
-
Min value for the Y axis, for chart types that have one.
Has a corresponding runtime min property.
-
Whether to show tick marks and labels on the chart axes.
Has a corresponding runtime showTicks property.
-
Set the color of the tick mark lines in the axis area, or
nullto default to axisColor.Has a corresponding runtime tickMarkColor property.
-
Where the chart's legend should appear relative to the main chart content. Options
inline-startandinline-endfunction as in CSS, with horizontal positioning controlled by RTL mode.Has a corresponding runtime legendPosition property.
-
Optional scale factor to increase or decrease the size of the chart legend.
Has a corresponding runtime legendScale property.
-
Whether to show all chart axes (
true), hide all axes (false), or an array indicating which axes to show. If array, valid elements are'x'and'y'.Has a corresponding runtime showAxes property.
-
The data records or objects containing data to display in the chart.
Has a corresponding runtime data property.
-
For line and bar charts, this series defines the data values to use as ticks for the x-axis. For pie and donut chart, it defines the data values to use as slice labels.
Has a corresponding runtime labels property.
-
One or more data series to display in the chart.
Has a corresponding runtime series property.
-
Chart tooltip configuration object. Configures the tooltip that appears when hovering over chart data points. This follows the Chartjs tooltip configuration specification. This will only be applied if showTooltips is
true.Has a corresponding runtime chartTooltip property.
-
Whether to do dynamic highlighting and other interactivity as the mouse cursor moves over the chart.
Has a corresponding runtime interactive property.
-
Whether to show tooltips when the mouse cursor hovers over chart elements.
Has a corresponding runtime showTooltips property.
-
Whether to animate chart data changes.
Has a corresponding runtime animate property.
-
Set the duration in milliseconds for all animations.
Has a corresponding runtime animationDuration property.
-
Layout direction for the bar chart type.
Has a corresponding runtime barDirection property.
-
Whether to show the chart's control button menu, for example, the download button.
Has a corresponding runtime showControls property.
-
Scale factor to apply to the computed size of bubbles in the bubble chart type.
Has a corresponding runtime bubbleScaleFactor property.
-
Radius of data points, in pixels.
Has a corresponding runtime pointSize property.
-
Whether to show data point markers on the chart.
Has a corresponding runtime showPoints property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Chart class, or subclass thereof.
-
Basic type of chart.
Has a corresponding chartType config.
-
The chart subtitle.
Has a corresponding subtitle config.
-
The chart title.
Has a corresponding title config.
-
Max value for the Y axis, for chart types that have one.
Has a corresponding max config.
-
Min value for the Y axis, for chart types that have one.
Has a corresponding min config.
-
Whether to show tick marks and labels on the chart axes.
Has a corresponding showTicks config.
-
Set the color of the tick mark lines in the axis area, or
nullto default to axisColor.Has a corresponding tickMarkColor config.
-
Where the chart's legend should appear relative to the main chart content. Options
inline-startandinline-endfunction as in CSS, with horizontal positioning controlled by RTL mode.Has a corresponding legendPosition config.
-
Optional scale factor to increase or decrease the size of the chart legend.
Has a corresponding legendScale config.
-
Whether to show all chart axes (
true), hide all axes (false), or an array indicating which axes to show. If array, valid elements are'x'and'y'.Has a corresponding showAxes config.
-
Identifies an object as an instance of Chart class, or subclass thereof.
-
The data records or objects containing data to display in the chart.
Has a corresponding data config.
-
For line and bar charts, this series defines the data values to use as ticks for the x-axis. For pie and donut chart, it defines the data values to use as slice labels.
Has a corresponding labels config.
-
One or more data series to display in the chart.
Has a corresponding series config.
-
Chart tooltip configuration object. Configures the tooltip that appears when hovering over chart data points. This follows the Chartjs tooltip configuration specification. This will only be applied if showTooltips is
true.Has a corresponding chartTooltip config.
-
Whether to do dynamic highlighting and other interactivity as the mouse cursor moves over the chart.
Has a corresponding interactive config.
-
Whether to show tooltips when the mouse cursor hovers over chart elements.
Has a corresponding showTooltips config.
-
Whether to animate chart data changes.
Has a corresponding animate config.
-
Set the duration in milliseconds for all animations.
Has a corresponding animationDuration config.
-
Layout direction for the bar chart type.
Has a corresponding barDirection config.
-
Whether to show the chart's control button menu, for example, the download button.
Has a corresponding showControls config.
-
Scale factor to apply to the computed size of bubbles in the bubble chart type.
Has a corresponding bubbleScaleFactor config.
-
Radius of data points, in pixels.
Has a corresponding pointSize config.
-
Whether to show data point markers on the chart.
Has a corresponding showPoints config.