Charts
A Chart renders a data visualization from a JSON definition. The definition describes what to plot, type, title, theme, categories and series, while the API controls only the size.
See chart definition JSON for the full definition specification.
The definition
The definition is a JSON string. Rather than hand-escaping JSON in string literals, we recommend building it with your JSON library of choice and passing the serialized result.
{
"chartType": "bar",
"title": "Revenue by region (thousands CAD)",
"theme": "nature",
"data": {
"categories": { "data": ["Q1", "Q2", "Q3", "Q4"] },
"series": [
{ "name": { "data": ["North America"] }, "data": { "data": [1250, 1410, 1580, 1720] } },
{ "name": { "data": ["Europe"] }, "data": { "data": [910, 980, 1120, 1180] } },
{ "name": { "data": ["Asia Pacific"] }, "data": { "data": [640, 720, 905, 1010] } }
]
}
}Add a chart
AddChart takes the size in points and the definition string.
Since the chart lives in a paragraph, it is positioned like any other inline content. Paragraph justification centers it, and a caption is simply the next paragraph.
Chart types
Three chart families are available: Bar, pie, and radar. The full option set for each is documented in Chart Definition JSON.
Bar
A bar chart is a clustered column chart with a category axis, a value axis, gridlines and a legend. Individual series can be switched to lines with "line": true, so columns and lines can be mixed in one chart.

Pie
A pie chart is a single-series proportional chart. When the definition creates more than one series, a doughnut hole is applied automatically.

Radar
A radar chart is a polar chart where every category is an axis radiating from the center. Radar series are always rendered as lines, which suits scorecards and multi-dimensional comparisons.

Themes
The theme member applies a named palette to the series. Omit the theme to use the default palette. Options include:
pastelgrayscalevividnaturesunset

Sizing
Chart size is not part of the definition. Pass it to AddChart, or change it later with SetWidth and SetHeight; the definition is unaffected.
Give charts enough room: titles, axis labels and legends are laid out inside the requested box, so a chart that is too small will crowd them.
Replace the definition
SetDefinition replaces the chart entirely. Any previously applied definition and styling derived from it is discarded, but the width and height are preserved.
Further Reading
Chart definition JSON for the complete definition specification, including series options and trendlines.
Tables for presenting the same data numerically.
Last updated
Was this helpful?