Configuring colors
Chart.js supports standard HTML/CSS color names and codes (see Chapter 2, Technology Fundamentals), which are assigned to properties that control fonts, strokes (lines, and borders), and fills. You can select a color by its name (for example, red), hexadecimal code (#f00, #ff0000), or three-argument generator functions that receive RGB or HSL components (rgb(255,0,0), or hsl(0,100%,50%)). CSS color generator functions also include a four-argument version that controls transparency with the alpha component ('rgba(255,0,0,1)', or 'hsla(0,100%,50%,1)').
The Chart.defaults.global.defaultColor property sets a default color for all the chart components, but it is mostly overridden by the default configurations for fonts, scales, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access