如图,生成的图表宽高不完全填充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);

Echars 生成图表宽高问题

相关文章:

  • 2021-11-29
  • 2022-01-19
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-06-15
  • 2021-08-15
  • 2021-04-14
  • 2021-05-17
  • 2021-10-08
  • 2022-12-23
相关资源
相似解决方案