Charts That Don't Rely on Color in Chart.js
Three small changes that make every line identifiable for colorblind users, in grayscale, and on a bad projector
Most line charts tell their series apart with color alone. Red is North, green is South, blue is West, and the legend is the key. That works until someone can't tell those colors apart. About 1 in 12 men and 1 in 200 women have some form of color vision deficiency, and red–green is the most common. Add printouts, grayscale PDFs, and washed-out conference-room projectors, and "the green line" stops being a reliable way to read a chart.
Here's a typical Chart.js line chart, shown in color and in grayscale:

In grayscale, the legend swatches for South and West are identical, and where the lines cross in May there's no way to tell which is which. The three colors look very different, but they're almost the same lightness, which is exactly what color vision deficiencies and grayscale output take away.
WCAG says the same thing in two rules: color can't be the only way information is conveyed (1.4.1, Use of Color), and the parts of a graphic needed to understand it need at least 3:1 contrast against their background (1.4.11, Non-text Contrast).
The fix: give each series more than one difference
Color can stay. It just shouldn't work alone. Chart.js already has everything needed:
- Point shapes (
pointStyle): a circle, a triangle, and a diamond are different in any color - Dash patterns (
borderDash): solid, dashed, and dotted lines are different even between the points - Direct labels: the series name at the end of each line, so nobody has to match a swatch to a legend
- Point shapes and dash patterns
const styles = [
{ color: '#0072B2', pointStyle: 'circle', borderDash: [] }, // solid
{ color: '#D55E00', pointStyle: 'triangle', borderDash: [8, 4] }, // dashed
{ color: '#009E73', pointStyle: 'rectRot', borderDash: [2, 3] } // dotted
];
const datasets = series.map((s, i) => ({
label: s.label,
data: s.values,
borderColor: styles[i].color,
backgroundColor: styles[i].color,
pointStyle: styles[i].pointStyle,
borderDash: styles[i].borderDash,
pointRadius: 6,
borderWidth: 2.5
}));
rectRot is a square rotated 45°, which reads as a diamond. Bump pointRadius up from the default of 3: at 3px, a triangle and a circle look alike.
The colors here come from the Okabe–Ito palette, designed to stay distinguishable for the common types of color vision deficiency. All three also clear 3:1 contrast against a white background, so the lines themselves meet WCAG 1.4.11. A colorblind-safe palette helps, but it's the shapes and dashes that make the chart work for everyone.
- Direct labels instead of a legend
A legend makes the reader look away from the data, find a swatch, and look back. Labeling each line where it ends removes that step. Chart.js has no built-in option for it, but a small plugin does the job:
const directLabels = {
id: 'directLabels',
afterDatasetsDraw(chart) {
const { ctx } = chart;
chart.data.datasets.forEach((dataset, i) => {
if (!chart.isDatasetVisible(i)) return;
// The last point of this line, in canvas pixels
const last = chart.getDatasetMeta(i).data.at(-1);
ctx.save();
ctx.font = '600 14px Roboto, Arial, sans-serif';
ctx.fillStyle = '#111827';
ctx.textBaseline = 'middle';
ctx.fillText(dataset.label, last.x + 12, last.y);
ctx.restore();
});
}
};
afterDatasetsDraw runs once the lines are drawn, and getDatasetMeta(i).data holds each point's pixel position. The labels use dark text instead of the series color, so they stay readable no matter which colors you pick.
new Chart(canvas, {
type: 'line',
data: { labels, datasets },
plugins: [directLabels],
options: {
layout: { padding: { right: 56 } }, // room for the labels
plugins: {
legend: { display: false }, // the labels replace it
tooltip: { usePointStyle: true } // tooltip shows the shape, not just a color box
}
}
});
If you keep a legend (for example, when lines end too close together to label), set legend.labels.usePointStyle: true so it shows each series' shape instead of a colored rectangle.
The result

Same data, same colors in spirit, but now every line can be identified three ways. In grayscale, the crossing in May is still easy to follow: the dashed line with triangles is South, the dotted line with diamonds is West.
Testing it
- Chrome DevTools can simulate color vision deficiencies: open the Command Menu, run Show Rendering, and pick an option under Emulate vision deficiencies. Achromatopsia (no color at all) is the toughest test.
- A quick CSS check:
canvas { filter: grayscale(1); }in DevTools shows the grayscale version of any chart instantly. - The squint test: if you can't tell the series apart with your eyes half closed, neither can someone on a dim projector.
Lessons learned
- Different hues aren't enough. Colors that look nothing alike can have the same lightness, and lightness is what survives grayscale and most color vision deficiencies.
- Layer the differences. Shape, dash pattern, and label each work on their own, so no single one has to carry the chart.
- Label the data, not a key. Direct labels are faster to read for everyone, not just colorblind users.
- Check the tooltip and legend too. Both default to color swatches;
usePointStylefixes them.
Conclusion
Making a chart readable without color takes a few dataset options and a 15-line plugin. Nothing about the design has to get worse, and the chart gets easier to read for everyone, including the person viewing your dashboard on a grayscale printout.
Let me know if you found this useful. Feel free to reach out to me with any questions on LinkedIn.