How can I build a Pie Chart

12 posts, 0 answers
  1. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 08 Mar 2011 Link to this post

    How can I build a best Pie Chart to retrieve my database data?

    Thanks in advance
  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 10 Mar 2011 Link to this post

    Hi Anoop,

    You can retrieve data from database using a technology of your choice (like Ado.NET, Linq to SQL, Entity Framework, etc.) and store this data in objects. Then you can bind your RadChart to the collection of these objects and set the SeriesMapping accordingly.

    Here is an example:

    Imagine that you have retrieved data from your database. Your class has one property that is called Quantity.

    <telerik:RadChart x:Name="radChart">
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping LegendLabel="Product Sales">
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:PieSeriesDefinition />
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Quantity" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>

    This markup will create a pie chart that binds to the Quantity property of your class.

    You can read more on how to databind RadChart in this topic in the online help system.


    Kind regards,
    Yavor Ivanov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 13 Mar 2011 Link to this post

    When I try to add a chart from the toolbox
    I got the attached window?

    How can I resolve that?

  5. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 13 Mar 2011 Link to this post

    Also when I tried to use the suggested code I got the attached error?
  6. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 16 Mar 2011 Link to this post

    Hi Anoop,

    If you are using local libs and not from GAC you can try deleting local libs and using only those from GAC. Try clean / rebuild and see if you still get this error.

    You can also find additional information in a similar thread in our forum here.

    Hope this helps!

    All the best,
    Yavor Ivanov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 04 Aug 2011 Link to this post

    Hi

    How can I bind the data to sql?



    Thanks in advance
  8. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 08 Aug 2011 Link to this post

    Hi Anoop,

    I suggest that you follow our help topic and use ADO.NET Data Service to bind the Chart to an SQL database as Northwind for example. Feel free to modify the code snippets so that they meet your requirements.

    Greetings,
    Evgenia
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  9. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 09 Aug 2011 Link to this post

    Is there is any other direct way instead of using services and reference?

     

    Thanks in advance

  10. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 11 Aug 2011 Link to this post

    Hi,

    Can’t we use sqldatasource and connection String is it possible or no way rather than using services.

     

    I need wpf chart for desktop application

  11. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 11 Aug 2011 Link to this post

    Hello Anoop,

    I believe you understand that consuming data from SQL database is beyond the support scope of our controls. We can guide you to our help topics or demos where there are samples using different approaches but it's up to you to choose how you will do it. Here you may find helpful information how to populate RadControls with data. You may also take a look at our RadChart documentation where we demonstrated how to bind RadChart to Northwind sample database using WCF service or ADO.NET Data Service.

    Regards,
    Evgenia
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  12. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 23 Aug 2011 Link to this post

    Do you have any  sample to bind to DataTable?

     

    Thanks in advance

  13. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 25 Aug 2011 Link to this post

    Hi Anoop,

    The way you bind RadChart to DataTable is the same as you would bind it to List of Business objects. Here is an example:

    InitializeComponent();
             DataTable table = new DataTable();
             table.Columns.Add(new DataColumn("Name1", typeof(string)));
             table.Columns.Add(new DataColumn("Value1", typeof(int)));
             table.Columns.Add(new DataColumn("Name2", typeof(string)));
             table.Columns.Add(new DataColumn("Value2", typeof(int)));
             table.Rows.Add(new object[] { "C1", 12, "C24", 30 });
             table.Rows.Add(new object[] { "C2", 14, "Dist", 90 });
             table.Rows.Add(new object[] { "C12", 25, "site", 24 });
             DataSeries chartSeries1 = new DataSeries();
             radChart1.ItemsSource = table;
     
    Regards,
    Evgenia
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
UI for WPF is Visual Studio 2017 Ready