Highcharts不会调整标签中的图表大小

编程入门 行业动态 更新时间:2024-10-10 15:19:08
本文介绍了Highcharts不会调整标签中的图表大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用twitter标签引导程序。每个选项卡内有多个选项卡和图表。在浏览器调整大小时,不在当前活动选项卡上的图表不会调整大小。事实上,它看起来很有趣,用一根细条。当前活动选项卡正常工作。有没有人看到这个问题,并有任何解决方法?

解决方案

下面是一个可行的例子:

codepen.io/colinsteinmann/pen/BlGfE

基本上单击选项卡时,每个图表上都会调用.reflow()函数。这样,图表就会根据应用于容器的新维度重新绘制。

这是最重要的代码片段:

//修复位于隐藏元素中的图表的维数 jQuery(document).on('shown.bs.tab' ,'a [data-toggle =tab]',function(e){//选项卡选择事件 jQuery(.contains-chart).each(function(){// target each element与.contains-chart类 var chart = jQuery(this).highcharts(); //将图表本身作为目标 chart.reflow()//重新绘制图表}); })

I am using twitter bootstrap with tabs. I have multiple tabs and charts inside each tab. Upon browser resize, charts that are not on the current active tab do not get resized. Infact, it looks kind of funny with a thin bar. The current active tab works fine. Has anyone seen this issue and are there any workarounds ?

解决方案

Here is a working example:

codepen.io/colinsteinmann/pen/BlGfE

Basically the .reflow() function is called on each chart when a tab is clicked. That way the chart gets redrawn based on the new dimensions which are applied to the container when it becomes visible.

This is the most important snippet of code:

// fix dimensions of chart that was in a hidden element jQuery(document).on( 'shown.bs.tab', 'a[data-toggle="tab"]', function (e) { // on tab selection event jQuery( ".contains-chart" ).each(function() { // target each element with the .contains-chart class var chart = jQuery(this).highcharts(); // target the chart itself chart.reflow() // reflow that chart }); })

更多推荐

Highcharts不会调整标签中的图表大小

本文发布于:2023-07-09 21:00:56,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   大小   标签   Highcharts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!