Search code examples
amcharts

AmCharts v3 stop old charts building from up


I have an angular app that utilizes AmCharts v3. If I render a new chart I can access it from the console using AmCharts.charts - If I then navigate to another page and render a new chart, calling AmCharts.charts now has 2 charts. This will continue every new chart rendered is added to the AmCharts main object, it just keeps getting larger. Does AmCharts offer a way to "clean up" old charts?


Solution

  • You can call clear on the chart instance (e.g. chartInstance.clear()) before you render your next chart. clear is also available on the AmCharts object if you need to clear all chart instances (AmCharts.clear()).