Help with SQL query to XML conversion
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Help with SQL query to XML conversion Expand / Collapse
Author
Message
Posted 4/17/2008 4:38:57 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/20/2008 1:58:54 PM
Posts: 6, Visits: 47
I have a page that is producing correct XML. If I use the page as the source, the graph doesn't render properly, but if I copy/paste the XML that that page produces to a separate XML document and use that as the source, then the graph works.

Here's my code:



protected
void Page_Load(object sender, EventArgs e)

{

DbConn1 oRs;

string strQuery;

string strXML;

strXML =
"<graph bgColor='F1f1f1' caption='Admissions' animation='1' yAxisMinValue='0' formatNumber='1' numdivlines='3' divLineColor='333333' decimalPrecision='0' showLegend='1' showColumnShadow='1' formatNumberScale='0'>";

strXML +=
"<categories font='Arial' fontsize='10' fontcolor='000000'>";

strXML +=
"<category name='Applied' hovertext='Applied' />";

strXML +=
"<category name='Admitted' hovertext='Admitted' />";

strXML +=
"<category name='Enrolled' hovertext='Enrolled' />";

strXML +=
"</categories>";

strXML +=
"<dataset seriesname= 'First-Time Students' color='FF0000'>";

strQuery =
"select * from admissions where student_type = 'First-Time Students' ";

oRs =
new DbConn1(strQuery);

//Iterate through each Record

while (oRs.ReadData.Read())

{

strXML +=
"<set value='" + oRs.ReadData["student_count"].ToString() + "' />";

}

oRs.ReadData.Close();

strXML +=
"</dataset>";

strXML +=
"<dataset seriesname= 'Transfer Students' color='009900'>";

strQuery =
"select * from admissions where student_type = 'Transfer Students' ";

DbConn1 oRs2 = new DbConn1(strQuery);

//Iterate through each Record

while (oRs2.ReadData.Read())

{

strXML +=
"<set value='" + oRs2.ReadData["student_count"].ToString() + "' />";

}

oRs2.ReadData.Close();

strXML +=
"</dataset>";

strXML +=
"</graph>";

Response.ContentType =
"text/xml";

Response.Write(strXML);

}



Produces the following XML:

- <graph bgColor="F1f1f1" caption="Admissions" animation="1" yAxisMinValue="0" formatNumber="1" numdivlines="3" divLineColor="333333" decimalPrecision="0" showLegend="1" showColumnShadow="1" formatNumberScale="0">
- <categories font="Arial" fontsize="10" fontcolor="000000">
<category name="Applied" hovertext="Applied" />
<category name="Admitted" hovertext="Admitted" />
<category name="Enrolled" hovertext="Enrolled" />
</categories>
- <dataset seriesname="First-Time Students" color="FF0000">
<set value="1103" />
<set value="912" />
<set value="443" />
</dataset>
- <dataset seriesname="Transfer Students" color="009900">
<set value="231" />
<set value="156" />
<set value="101" />
</dataset>
</graph>




Any help on where I've gone wrong would be appreciated. I figure I'm just missing something. Also, I am using the stacked column charts.
Post #5747
Posted 4/18/2008 12:57:06 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Today @ 8:30:13 AM
Posts: 92, Visits: 711
Hi musicman,
   I went through your problem. Your XML generation is ok. are you calling this page via dataURL method?
e.g

string dataURL = Server.UrlEncode("ChartXML.aspx");
Literal1.Text = FusionCharts.RenderChart("FusionCharts/FCF_MSColumn2D.swf", dataURL, "", "Chart1", "400", "400", false, false); 

If it does not work please send us the code.

Thanks,
Arindam

FusionCharts Team
www.fusioncharts.com

Post #5751
Posted 4/18/2008 8:10:42 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/20/2008 1:58:54 PM
Posts: 6, Visits: 47
I'm calling it using the following code:

<%

string strDataURL3;

strDataURL3 = "admissiondata.aspx";

Response.Write(FusionCharts.RenderChart("FusionCharts/FCF_StackedColumn3D.swf", strDataURL3, "", "Admissions3", "425", "300", false, false));

%>

Tried what you posted and get the following error:

CS0103: The name 'Literal1' does not exist in the current context

Post #5764
Posted 4/18/2008 8:42:50 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Today @ 8:30:13 AM
Posts: 92, Visits: 711
Hi musicman,

Please use with in method on script section , after that call it.

public void CallFusionChart()

{

string strDataURL3;

strDataURL3 = "admissiondata.aspx";

Response.Write(FusionCharts.RenderChart("FusionCharts/FCF_StackedColumn3D.swf", strDataURL3, "", "Admissions3", "425", "300", false, false));

}

and call it

<% CallFusionChart(); %>



Thanks,
Arindam

FusionCharts Team
www.fusioncharts.com

Post #5766
Posted 4/18/2008 9:18:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/20/2008 1:58:54 PM
Posts: 6, Visits: 47
Still no luck. I've attached what the chart looks like that is being produced. As well as the correct chart, which is being produced by the xml I pasted into a new document.

  Post Attachments 
chart.jpg (9 views, 50.31 KB)
chart-correct.jpg (7 views, 47.58 KB)
Post #5769
Posted 4/19/2008 1:10:30 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Today @ 1:21:47 AM
Posts: 675, Visits: 1,079
Hi,

Could you please check once again whether the values are coming zero or not from the XML?

The chart would show this when the values are zero or not numbers.

Regards,

Sudipto Choudhury
FusionCharts Team

Post #5778
Posted 4/21/2008 10:28:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/20/2008 1:58:54 PM
Posts: 6, Visits: 47
The xml that is being produced is correct, no zeros or non-numbers. As I stated before if I use the aspx page as the source, my chart is incorrect, but if I take the xml that is produced by the aspx page and copy/paste it into an xml document and use that as the source then the chart is correct.

I've attached the data aspx page as well as the data xml document.

This produces an incorrect graph:

<%

string strDataURL;
strDataURL3 = "admissiondata.aspx";
Response.Write(FusionCharts.RenderChart("FusionCharts/FCF_StackedColumn3D.swf", strDataURL3, "", "Admissions1", "425", "300", false, false));

%>

This does not:

<%

string strDataURL2;
strDataURL2 = "admissions.xml";
Response.Write(FusionCharts.RenderChart("FusionCharts/FCF_MSColumn3D.swf", strDataURL2, "", "Admissions2", "425", "300", false, false));

%>

Both contain or output the same exact xml data.




  Post Attachments