Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-svg-charts

> 前端框架
Open source

One library to rule all charts for React Native

2.4K stars0 likes1 views
WebsiteGitHub

About

One library to rule all charts for React Native

react-native-svg-charts

Welcome to react-native-svg-charts!

react-native-svg-charts provides SVG Charts support to React Native on iOS and Android, and a compatibility layer for the web.

Looking for maintainers! I alone don't have the time to maintain this library anymore. Preferably looking for somebody who uses this library in their proffesional work (how I originally got the time to maintain).

version 5 is now available!

A much improved decorator system has been introduced, allowing for greater flexibility and less complexity. See releases for more information.


In order to not bloat this README too much we've moved some examples over to react-native-svg-charts-examples. There we will try to showcase the really cool things you can do with this library. This README will try to keep things as simple as possible so that everybody can get up and running as fast as possible.

Prerequisites

This library uses react-native-svg to render its graphs. Therefore this library needs to be installed AND linked into your project to work.

Other than the above dependency this library uses pure javascript and supports both iOS and Android

Getting Started

Make sure to follow the installation mentioned in the Prerequisites

Then you can install the library using either yarn:

bash
yarn add react-native-svg-charts

or npm:

bash
npm install --save react-native-svg-charts

Now you're good to go!

Motivation

Creating beautiful graphs in React Native shouldn't be hard or require a ton of knowledge. We use react-native-svg in order to render our SVG's and to provide you with great extensibility. We utilize the very popular d3 library to create our SVG paths and to calculate the coordinates.

We built this library to be as extensible as possible while still providing you with the most common charts and data visualization tools out of the box. We're very proud of our "decorator" support. All charts can be extended with "decorators", a component that somehow styles or enhances your chart. Simply pass in a react-native-svg compliant component as a child to the graph and it will be called with all the necessary information to layout your decorator. See each chart for information on what data the decorator will be called with.

Feedback and PR's are more than welcome

Running

If you want to test out the library you can clone this repository and run it. We suggest that you test out the storybooks that we've implemented. Most of the charts are implemented with knobs so that you can tweak most properties and see their behavior live.

Clone the repo and run the following:

bash
yarn

# for iOS
(cd ios && pod install)
react-native run-ios

# for Android
react-native run-android

yarn storybook

# and then reload your device

Common Props

Property Default Description
data required An array of arbitrary data - use prop xAccessor/yAccessorto tell the chart about the data structure
yAccessor ({ item }) => item A function that takes each entry of data (named "item") as well as the index and returns the y-value of that entry
xAccessor ({ index }) => index Same as yAccessor but returns the x-value of that entry
yScale d3Scale.scaleLinear A function that determines the scale of said axis (only tested with scaleLinear, scaleTime & scaleBand )
xScale d3Scale.scaleLinear Same as yScale but for the x axis
svg {} an object containing all the props that should be passed down to the underlying react-native-svg component. See available props
animate false PropTypes.bool
animationDuration 300 PropTypes.number
style undefined Supports all ViewStyleProps
curve d3.curveLinear A function like this
contentInset { top: 0, left: 0, right: 0, bottom: 0 } An object that specifies how much fake "margin" to use inside of the SVG canvas. This is particularly helpful on Android where overflow: "visible" isn't supported and might cause clipping. Note: important to have same contentInset on axis's and chart
numberOfTicks 10 We use d3-array to evenly distribute the grid and dataPoints on the yAxis. This prop specifies how many "ticks" we should try to render. Note: important that this prop is the same on both the chart and on the yAxis
showGrid true Whether or not to show the grid lines
yMin undefined Alter how the chart bounds are calculated
yMax undefined Alter how the chart bounds are calculated
xMin undefined Alter how the chart bounds are calculated
xMax undefined Alter how the chart bounds are calculated
children undefined One or many react-native-svg components that will be used to enhance your chart

Common arguments to children

Property Description
x a function that normally accepts the index of a data point an returns its 'x' location on the canvas
y a function that normally accepts the value of a data point an returns its 'y' location on the canvas
width the width of the canvas in pixels
height the height of the canvas in pixels
data the same data array provided to the chart, use this to map over your data points if you want decorators on each point
ticks if numberOfTicks has been provided to the chart this array will include the calculated tick values (useful for grids)

Components

This library currently provides the following components

  • Area
  • StackedAreaChart
  • Bar
  • StackedBarChart
  • Line
  • Pie
  • ProgressCircle
  • YAxis
  • XAxis

Also see

  • Children
  • Grid

AreaChart

Example

…

Props

See Common Props

Property Default Description
start 0 The value of which the area should start (will always end on the data point)

Arguments to children

Supports all Common arguments to children

StackedAreaChart

Very similar to an area chart but with multiple sets of data stacked together. We suggest that you read up on d3 stacks in order to better understand this chart and its props See [Area stack chart with Y axis](https://github.com/JesperLekland/react-native-svg-charts-examples/blo

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptchartsd3react-nativereact-native-charts

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架