Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Databinding in the code behind for XamChart
posted

I am trying to create a XamChart with the following code, but cannt seem to get it to work.

System.Data.DataTable dt;

dt = new System.Data.DataTable();

dt.Columns.Add("Series Label", typeof(string));

dt.Columns.Add("Segment A", typeof(int));

dt.Columns.Add("Segment B", typeof(int));

dt.Columns.Add("Segment C", typeof(int));

dt.Columns.Add("SegmentD", typeof(int));

dt.Rows.Add(new object[ { "Stack A", 1, 4, 5, 200 });

dt.Rows.Add(new object[ { "Stack B", 2, 140, 4, 2 });

dt.Rows.Add(new object[ { "Stack C", 5, 10, 9, 15 });

dt.Rows.Add(new object[ { "Stack D", 3, 5, 5, 7 });

xamChart1.Series.Clear();

Series c = new Infragistics.Windows.Chart.Series();c.ChartType = ChartType.Stacked100Bar;for (int i = 0; i < 4; i++)

{

c = new Infragistics.Windows.Chart.Series();

c.ChartType = ChartType.Stacked100Bar;

c.DataSource = dt.Rows[i];

xamChart1.Series.Add(c);

}

Please give me some pointers to where I am going wrong. Thank you. 

 

Parents
  • 9694
    posted

    Hi,

    Either the DataTable needs to be formatted in such a way that you can assign a data mapping to the Series to communicate how to assign the data or you must explicitly create DataPoints for the XamChart and assign the data that way.

    I will add snippets for both in the following posts (to clarify the two).

    Thanks!

Reply Children