react-native-chart-android icon indicating copy to clipboard operation
react-native-chart-android copied to clipboard

render linechart will crash when more times

Open samuelltk opened this issue 8 years ago • 5 comments

The app will crash when states change more times. please help me, thanks.

getRandomData(){ var data={}; data['xValues']=[]; data['yValues']=[ { data:[], label:'test1', config:{ color:'blue' } } ]; for (var i = 0; i < 50; i++) { data.xValues.push(i+''); data.yValues[0].data.push(Math.random()*100); }; return data; } componentDidMount() { var num=0; setInterval(() => { var datas=this.getRandomData(); this.setState({ randomDatas:datas }); }, 1000); } render() { return ( <View style={styles.container}> <View style={styles.chartContainer}> <LineChart style={{flex:1}} data={this.state.randomDatas} visibleXRange={[0,30]} maxVisibleValueCount={50} xAxis={{drawGridLines:false,gridLineWidth:1,position:"BOTTOM"}} yAxisRight={{enable:false}} yAxis={{startAtZero:false,drawGridLines:false,position:"INSIDE_CHART"}} drawGridBackground={false} backgroundColor={"WHITE"} description={""} legend={{enable:true,position:'ABOVE_CHART_LEFT',direction:"LEFT_TO_RIGHT"}} /> </View> </View> ); }

samuelltk avatar Oct 30 '16 12:10 samuelltk

is there some exception log ?

hongyin163 avatar Oct 31 '16 02:10 hongyin163

10-27 23:09:21.858 15712-15762/com.myvictorytest A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x90cd005c in tid 15762 (mqt_js) 10-27 23:09:24.828 15712-15712/com.myvictorytest I/Choreographer: Skipped 170 frames! The application may be doing too much work on its main thread. @hongyin163

samuelltk avatar Oct 31 '16 02:10 samuelltk

how do you update your view?

hongyin163 avatar Oct 31 '16 05:10 hongyin163

@hongyin163 i update the state per 1 seconds, the render will be run, wait for a moment, my app will crash on android...i am use the Galaxy S4, 5.0.1....My code look on the top.

samuelltk avatar Oct 31 '16 07:10 samuelltk

时间间隔设置长一点呢? 或者使用setTimeout试试?

hongyin163 avatar Nov 02 '16 11:11 hongyin163