Dynamically addSeries highcharts

I am having trouble dynamically adding a series using highstock. To do this, I use the chart.addSeries function. The first series should also be added dynamically through data coming from the web service. My problem is the first view of my chart. I mean, when the chart is first displayed, the scroll bar is not displayed correctly, but when I click on the ZOOM area (1,3,6 months - year - year), the scroll bar appears.

chart.addSeries({
                name: name,
                data: data,
                type: 'spline'
            });

I also set the data in the navigator separately (in order to have the data on xAxis correctly) and the series property is empty (at first I have no series) - The problem is here (empty series)

I saw many examples with addSeries in other series, but did not see them as the first series.

 var navigator = chart.get('navigator');
            navigator.setData(data);

I searched a lot, but I could not find a good solution. Please help me...

thank

+5
source share
1 answer

The problem is the selected button in the range selector. You force Highstock to set extreme values ​​on empty data, so this will result in an error. What you can do is set extremes right after adding data, see

chart.addSeries({
        name: 'ADBE',
        data: ADBE
    }, false);
    var nav = chart.get('navigator');
    nav.setData(ADBE);
    chart.xAxis[0].setExtremes(); //reset or set extremes to get navigator and scrollbar

Real-time example: http://jsfiddle.net/vqa2r/

+4
source

All Articles