This is a migrated thread and some comments may be shown as answers.

How can I build a Pie Chart

11 Answers 306 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Anoop
Top achievements
Rank 1
Anoop asked on 08 Mar 2011, 11:09 AM
How can I build a best Pie Chart to retrieve my database data?

Thanks in advance

11 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Mar 2011, 09:53 PM
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!
0
Anoop
Top achievements
Rank 1
answered on 13 Mar 2011, 09:19 AM

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

How can I resolve that?

0
Anoop
Top achievements
Rank 1
answered on 13 Mar 2011, 09:23 AM
Also when I tried to use the suggested code I got the attached error?
0
Yavor
Telerik team
answered on 16 Mar 2011, 11:06 AM
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!
0
Anoop
Top achievements
Rank 1
answered on 04 Aug 2011, 06:01 AM
Hi

How can I bind the data to sql?



Thanks in advance
0
Evgenia
Telerik team
answered on 08 Aug 2011, 03:41 PM
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 >>
0
Anoop
Top achievements
Rank 1
answered on 09 Aug 2011, 07:45 AM

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

 

Thanks in advance

0
Anoop
Top achievements
Rank 1
answered on 11 Aug 2011, 08:28 AM
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

0
Evgenia
Telerik team
answered on 11 Aug 2011, 03:52 PM
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 >>
0
Anoop
Top achievements
Rank 1
answered on 23 Aug 2011, 08:57 AM

Do you have any  sample to bind to DataTable?

 

Thanks in advance

0
Evgenia
Telerik team
answered on 25 Aug 2011, 04:16 PM
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 >>

Tags
Chart
Asked by
Anoop
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Anoop
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or