Thursday, 8 June 2017

Map data from object properties containing arrays to multidimensional format.

I am having trouble figuring out the best way to map the current data to a format that is practical for chart.js.

the chart data is being stored here

$scope.data = [ 
   [week1 data, week2 data], //category1
  ...//category2
]

enter image description here

My current data is grouped by week and each week has data for each categories sales. The last element in each category is an object with values containing its total. I need to figure out a way to dynamically map from my current data to the $scope.data format so that $scope.data will create a new array for the category if it does not exist and append to that array as it goes through the weeks.



via CLR45

No comments:

Post a Comment