highcharts / highcharts-react-native

Other
103 stars 79 forks source link

Chart data is not resetting #80

Closed otskarli closed 4 years ago

otskarli commented 4 years ago

I found an issue with resetting data in chart series, i will try to do my best to explain it, it seems like, when i am using state for updating chart data, the previous data is not removed, instead it stacks at first index in chart and kind of breaks everything

Way to reproduce

Intial data:

[{"color": "#C9CCD0", "data": [30, 76, -7, 46, 43, 83, 24, 61, -37, -0, 51, 36, -1
3, 43, -12, 30, 60, -12, -6, 13, -35, -16, 23, -43], "name": "MIN"}]

call setState with new data:

[{"color": "#C9CCD0", "data": [30, 76, -7, 46, 43, 83, 24, 61, -37, -0, 51, 36, -1
3, 43, -12, 30, 60, -12, -6, 13, -35, -16, 23, -43], "name": "MIN"}, {"color": "#AAB1BB",
 "data": [34, -13, 26, 22, -44, -12, 75, 37, 79, 58, 72, 17, 83, 47, -23, 81, 67, 31, 61,
 -41, 57, 68, 39, 20], "name": "MAX"}]

if you call setState like this it breaks the chart this.setState({series: data});

if you clear the chart data before applying new data like this it works this.setState({ series: [] }, () => { this.setState({ series }) });

attached gif error

sebastianbochan commented 4 years ago

Hi @JsonGuy, The issue looks like the same here: https://github.com/highcharts/highcharts-react-native/issues/72 which was fixed by the commit.

Could you ensure that you use the newest version of wrapper?

otskarli commented 4 years ago

Hi @JsonGuy, The issue looks like the same here: #72 which was fixed by the commit.

Could you ensure that you use the newest version of wrapper?

Yes, thanks

aditya1711 commented 3 years ago

I have a similar issue where some series line disappear when chart is updated by a state update. I can see values on the tooltip when moving through the graph, but the lines just disappears. I am using the latest version, i.e., 3.1.2, and "react": "16.13.1", "react-native": "^0.62.2".