Skip to content
Logo Theodo

How I chose the #1 graph library for my React project

Tomas Piga10 min read

TL;DR

Reviewed the 6 most recommended React libraries and found the following answers among them:

Read on to find out why 🙀🚀📈👾

Context

I’ve witnessed projects lose time and trust because they picked a library that didn’t match their needs. Don’t make the same mistake and use this guide to make a better decision about both your graphing library, but also about other types of libraries in the future.

I curate a selection of the best React graph libraries, dig into what makes good measures, then critically and succinctly review their advantages. For the best JavaScript graphing library instead, see our neighbour article.

Overview

  1. The libraries
  2. The criteria
  3. Evaluation
    1. Popularity
    2. Reviews
    3. Functionality
    4. Maintainability
    5. Size
    6. Ease of development / prototyping
  4. Epilogue

The libraries

There’s several ways the top x libraries can be chosen: asking colleagues, reading online forums, or articles. For a strong consensus, I reviewed the first 6 articles [1, 2, 3, 4, 5, 6] I found after searching for top React libraries. By seeing which library was listed the most, I was able to reduce the list from over 100 to the following 6 most recommended libraries:

The criteria

To build a great product using many libraries, you need to turn your requirements into the correct technical decisions almost daily.

When working on new features, or even new products entirely, I’ve noticed 7 elements which can be important to saving time. I’ve turned these into criteria in order to easier guide you through these decisions.

Although not all may be relevant for every library, reading through these can at least help raise questions to clarify the intention and product characteristics. If you know the answers, then pick the ones that are relevant to your project.

Popularity

An easy instant indicator for the general appeal of a library and how well it has performed in the community over a long time

Reviews

A graphing library is a product at the end of the day which is why the ratio of good reviews to general use can help discriminate between good and bad implementations

Functionality

Not all graphing libraries offer every kind of chart and the features you need. The important thing here is to:

Maintenance

Sicara asked the CTO of a data visualisation company what was the first thing he checked to choose the right JS charting library. His answer was: the activity and popularity of the Github repository.

Size and dependancies

Design

The presentation of graphs in a library is a very opinionated topic. A library coming with a great design out-of-the-box can:

Documentation

There are so many variables and use cases of libraries that the docs and examples are absolutely key to both saving time, and having a stress-free developer experience in general, more specifically:

Popularity

To gauge the popularity, I looked at the number of package downloads over the last 2 years.

Number of downloads of the top 6 React graphing libraries. This chart won’t stay updated, but you can check out the comparison directly.

As you can see Recharts has double the number of downloads than the second-best. And even Chart.js for React (react-chartjs-2) has a few times more downloads than any of the others.

The chart allows us to see that downloads are not only currently high, but have been historically high and so a good indication for a lot of community experience and time with these libraries.

Reviews

To try to estimate the general quality of a library, I contrast the stars of their GitHub repository versus their downloads.

StarsDownloadsRating (%)
React-Vis5,96351,29012
Victory3,26350,8416
Recharts12,143219,5435
VX6,26634,43326
Nivo5,60422,84224
Chart.js (React)2,104132,6812

Legend: Where rating is the stars over the number of downloads.

Nivo and VX are really well received with about 1 in every 4 people starring the library. Meanwhile, only about 1 in every 50 people star the Chart.js (React) library. This really shows popularity is not necessarily correlational with quality.

Instead, one reason they could be so popular is through SEO optimisation. Recharts and Chart.js (React) are both ranked #1 for googling terms “charts react” and “charts javascript” respectively. Chart,js is also very popular because of its strong and historic JavaScript version (see this).

Functionality

General use

There are 4 main functions for graphs and so first I define what types of graph could be expected for each. Then, I look through the libraries and see how well they cover these to give

BasicScientificFinancialStatistical
React-VisLine Series,
Bar Series,
Label Series,
Arc Series,
Area Series
Contour Series,
Heatmap Series,
Radar Chart,
Parallel Coordinates
Time Chart,
Candlestick,
Whisker Series,
Zoom,
Tooltips
Whisker Series,
Sunburst,
Treemap,
Polygon Series
VictoryVictoryLine,
VictoryBar,
VictoryScatter,
VictoryPie,
VictoryArea
VictoryLine (polar property),
VictoryPolarAxis,
VictoryVoronoi
Time Scale,
VictoryCandleStick,
VictoryCursorContainer,
VictoryZoomContainer,
VictoryBrushContainer
VictoryErrorBar,
VictoryBoxPlot
RechartsLineChart,
BarChart,
ScatterChart,
PieChart,
AreaChart
RadarChart,
PolarGridTime Ticks,
VXShape.Line,
Shape.Bar,
Shape.Circle,
Shape.Pie,
Shape.AreaClosed
Heatmap.Heatmap,
Shape.LineRadial,
Voronoi.VoronoiPolygon,
RadarChart
Areas demo (time),
Stats plots demo,
Threshold demo
BoxPlot + ViolinPlot,
TreeMap
NivoLine,
Bar,
ScatterPlot,
Pie,
Stream
Heatmap,
Bump (parallel),
ParallelCoordinates,
Voronoi,
RadarChart
BulletSunburst,
TreeMap,
Waffle
Chart.js (React)Line,
Bar,
HorizontalBar,
Scatter,
Bubble,
Doughnut, Pie
Polar,
Radar
Time x-axis

Legend: Green means good support, yellow means partial support, and blank means either no support, or very limited support.

Features

AnimationsInteractiveResponsiveTypeScript
React-VisNo brushDefinitelyTyped
Victory ChartsCustomisable
Recharts
VXSpecialised zoomvx-typescript-kitchensink
NIVOBestNo, PRs exist but outdatedvx-typescript-kitchensink
Chart.js (React version)Not easilyPartial

Legend: Green means good support, yellow means partial support, and red means either no support, or very limited support.

Unique Features

TypeScript

It’s unusual to find libraries natively typed in TypeScript, in which case you can search for the separate NPM definition here. If there’s no official definition, Definitely Typed contains high quality definitions. Alternatively, you may find some that people have submitted through various issues or open pull requests.

Licensing

All of these libraries currently have an MIT license. This means they are free-to-use for both personal projects and commercially. In general, you can find licensing in the top-right of a library’s GitHub page.

Maintainability

Current support

The pulse of a library is GitHub’s way of showing you the contribution to a library in terms of commits over time. You can find it in the insights tab of each repository.

React-Vis (Feb 21, 2016 – Jul 20, 2019)

Victory (Jul 26, 2015 – Jul 20, 2019)

Recharts (Aug 2, 2015 – Jun 29, 2019)

VX (Mar 19, 2017 – Jul 20, 2019)

Nivo (Apr 10, 2016 – Jul 20, 2019)

Charts.js, React (May 1, 2016 – Jul 20, 2019)

Chart.js (Mar 17, 2013 – Aug 12, 2019)

Victory looks to have the best pulse, with React-Vis and Recharts also having fairly regular contributions.

Continued support and bugs

The distribution of commits across the top contributors can show its support structure and the likelihood of continued support. Under the issues tab, you can see both bugs and features that have been previously reported (open issues), and solved (closed issues) - a great indicator of the library healthiness.

CreationContributorsSPOF (%)Chance of bug
React-VisFeb, 201640391 in 255
VictoryJul, 201531711 in 333
RechartsAug, 201551791 in 376
VXMar, 201728901 in 889
NivoApr, 201611961 in 300
Chart.js (React)May, 201613501 in 687
Chart.jsMar, 201797571 in 1,257

Legend: contributors are the number of users who made at least 2 commits, SPOF is the Single Point of Failure chance calculated by taking the highest contributors commits over the top 5 contributors’ commits, and the change of bug is the number of open issues over the number of downloads (essentially the likelihood that you’ll encounter an existing issue).

The most distributed support is in React-Vis and Chart.js. React-Vis is backed by Uber, so there is probably a dedicated team or rota around maintaining the library. Even though Chart.js doesn’t belong to a company, its JavaScript contribution profile is very diverse.

The libraries which look to have the least bugs are VX and Chart.js. Bear in mind that this is only an estimate as some may be more common than others. Regardless of this, most libraries reach a common number, with an exception of VX which is exceptional in keeping open issues low; only 33 open.

Size

To find out the size of a library, you need to both look at its own size and also the size of its dependencies. Bundlephobia gives you an instant computed response, and allows you to see the library size growth over time.

Compressed size (KB)DependenciesModularisedNotes
React-Vis79.118No
Victory116.725No
Recharts119.211No
VX52.4-Yes@vx/grid, @vx/group, @vx/shape, @vx/axis, @vx/scale
Nivo82.511Yes@nivo/line
Chart.js (React)120.45NoAlso requires charts.js

Legend: Size is the min-zipped size of the library including all of its dependancies, modularised means whether the library is split into components so you can import only the parts

For a simple graph, in a standard 3G network at 50KB/s:

Though the former will tend towards the latter as you start to add more complex charts.

Ease of development / prototyping

Design

This is a subjective topic, so this section is for determining the generally preferred design and UX philosophy. To confirm this, I asked colleagues and contacts throughout London to rank these 6 libraries in order of best to worst. The final statistic is their average rank (from 1 being the best to 6 being the worst).

The results showed that Nivo and Recharts were much preferred over the React-Vis, VX, and Victory, with Chart.js sitting somewhere between.

The Nivo design was said to be accessible. Although VX appeared stylish, the impression was that it was trying too hard to have an opinionated great look, whilst disregarding some standard UX.

Documentation

SearchResourcesExamplesCodePen / JSFiddle
React-VisDocsShowcase
Storybook
Line
VictoryDocsIn docsResponsive docs
RechartsDocsIn docs
Showcase
Line
Bar
Pie
VXDocsShowcase
NivoDocsIn docs
Storybook
Chart.js (React)JavaScript DocsIn docs
React showcase
JavaScript Line
JavaScript Bar
JavaScript Pie

Victory leads in this area with each of its examples being responsive - allowing you to easily add and quickly test parameters. The search worked for both graphs and props to the graph which made it very easy to find whether certain features existed.

Nivo is the follow-up as the interactive demos allow a very clean way for even a UX/designer/product manager to find the right combination. However it lacked a thorough search throughout the library and the demo code itself wasn’t directly editable.

Epilogue

The most important part of all of this is to find out what your requirements are. What are you building?

Once you know that, then you can pick the library that suits exactly your need and enjoy the benefit that comes from that. Whether this is an improved user experience on mobile, or an excellent prototype to show to your stakeholders. Unsure about your requirements? Go with the catch-all React-Vis.

If you’ve found this useful, you’ll probably like some of the other articles we’ve posted on our Theodo blog, so check them out! If you’d like to join us, or start a project with us, visit our website for more info!

Liked this article?