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

StackedBar - Y Axis value

1 Answer 15 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 22 Aug 2012, 10:02 PM
Hi,

I am creating a StackedBar chart from the code behind, where each item on the Y axis is the name of a Customer, and the X values are the amount of invoices completed/outstanding today. Please see the attached screenshot for an example.

It's working well, except the labels for each item on the Y axis is a meaningless number (1-5). How can I get the label to be 'Name' property of each item?

Thanks - the code is below

IEnumerable<Invoice> invs = Invoice.GetTestInvoices(100);
var s = from i in invs
     group i by i.Name;
 
ChartSeries chtOutstanding = new ChartSeries("Outstanding", ChartSeriesType.StackedBar);
ChartSeries chtCompleted = new ChartSeries("Completed", ChartSeriesType.StackedBar);
chtOutstanding.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
chtCompleted.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
foreach (var item in s.OrderBy(a => a.Key))
{
    chtCompleted.AddItem(item.Where(a => a.Status == 1).Count());
    chtOutstanding.AddItem(item.Where(a => a.Status != 1).Count());
}
 
RadChart1.Series.Add(chtOutstanding);
RadChart1.Series.Add(chtCompleted);

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 27 Aug 2012, 09:04 AM
Hello Chris,

I think that you are only missing the setting for the labels of the axis:
this.RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name";

All the best,
Petar Marchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
Chris
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or