Chart axes
Axes set what range the numbers are read against. Fix their ends, stack the bars, turn the chart on its side, or hide an axis.
Axes are options.scales, with one entry per axis. A bar, line, scatter or bubble chart has x and y; a radar and a polar area chart have r. On a bar chart, x holds the labels and y the numbers. In a line chart the value axis starts near the lowest number unless you set beginAtZero: true; in a bar chart it starts at zero. The theme draws only the horizontal grid lines and aims for about six ticks.
Minimum, maximum and a title
min and max fix the ends of an axis. title.text names it, which is where a unit goes.

The part of the config that matters
{
"options": {
"scales": {
"y": {
"min": 0,
"max": 100,
"title": {
"display": true,
"text": "Done (%)"
}
}
}
}
}The full URL
https://chartpng.dev/chart?w=480&h=280&dpr=2&c=%7B%22type%22%3A%22line%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22W1%22%2C%22W2%22%2C%22W3%22%2C%22W4%22%2C%22W5%22%2C%22W6%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Tasks%20done%22%2C%22data%22%3A%5B62%2C68%2C71%2C66%2C79%2C84%5D%7D%5D%7D%2C%22options%22%3A%7B%22scales%22%3A%7B%22y%22%3A%7B%22min%22%3A0%2C%22max%22%3A100%2C%22title%22%3A%7B%22display%22%3Atrue%2C%22text%22%3A%22Done%20(%25)%22%7D%7D%7D%7D%7DStacked
stacked on both axes puts the datasets on top of each other. The number above a bar is still the value of its own dataset.

The part of the config that matters
{
"options": {
"scales": {
"x": {
"stacked": true
},
"y": {
"stacked": true
}
}
}
}The full URL
https://chartpng.dev/chart?w=480&h=280&dpr=2&c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22W1%22%2C%22W2%22%2C%22W3%22%2C%22W4%22%2C%22W5%22%2C%22W6%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Web%22%2C%22data%22%3A%5B24%2C37%2C31%2C45%2C39%2C52%5D%7D%2C%7B%22label%22%3A%22App%22%2C%22data%22%3A%5B12%2C18%2C22%2C21%2C30%2C34%5D%7D%5D%7D%2C%22options%22%3A%7B%22scales%22%3A%7B%22x%22%3A%7B%22stacked%22%3Atrue%7D%2C%22y%22%3A%7B%22stacked%22%3Atrue%7D%7D%7D%7DA horizontal chart
indexAxis y turns the bars sideways. The categories are now on y and the numbers on x, so the value axis options go under x.

The part of the config that matters
{
"options": {
"indexAxis": "y",
"scales": {
"x": {
"min": 0,
"max": 60
}
}
}
}The full URL
https://chartpng.dev/chart?w=480&h=280&dpr=2&c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22W1%22%2C%22W2%22%2C%22W3%22%2C%22W4%22%2C%22W5%22%2C%22W6%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Signups%22%2C%22data%22%3A%5B24%2C37%2C31%2C45%2C39%2C52%5D%7D%5D%7D%2C%22options%22%3A%7B%22indexAxis%22%3A%22y%22%2C%22scales%22%3A%7B%22x%22%3A%7B%22min%22%3A0%2C%22max%22%3A60%7D%7D%7D%7DHiding an axis and its grid
display false on an axis removes its line, its ticks and its labels. grid.display false removes only the lines across the plot. The theme still prints each value on its bar.

The part of the config that matters
{
"options": {
"scales": {
"y": {
"display": false
},
"x": {
"grid": {
"display": false
}
}
}
}
}The full URL
https://chartpng.dev/chart?w=480&h=280&dpr=2&c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22W1%22%2C%22W2%22%2C%22W3%22%2C%22W4%22%2C%22W5%22%2C%22W6%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Signups%22%2C%22data%22%3A%5B24%2C37%2C31%2C45%2C39%2C52%5D%7D%5D%7D%2C%22options%22%3A%7B%22scales%22%3A%7B%22y%22%3A%7B%22display%22%3Afalse%7D%2C%22x%22%3A%7B%22grid%22%3A%7B%22display%22%3Afalse%7D%7D%7D%7D%7DMore axis options
beginAtZero: trueon an axis starts it at zero.minandmaxfix the ends exactly; the theme adds a little room above the tallest bar for its value.ticks.maxTicksLimitcaps how many ticks an axis draws, andticks.countasks for a number of them. Both are at most 100; a larger number is a 400.ticks.display: falsekeeps the axis and hides its numbers.title.displaywithtitle.textnames an axis.
Units on the ticks
A prefix or a suffix on every tick, such as $ or %, is a tick callback in Chart.js, and a callback is code, which ChartPNG removes from a config. Put the unit in the axis title, as in the first example, or in the labels. The ranking, funnel, gauge and KPI presets take prefix and suffixfor the numbers they print: see report presets and the ranking chart.
Text on chosen ticks
A linear or logarithmic axis takes ticks.labels, a map from a value to the text drawn at it, as data instead of a callback:{ "scales": { "x": { "min": 0, "max": 2, "ticks": { "labels": { "0": "0", "1.7": "+50 %" } } } } }. The axis then shows ticks at exactly those values, with that text, and no other. A value outside the axis is not drawn, so set min and max to bring it in. At most 50 entries, and the keys are numbers; anything else, or a category axis, is a 400 with the code tick_labels.
Text on the chart
A label by each point comes from the datalabels plugin: set options.plugins.datalabels.display to true (or "auto" to hide labels that overlap) and give each point alabel, as in { "x": 4, "y": 120, "r": 8, "label": "Zontes +128 %" }. Nothing is drawn until you turn it on. Lines, boxes and captions on the plot come from options.plugins.annotation.annotations, at most 50, with text as a string or a list of strings in content. An image, a handler such as click or enter, or any other kind of content is a 400. Both are in the@chartpng/render README with a worked example.
What does not work
- A time axis,
type: 'time', needs a date adapter, which ChartPNG does not have, so it is refused with a 400. Send the dates as labels on the default category axis. - An axis type Chart.js does not know is a 400 that lists the types that are accepted.
More options
- Chart title and subtitle: A title, a subtitle, where they sit and how big they are.
- Chart legend: Move it to the bottom or the right, hide it, change its markers.
- Chart colors: Dataset colours, the theme and palette parameters, and the background.
- Chart image size: Width, height and dpr, and the limits on them.
- Chart gallery: every chart type, with its config and URL.
- API reference: every parameter of
/chart, the limits and the errors.