Axis Minimum / Maximum

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Geosucher
Newbie
Newbie
Posts: 10
Joined: Tue Feb 05, 2008 12:00 am

Axis Minimum / Maximum

Post by Geosucher » Fri Nov 12, 2010 9:49 am

Hallo,

I use TChar VCL V. 8.04.11395 Win95.
In my code I want to change axis minimum and maximum. But first I want to read the axis maximum.
If I use

Chart1.BottomAxis.Maximum

or

Chart1.Axis.Bottom.Maximum ,

I get allways 0. How can I get the maximum of axis?

Best regards

Roland

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Axis Minimum / Maximum

Post by Narcís » Fri Nov 12, 2010 10:09 am

Hi Geosucher,
I use TChar VCL V. 8.04.11395 Win95.
First of all please notice latest v8 release available at the client area is v8.07. BTW: Win95 really :shock: !?!? This is a piece of computer archaeology those days :wink:.
I get allways 0. How can I get the maximum of axis?
This is most likely because your chart hasn't been painted and therefore those properties haven't been calculated yet. To force the chart being internally painted to have valid values for those properties try calling Chart1.Draw() before retrieving axes min./max.
Best Regards,
Narcís Calvet / 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

Geosucher
Newbie
Newbie
Posts: 10
Joined: Tue Feb 05, 2008 12:00 am

Re: Axis Minimum / Maximum

Post by Geosucher » Fri Nov 12, 2010 10:27 am

Hi Narcis,

sorry you are right. Archeology is very interesting, but I don't use Windows 95. it should be Win32.
Here is the part of m code:

Code: Select all

Series1.Clear;
 Series2.Clear;
 if CntSPS_S>0 then
  begin
   for i := 0 to CntSPS_S - 1 do
    Series1.AddXY(SPS_S[i].Easting,SPS_S[i].Northing);
  end;
 if CntSPS_R>0 then
  begin
   for i := 0 to CntSPS_R - 1 do
    Series2.AddXY(SPS_R[i].Easting,SPS_R[i].Northing);
  end;
 Chart1.Draw;
 maxX:=Chart1.BottomAxis.Maximum;
 minX:=Chart1.BottomAxis.Minimum;
 maxY:=Chart1.LeftAxis.Maximum;
 minY:=Chart1.LeftAxis.Minimum;
 if (Chart1.ChartHeight>0) and (Chart1.ChartWidth>0) then
  begin
   XRange:=maxx-minx;
   tmpX:=XRange/Chart1.ChartWidth;
   XYScreen:=(GetDeviceCaps(Canvas.Handle,HORZSIZE)/Screen.Width)/(GetDeviceCaps(Canvas.Handle,VERTSIZE)/Screen.Height);
   YRange:=maxy-miny;
   tmpY:=YRange*XYScreen/Chart1.ChartHeight;
   if tmpX>tmpY then
    begin
     if tmpY<>0 then
      begin
       Offset:=((YRange*tmpX/tmpY)-YRange)/2.0;
       CHart1.Axes.Left.Automatic:=false;
       Chart1.Axes.Left.SetMinMax(Chart1.Axes.Left.Minimum-Offset,Chart1.Axes.Left.Maximum+Offset);
      end;
    end
   else if tmpX<tmpY then
    begin
     if tmpX<>0 then
      begin
       Offset:=((XRange*tmpY/tmpX)-XRange)/2.0;
       Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum-Offset,Chart1.Axes.Bottom.Maximum+Offset);
      end;
    end;
   mi:=Max(Chart1.Axes.Bottom.Increment,Chart1.Axes.Left.Increment);
   Chart1.Axes.Bottom.Increment:=mi;
   Chart1.Axes.Left.Increment:=mi;
  end;
The values of minX,maxX,minY and MaxY have all the value zero.

Best regards

Roland

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Axis Minimum / Maximum

Post by Narcís » Fri Nov 12, 2010 10:48 am

Hi Roland,

Thanks for the information. Code below does what you request here. Does it work fine at your end? If the problem persists can you please attach a simple example project we can run "as-is" to reproduce the problem here?

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 2 do
  begin
    Chart1.AddSeries(TLineSeries.Create(Self));
    Chart1[i].FillSampleValues;
  end;

  Chart1.Draw;

  With Chart1.Axes, Chart1.Title.Text do
  begin
    Clear;
    Add('MinX = ' + FloatToStr(Bottom.Minimum));
    Add('MaxX = ' + FloatToStr(Bottom.Maximum));
    Add('MinY = ' + FloatToStr(Left.Minimum));
    Add('MaxY = ' + FloatToStr(Left.Maximum));
  end;
end;
Thanks in advance.
Best Regards,
Narcís Calvet / 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

Geosucher
Newbie
Newbie
Posts: 10
Joined: Tue Feb 05, 2008 12:00 am

Re: Axis Minimum / Maximum

Post by Geosucher » Fri Nov 12, 2010 11:40 am

Hi Narcis,

sorry I found a big mistake in my code: I use two charts and that chart I wnat to change was Chart2. Now the code is right. :oops:
What a stupid error.

Best regards

Roland

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Axis Minimum / Maximum

Post by Narcís » Fri Nov 12, 2010 11:48 am

Hi Roland,

Ok, no problem. I'm glad to hear you found the solution to your problem.
Best Regards,
Narcís Calvet / 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