Construct shared scales (data → pixels / data → color) for chart marks. A scale exists independently of any plot area; multiple marks share one scale so they stay aligned under pan / zoom.
-- One slot per category, in this order; padding is the gap between-- slots, as a fraction of a slot.local days = datumhue.chart.scale.band({
domain = { "Mon", "Tue", "Wed" },
padding = 0.2,
})
print(#days.categories) --> 3
-- Exactly one of palette or colors. Past the domain, a value takes-- the end color.local heat = datumhue.chart.scale.color({
palette = "viridis",
domain = { min = 0, max = 100 },
})
print(heat:map(100) == heat:map(250)) --> true
local color = datumhue.colorlocal ovens = datumhue.chart.scale.color_category({
categories = { "North", "South" },
colors = { color("#7fbbb3"), color("#e69875") },
})
print(ovens:map("South") == color("#e69875")) --> true-- A name not listed takes the next color, cycling past the end.print(ovens:map("East") == color("#7fbbb3")) --> true