如何在按钮点击重置百分比Highchart图表宽度 [英] how to reset Highchart chart width in percentage on Button click

查看:114
本文介绍了如何在按钮点击重置百分比Highchart图表宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在按钮点击时更改 highchart的宽度,我知道我可以使用 chart.setSize 函数来做到这点,但它会设置宽度仅限像素。但我需要在百分比中设置宽度。



这里是 JSFiddle示例,其中我尝试以3种方式重置宽度。只有按钮1有效,但不是剩余的2.



请让我知道如何重置 百分比你可以像> button4 =http://jsfiddle.net/T7mtg/1/ =noreferrer> here

  var chart = $('#container')。highcharts(); 
var el = $('。chart-inner');
el.css('width','100%');
chart.setSize(el.width(),el.height(),true);


I want to change highchart's width on button click, I know I can do it using chart.setSize function, but it sets the width only in pixels. But I need to set the width in percentage.

Here is the sample JSFiddle, in which I have tried to reset the width in 3 ways. Only Button 1 works, but not the remaining 2.

Please let me know how can I reset the width in percentage.

解决方案

you could do it like button4 here :

    var chart = $('#container').highcharts();
    var el = $('.chart-inner');
    el.css('width','100%');
    chart.setSize(el.width(),el.height(),true);

这篇关于如何在按钮点击重置百分比Highchart图表宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆