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

Use RadGridView as a datasource for RadChartView

1 Answer 162 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Alden
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
0
Accepted
Dimitar
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()
{
    InitializeComponent();
    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();
    radChartView1.Series.Add(lineSeria);
    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. 

Regards,
Dimitar
Telerik
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
Tags
ChartView
Asked by
Alden
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or