Attributes
Every data attribute on a chart, a row and an annotation.
On the figure
| Attribute | Does |
|---|---|
data-chart |
Makes the figure a chart: column, bar, line, area, waterfall, donut or pie, or scatter or candlestick from the additional types |
data-chart-src |
Reads the data from a JSON file or API endpoint. See Data from a file or API. |
data-chart-transform |
The transform for the JSON of data-chart-src, by its name in the transforms option. none reads the JSON as it is. See What if my API gives other JSON? |
data-chart-stack |
Puts the values of a row on top of each other, in a column, bar, line or area chart |
data-chart-shape="step" |
Makes each value flat across its row, in a line or area chart |
data-chart-group |
On a figure or an element around it: charts side by side get names of one height, so their baselines line up. With a name, such as data-chart-group="sales", charts in different places are one group |
data-chart-group-scale |
Next to data-chart-group: the charts of the group share one scale, so the same value is the same height |
data-chart-ticks="false" |
Omits the ticks above the names under a line or area chart |
data-chart-values="auto" |
Which values a line or area chart shows: auto, all, none, or a set such as first last highest lowest outliers. auto last shows all if they fit, and else the last. See Which values are shown. |
data-chart-shape="smooth" |
Makes a line or area chart a curve through every point. data-chart-shape="straight" makes it straight when the shape option is "smooth". |
data-chart-animate="grow" |
How the chart builds: grow, each element from zero, or sweep, in one movement. false shows the chart from the start, without animation. See Animation. |
data-fragment |
On the figure, every row is a step; on a row, a column header or an annotation, that one is. See Step by step. |
data-fragment-index |
Rows with the same index arrive on the same step |
data-chart-entrance="0.25" |
How far an element around the chart that animates in is in before the chart builds, from 0 to 1. See Animated parents. |
data-chart-legend |
Puts the names of the lines in a legend. data-chart-legend="false" turns it off. With data-chart-legend="toggle", a click on a name turns its series off and on. See Turn series off and on. |
data-chart-lines |
The look of each next line, as a JSON list, also on an element around the figure. See Your own order |
data-chart-labels |
Puts the numbers of a column or bar chart inside or outside the columns or bars. On a pie, the numbers are inside where they fit; outside puts them all next to their slices. |
data-chart-aspect |
Sets the height of the chart as a share of its width, such as 0.5 |
data-chart-tooltip="auto" |
The tooltip of the chart: auto only when the chart does not show all its numbers, false never, true always, crosshair a line through the place you hover over, with its values at the side, on a line, area or candlestick chart. |
data-chart-croptext |
The line under a candlestick chart whose first rows are cropped, with {shown} and {rows}. It overrides the croptext option. See The chart will be cropped. |
data-chart-table="auto" |
When the table is shown under the chart: always, print, auto (in print, when the chart does not show all its numbers and the table is not too long) or never |
data-chart-ordered |
Says that the rows are in order, such as months, so a summary can have a change, a trend and outliers. Line, area and candlestick charts are always in order. |
data-chart-summary="auto" |
When the summary is shown: always, print, auto (in print, when the chart does not show all its numbers and its table is not printed) or never. See Summary. |
data-chart-axis |
Adds numbers along the value axis of a column, bar, line, area or waterfall chart; a candlestick chart has them by default. data-chart-axis="right" puts them on the right of an upright chart, and "left" on the left. data-chart-axis="false" turns them off when the axis option is true. |
data-chart-grid |
Adds a light line at each number of the value axis, or of both axes on a scatter chart. data-chart-grid="false" turns it off when the grid option is true. |
data-chart-scale="0 100" |
Where the value axis starts and ends, or with three numbers or more, the numbers along it. On a scatter chart it is the axis up, and data-chart-scale-y is another name for it. See The scale. |
data-chart-scale-x="0 100" |
The same, for the axis across |
data-chart-names="false" |
Turns off the names next to the markers of a scatter chart |
data-chart-keys |
Adds translation keys to the names, starting with its value. See Translation. |
On a row
| Attribute | Does |
|---|---|
data-kind="total" |
Makes the row a total, in a waterfall or a donut |
class |
Is copied to the bar, the number and the name of the row |
data-value="show" |
On the tr of a row: on a line or area chart, its value is always shown |
data-short |
On the th of the row: a short name for under the chart, such as Nov ’21 for November 2021. See Short names. |
On a column header
| Attribute | Does |
|---|---|
data-kind="focus" |
Highlights the line or the bars of this column. The others are shown fainter. |
data-marker |
Sets the point of the line: circle, square or diamond, with open for an open point, or none for no points. See Your own order |
data-line |
Makes the line dashed, dotted or dash-dot. See Your own order |
data-chart="line" |
On a column chart: shows this column as a line over the columns, on the same scale. See Columns and a line. |
data-axis="right" |
On a column, line or area chart: this column gets a value axis of its own, on the right, with its own scale. See Two value axes. |
data-note |
The cells of this column are notes, not values: each one is a note at its row on the chart. See Notes. |
data-group |
On a scatter chart: the cells of this column name the groups. Each group has its own colour and shape. See Scatter. |
On a sentence of a summary
Each sentence is an element in a div with the class chart-summary. See Summary.
| Attribute | Does |
|---|---|
data-series="2" |
Makes the sentence about the second value column. Without it, it is about the first. |
data-summary="range" |
Shows the sentence only if that part of the summary has a result: extremes, range, change, trend, outliers or notes |
data-none |
With data-summary: shows the sentence only if there is no result |
data-when="up" |
With data-summary="change" or "trend": shows the sentence only for up, down or flat, or for a trend also unclear |
data-each="outliers" |
On an element in the sentence: repeats it for each outlier, or with data-each="notes" for each note, joined as a list |
On an annotation
Each annotation is a span with data-annotation, in a div with the class chart-annotations. See Annotations.
| Annotation | Attribute | Sets |
|---|---|---|
bracket |
data-from, data-to |
The rows the bracket runs between. The first row is 1. |
trend |
data-at |
Where the badge is along the arrow, from 0 to 1 |
trend |
data-years |
The number of years, to check the yearly rate you wrote |
axis-break |
data-from, data-to |
The part of the scale that is made smaller |
axis-break |
data-size |
The share of the height that part gets, as a percentage |
axis-break |
data-mark |
How the break is shown: two slanted lines by default, or zigzag. See Scale break. |
reference |
data-value |
A line at a value on the value axis: a number, mean or median of the values |
reference |
data-name |
A line among names that are numbers: a number, mean or median, with each name counted as often as its value |
reference |
data-axis="y" |
On a scatter chart, puts the line across, at a value on the axis up |
reference |
data-line |
dotted makes the line dotted. It is dashed by default. |
quadrant |
data-x, data-y |
On a scatter chart: where the line up and the line across are, as a number, mean or median. Without them, the middle of the axis. |
quadrant |
data-corner |
On an element in the annotation: the corner of its name, such as top right |
| All | data-series |
The line the annotation uses, on a chart with several lines. The first line is 1. |
Set by Tablechart
Tablechart adds these attributes. You can use them in CSS.
| Attribute | On | Says |
|---|---|---|
data-row |
Bars, numbers | The row, counted from 1 |
data-series |
Lines, points, bars, numbers, names | The value column, counted from 1 |
data-slice |
Donut slices | The slice, counted from 1 |
data-marker, data-open |
Points | The shape of the point, and if it is open |
data-left-out |
Numbers | The chart has to omit the number, for lack of room |
Next
For the options of init(), see Options.