0👍
Make sure the data that comes back is a JSON object and not just a JSON string. In other words, try data = JSON.parse(data)
which may solve the problem.
0👍
data.datasets
should be an array of objects, you have a single object.
I get the same result (no graph drawn) if I remove the array []
from one of mine that normally uses this manually created structure within an ajax success function:
data: {
labels: ajaxData.Labels,
datasets: [{
label: ajaxData.Sets[0].Label,
data: ajaxData.Sets[0].Data,
backgroundColor: colourScheme.seventyPercent,
hoverBackgroundColor: colourScheme.opaque,
borderColor: colourScheme.white,
borderWidth: 2
}]
}
Source:stackexchange.com