JS-modulesnetflow-plot
2.23.0 · API 2

netflow-plot

Plain charts from a table's columns, 22 types from bars and lines to box plots, hexbins, density, Q-Q, Voronoi cells and word clouds, drawn as netflow-scene drawing lists so the map's renderer, themes and SVG export draw them; the charts of Netflow Map's Charts tab; one call, toSvg(rows), draws a picture.

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).

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

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)

Chartnetflow-plotObservable PlotEChartsVega-Lite
bar1.2 / 1 / 12.2 / 2 / 44.6 / 6 / 711.1 / 12 / 12
line4.9 / 4 / 64.1 / 6 / 96.9 / 8 / 1318 / 28 / 29
scatter16 / 14 / 1611.6 / 12 / 1835.2 / 39 / 6547.7 / 48 / 47
hist1.2 / 1 / 22 / 3 / 3n/a6.9 / 12 / 12
box1.3 / 1 / 26.9 / 6 / 9n/a13.6 / 21 / 22
hexbin6.6 / 8 / 105.3 / 6 / 8n/an/a
density5.4 / 5 / 9n/an/a21.2 / 29 / 24

20,000 rows (ms, lower is better; Chromium / Firefox / WebKitGTK)

Chartnetflow-plotObservable PlotEChartsVega-Lite
bar3.7 / 5 / 53.7 / 6 / 84.4 / 8 / 139.9 / 21 / 22
line11 / 15 / 1510 / 13 / 269.2 / 14 / 1630.9 / 56 / 70
scatter129.4 / 206 / 17984.7 / 126 / 16540.2 / 108 / 72295.1 / 298 / 402
hist2.2 / 3 / 47.2 / 7 / 12n/a13 / 19 / 28
box7.2 / 5 / 945.7 / 41 / 55n/a44 / 53 / 77
hexbin11.8 / 14 / 1619.6 / 19 / 23n/an/a
density12.5 / 10 / 20n/an/a138.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

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

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

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).

netflow-plot finishes a 100,000-point line chart in 3.4 to 6.6 ms, ahead of uPlot (8 to 17 ms) and Chart.js (12 to 15 ms with its own thinning)
Chromium 156
uPlot11.3
Chart.js (its own thinning)13.4
Chart.js (all points)41.7
netflow-plot3.4
Firefox 158
uPlot7.6
Chart.js (its own thinning)12.3
Chart.js (all points)36.1
netflow-plot3.9
WebKitGTK 2.52.6
uPlot17.3
Chart.js (its own thinning)14.7
Chart.js (all points)32.6
netflow-plot6.6

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).

netflow-plot's lines-only file is 21.8 KB gzipped, smaller than uPlot (22.0 KB); the full pair is 62.6 KB, smaller than Chart.js (70.9 KB)
gzip KB
Lower is better.
uPlot22.0
netflow-plot lines-only file21.8
netflow-plot with netflow-scene62.6
Chart.js70.9

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.