我正在根据动态数据创建 Highcharts,并且具有带美元符号的负值。但格式化程序将它们显示为:
$-4,322
当我想要的时候:
-$4,322
这就是我正在使用的:
pointFormat: 'Year {point.x:.0f}: ${point.y:,.0f}'
有人可以帮忙吗?谢谢。
最佳答案
您可以切换到pointFormatter
函数以这种方式格式化它。
例如( JSFiddle ):
pointFormatter: function() {
var isNegative = this.y < 0 ? '-' : '';
return 'Year ' + this.x.toFixed(0) + ': ' + isNegative + '$' + Math.abs(this.y.toFixed(0));
}
关于javascript - 在 Highcharts 中使用美元符号格式化负数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36700752/