Jump to content

HighCharts Datum Problem mit Datenbank


Recommended Posts

Hallo,

ich komme gerade irgendwie nicht weiter,

habe es geschafft daten die ein script in die mysql db geschrieben hat auszulesen und in highcharts anzuzeigen.

Leider bekomme ich unter dem diagramm nicht die uhrzeit angezeigt.

http://jediwookie.dyndns.org/test4.php?hour=2

xAxis: {
                categories: [<?php echo $row_buero; ?>] // HIER SOLL DIE UHRZEIT AUS DER DATENBANK REIN !!!!!!!!
            },

Funktioniert und er schreibt unter den Char die Temperatur Werte aus dem Büro, dieses habe mal zum testen anzeigen lassen.

 

xAxis: {
                categories: [<?php echo $row_dattim; ?>] // HIER SOLL DIE UHRZEIT AUS DER DATENBANK REIN !!!!!!!!
            },

Funktioniert leider nicht und die website bleibt weiss.

 

Auch das umwandeln des datums in

 

Hier der komplette code:

<center>
<a href="test4.php?hour=2">Last 2h</a> - 
<a href="test4.php?hour=6">Last 6h</a> - 
<a href="test4.php?hour=12">Last 12h</a> - 
<a href="test4.php?hour=24">Last 24h</a> - 
<a href="test4.php?hour=48">Last 48h</a>
</center>
<?php

include("connect.php");

$ausruf = $_GET["hour"];
$result = mysql_query("SELECT * FROM August WHERE dattim > DATE_SUB(NOW(), INTERVAL $ausruf HOUR)");
$num = mysql_num_rows ($result);

// $dattim = new DateTime;
// echo $dattim->format("H:i:s"); 

if ($num > 0 ) {
$i=0;
while ($i < $num) {

	$id = stripslashes(mysql_result($result,$i,"id"));
	$dattim = stripslashes(mysql_result($result,$i,"dattim"));
	$aussen1 = stripslashes(mysql_result($result,$i,"aussen1"));
	$buero = stripslashes(mysql_result($result,$i,"buero"));
	$temprasperry = stripslashes(mysql_result($result,$i,"temprasperry"));	
	$flur = stripslashes(mysql_result($result,$i,"flur"));

$row .= '<tr><td>'.$dattim.'</td><td>'.$aussen1.'°C</td><td>'.$temprasperry.'°C</td><td>'.$buero.'°C</td></tr>';
    $row_aussen .= ''.$aussen1.',';
$row_buero .= ''.$buero.',';
$row_rasp .= ''.$temprasperry.',';
// $row_flur .= ''.$flur.',';
$row_dattim .= ''.$dattim.',';


++$i; }} else { $row = '<tr><td colspan="2" align="center">Nothing found</td></tr>'; }

mysql_close();
?>



<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Temperaturen</title>

	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
	<script type="text/javascript">
$(function () {
        $('#container').highcharts({
            title: {
                text: 'Temperaturen',
                x: -20 //center
            },
            subtitle: {
                text: 'Source: Database -><?php echo $jahr;?>',
                x: -20
            },
            xAxis: {
                categories: [<?php echo $row_buero; ?>] // HIER SOLL DIE UHRZEIT AUS DER DATENBANK REIN !!!!!!!!
            },
            yAxis: {
                title: {
                    text: 'Temperature (°C)'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '°C'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 2
            },
            series: [{
                name: 'Buero',	
                data: [<? echo $row_buero ?>]
            },
            {
                name: 'Aussentemperatur',
                data: [<? echo $row_aussen ?>]
            },
            {
                name: 'Raspberry',
                data: [<? echo $row_rasp ?>]
            },
            {
                name: 'Flur',
                data: [<? echo $row_flur ?>]
            }]
        });
    });
    

	</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

</body>
</html>

 

Vieleicht kann mir jemand einen tip geben. :-)

 

Anbei noch bilder von der db struktur

 

gruss

Sascha

Bildschirmfoto_2013-08-23_um_14_53_31.thumb.png.a2f52c00adfbd4d674ffc7cf0dd1cf69.png

Bildschirmfoto_2013-08-23_um_14_54_16.png.f2aa347da058c024f29315720fc230f0.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...