Page 1 of 1

How to scale an axis so that ZERO always stays in view

Posted: Mon Sep 27, 2010 9:50 am
by 10546441
Hello Steema Team,

I am using a TChart component in 3D view and like to scale the left/right axis, so that 20 Values plus ZERO are shown.
This works most of the time, but not always.

thanks for any idea.

Here is the code, I am currently using

Code: Select all

procedure ScaleAxis(x,y: Integer)
var
  min, max, omin: Double;
begin
        min := chartP.LeftAxis.Minimum;
        max := chartP.LeftAxis.Maximum;

        { Minimum from Start }
        oMin := min;

        { just a formular, to get the size of scaling by a mouse value - 
          it simply increases or decreases the scale}
        min := min - ( (y-55) / 10000 ) * ( abs(min) + abs(max) ) /2 * 1.5;
        max := max + ( (y-55) / 10000 ) * (abs(min)+abs(max))/2 * 1.5;

        { prevent inverted scaling }
        if min > max then min := max;

        chartP.LeftAxis.Minimum := min;
        chartP.LeftAxis.Maximum := max;

        { try to get ZERO into the middle, and have 20 values }
        chartP.LeftAxis.Increment := (max - min) / 20;
        chartFlange2D.RightAxis.Increment := (max - min) / 20;
        chartFlange2D.LeftAxis.Increment := (max - min) / 20;

end;


Re: How to scale an axis so that ZERO always stays in view

Posted: Mon Sep 27, 2010 1:45 pm
by 10050769
Hello ChZiegelt,

Could you please, send us a simple project, because we can reproduce the problem here?


Thanks,

Re: How to scale an axis so that ZERO always stays in view

Posted: Mon Sep 27, 2010 4:33 pm
by 10546441
Hi Sandra,

I think this is not a real issue, or a problem with TChart.
It's just a question if this would be possible without coding.

I finally found a solution ow that works for me.

Thanks for the help !

Regards
Christian

Re: How to scale an axis so that ZERO always stays in view

Posted: Tue Sep 28, 2010 7:26 am
by 10050769
Hello Christian,


I am glad that you found a solution that works for you :).


Thanks,