I have a Chart.js with values from a Javascript array which looks exactly like that:
var obj = JSON.parse('{"0":"8.4113","2":"9.5231","3":"9.0655","4":"7.8400"}');
And here I give the "obj" array to the chartjs which works fine and fills out the bars:
var barChartData = {
labels : obj1,
datasets : [
{
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data : obj
}
]
}
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar(barChartData, {
responsive : true
});
}
</script>
But as you can see there is a second array called "obj1" which stores the names for the labels. This one looks exactly like that:
var obj1 = JSON.parse('{"0":"name1","2":"name2","3":"name3","4":"name4"}');
This second array does not fill out the labels like the other array, the labels are still empty. I have no idea why it does not work like the data:"".