I am working with zend framework 2 and i want to display charts in some views but it doesn't work!! This is my Action:
public function statvehAction(){
$data = [
'labels' => ["January","February","March","April","May","June","July"],
'data' => [18,99,30,81,28,55,30]
];
json_encode($data);
$viewModel = new ViewModel(array('data' => $data));
return $viewModel;
}
this is my view:
<script src="../../../../jquery.min.js"></script>
<script src="../../../../chart.min.js"></script>
<script>
(function($){
var ctx = document.getElementById("chart").getContext("2d");
$.ajax({
type: "POST",
url: "VehiculesController.php",
dataType: "json"
})
.success(function(data) {
var d = {
labels: $data.labels,
datasets : [
{
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,1)",
data: data.data }] };
var barChart = new Chart(ctx).Bar(d);
});
})(jQuery);
</script>
But when i want to diplay my chart i got a white page whith no error !! Please can you help me to solve this problem.