This is a migrated thread and some comments may be shown as answers.

X Axis Labels

1 Answer 120 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Will asked on 21 Oct 2008, 04:02 PM

I am trying to DataBind a bar chart to a datatable.  The datatable has 6 columns and 1 row, and the 6 fields just contain numbers.  This appears to equate to 6 series.  These series are displayed in the graph correctly, however the labels I want for the 6 bars, meaning what is displayed at the bottom for each one on the X-Axis, need to be the column names.  I cant get this to work, I'm not sure what to specify for the XDatacolumn as I want column names.  At the moment, it just specifies 15 in the middle of the X axis, I'm not sure where it is getting this from

Many thanks


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Oct 2008, 10:08 AM
Hi Will,

As you have 6 chart series with a single item, the axis actually contains a single axis item that corresponds to the first (and single) value for all 6 series i.e. you cannot add 6 axis item labels in this way.

You can display 6 axis item labels only if you were visualizing a single series with 6 items (i.e. single column data and six rows). If you choose this approach, you would most probably need additional string column that holds the axis item label text values and then you can pass it to the RadChart.PlotArea.XAxis.DataLabelsColumn property:

protected void Page_Load(object sender, EventArgs e) 
    DataTable dt = new DataTable(); 
    dt.Columns.Add("Data", typeof(int)); 
    dt.Columns.Add("AxisValue", typeof(string)); 
    DataRow dr = dt.NewRow(); 
    dr[0] = 5; 
    dr[1] = "test"; 
    DataRow dr2 = dt.NewRow(); 
    dr2[0] = 3; 
    dr2[1] = "test2"; 
    RadChart1.PlotArea.XAxis.DataLabelsColumn = "AxisValue"
    RadChart1.DataManager.ValuesYColumns = new string[] { "Data" }; 
    RadChart1.DataSource = dt

Sincerely yours,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Chart (Obsolete)
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question