Chart Series Palette Check
A four-line chart in three palettes, with a greyscale test and a measured lightness gap between the series.
AI prompt
Clean line chart with four series on a light grid, each line a different colour from the Okabe-Ito palette, deep blue, orange, bluish green and reddish purple, lines labelled directly at their right ends instead of a legend, thin axis lines, small grey tick labels, a side-by-side greyscale version showing each line still distinct, flat vector style, generous margins. Negative: rainbow gradients, 3D, red and green only, text errors, clutter. Reduced motion: static chart.About this pattern
Definition
Series colours in a chart must be told apart by more than hue. Colours with the same lightness merge in greyscale, in print and for many colour-blind readers. A good categorical palette varies in lightness, avoids red against green and is backed up by direct labels at the line ends.
When to use it
- Aim for a clear lightness gap between series, not only different hues.
- Use at most five to seven categories; beyond that, group or use small multiples.
- Label lines directly at their ends so the legend is optional.
- The Okabe-Ito set was designed to stay distinct under common colour vision differences.
What the controls do
- Three palette buttons and a Greyscale test checkbox with measured lightness gaps.
Motion & timing
- Changes are instant.
- Reduced motion: nothing animates.
Tips & variations
- Check the chart in greyscale and under a colour-blind simulation before shipping.
- Do not use colour as the only cue for important series; add dashes or markers.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Palette"><button data-p="0" aria-pressed="true">Equal lightness</button><button data-p="1" aria-pressed="false">Varied lightness</button><button data-p="2" aria-pressed="false">Okabe-Ito</button></div><svg class="ch" id="ch" viewBox="0 0 300 120" role="img" aria-label="Four series line chart"></svg><label class="sw"><input id="gs" type="checkbox"> Greyscale test</label><p class="out" id="out"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ch{width:100%;height:auto;border:1px solid var(--line);border-radius:12px;background:#fff;transition:filter .2s}.ch.g{filter:grayscale(1)}.ch text{font:10px system-ui,sans-serif;font-weight:600}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}@media (prefers-reduced-motion:reduce){.ch{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const PA=[['#e0525b','#3b9e5a','#3b7fd4','#b56ad1'],['#0b2a6b','#b0413e','#3aa17e','#f5d76e'],['#0072B2','#E69F00','#009E73','#CC79A7']],NM=['Alpha','Beta','Gamma','Delta'],DT=[[90,82,78,70,64,52],[96,92,88,90,84,80],[70,62,60,50,44,36],[50,52,40,38,30,20]],ch=document.getElementById('ch'),gs=document.getElementById('gs'),bs=[...document.querySelectorAll('#pre button')];let p=1;
const lum=h=>{const c=[1,3,5].map(i=>parseInt(h.substr(i,2),16)/255).map(v=>v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4));return .2126*c[0]+.7152*c[1]+.0722*c[2];},Ls=h=>{const y=lum(h);return y<=216/24389?y*24389/27:Math.cbrt(y)*116-16;};
function up(){let s='<line x1="30" y1="100" x2="240" y2="100" stroke="#ddd"/><line x1="30" y1="10" x2="30" y2="100" stroke="#ddd"/>';DT.forEach((d,i)=>{const pts=d.map((v,k)=>(30+k*42)+','+(100-v*.88)).join(' ');s+='<polyline points="'+pts+'" fill="none" stroke="'+PA[p][i]+'" stroke-width="2.5" stroke-linejoin="round"/><text x="246" y="'+(100-d[5]*.88+3)+'" fill="'+PA[p][i]+'">'+NM[i]+'</text>';});ch.innerHTML=s;ch.classList.toggle('g',gs.checked);
const L=PA[p].map(Ls);let mn=1e9;for(let i=0;i<4;i++)for(let j=i+1;j<4;j++)mn=Math.min(mn,Math.abs(L[i]-L[j]));document.getElementById('out').textContent='Smallest lightness gap between any two series: '+mn.toFixed(0)+' of 100. '+(mn<12?'Too close: lines can merge in greyscale, so add direct labels or dashes.':'Good separation in greyscale.');bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));gs.addEventListener('change',up);up();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Chart Series Palette Check — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ch{width:100%;height:auto;border:1px solid var(--line);border-radius:12px;background:#fff;transition:filter .2s}.ch.g{filter:grayscale(1)}.ch text{font:10px system-ui,sans-serif;font-weight:600}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}@media (prefers-reduced-motion:reduce){.ch{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Palette"><button data-p="0" aria-pressed="true">Equal lightness</button><button data-p="1" aria-pressed="false">Varied lightness</button><button data-p="2" aria-pressed="false">Okabe-Ito</button></div><svg class="ch" id="ch" viewBox="0 0 300 120" role="img" aria-label="Four series line chart"></svg><label class="sw"><input id="gs" type="checkbox"> Greyscale test</label><p class="out" id="out"></p></div>
</div>
<script>
const PA=[['#e0525b','#3b9e5a','#3b7fd4','#b56ad1'],['#0b2a6b','#b0413e','#3aa17e','#f5d76e'],['#0072B2','#E69F00','#009E73','#CC79A7']],NM=['Alpha','Beta','Gamma','Delta'],DT=[[90,82,78,70,64,52],[96,92,88,90,84,80],[70,62,60,50,44,36],[50,52,40,38,30,20]],ch=document.getElementById('ch'),gs=document.getElementById('gs'),bs=[...document.querySelectorAll('#pre button')];let p=1;
const lum=h=>{const c=[1,3,5].map(i=>parseInt(h.substr(i,2),16)/255).map(v=>v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4));return .2126*c[0]+.7152*c[1]+.0722*c[2];},Ls=h=>{const y=lum(h);return y<=216/24389?y*24389/27:Math.cbrt(y)*116-16;};
function up(){let s='<line x1="30" y1="100" x2="240" y2="100" stroke="#ddd"/><line x1="30" y1="10" x2="30" y2="100" stroke="#ddd"/>';DT.forEach((d,i)=>{const pts=d.map((v,k)=>(30+k*42)+','+(100-v*.88)).join(' ');s+='<polyline points="'+pts+'" fill="none" stroke="'+PA[p][i]+'" stroke-width="2.5" stroke-linejoin="round"/><text x="246" y="'+(100-d[5]*.88+3)+'" fill="'+PA[p][i]+'">'+NM[i]+'</text>';});ch.innerHTML=s;ch.classList.toggle('g',gs.checked);
const L=PA[p].map(Ls);let mn=1e9;for(let i=0;i<4;i++)for(let j=i+1;j<4;j++)mn=Math.min(mn,Math.abs(L[i]-L[j]));document.getElementById('out').textContent='Smallest lightness gap between any two series: '+mn.toFixed(0)+' of 100. '+(mn<12?'Too close: lines can merge in greyscale, so add direct labels or dashes.':'Good separation in greyscale.');bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));gs.addEventListener('change',up);up();
</script>
</body></html>