例:
Chart1 是在tab1 中,
Chart2 是在tab2 中,
var charts = [];
var Chart1 = echarts.init(document.getElementById('main'));
var Chart2 = echarts.init(document.getElementById('main2'));
Chart1.setOption(customerOrderNumOption);
Chart2.setOption(everyDayOrderSortOption);
charts.push(Chart1);
charts.push(Chart2);
$(function () {
for (var i = 0; i < charts.length; i++) {
charts[i].resize();
}
//data-toggle="pill还是data-toggle="tab" 根据前面所用标签页的不同来选择。我使用的是data-toggle="tab"。
//解决tab切换不显示问题 在加载窗口后重新渲染。
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
for (var i = 0; i < charts.length; i++) {
charts[i].resize();
}
});
})