Hello Ashim,
Have in mind that when grouping is applied for series, the XValue of each SeriesItem will be respected (if no XValue is set -- the items will be added consecutively). Setting
DataLabelsColumn property to the XAxis provides labels for each of the XAxis Items but that has nothing in common with their XValue-s. Take a look at the following code snippet that demonstrates how to achieve your scenario:
DataTable tbl = new DataTable();
DataColumn col = new DataColumn("totalFaxes");
col.DataType = typeof(int);
tbl.Columns.Add(col);
col = new DataColumn("facilityName");
col.DataType = typeof(string);
tbl.Columns.Add(col);
col = new DataColumn("Hour");
col.DataType = typeof(double);
tbl.Columns.Add(col);
tbl.Rows.Add(new object[] { 100, "Fac1", 1 });
tbl.Rows.Add(new object[] { 20, "Fac1", 2 });
tbl.Rows.Add(new object[] { 20, "Fac1", 4 });
tbl.Rows.Add(new object[] { 20, "Fac1", 5 });
tbl.Rows.Add(new object[] { 35, "Fac2", 2 });
tbl.Rows.Add(new object[] { 35, "Fac2", 3 });
tbl.Rows.Add(new object[] { 35, "Fac2", 4 });
RadChart1.DataManager.ValuesYColumns = new string[1] { "totalFaxes" };
RadChart1.DataManager.ValuesXColumn = "Hour";
RadChart1.DataGroupColumn = "facilityName";
RadChart1.DefaultType = ChartSeriesType.StackedBar;
RadChart1.DataSource = tbl;
RadChart1.DataBind();
RadChart1.PlotArea.XAxis.AutoScale = false;
RadChart1.PlotArea.XAxis.AddRange(1, 5, 1);
string[] labels = new string[] { "Toyota", "Mazda", "Mini", "Opel", "Renault"};
for (int i = 0; i < RadChart1.PlotArea.XAxis.Items.Count; i++)
{
RadChart1.PlotArea.XAxis.Items[i].TextBlock.Text = labels[i];
}
The
ValuesXColumn predefines the XValue of each SeriesItem. Also after the Chart is databound there are new custom labels set for each of the Axis Items.
Greetings,
Evgenia
the Telerik team