Oops, I'm using ChartJS for graphing, I'm integrating with PHP to send json to the chart
php
$arrLabels = array("January","February","March");
$arrDatasets = array('label' => "My First dataset",'fillColor' => "rgba(220,220,220,0.2)", 'strokeColor' => "rgba(220,220,220,1)", 'pointColor' => "rgba(220,220,220,1)", 'pointStrokeColor' => "#fff", 'pointHighlightFill' => "#fff", 'pointHighlightStroke' => "rgba(220,220,220,1)", 'data' => array('28', '48', '40'));
$arrReturn = array(array('labels' => $arrLabels, 'datasets' => $arrDatasets));
print (json_encode($arrReturn));
js
var ctx = document.getElementById("salesChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
data_retorno
}
});
Value of data_retorno
[
{
"labels":[
"January",
"February",
"March"
],
"datasets":{
"label":"My First dataset",
"fillColor":"rgba(220,220,220,0.2)",
"strokeColor":"rgba(220,220,220,1)",
"pointColor":"rgba(220,220,220,1)",
"pointStrokeColor":"#fff",
"pointHighlightFill":"#fff",
"pointHighlightStroke":"rgba(220,220,220,1)",
"data":[
"28",
"48",
"40"
]
}
}
]
Where data_retorno
is the return of ajax.
The graph that is already loaded with other data, upon receiving this result, simply the lines disappear and nothing happens