react-native-gifted-charts/README.md

112 lines
4.7 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
2022-03-09 14:19:19 +00:00
The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar 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
2021-11-24 06:30:10 +00:00
6. Fully customizable (see the [props](docs/docs.md))
2021-11-24 06:22:34 +00:00
7. Detailed [documentation](https://gifted-charts.web.app/) with examples
8. Support for **_combined_** Bar and Line charts
2021-08-04 21:14:35 +00:00
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)
2022-01-21 18:44:59 +00:00
<img src='/demos/animatedDataLine.gif' alt='' width=300/>
2022-01-12 11:39:12 +00:00
<img src='/demos/pielabbelled.svg' alt='' height=280 width=270/>
2021-08-14 09:40:12 +00:00
<img src='/demos/movingBars.gif' alt='' width=300/>
2022-03-09 14:27:40 +00:00
<img src='/demos/stacks.png' alt='' height=360 width=320/>
2021-08-08 23:54:50 +00:00
![alt text](/demos/lineArea.png)
2021-11-26 18:23:24 +00:00
<img src='/demos/cappedCombined.png' alt='' height=280 width=280/>
2022-01-12 11:39:12 +00:00
<img src='/demos/line.gif' alt='' height=300 width=290/>
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-23 17:05:37 +00:00
npm install react-native-gifted-charts react-native-linear-gradient 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
```
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
2021-11-24 06:19:49 +00:00
_Dear developers_! Your small contribution can make someone's day 😊
One of the ways you can contribute is to address an [open issue](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues).
Sometimes people report issues which don't exist, or request for features which are already present. Such issues can be addressed without pushing any code to the repo. Just show them in the comments how to do it.
2021-07-30 13:12:53 +00:00
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
2022-01-21 18:45:49 +00:00
| Issue | Solution |
| ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [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) |
| **Invariant Violation: requireNativeComponent: "RNCWebView" was not found in the UIManager.** | install `react-native-webview` |
| Setting `height`, `maxValue`, `stepValue`, `stepHeight`, or `noOfSections` breaks the chart | Please make sure that<br/> `maxValue = noOfSections * stepValue;` <br/>is followed. [See this](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/71) |
2021-11-18 08:39:51 +00:00
## To-dos
[To do list](./src/todos.md)
2021-07-30 13:12:53 +00:00
## License
MIT