I would like to assign the values of an array to the data and label fields within a chart.js dataset.
Below is the code executed upon successfully fetching JSON data using an AJAX call. The fetched JSON data is then stored in an array.
Data = jQuery.parseJSON(result);
var count = Data.length;
var counter = 0;
while(count > 0) {
LabelResult[counter] =[Data[counter].TIME];
counter++;
count --;
}
Now, I am looking to utilize these label values for the labels field.
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [LabelResult],
datasets: [{
label: '# of Votes',
data: [DataResult],
borderWidth: 1
}]
}
});
However, there appears to be an issue as the data is not being rendered on the chart.