A question about custom label.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

A question about custom label.

Post by sswang » Fri May 04, 2012 1:50 am

Dear Steema Support,

I am using the following code to customize bottom axis labels:

AHost.BottomAxis.Items.Add(0, '9:00');
AHost.BottomAxis.Items.Add(60, '10:00');
AHost.BottomAxis.Items.Add(120, '11:00');
AHost.BottomAxis.Items.Add(180, '12:00');
AHost.BottomAxis.Items.Add(240, '13:00');

But after that, the added labels lose the ability to avoid overlapping to each other when the display area is crowded (by automatically setting itself's visibility to false). What can I do about it? thanks.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: A question about custom label.

Post by Sandra » Fri May 04, 2012 10:56 am

Hello sswang,

I suggest you three different options:

First: You can do something as next code without custom labels and using DateTimeStep to define increment.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var Series1:TAreaSeries;
begin
    Series1 := TAreaSeries.Create(self);
    Chart1.AddSeries(Series1);
    Chart1.Align := alClient;
    Series1.XValues.DateTime:=True;
    Series1.AddXY(EncodeTime(9,00,00,00),100);
    Series1.AddXY(EncodeTime(10,00,00,00),99);
    Series1.AddXY(EncodeTime(11,00,00,00),200);
    Series1.AddXY(EncodeTime(12,00,00,00),150);
    Series1.AddXY(EncodeTime(13,00,00,00),189);
    Chart1.Axes.Bottom.DateTimeFormat:= 'hh:mm';
    Chart1.Axes.Bottom.Increment:=  DateTimeStep[dtOneHour];
Second: Use property increment to increment bottom axis to 60 as do in next line of code:

Code: Select all

Chart1.Axes.Bottom.Increment:=60;
Third: Use custom labels and control the overlap manually.
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

Re: A question about custom label.

Post by sswang » Tue May 08, 2012 7:55 am

Hi,
Thanks, I think I've got a clue...now I wonder how to use your first suggested approach without inserting visible Y values?
I mean if there is actually no data on 10 o'clock, how to make sure that the "10:00" tick and label will still be there on X-axis? Thanks again.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: A question about custom label.

Post by Yeray » Thu May 10, 2012 3:00 pm

Hi,
sswang wrote:Thanks, I think I've got a clue...now I wonder how to use your first suggested approach without inserting visible Y values?
I mean if there is actually no data on 10 o'clock, how to make sure that the "10:00" tick and label will still be there on X-axis? Thanks again.
I'm not sure to understand you. If I comment the following line in Sandra's code above

Code: Select all

//    Series1.AddXY(EncodeTime(10,00,00,00),99);
This is what I get, still with the axis label "10:00"
labels.png
labels.png (5.52 KiB) Viewed 5205 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply