How to scale an axis so that ZERO always stays in view
Posted: Mon Sep 27, 2010 9:50 am
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
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;