Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Hi guys,

I'm working on fusion charts in my asp.net page using c#.

n

i have gone through with its documentation as well.

i'm tried hard from the hours, but getting invalid xml to generate fusion charts.

i'm getting this xml, plz check it, if its some where wrong plzzz let me know.

The link in the chart is making the problem,
if i remove the link then this code is working fine....


<chart caption='NATIONAL PETROLEUM SERVICES' palette='1' animation='1' formatNumberScale='0' startingAngle='125' baseFontSize='15' baseFontBold='1' labelDisplay='rotate'>
<categories>
<category label='40-301' UnitID='20' />
<category label='40-303' UnitID='21' />
<category label='40-305' UnitID='13' />
<set value='' color='#00FF00' />
<set value='4' color='#00FF00' link='EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303' />
/></categories><dataset seriesName='Active'><set value='' color='#00FF00' /><set value='4' color='#00FF00' link='EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303' />
<set value='' color='#00FF00' />
<set value='' color='#00FF00' />
<set value='' color='#00FF00' />
<set value='' color='#00FF00' />
<set value='' color='#00FF00' />
</dataset>
</chart>


c# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using DataAccessLayer;

namespace NPSDashboard
{
    public partial class TruckPieChartData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Generate_chart();
        }

        protected void Generate_chart()
        {
            XmlDocument XDoc = new XmlDocument();

            XmlDocument Chart = new XmlDocument();
            Chart.LoadXml("<chart />");
            Chart.DocumentElement.SetAttribute("caption", "NATIONAL PETROLEUM SERVICES");
            Chart.DocumentElement.SetAttribute("palette", "2");
            Chart.DocumentElement.SetAttribute("animation", "1");
            Chart.DocumentElement.SetAttribute("formatNumberScale", "0");
            //Chart.DocumentElement.SetAttribute("numberPrefix", "$");
            Chart.DocumentElement.SetAttribute("pieSliceDepth", "30");
            Chart.DocumentElement.SetAttribute("startingAngle", "125");
            Chart.DocumentElement.SetAttribute("showValues", "0");

            XmlDocument LossTimeXml = new XmlDocument();
            XmlDocument TotalTimeXml = new XmlDocument();

            //string fmdt = Request.QueryString["FromDate"].ToString();
            //string tdt = Request.QueryString["ToDate"].ToString();
            //string did = Request.QueryString["did"].ToString();


            double lt, tt, result;

            string st = DAL.GenericSP_Str(2, "Sp_GetTruckTrackingPieChart", "<Root FromDate=\"" + Request.QueryString["FromDate"] + "\" Todate=\"" + Request.QueryString["ToDate"] + "\" />");

            LossTimeXml.LoadXml(st);

            string slt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("value"));
            string stt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("TotalVehicles"));

            lt = Convert.ToDouble(slt);
            tt = Convert.ToDouble(stt);

            result = (lt / tt) * 100;

            XmlElement ActiveElement = Chart.CreateElement("set");
            ActiveElement.SetAttribute("label", "Active" + "(" + lt + ")" + "[" + Math.Round(result, 2) + "% ]");
            ActiveElement.SetAttribute("value", Math.Round(result, 2).ToString());
            ActiveElement.SetAttribute("link", "P-detailsPopUp,width=800,height=550,toolbar=no,scrollbars=no,resizable=no-TruckDailyChart.aspx?FromDate=" + Request.QueryString["FromDate"] + "&ToDate=" + Request.QueryString["ToDate"] + "&Status=" + "1" + "&label=Active");


            Chart.DocumentElement.AppendChild(ActiveElement);

            TotalTimeXml.LoadXml(DAL.GenericSP_Str(2, "Sp_GetTruckTrackingPieChartInActive", "<Root FromDate=\"" + Request.QueryString["FromDate"] + "\" Todate=\"" + Request.QueryString["ToDate"] + "\" />"));

            lt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("value"));
            tt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("TotalVehicles"));

            result = (lt / tt) * 100;

            XmlElement InActiveElement = Chart.CreateElement("set");
            InActiveElement.SetAttribute("label", "InActive" + "(" + lt + ")" + "[" + Math.Round(result, 2) + "% ]");
            InActiveElement.SetAttribute("value", Math.Round(result, 2).ToString());
            InActiveElement.SetAttribute("link", "P-detailsPopUp,width=800,height=550,toolbar=no,scrollbars=no,resizable=no-TruckDailyChart.aspx?FromDate=" + Request.QueryString["FromDate"] + "&ToDate=" + Request.QueryString["ToDate"] + "&Status=" + "2" + "&label=InActive");

            Chart.DocumentElement.AppendChild(InActiveElement);


            XmlElement Style = Chart.CreateElement("styles");
            XmlElement definition = Chart.CreateElement("definition");
            Style.AppendChild(definition);

            XmlElement style1 = Chart.CreateElement("style");
            style1.SetAttribute("type", "font");
            style1.SetAttribute("name", "CaptionFont");
            style1.SetAttribute("size", "15");
            style1.SetAttribute("color", "666666");

            XmlElement style2 = Chart.CreateElement("style");
            style2.SetAttribute("type", "font");
            style2.SetAttribute("name", "SubCaptionFont");
            style2.SetAttribute("bold", "1");

            definition.AppendChild(style1);
            definition.AppendChild(style2);

            XmlElement application = Chart.CreateElement("application");
            Style.AppendChild(application);

            XmlElement apply1 = Chart.CreateElement("style");
            apply1.SetAttribute("toObject", "caption");
            apply1.SetAttribute("styles", "CaptionFont");

            XmlElement apply2 = Chart.CreateElement("style");
            apply2.SetAttribute("toObject", "SubCaption");
            apply2.SetAttribute("styles", "SubCaptionFont");


            application.AppendChild(apply1);
            application.AppendChild(apply2);
            Chart.DocumentElement.AppendChild(Style);

            Response.Write(Chart.OuterXml);

        }
    }
}



i'm getting error in this code:
string Para = "EquipmentID=" + ((XmlElement)CategoryLst[j]).GetAttribute("UnitID");
                                Para = Para + "&Section=" + section;
                                Para = Para + "&StartDate=" + FromDate;
                                Para = Para + "&EndDate=" + ToDate;
                                Para = Para + "&Status=" + (i + 1).ToString();
                                Para = Para + "&label=" + ((XmlElement)CategoryLst[j]).GetAttribute("label");
SetElement.SetAttribute("link", "EquipmentInActive.aspx?" + Para);//Error on this line


plzzz help me.

thanks
Posted
Updated 4-Jun-14 6:46am
v4

1 solution

link='EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303' />
& is an illegal character in the xml.
Use &amp; instead.
 
Share this answer
 
v2
Comments
abdul subhan mohammed 3-Jun-14 16:29pm    
its showing d same error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900