Page 1 of 1

OnDrawLabel is not called when drawing the depth axis

Posted: Thu Jul 27, 2006 1:04 am
by 9338026
The onDrawLabel event is only invoked for horizontal and vertical axes, but not for depth axes.


Dave

Posted: Thu Jul 27, 2006 10:32 am
by narcis
Hi Dave,

Thanks for reporting. I could reproduce the issue here and added it (TV52011624) to our defect list to be fixed for future releases. In the meantime you can try using the OnGetAxisLabel event, for example:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if (sender = Chart1.Axes.Depth) then
    LabelText:='Hi!';
end;
If you are a source code customer, another option would be trying one customer, Alexey Kuznetsov, suggested in our public newsgroups:

Code: Select all

unit TeEngine;

.... somewhere in this unit add or modify lines marked with {kuaw} ...

  Procedure DrawThisLabel(LabelPos:Integer; Const tmpSt:String;
Format:TTeeCustomShape=nil);
  var tmpZ : Integer;
      tmpPos : Integer;
{kuaw}tmpY: integer;
{kuaw}tmpDraw: boolean;
{kuaw}tmpS: string;
  begin
    if TickOnLabelsOnly then
       AddTick(LabelPos);

    With ParentChart,Canvas do
    begin
      if Assigned(Format) then AssignFont(Format.Font)
                          else AssignFont(Items.Format.Font);

      // trick
      Brush.Style:=bsSolid;
      Brush.Style:=bsClear;

      {$IFDEF CLX}
      BackMode:=cbmTransparent;
      {$ENDIF}

      if IsDepthAxis then
      begin
        TextAlign:=DepthAxisAlign;

        if (View3DOptions.Rotation=360) or View3DOptions.Orthogonal then
           tmpZ:=LabelPos+(FontHeight div 2)
        else
           tmpZ:=LabelPos;

        if OtherSide then tmpPos:=PosLabels
                     else tmpPos:=PosLabels-2-(TextWidth('W') div 2);

{kuaw} tmpY := DepthAxisPos;
{kuaw} tmpS := tmpSt;
{kuaw} tmpDraw := true;
{kuaw} if Assigned(FOnDrawLabel) then // 7.0
{kuaw} FOnDrawLabel(Self,tmpPos, tmpY, tmpZ, tmpS, tmpDraw);

{kuaw} if (tmpDraw) then TextOut3D(tmpPos, tmpY, tmpZ, tmpS);
{kuaw: was simply TextOut3D(tmpPos,DepthAxisPos,tmpZ,tmpSt); without
calling OnDrawLabel event}
....

Posted: Thu Jul 27, 2006 4:05 pm
by 9338026
Thanks Narcis,

I am a source code customer, and I've already gone with the second solution. :)

Dave