Bar, Line, Area, Pie, and Donut charts in React Native

Overview

react-native-gifted-charts Rate on Openbase

The most complete library for Bar, Line, Area, Pie, and Donut charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.

Yet another chart library? Why?

To bring Life to your data

  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 (see the props)
  7. Detailed documentation with examples
  8. Support for combined Bar and Line charts

alt text alt text alt text


Installation

npm install react-native-gifted-charts react-native-linear-gradient react-native-svg

For Pie chart and Donut chart, these additional packages should be installed-

npm i react-native-canvas react-native-webview

For iOS-

cd ios && pod install

Docs

Documentation and gallery

Usage

The simplest usage of various types of charts can be done as below-

import { BarChart, LineChart, PieChart } from "react-native-gifted-charts";

// ...
const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]

<BarChart data = {data} />
<LineChart data = {data} />
<PieChart data = {data} />

// 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

<LineChart data = {data} areaChart />

// For Donut chart, just add the prop donut to the <PieChart/> component

<PieChart data = {data} donut />

Props tables

1. BarChart, Horizontal BarChart and Stacked Bar Chart props
2. LineChart and AreaChart props
3. PieChart and DonutChart props

Contributing

Dear developers! Your small contribution can make someone's day 😊

One of the ways you can contribute is to address an open issue.

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.

See the contributing guide to learn how to contribute to the repository and the development workflow.

Common issues

Issue Solution
BarChart - Value and section line don't match Comment by the owner

License

MIT

Comments
  • Setting 'spacing' to automatically fill the width provided for number of data points

    Setting 'spacing' to automatically fill the width provided for number of data points

    Hey,

    Within the LineChart is there any way for the 'spacing' field to automatically be set to the value that would have each data point spaced equally along the width you provide?

    My use case is that the number of data points I use will be dynamic so without doing a secondary calculation I won't know what the spacing should be.

    Cheers, Josh

    opened by joshuarichards001 13
  • Tooltip off Screen

    Tooltip off Screen

    hello team, at first i would like to thank you for this great package. Tooltip component is viewed off screen when multiple columns for bar charts. and how can i change the scrollbar color with custom color not only balck,white and default thank you in advance

    opened by mmatahen 11
  • Horizontal + Vertical Line (Dotted / Dashed / Solid)

    Horizontal + Vertical Line (Dotted / Dashed / Solid)

    Feature Request:

    Not urgent but if we can set a type prop for the data line props i.e

    showStrip,
    dataPointText,
    textShiftX,
    

    Even better if we can also have the Y-axis counterpart.


    Why is this a good idea?

    • A lot of graphs sometimes decrease straight from the onset, so if you use vertical lines to display that "highest" data point it wont be visible since it may get overlapped by the y-axis (if the highest is at index = 0)

    • Also if you use a horizontally scrolling graph, having a horizontalLine means you will be able to see where the highest data point no matter how much you scroll to the left/right.


    • also, the dashed/dotted/solid type prop idea is also useful because it allows us to distinguish between which custom data points we're showing. for example my background lines for the graph are solid, however I would like to display the highest in dotted (horizontal) and the lowest value in dashed.

    Just some ideas for expanding this in the future, not really urgent. (would be great if we could have the option to set our own graph container border, right now it's default only the bottom and right of the graph (unless I have messed things up) / border radius etc..

    opened by NemyaNation 8
  • Abillity to set elevation of Y/X axis.

    Abillity to set elevation of Y/X axis.

    Would be great if we could render our own text component for Y-axis, similarly to how we can for x-axis. Then we could personalize and style our own text strings completely, including it's container.

    Failing that, if we can set the elevation, to "above"/"below" or 0/1 for x/y axis labels.

    graph-example2


    tldr: I want the ability to display my text labels above the curve and overlay.

    opened by NemyaNation 8
  • Change startingPoint default props on PieChart (donut)

    Change startingPoint default props on PieChart (donut)

    Just some ideas for you @Abhinandan-Kushwaha

    It would be smarter to start your donut/pieChart from the center top (0 degrees) instead of the current (90 degrees)

    The reason for this is because usually in most donut charts, they are displayed in descending order, meaning that the right hand side of the entire donut graph, will most of the time only show one label (< 90 degress)

    And since most people output their labels LTR (Left to right is the standard), this would mean that the most clusterd position usually will be the right hand side of the donut chart.

    This can be avoided in most cases however if you start at (0 degrees)

    Look at this image to further understand my point:

    Screenshot_2022-04-10-01-06-01-708_com tcgfintech tcgprice


    As you can see my data is in descending order, light blue is biggest (starting at 90*), then dark blue then purple. Unfortunately this means that the smaller labels are congested since they are all rightToLeft and therefore cut off from the screen entirely.

    This could be avoided if the're final posiiton was somewhere near the top (the case if you start at 0degrees)


    Usually for (LTR) we want as least labels as possible on the right (avoid overflow issues like we see above).

    Let me know if this at all makes any sense to you, and if not I can expand my point. (should be a simple edit that I think is better as the default (I can't see any use-cases for starting at 90degrees instead)

    Also, zIndex of the labels should always be higher than the slices, I can't see a usecase where you would want to hide the label if it overlaps onto another (because it's starting point is always visible)

    opened by NemyaNation 7
  • Implementing exactly.

    Implementing exactly.

    Describe the bug I'm unable to design the chart exactly like this.

    Expected result: Screenshot 2022-06-14 at 8 35 10 PM

    Some snippets on how to achieved result exactly like this might be help.

    Thank you.

    opened by nzrin 6
  • xAxisLabel top margin

    xAxisLabel top margin

    I am trying to give more margin from the top to the x-axis labels, but still can't, I tried to use labelComponent with marginTop, but it seems that the labels container have fixed height because the text start to look trimmed from the bottom, any idea how to handle this?

    image
    opened by Hijleh 6
  • ShowVerticalLine isn't the height of the chart

    ShowVerticalLine isn't the height of the chart

    Was hoping to use showVerticalLine to render on specific data points while looking similar to the chart prop showVerticalLines where the lines are the height of the chart.

    Using showVerticalLine however only goes to the height of the data point.

    Screen Shot 2022-03-10 at 2 03 05 PM

    opened by kimdolion 6
  • Redundant Space at top of Bar Chart

    Redundant Space at top of Bar Chart

    Hi,

    Just wondering if it's possible to get rid of the redundant space at the top of the bar chart - highlighted the background in red to show the space at the top:

    Screenshot 2022-01-20 at 17 10 34

    Thanks

    .

    opened by verofy-simon-denny 6
  • can we have a different onPress for different piechart data with animation onPress of some selected data

    can we have a different onPress for different piechart data with animation onPress of some selected data

    Describe the bug Prop to make different datas of Pie chart clickable, such that when we click some specific data it should shown up or animated like it's somewhat lifted outwards.

    To Reproduce Steps to reproduce the behavior:

    1. Go to pi chart
    2. Click on some data from it
    3. Clicked data should be animated like it's lifted upward

    Expected behavior Clickable datas on the pie chart and animations to be added on the onPress of datas, in mobile application.

    Screenshots If applicable, add screenshots to help explain your problem.

    • Device: all iPhone and android devices
    • Version of the library being used [1.2.18]
    Screenshot 2022-05-26 at 6 04 50 PM
    opened by siddhi-unthinkable-co 5
  • Scroll through data points instead of justing clicking on them.

    Scroll through data points instead of justing clicking on them.

    @Abhinandan-Kushwaha

    I really want to implement functionality similar to the delta investment app, where we can holdPress on the graph, and then we can scroll through the datapoints, without removing our focus from the graph.

    Look at the video below

    Delta Investment App

    https://user-images.githubusercontent.com/17049683/160614368-40cdc65a-4a26-444f-8292-ac7956ff6613.mp4


    I want to achieve something similar and I've gotten as far as onPress, however I am having trouble handling the onScroll functionality with the focus still maintained on the graph.

    My attempt thus far (you can see there is no scroll functionality, it's just onPress on each of the several data points)

    https://user-images.githubusercontent.com/17049683/160614583-e1d7b383-1299-44b7-b5f3-fa87afcb9195.mp4

    opened by NemyaNation 5
  • Question:  Is it possible to have pointerConfig active and show soon as touch event happens vs current behavior of onMove

    Question: Is it possible to have pointerConfig active and show soon as touch event happens vs current behavior of onMove

    Describe the bug For a line chart, I noticed that I have to touch then move my fingers for the pointerConfig to take affect. I am wondering if it's possible to provide immediate feedback with the pointerConfig on touch start instead of on move?

    To Reproduce Steps to reproduce the behavior:

    1. Take any of the demo chart and verify the pointer config data only shows after touch move and not on touch start.
    • Device: Iphone 11 pro max
    • OS: latest
    • Version of the library being used [e.g. 1.2.17]
    opened by dchhetri 0
  • Line Chart: PressIn on chart doesn't lock the pointer when scrolling vertically

    Line Chart: PressIn on chart doesn't lock the pointer when scrolling vertically

    Describe the bug

    • Have a line chart inside a scroll view
    • pressIn on a line chart with pointerConfig defined
    • While pressed in, move the finger down and notice the scrollview scrolls down.

    The issue sounds similar to #175

    Expected behavior I'm hoping once the user presses in on the line chart, moving the finger while pressed will not cause the scroll view to scroll down. Atm, the pointerConfig doesn't operate as expected in this situation due to the scrolling conflict.

    I'm trying to find a workaround but nothing in the exposed API allows it as far as I can tell.

    opened by dchhetri 0
  • Line chart has white space when using adjustToWidth

    Line chart has white space when using adjustToWidth

    • When I use adjustToWidth line chart shows white space like this 596580790c86cad89397
    • How can I make a chart look like this: https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/blob/master/demos/scrollLine.gif
    • I'm using chart version ^1.2.41
    • this is my line chart code: <LineChart areaChart data={chartData} width={width * 0.85} curved adjustToWidth disableScroll initialSpacing={0} hideDataPoints scrollToEnd scrollAnimation={false} color={hexToRgbA(color.primary, 0.7)} thickness={1.5} startFillColor={hexToRgbA(color.primary, 0.1)} endFillColor={hexToRgbA(color.background, 0.1)} startOpacity={0.2} endOpacity={0.1} noOfSections={4} stepValue={highestNav / 4} maxValue={highestNav} minValue={minNav} showXAxisIndices xAxisIndicesColor={color.palette.deepGray} xAxisIndicesHeight={1} xAxisIndicesWidth={7} yAxisThickness={1} xAxisColor={color.palette.deepGray} hideRules hideOrigin yAxisColor={color.palette.deepGray} yAxisTextStyle={{ color: color.palette.lightBlack, right: s(-70), position: "absolute", }} yAxisSide="right" yAxisLabelWidth={s(50)} yAxisLabelContainerStyle={{ zIndex: -1 }} verticalLinesUptoDataPoint getPointerProps= {(pointerProps)=>{ if (pointerProps.pointerIndex > 0){ setScrollAble(false) return } setScrollAble(true) }} pointerConfig={{ pointerStripColor: color.palette.deepGray, pointerStripWidth: 2, pointerColor: color.primary, radius: 4, pointerLabelWidth: s(100), pointerLabelHeight: 90, // set to false => can not scroll when enable scrollEnable activatePointersOnLongPress: false, autoAdjustPointerLabelPosition: true, pointerLabelComponent: items => { return ( <View style={styles.toolkit}> <AppText style={{ fontSize: ms(14), textAlign: "center" }}> {items[0].date} <View style={ALIGN_CENTER}> <AppText style={FONT_BOLD_12}> {numberWithCommas(items[0].value)} VNĐ ) }, }} />
    opened by KulBoiz 4
  • Change Yaxis direction

    Change Yaxis direction

    Hi! How can I change the Y axis direction? I need minValue={120} maxValue={0} and show something like this. The Y axis must grow down. Is there any prop I can use?

    opened by leoamato 2
📊React Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)

??React Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)

null 2.4k Jan 9, 2023
SVG donut component for React

React SVG Donuts A ReactJS component for simple (and complex) SVG donuts. The current version depends on the Hooks API introduced with React 16. If yo

Atanas Atanasov 8 Dec 28, 2022
An extendable SVG donut chart React component

react-donut-chart An extendable SVG-based donut chart React component. Installation npm install react-donut-chart --save Usage import DonutChart from

JJ Naughton 28 Dec 7, 2022
Create beautiful JavaScript charts with one line of React

React Chartkick Create beautiful JavaScript charts with one line of React See it in action Supports Chart.js, Google Charts, and Highcharts Quick Star

Andrew Kane 1.2k Dec 28, 2022
A thin, typed, React wrapper over Google Charts Visualization and Charts API.

React Google Charts A thin, typed, React wrapper for Google Charts. Docs and examples. React Google Charts Docs and examples. Installation Quick Start

Rakan Nimer 1.4k Jan 4, 2023
A thin, typed, React wrapper over Google Charts Visualization and Charts API.

A thin, typed, React wrapper for Google Charts. Docs and examples. React Google Charts Docs and examples. Installation Quick Start

Rakan Nimer 1.4k Jan 6, 2023
React-native-graph: a Line Graph implementation based on the high performance 2D graphics rendering engine "Skia"

?? react-native-graph Beautiful, high-performance Graphs/Charts for React Native. About react-native-graph is a Line Graph implementation based on the

Margelo 1.1k Jan 6, 2023
3D Earth: a beautiful component of earth flying line based on threejs

Language: English | 中文简体 3D Earth is a beautiful component of earth flying line

Zy 199 Dec 30, 2022
React components for building composable and flexible charts

rumble-charts React components for building composable and flexible charts to visualize your data. It's based on D3.js under the hood, but most of the

null 338 Dec 26, 2022
Reactochart is a library of React components for creating data visualization charts and graphs.

Reactochart is a library of React components for creating data visualization charts and graphs. Components include line chart, bar chart, area chart, heat maps, scatterplot, histogram, pie chart, sankey diagram, and tree map.

Spotify 530 Dec 26, 2022
Plug and play React charts

Orama [DEPRECATED] This package has been deprecated as it is no longer used by Kensho internally and we do not plan to continue maintaining it. We hop

Kensho 124 Nov 12, 2022
EazyChart is a reactive chart library 📈, it allows you to easily add SVG charts in your React and Vue web applications.

EazyChart EazyChart is a reactive chart library, it offers the ability to easily add charts in your React and Vue web applications. The purpose of thi

Hexastack 16 Dec 15, 2022
Highly customizable stock charts with ReactJS and d3

React Stockcharts Create highly customizable stock charts Built with React JS and d3 If you like this project checkout gocharting.com integrates multi

Ragu Ramaswamy 3.6k Dec 29, 2022
Highly customizable library for building interactive node-based UIs, editors, flow charts and diagrams

React Flow is a library for building node-based graphs. You can easily implement custom node types and it comes with components like a mini-map and graph controls.

webkid 13.2k Jan 4, 2023
A declarative, efficient, and simple JavaScript library for building responsive charts

A declarative, efficient, and simple JavaScript library for building responsive charts

ZingChart 254 Dec 8, 2022
App with D3 Charts and Google Maps

react-charts-and-maps This project contains the implementation of libraries D3, highcharts and react-google-maps with the ReactJS. It shows how easy i

Marek Dano 8 Aug 19, 2022
📊 📈 📉 React.js plugin for building charts using CSS

Chartify React.js plugin for building charts using CSS. Demo The source for this module is in the main repo. Example app is here. Backend service for

Kirill Stepkin 685 Jan 1, 2023
📊 📈 📉 React.js plugin for building charts using CSS

Chartify React.js plugin for building charts using CSS. Demo The source for this module is in the main repo. Example app is here. Backend service for

Kirill Stepkin 685 Jan 1, 2023
Modular React charts made with d3.js

Update Important update: The actively maintained fork of this project is now at the Github of react-d3 co-creator yang-wei, who has recently taken the

Eric S. Bullington 1.8k Oct 27, 2022