Need help with ColumnChart

0 views
Skip to first unread message

kapil

unread,
Jul 24, 2008, 12:48:55 AM7/24/08
to Flex India Community
Hi,

I am new to flex.
I want to create a sample report using ColumnChart.
I have a JSP which gives me data in XML format from the server.

At flex end i am doing the following-

<mx:HTTPService result="handleXML(event);"
fault="handleFault(event);"
id="xmlRPC"
resultFormat="e4x"
url="http://localhost:8080/webapp/xmlChartData.jsp"
useProxy="false"/>

<mx:Script>
<![CDATA[

import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;

[Bindable]
private var chartData:XMLList;

public function handleXML(event:ResultEvent):void
{
chartData = event.result.option as XMLList;
}

public function handleFault(event:FaultEvent):void
{
Alert.show(event.fault.faultString, "Error");
}
]]>

</mx:Script>


Can somebody help me out with ColumnChart code i.e. how can i plot the
data from the XMLList object.


Lets say my XML data will look like this -

<Samples>
<Sample month="January" revenue="120" costs="45" overhead="102"
oneTime="23">1</Sample>
<Sample month="February" revenue="108" costs="42" overhead="87"
oneTime="47">2</Sample>
<Sample month="March" revenue="150" costs="82" overhead="32"
oneTime="21">3</Sample>
</Samples>

Natwar Garg

unread,
Jul 24, 2008, 8:02:36 AM7/24/08
to flex_...@googlegroups.com
Below are the changes

/**************Old Code **************************


public function handleXML(event:ResultEvent):void
{
chartData = event.result.option as XMLList;
}

endOf---Old Code ***************************/


public function handleXML(event:ResultEvent):void
{

chartData = event.result.Sample as XMLList;

}


/* You can use received XMLlist as below*******

for(var idx:Number=0;idx chartData.length();idx++)
{
trace(" \n Sample :" + idx.toString() + " - > " + chartData[idx].@month);
}
*/


Regards,
Natwar Garg

________________________________

Anish Kumar

unread,
Jul 24, 2008, 9:06:47 AM7/24/08
to Flex India Community
Hi,

I feed the XML i receive from HTTPService as XMLListCollection. So for
your above sample xml, you might try this


_myColChart.dataProvider =new XMLListCollection(evt.result.Sample);

and make sure you column series have their xField and yField assigned
respectively.

regards,
-Anish

Sarika Jain

unread,
Jul 24, 2008, 1:44:15 AM7/24/08
to flex_...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages