Chart

Molecule

Token-aware primitive chart library, the EJS sibling of kui-react `@/modules/ui/Chart` (modules/ui/Chart/Chart.ejs). Line, Bar, Area, Pie, Donut and SparkLine consume one `Series` data shape; colours come from --primary / --secondary / --success / --warning / --error / --info, so dark mode and theme swaps need no extra work. Value axes widen to round bounds with readable steps (never 263.25 on a 0-351 axis; `yTickCount` sets about how many intervals); crowded category labels are thinned so they never overlap. Line / Area / Bar share the settings surface: a right value axis (`series[].yAxis: 'right'`, `y2Min` / `y2Max` / `y2Label`, aligned to the left grid), `yMin` / `yMax`, axis titles, thresholds, `gridStyle` (dashed by default), `showXAxis` / `showYAxis`, legend position / values / toggling, tooltip mode, header, value format and stack total, and `fill` (take the parent's height). Line / Area add curves (smooth, linear, step), per-series stroke style, point marks (circle, square, diamond, triangle, `pointSize`) and gradient fills; Bar adds grouped stacks (`series[].stack`), horizontal bars, value labels, category ticks and markers. Pie / Donut take slice labels (inside or outside), a slice gap, the start angle, a centre caption and legend values. GaugeChart, HeatmapChart and the time axis (`xAxis: 'time'` with drag-to-zoom) have their own pages. Format options are the NAME of a global function, since the config travels as JSON.

LineChart

Preview

Daily active users vs new signups

Code
<%- include('modules/ui/Chart/Chart', { id: 'activity', type: 'line', series: series, height: 220 }) %>

Stacked bars and areas

Preview

Revenue + expenses, stacked

Code
<%- include('modules/ui/Chart/Chart', { type: 'bar', stacked: true, series: series }) %>
<%- include('modules/ui/Chart/Chart', { type: 'area', stacked: true, series: series }) %>

BarChart

Preview

Revenue vs expenses (monthly)

Code
<%- include('modules/ui/Chart/Chart', { type: 'bar', series: series }) %>

AreaChart

Preview

Engagement over the week (smoothed)

Code
<%- include('modules/ui/Chart/Chart', { type: 'area', series: series, fillOpacity: 0.18 }) %>

PieChart

Preview

Sales by category

Code
<%- include('modules/ui/Chart/Chart', { type: 'pie', series: pieSeries }) %>

DonutChart

Preview

Sales by category (donut)

Code
<%- include('modules/ui/Chart/Chart', { type: 'donut', series: pieSeries, innerRadius: 0.62 }) %>

Right axis, point marks and a gradient fill

Preview

Load (left) vs outside temperature (right axis), limit line

Code
<%- include('modules/ui/Chart/Chart', { type: 'line', series: [load, { ...temp, yAxis: 'right' }], yLabel: 'kW', y2Label: '°C',
  thresholds: [{ value: 320, label: 'Limit' }] }) %>
<%- include('modules/ui/Chart/Chart', { type: 'area', series: [{ ...visits, fillGradient: true }], showValues: true, gridStyle: 'dotted' }) %>

Scatter, with a trend line and number formats as data

Preview

Load (rpm) vs pressure (bar), two machines

Code
<%- include('modules/ui/Chart/Chart', {
  type: 'scatter', series: [machineA, machineB], trendLine: true, pointShape: 'diamond',
  // a format option is the NAME of a global function, or plain data the browser turns into one
  xFormat: { base: { unit: 'rpm' } },
  yFormat: { base: { unit: 'bar', decimals: 1 }, mode: 'tick' },
}) %>

Grouped stacks, markers and crowded labels

Preview

North A + B stacked beside South; a histogram with its mean; 30 days thinned; horizontal bars

Code
<%- include('modules/ui/Chart/Chart', { type: 'bar', series: [{ ...a, stack: 'north' }, { ...b, stack: 'north' }, south], showValues: true, tooltipTotal: true }) %>
<%- include('modules/ui/Chart/Chart', { type: 'bar', series: bins, barWidth: 1, barGap: 0, radius: 0, markers: [{ at: 4.2, label: 'Mean 210 ms' }] }) %>
<%- include('modules/ui/Chart/Chart', { type: 'bar', series: thirtyDays, yTickCount: 3 }) %>
<%- include('modules/ui/Chart/Chart', { type: 'bar', series: share, orientation: 'horizontal', showValues: true }) %>

Pie and donut labels

Preview

Outside labels with a grid legend; donut with a caption, a slice gap and shares in the legend

Code
<%- include('modules/ui/Chart/Chart', { type: 'pie', series: pieSeries, labels: 'name-percent', labelPosition: 'outside', legendLayout: 'grid' }) %>
<%- include('modules/ui/Chart/Chart', { type: 'donut', series: pieSeries, centerLabel: 'Total', sliceGap: 3, legendValue: 'percent', legendPosition: 'right' }) %>

SparkLine

Preview

Inline sparklines

MRR 
+24%
DAU 
+8%
Code
<%- include('modules/ui/Chart/Chart', { type: 'sparkline', series: [{ id: 'spark', name: 'spark', data: values }], height: 28, filled: true }) %>
<%- include('modules/ui/Chart/Chart', { type: 'sparkline', series: [{ id: 'spark', name: 'spark', data: values2 }], height: 28 }) %>
Source modules/ui/Chart/Chart.ejs