r/reactjs • • 16d ago

Show /r/reactjs I built the same two charts in six React chart libraries and in hand-written SVG, and timed them

The charting library in a product I worked on had not had a release in over a year, so I wanted to know what we could move to. I built a survival curve and a scatter plot in nivo, Recharts, ECharts, visx, TanStack Charts and Chart.js, plus a version in plain React and SVG. Same spec, same data, timed the same way.

What I found (M3 Pro, headless Chromium, native speed):

- At typical dashboard sizes there was no clear speed winner. The timings for each chart were within one frame of each other.

- At 10,000 scatter points they spread out: hand-written SVG 24 ms, visx 33 ms, TanStack Charts 53 ms, Chart.js 80 ms, ECharts 86 ms, Recharts 310 ms, nivo's SVG scatter 3.2 s.

- Both Canvas implementations took longer to mount than plain SVG at that size.

- TanStack Charts needed the least code. Hand-written SVG added the least JavaScript, about 2 KB gzipped against 25–164 KB.

There is a playground where you can paste your own data and measure the libraries on your own machine, across twelve chart types: https://gusevp.github.io/chart-bench/

Code, raw data and notes on each port: https://github.com/GusevP/chart-bench

Full write-up with the method and limits: https://dev.to/gusevp/six-react-chart-libraries-against-hand-written-svg-what-i-found-46ib

One machine and two chart types, so treat it as a starting point. If I used your favourite library wrong, tell me or open a PR.

27 Upvotes

12 comments sorted by

2

u/GeekyAntsBFSI 15d ago

The “within one frame at normal dashboard sizes” finding is probably the most useful takeaway here. It leaves room to choose based on API fit and maintenance without overoptimizing the initial render.

I'm Interested how the 10k-point results change when updating the dataset or hovering across points. Mount time is one part of the experience; interaction latency could change the tradeoffs. Were animations and hit-testing configured comparably across the ports?

1

u/DutyEnvironmental838 15d ago

Thanks. That's how I read it too: at dashboard sizes, pick for API fit and maintenance.

Hover: yes, I measured it. The pointer sweeps the chart in 60 steps while a rAF loop records frame gaps, and I report the longest gap. On the 10k scatter with the CPU throttled 4×:

- nivo and ECharts: 16.8 ms, one frame

- TanStack and hand-written SVG: 33 ms

- visx and Chart.js: 50 ms

- Recharts: 133 ms

At native speed everything stays at one frame except Recharts, at 33 ms.

Hit-testing was not identical, and I didn't force it to be. Each port uses whatever its docs recommend:

- nivo hit-tests a precomputed Voronoi mesh, which is why its hover is cheap.

- ECharts and Recharts hit-test the item under the pointer.

- Chart.js uses mode 'nearest'.

- TanStack does a linear nearest-point scan by default. Its docs suggest a spatialIndex for dense data; I didn't add one.

- visx has no built-in hit-testing, so it's my own linear scan within 20 px. u/visx/voronoi would be the upgrade.

Animation is off everywhere for the timed runs, set the way each library's docs say (animate={false}, isAnimationActive={false} on every Recharts element, animation: false). nivo still routes geometry through react-spring with immediate: true, so springs are allocated even with animation off. That's part of its 10k mount cost.

Updates: the published runs only time mount. The playground measures update time on your own data, though, with the same libraries: https://gusevp.github.io/chart-bench/. One caveat: it can't resolve updates below two frames, so fast libraries only separate with CPU throttling on.

3

u/amayle1 16d ago

Glad to see numbers supporting what I felt intuitively. Switched from recharts to visx some years ago.

2

u/CesnaitisSwitlana 15d ago

tbh even without the numbers you can usually feel that sluggishness right away on heavier charts.

2

u/amayle1 15d ago

Also recharts API is too abstracted

2

u/bossier330 15d ago

I had a similar experience. I built a web app to run locally on my OrangePi, which rendered dozens of charts. With recharts, I was spending a lot of time trying to make rendering smooth, with no luck. So I re-implemented only what I needed, and the speed up was 100x. Wild how slow recharts was. It was useful for prototyping what kind of charting I wanted though.

2

u/Important_Pomelo_407 14d ago

Saw there was no demo video yet, so I made you one. Here’s the PR: https://github.com/GusevP/chart-bench/pull/1

and I used my repo to do it :) https://github.com/yasirwhite/OpenDemo

0

u/liyahlovee 7d ago

scichart js is a good benchmark for this, did you include first in your mount timings or just setup

1

u/DutyEnvironmental838 7d ago edited 7d ago

Good pointer. SciChart's Chart Bench measures something different: frame rate under extreme, mostly streaming workloads. Mine times how long a chart takes to first appear with dashboard-sized data, plus a few heavy cases.

On first paint: yes, it's included, not just setup. The clock starts when the harness calls mount() and stops two animation frames after the chart reports done. So it covers React render and commit, the library's own drawing, and the browser painting it. For the Canvas libraries "done" is the library's own rendered event, so the clock can't stop on a blank canvas. Bundle download and module evaluation happen before mount() and aren't counted; bundle size is reported separately.

Since the scale question keeps coming up, I'm adding a 100k-point tier and a few more libraries, including uPlot, Plotly's WebGL scatter and SciChart.

0

u/[deleted] 6d ago

[removed] — view removed comment

1

u/DutyEnvironmental838 6d ago

I've added 100K points and some charts in the playground. So you can test it on your own machine here https://gusevp.github.io/chart-bench/