Search code examples
angularamchartsamcharts4

resizeSensor Amcharts on Angular


Im using Amcharts for a while and im happy with it, but i discovered a bug on my app.

If I leave the graphics screen to another component, it creates a space of 7 hidden divs. Those divs are from Amcharts.

The official documentation says that this happens because charts are using a resize sensor which gets knocked of its feet when chart container is moved about in a DOM tree.

The solution is to implement: chart.svgContainer.resizeSensor.reset();

BUT resizeSensor.reset() is getting deprecated on my code and i dont know why!

https://i.sstatic.net/RFwjf.jpg

this is the official documentation about this problem:

https://www.amcharts.com/docs/v4/getting-started/integrations/using-angular2/#Fixing_broken_resizing_on_route


Solution

  • Got the solution, i just need to unsubscribe with "am4core.disposeAllCharts();" on ngOnDestroy.

    That did the trick