Groups | Blog | Home
all groups > flash data integration > may 2005 >

flash data integration : Action Script to read multiple datasets in XML doc for Flash Bar Chart



dbmdsrv01
5/25/2005 12:00:00 AM
I am trying to compare groups of items using an XML source and need assistance
in creating the
Action Script to properly read multiple datasets within an XML doc in order to
create a Flash MX
Bar Chart.

I have been successful in creating a Flash Chart using one dataset, i.e.
phone expenses for
current year. However, I would like to include additional information for
comparison to the
prior year, i.e. phone expenses for current year with last year expenses
appearing as a column
directly to the left of the column for the current year.

Here is the Action Script that I have been able to successfully use in passing
the XML data
containing a single dataset:

--------------------------------------------------------------------------------
--------------------------
function parseXML() {
//This functions parses the XML Data passed to it.
//cldNodes array will contains the child nodes of the XML Doc passed to it.
cldnodes = new Array();
cldnodes = XMLDoc.childNodes;

//Num will contain the count of datasets passed to the movie, i.e. 0 = 1
dataset; 1 = 2 datasets, etc.
num = 0;

//Dataset will contain the data childnodes
dataset = new Array();

//DataName will contain the x-axis name(or value) of the data sets
dataname = new Array();

//DataValue will contain the y-axis value of the data sets
datavalue = new Array();

//dataLink will contain the hot-spots
dataLink = new Array();

//Iterate through the first level children of the XML Doc
for (j=0; j<=cldnodes.length; j++) {

//Check if the node Name is Graph (i.e., the data set belongs to graph)
if (cldnodes[j].nodeName.toUpperCase() == "GRAPH") {

//Get the chart type to be shown
chartType = cldnodes[j].attributes.chartType;

//Get the caption of the graph
caption = cldnodes[j].attributes.caption;

//Get the x-axis name
xaxisname = cldnodes[j].attributes.xaxisname;

//Get the y-axis name
yaxisname = cldnodes[j].attributes.yaxisname;

//Get the dataset
dataset = cldnodes[j].childNodes;

//Iterate through the dataset
for (k=0; k<=dataset.length; k++) {

//If the node name is Set (i.e., a graph dataset) then retrieve and collect
the values
if (dataset[k].nodeName == "set") {

//Get the x-axis name
dataname = dataset[k].attributes.name;

//Get the value
datavalue = dataset[k].attributes.value;

//Get the link
dataLink = dataset[k].attributes.link;

//Increment counter
num = num+1;

}
}
}
}

play();
}

--------------------------------------------------------------------------------
--------------------------


The above Action script successfully parses the following XML:

--------------------------------------------------------------------------------
--------------------------
<graph chartType="PIE" caption="Utility Costs" xaxisname="Commodity"
yaxisname="Cost ($000's)">
<set name="Gas" value="20" link="#" />
<set name="Water" value="30" link="#" />
<set name="Steam" value="40" link="#" />
<set name="Electricity" value="50" link="#" />
<set name="Phone" value="60" link="#" />
</graph>

--------------------------------------------------------------------------------
--------------------------


However, I would like to include more information by grouping the data using
the following XML:

--------------------------------------------------------------------------------
--------------------------
<graph chartType="PIE" caption="Utility Costs" xaxisname="Commodity"
yaxisname="Cost ($000's)">
<categories>
<category name=?2004? />
<category name=?2005? />
</categories>
<dataset seriesname=?Gas? />
<set value="18" link="#" />
<set value="20" link="#" />
</dataset>
<dataset seriesname=?Water? />
<set value="27" link="#" />
<set value="30" link="#" />
</dataset>
<dataset seriesname=?Steam? />
<set value="46" link="#" />
<set value="40" link="#" />
</dataset>
<dataset seriesname=?Electricity? />
<set value="64" link="#" />
<set value="50" link="#" />
</dataset>
<dataset seriesname=?Phone? />
<set value="46" link="#" />
<set value="60" link="#" />
</dataset>
</graph>

--------------------------------------------------------------------------------
--------------------------

Can anyone help? .....
... Any help, comments or recommendations would be greatly appreciated!!!!! ...
:confused;
raja_king
6/15/2005 7:06:50 AM
Hi,
I was using the

<graph chartType="PIE" caption="Utility Costs" xaxisname="Commodity"
yaxisname="Cost ($000's)">
<categories>
<category name=?2004? />
<category name=?2005? />
</categories>
<dataset seriesname=?Gas? />
<set value="18" link="#" />
<set value="20" link="#" />
</dataset>
<dataset seriesname=?Water? />
<set value="27" link="#" />
<set value="30" link="#" />
</dataset>
<dataset seriesname=?Steam? />
<set value="46" link="#" />
<set value="40" link="#" />
</dataset>
<dataset seriesname=?Electricity? />
<set value="64" link="#" />
<set value="50" link="#" />
</dataset>
<dataset seriesname=?Phone? />
<set value="46" link="#" />
<set value="60" link="#" />
</dataset>
</graph>

----------------------------------------------------------------
and i was using the function also


But nothing has come.


Can any one send the prototype of this chart


AddThis Social Bookmark Button