UI Interface
Chart gallery
Twenty chart patterns built on the shared mount(), spark(), donut() and radial() helpers. Every config is a theme-aware factory; open View code under a chart to copy it.
Chart design rules
The conventions every chart in this template follows.
Palette order
Series take --sx-c1 to --sx-c8 in a fixed order, never cycled. A single series uses slot 1. Keep to five series and fold the tail into Other.
No dual axes
Never plot two units on two y-axes. Mixed column and line is allowed when both share one unit. Otherwise use two small charts stacked.
Thin marks
Lines are 2px, bars have 4px rounded ends and a 2px surface gap when stacked. Gridlines are hairline and solid, with no vertical lines.
Legend and labels
Two or more series always show a legend. Data labels only on selected values. Donuts hold six slices at most and sit beside a value list.
Status colors
Good, warning and critical colors are reserved for meaning and are always paired with an icon or label.
Theme aware
Pass a factory (t) => options to mount() so charts rebuild with the right tokens when the theme changes. Never read colors outside it.
Palette preview
Categorical slots in the order series consume them. Values switch with the theme.
Slot 1 --sx-c1
Primary series, single-series charts
Slot 2 --sx-c2
Second series, comparison
Slot 3 --sx-c3
Third series
Slot 4 --sx-c4
Fourth series
Slot 5 --sx-c5
Fifth series
Slot 6 --sx-c6
Use sparingly
Slot 7 --sx-c7
Use sparingly
Slot 8 --sx-c8
Fold into Other
Line chart
Weekly active users by platform over 14 days. Two series, 2px strokes, hairline grid.
View code
mount('#chart-line', (t) => ({
chart: { type: 'line', height: 280 },
series: [
{ name: 'Web', data: series(14, { base: 5200, vol: 0.06, trend: 0.18, seed: 3 }) },
{ name: 'Mobile', data: series(14, { base: 3400, vol: 0.08, trend: 0.3, seed: 4 }) },
],
colors: [t.series[0], t.series[1]],
xaxis: { categories: days(14), tickAmount: 6 },
legend: { show: false },
}));
Smooth area
Single series, so one color. Gradient fades to transparent to keep the grid readable.
View code
mount('#chart-area', (t) => ({
chart: { type: 'area', height: 280 },
series: [{ name: 'Revenue', data: series(12, { base: 42000, vol: 0.08, trend: 0.5, seed: 11 }) }],
colors: [t.series[0]],
fill: areaFill(0.28, 0.02),
xaxis: { categories: months(12) },
yaxis: { labels: { formatter: (v) => fmt.usdK(v, 0) } },
}));
Stacked area
Traffic share by channel. Fills are separated by a 2px surface gap.
View code
mount('#chart-stacked-area', (t) => ({
chart: { type: 'area', height: 280, stacked: true },
series: [
{ name: 'Organic', data: series(12, { base: 900, vol: 0.1, trend: 0.4, seed: 21 }) },
{ name: 'Paid', data: series(12, { base: 520, vol: 0.1, trend: 0.2, seed: 22 }) },
{ name: 'Referral', data: series(12, { base: 260, vol: 0.12, trend: 0.1, seed: 23 }) },
],
colors: [t.series[0], t.series[1], t.series[2]],
stroke: { width: 2, colors: [t.surface] },
fill: { type: 'solid', opacity: 0.9 },
xaxis: { categories: months(12) },
legend: { show: false },
}));
Grouped column
Quarterly plan versus actual versus prior year, bars side by side.
View code
mount('#chart-grouped', (t) => ({
chart: { type: 'bar', height: 280 },
series: [
{ name: 'Plan', data: [120, 135, 150, 170] },
{ name: 'Actual', data: [126, 131, 158, 181] },
{ name: 'Prior year', data: [98, 110, 121, 139] },
],
colors: [t.series[0], t.series[1], t.series[2]],
plotOptions: { bar: { columnWidth: '58%', borderRadius: 3 } },
stroke: { width: 2, colors: ['transparent'] },
xaxis: { categories: ['Q1', 'Q2', 'Q3', 'Q4'] },
legend: { show: false },
}));
Stacked column
Support tickets by severity per month. Segments share a 2px gap.
View code
mount('#chart-stacked-col', (t) => ({
chart: { type: 'bar', height: 280, stacked: true },
series: [
{ name: 'Low', data: [44, 52, 38, 61, 49, 57] },
{ name: 'Medium', data: [28, 31, 36, 29, 41, 33] },
{ name: 'High', data: [9, 12, 8, 14, 11, 7] },
],
colors: [t.series[0], t.series[1], t.series[2]],
plotOptions: { bar: { columnWidth: '42%', borderRadius: 3 } },
stroke: { width: 2, colors: [t.surface] },
xaxis: { categories: ['Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov'] },
legend: { show: false },
}));
Horizontal bar
Ranked bars beat donuts for close values. One color, labels at the bar end.
View code
mount('#chart-hbar', (t) => ({
chart: { type: 'bar', height: 280 },
series: [{ name: 'Signups', data: [4820, 3910, 3275, 2640, 1980, 1215] }],
colors: [t.series[0]],
plotOptions: { bar: { horizontal: true, barHeight: '52%', borderRadius: 4 } },
dataLabels: { enabled: true, offsetX: 6, style: { fontSize: '11.5px', colors: [t.text] }, formatter: (v) => fmt.num(v) },
xaxis: { categories: ['Search', 'Direct', 'Social', 'Email', 'Referral', 'Affiliate'], labels: { show: false } },
grid: { xaxis: { lines: { show: false } }, yaxis: { lines: { show: false } } },
}));
Mixed column and line
Orders as columns and a 3-month moving average as a line. Same unit, one axis.
View code
mount('#chart-mixed', (t) => {
const orders = series(12, { base: 1800, vol: 0.12, trend: 0.35, seed: 31 });
const avg = orders.map((_, i) => Math.round(orders.slice(Math.max(0, i - 2), i + 1).reduce((a, b) => a + b, 0) / Math.min(i + 1, 3)));
return {
chart: { type: 'line', height: 280 },
series: [{ name: 'Orders', type: 'column', data: orders }, { name: 'Moving average', type: 'line', data: avg }],
colors: [t.series[0], t.series[1]],
stroke: { width: [0, 2.5] },
plotOptions: { bar: { columnWidth: '40%', borderRadius: 3 } },
xaxis: { categories: months(12) },
legend: { show: false },
};
});
Donut
Uses the shared donut() helper: centered total, four slices, HTML legend with values.
- Subscriptions$6,420
- Services$2,180
- Add-ons$1,240
- Other$460
View code
donut('#chart-donut', {
labels: ['Subscriptions', 'Services', 'Add-ons', 'Other'],
values: [6420, 2180, 1240, 460],
height: 240,
center: { label: 'Revenue' },
format: (v) => fmt.usd(v),
});
Radial gauge
Uses radial(): one value, one color, a rounded cap over a sunken track.
View code
radial('#chart-radial', 78, { color: 1, label: 'Goal reached', height: 240 });
Radar
Team skill profile compared with the target level on six axes.
View code
mount('#chart-radar', (t) => ({
chart: { type: 'radar', height: 300 },
series: [{ name: 'Current', data: [72, 64, 81, 58, 69, 76] }, { name: 'Target', data: [80, 75, 80, 70, 75, 80] }],
colors: [t.series[0], t.series[1]],
stroke: { width: 2 },
fill: { opacity: 0.12 },
markers: { size: 3 },
xaxis: { categories: ['Speed', 'Quality', 'Uptime', 'Cost', 'Support', 'Security'] },
yaxis: { show: false, max: 100 },
plotOptions: { radar: { polygons: { strokeColors: t.grid, connectorColors: t.grid, fill: { colors: ['transparent'] } } } },
legend: { show: false },
}));
Polar area
Five regions sized by radius. Fixed palette order, thin surface gaps.
View code
mount('#chart-polar', (t) => ({
chart: { type: 'polarArea', height: 300 },
series: [42, 34, 28, 21, 15],
labels: ['North', 'South', 'East', 'West', 'Central'],
colors: t.series.slice(0, 5),
stroke: { width: 2, colors: [t.surface] },
fill: { opacity: 0.9 },
yaxis: { show: false },
plotOptions: { polarArea: { rings: { strokeWidth: 1, strokeColor: t.grid }, spokes: { strokeWidth: 1, connectorColors: t.grid } } },
legend: { show: false },
}));
Heatmap
Sessions by weekday and hour block. One hue, intensity encodes volume.
View code
mount('#chart-heatmap', (t) => {
const r = rng(5);
const rows = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
return {
chart: { type: 'heatmap', height: 300 },
series: rows.map((d, i) => ({ name: d, data: ['00', '03', '06', '09', '12', '15', '18', '21'].map((h, j) => ({ x: h + ':00', y: Math.round(10 + 80 * r() * (j > 2 && j < 7 ? 1 : 0.4) * (i > 4 ? 0.6 : 1)) })) })).reverse(),
colors: [t.series[0]],
stroke: { width: 2, colors: [t.surface] },
plotOptions: { heatmap: { radius: 4, enableShades: true, shadeIntensity: 0.7 } },
};
});
Treemap
Budget by department. Area encodes spend; ranks keep the palette order.
View code
mount('#chart-treemap', (t) => ({
chart: { type: 'treemap', height: 300 },
series: [{ data: [
{ x: 'Engineering', y: 482 }, { x: 'Sales', y: 336 }, { x: 'Marketing', y: 244 },
{ x: 'Support', y: 168 }, { x: 'Operations', y: 126 }, { x: 'Legal', y: 58 },
] }],
colors: t.series.slice(0, 6),
plotOptions: { treemap: { distributed: true, enableShades: false } },
stroke: { width: 2, colors: [t.surface] },
dataLabels: { enabled: true, style: { fontSize: '12px', fontWeight: 600 } },
}));
Scatter
Deal size versus days to close for two segments, 40 points each.
View code
mount('#chart-scatter', (t) => {
const a = rng(8), b = rng(9);
const pts = (r, x0, xs, y0, ys) => Array.from({ length: 40 }, () => [Math.round(x0 + r() * xs), Math.round(y0 + r() * ys)]);
return {
chart: { type: 'scatter', height: 300 },
series: [{ name: 'SMB', data: pts(a, 5, 40, 4, 30) }, { name: 'Enterprise', data: pts(b, 30, 60, 20, 60) }],
colors: [t.series[0], t.series[1]],
markers: { size: 6, strokeWidth: 0 },
xaxis: { type: 'numeric', tickAmount: 6, title: { text: 'Days to close', style: { color: t.muted, fontWeight: 500 } } },
yaxis: { title: { text: 'Deal size ($k)', style: { color: t.muted, fontWeight: 500 } } },
legend: { show: false },
};
});
Bubble
Third dimension as area: accounts by usage and revenue, sized by seats.
View code
mount('#chart-bubble', (t) => {
const a = rng(12), b = rng(13);
const pts = (r, y0, ys, z0, zs) => Array.from({ length: 12 }, (_, i) => [10 + i * 7 + Math.round(r() * 5), Math.round(y0 + r() * ys), Math.round(z0 + r() * zs)]);
return {
chart: { type: 'bubble', height: 300 },
series: [{ name: 'Starter', data: pts(a, 5, 25, 4, 14) }, { name: 'Business', data: pts(b, 30, 45, 10, 40) }],
colors: [t.series[0], t.series[1]],
fill: { opacity: 0.55 },
stroke: { width: 1.5 },
plotOptions: { bubble: { minBubbleRadius: 5, maxBubbleRadius: 28 } },
xaxis: { type: 'numeric', tickAmount: 6, title: { text: 'Weekly sessions', style: { color: t.muted, fontWeight: 500 } } },
legend: { show: false },
};
});
Range area
Daily temperature band: low to high with a 2px outline.
View code
mount('#chart-range', (t) => {
const r = rng(17);
const data = days(21).map((d, i) => { const m = 8 + 6 * Math.sin(i / 4) + r() * 2; return { x: d, y: [Math.round(m - 4 - r() * 2), Math.round(m + 5 + r() * 2)] }; });
return {
chart: { type: 'rangeArea', height: 280 },
series: [{ name: 'Temperature (C)', data }],
colors: [t.series[0]],
stroke: { width: 2, curve: 'smooth' },
fill: { opacity: 0.22 },
xaxis: { tickAmount: 6 },
};
});
Candlestick
Share price, open-high-low-close for 14 sessions. Semantic colors with direction implied by fill.
View code
mount('#chart-candle', (t) => {
const r = rng(23); let p = 120;
const data = days(14).map((d) => { const o = p, c = o + (r() - 0.45) * 8, h = Math.max(o, c) + r() * 3, l = Math.min(o, c) - r() * 3; p = c; return { x: d, y: [o, h, l, c].map((v) => +v.toFixed(2)) }; });
return {
chart: { type: 'candlestick', height: 300 },
series: [{ name: 'ACME', data }],
plotOptions: { candlestick: { colors: { upward: t.good, downward: t.crit }, wick: { useFillColor: true } } },
xaxis: { tickAmount: 7 },
yaxis: { labels: { formatter: (v) => fmt.usd(v) } },
};
});
Boxplot
Response time distribution per region: min, Q1, median, Q3, max.
View code
mount('#chart-box', (t) => ({
chart: { type: 'boxPlot', height: 300 },
series: [{ name: 'Latency (ms)', data: [
{ x: 'US East', y: [38, 52, 61, 74, 98] }, { x: 'US West', y: [42, 58, 69, 83, 110] },
{ x: 'EU', y: [51, 66, 78, 92, 124] }, { x: 'APAC', y: [72, 94, 112, 135, 176] }, { x: 'LATAM', y: [64, 85, 99, 121, 158] },
] }],
colors: [t.series[0]],
plotOptions: { boxPlot: { colors: { upper: t.series[0], lower: t.series[1] } } },
stroke: { colors: [t.ink], width: 1 },
}));
Waterfall
Cash bridge from opening to closing balance. Gains, losses and totals use distinct colors.
View code
mount('#chart-waterfall', (t) => {
const steps = [['Opening', 0, 480, 'T'], ['Sales', 480, 720, 'U'], ['Services', 720, 810, 'U'], ['Payroll', 610, 810, 'D'], ['Cloud', 560, 610, 'D'], ['Tax', 500, 560, 'D'], ['Closing', 0, 500, 'T']];
return {
chart: { type: 'rangeBar', height: 300 },
series: [{ name: 'Cash ($k)', data: steps.map(([x, lo, hi]) => ({ x, y: [lo, hi] })) }],
colors: [({ dataPointIndex }) => ({ T: t.series[0], U: t.good, D: t.crit }[steps[dataPointIndex][3]])],
plotOptions: { bar: { columnWidth: '46%', borderRadius: 3, distributed: true } },
legend: { show: false },
yaxis: { labels: { formatter: (v) => '$' + v + 'k' } },
};
});
Sparkline variants
The spark() helper at 44px: area, line and bar. Each is one series in one color slot.
Area
Line
Bar
View code
spark('#sp-area', series(20, { base: 40, vol: 0.2, trend: 0.5, seed: 41 }), { type: 'area', color: 1 });
spark('#sp-line', series(20, { base: 40, vol: 0.2, trend: -0.3, seed: 42 }), { type: 'line', color: 2 });
spark('#sp-bar', series(14, { base: 40, vol: 0.3, trend: 0.2, seed: 43 }), { type: 'bar', color: 3 });
/* Inline SVG sparkline, no engine: <span data-sx-spark="3,5,4,8,7,9" data-color="4"></span> */