I have flex 4, zend & php. I am trying to generate a chart w/ 5 yrs of data & then let the user (without making another call to the server) get a 1 yr chart w/ the same data. (In other words, the 1 yr's worth of data is a subset of the 5 yrs). I can get the initial 5 yr chart but when I try to apply a filter, as below, I get no data. What am I doing wrong?
I have the following code:
`
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:datadata="services.datadata.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function getData(event:FlexEvent):void
{
getDataResult.token = dataData.getData();
}
public function filterByRange(item:Object):Boolean
{
var result:Boolean = true;
if (item.date.time > 2007-01-01 && item.date.time < 2008-12-31 ){
result = false;
}
return result;
dg.refresh();
}
]]>
</fx:Script>
<fx:Declarations>
<s:ArrayCollection id="dg" filterFunction="filterByRange" list="{getDataResult.lastResult}" />
<s:CallResponder id="getDataResult"/>
<datadata:DataData id="dataData" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
</fx:Declarations>
<mx:AreaChart id="areachart1" width="100%" height="100%" creationComplete="getData(event)" dataProvider="{dg}" showDataTips="true">
<mx:series>
<mx:AreaSeries yField="price" id="areaSeries" xField="date"/>
</mx:series>
<mx:horizontalAxis>
<mx:DateTimeAxis/>
</mx:horizontalAxis>
</mx:AreaChart>
`
This is what my PHP code looks like. Remember, I am using Zend.
`
public function getData() {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename");
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->date, $row->price);
while (mysqli_stmt_fetch($stmt)) {
$row->date = new DateTime($row->date);
$rows[] = $row;
$row = new stdClass();
mysqli_stmt_bind_result($stmt, $row->date, $row->price);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
`