Echars 生成图表宽高问题
如图,生成的图表宽高不完全填充div容器。如果
chart_detail 的 width :100%;生成的echars width:100px。
原因1:查看是否父容器style ="display:none" 属性,如果有先删掉,在js里面写。
原因2: 如果width设置为100%,浏览器执行的时候,没有获取到父容器div的100%宽度。
解决方法:
window.onresize = myChart_detail.resize;
myChart_detail = echarts.init(document.getElementById('chart_detail')); var detail_option = { title: { text: '人数趋势图', left: 'center',bottom:'bottom' }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap : false, data: [] }, yAxis: { type: 'value', max:100, axisLabel: { formatter: '{value}%' } }, series: [ { name:'人数趋势图', type:'line', data:[] } ] }; window.onresize = myChart_detail.resize; myChart_detail.setOption(detail_option);