angularjs - how to merge JSON object together -
i want make bar-chart , have 2 functions each of them return data exemple : first function 1,:
$scope.data = {     labels: ['jan', 'feb', 'mar'],     datasets: [         {             label: 'my first dataset',             fillcolor: 'rgba(220,220,220,0.2)',             strokecolor: 'rgba(220,220,220,1)',             pointcolor: 'rgba(220,220,220,1)',             pointstrokecolor: '#fff',             pointhighlightfill: '#fff',             pointhighlightstroke: 'rgba(220,220,220,1)',             data: [55, 40, 84]         }     ] };   the second function returned :
$scope.data = {     labels: ['apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'],     datasets: [          {             label: 'my second dataset',             fillcolor: 'rgba(151,187,205,0.2)',             strokecolor: 'rgba(151,187,205,1)',             pointcolor: 'rgba(151,187,205,1)',             pointstrokecolor: '#fff',             pointhighlightfill: '#fff',             pointhighlightstroke: 'rgba(151,187,205,1)',             data: [28, 48, 40, 19, 86, 27, 90, 102, 123]         }     ] };   my quesion how can combine resut ths final result:
 $scope.data = {     labels: ['jan', 'feb', 'mar','apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'],     datasets: [       {             label: 'my second dataset',             fillcolor: 'rgba(151,187,205,0.2)',             strokecolor: 'rgba(151,187,205,1)',             pointcolor: 'rgba(151,187,205,1)',             pointstrokecolor: '#fff',             pointhighlightfill: '#fff',             pointhighlightstroke: 'rgba(151,187,205,1)',             data: [28, 48, 40, 19, 86, 27, 90, 102, 123]         },         {             label: 'my second dataset',             fillcolor: 'rgba(151,187,205,0.2)',             strokecolor: 'rgba(151,187,205,1)',             pointcolor: 'rgba(151,187,205,1)',             pointstrokecolor: '#fff',             pointhighlightfill: '#fff',             pointhighlightstroke: 'rgba(151,187,205,1)',             data: [28, 48, 40, 19, 86, 27, 90, 102, 123]         }     ] };      
use concat method.
 var finalobj = data1.concat(data2);      
Comments
Post a Comment