React Charts is a declarative charting library for React, leveraging D3 and React-Spring for highly customizable and performant data visualizations. It's designed to be lightweight, fast, and fully responsive, offering a wide range of chart types including line, bar, area, and bubble charts. The library is currently in an active beta phase for its v3 major version, with frequent updates addressing bugs and adding new features, as evidenced by the recent `3.0.0-beta.*` releases. It differentiates itself by providing a robust API for custom tooltip rendering, axis configuration, and interactive elements, aiming for a balance between ease of use and advanced customization. The current stable release appears to be `2.0.0-beta.7`, but active development is focused on the `3.x` branch.
npm install react-chartsVerified import paths — ran on the pinned version, not inferred.
This quickstart renders a basic line chart with two series, demonstrating data structure, primary and secondary axis configuration, and wrapping the chart in a sized container.
Refer to the official v3 documentation or migration guides for updated API usage. Many props from v2 are now consolidated into a single `options` prop on the `Chart` component.
Pin the exact beta version in your `package.json` (`"react-charts": "3.0.0-beta.x"`) to prevent unexpected updates. Regularly check release notes for changes.
Ensure the `Chart` component is rendered within a container that has explicit `width` and `height` CSS properties, or use a flexible container like `flex: 1` in a flexbox layout.
Always specify `elementType: 'line'`, `elementType: 'bar'`, etc., on each secondary axis definition to explicitly control how the data is rendered. For example: `secondaryAxes: [{ getValue: d => d.secondary, elementType: 'line' }]`.Wrap the `<Chart />` component in a `div` with defined `width` and `height` styles, e.g., `<div style={{ width: '100%', height: '300px' }}><Chart ... /></div>`.Ensure both `primaryAxis` and all `secondaryAxes` objects include a `getValue` function, e.g., `primaryAxis: { getValue: datum => datum.primary }`.Run `npm install react-charts` or `yarn add react-charts`. If using TypeScript, ensure `react-charts` is listed in your `tsconfig.json`'s `types` or `typeRoots` if custom type declarations are used.