单击DIV时,我使用一种简单的JQuery和CSS方法来调整图表DIV的大小。 DIV调整为页面的100%。

示例在这里(或检查我的Fiddle):



$('.col-sm-6').on('click', function() {
			$(this).toggleClass('clicked');
		});

.col-sm-6 {
			width: 68%;
			transition: width 2s !important;
      height: 100px;
      width: 100px;
      background: #ffffff;
		}
		.col-sm-6.clicked {
			z-index: 9999;
			width: 100%;
			height: 100%;
			position: fixed;
			top: 25px;
			left: 0px;
		}

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<div class="col-sm-6" style="border:1px solid black">CLICK</div>





当调整DIV大小(并再次返回)时,如何调整图表svg的大小,该图表svg包含在以上示例中的“ col-sm-6” DIV中?似乎只有在实际浏览器窗口更改时才调整大小,而不仅仅是DIV。

我会在C3JS中使用onresize()函数吗?

最佳答案

您应该使用c3.js API .resize()方法:

chart.resize({
  height: 640,
  width: 480
});


请参阅此处的example



您提到过onresize()-这仅是网页大小调整时的回调,并且在.resize()之后不会触发

10-04 22:13
查看更多