I have a DataTable that I am trying to filter to display multiple pie charts from one set. I am able to filter my data using a DataView but once the data is assigned to the Chart, I want to remove the filtered column from the bound fields. I want to do this because the filtered data is being used as labels when I want other fields from the dataview.
In my sample code below. I want to remove the "REGION" column so that my labels are pulled from the "TYPE" column. If I try to do this by removing the REGION from usage, the chart displays no data. How can I do this? Is there a completely different approach to doing this in the chart? I know i can do this my manually building a new Data Table that doesnt contain the "REGION" column, but it looks like the chart should be able to exclude the column for me.
Thanks - Eric Smith
[replace page_load of a blank aspx page to run the code]
protected void Page_Load(object sender, EventArgs e) { ChartFX.WebForms.Chart cht = new ChartFX.WebForms.Chart(); cht.Gallery = ChartFX.WebForms.Gallery.Pie; System.Data.DataTable dt = new DataTable(); dt.Columns.Add("REGION", System.Type.GetType("System.String")); dt.Columns.Add("TYPE", System.Type.GetType("System.String")); dt.Columns.Add("PCT", System.Type.GetType("System.Int16")); dt.Rows.Add(new object[] { "R1", "O", 20 }); dt.Rows.Add(new object[] { "R1", "W", 80 }); dt.Rows.Add(new object[] { "R2", "O", 50 }); dt.Rows.Add(new object[] { "R2", "W", 50 }); //cht.DataSourceSettings.Fields.Add(new ChartFX.WebForms.FieldMap("REGION", ChartFX.WebForms.FieldUsage.NotUsed)); cht.DataSource = new System.Data.DataView(dt, "REGION='R1'", "", DataViewRowState.CurrentRows); form1.Controls.Add(cht); }