hi i have a table contains 3 columns (time datetime,temperature int,humidity int)
![table meteo](https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfa1/v/t34.0-12/10719339_1004269489599019_1301360240_n.jpg?oh=e83c7a010ed91e826c1e18bbab5288cd&oe=54407B0D&__gda__=1413578501_4752b32a968c53932ef21d0925aa621b)
i wanna draw a canvas with 2 lines of temperature and humidity with date day by day my php is :
<?php
header('Content-Type: application/json');
include_once("connect.php");
if($_POST['action'] == "showGraph"){
$data_points = array();
$result = mysql_query("SELECT * FROM data" , $connection);
while($row = mysql_fetch_assoc($result)){
$point = array("label" => $row['TS'] , "y" => $row['TEMP']);
array_push($data_points, $point);
}
echo json_encode($data_points, JSON_NUMERIC_CHECK);
}
javascript :
function showGraph(){
$.getJSON("scriptWithAjax.php", function (result) {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Temperature et l'humidité"
},
axisY:{
titleFontFamily: "arial",
titleFontSize: 12,
includeZero: false
},
toolTip: {
shared: true
},
data: [
{
type: "spline",
name: "Humidité",
showInLegend: true,
dataPoints: [
{label: "Oct 1" , y: 40} ,
{label:"Oct 2", y: 37} ,
{label: "Oct 3", y: 34} ,
{label: "Oct 4", y: 36} ,
{label: "Oct 5", y: 54}
]
},
{
type: "spline",
name: "Température",
showInLegend: true,
dataPoints: [
{label: "Oct 1" , y: 27} ,
{label:"Oct 2", y: 28} ,
{label: "Oct 3", y: 26} ,
{label: "Oct 4", y: 27} ,
{label: "Oct 5", y: 32}
]
}
],
legend:{
cursor:"pointer",
itemclick:function(e){
if(typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
chart.render();
}
}
});
chart.render();
});
}
jquery and canvas are called in my index but it doesn’t shows anything
if it show then i need to draw a line for humidity