tags:

views:

322

answers:

2

Hello,

I want to create a ColumnSeries Bar Chart in WPF using C#. I shall extract the data from the database and want to bind it to the bar chart. The data extracted will contain two values. First is parameter name(string) and the other is its value(double). Which type of collection shall i use? and how to do the binding? Thanks in advance.

+1  A: 

i finally used a simple KeyValuePair array and assigned it to the ItemsSource property of the ColumnSeries of barchart.

Archie
A: 

Just use the Dictionary

how to use i will tell u

Dictionary data = new Dictionary ();

if u have a data in dataset then use foreach loop for item in the dataset

ex: foreach (DataRow drv in DS.Tables[0].Rows) { string strvalue= Convert.ToString(drv["columnname string type"]); string intvalue= Convert.ToString(drv["column name int type"]); data.Add(Convert.ToString(strvalue), Convert.ToInt32(intvalue)); }

                ((ColumnSeries)msChart3.Series[0]).ItemsSource = data;

this way u can bind data to a column series chart type..

if any problem occures feel free to ask..

regards, Kapil Vaichalkar

Kapil Vaichalkar