I need help with inserting data from my ChartJS Controller in an MVC 5 project with AngularJS.
.CS Controller
public JsonResult GetTodaySoFar()
{
TodaySoFarModel todaysofarModel = new TodaySoFarModel();
todaysofarModel.TodaySoFar.Add(new TodaySoFarItemModel { TodaySoFarData = "[22,44,55]" });
return Json(todaysofarModel, JsonRequestBehavior.AllowGet);
}
This is the Controller where I am fetching the data.
$http.get('/revenue/gettodaysofar').success(function (data) {
//debugger;
$scope.todaysofar = data.TodaySoFar;
console.log($scope.todaysofar);
$scope.loading = false;
})
$scope.revenueToday = {
labels: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00'],
datasets: [
{
label: 'My Second dataset',
fillColor: 'rgba(35,183,229,0.2)',
strokeColor: 'rgba(35,183,229,1)',
pointColor: 'rgba(35,183,229,1)',
pointStrokeColor: '#fff',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(35,183,229,1)',
data: [] //I want to populate this array with the values [22, 44, 55] fetched from the JsonResult
}
]
};
Can someone guide me on how to properly insert the Json result into the 'data' section?