GetNextAxisLabel event not fired!
Posted: Fri Aug 11, 2006 4:40 pm
Hi,
When GetAxisLabel event is set the GetNextAxisLabel event not fire!
I used GetAxisLabel to convert datetime axis label from UTC to LocalTime.
Please response me as soon as possible!
Best regards,
Gabor Varga
When GetAxisLabel event is set the GetNextAxisLabel event not fire!
I used GetAxisLabel to convert datetime axis label from UTC to LocalTime.
Code: Select all
with TChart1.Axes.Bottom do
begin
Labels.DateTimeFormat := 'yyyy.MM.dd HH:mm:ss';
Labels.MultiLine := true;
end;
Code: Select all
procedure TWinForm.TChart1_GetNextAxisLabel(sender: System.Object; e: Steema.TeeChart.GetNextAxisLabelEventArgs);
var
value : Double;
date : System.DateTime;
ax : Steema.TeeChart.Axis;
a : integer;
t : TimeSpan;
d1, d2 : datetime;
LabelOK : Boolean;
begin
LabelOK := False;
ax := steema.teechart.axis( sender );
if (ax.Equals(tChart1.Axes.Bottom)) then
begin
d1 := DateTime.fromoadate( ax.Maximum);
d2 := datetime.fromoadate( ax.Minimum);
t:= d1.Subtract(d2);
a := convert.ToInt32(t.TotalMinutes) div 15;
e.Stop := False;
if first then
begin
value := e.LabelValue;
date := DateTime.FromOADate(value);
Debug.Write(date.ToString);
newDate := DateTime.Create(date.Year, date.Month, date.Day, date.Hour, 0, 0);
debug.Write('Newdate1 = ' + newdate.ToString);
if (date.Minute >= 15) then
newDate := newDate.AddMinutes(15)
else if (date.Minute >= 30) then
newDate := newDate.AddMinutes(30)
else if (date.Minute >= 45) then
newDate := newDate.AddMinutes(45);
first := False;
end
else
newDate := newDate.AddMinutes(15);
if e.LabelIndex = 0 then
begin
e.LabelValue := value;
LabelOK := True;
end;
if (e.LabelIndex > 0) and (e.Labelindex <= a + 2) then
begin
e.LabelValue := newDate.ToOADate();
LabelOk := True;
end;
if e.LabelIndex = a+3 then
begin
e.LabelValue := ax.Maximum;
LabelOK := True;
end;
if not LabelOK then
begin
e.Stop := true;
first := true;
end;
end;
end;
Code: Select all
procedure TWinForm.TChart1_GetAxisLabel(sender: System.Object; e: Steema.TeeChart.GetAxisLabelEventArgs);
var
axis : Steema.TeeChart.Axis;
datValue : System.DateTime;
begin
axis := Steema.TeeChart.Axis( sender );
if (sender = axis.Chart.Axes.Bottom) then
begin
// note - e.LabelText must initially hold complete datetime, not only time part!
datValue := System.DateTime.Parse(e.LabelText);
e.LabelText := datValue.ToLocalTime.ToString('MM.dd HH:mm:ss');
end;
end;
Best regards,
Gabor Varga