我試圖通過使用morris JavaScript的mysql傳遞值從而顯示動態條形圖。但只有值是x軸正在傳遞。因此該圖是空白的。我做了所有研究,但找不到它。我需要你的幫助。我是編程新手。在Y軸的值不通過莫里斯javascript
Morris.Bar({
element : 'chart',
data:[<?php echo $chart_data; ?>],
xkey:'gp_submit',
ykeys:['cnt'],
labels:['Submitted','cnt'],
hideHover:'auto',
stacked:true
});
<?php $connect = mysqli_connect("localhost", "root", "", "hr");
$query = "SELECT gp_submit AS dt, name AS cnt FROM `emp_det` where gp_submit>=DATE_SUB(NOW(), INTERVAL 1 WEEK) GROUP BY gp_submit";
$result = mysqli_query($connect, $query);
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$chart_data .= "{ gp_submit:'".$row["dt"]."', cnt:'".$row["cnt"]."'}, ";
}
$chart_data = substr($chart_data, 0, -2);
?>
<div id="chart" style="width:100%; height:280px;"></div>
您還可以添加您的查詢結果,以便我們可以看到您正在處理的數據嗎? –