2021-07-30 13:12:53 +00:00
|
|
|
# react-native-gifted-charts
|
|
|
|
|
2021-08-02 11:13:32 +00:00
|
|
|
The most complete library for Bar, Line, Area, Pie, and Donut charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.
|
2021-07-30 13:12:53 +00:00
|
|
|
|
2021-08-01 23:25:13 +00:00
|
|
|
![alt text](/demos/line.gif)
|
|
|
|
![alt text](/demos/area.gif)
|
|
|
|
![alt text](/demos/movingBars.gif)
|
|
|
|
|
2021-07-30 13:12:53 +00:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
```sh
|
|
|
|
npm install react-native-gifted-charts
|
|
|
|
```
|
|
|
|
|
2021-08-02 14:39:00 +00:00
|
|
|
Since we will be using LinearGradient, Svg and Canvas-
|
|
|
|
|
|
|
|
```sh
|
|
|
|
npm i react-native-linear-gradient react-native-svg react-native-canvas react-native-webview
|
|
|
|
```
|
|
|
|
|
|
|
|
For iOS-
|
|
|
|
|
|
|
|
```sh
|
2021-08-02 14:42:26 +00:00
|
|
|
cd ios && pod install
|
2021-08-02 14:39:00 +00:00
|
|
|
```
|
|
|
|
|
2021-07-30 13:12:53 +00:00
|
|
|
## Usage
|
|
|
|
|
2021-08-02 11:20:24 +00:00
|
|
|
The simplest usage of various types of charts can be done as below-
|
2021-08-02 11:00:43 +00:00
|
|
|
|
2021-07-30 13:12:53 +00:00
|
|
|
```js
|
2021-08-02 11:00:43 +00:00
|
|
|
import { BarChart, LineChart, PieChart } from "react-native-gifted-charts";
|
2021-07-30 13:12:53 +00:00
|
|
|
|
|
|
|
// ...
|
2021-08-02 11:02:45 +00:00
|
|
|
const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
|
2021-08-02 11:00:43 +00:00
|
|
|
|
2021-08-02 11:02:25 +00:00
|
|
|
<BarChart data = {data} />
|
|
|
|
<LineChart data = {data} />
|
2021-08-02 11:21:40 +00:00
|
|
|
<PieChart data = {data} />
|
2021-08-02 11:00:43 +00:00
|
|
|
|
2021-08-02 11:20:24 +00:00
|
|
|
// For Horizontal Bar chart, just add the prop horizontal to the <BarChart/> component
|
|
|
|
<BarChart data = {data} horizontal />
|
|
|
|
|
|
|
|
// For Area chart, just add the prop areaChart to the <LineChart/> component
|
2021-08-02 11:02:25 +00:00
|
|
|
<LineChart data = {data} areaChart />
|
2021-07-30 13:12:53 +00:00
|
|
|
|
2021-08-02 11:20:24 +00:00
|
|
|
// For Donut chart, just add the prop donut to the <PieChart/> component
|
2021-08-02 11:02:25 +00:00
|
|
|
<PieChart data = {data} donut />
|
2021-07-30 13:12:53 +00:00
|
|
|
```
|
|
|
|
|
2021-08-03 10:49:48 +00:00
|
|
|
## Props table
|
2021-08-03 10:06:06 +00:00
|
|
|
|
2021-08-03 10:52:50 +00:00
|
|
|
**[1. BarChart props](docs/BarChart/BarChartProps.md)** \
|
|
|
|
**[2. LineChart props](docs/LineChart/LineChartProps.md)** \
|
2021-08-03 10:51:50 +00:00
|
|
|
**[3. PieChart props](docs/PieChart/PieChartProps.md)**
|
2021-08-03 10:06:06 +00:00
|
|
|
|
2021-07-30 13:12:53 +00:00
|
|
|
## Contributing
|
|
|
|
|
|
|
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
MIT
|