Improve highcharts performance for large amounts of data

前端 未结 7 1175
名媛妹妹
名媛妹妹 2021-02-02 01:38

I am trying to get a larger amount of data. Sample data is below

1850/01   -0.845   -0.922   -0.748   -1.038   -0.652   -1.379   -0.311   -1.053   -0.636   -1.41         


        
7条回答
  •  太阳男子
    2021-02-02 01:50

    new Array(length)

    Specify the array's length rather than creating an empty array. Writing to an existing offset in an array is substantially faster than creating a new offset each time you write an item.

    var data = new Array(lines.length);  // Specify array length
    
    $.each(lines, function(index, row) {
      var cells = row.split(','),
      series = {
        type: 'line',
        data: new Array(cells.length)  // Specify array length
      };
    
      $.each(cells, function(itemNo, item) {
        if (itemNo == 0) {
          series.name = item;
        } else {
          series.data.push(parseFloat(item));
        }
      });
    
      data.push(series);
    });
    

提交回复
热议问题