Page 1 of 1

Custom Log Axis

Posted: Fri Nov 06, 2009 5:01 am
by 5890703
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.

Re: Custom Log Axis

Posted: Fri Nov 06, 2009 12:41 pm
by yeray
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;

Re: Custom Log Axis

Posted: Sat Nov 07, 2009 1:44 am
by 5890703
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?

Re: Custom Log Axis

Posted: Mon Nov 09, 2009 2:38 pm
by yeray
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;