@nivo/line and recharts are declarative SVG-based charting libraries built specifically for React, offering component-driven APIs for building interactive data visualizations. chart.js is a versatile Canvas-based library that supports multiple chart types across frameworks but requires imperative setup within React. @vx/shape is a low-level SVG primitive collection formerly maintained by Airbnb, now deprecated in favor of @visx. These tools serve different needs β from quick dashboard integration to custom visualization engines.
@nivo/line, recharts, chart.js, and @vx/shape all solve the problem of displaying data visually, but they approach it from different angles. Some prioritize ease of use, others focus on raw performance or low-level control. Let's compare how they handle rendering, integration, and maintenance.
The underlying technology dictates performance and styling capabilities.
@nivo/line uses SVG elements.
// @nivo/line: SVG-based
import { Line } from '@nivo/line';
<Line
data={data}
margin={{ top: 20, right: 20, bottom: 20, left: 20 }}
width={400}
height={300}
/>
recharts also uses SVG elements.
// recharts: SVG-based
import { LineChart, Line, XAxis, YAxis } from 'recharts';
<LineChart width={400} height={300} data={data}>
<XAxis dataKey="name" />
<YAxis />
<Line type="monotone" dataKey="uv" />
</LineChart>
chart.js uses HTML5 Canvas.
// chart.js: Canvas-based
import Chart from 'chart.js/auto';
useEffect(() => {
const ctx = canvasRef.current.getContext('2d');
new Chart(ctx, {
type: 'line',
data: { datasets: [{ data: data }] }
});
}, [data]);
@vx/shape uses raw SVG primitives.
<Line> or <Arc>.// @vx/shape: Low-level SVG
import { Line } from '@vx/shape';
<svg width={400} height={300}>
<Line
from={{ x: 0, y: 0 }}
to={{ x: 400, y: 300 }}
stroke="#fff"
/>
</svg>
How well the library fits into the React lifecycle matters for maintainability.
@nivo/line is fully declarative.
useEffect needed for basic usage.// @nivo/line: Declarative
<Line data={data} animate={true} />
recharts is fully declarative.
// recharts: Declarative
<LineChart data={data}>
<Line dataKey="value" />
</LineChart>
chart.js is imperative.
useEffect to sync React state with Chart instance.// chart.js: Imperative
useEffect(() => {
const chart = new Chart(ctx, config);
return () => chart.destroy(); // Manual cleanup
}, []);
@vx/shape is declarative but low-level.
// @vx/shape: Declarative Primitives
<Line from={start} to={end} />
Some libraries use configuration objects, others use component composition.
@nivo/line uses a mix of config and components.
// @nivo/line: Prop-based config
<Line
colors={{ scheme: 'nivo' }}
tooltip={({ point }) => <CustomTooltip point={point} />}
/>
recharts uses component composition.
<Tooltip /> or <Legend /> as children.// recharts: Component composition
<LineChart data={data}>
<Tooltip content={<CustomTooltip />} />
<Line dataKey="uv" />
</LineChart>
chart.js uses configuration objects.
options object.// chart.js: Config object
options: {
plugins: {
tooltip: {
callbacks: {
label: (context) => `Value: ${context.raw}`
}
}
}
}
@vx/shape requires manual composition.
// @vx/shape: Manual build
<svg>
<GridRows scale={yScale} />
<Line path={path} />
<AxisBottom scale={xScale} />
</svg>
Library health impacts long-term project stability.
@nivo/line is actively maintained.
recharts is actively maintained.
chart.js is actively maintained.
@vx/shape is DEPRECATED.
@vx namespace was renamed to @visx.@vx.@visx/shape.// @vx/shape: Deprecated warning
// β Avoid: import { Line } from '@vx/shape';
// β
Use: import { Line } from '@visx/shape';
| Feature | @nivo/line | recharts | chart.js | @vx/shape |
|---|---|---|---|---|
| Rendering | π¨ SVG | π¨ SVG | πΌοΈ Canvas | π¨ SVG |
| React Fit | β Declarative | β Declarative | β οΈ Imperative | β Declarative |
| Setup Effort | π’ Low | π’ Low | π‘ Medium | π΄ High |
| Performance | π‘ Medium | π‘ Medium | π’ High | π’ High |
| Status | β Active | β Active | β Active | β Deprecated |
recharts is the go-to for standard React dashboards π β it feels natural to React developers and covers 90% of use cases with minimal code.
@nivo/line is the choice for design-heavy applications π¨ β it offers better defaults for animations and styling out of the box.
chart.js wins on performance for large datasets π β use it when SVG becomes too slow or you need non-React framework support.
@vx/shape should be avoided π β it is deprecated. If you need low-level primitives, use @visx/shape instead.
Final Thought: For most React projects, start with recharts or @nivo/line. Only reach for chart.js if you hit performance limits, and never start new work with @vx.
Choose chart.js if you need a lightweight, framework-agnostic solution with broad chart type support (bar, line, pie, radar). It is suitable for applications where Canvas rendering performance is critical for large datasets, and you can manage imperative DOM updates.
Choose @nivo/line if you need highly customizable, aesthetically pleasing charts with built-in animations and tooltips. It is ideal for projects where design consistency and interactive features are priorities, and you want a balance between configuration and component control.
Do NOT choose @vx/shape for new projects. It is deprecated and replaced by @visx/shape. Only consider it if maintaining legacy code that relies on specific low-level SVG primitives without higher-level chart abstractions.
Choose recharts if you want a composable, React-native API that feels like writing standard JSX. It is best for teams that prioritize developer experience, easy customization via components, and strong community support for common dashboard use cases.
Simple yet flexible JavaScript charting for designers & developers
All the links point to the new version 4 of the lib.
In case you are looking for an older version of the docs, you will have to specify the specific version in the url like this: https://www.chartjs.org/docs/2.9.4/
Instructions on building and testing Chart.js can be found in the documentation. Before submitting an issue or a pull request, please take a moment to look over the contributing guidelines first. For support, please post questions on Stack Overflow with the chart.js tag.
Chart.js is available under the MIT license.