问题
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