What it is and how it works
Load order: netflow-scene.js, then netflow-plot.js (this module draws through netflow-scene).
Plain charts from a table's columns: 22 chart types, drawn as the same drawing lists a netflow-scene map picture uses (rects, dots, curves, polys, labels).
make(rows, spec, options, NetflowScene)reads the columns named inspecand returns a scene.- One call draws a picture:
NetflowPlot.toSvg(rows)returns SVG text (see Use). To draw it yourself, the scene works with any netflow-scene renderer orNetflowScene.toSvg. Themes, palettes and export are the map's own. markAt(scene, x, y)finds the bar, dot, slice or cell under the pointer, with the rows behind it and a tooltip text.- No page, no DOM, no dependencies beyond netflow-scene.
Why it exists
Netflow Map's Charts tab draws these charts from a map's table of items or links, with the map's own look and export. Keeping the chart code here means the app and any other page use one tested copy.
Where it helps
- Charts of a map's items or links, drawn with the map's look.
- Quick charts in an offline, single-file page.
- A chart picture that exports to SVG with its own key.
Not for: animated or interactive chart editing; it draws one chart from one spec.
How it compares
Rows to an SVG on the page, each library drawing the same rows (cloud test machine, median of 7, after 2 warm-up runs). netflow-plot is make plus NetflowScene.toSvg put into the page; Observable Plot 0.6.17 builds its SVG in the page; ECharts 5.6.0 uses its SVG renderer with animation off; Vega-Lite 5.21.0 compiles and renders to SVG with Vega 5.30.0. n/a means the library has no such chart built in. Firefox and WebKitGTK time in whole milliseconds.
2,000 rows (ms, lower is better; Chromium / Firefox / WebKitGTK)
| Chart | netflow-plot | Observable Plot | ECharts | Vega-Lite |
|---|---|---|---|---|
| bar | 1.2 / 1 / 1 | 2.2 / 2 / 4 | 4.6 / 6 / 7 | 11.1 / 12 / 12 |
| line | 4.9 / 4 / 6 | 4.1 / 6 / 9 | 6.9 / 8 / 13 | 18 / 28 / 29 |
| scatter | 16 / 14 / 16 | 11.6 / 12 / 18 | 35.2 / 39 / 65 | 47.7 / 48 / 47 |
| hist | 1.2 / 1 / 2 | 2 / 3 / 3 | n/a | 6.9 / 12 / 12 |
| box | 1.3 / 1 / 2 | 6.9 / 6 / 9 | n/a | 13.6 / 21 / 22 |
| hexbin | 6.6 / 8 / 10 | 5.3 / 6 / 8 | n/a | n/a |
| density | 5.4 / 5 / 9 | n/a | n/a | 21.2 / 29 / 24 |
20,000 rows (ms, lower is better; Chromium / Firefox / WebKitGTK)
| Chart | netflow-plot | Observable Plot | ECharts | Vega-Lite |
|---|---|---|---|---|
| bar | 3.7 / 5 / 5 | 3.7 / 6 / 8 | 4.4 / 8 / 13 | 9.9 / 21 / 22 |
| line | 11 / 15 / 15 | 10 / 13 / 26 | 9.2 / 14 / 16 | 30.9 / 56 / 70 |
| scatter | 129.4 / 206 / 179 | 84.7 / 126 / 165 | 40.2 / 108 / 72 | 295.1 / 298 / 402 |
| hist | 2.2 / 3 / 4 | 7.2 / 7 / 12 | n/a | 13 / 19 / 28 |
| box | 7.2 / 5 / 9 | 45.7 / 41 / 55 | n/a | 44 / 53 / 77 |
| hexbin | 11.8 / 14 / 16 | 19.6 / 19 / 23 | n/a | n/a |
| density | 12.5 / 10 / 20 | n/a | n/a | 138.2 / 221 / 104 |
netflow-plot is the fastest of the four on bars, histograms, box plots and density charts at both sizes (at 20,000 rows it ties Observable Plot on bars in Chromium). Lines take up to 1.2 times the fastest library's time. Hexbins are the fastest at 20,000 rows and take 1.25 to 1.33 times Observable Plot's time at 2,000. Scatters are slower: at 2,000 rows up to 1.4 times Observable Plot (faster in WebKitGTK), and at 20,000 rows 1.9 to 3.2 times ECharts. Most of that time is the page reading 20,000 dots of SVG text; building the chart itself takes about 6 ms.
How to use it
Use
// netflow-scene.js first, then netflow-plot.js
var S = NetflowPlot.make(rows, { type: 'bar', x: 'region', y: 'sales', color: 'kind' }, { theme: 'dark', width: 900, height: 560 }, NetflowScene);
svgElement.outerHTML = NetflowScene.toSvg(S, 'Sales by region');
var hit = NetflowPlot.markAt(S, x, y); // { rows, t } or null
rows: plain objects. A column is read fromrow.attrs[key], thenrow[key]; passoptions.get(row, key)to read it another way.spec:type(one ofNetflowPlot.TYPES),x,y,color,size,agg(sum,mean,count,min,max,median),stack(stack,group,normalize,stream,none),horizontal,top(bars: the N biggest plus one bar for the rest, named Others; for a value that does not add up, such as a rate, that bar is the average and is named "Others, average"),bins,smooth(moving average window),index(lines from 100),cols(parallel lines and scatter matrix),sort(value,name,none).- Auto charts (since 2.11.0): a bar pick with more than 25 names and no values below zero becomes the 10 biggest plus Others, laid sideways so every name fits; pass
top: falseto keep every bar. Bar, dot and line charts whose values are all fractions between 0 and 1 (each bar one row or an average, and a name that is not a p-value, correlation, score or index) are written as percents; passpercent: falseto keep plain numbers. - Colors (since 2.12.0): bars and boxes use the same mauve-first colors as every other chart; a bar chart that goes below zero keeps navy above and red below. The Others bar of a top-N chart is light gray. Up to 16 lines are named at their ends when each has 14 px of height; with more, the key row comes back and the start values are left out.
- Three groups (since 2.15.0): when a chart has exactly three groups and uses the built-in colors, they are mauve, light green and orange, the three colors easiest to tell apart for every kind of color vision. Four or more groups, and any palette you choose, keep their usual order. A key with three names or fewer always shows all of them, shortening the names last.
options:theme,palette,width,height,get, and the optionaltitle,subtitle,source,highlight, andframe: true(ortheme: 'editorial') for the opt-in Economist frame: a small red tag at the top left and the source under the picture, with no rule above the source.- Clean look (on by default): bar and box charts write their values on the bars (and inside stacked parts that have room) and the median over each box, with no number axis or gridlines, in a calm blue-first color set. When the values would not fit, the number axis comes back on its own. Line charts (since 2.7.0) have no number axis or gridlines either: each line's first value sits at its left end and its last value after its name at the right end; a single line also gets its high and low.
clean: falsekeeps the number axis and gridlines. - Title block (optional, off unless given):
title(bold, top left),subtitle(under it) andsource(small, under the picture), set in theoptionsoptions. The block sits outside the picture, so nothing in the picture moves, and the SVG export draws it. highlight(optional): a series name from thecolorcolumn (or, with no color column, one bar) keeps its color and is drawn on top; the rest turn one gray. Works on every type that colors by a column. A name that is not there changes nothing, and a highlighted name is never folded into Other.NetflowPlot.warm()(optional, since 2.16.0): call it from an idle callback, afternetflow-scene.jshas loaded. It draws four small made-up charts once and throws them away, so the engine has already optimized the drawing code when your first real chart comes. 7 to 13 ms of work; the first four charts then took 0.55 (ungoogled Chromium 156), 0.82 (Firefox 158) and 0.64 (WebKitGTK 2.52.6) of the time without it. Returnstrue, orfalsewhenNetflowSceneis missing. Charts are the same with or without it.NetflowPlot.NEEDSlists which columns each type needs (a number, a category, text, or any).- Helpers:
ticks,timeTicks,kde,normInv,voronoiCells,quant,fmtNum.
Chart types: bar, line, area, scatter, connected, beeswarm, dotplot, hist, box, density, ridgeline, hexbin, heat, donut, radialbar, parallel, splom, qq, slope, marimekko, voronoi, words. A date column gives a calendar heat map.
A chart colored by a column keeps a 44 px key row at the top, so its picture and SVG carry their own key.
Use
// netflow-scene.js first, then netflow-plot.js
var S = NetflowPlot.make(rows, { type: 'bar', x: 'region', y: 'sales', color: 'kind' }, { theme: 'dark', width: 900, height: 560 }, NetflowScene);
svgElement.outerHTML = NetflowScene.toSvg(S, 'Sales by region');
var hit = NetflowPlot.markAt(S, x, y); // { rows, t } or null
rows: plain objects. A column is read fromrow.attrs[key], thenrow[key]; passoptions.get(row, key)to read it another way.spec:type(one ofNetflowPlot.TYPES),x,y,color,size,agg(sum,mean,count,min,max,median),stack(stack,group,normalize,stream,none),horizontal,top(bars: the N biggest plus one bar for the rest, named Others; for a value that does not add up, such as a rate, that bar is the average and is named "Others, average"),bins,smooth(moving average window),index(lines from 100),cols(parallel lines and scatter matrix),sort(value,name,none).- Auto charts (since 2.11.0): a bar pick with more than 25 names and no values below zero becomes the 10 biggest plus Others, laid sideways so every name fits; pass
top: falseto keep every bar. Bar, dot and line charts whose values are all fractions between 0 and 1 (each bar one row or an average, and a name that is not a p-value, correlation, score or index) are written as percents; passpercent: falseto keep plain numbers. - Colors (since 2.12.0): bars and boxes use the same mauve-first colors as every other chart; a bar chart that goes below zero keeps navy above and red below. The Others bar of a top-N chart is light gray. Up to 16 lines are named at their ends when each has 14 px of height; with more, the key row comes back and the start values are left out.
- Three groups (since 2.15.0): when a chart has exactly three groups and uses the built-in colors, they are mauve, light green and orange, the three colors easiest to tell apart for every kind of color vision. Four or more groups, and any palette you choose, keep their usual order. A key with three names or fewer always shows all of them, shortening the names last.
options:theme,palette,width,height,get, and the optionaltitle,subtitle,source,highlight, andframe: true(ortheme: 'editorial') for the opt-in Economist frame: a small red tag at the top left and the source under the picture, with no rule above the source.- Clean look (on by default): bar and box charts write their values on the bars (and inside stacked parts that have room) and the median over each box, with no number axis or gridlines, in a calm blue-first color set. When the values would not fit, the number axis comes back on its own. Line charts (since 2.7.0) have no number axis or gridlines either: each line's first value sits at its left end and its last value after its name at the right end; a single line also gets its high and low.
clean: falsekeeps the number axis and gridlines. - Title block (optional, off unless given):
title(bold, top left),subtitle(under it) andsource(small, under the picture), set in theoptionsoptions. The block sits outside the picture, so nothing in the picture moves, and the SVG export draws it. highlight(optional): a series name from thecolorcolumn (or, with no color column, one bar) keeps its color and is drawn on top; the rest turn one gray. Works on every type that colors by a column. A name that is not there changes nothing, and a highlighted name is never folded into Other.NetflowPlot.warm()(optional, since 2.16.0): call it from an idle callback, afternetflow-scene.jshas loaded. It draws four small made-up charts once and throws them away, so the engine has already optimized the drawing code when your first real chart comes. 7 to 13 ms of work; the first four charts then took 0.55 (ungoogled Chromium 156), 0.82 (Firefox 158) and 0.64 (WebKitGTK 2.52.6) of the time without it. Returnstrue, orfalsewhenNetflowSceneis missing. Charts are the same with or without it.NetflowPlot.NEEDSlists which columns each type needs (a number, a category, text, or any).- Helpers:
ticks,timeTicks,kde,normInv,voronoiCells,quant,fmtNum.
Chart types: bar, line, area, scatter, connected, beeswarm, dotplot, hist, box, density, ridgeline, hexbin, heat, donut, radialbar, parallel, splom, qq, slope, marimekko, voronoi, words. A date column gives a calendar heat map.
A chart colored by a column keeps a 44 px key row at the top, so its picture and SVG carry their own key.
Good to know
Limits
- A line over 5,000 points is drawn from each pixel column's lowest and highest point (first and last too), as a filled band at least 2 px thick (since 2.20.0; a stroked line before). A one-point spike is kept. Lines of 5,000 points or fewer draw every point as a stroke.
- Text sizes are estimated, not measured, so very long labels are cut with an ellipsis.
- A scatter of tens of thousands of dots makes one SVG element per dot, which is slow for a page to read; see the race below.
Speed and efficiency numbers
Against uPlot and Chart.js, cloud-browser runs
One line chart of 100,000 points (900 x 500), a fresh page for every library, shared 4-core cloud machine, one browser at a time, so treat gaps smaller than the pass-to-pass spread (5 to 20%) as ties. Lower is faster.
Compared: netflow-plot against uPlot 1.6.32 and Chart.js 4.6.1 (a finished 100,000-point line chart on screen, ms per chart).
How it is measured: every frame the page throws away its charts and builds new ones, 5 at a time and then 20 at a time, for 1.8 seconds each; the cost of one chart is the extra frame time per extra chart. A frame cannot start before the one before it is on screen, so this counts everything: the library's script, layout, painting and turning the shapes into pixels. Median of 2 passes (6 for netflow-plot in WebKitGTK). netflow-plot 2.20.0 and uPlot were raced together on 2026-11-21; the Chart.js rows are from the 2026-11-20 race. All four are given the same 100,000 points; netflow-plot reads them from 100,000 row objects, uPlot from two number columns, Chart.js from a list of x, y pairs.
Why not just time the call: uPlot's call returns in 1 to 3 ms, because it only schedules its drawing for a moment later. Counting that drawing, the page is busy for 5.5 ms in Chromium and 9.5 ms in Firefox, and until the canvas holds its pixels 10.9 ms in Chromium. netflow-plot's call (with the finished SVG in the page and laid out) takes 5.4 to 5.9, 6 and 7 to 12 ms in the three browsers, and Chart.js with thinning 7.2, 14.5 and 19. Earlier versions of this page compared netflow-plot's whole call with uPlot's 1 ms and so showed uPlot far ahead.
Given the same points as two number columns instead of rows (since 2.19.0), netflow-plot's own call drops from 5.5 to 3.9 ms in Chromium, one chart reaches the screen in about 11 ms instead of 12, and the steady-redraw cost per chart falls to 2.0 to 2.3 ms in Chromium, 2.5 to 2.6 in Firefox and 4.3 to 5.1 in WebKitGTK.
One chart alone, from the call to the frame the browser reports as shown: Chromium 11.7 to 12.7 ms against uPlot's 21.7 to 24.5; Firefox 21 to 23 against 21 to 22, a tie inside one screen refresh (from number columns Firefox showed it in 10 to 22 ms; WebKitGTK has no such report). Fairness notes: above 5,000 points on a line, netflow-plot keeps for each whole-pixel column its first, lowest, highest and last point, and since 2.20.0 draws them as a filled band, one piece per pixel column (97.5% of the pixels match the stroked line it replaced, which cost 4.0 to 5.5 ms per chart); uPlot also draws the lowest and highest of each pixel column, and Chart.js's min-max thinning does much the same, so those three draw about the same picture, while "all points" draws every one. WebKitGTK timings vary about 20% from run to run on this machine.
At netflow-plot 2.23.0, Firefox 158, one 100,000-point chart from rows, counted with the precise timer (24 tries for uPlot, 72 for ours): ours was on screen a refresh early in 66 of 72 tries (median 8.0 ms); uPlot 1.6.32 in 0 of 24 (median 21.2 ms). This is Firefox only, one machine; the table above is still the 2.20.0 race in all three browsers.
From a packed file's summaries (since 2.22.0; the lowest and highest value of every 256 rows, no column unpacked), a 1,000,000-point line takes 2.2 to 2.5 ms in Chromium 156, 3 in Firefox 158 and 4 to 6 in WebKitGTK 2.52.6, against 14, 15 to 17 and 17 to 19 from the two full columns, and against 18, 21 to 23 and 29 to 31 for uPlot's script alone on all the points (its painting not counted). The picture matches the one from all values on 99.26% of pixels (99.76% in WebKitGTK).
Compared: netflow-plot against uPlot and Chart.js (gzipped size in KB, smaller is better).
Same minifier for ours and uPlot; the rivals' own minified files otherwise. Measured at netflow-plot 2.20.0 and netflow-scene's current file, minified and gzipped (30.0 KB and 32.6 KB). The lines-only file (since 2.21.0) is netflow-plot-line.min.js: line charts only, the same SVG as the full pair, nothing else to load; uPlot also needs its style sheet (0.8 KB gzipped), which is not counted here. netflow-scene is needed to draw.
Source: Against uPlot and Chart.js, cloud-browser runs.
Credits
The code is Netflow Map's own (LFC Foundry); no code from other projects. The chart types are the common ones of plotting libraries; the Voronoi cells are cut by half-planes with a grid of nearby dots, a textbook method.