如何显示具有组成数据的高图表y轴

How to display highchart y axis with constistant data

本文关键字:数据 高图表 何显示 显示      更新时间:2023-09-26

我有一个高图柱状图,因为在某些时候,y轴数据显示为[1000200030004000],在某些时候显示为[1k,2k,3k,4k]。

如何将其修复为单一类型的数据。

谨致问候,Navin-Leon

比较http://jsfiddle.net/BNFe5/

区别就在这里:

yAxis: {
    labels: {
        formatter: function() {
            return this.value;
        }
    }
},

用于将yaxis值转换为1k、2k、3k、4k等:

yAxis: 
{
    labels: 
    { 
      formatter: function() 
      {
         return Math.round(this.value/1000) + 'k';
      }
    }
},

如果您在一个图表中使用数千和数百万,请检查一下。

yAxis: {
    labels: {
        formatter: function () {
            if (this.value.toFixed(0) >= 1000000) {
                return '$' + this.value.toFixed(0) / 1000000 + 'M';
            } else {
                return '$' + this.value.toFixed(0) / 1000 + 'K';
            }
        }
    },
    title: {
        text: ''
    }
},