使用JavaScript自定义轴标签格式:

可以通过JavaScript代码自定义轴标签格式,避免显示重复值。

1. 整数格式:

function() {
    if (this == parseInt(this)) {
        return this;
    } else {
        return " ";
    }
}

2. 保留两位小数格式: 

function() {
    if (this == this.toFixed(2)) {
        return this;
    } else {
        return " ";
    }
}

3. 化为人民币千分位形式并保留两位小数: 

function() {
    if (this == this.toFixed(2)) {
        // 使用toLocaleString方法格式化数字为人民币格式(千分位形式)
        return this.toLocaleString('zh-CN', {
          style: 'currency',       // 指定为货币格式
          currency: 'CNY',         // 指定货币为人民币
          minimumFractionDigits: 2, // 最小小数位数
          maximumFractionDigits: 2  // 最大小数位数
        });
    } else {
        return " ";
    }
}

注:图片来自帆软官方 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐