Question to labels in bar series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Thomas
Newbie
Newbie
Posts: 7
Joined: Mon Dec 04, 2006 12:00 am

Question to labels in bar series

Post by Thomas » Thu Feb 22, 2007 8:01 am

Hi,

I would like to add a label to each bar in multiple bar series. I use custom AxesLabelItems with the same x-value of the bar. If a bar of another series have the same x-value, the label of the previous bar will overlaped.

Example code:

Chart1.Axes.Bottom.Labels.Angle = 90;

Bar bar1 = new Bar(Chart1);
bar1.MultiBar = Multibars.Side;
bar1.Add(1, 0.6);
bar1.Add(2, 0.7);
bar1.Add(3, 0.9);

AxisItemLabel lbl1 = new AxisItemLabel(Chart1);
lbl1.Transparent = true;
lbl1.Value = 1;
lbl1.Text = "Bar 1 - Label 1";

bar1.Labels.Items.Add(lbl1);

Bar bar2 = new Bar(Chart1);
bar2.MultiBar = Multibars.Side;
bar2.Add(1, 0.3);
bar2.Add(2, 0.5);
bar2.Add(3, 0.4);

AxisItemLabel lbl2 = new AxisItemLabel(Chart1);
lbl2.Transparent = true;
lbl2.Value = 1;
lbl2.Text = "Bar2 - Label 2";

bar2.Labels.Items.Add(lbl2);


In this case the label of bar2 series overlapped the label of bar1. How can I place the labels exactly below the bars?

Thanks in advance,
Thomas

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Feb 22, 2007 9:23 am

Hi Thomas

We don't understand what are you trying to achieve here.

Our fist suggestion would be that you used default series marks and added marks content in one of the Add method's overrides that allow adding a label for each point. Otherwise, by default, Y values would be displayed in series marks. Even this can be changed using bar1.Marks.Style property. Below there's an example of this.

Code: Select all

            tChart1.Axes.Bottom.Labels.Angle = 90;

            Bar bar1 = new Bar(tChart1.Chart);
            bar1.MultiBar = MultiBars.Side;
            bar1.Add(1, 0.6,"myLabel1"); //Add a value and Label
            bar1.Add(2, 0.7,"myLabel2");
            bar1.Add(3, 0.9,"myLabel3");
            bar1.Marks.Visible = true;
            
            Bar bar2 = new Bar(tChart1.Chart);
            bar2.MultiBar = MultiBars.Side;
            bar2.Add(1, 0.3,"myLabel4");
            bar2.Add(2, 0.5,"myLabel5");
            bar2.Add(3, 0.4,"myLabel6"); 
            bar2.Marks.Visible = true;
On the other hand, if you are interested in setting custom axis labels you may be interested in checking the "What's New?\Welcome!\Axes\Labels\Custom labels" example at the features demo. You'll find the demo at TeeChart's program group.

If that's your case and your custom labels overlap, you'll find more information about how to prevent this at this post.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Thomas
Newbie
Newbie
Posts: 7
Joined: Mon Dec 04, 2006 12:00 am

Post by Thomas » Thu Feb 22, 2007 9:42 am

Hi,

yes, I use default series marks. I already tried this code you posted, the result is, that I see both bars on each x position, but only the label "myLabel1" will displayed instead of "myLabel1" and "myLabel4"...

Greetings,
Thomas

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Feb 22, 2007 10:02 am

Hi Thomas

Text for axis labels is taken from first series in the chart. To achieve what you request you should use "custom axis labels" as told in my previous message.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Thomas
Newbie
Newbie
Posts: 7
Joined: Mon Dec 04, 2006 12:00 am

Post by Thomas » Thu Feb 22, 2007 12:37 pm

For this reason I used AxisLabelItems, but I could'nt find out how I can place the "myLabel4" on the right side of "myLabel1".

Can you send me please a piece of code which shows how I can compute programmatically the value of the "myLabel4"-label ?

Thanks,
Thomas

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Feb 22, 2007 3:48 pm

Hi Thomas,

Please have a look at the message Edu pointed in his first reply. This message contains several ideas on how to deal with custom labels and their positions in the chart. Please notice that this thread has several pages and what are you interested in may be in the last pages.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply