react-native-gifted-charts/README.md

104 lines
3.1 KiB
Markdown
Raw Normal View History

2021-11-18 07:04:42 +00:00
# react-native-gifted-charts [![Rate on Openbase](https://badges.openbase.com/js/rating/react-native-gifted-charts.svg)](https://openbase.com/js/react-native-gifted-charts?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
2021-07-30 13:12:53 +00:00
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-04 21:15:46 +00:00
### Yet another chart library? Why?
2021-08-04 21:14:35 +00:00
**_To bring Life to your data_**
2021-08-08 23:54:50 +00:00
2021-08-04 21:14:35 +00:00
1. Plenty of features with minimal code
2. Apply animations to your charts on load and on value change, just by adding a prop
3. Smooth animations implemented using LayoutAnimation
4. Clickable and scrollable
5. Three-D and gradient effects
6. Fully customizable
7. Detailed documentation with examples
2021-08-08 23:56:19 +00:00
---
2021-08-08 23:54:50 +00:00
![alt text](/demos/altBars.svg)
![alt text](/demos/barPairs.svg)
2021-08-14 09:40:12 +00:00
<img src='/demos/movingBars.gif' alt='' width=300/>
2021-08-14 09:48:45 +00:00
<img src='/demos/lineLabelled.png' alt='' height=370 width=360/>
2021-08-08 23:54:50 +00:00
![alt text](/demos/lineArea.png)
2021-08-14 09:49:36 +00:00
<img src='/demos/line.gif' alt='' height=400 width=340/>
2021-08-08 23:54:50 +00:00
![alt text](/demos/pielabbelled.svg)
2021-08-01 23:25:13 +00:00
2021-08-08 23:56:19 +00:00
---
2021-07-30 13:12:53 +00:00
## Installation
```sh
2021-11-15 08:29:46 +00:00
npm install react-native-gifted-charts react-native-linear-gradient
```
For Line and Area charts, add the react-native-svg package too -
```
npm install react-native-svg
2021-07-30 13:12:53 +00:00
```
2021-08-07 11:55:16 +00:00
For Pie chart and Donut chart, these additional packages should be installed-
2021-08-02 14:39:00 +00:00
```sh
2021-08-07 11:55:16 +00:00
npm i react-native-canvas react-native-webview
2021-08-02 14:39:00 +00:00
```
2021-08-07 11:55:16 +00:00
2021-08-02 14:39:00 +00:00
For iOS-
```sh
2021-08-02 14:42:26 +00:00
cd ios && pod install
2021-08-02 14:39:00 +00:00
```
2021-08-13 11:28:55 +00:00
# Docs
2021-08-13 11:28:55 +00:00
[Documentation and gallery](https://gifted-charts.web.app/)
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
2021-08-03 13:20:52 +00:00
2021-08-02 11:20:24 +00:00
<BarChart data = {data} horizontal />
// For Area chart, just add the prop areaChart to the <LineChart/> component
2021-08-03 13:20:52 +00:00
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-03 13:20:52 +00:00
2021-08-02 11:02:25 +00:00
<PieChart data = {data} donut />
2021-07-30 13:12:53 +00:00
```
2021-08-03 12:26:35 +00:00
## Props tables
2021-08-03 10:06:06 +00:00
2021-08-08 23:27:06 +00:00
**[1. BarChart, Horizontal BarChart and Stacked Bar Chart props](docs/BarChart/BarChartProps.md)** \
2021-08-03 12:26:35 +00:00
**[2. LineChart and AreaChart props](docs/LineChart/LineChartProps.md)** \
**[3. PieChart and DonutChart 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.
2021-11-18 08:39:51 +00:00
## Common issues
| Issue | Solution |
| ---- | ---- |
2021-11-18 08:40:46 +00:00
| [When the isAnimated is enabled the labels are not showing for Bar Charts](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/18) | [Comment by Abhinav](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/18#issuecomment-971662656) |
2021-11-18 09:15:25 +00:00
| [BarChart - Value and section line don't match](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/35) | [Comment by the owner](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/35#issuecomment-972673281) |
2021-11-18 08:39:51 +00:00
2021-07-30 13:12:53 +00:00
## License
MIT