09-echarts

2023-02-17  本文已影响0人  零涂

初始化echarts表

function initCharts() {
  this.myChart = this.$echarts.init(this.$refs.echartsEl);
  let option = {};
  option && this.myChart.setOption(option);
  window.addEventListener('resize',this.myChart.resize);
  this.$once('hook:beforeDestroy', () => {            
    window.removeEventListener('resize',this.myChart.resize);                           
  }) 
}

坐标轴数字单位换算

参考:https://blog.csdn.net/Dandelion_drq/article/details/79270597

option = {
    ...
    yAxis: {
        type: 'value',
        name: '营业额(元)',
        axisTick: {
            inside: true
        },
        scale: true,
        axisLabel: {
            margin: 2,
            formatter: function (value, index) {
                if (value >= 10000 && value < 10000000) {
                    value = value / 10000 + "万";
                } else if (value >= 10000000) {
                    value = value / 10000000 + "千万";
                }
                return value;
            }
        },
    },
    grid: {
        left: 35
    },
    ...
};
image.png
上一篇 下一篇

猜你喜欢

热点阅读