【问题标题】:how to divide two columns on series with json in highchart如何在highchart中用json划分系列的两列
【发布时间】: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


【解决方案1】:

您可以在查询中创建除法公式,以获取除法结果

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    • 2015-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多