0

I am using highcharts.js to display line chart with multiple series dynamically from servlet .I am storing the series data in arrays and traversing them as follows:

                       series: [{  
                        name: 'series1',
                        data: (function () {
                        var data = [];

                        for (var i = 0; i <= datePV.length; i ++) {
                            data.push([
                                Date.parse(datePV[i]),
                                PVValues[i]
                            ]);
                        }
                        return data;
                    }())

                  },....

The problem is whenever one of the series has no data the whole chart display no data until legends are clicked individually. I want to display all the series with data and the series with no data should not overlap other series data.Need help.

JEECoder
  • 145
  • 1
  • 1
  • 12
  • 1
    Can you refer to [the example](http://jsfiddle.net/nmnr2yo5/1/)? I cannot see the behaviour you described there. – morganfree Jan 18 '17 at 10:46
  • @morganfree Yes u r right. I have even updated this fiddle http://jsfiddle.net/J5y2D/22/ to see if the problem is because of timeseries but it works fine. I don't know what am i doing wrong. – JEECoder Jan 19 '17 at 06:00

1 Answers1

0

I have modified set data function for the series in high charts and applied a check if(datePV.length>0) before for loop.It seems to have done the trick and code is working fine.This is the final code:

                      series: [{
                      name: 'PV',
                      data: (function () {

                        var data = [];
                       if(datePV.length>0)
                       {
                        for (var i = 0; i <= datePV.length; i ++) {
                            data.push([
                                Date.parse(datePV[i]),
                                PVValues[i]
                            ]);
                        }
                       }

                        return data;

                    }())

I hope it helps others facing the same issue.

JEECoder
  • 145
  • 1
  • 1
  • 12