Chart Color System

v0.1.2
io.github.socraticstatic/chart-color-system Checked 3 hours ago Published 1 month ago

Solve, audit and simulate colorblind-safe chart palettes.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

solve_palette Solve a chart palette

Generate a categorical chart palette of n colors (1-12) that maximizes perceptual separation under normal vision and colorblindness, with the given brand colors locked as anchors in slot order. Returns the palette, the worst pair distances, the engine's relaxation notes, a full accessibility audit against the background, and a link to open it in the app. Honest cap is 6 slots; above that the result says so.

ParameterTypeDescription
anchorsarrayBrand or required colors, kept exactly, in slot order (CSS syntax)
backgroundstringChart background color
gridstringGridline color; defaults to a light or dark gray to match the background
nintegerNumber of categorical slots
posturestringkpi: few strong colors; comparative: balanced; exploratory: many muted

audit_palette Audit a chart palette

Audit existing chart colors for accessibility: pairwise OKLab separation under normal vision, deuteranopia, protanopia, tritanopia and achromatopsia, plus WCAG 2.2 non-text contrast (3:1) of every color against the chart background. A translucent color is composited over the background first and reported as rendered. Returns a pass / warn / fail verdict with the numbers behind it. Set ramp=true for sequential or diverging scales, whose steps are meant to be close.

ParameterTypeDescription
colors *arrayPalette colors in slot order (CSS syntax)
backgroundstringChart background color
rampbooleantrue for a sequential or diverging scale (skips pairwise separation)

simulate_palette Simulate colorblind vision

Show what each color looks like to readers with deuteranopia, protanopia, tritanopia or achromatopsia (published Machado 2009 matrices), so an assistant can describe or render the palette as a colorblind reader sees it.

ParameterTypeDescription
colors *arrayColors in slot order (CSS syntax)
modesarrayVision modes to simulate; default all

build_ramp Build a sequential or diverging ramp

Build an evenly spaced perceptual (OKLab) color scale: sequential from start to end, or diverging from start through mid to end. Returns the steps and a background-contrast audit (pairwise separation is not judged for ramps).

ParameterTypeDescription
end *stringLast color (or the positive end)
kind *string
start *stringFirst color (or the negative end of a diverging scale)
backgroundstring
midstringMiddle color for a diverging scale; default a neutral near the background
stepsinteger