本文介绍了Highcharts:选择一张图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用highcharts来制作仪表板。
现在我用每个函数的jquery搜索每个图表,找出哪个图表比窗口更宽,以使其响应。
所以我必须为每个图表定义宽度。

如果图表比窗口宽,我想定义

  width = $(window).width()。 

with

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

我可以选择所有图表,但如何选择单个图表?



感谢您的帮助。

解决方案

我相信你正在寻找.each()和Highcharts

  $(。dashboard)。each(function(){
//测试图表是否比窗口更宽,并更新为
$(this).highcharts.setSize数字宽度,数字高度);
});

尽管如果您只是在寻找响应式图表,您可以将highcharts容器设置为100%宽度,会自动发生。

 < div id =chartcontainerwidth ='100%'>< / div> 


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.

解决方案

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>

这篇关于Highcharts:选择一张图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 13:34