1.0.5 • Published 2 years ago

@digieggs/rn-polygon-chart v1.0.5

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

React Native Polygon Chart

DIGIEGGS - RNPolygonChart stars - RNPolygonChart forks - RNPolygonChart

Unit Tests GitHub tag License issues - RNPolygonChart

Customizable and animatable polygon chart.

Getting started

Installation

React Native CLI

npm install react-native-svg @digieggs/rn-polygon-chart

or

yarn add react-native-svg @digieggs/rn-polygon-chart

Expo CLI

expo install react-native-svg
expo install @digieggs/rn-polygon-chart

Additional steps

  • iOS

In your project's ios directory

pod install
  • Android

No additional steps needed

Usage

Import

import {
  Hexagon,
  Pentagon,
  Tetragon,
  Triangle,
} from 'react-native-polygon-chart';

Usage

<Triangle
  poles= {[
    {
      score: 0.8,
      innerStroke: {opacity: 1, stroke: "#30d158", strokeWidth: 2},
      stroke: {opacity: 1, stroke: "#0a84ff"},
    },
    {
      score: 0.6,
      innerStroke: {opacity: 1, stroke: "#30d158", strokeWidth: 2},
      stroke: {opacity: 1, stroke: "#0a84ff"},
    },
    {
      score: 0.9,
      innerStroke: {opacity: 1, stroke: "#30d158", strokeWidth: 2},
      stroke: {opacity: 1, stroke: "#0a84ff"},
    },
  ]}
  innerColor="#30d158"
  innerOpacity={0.2}
  outerStroke={{stroke: green, opacity: 1, strokeWidth: 1}}
  animation={{delay: 0, duration: 500}}
  style={styles.triangle}
/>

...

const styles = StyleSheet.create({
  triangle: {width: 300, height: 600},
});

You can use more poles for other polygons or polygon will render as if remaining scores are zero.

polygon2

Props

animation

TypeRequiredDescription
IAnimationParamsnoObject that specifies the details of the polygon render animation.

innerColor

TypeRequiredDescription
stringnoFill color of the polygon.

innerOpacity

TypeRequiredDescription
numbernoFill opacity of the polygon.

outerStroke

TypeRequiredDescription
ILinePropsnoProps for outer stroke of the polygon.

poles

TypeRequiredDescription
Array<IPole>yesAn array of details to draw the polygon.

style

TypeRequiredDescription
ViewStylenoStyle of the polygon's container.

Essential types and interfaces

ILineProps

PropsTypeRequired
strokestringno
strokeWidthnumberno
opacitynumberno
  • The stroke prop is being used for line color.

IPole

PropsTypeRequired
scorenumberyes
infoIInfono
strokeILinePropsno
innerStrokeILinePropsno
  • The point prop is a multiplier between 0 and 1 determines the vertex distance from the center of the polygon.

IInfo

PropsTypeRequired
textstringno
textStyleTextStyleno
styleViewStyleno
onPress() => voidno
offsetIOffsetno
  • The offset prop determines the absolute x and y offsets of info element.

IOffset

PropsTypeRequired
xnumberyes
ynumberyes

IAnimationParams

PropsTypeRequired
delaynumberno
durationnumberno
easingEasingFunctionno
1.0.5

2 years ago

1.0.4

2 years ago

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.0.1

2 years ago