Echarts 折线图y轴标签值太长时显示不全的解决办法

发布时间 2023-06-08 09:28:31作者: 谢凌
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
    },
    ...
};

  

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    },    ...};