【发布时间】:2018-08-03 07:26:15
【问题描述】:
我有这样的脚本 json,我想将列 value_a 除以总数
regional value_a total
SUL 1072 5823
KAL 991 5472
PUMA 253 1832
value_a/total*100
series = [{
borderWidth: 0,
data: json[2]['total'],
data: json[1]['value_a'],
dataLabels: {
style: {
fontWeight: "normal"
},
formatter: function() {
var y = this.y;
var percentage = (this.y/json[2]['total']*100).toFixed(2);
return '<div style="text-align:center"><span style="font-size:20px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'white') + '"><br/>'+ y +'</span><span><small> / ' + percentage + ' %</small></span>';
}
}
}];
但结果是显示 NaN
【问题讨论】:
-
请向我们展示有问题的 JSON。另外,当您进行计算时,
this.y的值是多少。您的除法操作似乎在某处使用了一些无效值,因此结果不能是有效数字
标签: json highcharts series