PDA

View Full Version : Ext.chart.Linechart cannot render request from php :(



Gusti
19 May 2011, 11:50 PM
Hi all, i am trying to make an application using Ext.chart and Ext.form. So, i can render charts from range date between date x and date y from the parameter given in the form. This is how i get value from Ext.form :



buttons: [{
text: 'Render',
handler: function() {
var formPanel = Ext.getCmp('date_range');
formPanel.getForm().submit({
type : 'submit',
url: 'desktop_charts.php',
method : 'POST',
params: {date_range_from: 'date_range_from',
date_range_to :'date_range_to',
time_from : 'time_from',
time_to : 'time_to'},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
}
}]



And this is my charts :



new Ext.Panel({
iconCls:'chart',
title: 'X : Date and Time Received - Y : Temperature',
frame:true,
layout:'fit',
//autoScroll : true,
url: '../ext-3.0/resources/charts.swf',
items : new Ext.chart.LineChart({
//url: '../ext-3.0/resources/charts.swf',
autoLoad: false,
//autoLoad: {url: 'desktop_charts.php', scope: this},
store: date_store,
dataField: 'date_received',
xField: 'date_received',
yField: 'temperature',

yAxis: new Ext.chart.NumericAxis({
displayName: 'Temperature',
labelRenderer : Ext.util.Format.numberRenderer('00.00'),
majorUnit : 0.5
}),

tipRenderer : function(chart, record){
return Ext.util.Format.number(record.data.temperature, '00.00') + ' temperature in ' + record.data.date_received;
}

})
})



Why i cannot plot the data that returned from json?
This is my php code :




<?php
header("Cache-Control: no-cache");
sleep(2);

global $con;
$con = mysql_connect("localhost","root","wireless");
mysql_select_db("wsn", $con);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

if(isset($_POST['submit'])) {
$dateFrom = $_POST['date_range_from'];
$dateTo = $_POST['date_range_to'];
$timeFrom = $_POST['time_from'];
$timeTo = $_POST['time_to'];
}

$query = "SELECT date_received, temperature FROM `sensor_results` WHERE node_id = '1' AND date_received BETWEEN " .$dateFrom." ". $timeFrom. "AND". $dateTo." ".$timeTo ;
$result = mysql_query($query);
$dataset1 = array();
while($row = mysql_fetch_array($result))
{
$dataset1['date_received'] = $row [date_received];
$dataset1['temperature'] = $row [temperature];
$data[] = $dataset1;
}
//$response = array( 'data' => $dataset1 );
echo json_encode($data);


mysql_close($con);

?>




When i call php from URL bar of my browser using :


http://localhost/TA/desktop_sms/desktop/desktop_charts.php?submit=true&date_range_from=2011-05-20%2011:00:00&date_range_to=2011-05-20%2012:00:00


The page returned null? Why?
can anyone help me out of this? thank you very much. I need the answer asap :(( So stuck :(

Gusti
23 May 2011, 9:27 PM
No answer? YOU ALL GEEKS! Thanks for silentness!