简体   繁体   中英

no data module with multiple series in highcharts.js

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM