0
Your jsonChartDataSets
property is a string
, not json. You need to convert it back again in your script using JSON.parse()
.
Note you also need @inject IJsonHelper Json;
in your view for the Json.Serialize()
method.
// Get the value from the model
var data = @Json.Serialize(@Model[0].jsonChartDataSets);
// convert to javascript array
data = JSON.parse(data);
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: months,
datasets: data
},
....
});
Source:stackexchange.com