我正在将此代码用于highchart:
Highcharts.setOptions({
lang : {
numericSymbols : [ ' thousands', ' Lakhs', ' Crores' ]
}
});
当我运行此命令时,它以数十万这样的结果显示结果:20lakhs,40lakhs,80lakhs,120lakhs...。
但是我想要这样(在90.1亿之后),像这样:1.2十亿= 1千万个20亿。
我正在使用日食。
最佳答案
您可以覆盖defaultLabelFormatter
Highcharts.Axis.prototype.defaultLabelFormatter = function () {
var axis = this.axis,
value = this.value,
categories = axis.categories,
dateTimeLabelFormat = this.dateTimeLabelFormat,
numericSymbols = Highcharts.getOptions().lang.numericSymbols,
i = numericSymbols && numericSymbols.length,
multi,
ret,
formatOption = axis.options.labels.format,
// make sure the same symbol is added for all labels on a linear axis
numericSymbolDetector = axis.isLog ? value : axis.tickInterval;
if (formatOption) {
ret = Highcharts.format(formatOption, this);
} else if (categories) {
ret = value;
} else if (dateTimeLabelFormat) { // datetime axis
ret = Highcharts.dateFormat(dateTimeLabelFormat, value);
} else if (i && numericSymbolDetector >= 1000) {
// Decide whether we should add a numeric symbol like k (thousands) or M (millions).
// If we are to enable this in tooltip or other places as well, we can move this
// logic to the numberFormatter and enable it by a parameter.
while (i-- && ret === UNDEFINED) {
multi = Math.pow(1000, i + 1);
if (numericSymbolDetector >= multi / 10 && numericSymbols[i] !== null) {
ret = Highcharts.numberFormat(value / multi, -1) + numericSymbols[i];
}
}
}
if (ret === UNDEFINED) {
if (mathAbs(value) >= 10000) { // add thousands separators
ret = numberFormat(value, 0);
} else { // small numbers
ret = numberFormat(value, -1, UNDEFINED, ''); // #2466
}
}
return ret;
},
Highcharts.setOptions({
lang : {
numericSymbols : [ ' thousands', ' Lakhs', ' Crores' ]
}
});
选中此DEMO