score:1

Accepted answer

You are missing this for loop this will generate as many paths as the test data length.

In your case you were just making a single path...

var currentYear = parseInt(new Date().getFullYear());
            var zeroLayer = [];
            for (var j =0; j < test.length; j++){
               var zeroSegment = {};
              zeroSegment.values = [];
              for(var i=2000;i<=currentYear;i++){
                  zeroSegment.values.push({"x":new Date(i,0,1),"y":0,"y0":0});
              }
              zeroLayer.push(zeroSegment);//only one path gets inserted
            }

In the corrected code test data has 6 data so 6 zeroLayers be created.

for (var j =0; j < test.length; j++){
               var zeroSegment = {};
              zeroSegment.values = [];
              for(var i=2000;i<=currentYear;i++){
                  zeroSegment.values.push({"x":new Date(i,0,1),"y":0,"y0":0});
              }
              zeroLayer.push(zeroSegment);//test data has 6 data so 6 zeroLayers be created
            }

working code here

Hope this helps!


Related Query

More Query from same tag