Good morning in PDT, and thanks for being here.
Me: new to AS & Flex, building a Linux-based dashboard, using
Flexbuilder alpha for Linux in Eclipse
( this does not have all features compared to Windows and OSX I believe,
and may be buggy)
*Problem:* I've been given an XML schema for incoming data thats
complex, and well, may not be optimum. :)
When I follow the tutorials using simple data,
<data>
<item>
<eth>eth0</eth>
<packets>1234</packets>
<bps>3005</bps>
</item>
<item>
<eth>eth1</eth>
<packets>517</packets>
<bps>4335</bps>
</item>
...
</data>
I am able to get a dynamic bar chart that responds to changes in number
of members of the "data" array of elements. But my real data is complex
( see below) and it appears to me that the dataFunc to chart series
dataprovider connection, which understands simple arrays, gets confused
with complex arrays.
*What I get thats wrong:*
Trace shows me getting results like
"<peas> data1 </peas>
<peas> data2 </peas>"
or using a different notation,
"data1data2"
when I expect an array of data1,data2
and the chart won't work at all.
*What I want to know:* I want some guidance to help me avoid dead ends-
Is my XML just flat not suitable?
Am I wrong about the problem?
Do I need to do some complicated restructuring of the data before I
return it from the dataFunc, so I send a simple array like shown above?
Thanks!
John
*Simplified Data:*
<save_instance>
<name>PC</name>
<instance>
<id>1</id>
<beetles_count>1</beetles_count>
<beetles>
<array>
<seed_name>eth3</seed_name>
<instance>0</instance>
<apple_id>4094</apple_id>
</array>
</beetles>
<service_count>1</service_count>
<services>
<array>
<waiter_count>4</waiter_count>
<name>html</name>
<servers>
<array>
<lpeach>0</lpeach>
<name>se1</name>
<upeach>0</upeach>
<instance>0</instance>
<carrots_list>
<array>
<carrots_list>1</carrots_list>
</array>
</carrots_list>
<apple_id>1</apple_id>
<statistics>
<statistics>
*<peas>00000000</peas> data1*
* <refresh>0</refresh> X label*
*<bugs>00000000</bugs> data2*
</statistics>
<activeconns>00000000</activeconns>
<inactiveconns>00000000</inactiveconns>
<persistconns>00000000</persistconns>
</statistics>
<pits>10.0.1.42</pits>
<pc_pits>10.0.1.101</pc_pits>
<status>2</status>
<weight>1</weight>
</array>
</servers>
<instance>0</instance>
<status>2</status>
<statistics>
<peas>00000000</peas>
<refresh>2000</refresh>
<bugs>00000000</bugs>
</statistics>
<protocol>00000001</protocol>
<scheduling>00000001</scheduling>
<forwarding_method>00000001</forwarding_method>
</array>
...
</services>
<control_seedname>eth0</control_seedname>
<fastpath>
<num_stack>0</num_stack>
<num_key>0</num_key>
<num_hash>0</num_hash>
</fastpath>
<statistics>
<peas>0000000c</peas>
<refresh>2000</refresh>
<bugs>00000000</bugs>
</statistics>
</instance>
...
</save_instance>
//////////////////////////////////////////////////////////
*dataFunc:*
private function dataFunc(series:Series, item:Object,
fieldName:String):Object {
if(fieldName == "yValue" && series.id=="peas"){
return(item.services.array.servers.array.statistics.statistics.peas ) ;}
else if(fieldName == "yValue" && series.id=="bugs"){
return(item.services.array.servers.array.statistics.statistics.bugs) ;}
else if(fieldName == "xValue"){
return(item.services.array.servers.array.name) ;}
else{
display (" dataFunc returns NULL");
return null;
}
}
/////////////////////////////////////////////////////////////
*chart:*
<mx:ColumnChart id="chart"
dataProvider="{xmlData}"
showDataTips="true"
width="50%"
height="50%"
>
<mx:horizontalAxis>
<mx:CategoryAxis id="h1" dataFunction="catFunc"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries id="peas"
displayName="Peas"
dataFunction="dataFunc"
/>
<mx:ColumnSeries id="bugs"
displayName="Bugs"
dataFunction="dataFunc"
/>
</mx:series>
</mx:ColumnChart>