Reload chart data via JSON with Highcharts

前端 未结 8 2286
借酒劲吻你
借酒劲吻你 2020-11-28 02:11

I am trying to reload the data for a Highcharts chart via JSON based on a button click elsewhere in the page. Initially I would like to display a default set of data (spendi

8条回答
  •  天命终不由人
    2020-11-28 03:14

    Correct answer is:

    $.each(lines, function(lineNo, line) {
                        var items = line.split(',');
                        var data = {};
                        $.each(items, function(itemNo, item) {
                            if (itemNo === 0) {
                                data.name = item;
                            } else {
                                data.y = parseFloat(item);
                            }
                        });
                        options.series[0].data.push(data);
                        data = {};
                    });
    

    You need to flush the 'data' array.

    data = {};
    

提交回复
热议问题