I am using a togglebuttonbar to navigate between 3 seperate
linecharts, each displaying unique data. My problem is that with my
current code only the last chart is displaying any data. Everytime
I change which chart is displayed last it is always the last chart
that displays properly.
So my code lloks like this:
TOGGLEBUTTONBAR
VIEWSTACK
For Loop(example: loops 3 times){
new Canvas(added as child to viewstack)
new Panel(addd as child to canvas)
new Chart
new Array (for line series)
FOR LOOP(example: 2 times){
new Line
line.yfeild = NAME
push line into line series array
}
HTTPservice to get the data, calls dataReceived function,
which is within this for loop
dataReceived{ Chart.dataProvider = event;} // te httpservice
works, Ive checked it in debugging, and because the last chart
displays properly
}
done.
So that should display 3 charts, each with two lines. Note
that the httpservice is calling the same chunk of XML for every
chart, but Im only displaying a couple portions in the each
individual chart. (for example, the xml file has: APPLES, ORANGES,
BANANAS. one cahrt would display apples, the next bananas, etc)
A useful chunk of code is beow... once again, only the last
chart's data is being displayed.
var DB_Connect:Object = new Object;
var URL:String = new String;
URL = ''
http://192.168.11.12/getdata.php?length=day''
useHTTPservice(DB_Connect,URL,dataReceived);
_newChart.series = _newSeries;
_newPanel.addChild(_newChart);
function dataReceived(evt:ResultEvent):void
{
_newChart.dataProvider = evt.result.point;
}
thats from inside the first for loop. I'm certain Im making
some noob mistake!
Chart HTTPservice %26amp; for loop
the newChart object is getting created synchronously, but the
data is comming asynchronously.
You need to store a reference to each new child instance,
perhaps in an associative array(object) as it is created. Then in
the result handler, assign the current result to the appropriate
chart.
Probably need AsyncToken to match call to result.
Tracy
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment