Adding new HighChart Series

后端 未结 2 655
谎友^
谎友^ 2020-12-15 11:54

At this code javascrip give an error

$.each(JSON, function(i, array) {                        
    chart.series[i].name = array.teamName;
    chart.series[i]         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 12:24

    You need to looka at the "Methods and Properties" part of the API. See http://api.highcharts.com/highcharts#Chart (There is an jsFiddle on the documentation page as well).

    var chart = new Highcharts.Chart(options);
    chart.addSeries({                        
        name: array.teamName,
        data: array.teamPowher
    });
    

    If you are going to add several series you should set the redraw flag to false and then call redraw manually after as that will be much faster.

    var chart = new Highcharts.Chart(options);
    chart.addSeries({                        
        name: array.teamName,
        data: array.teamPower
    }, false);
    chart.addSeries({                        
        name: array.teamName,
        data: array.teamPower
    }, false);
    chart.redraw();
    

提交回复
热议问题