A chart is one node
ultrafast has three ready-made charts: bar_chart, line_chart and donut. Each is a block node. You give it the values and labels, and it builds the axis, the marks, the numbers and the animation in one house style. This is the whole document for the line chart below:
{
"version": 1,
"format": { "width": 1920, "height": 1080, "fps": 30, "duration": 6 },
"output": "out",
"nodes": {
"bg": { "op": "solid", "params": { "color": "#0e1116" } },
"chart": { "op": "block", "params": {
"kind": "line_chart",
"kicker": "WORLD, 2015 TO 2025",
"title": "Solar's share of electricity",
"values": [1.1, 1.3, 1.7, 2.2, 2.6, 3.2, 3.7, 4.6, 5.6, 6.9, 8.7],
"labels": "2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025",
"suffix": "%", "decimals": 1, "height": 500, "draw_time": 2.2,
"ink": "#f4efe6", "accent": "#ffb21e" } },
"source": { "op": "text", "params": {
"text": "Data: Ember and others, via Our World in Data (CC BY 4.0)",
"font": "ultrafast:mono", "size": 26, "color": "#8a8f98", "position": [192, 983] } },
"a": { "op": "over", "inputs": { "fg": "chart", "bg": "bg" } },
"out": { "op": "over", "inputs": { "fg": "source", "bg": "a" } }
}
}uf check line.json && uf export line.json line.mp4- The line draws on over
draw_timeseconds, a dot pops as the line reaches each value, and the area underneath fills in behind it ("area": falseleaves it out). highlightpicks the point that gets the large dot and its value; for a line it defaults to the last.suffix,prefixanddecimalsformat the numbers.- The plot runs from 0 (or the smallest value, if it's negative) to the largest value. Set
minandmaxto fix the scale. - The chart stays for
durationseconds (5 by default), then leaves. Put it later in a longer film with"timing": {"offset": 12}on the node. ink,mutedandaccentset the colours;display_font,text_fontandmono_fontthe type. Sizes follow the frame.
Bar charts
Swap the kind and the data. Bars rise one after another and each value counts up on top of its bar. The largest is drawn in the accent colour unless highlight names another index (-1 for none). The clip at the top of the page is this node:
"chart": { "op": "block", "params": {
"kind": "bar_chart",
"kicker": "SHARE OF ELECTRICITY FROM SOLAR, 2025",
"title": "Where the sun does the most work",
"values": [25.1, 21.8, 19.6, 17.9, 11.1, 9.4, 8.6],
"labels": "Chile,Spain,Australia,Germany,China,India,US",
"suffix": "%", "decimals": 1, "height": 500,
"ink": "#f4efe6", "accent": "#ffb21e" } },color sets the other bars. Labels are comma-separated; when a label holds a comma, separate them with | instead.
Donuts
"chart": { "op": "block", "params": {
"kind": "donut",
"kicker": "WORLD, 2025",
"title": "Where electricity comes from",
"values": [8.75, 32.96, 21.78, 13.96, 8.85, 8.54, 5.17],
"labels": "Solar,Coal,Gas,Hydro,Nuclear,Wind,Other",
"highlight": 0, "height": 520,
"ink": "#f4efe6", "accent": "#ffb21e" } },- Values are shares of their total, so they don't have to add up to 100. The middle counts up to the highlighted segment's share, here solar.
- The legend rounds each share to a whole percent. Pass two decimals, as here: rounded to one, wind's 8.54 becomes 8.5, which rounds down to 8% while its real share is nearer 9%.
colorstakes a comma-separated list of segment colours; by default the accent comes first, then a built-in palette.radiusandthicknesssize the ring.
Values from a CSV
The numbers above come from Our World in Data's download of Ember's electricity data, a plain CSV with one row per country and year:
$ curl -L -o share-electricity-solar.csv \
"https://ourworldindata.org/grapher/share-electricity-solar.csv?v=1&csvType=full&useColumnShortNames=true"
$ head -3 share-electricity-solar.csv
entity,code,year,solar_share_of_electricity__pct
ASEAN (Ember),,2000,0
ASEAN (Ember),,2001,0A document is JSON, so filling a chart from a file is a few lines in any language. This script puts the world's last eleven years into line.json:
# fill_line.py: the world's share of electricity from solar, 2015 to 2025, into line.json
import csv, json
rows = csv.DictReader(open("share-electricity-solar.csv"))
share = {int(r["year"]): float(r["solar_share_of_electricity__pct"]) for r in rows if r["entity"] == "World"}
years = range(2015, 2026)
doc = json.load(open("line.json"))
chart = doc["nodes"]["chart"]["params"]
chart["values"] = [round(share[y], 1) for y in years]
chart["labels"] = ",".join(str(y) for y in years)
json.dump(doc, open("line.json", "w"), indent=2)
print(chart["values"])$ python fill_line.py
[1.1, 1.3, 1.7, 2.2, 2.6, 3.2, 3.7, 4.6, 5.6, 6.9, 8.7]A video per row
For many charts of the same kind, keep one template and let uf batch fill it from a CSV. A column named node.param sets that param on that node; other columns, like name, only name the output files. The template is a 4:5 version of the line chart:
"format": { "width": 1080, "height": 1350, "fps": 30, "duration": 6 },
...
"chart": { "op": "block", "params": {
"kind": "line_chart",
"kicker": "2015 TO 2025",
"title": "Solar's share of electricity",
"values": [1.1, 1.3, 1.7, 2.2, 2.6, 3.2, 3.7, 4.6, 5.6, 6.9, 8.7],
"labels": "2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025",
"suffix": "%", "decimals": 1, "height": 640, "max": 30, "draw_time": 2.2,
"ink": "#f4efe6", "accent": "#ffb21e" } },
"source": { "op": "text", "params": { ..., "position": [108, 1262] } },# make_rows.py: one row per country for uf batch
import csv
src = list(csv.DictReader(open("share-electricity-solar.csv")))
places = ["World", "Chile", "Spain", "Australia", "Germany", "China", "India", "United States"]
with open("rows.csv", "w", newline="") as f:
out = csv.writer(f)
out.writerow(["name", "chart.kicker", "chart.values"])
for place in places:
share = {int(r["year"]): float(r["solar_share_of_electricity__pct"]) for r in src if r["entity"] == place}
out.writerow([place.lower().replace(" ", "-"), f"{place.upper()}, 2015 TO 2025",
",".join(f"{share[y]:.1f}" for y in range(2015, 2026))])name,chart.kicker,chart.values
world,"WORLD, 2015 TO 2025","1.1,1.3,1.7,2.2,2.6,3.2,3.7,4.6,5.6,6.9,8.7"
chile,"CHILE, 2015 TO 2025","1.7,3.3,4.9,6.3,7.5,9.0,12.0,17.3,20.1,22.8,25.1"
spain,"SPAIN, 2015 TO 2025","5.0,5.0,5.3,4.7,5.6,8.0,10.0,12.4,17.4,20.7,21.8"
...$ uf batch country.json --data rows.csv --out 'out/{name}.mp4'
1/8 out/world.mp4: 180 frames in 0.29 s
2/8 out/chile.mp4: 180 frames in 0.15 s
3/8 out/spain.mp4: 180 frames in 0.15 s
...
8/8 out/united-states.mp4: 180 frames in 0.15 s
8 videos in 1.4 s- A cell of numbers separated by commas becomes the list of values. Quote it in the CSV, as Python's
csvmodule does, because it holds commas. "max": 30in the template puts every country on the same scale. Without it, each chart scales to its own peak, and the world's 8.7% would look as tall as Chile's 25.1%.- A column that names a node the template doesn't have stops the batch before the first frame:
Error: row 1: `chrat.values`: no node `chrat` (did you mean `chart`?). A misspelled param on a real node doesn't. In 0.2.1,chart.valeusrendered every video with the template's values and said nothing. Write the row documents with--docsand runuf checkon one first: it warns`block` has no param `valeus`. - An empty cell keeps the template's value. More on templates, names and photos per row in personalized videos from a CSV.
Check before you post
uf review reads every frame and reports text that is clipped, too small, too brief, low in contrast or outside the safe areas. On the first version of these charts it caught the source line twice. At 22 px:
"kind": "small_text", "node": "source",
"message": "\"Data: Ember and others, via Our World in…\" is set at 22 px; below about 24 px it is hard to read on a phone"And once it was 26 px, still sitting near the bottom edge of the 16:9 frame:
"kind": "unsafe_area", "node": "source",
"message": "\"Data: Ember and others, via Our World in…\" sits in the safe margin (bounds 195,1017 to 1075,1037)"Moving it up to y 983 cleared both. All four documents on this page, and the eight row documents the batch made (uf batch ... --docs DIR writes them out), now review with no issues.
16:9, 4:5 and 9:16 from one document
Charts lay themselves out from the frame, so the same document renders for YouTube, an Instagram post and Shorts or Reels. format.width and format.height work as batch columns too, so one CSV gives all three:
name,format.width,format.height,chart.height,source.position
youtube,1920,1080,500,"192,983"
instagram,1080,1350,640,"108,1262"
shorts,1080,1920,900,"108,1800"$ uf batch line.json --data shapes.csv --out '{name}.mp4'
1/3 youtube.mp4: 180 frames in 0.33 s
2/3 instagram.mp4: 180 frames in 0.15 s
3/3 shorts.mp4: 180 frames in 0.19 s
3 videos in 0.7 sThe chart's own height and the source line's position are in pixels, so they change with the shape. The title, labels and numbers scale with the frame on their own.
Charts the blocks don't draw
A chart block expands into ordinary path, shape and text nodes, and you can write those yourself for any chart the blocks don't cover. The Keeling Curve example does this: every monthly mean of carbon dioxide at Mauna Loa since March 1958, 824 values, is one path whose d a script wrote from NOAA's file. Keying its trim_end up to 1 draws the curve on, and morph blends it into a stretched copy of itself (to) for the dive into 2025. Its full document is keeling.json.
The same parts make other charts: a shape per point for a scatter plot, one path per series for several lines, text with a keyed number for a counter that tracks a value.
Data from an API works the same way as data from a CSV. A film of a GitHub repo fills a line chart, a bar chart and a donut from the GitHub API and puts them in one film with a title and an end card.
Render times
| Command | Frames | Time |
|---|---|---|
uf export line.json | 180 | 0.54–0.57 s |
uf export bar.json | 180 | 0.51–0.57 s |
uf export donut.json | 180 | 0.52–0.55 s |
uf export country.json, 1080×1350 | 180 | 0.57–0.62 s |
uf batch country.json, 8 rows | 8 × 180 | 1.68–1.70 s |
uf batch line.json, 3 shapes | 3 × 180 | 1.00–1.46 s |
Wall clock from the command to the last file, warm, three runs each (five for the eight-row batch, six for the shapes), on one RTX 5090 workstation with the published 0.2.1 binary, 6-second videos at 30 fps to H.264. The time inside a batch's own report leaves out start-up, which is why it says 1.3 or 1.4 s. The clips on this page are smaller web copies of these exports.
Limits
- One series per chart.
bar_chartandline_charttake one list of values: no grouped or stacked bars and no second line. Build those from paths and shapes, as above. - No bar chart race. There's no block for bars that reorder over time.
- No y axis or gridlines. Bars carry their own values and the line labels its highlighted point.
- Up to about nine x labels. With more values, the chart shows every second or third label and always the last. Blank labels count in that thinning, so pass every label and let the chart pick; a hand-thinned list like
2015,,,,,2020,,,,,2025loses 2020. - Video, not a web chart. For a chart people can hover and zoom on a page, use a charting library. ultrafast makes video files, and it needs a GPU: an Apple silicon Mac, or Linux or WSL2 with Vulkan.
Questions
How do I turn a CSV into an animated chart video?
Put the numbers in a chart block's values and the categories in labels, then run uf export chart.json chart.mp4. A few lines of Python can read the CSV and fill the document, and uf batch chart.json --data rows.csv makes one video per row, with a chart.values column setting each row's numbers.
Can I make a bar chart race?
Not with a ready-made block. bar_chart draws one set of values that rise in turn; there's no block for bars that reorder over time.
Can I make animated chart videos with Python?
Yes. Python can write the ultrafast document, as fill_line.py and make_rows.py do on this page, and ultrafast renders it on the GPU. matplotlib's animation module is the other common route: it draws each frame on the CPU and saves the video through FFmpeg.
What size should a chart video be for YouTube, Instagram and Shorts?
1920×1080 (16:9) for YouTube, 1080×1350 (4:5) for an Instagram post, and 1080×1920 (9:16) for Shorts, Reels and TikTok. Chart blocks lay themselves out from the frame, so one document makes all three with format.width and format.height columns in a batch.
How long does a chart video take to render?
On one RTX 5090 workstation with ultrafast 0.2.1, each 6-second 1080p chart on this page exported in 0.51 to 0.57 s, and eight 4:5 videos, one per country, took 1.68 to 1.70 s as a batch.