hi, All,
I need to display some simple data on chart, the data is in JSON format
return from some PHP page, but i could not get it work in both hosted mode,
which gave me "expected ;" message and Firefox, which gave me "Invalid
label" error message. i suspect for some reason gwt-ext cannot cope with
the JSON from php, tried to modified the code couple of time still cannot
get it work. i post both php code and gxt-ext code below, please give me
some help, thanks.
*php:*
<?php
ini_set("display_errors", 0);
$dhost = 'localhost';
$duser = 'root';
$dpass = 'hello';
$database = 'test';
$retval = array();
$link = mysql_connect($dhost, $duser, $dpass);
if(!$link) {
die('Could not connect: '.mysql_error());
}
@mysql_select_db($database) or die('Unable to select database');
$query = 'select * from hrrr limit 1';
$result = mysql_query($query);
$i = 0;
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
$data[$i] = array('time'=>$row[0], 'rr'=>(float)$row[1]);
$i++;
}
mysql_free_result($result);
mysql_close($link);
$retval['data'] = $data;
echo json_encode($retval);
?>
*data return from php page: *
{"data":[{"time":"0","rr":14.88}]}
*gwt-ext code:*
DataProxy dataProxy = new ScriptTagProxy("
http://xxx.xx.xx.x/getData.php");
final RecordDef recordDef = new RecordDef(new FieldDef[]{
new StringFieldDef("time"),
new FloatFieldDef("rr")
});
JsonReader reader = new JsonReader(recordDef);
reader.setRoot("data");
Store store = new Store(dataProxy, reader);
store.load();
SeriesDefY[] seriesDef = new SeriesDefY[]{
new SeriesDefY("RR", "rr")
};
NumericAxis currencyAxis = new NumericAxis();
currencyAxis.setMinimum(5);
currencyAxis.setLabelFunction("formatCurrencyAxisLabel");
LineChart rrChart = new LineChart();
rrChart.setWMode("transparent");
rrChart.setStore(store);
rrChart.setSeries(seriesDef);
rrChart.setXField("time");
rrChart.setYAxis(currencyAxis);
rrChart.setDataTipFunction("getDataTipText");
rrChart.setExpressInstall("js/yui/assets/expressinstall.swf");
rrChart.setWidth(445);
rrChart.setHeight(110);
...
in host mode, it complained:
*A Runtime Error has occurred. Do you wish to Debug?
Line: 1
Error: Expected ';'
*
in firefox, it complained:
* invalid label
{"data":[{"time":"0","rr":14.88}]}
*
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---