AnyChart / AnyChart-React

Intuitive and easy to use React plugin that allows you to create and work with AnyChart JavaScript Charts
https://www.anychart.com
Apache License 2.0
39 stars 30 forks source link

How do I prevent rescrolling #9

Closed Radzell closed 5 years ago

Radzell commented 5 years ago

How do I prevent a scrolling when my data changes?

chart.data(treeData);

<AnyChart
   instance={stage}
  height={600}
  charts={[chart]} />
Shestac92 commented 5 years ago

@Radzell Please, can you specify which chart type you are using? Is your chart is scrolled to a specific position before the chart data updates?

Radzell commented 5 years ago

@Shestac92 I am using a gantt project chart. It's rescrolling back to the beginning of the chart. The scroll happens when I update the data.

Shestac92 commented 5 years ago

@Radzell If you add new items to the existing tree data it doesn't lead to dropping the current scrolling position. Here is a sample how it works.

If you apply new data tree to the chart it leads to dropping of the current scroll position as the currently visible range cannot cover the new data range. You can avoid this by using the following approach. Before updating the chart you can save the current visible range, update the chart and then zoom to that range again. Here is a sample of this approach.