Search code examples
angularjsnvd3.jsstacked-area-chart

how to figure out the input data in nvd3.js Stacked Area Chart


Guys I'm trying to implement a Stacked Area Chart using nvd3.js and angular.js the input data is as follows,

{ 
      "key" : "North America" , 
      "values" : [ [ 1025409600000 , 23.041422681023] , [ 1028088000000 , 19.854291255832],
       [ 1030766400000 , 21.02286281168], 
       [ 1033358400000 , 22.093608385173],
       [ 1036040400000 , 25.108079299458],
       [ 1038632400000 , 26.982389242348]]
}

I cant understand what this data represents. Specially the X axis data, It gets the date value from the data below but I cant figure it out. Any help would be great. The link to the original code is below http://nvd3.org/examples/stackedArea.html


Solution

  • In the above data,

    { 
          "key" : "North America" , 
          "values" : [ [ 1025409600000 , 23.041422681023] , [ 1028088000000 , 19.854291255832],
           [ 1030766400000 , 21.02286281168], 
           [ 1033358400000 , 22.093608385173],
           [ 1036040400000 , 25.108079299458],
           [ 1038632400000 , 26.982389242348]]
    }
    

    It shows one series of a stack bar chart. Where Key Indicates the Series Name and The Values indicates the Stack, if you take the first value 1025409600000 is the Date (Here its timestamp) and 19.854291255832 is the y axis value. Similarly it goes on, You can have more series with different stacks.

    You can see the FullStack Data here.