I am trying to create a column chart. I am building a datatable with several columns in it and I need to pick the column that will be represented along the X-axis. I can bind to my dataview with no problem, but I can't figure out how to show a column other than the first column in the datatable along the x-axis. How do I do that in code?
Hello Rehemann,
There are different approaches to solve this task. Maybe one possible solution could be if you are using DataBind method of your series. For example:
// DataSource
DataTable dt = new DataTable();
dt.Columns.Add("Items", typeof(string));
dt.Columns.Add("Miles Column", typeof(decimal));
dt.Columns.Add("Fillups Column", typeof(decimal));
NumericSeries columnSeries = new NumericSeries();
columnSeries.DataBind(dt,"Miles Column", "Items");
columnSeries.PEs.Add(new PaintElement(Color.Gold));
columnSeries.Label ="Miles [nm]";
Please take a look at the attached sample for more details and if you have any questions, feel free to write me
Regards
Please take a look at the attached picture. My data is represented correctly. The problem is that the labels along the X-axis are for the wrong column in my data table. 3145 is an autonumber field in my table and happens to be the first column in the table. I really want to display a customer name column instead. How do I pick another column in my bound datatable to be represented as the label? I cannot alter the structure of the table.
This is the sample