【问题标题】:Highchart not able to use javascript variables(arrays) in series dataHighchart 无法在系列数据中使用 javascript 变量(数组)
【发布时间】:2014-06-07 07:43:53
【问题描述】:

您好,我正在尝试在 highchart 系列数据中使用数组变量,但我没有得到图表中的值(未绘制线)。

var day = [];
        var count = [];
        var i = 0; 
        var j = 0;
        $.each(data.day,function(index,value){
        day[i++] = value;
        });
        $.each(data.count,function(index,value){
        count[j++] = value;
        });


series: [{
            name: 'Profile View',
            data: [count[0],count[1],count[2],count[3],count[4],count[5],count[6]] 
        }]

我在这里没有得到 count 或 day 的值 虽然它适用于类别

xAxis: {

                categories: [day[0], day[1], day[2], day[3], day[4], day[5],count[6]]
            }

我在这里卡了很长时间,但无法弄清楚问题所在。

【问题讨论】:

    标签: javascript highcharts


    【解决方案1】:

    我对你的代码做了一些小改动,它可能会起作用

    series: [{
                    name: 'Profile View',
                    data: JSON.parse("[" + count + "]") 
                }]
    

    Highcharts with Variable Data

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      相关资源
      最近更新 更多