Stacked Bar graph labels

Thread is closed for posting
2 posts, 0 answers
  1. Arvind
    Arvind avatar
    6 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2010 Link to this post

       I have attached the screen shot.  I want to display the value 1000 according to the width of the red portion.  Is it possible to display the value (1000) on top of the horizontal stacked bar (as shown in the second example) if it does not fit inside the red portion? 

    We need to show the value inside the bar graph if it fits inside it or else it should be displayed on top of the bar.

    I have used the following code:
    radChart1.IntelligentLabelsEnabled = true;
    ChartSeries cs = new ChartSeries(); 
    cs.Items.Add(new ChartSeriesItem(1000));
    cs.Appearance.BarWidthPercent = 30;
    cs.Appearance.FillStyle.MainColor = Color.Red;
    cs.Appearance.FillStyle.SecondColor = Color.Red;
    //cs.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
    cs.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Outside;
    cs.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Green;
    cs.Type = ChartSeriesType.StackedBar100;
    ChartSeries cs1 = new ChartSeries(); 
    cs1.Items.Add(new ChartSeriesItem(9000));
    cs1.Appearance.LabelAppearance.Visible = false;
    cs1.Appearance.FillStyle.MainColor = Color.Orange;
    cs1.Appearance.FillStyle.SecondColor = Color.Orange;
    cs1.Type = ChartSeriesType.StackedBar100;
    radChart1.PlotArea.XAxis.Visible = Telerik.Charting.Styles.ChartAxisVisibility.False;
    radChart1.PlotArea.YAxis.Visible = Telerik.Charting.Styles.ChartAxisVisibility.False;
    radChart1.Legend.Visible = false;
    radChart1.ChartTitle.Visible = false;

    Arvind Robin Kumar.
  2. Ves
    Ves avatar
    2926 posts

    Posted 12 Aug 2010 Link to this post

    Hi Arvind,

    I am afraid, there is no automatic setting which would allow you to achieve such conditional label positioning.

    Still, you can control each individual label position like this:
    RadChart1.Series[0][0].Label.Appearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Outside;
    RadChart1.Series[0][0].Label.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopLeft;

    So, you can check each ChartSeriesItem's YValue and decide whether you need the label to stay inside or to move it outside the bar.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top