highcharts - 在没有任何数据图片的情况下显示没有任何呈现从mysql查询
问题描述:
我一直在寻找这里和在互联网上的解决方案显示没有数据图片上的highcharts的DIV时,查询不返回任何来自数据库的东西。highcharts - 在没有任何数据图片的情况下显示没有任何呈现从mysql查询
MySQL查询
$GetData= "SELECT COUNT(*) AS `items count` , `items`
FROM `items`
where repdate = curdate()
GROUP BY `items`
ORDER BY `items count` DESC ";
我的表的代码
<table width="313" id="datatable" style="display:none;">
<thead>
<tr>
<th>column 1</th>
<th>column 2</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_array($GetData)) {
echo "<tr>";
echo "<th>" . $row['items'] . "</th>";
echo "<td>" . $row['items count'] . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
例如:
在MySQL查询不返回任何数据,我得到以下。
如何从渲染如果没有返回的数据停止highcharts?并用图片
类似的例子更换JSfiddle
答
您可以检查你的选择变量,看是否有任何数据,并且只渲染是否存在的数据图表。
if (options.series.length > 0) {
var chart = new Highcharts.Chart(options);
}
我的查询而没有数据是背面像” \t \t \t 项 \t \t \t 项目数 \t \t
\t “不与上述工作,因为该系列计数与第一行开始,我不能循环而内部的表头..任何其他溶液 – 2013-03-20 14:29:40NVM,通过将上述一个解决如果声明。 – 2013-03-20 14:37:48
然后为实际数据添加一个计数器,并在渲染图之前检查它:) – cernunnos 2013-03-20 15:15:21