Chart
Zero-dependency pure-SVG chart component, chart is self-closing. t selects the type, d feeds data, l provides labels, c customizes colors — 20 chart types render with no external chart library. Every example shows DSL on the left and a live render on the right; click "edit" to tweak instantly.
Supported types: bar, line, area, pie, donut, rose, funnel, radar, scatter, bubble, heatmap, histogram, waterfall, boxplot, treemap, sankey, candlestick, progress, gauge, gantt.
Attribute Output Order (Streaming Render Constraint)
When emitting [chart], attributes must follow type → style/layout → labels → data (skip absent segments):
ttype (always first)- Style/layout attributes (affect render shape, data-independent):
tt,orient,stack,smooth,area,vals,w,h,range,anim,xl,yl,status,zones,zc,c,u,dec,ticks,sub,bins,mode,deps, etc. llabels (data-related, but must precede data — build axis/legend ticks first, then plot points)- Data payload (last):
d/tasks/rows/nodes+flows/ms/v
[chart t:bar tt:Daily output orient:h vals w:800 h:600 l:"Mon,Tue,Wed,Thu,Fri" d:"10,24,18,30,22"]Why: during streaming, data grows point by point and the parser's half-built attributes only contain keys accumulated so far. If style keys (orient/stack/vals, etc.) are written after d, the preview can't see them yet → it first draws with the default layout, then flips when ] closes and the style keys arrive (root cause of horizontal bars "suddenly turning" at the end). Putting them first means the preview is in its final layout from the start, with no flip/flicker. Never write d/tasks before l or any style attribute.
Common Props
All chart types share these props, self-closing.
| Prop | Meaning | Example |
|---|---|---|
t | Chart type | t:bar |
d | Data. Single series comma-separated; multi-series (bar/line/donut) use ` | ; scatter/bubble pairs use ;` |
l | Labels, comma-separated | l:"Jan,Feb,Mar" |
c | Custom color sequence, comma-separated; supports #hex / rgb() / var(--x) | c:"#1677ff,#52c41a" |
tt | Title | tt:Monthly Sales |
w / h | SVG width/height (px, internal coord ratio only) | w:480 |
v | Single value (donut center text / progress / gauge current) | v:75 |
area | Fill line chart (boolean) | area |
vals | Show value labels on bars/lines (boolean) | vals |
stack | Stack (boolean, bar/line/area/donut multi-series) | stack |
smooth | Smooth curve for line/area (boolean) | smooth |
orient | Bar orientation: h horizontal (default vertical) | orient:h |
xl / yl | X / Y axis unit name | xl:Input yl:Output |
range | Gauge sweep angle: 180 (default) / 270 / 360 | range:270 |
anim | Value animation duration (ms, progress/gauge, auto-stops under reduced-motion) | anim:1200 |
Attribute values containing commas or pipes must be double-quoted, or the parser splits on the delimiter. When colors are omitted a built-in 10-color palette is used. Long X-axis labels auto-rotate -35° to avoid overlap; empty data shows a "No data" placeholder.
Responsive sizing: charts default to
width:100%filling the container, capped per type (max-width × max-height): bar/line/area/scatter/bubble/histogram/waterfall/boxplot 1400×600 (horizontal barsorient:hheight cap 800), candlestick 1400×600, gantt 1400×640, pie/donut/radar/rose 600×600, gauge 600×400, funnel 1000×600, heatmap/treemap 1000×600, sankey 1000×600, progress 780×120. Beyond the cap it scales & centers without distortion.w/honly affect the internal coord ratio, not final render size — usually leave them out; for horizontal bars with many categories you may sethexplicitly (max 800).
Bar Chart t:bar
Grouped bar chart, self-closing. Multi-series d uses |, one group of bars per series; a legend is auto-generated at the bottom when series > 1. Add stack to stack, orient:h for horizontal.
| Prop | Meaning | Example |
|---|---|---|
d | Data, multi-series via ` | ` |
l | X-axis labels, comma-separated | l:"Q1,Q2,Q3" |
stack | Stack (boolean) | stack |
orient | h horizontal bars (long-label friendly) | orient:h |
vals | Show bar-top values | vals |
Multi-series comparison (auto legend):
Stacked bars (columns accumulate):
Horizontal bars (orient:h, good for long labels):
Horizontal bars (
orient:h) put categories on the y-axis, so height grows linearly with category count (~26px each); the render-sidemax-heightauto-loosens to 800px (vertical bars: 580px). When categories are many (e.g. ≥15), you may explicitly sethto grow the canvas, max effective 800 (= the display cap — larger gets clipped, smaller cramps), e.g.[chart t:bar orient:h h:800 l:"..." d:"..."]; for few categories, leavehunset (auto). Vertical bars generally don't seth.
Line Chart t:line
Line trend chart, self-closing. Add area for translucent fill; smooth for a smooth curve; stack to stack (with area → stacked area); multi-series via |.
| Prop | Meaning | Example |
|---|---|---|
d | Data, multi-series via ` | ` |
l | X-axis labels, comma-separated | l:"Mon,Tue,Wed" |
area | Area fill (boolean) | area |
smooth | Smooth curve (boolean) | smooth |
stack | Stack (boolean) | stack |
vals | Show node values | vals |
Multi-series line + smooth curve:
Area Chart t:area
Area chart = line chart + default fill, self-closing. Supports multi-series and stack for stacked area (later series layered on earlier).
| Prop | Meaning | Example |
|---|---|---|
d | Data, multi-series via ` | ` |
l | X-axis labels | l:"Jan,Feb,Mar" |
stack | Stacked area (boolean) | stack |
smooth | Smooth curve (boolean) | smooth |
Stacked area (cumulative composition):
Pie Chart t:pie
Proportion pie, self-closing. d holds per-item values, l their names; slices carry leader lines and percentage labels.
| Prop | Meaning | Example |
|---|---|---|
d | Per-item values, comma-separated | d:"45,30,25" |
l | Per-item names, comma-separated | l:"Search,Direct,Referral" |
c | Per-item colors | c:"#1677ff,#52c41a,#faad14" |
Donut Chart t:donut
Donut chart, self-closing. Same structure as pie, plus a v prop to show a number at the center. Multi-series d:"1,2|3,4" renders concentric rings (outer→inner).
| Prop | Meaning | Example |
|---|---|---|
d | Per-item values; multi-ring via ` | ` |
l | Per-item names, comma-separated | l:"PC,Mobile,Tablet" |
c | Per-item colors | c:"#1677ff,#52c41a,#faad14" |
v | Center text (single ring) | v:78 |
Multi-ring comparison (current vs previous, outer = current):
Rose Chart t:rose
Nightingale rose, self-closing. Like pie but with equal angles and slice radius proportional to value (larger value = longer petal); good for proportion comparison with wide value ranges.
| Prop | Meaning | Example |
|---|---|---|
d | Per-item values, comma-separated | d:"30,25,20,25" |
l | Per-item names, comma-separated | l:"Spring,Summer,Fall,Winter" |
c | Per-item colors | c:"#1677ff,#52c41a,#faad14,#f5222d" |
Funnel Chart t:funnel
Conversion/sales funnel, self-closing. Tapered trapezoids stacked top-to-bottom, width proportional to value, for progressively-shrinking flows (checkout, signup, screening). Data should be descending (top = funnel mouth, max value); each stage auto-labels its name and conversion rate vs the first stage.
| Prop | Meaning | Example |
|---|---|---|
d | Per-stage values, comma-separated (descending recommended) | d:"12000,5400,2800,1600,920" |
l | Per-stage names, comma-separated | l:"曝光,点击,加购,下单,付款" |
c | Per-stage colors | c:"#1677ff,#52c41a,#faad14" |
Radar Chart t:radar
Multi-dimension radar, self-closing. l is dimension names, d the scores (0-100 recommended). Multi-series supported (d via |) for entity comparison.
| Prop | Meaning | Example |
|---|---|---|
d | Per-dimension values, multi-series via ` | ` |
l | Dimension names, comma-separated | l:"Speed,Quality,Cost,UX,Stability" |
c | Per-series fill color | c:"#1677ff,#52c41a" |
Multi-series comparison (Product A vs B):
Scatter Chart t:scatter
2D scatter, self-closing. d uses semicolon ; to separate coordinate pairs, each x,y; xl/yl set axis names (default X/Y).
| Prop | Meaning | Example |
|---|---|---|
d | Coordinate pairs, ; between, , inside | d:"1,2;3,5;6,4" |
xl | X-axis name | xl:Input |
yl | Y-axis name | yl:Output |
c | Point color sequence | c:"#1677ff" |
xmin/xmax/ymin/ymax | Explicitly lock axis range | ymin:0 ymax:100 |
Scatter differs from bar/line: pairs are
;-separated, coords inside a pair are,-separated.
Streaming jitter-free: in container mode points are fed incrementally and the X/Y axes auto-fit by default (expand-only + nice rounding); existing points may reflow once when an extremum expands. For absolute zero-jitter, set
xmin/xmax/ymin/ymaxto lock the axes.
Bubble Chart t:bubble
3D bubble chart, self-closing. Scatter plus a third dimension: d uses ; between points, each x,y,size; bubble radius is proportional to size. Supports xmin/xmax/ymin/ymax explicit axis locking (same as scatter; jitter-free in streaming).
| Prop | Meaning | Example |
|---|---|---|
d | Points x,y,size, ;-separated | d:"1,2,5;3,4,10" |
xl / yl | X / Y axis name | xl:GDP yl:Population |
sl | Third-dim (size) name (tooltip) | sl:Output |
xmin/xmax/ymin/ymax | Explicitly lock axis range (jitter-free streaming) | ymin:0 ymax:100 |
Heatmap t:heatmap
Matrix heatmap, self-closing. rows holds grid data (| between rows, , between cols), cols column labels, l row labels (cols count must = values per row, l count must = number of |-separated rows — must match or cells misalign); color scale linearly interpolates between stops over the min→max range. Supports container-mode streaming (feed [hrow v:"v,v,v"] per row; hrow = heatmap row, avoids the layout row). In container streaming, the opening tag first draws an l×cols single-color skeleton grid; each hrow arriving fills that row. Value range is expand-only by default (prevents filled-cell color jitter); set vmin/vmax to lock it. A hrow's v arriving in fragments fills cell-by-cell (no waiting for the full tag).
| Prop | Meaning | Example |
|---|---|---|
rows | Grid data, rows via ` | , cols via ,` |
cols | Column labels, comma-separated | cols:"Mon,Tue,Wed" |
l | Row labels, comma-separated | l:"Morning,Noon,Night" |
c | Color-scale stops (comma-separated, low→high) | c:"#bae0ff,#1677ff,#0958d9" |
vmin/vmax | Explicitly lock color-scale range (jitter-free streaming) | vmin:0 vmax:100 |
Histogram t:histogram
Frequency histogram, self-closing. d holds raw values; binning happens client-side (bins sets count, default ~√n), and per-bin frequency renders as bars. Streaming WYSIWYG: range-segment labels l:"40-50,...,90-100" auto-lock lo/hi/bins (recommended, streaming==final); or set explicit bins+min+max; by default bins is fixed at first frame and lo/hi expand-only, so an expanding extremum makes bars jump once. bins must = number of l segments.
| Prop | Meaning | Example |
|---|---|---|
d | Raw value sequence, comma-separated | d:"1.2,3.4,5.1,..." |
bins | Bin count, default auto; must = number of l segments | bins:10 |
l | Bin labels; range segments 40-50,...,90-100 auto-lock lo/hi/bins (streaming==final) | l:"40-50,...,90-100" |
min/max | Explicitly lock value range (jitter-free streaming) | min:0 max:100 |
ymax | Explicitly lock frequency cap (y-axis jitter-free) | ymax:30 |
Waterfall Chart t:waterfall
Increment/decrement waterfall, self-closing. d is a signed delta sequence; bars float cumulatively with dual color (default green/red), dashed connectors between adjacent segments — for stepping from an initial to a final value (P&L, inventory).
| Prop | Meaning | Example |
|---|---|---|
d | Delta sequence (signed), comma-separated | d:"100,-30,50,-15" |
l | Per-segment labels | l:"Revenue,Cost,Profit,Tax" |
c | Positive/negative colors (first two) | c:"#52c41a,#f5222d" |
Boxplot t:boxplot
Statistical boxplot, self-closing. d uses ; between groups, each group five numbers min,Q1,median,Q3,max; shows distribution center, spread and range, multiple groups side-by-side.
| Prop | Meaning | Example |
|---|---|---|
d | Five-number list, ; between groups, , inside | d:"1,3,5,7,9;2,4,6,8,10" |
l | Group names | l:"Group A,Group B,Group C" |
Treemap t:treemap
Proportion treemap, self-closing. d is name:value comma-separated; rectangles are split by area proportion (largest first), each tile shows name, value and share — a one-glance view of hierarchy/category proportions. Supports container-mode streaming (feed [pt v:"name:value"] per item).
| Prop | Meaning | Example |
|---|---|---|
d | name:value list, comma-separated | d:"A:100,B:60,C:40" |
c | Color sequence | c:"#1677ff,#52c41a,#faad14,#f5222d" |
Sankey t:sankey
Flow sankey, self-closing. nodes lists nodes, flows gives source->target:volume (comma-separated); volume drives the connecting band width — for resource/money/user flow distribution. Supports container-mode streaming (feed [flow v:"source->target:volume"] per flow; nodes auto-extracted from flows, nodes optional). A flow's v arriving in fragments fills flow-by-flow.
| Prop | Meaning | Example |
|---|---|---|
nodes | Node names, comma-separated | nodes:"A,B,C" |
flows | Flows src->dst:vol, comma-separated | flows:"A->B:10,B->C:5" |
c | Per-flow colors | c:"#1677ff,#52c41a" |
Candlestick t:candlestick
OHLC candlestick, self-closing. d uses ; between candles, each open,high,low,close; close≥open is bullish (default red), otherwise bearish (default green), with wicks and bodies — for financial quotes. Follows the Chinese convention (red=up, green=down).
| Prop | Meaning | Example |
|---|---|---|
d | OHLC list, ; between candles, , inside | d:"10,12,8,11;11,13,9,10" |
l | Date/time labels | l:"Mon,Tue,Wed" |
c | Bullish/bearish colors (first two, bullish red / bearish green) | c:"#f5222d,#52c41a" |
Progress t:progress
Horizontal progress bar, self-closing. Track + fill + percentage text; v sets current, max/min the range, anim animates from min to v. Lighter than gauge, good for KPI/task progress.
| Prop | Meaning | Example |
|---|---|---|
v | Current value | v:65 |
max / min | Upper/lower bound, default 100 / 0 | max:100 |
u | Unit suffix; auto % when min:0 max:100 | u:pcs |
l | Prefix label | l:Done |
c | Fill color | c:"#1677ff" |
anim | Animation duration (ms) | anim:1000 |
Gauge t:gauge
Single-value gauge / KPI speedometer, self-closing. Half-circle track + value arc + needle + center number + ticks, for showing where a single value sits in a range (completion rate, CPU load, speed, health, compliance). Feed the value via v, not d.
| Prop | Meaning | Example |
|---|---|---|
v | Current value (required) | v:72 |
max / min | Upper/lower bound, default 100 / 0 | max:240 min:0 |
range | Sweep angle: 180 (default) / 270 / 360 | range:270 |
u | Unit suffix; auto % when min:0 max:100 | u:"km/h" |
dec | Decimal places; default 1 when span≤10 else 0 | dec:1 |
status | Semantic color + badge: success / warning / danger / info | status:danger |
c | Custom arc color (lower priority than status/zones) | c:"#1677ff" |
zones | Stage band thresholds, comma-separated; arc color follows the band the value lands in | zones:"60,85" |
zc | Zone band colors (low→high); default green/yellow/red | zc:"#52c41a,#faad14,#f5222d" |
anim | Number + arc + needle animation (ms, from min to v; respects reduced-motion) | anim:1200 |
ticks | Tick density, default 6 | ticks:10 |
l | Metric name (under center value) | l:CPU Usage |
sub | Subtitle (bottom small text) | sub:"Source: monitor" |
Color priority:
zonesband >statussemantic >ccustom > default palette. Out-of-range values clamp to[min, max].
Basic gauge (status color + subtitle):
Gauge with unit (custom max & unit):
Stage bands (compliance: thresholds 60/85 split into 3 bands, ticks auto-mark thresholds; arc color follows the band) + number animation:
Reversed palette (error rate: high = bad, red at top; with decimals):
270° gauge (range:270, fuller arc):
Multi-KPI dashboard (with grid):
Gantt t:gantt
Project schedule gantt, self-closing. Task bars laid out by row, with progress fill, dependency arrows, milestones and group colors. Leave mode empty to auto-detect (a start value containing - or / is treated as a date).
Gantt-specific Props
| Prop | Meaning | Example |
|---|---|---|
tasks | Task list. Each name,start,end[,progress[,group]], multiple via ` | ` |
gnames | Group names, mapped by group number to legend text, multiple via ` | . If tasks use a group number (5th field) you must supply gnames` or the legend shows placeholders "组1/组2" |
deps | Dependencies (finish→start), format srcIdx->dstIdx, multiple via ,. Indices are task order (0-based) | deps:"0->1,1->2" |
ms | Milestones. Each name,time[,group], multiple via ` | ` |
mode | Time mode: days / dates, empty = auto | mode:dates |
Time values: days as numbers (1,3); dates as 2026-06-15 or 2026/6/15. In date mode a "today" reference line is drawn when it falls within the range.
Click any task bar to highlight its dependency transitive closure (upstream + downstream + self) for critical-path tracing.
Basic gantt (days mode)
mode:days, time values are plain numbers = day N.
Gantt with dependencies & milestones
deps uses src->dst to mean the next task starts after the prior finishes; ms marks key nodes as diamonds.
Date-mode gantt
mode:dates (or empty for - auto-detect), times as YYYY-MM-DD or YYYY/M/D, with a "today" dashed line.
Full props and gantt fields are in the DSL syntax reference section 5.7; if that page isn't generated, see
demo/TOKUI_DSL_REFERENCE.mdin the repo.