StackedBar - Y Axis value

Thread is closed for posting
2 posts, 0 answers
  1. Chris
    Chris avatar
    17 posts
    Member since:
    Oct 2010

    Posted 22 Aug 2012 Link to this post


    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());
  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 27 Aug 2012 Link to this post

    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.
Back to Top