Highchart不能在序列数据中使用javascript变量(数组)

Highchart not able to use javascript variables(arrays) in series data

本文关键字:javascript 变量 数组 不能 数据 Highchart      更新时间:2023-09-26

嗨,我试图在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]]
            }

我在这儿堵了好长时间了,可就是想不出问题来。

我在你的代码做了一个小的改变,它可能工作

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

Highcharts with Variable Data