0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'> </script>
<script src='http://code.highcharts.com/modules/exporting.js' type='text/javascript'> </script>
</head>
<body>
<?php
$con = mysql_connect('localhost', 'root', '123456') or die('Error connecting to server');
mysql_select_db("aplikace", $con);
$SQL1 = "SELECT * FROM data";
$result1 = mysql_query($SQL1);
$data1 = array();
while ($row = mysql_fetch_array($result1)) {
$data1[] = $row['cas'];
}
$result2 = mysql_query($SQL1);
$data2 = array();
while ($row = mysql_fetch_array($result2)) {
$data2[] = hexdec($row['pars_data']);
}
?>
<script type="text/javascript">
$(document).ready(function() {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line'
},
title: {
text: 'Comming Data'
},
xAxis: {
categories: ['<?php echo join($data1, "','") ?>'],
},
yAxis: {
min:0,
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',
verticalAlign: 'top',
x: 50,
y: 35,
floating: true,
shadow: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [ {
name: 'Data',
data: ['<?php echo join($data2, "','") ?>'],
// pointStart: 0
//pointInterval
},
]
});
});
</script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
傢伙嗨,我不kwno在那裏我有一個錯誤,你能幫助我嗎?在X軸上應該是來自列CAS->的日期時間,但它不會顯示列PARS_DATA。感謝您的幫助,謝謝。
MySQL表屏幕:
表,我看到:
第一,爲什麼執行兩次相同的查詢時,你可以做到這一點只有一次?其次,你是否打印data2數組以查看它的外觀?大數字爲 – 2013-03-12 13:09:39
,hexdec使用科學記數法。也許這是在混淆價值。在hexdec後使用number_format($ hexdec_result,0,'',''); – 2013-03-12 13:17:39
你是對的,我可以做一次查詢,當我想顯示'$ data2'數組圖表disapper,我什麼都看不到。你能指導我嗎? – forgatn 2013-03-12 13:18:39