我使用mysql作为数据,然后用php.
$array = data()->query("SELECT DATE(rezervacijaOpravljena) d, COUNT(id) visits FROM rezervacija GROUP BY d")->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($array,JSON_NUMERIC_CHECK); 在javascript (morris.js数据)中,我使用了以下脚本:
Morris.Line({
element: 'morris-line-chart',
data: $.ajax({
url: "dodajRezervacijo.php",
success: function(html) {
console.log(JSON.parse(html)[0]);
return JSON.parse(html)[0];
}
})
,
// The name of the data record attribute that contains x-visitss.
xkey: 'd',
// A list of names of data record attributes that contain y-visitss.
ykeys: ['visits'],
// Labels for the ykeys -- will be displayed when you hover over the
// chart.
labels: ['Visits'],
// Disables line smoothing
smooth: true,
resize: true
}); 但这是行不通的。我是一个使用ajax的初学者。php查询数据的这种使用也是好的吗?还是最好有所有的东西,如(准备和执行功能分别?)
发布于 2014-10-07 16:45:02
从ajax调用中获取数据,在成功函数中调用morris图。
这应该能起作用。
https://stackoverflow.com/questions/26240606
复制相似问题