diff --git a/dist/BarChart.js b/dist/BarChart.js index 5921a10..2e88219 100644 --- a/dist/BarChart.js +++ b/dist/BarChart.js @@ -14,7 +14,7 @@ justifyContent:'space-around'}});var BarChart=function(_Component){_inherits(BarChart,_Component); -function BarChart(props){_classCallCheck(this,BarChart);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(BarChart).call(this, +function BarChart(props){_classCallCheck(this,BarChart);var _this=_possibleConstructorReturn(this,(BarChart.__proto__||Object.getPrototypeOf(BarChart)).call(this, props));_this. @@ -27,7 +27,7 @@ _this.props.data.onDataPointPress(e,dataPoint,index); _drawBar=function(_dataPoint,index){var _dataPoint2=_slicedToArray( _dataPoint,2);var _x=_dataPoint2[0];var dataPoint=_dataPoint2[1]; -var backgroundColor=_this.props.color||C.BLUE; +var backgroundColor=typeof _this.props.barColors!=='undefined'&&_this.props.barColors[index]?_this.props.barColors[index]:C.BLUE; var HEIGHT=_this.props.height; var WIDTH=_this.props.width; var widthPercent=_this.props.widthPercent||0.5; diff --git a/dist/Chart.js b/dist/Chart.js index 00a20ff..430a97f 100644 --- a/dist/Chart.js +++ b/dist/Chart.js @@ -56,7 +56,7 @@ Chart=function(_Component){_inherits(Chart,_Component); -function Chart(props){_classCallCheck(this,Chart);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(Chart).call(this, +function Chart(props){_classCallCheck(this,Chart);var _this=_possibleConstructorReturn(this,(Chart.__proto__||Object.getPrototypeOf(Chart)).call(this, props));_this. @@ -132,8 +132,8 @@ props));_this. _onContainerLayout=function(e){return _this.setState({ -containerHeight:Math.ceil(e.nativeEvent.layout.height)+1, -containerWidth:Math.ceil(e.nativeEvent.layout.width)});};_this.state={bounds:{min:0,max:0}};return _this;}_createClass(Chart,[{key:'componentDidMount',value:function componentDidMount(){this._computeBounds();}},{key:'shouldComponentUpdate',value:function shouldComponentUpdate(props,state){return props!==this.props||state!==this.state;}},{key:'componentDidUpdate',value:function componentDidUpdate(props){if(this.props!==props){this._computeBounds();}}},{key:'_computeBounds',value:function _computeBounds(){var min=Infinity;var max=-Infinity;var data=this.props.data||[];data.forEach(function(XYPair){var number=XYPair[1];if(numbermax)max=number;});min=Math.floor(min);max=Math.ceil(max);// Exit if we want tight bounds +containerHeight:e.nativeEvent.layout.height, +containerWidth:e.nativeEvent.layout.width});};_this.state={bounds:{min:0,max:0}};return _this;}_createClass(Chart,[{key:'componentDidMount',value:function componentDidMount(){this._computeBounds();}},{key:'shouldComponentUpdate',value:function shouldComponentUpdate(props,state){return props!==this.props||state!==this.state;}},{key:'componentDidUpdate',value:function componentDidUpdate(props){if(this.props!==props){this._computeBounds();}}},{key:'_computeBounds',value:function _computeBounds(){var min=Infinity;var max=-Infinity;var data=this.props.data||[];data.forEach(function(XYPair){var number=XYPair[1];if(numbermax)max=number;});min=Math.floor(min);max=Math.ceil(max);// Exit if we want tight bounds if(this.props.tightBounds){return this.setState({bounds:{min:min,max:max}});}max=getRoundNumber(max,this.props.verticalGridStep);if(min<0){var step=void 0;if(this.props.verticalGridStep>3){step=Math.abs(max-min)/(this.props.verticalGridStep-1);}else{step=Math.max(Math.abs(max-min)/2,Math.max(Math.abs(min),Math.abs(max)));}step=getRoundNumber(step,this.props.verticalGridStep);var newMin=void 0;var newMax=void 0;if(Math.abs(min)>Math.abs(max)){var m=Math.ceil(Math.abs(min)/step);newMin=step*m*(min>0?1:-1);newMax=step*(this.props.verticalGridStep-m)*(max>0?1:-1);}else{var _m=Math.ceil(Math.abs(max)/step);newMax=step*_m*(max>0?1:-1);newMin=step*(this.props.verticalGridStep-_m)*(min>0?1:-1);}if(minnewMax+step){newMin+=step;newMax+=step;}if(max. - */var Wedge=function(_Component){_inherits(Wedge,_Component);function Wedge(props){_classCallCheck(this,Wedge);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(Wedge).call(this,props));_this.circleRadians=Math.PI*2;_this.radiansPerDegree=Math.PI/180;_this._degreesToRadians=_this._degreesToRadians.bind(_this);return _this;}/** + */var Wedge=function(_Component){_inherits(Wedge,_Component);function Wedge(props){_classCallCheck(this,Wedge);var _this=_possibleConstructorReturn(this,(Wedge.__proto__||Object.getPrototypeOf(Wedge)).call(this,props));_this.circleRadians=Math.PI*2;_this.radiansPerDegree=Math.PI/180;_this._degreesToRadians=_this._degreesToRadians.bind(_this);return _this;}/** * _degreesToRadians(degrees) * * Helper function to convert degrees to radians diff --git a/dist/xAxis.js b/dist/xAxis.js index 10b7d42..23e81a3 100644 --- a/dist/xAxis.js +++ b/dist/xAxis.js @@ -16,7 +16,7 @@ backgroundColor:'transparent'}});var -XAxis=function(_Component){_inherits(XAxis,_Component);function XAxis(){_classCallCheck(this,XAxis);return _possibleConstructorReturn(this,Object.getPrototypeOf(XAxis).apply(this,arguments));}_createClass(XAxis,[{key:'render',value:function render() +XAxis=function(_Component){_inherits(XAxis,_Component);function XAxis(){_classCallCheck(this,XAxis);return _possibleConstructorReturn(this,(XAxis.__proto__||Object.getPrototypeOf(XAxis)).apply(this,arguments));}_createClass(XAxis,[{key:'render',value:function render() diff --git a/dist/yAxis.js b/dist/yAxis.js index fc4f620..5aa2ddc 100644 --- a/dist/yAxis.js +++ b/dist/yAxis.js @@ -31,7 +31,7 @@ YAxis=function(_Component){_inherits(YAxis,_Component); -function YAxis(props){_classCallCheck(this,YAxis);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(YAxis).call(this, +function YAxis(props){_classCallCheck(this,YAxis);var _this=_possibleConstructorReturn(this,(YAxis.__proto__||Object.getPrototypeOf(YAxis)).call(this, props));_this. diff --git a/react-native-chart.flow.js b/react-native-chart.flow.js index 0281516..a0c3d8c 100644 --- a/react-native-chart.flow.js +++ b/react-native-chart.flow.js @@ -25,7 +25,7 @@ declare type Chart = { yAxisUseDecimal?: boolean, // Bar chart props - color?: number | string, + barColors?: Array, cornerRadius?: number, widthPercent?: number, diff --git a/src/BarChart.js b/src/BarChart.js index 3d901d4..2abf9b4 100644 --- a/src/BarChart.js +++ b/src/BarChart.js @@ -27,7 +27,7 @@ export default class BarChart extends Component { _drawBar = (_dataPoint : [number, number], index : number) => { const [_x, dataPoint] = _dataPoint; - const backgroundColor = this.props.color || C.BLUE; + const backgroundColor = (typeof this.props.barColors !== 'undefined' && this.props.barColors[index] ? this.props.barColors[index] : C.BLUE); const HEIGHT = this.props.height; const WIDTH = this.props.width; let widthPercent = this.props.widthPercent || 0.5;