与highcharts系列选项的问题 [英] problem with highcharts series option

查看:134
本文介绍了与highcharts系列选项的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我对我的highcharts'系列'选项有问题。我初始化了图表选项,如下所示:

  var options = {
图表:{
renderTo:'图表',
defaultSeriesType:'line',
},
title:{
text:'Weight Monitor',
},
xAxis:{
title:{
text:'Date Measurement'
},
categories:[]
},
yAxis:{
title: {
text:'Weight(in Lbs)'
}
},
series:[]
};

我保留类别:[]空白,以便稍后可以将这些值分类。我对我的系列选项也做了同样的事情。我保留了数据:[]作为空白以备后用。现在我编写了填充数据的代码。

  var lines = [
[2011,150],
[2012,121],
$ .each(lines,function(lineNo,line){
var items = line.toString()。split(,);
$ .each(items,function(itemNo,item ){

if(itemNo == 0){
alert(itemNo:+ itemNo +item:+ item);
options.xAxis.categories.push (item);
alert(options.xAxis.categories);
}

else {
var series = {
data:[]
$;
alert(itemNo:+ itemNo +item:+ item);
options.series.data.push(parseFloat(item));
alert(options .series.data);
};
});
});
var chart = new Highcharts.Chart(options);

现在,当我执行此代码时,我的类别[]正确地获取值,但执行被卡住当它在options.series.data.push(parseFloat(item))时。我在alert(itemNo:+ itemNo +item:+ item);中获得了适当的值。但在此之后,它会在series.data []



中推送该项目时挂起任何想法是什么问题。我在php项目中运行这个JavaScript,所以不知道是否有任何问题,因为语言。谢谢

解决方案

问题是 options.series.data.push(parseFloat(item))



如果您查看选项对象,则可以看到您的系列数组为空。您可以在您的选项定义中广告系列对象,如下所示 -

 系列:[{
data:[]




$ p

<$>

p $ p> var series = {
data:[]
};

是没有用的。


Hi i am having problem with my highcharts 'series' options. i initialized the chart options as below:

            var options = {
            chart: {
                renderTo: 'chart',
                defaultSeriesType: 'line',
            },
            title: {
                text: 'Weight Monitor',
            },
            xAxis: {
                title: {
                    text: 'Date Measurement'
                },
                categories: []
            },
            yAxis: {
                title: {
                    text: 'Weight (in Lbs)'
                }
            },
            series: []
    };

I kept the categories: [] blank so that i can put the values in categories later. Same thing i did with my series options. I kept the data:[] as blank to fill it later. Now i wrote the code to fill the data.

                var lines = [
                [2011,150],
                [2012,121],
        $.each(lines, function(lineNo, line) {
            var items = line.toString().split(",");
            $.each (items, function(itemNo, item) {

                if(itemNo == 0){
                    alert("itemNo: " + itemNo + " item: " + item);
                    options.xAxis.categories.push(item);
                    alert(options.xAxis.categories);
                }

                else {
                            var series = {
                                    data: []
                            };
                    alert("itemNo: " + itemNo + " item: " + item);
                    options.series.data.push(parseFloat(item));
                    alert(options.series.data);
                };
            });
        });
        var chart = new Highcharts.Chart(options);

Now when i execute this code, my categories[] is getting values properly, but the execution gets stuck when it is at "options.series.data.push(parseFloat(item))". I am getting the proper value in the "alert("itemNo: " + itemNo + " item: " + item);". but just after that it hangs while pushing the item in series.data[]

any idea what is the problem. and i am running this javascript in php project so don't know if there is any issue because of the language. thanks

解决方案

The problem is options.series.data.push(parseFloat(item)).

If you look at your options object, you can see that your series array is empty. You can ad series object in your options definition as follows -

series: [{
    data: []
}]

Also the line

var series = {
    data: []
};

is of no use.

这篇关于与highcharts系列选项的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆