par
dayou05 » 28 déc. 2014, 22:38
Parce que en fait, voici mon graphique actuel :
graph.png
Ensuite voila le fichier data.php celui contenu ton code :
<?php
$con = mysql_connect("localhost","admin","admin");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tp_arexx", $con);
// On selectionne les tables
$tables = $return = array();
$result = mysql_query("SELECT `Arexx_Table` FROM `tp_arexx_capteurs`");
while ($row = mysql_fetch_assoc($result)) {
$tables[] = $row['Arexx_Table'];
}
// On fait une boucle des tables pour lire leur contenu
foreach($tables as $k => $v) {
$sth = mysql_query("SELECT `mesure`, `jour`, `heure` FROM `".$v."`");
while($r = mysql_fetch_array($sth)) {
$return[$k][] = array(strtotime($r['jour'].' '.$r['heure'])*1000, $r['mesure']);
}
}
print json_encode($return, JSON_NUMERIC_CHECK);
mysql_close($con);
?>
Puis le fichier index.php génération du graph : seulement j'ai trouver enfin comment afficher les heures pas les valeurs récupérer dans la tables..
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
[javascript]
$(function () {
var chart;
$(document).ready(function() {
$.getJSON("data.php", function(json) {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'x',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Affichage des mesures des capteurs en fonction du temps et de la date.',
x: -20 //center
},
subtitle: {
text: 'Vous pouvez effectuer un zoom sur le graphique en maintenant le clique gauche souris sur une zone du graphique',
x: -20
},
xAxis: {
type: 'datetime',
tickInterval: 3600 * 1000,
min: Date.UTC(2013,4,22),
max: Date.UTC(2013,4,23),
},
yAxis: {
max:50, // maxi du graphe
min: -50, // mini du graphe
tickInterval: 10,
title: {
text: 'Températures °C'
},
plotLines: [{
value: 0,
width: 1,
color: '#FF0000'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y + ' °C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
credits: {
text: '© Dayan LOMBARDI',
},
series: [{
data: [
json
//and so on...
]
}]
});
});
});
});
[/javascript]
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Etant donner que je réussit a afficher 24h je penser faire une sélection des capteurs grâce a une listbox puis le jour disponible et enregistrer pour ce capteur enregistrer dans la BDD et ainsi afficher le graphique sur 24h ...
Mais si tu me propose autrement, ou si tu peut m'aider à accomplit au moins cela je t'en serait très reconnaissant !
Parce que en fait, voici mon graphique actuel :
[attachment=0]graph.png[/attachment]
Ensuite voila le fichier data.php celui contenu ton code :
[php]<?php
$con = mysql_connect("localhost","admin","admin");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tp_arexx", $con);
// On selectionne les tables
$tables = $return = array();
$result = mysql_query("SELECT `Arexx_Table` FROM `tp_arexx_capteurs`");
while ($row = mysql_fetch_assoc($result)) {
$tables[] = $row['Arexx_Table'];
}
// On fait une boucle des tables pour lire leur contenu
foreach($tables as $k => $v) {
$sth = mysql_query("SELECT `mesure`, `jour`, `heure` FROM `".$v."`");
while($r = mysql_fetch_array($sth)) {
$return[$k][] = array(strtotime($r['jour'].' '.$r['heure'])*1000, $r['mesure']);
}
}
print json_encode($return, JSON_NUMERIC_CHECK);
mysql_close($con);
?>
[/php]
Puis le fichier index.php génération du graph : seulement j'ai trouver enfin comment afficher les heures pas les valeurs récupérer dans la tables..
[html]
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
[javascript]
$(function () {
var chart;
$(document).ready(function() {
$.getJSON("data.php", function(json) {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'x',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Affichage des mesures des capteurs en fonction du temps et de la date.',
x: -20 //center
},
subtitle: {
text: 'Vous pouvez effectuer un zoom sur le graphique en maintenant le clique gauche souris sur une zone du graphique',
x: -20
},
xAxis: {
type: 'datetime',
tickInterval: 3600 * 1000,
min: Date.UTC(2013,4,22),
max: Date.UTC(2013,4,23),
},
yAxis: {
max:50, // maxi du graphe
min: -50, // mini du graphe
tickInterval: 10,
title: {
text: 'Températures °C'
},
plotLines: [{
value: 0,
width: 1,
color: '#FF0000'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y + ' °C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
credits: {
text: '© Dayan LOMBARDI',
},
series: [{
data: [
json
//and so on...
]
}]
});
});
});
});
[/javascript]
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
[/html]
Etant donner que je réussit a afficher 24h je penser faire une sélection des capteurs grâce a une listbox puis le jour disponible et enregistrer pour ce capteur enregistrer dans la BDD et ainsi afficher le graphique sur 24h ...
Mais si tu me propose autrement, ou si tu peut m'aider à accomplit au moins cela je t'en serait très reconnaissant !