<div class="DataDetails" id="DataDetails">
<div id="main" style="width:100%;height:400px;"></div>//圖表的盒子
</div>
that.mychart = this.echarts.init(document.getElementById("main"));
that.mychart.clear();
that.mychart.setOption(option); //展現
setTimeout(function() {
//從新給圖表的盒子設置寬度,若不設置寬度爲100px
var he = $("#DataDetails").width() - 80;//80不是固定的,根據項目的實際數進行修改
$("#main").css("width", he + "px");
$("#main div").css("width", he + "px");
$("#main canvas").css("width", he + "px");
$("#main canvas").attr("width", he);
}, 200);複製代碼