I have data from a database that I want to use to create a chart with labels and values. I have already converted the data to a JSON object. Here is the basic script for setting the labels:
<script>
window.onload = function () {
var arrchartdata = JSON.parse('<?php print $a;?>');
var options = {
animationEnabled: true,
title: {
text: "GDP Growth Rate - 2016"
},
axisY: {
title: "Growth Rate (in %)",
suffix: "%",
includeZero: false
},
axisX: {
title: "Countries"
},
data: [{
type: "column",
yValueFormatString: "#,##0.0#"%"",
dataPoints: [
// Loop through the array of data to set labels and values
]
}]
};
$("#chartContainer").CanvasJSChart(options);
}
</script>
I am trying to loop through the data to set the label as "arrchartdata[0].MenuName" and the value as 10.09, but I am encountering errors. Any assistance on how to properly do this looping would be greatly appreciated!