Jump to content
Software FX Community

Loading data from XML


User (Legacy)

Recommended Posts

Hi,

I'm trying to load data into a chart using XML.

SoftwareFX.ChartFX.Internet.Server.Chart chart1 = new

SoftwareFX.ChartFX.Internet.Server.Chart(this);

SoftwareFX.ChartFX.Data.XmlDataProvider cfxXML = new

SoftwareFX.ChartFX.Data.XmlDataProvider();

cfxXML.Load(Server.MapPath(null) + "\\ChartData2.xml");

chart1.DataSourceSettings.DataSource = cfxXML;

I used the shipped sample XML file as a guideline, producing

<?xml version="1.0"?>

<Site>

<COLUMNS>

<COLUMN NAME="Q1" TYPE="Integer" DESCRIPTION="App A"/>

<COLUMN NAME="Q2" TYPE="Integer" DESCRIPTION="App B"/>

</COLUMNS>

<ROW product="Site 1" Q1="9200" Q2="7835"/>

<ROW Product="Site 2" Q1="14350" Q2="11233"/>

</Site>

In the XML I want to import:

. AxisX label and KeyLabel values (similar to calling the following

programatically)

o chart1.AxisX.Label[0] = "ProductID 1";

o chart1.AxisX.KeyLabel[0] = "13987";

. TagString for each series: similar to calling

o chart1.Point[0, 0].Tag = "Tagstring-0-0";

o chart1.Point[0, 1].Tag = "Tagstring-0-1";

. Series Legend with a different value than the description attached to each

column: similar to calling

o chart1.SerLeg[0] = "Product A"

o chart1.SerLeg[1] = "Product B";

By adding these equivalent method calls in code, I was able to generate the

following XML, but when I import it, the labels etc., don't appear. Is

there a particular sequence of XML events required? Any detailed document

describing the import XML requirements would be appreciated.

I could write code to parse the XML doc manually and loop through the set

the values programmatically, but I'd prefer not opening the document up in

the DOM to do such parsing.

<AXIS>

<ITEM index="0">

<GRIDLINES>True</GRIDLINES>

</ITEM>

<ITEM index="2">

<STYLE>Notify, Default</STYLE>

<NOTIFY>True</NOTIFY>

<MINORTICKMARK>Cross</MINORTICKMARK>

<LABELLIST>

<ITEM>

ProductID 1

</ITEM>

<ITEM>

ProductID 2

</ITEM>

</LABELLIST>

<KEYLIST>

<ITEM>

13987

</ITEM>

<ITEM>

45787

</ITEM>

</KEYLIST>

</ITEM>

</AXIS>

<POINT>

<ITEM series="1" point="0">

<TAG>Tagstring-1-0</TAG>

</ITEM>

<ITEM series="1" point="1">

<TAG>Tagstring-1-1</TAG>

</ITEM>

<ITEM series="0" point="1">

<TAG>Tagstring-0-1</TAG>

</ITEM>

<ITEM series="0" point="0">

<TAG>Tagstring-0-0</TAG>

</ITEM>

</POINT>

<SERLEG>

<ITEM>

Product A

</ITEM>

<ITEM>

Product B

</ITEM>

</SERLEG>

<SERLEGBOXOBJ>

<WIDTH>0</WIDTH>

<HEIGHT>0</HEIGHT>

<FONT>

<SIZE>6</SIZE>

</FONT>

</SERLEGBOXOBJ>

Any help would be appreciated.

Thanks in advance.

Declan

Link to comment
Share on other sites

1) You did not define a column for Product, something like:

<COLUMN NAME="Product" TYPE="String" DESCRIPTION="Product Name"/>

2) Where are KeyLabels like "13987" suppose to come from ? Maybe you need to

add another column and use the DataType property to make it go into the Key

legends.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

re 1) The series "product" wasnt declared in the column section as the info

wasnt't required, sorry about this.

2) The KeyLabel and Label values (along with the series data) will come from

our database that one of our assemblies will gerenate query and then create

an XML file. What should an XML file lookup like in order for these values

and display in the chart. We need the label info and keylabel values to

display meaningful text to the user, but in the back ground use the other

value when a drill down occurs to load a new graph with the selected values.

Regards,

Dec.

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:wm1AG6RdCHA.2308@webserver1.softwarefx.com...

> 1) You did not define a column for Product, something like:

>

> <COLUMN NAME="Product" TYPE="String" DESCRIPTION="Product Name"/>

>

> 2) Where are KeyLabels like "13987" suppose to come from ? Maybe you need

to

> add another column and use the DataType property to make it go into the

Key

> legends.

>

> --

> FP

> Software FX, Inc.

>

>

Link to comment
Share on other sites

We've decided to populate each row with the extra required information and

then let the chart load as much XML as possible using the LoadXml method.

The remaining "extra information" is loaded into the DOM and then loop thru

each nodelist and sets chart tag, series methods accordingly.

These sequence of events might be useful to someone.

(XML with extra info

S0 - S4 are descriptions for each series (which may differ per row)

LabelList is the background ID and Keylist is the UI (X-Axis) description)

<ROW Q1="3550" Q2="19068" Q3="2168" Q4="10682" Q5="128" S0="Series Va 1"

S1="Series Va 2" S2="Series Val 3" S3="Series Va 4" S4="Series Va 5"

LabelList="111" KeyList="Site 21"/>

(Using assembly (xmlB) to load XML doc into DOM, XML generated in another

assembly by querying db)

//Get Columns count

XmlNodeList nListCoulmn = xmlB.GetNodeList("/Site/COLUMNS/COLUMN");

int count = nListCoulmn.Count;

//Get Rows

XmlNodeList nList = xmlB.GetNodeList("/Site/ROW");

int index =0;

string seriesLookup;

//For Each Row

foreach ( XmlNode Param in nList)

{

//Get the label (used as the X-Axis value)

chart1.AxisX.Label[index] = Param.Attributes["LabelList"].Value;

//Get the keyList (used as the behind the scenes ID )

chart1.AxisX.KeyLabel[index] = Param.Attributes["KeyList"].Value;

//Get each series value and set as a tag.

for (int i=0; i < count; i++)

{

seriesLookup = "S"+ i.ToString();

chart1.Point[i, index].Tag = Param.Attributes[seriesLookup].Value;

}

//Move on to the next node row.

index++;

}

Regards,

Dec.

"Declan O'Leary" <declanol@hotmail.com> wrote in message

news:CKJFQKSdCHA.2308@webserver1.softwarefx.com...

> re 1) The series "product" wasnt declared in the column section as the

info

> wasnt't required, sorry about this.

>

> 2) The KeyLabel and Label values (along with the series data) will come

from

> our database that one of our assemblies will gerenate query and then

create

> an XML file. What should an XML file lookup like in order for these

values

> and display in the chart. We need the label info and keylabel values to

> display meaningful text to the user, but in the back ground use the other

> value when a drill down occurs to load a new graph with the selected

values.

>

> Regards,

> Dec.

>

>

> "SoftwareFX Support" <support@softwarefx.com> wrote in message

> news:wm1AG6RdCHA.2308@webserver1.softwarefx.com...

> > 1) You did not define a column for Product, something like:

> >

> > <COLUMN NAME="Product" TYPE="String" DESCRIPTION="Product Name"/>

> >

> > 2) Where are KeyLabels like "13987" suppose to come from ? Maybe you

need

> to

> > add another column and use the DataType property to make it go into the

> Key

> > legends.

> >

> > --

> > FP

> > Software FX, Inc.

> >

> >

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...