How to use add series and update methods in the high chart wrapper for angular?

后端 未结 2 894
抹茶落季
抹茶落季 2020-12-21 07:34

I am using high chart wrapper in my angular5 app with the help of below link.

high chart wrapper

but how can I use addSeries() to add series into the existing

2条回答
  •  一整个雨季
    2020-12-21 08:18

    here is a very useful answer for learning how to updata a highchart.

    https://www.highcharts.com/demo/chart-update

    it explains a method chart.update

     chart.update({
        chart: {
          inverted: false,
          polar: false
        },
        subtitle: {
          text: 'Plain'
        }
      });
    

    For adding series the following method is used

    chart.addSerie(serie,true);
    

    flag 'true' here is equivalent to chart.redraw();

    OR

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

    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: 'Bill',
        data: [1,2,4,6]
    }, false);
    chart.addSeries({                        
        name: 'John',
        data: [4,6,4,6]
    }, false);
    chart.redraw();
    

    For more information and methods you can visit the Official Highcharts API page:

    https://api.highcharts.com/class-reference/Highcharts.Chart

    When using angular-highcharts wrapper as import { Chart } from 'angular-highcharts';

    create charts as below

      chart = new Chart({
        chart: {
          type: 'line'
        },
        title: {
          text: 'Linechart'
        },
        credits: {
          enabled: false
        },
        series: [
          {
            name: 'Line 1',
            data: [1, 2, 3]
          }
        ]
      });
    

    now you can call all API methods on this

提交回复
热议问题