Search code examples
javascripthighchartsangular5angular2-highcharts

How to add flags to countinuous update angular highcharts


I tried to add flags for loading dynamical data that worked at first when I used the continuous update charts as follows https://www.highcharts.com/stock/demo/dynamic-update and then the flags as follows https://www.highcharts.com/stock/demo/flags-shapes.

Can you please give me some solution for adding flags for continuous data? Also, I would want that if the continuous data exceeds some limit, the flags should appear on that series. And i want flags on continuous data also


Solution

  • Similar to adding points for the basic series, you should also add flag series points:

        events: {
            load: function () {
                var series = this.series[0],
                    flagSeries = this.series[1];
    
                setInterval(function () {
                    var x = (new Date()).getTime(), // current time
                        y = Math.round(Math.random() * 100);
    
                    series.addPoint([x, y], true, true);
    
                    flagSeries.addPoint({
                        x: x,
                        title: y
                    });
                }, 1000);
            }
        }
    

    Live demo: https://jsfiddle.net/BlackLabel/rh8jug5d/

    API: https://api.highcharts.com/class-reference/Highcharts.Series#addPoint