gpt4 book ai didi

javascript - 我如何在 Highcharts 中将 "120 Lakhs"更改为 "1 crore 20 Lakhs"

转载 作者:行者123 更新时间:2023-11-28 11:04:12 25 4
gpt4 key购买 nike

我将此代码用于 Highcharts :

Highcharts.setOptions({
lang : {
numericSymbols : [ ' thousands', ' Lakhs', ' Crores' ]
}
});

当我运行这个时,它显示的结果是十万,例如:200万、400万、800万、1200万......但我想要这个,(990万之后)千万像:1200万= 1千万200万。我正在使用 Eclipse。

最佳答案

您可以覆盖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

关于javascript - 我如何在 Highcharts 中将 "120 Lakhs"更改为 "1 crore 20 Lakhs",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39872361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com