1.0.3 • Published 2 years ago

react-native-simple-pie-chart v1.0.3

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

react-native-simple-pie-chart

npm version npm downloads license

Simple pie chart module for both Android and iOS with optional dashes and middle component if needed.

Installation

You need to have react, react-native and react-native-svg as your app's dependencies. If you had trouble installing react-native-svg, refer to the project's documentation: https://www.npmjs.com/package/react-native-svg.

Then install this package with:

  npm install react-native-pie-chart --save

or

  yarn add react-native-pie-chart

Basic usage

  import { PieChart } from 'react-native-simple-pie-chart'

  const data = [
    { amount: 10, color: '#378d68' },
    { amount: 20, color: '#a75d46' },
  ]

  export const Main() => {
    return (
      <PieChart data={data} />
    )
  }

With this you'll get the following result

Props

KeyData typeDefault value?Description
dataArray of objects (described below)RequiredData array from which we calculate and show the chart
maxnumberWill be calculated from dataMaximum amount to calculate percentages of each individual pies
backgroundColorstring#b5e48cBackground color of the pie chart in the background
withDashesbooleanfalseIndicates if we have dashes on pie chart
dashesAmountSee below25Indicates how many dashes we have
centerReactNodeundefinedIf present, will be rendered in the center of our pie chart

Where dashesAmount can be one of the following: 10, 20, 25, 50, 100

The required data array must contain objects with the following options:

KeyData typeDefault value?Description
amountnumberRequired.Will be used to calculate percentage of pie chart with comparison with max value. And if we don't have max value, this prop will be used to calculate maximum possible amount
colorstringRandom color from this libraries color paletteThe color of the pie chart.
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago