Page 1 of 1

A question about custom label.

Posted: Fri May 04, 2012 1:50 am
by 16562051
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.

Re: A question about custom label.

Posted: Fri May 04, 2012 10:56 am
by 10050769
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,

Re: A question about custom label.

Posted: Tue May 08, 2012 7:55 am
by 16562051
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.

Re: A question about custom label.

Posted: Thu May 10, 2012 3:00 pm
by yeray
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 5209 times