// Design tokens as colours a can paint with. A chart is drawn on a // canvas, which can't read var(--green), so each token is resolved through a // hidden element to the rgb() the browser computed for it. // // Loaded after the stylesheets (a script waits for the sheets above it), so the // tokens are defined by the time this runs. It also gives every Chart.js chart // the page's text and grid colours, so a chart config only names its series. (function () { function stewardColor(name) { var probe = document.createElement('span'); probe.style.display = 'none'; probe.style.color = 'var(' + name + ')'; document.documentElement.appendChild(probe); var value = getComputedStyle(probe).color; probe.remove(); return value; } window.stewardColor = stewardColor; if (window.Chart) { Chart.defaults.color = stewardColor('--text-muted'); Chart.defaults.borderColor = stewardColor('--border'); } })();