I have a bar graph that I'm attempting to create with chart.js that takes a PHP array and loads via ajax. I am able to load the data with ajax (verified in the console) but I cannot get the data in the graph - here is the data in the console:
I have not received any error messages so I'm perplexed at this point. Here is all of the code:
HTML
<?php
include 'connect.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
</canvas><canvas id="myChart"></canvas>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="javascript/charts.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
</body>
JS
$(document).ready(function(){
$.ajax({
url: "prod_agg.php",
method: "GET",
success: function(data) {
console.log(data);
var date = [];
var output = [];
for(var i in data) {
date.push(data[i].date);
output.push(data[i].output);
}
var chartdata = {
labels: date,
datasets : [
{
label: 'Date',
backgroundColor: 'rgba(200, 200, 200, 0.75)',
borderColor: 'rgba(200, 200, 200, 0.75)',
hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
hoverBorderColor: 'rgba(200, 200, 200, 1)',
data: output
}
]
};
var ctx = $("#myChart");
var barGraph = new Chart(ctx, {
type: 'bar',
data: chartdata
});
},
error: function(data) {
console.log(data);
}
});
});
I receive an empty graph:
Any help on this issue would be greatly valued!

