在 ECharts 中,你可以使用 min 和 max 属性来设置对数轴的底数。同时,通过 axisLabel 的 formatter 属性可以判断 yAxis 是否是静态(不会自动调整范围)。以下是一个示例:
option = {
    yAxis: {
        type: 'log', // 设置为对数轴
        logBase: 2, // 设置对数轴的底数为 2
        // 其他 yAxis 配置项可以根据需要添加
        axisLabel: {
            formatter: function (value, index) {
                // 判断是否为静态坐标轴
                if (value === Math.pow(2, index)) {
                    return value; // 是静态坐标轴,直接返回值
                } else {
                    return ''; // 不是静态坐标轴,返回空字符串
                }
            }
        }
    },
    xAxis: {
        type: 'category',
        data: ['A', 'B', 'C', 'D', 'E'],
    },
    series: [
        {
            type: 'bar',
            data: [10, 20, 15, 25, 30]
        }
    ]
};

在上述示例中,type: 'log' 表示使用对数轴,而 logBase: 2 设置了对数轴的底数为 2。axisLabel 中的 formatter 函数通过判断当前刻度值是否等于 2 的指数值,来判断是否是静态坐标轴。如果是静态坐标轴,则直接返回刻度值;否则返回空字符串。




转载请注明出处:http://www.zyzy.cn/article/detail/5202/ECharts