-
October 22nd, 2011, 04:42 PM
#1
noob needs help
please could you help me i am using highcharts and cant get the dates to show at the bottom from mysql over 5 days please could some one help me with this
thank you
here is the chart
database layout
code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Daily Temperature 8 Conv</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="./js/highcharts.js" type="text/javascript"></script>
<script type="text/javascript" src="js/theme-wsl.js"></script>
</head>
<div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div>
<?php
$db = @mysql_connect("localhost", "8conv", "*******") or die("Connection Error: " . mysql_error());
mysql_select_db("tempmonitor") or die("Error connecting to db.");
$sql = "SELECT * FROM `8conv`";
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result)) {
$temp1[] = (int)$row['temp1'];
$temp2[] = (int)$row['temp2'];
$time[] = $row['timestamp'];
}
$temp1 = json_encode($temp1);
$temp2 = json_encode($temp2);
$time = json_encode($time);
?>
<script type="text/javascript">
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
title: {
text: 'Weekly Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: 8 conveyor',
x: -20
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y +' oC ';
}
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxZoom: 20 * 1000
},
yAxis: {
title: {
text: 'Temperature ( oC )'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
series: [{
name: 'Temp 1',
data:<?php echo $temp1; ?>,
},
{
name: 'Temp 2',
data:<?php echo $temp2; ?>,
}]
});
</script>
</head>
</body>
</html>
thanks
-
October 22nd, 2011, 05:54 PM
#2
Re: noob needs help
You should post your question in a more appropriate forum (try this). This is a Java forum and Java != JavaScript.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|