Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically addSeries highcharts

I had a problem in adding series dynamically with highstock. Inorder to do this, I'm using the chart.addSeries function. The first series also should be added dynamically via data comming from a web service. My problem is in the first view of my chart. I mean when the chart is first shown the scrollbar is not shown properly, but when I click on the ZOOM area(1,3,6 month - yearly - ytd) the scrollbar appears.

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

also I'm setting data to navigator separately(inorder to have data on xAxis properly) and the series property is empty(at first I don't have any series)- The problem is here(empty series)

I have seen a lot of examples with addSeries to other series, but haven't seen as the first series.

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

I have searched a lot, but I could'nt find a good solution.Please help me...

Thank you

like image 845
bahar_Agi Avatar asked Oct 05 '22 20:10

bahar_Agi


1 Answers

The problem is with selected button in range selector. You force Highstock to set extremes on empty data, so it will produce error. What you can to is to set directly extremes after data is added, 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

Live example: http://jsfiddle.net/vqa2r/

like image 105
Paweł Fus Avatar answered Oct 13 '22 12:10

Paweł Fus