amcharts / amcharts3-react

Official amCharts V3 React component
Apache License 2.0
118 stars 50 forks source link

graph displays 'show all' on update #22

Closed hombrew closed 7 years ago

hombrew commented 7 years ago

I don't know if this is configurable, but everytime 'dataProvider' is updated, the graph displays a button that says 'show all'. I'd like it to display the new data inmediatly.

this is how the chart data is being generated:

this.GRAPH_DATA = {
   ...
   'dataProvider': this.props.data.previous,
   ...
}

and this is how it is displayed

<AmCharts {...this.GRAPH_DATA}/>

this.props.data is updated via an api that is being fetched after a button is clicked by the parent component.

Thanks in advance for any help you can offer.

Pauan commented 7 years ago

@hombrew Every time you call the this.setState method it will update the chart. Are you calling setState immediately after setting the new data?

bleachdugu commented 7 years ago

the same problem occurs in my project. I use some dirty tricky way to solve it. the data provider in my project was stored in my reduce state, once it updated, the chart will be rerendered and display show all, then I added a listener to the chart, once it rerendered and call the function to force the chart show all

(event) => {
event.chart.zoomOut();
}

it solve my problem, but it's a dirty way I thought ==

Pauan commented 7 years ago

@hombrew @bleachdugu I was able to reproduce this bug, and I fixed it.

Please upgrade amcharts3-react to version 1.1.7

You can upgrade by deleting node_modules/amcharts3-react and then running npm install

hombrew commented 7 years ago

thank you very much!!

devilsbibble commented 7 years ago

Could someone help me about this problem? My amcharts3-react version is 3.21.5 , but still have this problem

Pauan commented 7 years ago

@devilsbibble It seems this got broken again.

We just now released a fix in version 3.21.6 of AmCharts.

If you are using our CDN (https://www.amcharts.com/lib/3/amcharts.js) then you do not need to change anything, you already have the fix. You might need to clear your browser's cache.

If you downloaded AmCharts from somewhere else (such as our Commercial Downloads center, or npm) then you will need to redownload the latest version of AmCharts.

Here is a working demo.