0

I have JSON that looks like the below:

values: [[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0]]

I query for this in my MEANJS app from the controller

$scope.find = function() {
        $scope.transByusers = TransByusers.query();

Yet, when I attempt to add it into the $scope.data, it does not work.

$scope.data = [

        {
            values: [[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0],[13,0],[14,0],[15,0],[16,0],[17,0],[18,0],[19,0],[20,0],[21,0],[22,0],[23,0],[24,0]]                ,
            mean: 3
        },
        {
            values: $scope.transByusers[0].values
        }

    ];
};

Any insight would greatly appreciated, thanks.

Mörre
  • 5,699
  • 6
  • 38
  • 63

1 Answers1

0

You need to make sure you are telling NVD3 how to access your data (assuming the first object is a series)

var chart = nv.models.multiBarChart()
    .x(function (d) { return d[0] })
    .y(function (d) { return d[1] });

You also need to make sure the series objects you pass to it are of the form

{
   key: 'Series Name', 
   values: [[1,1], [2,4], [3,2], [4,7]], 
   color: 'red'
}

Where color (and technically key) are optional

See this Plunk.

Perhaps you can elaborate more on the what doesn't work or post the code in a Plunker?

Lucas
  • 1,359
  • 7
  • 16