Class ChartPalette
Theme.
The two sets are the same eight hues stepped for their surface, not two unrelated
palettes, and the order is the mechanism, not decoration: it was chosen so that
every adjacent pair stays apart under simulated protanopia and deuteranopia
(OKLab ΔE ≥ 8) as well as under normal vision (ΔE ≥ 15), because adjacent slots are the
pairs a stacked bar, a grouped bar and a legend actually put side by side. Reordering
the slots or editing a hex breaks that guarantee; ChartPaletteTest pins the
values so the break is a test failure rather than a silent regression.
What a chart draws by default is held to 3:1 on the palette's surfaces, as WCAG
2.1 1.4.11 asks of a mark that is needed to read the chart: defaultFor(limn.components.Theme)
moves each slot in OKLab lightness alone, keeping its hue and its chroma where the gamut
allows, darker in a light palette and lighter in a dark one, only until it clears 3:1 on the
canvas, a card and a popover; then it moves an adjacent pair further apart wherever the move
brought it under the separation above. Four of the light slots and one of the dark sit below
3:1 as written, on most palettes' surfaces. forLightSurface() and
forDarkSurface() keep the slots as written. A palette of your own is used as given:
hold it to 3:1 yourself, or let a legend and the tooltip name every series.
Past the last slot the palette repeats, shading each repeat alternately toward white and black. That keeps a ninth series drawable, but two series then differ only by lightness: at that point fold the tail into an "Other" series, or split the chart.
chart.setPalette(ChartPalette.of(Color.rgb(0x4C8DFF), Color.rgb(0xF472B6)));
-
Method Summary
Modifier and TypeMethodDescriptioncolor(int index) The color for slotindex.colors()The slots, in assignment order.static ChartPalettedefaultFor(Theme theme) The built-in set fortheme's mode, solved for its surfaces: what a chart uses unless told otherwise.static ChartPaletteThe built-in slots for a dark surface.static ChartPaletteThe built-in slots for a light surface.static ChartPaletteof(Color...)over a list; the list is copied.static ChartPaletteA palette over the given colors, in the order they will be assigned.intsize()How many distinct slots this palette declares.
-
Method Details
-
of
A palette over the given colors, in the order they will be assigned.- Throws:
IllegalArgumentException- if no color is given
-
of
of(Color...)over a list; the list is copied. -
forLightSurface
The built-in slots for a light surface. -
forDarkSurface
The built-in slots for a dark surface. -
defaultFor
The built-in set fortheme's mode, solved for its surfaces: what a chart uses unless told otherwise. Each slot clears 3:1 on the theme's background, surface and raised surface, and adjacent slots stay apart under normal vision, protanopia and deuteranopia; see the class comment. Solved once per palette. -
color
The color for slotindex. Indexes pastsize()repeat the slots, shading each repeat alternately lighter and darker; see the class note on why that is a fallback rather than an extension.- Throws:
IllegalArgumentException- ifindexis negative
-
size
public int size()How many distinct slots this palette declares. -
colors
The slots, in assignment order.
-