Chart legend
The legend tells the reader which colour is which dataset. Move it, hide it, or change how its entries look.
The legend is the legend plugin, options.plugins.legend. Each entry's text is the dataset's label; on a pie, doughnut or polar area chart there is one entry per slice, and its text comes from data.labels. The theme shows the legend at the top left when a dataset has a label or there is more than one dataset, and on the right for pie, doughnut and polar area charts. Anything you set wins.
Legend at the bottom
position takes top, bottom, left or right. The theme puts the legend at the top left.

The part of the config that matters
{
"options": {
"plugins": {
"legend": {
"position": "bottom"
}
}
}
}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%22plugins%22%3A%7B%22legend%22%3A%7B%22position%22%3A%22bottom%22%7D%7D%7D%7DLegend on the right
On the left or the right the entries stack in a column and the plot gets narrower.

The part of the config that matters
{
"options": {
"plugins": {
"legend": {
"position": "right"
}
}
}
}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%22plugins%22%3A%7B%22legend%22%3A%7B%22position%22%3A%22right%22%7D%7D%7D%7DNo legend
display false removes it. Do this when the title already says what the line is.

The part of the config that matters
{
"options": {
"plugins": {
"legend": {
"display": false
}
}
}
}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%22Signups%22%2C%22data%22%3A%5B24%2C37%2C31%2C45%2C39%2C52%5D%7D%5D%7D%2C%22options%22%3A%7B%22plugins%22%3A%7B%22title%22%3A%7B%22display%22%3Atrue%2C%22text%22%3A%22Signups%20per%20week%22%7D%2C%22legend%22%3A%7B%22display%22%3Afalse%7D%7D%7D%7DMarkers, text and alignment
The theme draws round markers. pointStyle changes their shape, boxWidth and boxHeight their size, font the text, and align moves the row to start, center or end.

The part of the config that matters
{
"options": {
"plugins": {
"legend": {
"align": "end",
"labels": {
"pointStyle": "rect",
"boxWidth": 12,
"boxHeight": 12,
"font": {
"size": 14
}
}
}
}
}
}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%22plugins%22%3A%7B%22legend%22%3A%7B%22align%22%3A%22end%22%2C%22labels%22%3A%7B%22pointStyle%22%3A%22rect%22%2C%22boxWidth%22%3A12%2C%22boxHeight%22%3A12%2C%22font%22%3A%7B%22size%22%3A14%7D%7D%7D%7D%7D%7DThings to know
positionistop,bottom,leftorright.alignisstart,centerorend, along that side.display: falseworks on every chart type, pie included. Without a legend, say what the colours mean in the title or in the data labels.- Clicking an entry to hide a dataset is a browser feature. In a PNG every dataset is drawn. To leave one out, leave it out of the config.
legendis an object. A list there is a 400 with the messageoptions.plugins.legend must be an object.
More options
- Chart title and subtitle: A title, a subtitle, where they sit and how big they are.
- Chart axes: Minimum and maximum, stacked bars, a horizontal chart, hiding an axis, units.
- 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.