Urgent-Bind Pie chart from datatable

Apr 17, 2012 at 11:41 AM

Hi,

 

I found this Highchart very useful.

I want to bind Pie chart from datatable.

Please help me out, urgently required.

 

Thank in advance

Vijay

Developer
Apr 17, 2012 at 1:52 PM
Edited Apr 17, 2012 at 4:23 PM

Use something like the following:

SerieCollection coll = new SerieCollection ();

foreach row in DataTable
{
  coll.Add(new Serie(){ name = row["serieTitle"].tostring(), data = new object[] {row["data"].tostring()});
}

The above is only pseudocode. But let me know if you have some more problems.

Apr 18, 2012 at 5:24 AM

Hi testmyo,

 

Can you pls provide the code as i have a datatable with two columns "Name" and "Age".

I want to bind these things to a pie chart.

 

Thanks in advance

Vijay

May 16, 2012 at 10:46 PM

Here is what I did. Probably not perfect, but works.

        var series = new Collection<Serie>();
                series.Add(new Serie
                {
                    size = 130,
                    data = new object[10]
                });
                for (var i = 0; i < dt.Rows.Count; i += 1)
                {
                    series[0].data[i] = new object[] { dt.Rows[i][0], dt.Rows[i][2] };
                }
                Array.Resize(ref series[0].data, dt.Rows.Count);