react-native-gifted-charts/README.md

117 lines
4.9 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
2022-08-06 13:54:59 +00:00
**Alert:**
This library doesn't support web apps yet. Use this library if you are planning mobile first.</br>
However, we are planning to add support for web which will be available soon.
2022-07-02 17:16:16 +00:00
<img src='/demos/bars.png' alt=''/>
<img src='/demos/lineArea.png' alt=''/>
2022-07-03 12:03:17 +00:00
<img src='/demos/blues.png' alt=''/>
2022-07-02 17:26:15 +00:00
<table>
<tr>
<td><img src='/demos/scrollLine.gif' alt='' width=320 height=280/></td>
<td><img src='/demos/animatedDataLine.gif' alt='' width=320 height=260/></td>
</tr>
<tr>
<td><img src='/demos/movingBars.gif' alt='' width=270 height=300/></td>
<td><img src='/demos/pielabbelled.svg' alt='' height=280 width=270/></td>
</tr>
</table>
2021-08-01 23:25:13 +00:00
2021-08-08 23:56:19 +00:00
---
2022-04-18 20:17:12 +00:00
## Version 1.2.x 🎉
Version 1.2.0 onwards we are dependent only on `react-native-svg` and `react-native-linear-gradient`. Earlier, Pie and Donut charts were rendered using `react-native-canvas`, but now they are also rendered using <b>svg</b>. We are no longer using `react-native-canvas` neither `react-native-webview`!
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-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) |
| 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) |
2022-08-16 10:58:06 +00:00
| Charts with datasets having negative values (4th quadrant) break https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/261 | Not yest solved |
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