我正在尝试显示高库存烛台图表,但我无法实现。我的网站在图表应显示的位置显示一个空白,但图表中没有任何显示。如何修复它以显示图表?我有两个脚本:datachart.inc.php:<?phpinclude '../dbh.php'; //It connects to the database$sql = "SELECT * from table";$result = $conn->query($sql);$row = mysqli_fetch_array($result);$data = array();$count = 0;while ($row=mysql_fetch_array($result)){ $newdate = strtotime($row['date']) * 1000; $data[] = array($newdate, (float)$row['open'], (float)$row['high'], (float)$row['low'], (float)$row['close']); $count++;} echo json_encode($data);?>index.htm:<!DOCTYPE HTML><HTML> <BODY> <script> $(function() { $.getJSON('datachart.inc.php', function(data) { // create the chart chart = new Highcharts.StockChart({ chart : { renderTo : 'container', }, rangeSelector : { selected : 1 }, title : { text : 'Test Price' }, series : [{ type : 'candlestick', name : '', data : data, tooltip: { valueDecimals: 2 }, dataGrouping : { units : [ ['week', // unit name [1] // allowed multiples ], [ 'month', [1, 2, 3, 4, 6]] ] } }] }); });});</script><div id="container" style="height: 250px; min-width: 250px"></div> </BODY></HTML>
1 回答
LEATH
TA贡献1936条经验 获得超6个赞
解决了:
1)导入javascript文件
2)删除“ $ row = mysqli_fetch_array($ result);”
3)将“ while($ row = mysqli_fetch_array($ result))”更改为“ while($ row = mysqli_fetch_array($ result))”
- 1 回答
- 0 关注
- 145 浏览
添加回答
举报
0/150
提交
取消