Amchart V4 export all existing amcharts together in a page

孤人 提交于 2020-01-24 15:07:45

问题


How can I get all Amchart instances of my page in Amchart V4, like it was this.AmChartsService.charts in V3? I want to export them all together.


回答1:


You can use the am4core.registry.baseSprites array and use the native JavaScript methods to filter it.

Find by html id:

var id = 'chartdiv';
var chart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === id);

Find by html class name:

var className = 'my-class';
var chart = am4core.registry.baseSprites.find(c => Array.from(c.htmlContainer.classList).includes(className));

Find by chart id:

var id = 'myId';
var chart = am4core.registry.baseSprites.find(c => c.id === id);


来源:https://stackoverflow.com/questions/54835456/amchart-v4-export-all-existing-amcharts-together-in-a-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!