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

Stacked Bar graph labels

1 Answer 125 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arvind
Top achievements
Rank 1
Arvind asked on 10 Aug 2010, 08:29 AM
Hi,
   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.Series.Clear();
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;
radChart1.Series.Add(cs); 
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.Series.Add(cs1);
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;
radChart1.Update();


Regards,
Arvind Robin Kumar.

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 12 Aug 2010, 10:34 AM
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.

Regards,
Ves
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
Tags
Chart (obsolete as of Q1 2013)
Asked by
Arvind
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or