Custom Log Axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Hans Wolfgang
Newbie
Newbie
Posts: 58
Joined: Fri Nov 15, 2002 12:00 am
Location: Naples, FL
Contact:

Custom Log Axis

Post by Hans Wolfgang » Fri Nov 06, 2009 5:01 am

In the attached project, the left axis is log10 of y values, but is linear in the log scale. In uTestCase.pas line 166, minimum y value of left axis is supposed to be log10(50), but it does not get it right. You can see the 50 label and grid line are down below the bottom axis. They are to scale, however, and all other labels/gridlines are at their correct locations. 50 is also correct, but the chart axis stops too high.

Hope you can find what is wrong.
Attachments
ENW-Test04.zip
(15.53 KiB) Downloaded 579 times

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

Re: Custom Log Axis

Post by Yeray » Fri Nov 06, 2009 12:41 pm

Hi Hans,

You could check if the label you are going to draw is in the axis range. Something as follows:

Code: Select all

      repeat
        y1 := CalcPosValue( y );
        if (y1 > CalcPosValue(Maximum)) and (y1 < CalcPosValue(Minimum)) then
        begin
          DrawAxisLabel( PosAxis - 4, y1, 0, IntToStr( tpi ));
          MoveTo( PosAxis, y1 );
          LineTo( BottomAxis.IEndPos, y1 );
        end;
        dy := GetNextTic( y );
        y := y + dy;
        tpi := round( Power( 10, y ));
      until y >= yMax;
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

Hans Wolfgang
Newbie
Newbie
Posts: 58
Joined: Fri Nov 15, 2002 12:00 am
Location: Naples, FL
Contact:

Re: Custom Log Axis

Post by Hans Wolfgang » Sat Nov 07, 2009 1:44 am

I'm still missing something. Values of vertical axis are displayed logarithmically, but the axis itself is linear in log10(y). I do not want to get rid of the 50 tic. What needs to happen is to correctly set the vertical scale of the chart so that the 50 tic lies on the bottom of the left axis. I cannot diagnose the reason why this is not happening.

The y1 value, for y = 50, lies below LeftAxis.IEndPos. But I believe I have set the minimum of the left axis correctly for LabData.MinYvalue = 1.6997 = log10( 50 ).

Please put a breakpoint at utestCase.pas line 173. Something is wrong. The value of IEndPos is only 456. I believe that is should be 495. The "50" tic and grid line are drawn at 495 px, which is below the x axis, but they should actually be right on the x axis, i.e., at y = Ymin.

But please notice that the 50 tic IS in the correct position with respect to the 100 tic. I believe that the scale of the graph is being set incorrectly. It needs to be adjusted to place 50 at the origin of the graph.

How and where am I going wrong here?
Attachments
ENW-Test05.zip
(15.49 KiB) Downloaded 584 times

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

Re: Custom Log Axis

Post by Yeray » Mon Nov 09, 2009 2:38 pm

Hi Hans,

I think it lefts a chart repaint to force the chart to be drawn and to the internal variables have correct values.
Try calling the following at the end of you FormCreate procedure:

Code: Select all

chLifeTemp.Draw;
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