Journal/data · charts · tutorialEntry 07 / 10
Animated charts from data
A bar chart, a line chart with a marker riding its tip, and a donut, each built from a few layers with repeat, expressions and attach, with the data passed in as props.

▸ blog-data-donut1280×720 · 30 fps · 0:04.0Rendered by vidmake
Some of the best uses of programmatic video are a weekly metrics recap, a launch-day chart for social, or a dashboard that turns into a 10-second clip. They are also where hand-built video tools are weakest, because the numbers change every week and nobody wants to re-time 40 keyframes by hand.
vidmake doesn't have chart layers, and we don't think it needs them. A chart is a handful of shapes positioned by data, and since 0.2 a project can express that directly: repeat stamps out one layer per data point, expressions read the data with pick(i, [...]), and attach lets a marker ride a line as it draws. This post builds three charts that way. Each is one file, and the data lives in props so a script can swap it without touching the layers.
#Bars from two arrays
{ "fonts": [ { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }, { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk-Italic.ttf" }, { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" } ], "compositions": [{ "id": "bars", "description": "A bar chart from two prop arrays: one repeated group per day with a bar, a counting value and a label", "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea", "props": { "values": [412, 538, 497, 621, 884, 356, 298], "labels": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], "peak": 4 }, "layers": [ { "id": "title", "type": "text", "text": ["Renders ", { "text": "per day", "italic": true, "fontWeight": 400 }], "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 60, "letterSpacing": -2.6, "fill": "#161412", "anchor": "left", "x": 120, "y": 92, "enter": "fadeUp" }, { "id": "grid", "type": "rect", "width": 1040, "height": 1, "fill": "=i == 3 ? '#161412' : '#d8d1c1'", "x": "50%", "y": 450, "repeat": { "count": 4, "layout": "column", "spacing": 100 }, "enter": "wipeRight" }, { "id": "day", "type": "group", "width": 120, "height": 520, "x": "50%", "y": 400, "repeat": { "count": 7, "layout": "row", "spacing": 146, "delay": "0.07s" }, "children": [ { "id": "bar", "type": "rect", "width": 64, "anchor": "bottom", "x": 60, "y": 460, "height": "=pick(i, {{values}}) * 0.36 * easeOutCubic(clamp(t / 0.9, 0, 1))", "fill": "=i == {{peak}} ? '#c92a26' : '#161412'" }, { "id": "value", "type": "text", "font": "JetBrains Mono", "fontSize": 18, "x": 60, "y": "=440 - pick(i, {{values}}) * 0.36 * easeOutCubic(clamp(t / 0.9, 0, 1))", "text": "${round(pick(i, {{values}}) * easeOutCubic(clamp(t / 0.9, 0, 1)))}", "fill": "=i == {{peak}} ? '#c92a26' : '#4a4640'" }, { "id": "label", "type": "text", "text": "${pick(i, {{labels}})}", "font": "JetBrains Mono", "fontSize": 14, "letterSpacing": 1.7, "uppercase": true, "fill": "#8a857a", "x": 60, "y": 494 } ] } ] }]}The whole chart is one repeated group. The composition declares the data as props:
"props": { "values": [412, 538, 497, 621, 884, 356, 298], "labels": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], "peak": 4 }and the group repeats once per day, laid out in a row:
{ "id": "day", "type": "group", "width": 120, "height": 520, "x": "50%", "y": 400, "repeat": { "count": 7, "layout": "row", "spacing": 146, "delay": "0.07s" }, "children": [ ... ] }Every child of a repeated group sees the copy's i, so each child can read its own data point:
- the bar's height is
pick(i, {{values}}) * 0.36 * easeOutCubic(clamp(t / 0.9, 0, 1)), its data value scaled to pixels and eased in over 0.9 seconds."anchor": "bottom"makes it grow up from the baseline. - the value label uses the same product for its
y, so it rides the top of its bar, and printsround(...)of the same eased value so the number counts while the bar grows. - the day label prints
pick(i, {{labels}}). - the color is
i == {{peak}} ? '#c92a26' : '#161412', a ternary that returns one of two colors.
The {{values}} inside an expression is ordinary props templating: before anything is compiled, the prop's JSON text is spliced into the string, so the expression becomes pick(i, [412, 538, ...]). String arrays work the same way, since expressions accept double-quoted strings. That means new data needs no edit to the file. The same project with different props:
![vidmake still blog-data-bars.json -t 3s -p values=[120,240,360,480,600,720,840] -p peak=6](/media/still-57e008d85d01.jpg)
From a pipeline, write the data to a file and pass --props-file week43.json. The scale factor (0.36 px per unit) is the one thing that doesn't adapt by itself. Put it in props too, or compute it upstream as the chart height divided by the maximum value.
Children of a repeated group keep their own ids, so inspect lists a bar, value and label under each day.<i> copy, with every bounding box in canvas pixels. That's enough to check that the numbers landed where they should, and that no value label collides with the title:
$ vidmake inspect blog-data-bars.json -t 3s
Frame 90 (3.00s) of `bars` (1280x720), 33 visible layer(s), drawn bottom→top:
ID TYPE X Y W H ROT SCALE OPAC BBOX [x0,y0,x1,y1] NOTES
title text 120.0 92.0 443.7 72.0 0.0 1.00 1.00 [120,56,564,128] "Renders per day"
grid.0 rect 640.0 300.0 1040.0 1.0 0.0 1.00 1.00 [120,300,1160,300]
grid.1 rect 640.0 400.0 1040.0 1.0 0.0 1.00 1.00 [120,400,1160,400]
grid.2 rect 640.0 500.0 1040.0 1.0 0.0 1.00 1.00 [120,500,1160,500]
grid.3 rect 640.0 600.0 1040.0 1.0 0.0 1.00 1.00 [120,600,1160,600]
day.0 group 202.0 400.0 120.0 520.0 0.0 1.00 1.00 [142,140,262,660]
bar rect 60.0 460.0 64.0 148.3 0.0 1.00 1.00 [170,452,234,600]
value text 60.0 291.7 32.4 21.6 0.0 1.00 1.00 [186,421,218,442] "412"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [188,626,216,642] "MON"
day.1 group 348.0 400.0 120.0 520.0 0.0 1.00 1.00 [288,140,408,660]
bar rect 60.0 460.0 64.0 193.7 0.0 1.00 1.00 [316,406,380,600]
value text 60.0 246.3 32.4 21.6 0.0 1.00 1.00 [332,376,364,397] "538"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [334,626,362,642] "TUE"
day.2 group 494.0 400.0 120.0 520.0 0.0 1.00 1.00 [434,140,554,660]
bar rect 60.0 460.0 64.0 178.9 0.0 1.00 1.00 [462,421,526,600]
value text 60.0 261.1 32.4 21.6 0.0 1.00 1.00 [478,390,510,412] "497"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [480,626,508,642] "WED"
day.3 group 640.0 400.0 120.0 520.0 0.0 1.00 1.00 [580,140,700,660]
bar rect 60.0 460.0 64.0 223.6 0.0 1.00 1.00 [608,376,672,600]
value text 60.0 216.4 32.4 21.6 0.0 1.00 1.00 [624,346,656,367] "621"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [626,626,654,642] "THU"
day.4 group 786.0 400.0 120.0 520.0 0.0 1.00 1.00 [726,140,846,660]
bar rect 60.0 460.0 64.0 318.2 0.0 1.00 1.00 [754,282,818,600]
value text 60.0 121.8 32.4 21.6 0.0 1.00 1.00 [770,251,802,273] "884"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [772,626,800,642] "FRI"
day.5 group 932.0 400.0 120.0 520.0 0.0 1.00 1.00 [872,140,992,660]
bar rect 60.0 460.0 64.0 128.2 0.0 1.00 1.00 [900,472,964,600]
value text 60.0 311.8 32.4 21.6 0.0 1.00 1.00 [916,441,948,463] "356"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [918,626,946,642] "SAT"
day.6 group 1078.0 400.0 120.0 520.0 0.0 1.00 1.00 [1018,140,1138,660]
bar rect 60.0 460.0 64.0 107.3 0.0 1.00 1.00 [1046,493,1110,600]
value text 60.0 332.7 32.4 21.6 0.0 1.00 1.00 [1062,462,1094,484] "298"
label text 60.0 494.0 28.6 16.8 0.0 1.00 1.00 [1064,626,1092,642] "SUN"#A line that draws, and a marker that rides it
{ "fonts": [ { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }, { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" } ], "compositions": [{ "id": "line", "description": "A line chart that draws itself, a glowing marker riding its drawn tip, and a label that pops in when it lands", "width": 1280, "height": 720, "fps": 30, "duration": "4.5s", "background": "#f4f1ea", "layers": [ { "id": "title", "type": "text", "text": "Monthly active agents", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 52, "letterSpacing": -2.2, "fill": "#161412", "anchor": "left", "x": 160, "y": 100, "enter": "fadeUp" }, { "id": "grid", "type": "rect", "width": 960, "height": 1, "fill": "#d8d1c1", "x": 640, "y": 360, "repeat": { "count": 5, "layout": "column", "spacing": 80 } }, { "id": "month", "type": "text", "text": "${pick(i, ['J','F','M','A','M','J','J','A','S','O','N','D'])}", "font": "JetBrains Mono", "fontSize": 14, "fill": "#8a857a", "x": 640, "y": 556, "repeat": { "count": 12, "layout": "row", "spacing": 87.27 } }, { "id": "area", "type": "path", "anchor": "top-left", "x": 160, "y": 200, "stroke": null, "d": "M0 238 L87 219 L175 224 L262 197 L349 178 L436 187 L524 146 L611 119 L698 133 L785 82 L873 55 L960 18 L960 320 L0 320 Z", "fill": { "type": "linear", "angle": 180, "stops": ["#16141220", "#16141200"] }, "start": "2.4s", "enter": { "type": "fade", "duration": "0.8s" } }, { "id": "trend", "type": "line", "anchor": "top-left", "x": 160, "y": 200, "stroke": "#161412", "strokeWidth": 3, "points": [[0, 238], [87, 219], [175, 224], [262, 197], [349, 178], [436, 187], [524, 146], [611, 119], [698, 133], [785, 82], [873, 55], [960, 18]], "drawEnd": { "from": 0, "to": 1, "start": "0.3s", "duration": "2.4s", "ease": "easeInOutCubic" } }, { "id": "dot", "type": "ellipse", "width": 16, "fill": "#c92a26", "attach": "trend", "glow": { "radius": 18, "strength": 1.6, "color": "#c92a26" } }, { "id": "value", "type": "text", "attach": "trend", "y": -40, "font": "JetBrains Mono", "fontSize": 18, "fill": "#fbf9f4", "background": "#161412", "padding": 8, "cornerRadius": 2, "text": "66k", "start": "2.7s", "enter": "pop" } ] }]}The trend is a line layer with twelve points and an animated drawEnd, which trims the stroke from 0 (nothing) to 1 (the whole line):
"drawEnd": { "from": 0, "to": 1, "start": "0.3s", "duration": "2.4s", "ease": "easeInOutCubic" }The marker is a 16 px ellipse with one line of positioning: "attach": "trend". An attached layer sits on the drawn tip of a sibling path or line every frame. Its glow gives it a soft halo. Here is the dot following the tip:
$ vidmake trace blog-data-line.json -l dot --every 15 --from 0.3s --to 2.7s
FRAME TIME X Y W H ROT SCALE OPAC NOTES
9 0.30s 160.0 438.0 16.0 16.0 0.0 1.00 1.00
24 0.80s 195.6 430.2 16.0 16.0 0.0 1.00 1.00
39 1.30s 445.0 392.0 16.0 16.0 0.0 1.00 1.00
54 1.80s 922.4 295.2 16.0 16.0 0.0 1.00 1.00
69 2.30s 1102.8 225.3 16.0 16.0 0.0 1.00 1.00Two things we learned building this one:
A counting label at the tip is harder than it looks. drawEnd is a fraction of the line's length. For a gently rising line like this one, that is close to the fraction of the x-axis: at 1.3 seconds the eased progress is 0.29 and the dot is 30% of the way across. Steep segments, though, use up more length per month than flat ones. Our first version had a value label riding the tip, counting from 18k to 66k with the same easing as the line. Halfway through it read 42k while the dot sat between June and July, where the data says about 33k: an eased count from the first value to the last ignores every value in between. If the label has to be live, compute its value from the data at the tip yourself. Here, the label pops in once the line has landed, attached to the same tip, showing the final value.
Use path for filled areas. The soft gradient under the line is a path whose d is the same points plus the two bottom corners. A line layer is stroke-first: without a stroke, its fill becomes the stroke color, so a closed line with only a fill draws an outline rather than an area.
The month labels are a repeated text layer with pick(i, ['J', 'F', ...]), spaced 960 / 11 apart so each sits under its data point, and the gridlines are a repeated 1 px rect in a column.
#A donut from one arc
{ "fonts": [ { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }, { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" } ], "compositions": [{ "id": "donut", "description": "A donut chart from one repeated arc: cumulative start angles, one continuous sweep, and a legend from the same arrays", "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea", "props": { "pct": [42, 28, 18, 12], "start": [0, 42, 70, 88], "names": ["Rust", "JSON", "ffmpeg", "Coffee"] }, "layers": [ { "id": "track", "type": "arc", "width": 380, "x": 420, "y": 360, "stroke": "#e9e4d8", "strokeWidth": 54 }, { "id": "slice", "type": "arc", "width": 380, "x": 420, "y": 360, "strokeWidth": 54, "lineCap": "butt", "repeat": 4, "startAngle": "=pick(i, {{start}}) * 3.6 + 1", "endAngle": "=max(pick(i, {{start}}) * 3.6 + 1, min((pick(i, {{start}}) + pick(i, {{pct}})) * 3.6 - 1, 360 * easeInOutCubic(clamp(t / 1.8, 0, 1))))", "stroke": "=pick(i, ['#c92a26', '#161412', '#8a857a', '#d8d1c1'])" }, { "id": "center", "type": "text", "text": "${round(42 * easeOutCubic(clamp(t / 1.2, 0, 1)))}%", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 96, "letterSpacing": -4, "fill": "#161412", "x": 420, "y": 346 }, { "id": "center-label", "type": "text", "text": "of the stack", "font": "JetBrains Mono", "fontSize": 14, "letterSpacing": 1.7, "uppercase": true, "fill": "#8a857a", "x": 420, "y": 416 }, { "id": "legend", "type": "group", "width": 360, "height": 64, "anchor": "left", "x": 760, "y": 360, "repeat": { "count": 4, "layout": "column", "spacing": 76, "delay": "0.15s" }, "start": "0.6s", "enter": "fadeLeft", "children": [ { "id": "swatch", "type": "ellipse", "width": 16, "x": 8, "y": 32, "fill": "=pick(i, ['#c92a26', '#161412', '#8a857a', '#d8d1c1'])" }, { "id": "name", "type": "text", "text": "${pick(i, {{names}})}", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 38, "letterSpacing": -1.5, "fill": "#161412", "anchor": "left", "x": 36, "y": 30 }, { "id": "pct", "type": "text", "text": "${pick(i, {{pct}})}%", "font": "JetBrains Mono", "fontSize": 20, "fill": "#8a857a", "anchor": "right", "x": 360, "y": 32 } ] } ] }]}Four slices, one layer. An arc draws a stroke from startAngle to endAngle (degrees, 0 at twelve o'clock, clockwise). Each copy's start angle comes from a cumulative array, and its end grows with a single shared sweep:
"startAngle": "=pick(i, {{start}}) * 3.6 + 1","endAngle": "=max(pick(i, {{start}}) * 3.6 + 1, min((pick(i, {{start}}) + pick(i, {{pct}})) * 3.6 - 1, 360 * easeInOutCubic(clamp(t / 1.8, 0, 1))))"That endAngle reads better from the inside out. 360 * easeInOutCubic(...) is a sweep angle that goes once around the circle in 1.8 seconds. Each slice clips the sweep to its own range with min (don't pass my end) and max (don't go below my start), so the slices fill in turn, as if one pen drew the whole ring. The + 1 and - 1 leave a 2° gap between slices, and "lineCap": "butt" keeps the ends square.
The props hold both the percentages and their running totals ("start": [0, 42, 70, 88]). Expressions can't sum an array, so we compute the cumulative values when we write the props, which any script producing the data can do in one line.
The legend is the same pattern as the bar chart: a group repeated in a column, each copy with a swatch, a name and a percentage picked from the same arrays, entering with fadeLeft 0.15 seconds apart. The number in the middle counts up with round(42 * easeOutCubic(...)).
#Counters that stay honest
Every chart here has a number that counts. A few rules keep them correct:
- Count with the same easing as the shape it labels, so the number and the bar agree on every frame.
- Avoid overshooting eases such as
easeOutBackand springs on numbers. A bar that overshoots looks lively; a number that overshoots is briefly wrong.traceprints the text at each sample, so you can check:vidmake trace project.json -l value --every 2. - Format with
fmt()andround(), for examplefmt(round(x))for12,480, orfmt(x, '.', 2)for European separators.${x:1}prints one decimal.
#From data to MP4, unattended
Put together, a weekly chart video is a template project plus a props file:
vidmake validate chart.json --props-file week43.jsonvidmake still chart.json --props-file week43.json -t 3s -o check.pngvidmake render chart.json --props-file week43.json -o out/week43.mp4 --jsonvalidate still runs the layout lint with the new data, so a label that a longer series pushed off the canvas shows up as a warning. The still is a cheap image to look at, or to attach to a pull request, before the render.
See repeat, attach, expressions and props for the details.
Keep reading

Four reels, thirty seconds each
A Swiss poster, a piece of generative op-art, a data poem and a risograph collage. Each is a single vidmake JSON file, written, checked and rendered by an agent, using nothing but the four stock assets.
Read
What's new in vidmake 0.5
Markers name the beats of a video, decoration draws underlines, strike-throughs and highlights from the glyphs, design tokens and named easings bring a brand's system into a project, and WOFF2 fonts, synthetic italics, skewX, themed SVG icons, repeat origins and wipe edges close the gaps an agent hit making a 20-second ad.

What's new in vidmake 0.2.1
vidmake analyze shows the beats and loudness curves that audio-reactive expressions will see, rich-text spans take fontWeight, italic and font, drawMode: "total" draws many strokes with one pen, and source builds report the right version.