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

Use RadGridView as a datasource for RadChartView

1 Answer 136 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Alden asked on 23 Nov 2015, 07:30 AM

I constructed a RadGridView and would like to use its content for my RadChartView to create a pie chart, but so far nothing shows up.

For RadGridView I would have five columns.

Name     Count     C     D     E

 Germany  20

France      50

I would only use the "Name" and Count" column to construct my pie chart but not "C", "D", and "E" columns, so it would be a percentage chart with Germany 20/70 and France 50/70. How do I use these two columns of the RadGridView for my RadChartView?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 23 Nov 2015, 03:07 PM
Hello Alden,

Thank you for writing.

You can bind the controls to the same table, you only need to specify the ValueMember of the series:
DataTable table;
public RadForm1()
    table = new DataTable();
    table.Columns.Add("Value", typeof(double));
    table.Columns.Add("Name", typeof(string));
    table.Rows.Add(1, "John");
    table.Rows.Add(3, "Adam");
    table.Rows.Add(5, "Peter");
    table.Rows.Add(12, "Sam");
    table.Rows.Add(6, "Paul");
    radGridView1.DataSource = table;
    radChartView1.AreaType = ChartAreaType.Pie;
    PieSeries lineSeria = new PieSeries();
    lineSeria.ShowLabels = true;
    lineSeria.DataSource = table;
    lineSeria.ValueMember = "Value";
    lineSeria.LegendTitleMember = "Name";
    radChartView1.ShowLegend = true;

Please let me know if there is something else I can help you with. 

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question