Highcharts: Select a single chart?

邮差的信 提交于 2019-12-11 23:07:25

问题


I am working with highcharts to make a dashboard. Now I search each chart with the jquery for each function, to find which chart is wider than the window to make it responsive. So I have to define the width for each chart.

If a chart is wider than the window, I want to define

width = $(window).width().

with

$(".dashboard").highcharts({
    chart: {
        width: width, //320
     },
});

I can select all charts, but how do I select a single chart?

Thanks for helping.


回答1:


I believe you are looking for .each() and Highcharts setSize

$(".dashboard").each(function () {
  //Test if chart is wider than window here and update below
  $(this).highcharts.setSize(Number width, Number height);
});

Although if you are just looking for responsive charts you can set your highcharts container to 100% width and it will automatically happen.

<div id="chartcontainer" width='100%'></div>


来源:https://stackoverflow.com/questions/32630868/highcharts-select-a-single-chart

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