react-native-pie-chart
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "react-native-pie-chart", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "pie chart for react native", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
import React, { Component } from 'react'; | ||
import { ART } from 'react-native'; | ||
import { Platform, ART } from 'react-native'; | ||
const { Surface, Group, Path, Shape } = ART; | ||
@@ -22,5 +22,7 @@ import Wedge from './Wedge'; | ||
render() { | ||
const radius = this.getRadius(); | ||
const rotation = Platform.OS === 'ios' ? 0 : -90; | ||
return ( | ||
<Surface style={this.props.style} width={this.props.chart_wh} height={this.props.chart_wh}> | ||
<Group> | ||
<Group rotation={rotation} originX={radius} originY={radius}> | ||
{Object.keys(this.props.series).map((key)=>{ | ||
@@ -27,0 +29,0 @@ return ( |
@@ -26,3 +26,3 @@ /** | ||
import React, {Component, PropTypes} from 'react'; | ||
import {ART} from 'react-native'; | ||
import {Platform, ART} from 'react-native'; | ||
const {Shape, Path} = ART; | ||
@@ -131,6 +131,21 @@ | ||
path.move(or + or * ss, or - or * sc). // move to starting point | ||
arc(or * ds, or * -dc, or, or, large). // outer arc | ||
line(dr * es, dr * -ec); // width of arc or wedge | ||
// Update by Gene Xu to fix android issue, follow below | ||
// https://github.com/facebook/react-native/blob/master/Libraries/ART/ARTSerializablePath.js | ||
// https://github.com/bgryszko/react-native-circular-progress/blob/master/src/CircularProgress.js | ||
// https://github.com/nihgwu/react-native-pie | ||
const ARC = 4; | ||
const CIRCLE_X = or; | ||
const CIRCLE_Y = or; | ||
const RX = or - or / 2; | ||
const TwoPI = 2 * Math.PI; | ||
if (Platform.OS === 'ios') { | ||
path.move(or + or * ss, or - or * sc). // move to starting point | ||
arc(or * ds, or * -dc, or, or, large). // outer arc | ||
line(dr * es, dr * -ec); // width of arc or wedge | ||
} else { | ||
path.path.push(ARC, CIRCLE_X, CIRCLE_Y, RX, startAngle / 360 * TwoPI, (startAngle / 360 * TwoPI) - ((endAngle - startAngle) / 360 * TwoPI), 0) | ||
} | ||
if (ir) { | ||
@@ -165,3 +180,7 @@ path.counterArc(ir * -ds, ir * dc, ir, ir, large); // inner arc | ||
return <Shape {...this.props} d={path}/>; | ||
if (Platform.OS === 'ios') { | ||
return <Shape {...this.props} d={path}/>; | ||
} else { | ||
return <Shape d={path} stroke={this.props.fill} strokeWidth={outerRadius} strokeCap='butt' />; | ||
} | ||
} | ||
@@ -168,0 +187,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12633
300