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

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChZiegelt
Newbie
Newbie
Posts: 39
Joined: Thu Aug 09, 2007 12:00 am
Contact:

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

Post by ChZiegelt » 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

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;


Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

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

Post by Sandra » Mon Sep 27, 2010 1:45 pm

Hello ChZiegelt,

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


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

ChZiegelt
Newbie
Newbie
Posts: 39
Joined: Thu Aug 09, 2007 12:00 am
Contact:

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

Post by ChZiegelt » Mon Sep 27, 2010 4:33 pm

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

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

Post by Sandra » Tue Sep 28, 2010 7:26 am

Hello Christian,


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


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply