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.
Contrast against the surface is deliberately not a gate for these marks: four of the light slots and one of the dark sit below 3:1 on a typical chart surface, which is legal only because identity is never carried by color alone here: a chart with two or more series always draws a legend, and the tooltip names the series it reports. Keep that relief in place if you swap in your own colors.
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 matchingtheme's mode, 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 matchingtheme's mode, what a chart uses unless told otherwise. -
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.
-