How to bind a xml file to Silverlight Pie Chart

3 posts, 0 answers
  1. Vinod
    Vinod avatar
    2 posts
    Member since:
    Feb 2011

    Posted 02 Feb 2011 Link to this post

         I have a requirement where i need to bind a XML file to a Silver Light Pie Chart and i should be able to configure the series also programatically based on the XML file.


  2. Vinod
    Vinod avatar
    2 posts
    Member since:
    Feb 2011

    Posted 03 Feb 2011 Link to this post

         Any updates on the thread actually it is stopping me to proceed further
  3. Missing user
    Missing user avatar

    Posted 07 Feb 2011 Link to this post

    Hello Vinod,

    You can read the XML document, retrieve the data and after that bind it to the chart by using Manual Series Mapping.

    Here is a simple XML file:

    <?xml version="1.0" encoding="utf-8" ?>
        <item Continent="Europe" Sales="26.92" />
        <item Continent="North America" Sales="17.70" />
        <item Continent="Asia" Sales="27.63" />
        <item Continent="Other" Sales="27.76" />

    and you can read it by Linq to XML

    XDocument myXML = XDocument.Load("XMLFile1.xml");
    List<SalesItem> salesList =
    (from list in myXML.Descendants("item")
    select new SalesItem()
        Continent = list.Attribute("Continent").Value,
        Sales = double.Parse(list.Attribute("Sales").Value),

    I'm using Manual Series Mapping and setting the data to the ItemSource:

    this.RadChart1.ItemsSource = salesList;

    and this is a simple example how to populate the data in Pie RadChart

    <telerik:RadChart x:Name="RadChart1">
                    <telerik:PieSeriesDefinition ItemToolTipFormat="#%{P2}">
                            <telerik:InteractivitySettings HoverScope="Item" SelectionScope="Item" SelectionMode="Single" />
                    <telerik:ItemMapping FieldName="Sales" DataPointMember="YValue" />
                    <telerik:ItemMapping FieldName="Continent" DataPointMember="LegendLabel" />

    Here you can find a demo how to populate data with Pie RadChart:
    and another examples about reading XML files:

    I hope this will help you.

    Best wishes,
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top