amcharts4 icon indicating copy to clipboard operation
amcharts4 copied to clipboard

Is it possible to not instantiate a chart until it is visible?

Open stla opened this issue 1 year ago • 4 comments

Hello,

I have a problem with amcharts4 graphics in a dashboard. The dashboard has several pages and there is one chart in each page. When opening it, the chart at the first page is correct. But when going to another page, the chart on this page is already rendered and not correctly. Therefore I'm looking for an option like onlyShowOnViewport but to not instantiate the chart when it is not visible (onlyShowWhenVisible). I tried this option but it didn't help. I'm using the latest version of amcharts4 with React.

stla avatar Sep 21 '22 17:09 stla

If you render a chart into a div with display:none and later change it to display:block, it should work fine.

zeroin avatar Sep 22 '22 06:09 zeroin

Hello,

That's what I do in my answer on StackOverflow. This is nice except that the button is misplaced.

stla avatar Sep 22 '22 07:09 stla

Try to call chart.zoomOutButton.hardInvalidate() when size of a chart changes:

chart.events.on("sizechanged", ()=>{
   chart.zoomOutButton.hardInvalidate()
})

zeroin avatar Sep 22 '22 12:09 zeroin

Thanks. But this is for a zoom button, right? My button is not a zoom button, this is just a button. But I keep your suggestion in mind, I'll include this code in my package.

stla avatar Sep 22 '22 13:09 stla

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 23 '22 00:10 github-actions[bot]