Media and drawing
Charts
Examplea whole program
state rows: json = [{day: "Mon", visitors: 820, orders: 41}, {day: "Tue", visitors: 932, orders: 48}, {day: "Wed", visitors: 901, orders: 52}, {day: "Thu", visitors: 934, orders: 47}, {day: "Fri", visitors: 1290, orders: 66}, {day: "Sat", visitors: 1330, orders: 72}, {day: "Sun", visitors: 1320, orders: 70}]column gap=24 padding=16 LineChart data=rows x="day" y="visitors" label="Visitors this week" Chart data=rows x="day" label="Visitors and orders" Bar y="visitors" label="Visitors" Line y="orders" label="Orders" axis="right" dots=true Rule y=1000 label="target"Mental model#
A chart for each kind#
Lines and areas#
Examplea whole program
state rows: json = [{month: "Jan", desktop: 186, mobile: 80}, {month: "Feb", desktop: 305, mobile: 200}, {month: "Mar", desktop: 237, mobile: 120}, {month: "Apr", desktop: 73, mobile: 190}, {month: "May", desktop: 209, mobile: 130}, {month: "Jun", desktop: 214, mobile: 140}]state cfg: json = [{key: "desktop", label: "Desktop"}, {key: "mobile", label: "Mobile"}]column gap=24 padding=16 LineChart data=rows x="month" config=cfg curve="smooth" dots=true AreaChart data=rows x="month" config=cfg stacked=true AreaChart data=rows x="month" config=cfg stack="expand" label="Share by device"Bars#
Examplea whole program
state rows: json = [{month: "Jan", desktop: 186, mobile: 80}, {month: "Feb", desktop: 305, mobile: 200}, {month: "Mar", desktop: 237, mobile: 120}]state cfg: json = [{key: "desktop", label: "Desktop"}, {key: "mobile", label: "Mobile"}]state budget: json = [{step: "Revenue", change: 420}, {step: "Costs", change: -160}, {step: "Gross", change: 0, total: true}, {step: "Wages", change: -120}, {step: "Net", change: 0, total: true}]column gap=24 padding=16 BarChart data=rows x="month" config=cfg BarChart data=rows x="month" config=cfg orientation="horizontal" stacked=true WaterfallChart data=budget x="step" y="change" total="total" labels=trueDistributions and points#
Grids#
Examplea whole program
state busy: json = [{day: "Mon", hour: "9h", n: 12}, {day: "Mon", hour: "10h", n: 30}, {day: "Tue", hour: "9h", n: 18}, {day: "Tue", hour: "10h", n: 44}]state kept: json = [{cohort: "Jan", week: "W0", share: 1}, {cohort: "Jan", week: "W1", share: 0.62}, {cohort: "Feb", week: "W0", share: 1}, {cohort: "Feb", week: "W1", share: 0.58}]column gap=24 padding=16 HeatMap data=busy x="hour" y="day" value="n" labels=true CohortChart data=kept cohort="cohort" period="week" value="share"Round charts#
Examplea whole program
state browsers: json = [{browser: "Chrome", visitors: 275}, {browser: "Safari", visitors: 200}, {browser: "Firefox", visitors: 187}, {browser: "Other", visitors: 90}]row gap=16 padding=16 flex-wrap=wrap PieChart data=browsers value="visitors" name="browser" donut=true labels="percent" text "752" font-size=24 font-weight=700 GaugeChart value=72 label="Uptime score" bands=[50, 80, 100]Money, flows, trees, time#
Small charts#
Examplea whole program
state accounts: json = [{id: 1, name: "Ada", trend: [3, 5, 4, 8, 6, 9]}, {id: 2, name: "Ben", trend: [9, 7, 8, 4, 5, 3]}]column gap=8 padding=16 for a in accounts key=a.id row gap=12 align-items=center text a.name width=80 Sparkline data=a.trend Sparkline data=a.trend kind="bar" Sparkline data=[1, -1, 1, 1, -1] kind="winloss"Chart: marks of your own#
Examplea whole program
state days: json = [{day: 1, visitors: 820, low: 760, high: 880, orders: 41}, {day: 2, visitors: 932, low: 870, high: 990, orders: 48}, {day: 3, visitors: 901, low: 850, high: 960, orders: 52}, {day: 4, visitors: 1290, low: 1200, high: 1370, orders: 66}]Chart data=days x="day" label="Visitors, with their range, and orders" Band lower="low" upper="high" Line y="visitors" label="Visitors" Bar y="orders" label="Orders" axis="right" Rule y=1000 label="target" Note x=4 y=1290 label="launch"Data#
Large data#
Interactions#
Accessibility#
Theming#
Pitfalls#
The older charts#
In the source#
Edit this page:
docs/charts.md