Option reference

Chart colors

Colour a dataset, a single bar, or the whole chart: in the config, with a theme or a palette of your own, and behind it with a background.

A colour is decided in this order. A dataset's own backgroundColor and borderColor come first. A dataset with none takes the next colour of the palette you gave, or, without one, of the theme. With neither, the default theme draws blue first, then orange. The background, bkg, is white unless you set it, and the text and the grid turn light when it is dark.

The numbers in the images are sample data. Each image is what the URL under it returns.

A colour for each dataset

backgroundColor fills the bars and borderColor draws their edge. Any CSS colour string works, including rgba for transparency.

Bar chart with a dark green web dataset and a semi-transparent orange app dataset with a solid orange border
Open in the editor

The part of the config that matters

{
  "data": {
    "datasets": [
      {
        "backgroundColor": "#0b5d3b"
      },
      {
        "backgroundColor": "rgba(184, 67, 15, 0.35)",
        "borderColor": "#b8430f",
        "borderWidth": 2
      }
    ]
  }
}

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%2C%22backgroundColor%22%3A%22%230b5d3b%22%7D%2C%7B%22label%22%3A%22App%22%2C%22data%22%3A%5B12%2C18%2C22%2C21%2C30%2C34%5D%2C%22backgroundColor%22%3A%22rgba(184%2C%2067%2C%2015%2C%200.35)%22%2C%22borderColor%22%3A%22%23b8430f%22%2C%22borderWidth%22%3A2%7D%5D%7D%7D

A colour for each bar

A list of colours on one dataset colours its bars, slices or points in order. Use it to mark one bar.

Bar chart of signups per week where the last bar is orange and the others are grey
Open in the editor

The part of the config that matters

{
  "data": {
    "datasets": [
      {
        "backgroundColor": ["#85878c", "#85878c", "#85878c", "#85878c", "#85878c", "#b8430f"]
      }
    ]
  }
}

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%2C%22backgroundColor%22%3A%5B%22%2385878c%22%2C%22%2385878c%22%2C%22%2385878c%22%2C%22%2385878c%22%2C%22%2385878c%22%2C%22%23b8430f%22%5D%7D%5D%7D%7D

A theme with theme=

theme= picks one of six palettes for datasets that set no colour. The parameter sits beside c; the config can say the same in options.plugins.chartpng.theme.

Bar chart of web and app signups per week drawn in the colorblind theme, blue and orange

The part of the config that matters, and the parameter beside it

{
  "data": {
    "datasets": [
      {
        "label": "Web"
      },
      {
        "label": "App"
      }
    ]
  }
}

Added to the URL, beside c: theme=colorblind

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%7D&theme=colorblind

A palette with palette=

palette= is a list of 1 to 12 hex colours that replaces the theme colours, in order. Write the # as %23 or leave it out.

Bar chart of web and app signups per week drawn with a navy and a terracotta palette

The part of the config that matters, and the parameter beside it

{
  "data": {
    "datasets": [
      {
        "label": "Web"
      },
      {
        "label": "App"
      }
    ]
  }
}

Added to the URL, beside c: palette=0b3d91,c4502a

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%7D&palette=0b3d91,c4502a

The background with bkg=

bkg= is the colour behind the chart, white by default. A dark colour turns the text and the grid light.

Bar chart of web and app signups per week on a near-black background with light text

The part of the config that matters, and the parameter beside it

{
  "data": {
    "datasets": [
      {
        "label": "Web"
      },
      {
        "label": "App"
      }
    ]
  }
}

Added to the URL, beside c: bkg=%23111215

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%7D&bkg=%23111215

Things to know

More options