@@ -121,14 +121,18 @@ props));_this.
121121
122122
123123
124+
125+
126+
127+
124128
125129
126130
127131
128132
129133_onContainerLayout = function ( e ) { return _this . setState ( {
130134containerHeight :Math . ceil ( e . nativeEvent . layout . height ) + 1 ,
131- 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 :'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 ( number < min ) min = number ; if ( number > max ) max = number ; } ) ; min = Math . round ( min ) ; max = Math . round ( max ) ; // Exit if we want tight bounds
135+ 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 ( number < min ) min = number ; if ( number > max ) max = number ; } ) ; min = Math . round ( min ) ; max = Math . round ( max ) ; // Exit if we want tight bounds
132136if ( 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 ( min < newMin ) { newMin -= step ; newMax -= step ; } if ( max > newMax + step ) { newMin += step ; newMax += step ; } if ( max < min ) { var tmp = max ; max = min ; min = tmp ; } } return this . setState ( { bounds :{ max :max , min :min } } ) ; } } , { key :'_minVerticalBound' , value :function _minVerticalBound ( )
133137
134138{
@@ -145,18 +149,18 @@ return this.state.bounds.max>0?this.state.bounds.max:0;}},{key:'render',value:fu
145149var components = { 'line' :_LineChart2 . default , 'bar' :_BarChart2 . default , 'pie' :_PieChart2 . default } ;
146150var axisAlign = this . props . type === 'line' ?'left' :'center' ;
147151return (
148- _react2 . default . createElement ( _reactNative . View , { __source :{ fileName :_jsxFileName , lineNumber :148 } } ,
152+ _react2 . default . createElement ( _reactNative . View , { __source :{ fileName :_jsxFileName , lineNumber :152 } } ,
149153function ( ) {
150154var ChartType = components [ _this2 . props . type ] || _BarChart2 . default ;
151155if ( _this2 . props . showAxis && Chart !== _PieChart2 . default ) {
152156return (
153157_react2 . default . createElement ( _reactNative . View , {
154158ref :'container' ,
155159style :[ _this2 . props . style || { } , { flex :1 , flexDirection :'column' } ] ,
156- onLayout :_this2 . _onContainerLayout , __source :{ fileName :_jsxFileName , lineNumber :153 } } ,
160+ onLayout :_this2 . _onContainerLayout , __source :{ fileName :_jsxFileName , lineNumber :157 } } ,
157161
158- _react2 . default . createElement ( _reactNative . View , { style :[ styles . default , { flexDirection :'row' } ] , __source :{ fileName :_jsxFileName , lineNumber :158 } } ,
159- _react2 . default . createElement ( _reactNative . View , { ref :'yAxis' , __source :{ fileName :_jsxFileName , lineNumber :159 } } ,
162+ _react2 . default . createElement ( _reactNative . View , { style :[ styles . default , { flexDirection :'row' } ] , __source :{ fileName :_jsxFileName , lineNumber :162 } } ,
163+ _react2 . default . createElement ( _reactNative . View , { ref :'yAxis' , __source :{ fileName :_jsxFileName , lineNumber :163 } } ,
160164_react2 . default . createElement ( _yAxis2 . default , _extends ( { } ,
161165_this2 . props , {
162166data :_this2 . props . data ,
@@ -165,7 +169,7 @@ width:_this2.props.yAxisWidth,
165169minVerticalBound :_this2 . state . bounds . min ,
166170containerWidth :_this2 . state . containerWidth ,
167171maxVerticalBound :_this2 . state . bounds . max ,
168- style :{ width :_this2 . props . yAxisWidth } , __source :{ fileName :_jsxFileName , lineNumber :160 } } ) ) ) ,
172+ style :{ width :_this2 . props . yAxisWidth } , __source :{ fileName :_jsxFileName , lineNumber :164 } } ) ) ) ,
169173
170174
171175_react2 . default . createElement ( ChartType , _extends ( { } ,
@@ -174,19 +178,19 @@ data:_this2.props.data,
174178width :_this2 . state . containerWidth - _this2 . props . yAxisWidth ,
175179height :_this2 . state . containerHeight - _this2 . props . xAxisHeight ,
176180minVerticalBound :_this2 . state . bounds . min ,
177- maxVerticalBound :_this2 . state . bounds . max , __source :{ fileName :_jsxFileName , lineNumber :171 } } ) ) ) ,
181+ maxVerticalBound :_this2 . state . bounds . max , __source :{ fileName :_jsxFileName , lineNumber :175 } } ) ) ) ,
178182
179183
180184function ( ) {
181185return (
182- _react2 . default . createElement ( _reactNative . View , { ref :'xAxis' , __source :{ fileName :_jsxFileName , lineNumber :182 } } ,
186+ _react2 . default . createElement ( _reactNative . View , { ref :'xAxis' , __source :{ fileName :_jsxFileName , lineNumber :186 } } ,
183187_react2 . default . createElement ( _xAxis2 . default , _extends ( { } ,
184188_this2 . props , {
185189width :_this2 . state . containerWidth - _this2 . props . yAxisWidth ,
186190data :_this2 . props . data ,
187191height :_this2 . props . xAxisHeight ,
188192align :axisAlign ,
189- style :{ marginLeft :_this2 . props . yAxisWidth - 1 } , __source :{ fileName :_jsxFileName , lineNumber :183 } } ) ) ) ) ; } ( ) ) ) ; }
193+ style :{ marginLeft :_this2 . props . yAxisWidth - 1 } , __source :{ fileName :_jsxFileName , lineNumber :187 } } ) ) ) ) ; } ( ) ) ) ; }
190194
191195
192196
@@ -198,15 +202,15 @@ return (
198202_react2 . default . createElement ( _reactNative . View , {
199203ref :'container' ,
200204onLayout :_this2 . _onContainerLayout ,
201- style :[ _this2 . props . style || { } , styles . default ] , __source :{ fileName :_jsxFileName , lineNumber :198 } } ,
205+ style :[ _this2 . props . style || { } , styles . default ] , __source :{ fileName :_jsxFileName , lineNumber :202 } } ,
202206
203207_react2 . default . createElement ( ChartType , _extends ( { } ,
204208_this2 . props , {
205209data :_this2 . props . data ,
206210width :_this2 . state . containerWidth ,
207211height :_this2 . state . containerHeight ,
208212minVerticalBound :_this2 . state . bounds . min ,
209- maxVerticalBound :_this2 . state . bounds . max , __source :{ fileName :_jsxFileName , lineNumber :203 } } ) ) ) ) ; } ( ) ) ) ; } } ] ) ; return Chart ; } ( _react . Component ) ; Chart . defaultProps = { data :[ ] , animated :true , animationDuration :300 , axisColor :C . BLACK , axisLabelColor :C . BLACK , axisLineWidth :1 , axisTitleColor :C . GREY , axisTitleFontSize :16 , chartFontSize :14 , dataPointRadius :3 , gridColor :C . BLACK , gridLineWidth :0.5 , hideHorizontalGridLines :false , hideVerticalGridLines :false , horizontalScale :1 , labelFontSize :10 , lineWidth :1 , showAxis :true , showDataPoint :false , showGrid :true , showXAxisLabels :true , showYAxisLabels :true , tightBounds :false , verticalGridStep :4 , xAxisHeight :20 , yAxisWidth :30 } ; exports . default = Chart ;
213+ maxVerticalBound :_this2 . state . bounds . max , __source :{ fileName :_jsxFileName , lineNumber :207 } } ) ) ) ) ; } ( ) ) ) ; } } ] ) ; return Chart ; } ( _react . Component ) ; Chart . defaultProps = { data :[ ] , animated :true , animationDuration :300 , axisColor :C . BLACK , axisLabelColor :C . BLACK , axisLineWidth :1 , axisTitleColor :C . GREY , axisTitleFontSize :16 , chartFontSize :14 , dataPointRadius :3 , gridColor :C . BLACK , gridLineWidth :0.5 , hideHorizontalGridLines :false , hideVerticalGridLines :false , horizontalScale :1 , labelFontSize :10 , lineWidth :1 , showAxis :true , showDataPoint :false , showGrid :true , showXAxisLabels :true , showYAxisLabels :true , tightBounds :false , verticalGridStep :4 , xAxisHeight :20 , yAxisWidth :30 } ; exports . default = Chart ;
210214
211215
212216
0 commit comments