1.0.0 • Published 2 years ago

react-native-expo-pie-chart v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-expo-pie-chart

npm npm npm bundle size GitHub issues Npm Publish Workflow License

A customizable Pie Chart library that uses react-native-svg. Can be used for react native & expo.

Example

Installation

Install using npm

npm i react-native-expo-pie-chart

Please Note: react-native-svg is required as peer dependencies. Install it according to their documentation.

Usage

View it live: Expo Snack

import PieChart from 'react-native-expo-pie-chart';

<PieChart
    data={[
    {
        key: 'First Data',
        count: 20,
        color: 'blue',
    },
    {
        key: 'Second Data',
        count: 25,
        color: 'yellow',
    },
    {
        key: 'Third Data',
        count: 40,
        color: 'green',
    },
    {
        key: 'Forth Data',
        count: 35,
        color: 'orange',
    },
    ]}
    length={200}
/>

Props

NameTypeDescriptionRequiredDefault
datadataItem[]
lengthnumberthe side length of the bounding square150
rotationnumberrotation of the pie chart-90
zeroTotalCircleColorstringthe color of the complete circle to display if the total of data.count is zero'#F1F6F9'
containerPropsViewPropsprops for wrapper view component
svgPropsSvgPropsprops for the svg component (read react-native-svg docs))
gPropsGPropsprops for the g component (read react-native-svg docs))
circlePropsCirclePropsprops for the circle component (read react-native-svg docs))

Data Item

NameTypeDescription
colorstringthe color of this item in the pie chart
countnumberthe value of this item
keystringunique key representing this item

Developing

You can use the example app to develop the package.

To link the package in development, You can use Yalc. Read through the installation and usage section in Yalc's documentation or use the following lines for a quick start:

npm i yalc -g

yalc publish

cd example
yalc add react-native-expo-pie-chart
npm install

License

This project is licensed under the MIT License - see the LICENSE file for details