How can i get access to a Highcharts chart through a DOM-Container

前端 未结 9 822
轮回少年
轮回少年 2020-12-02 11:55

When i render a highcharts-chart to a div container, how can i get access to the chart object through the div-Container? i dont want to make the chart variable global.

9条回答
  •  独厮守ぢ
    2020-12-02 12:27

    Without jQuery (vanilla js):

    let chartDom = document.getElementById("testDivId");
    let chart = Highcharts.charts[Highcharts.attr(chartDom, 'data-highcharts-chart')]
    

提交回复
热议问题