Problem with zooming in Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Diarmid
Newbie
Newbie
Posts: 12
Joined: Fri Apr 30, 2010 12:00 am

Problem with zooming in Chart

Post by Diarmid » Fri May 28, 2010 5:31 pm

I am running Delphi 7 Professional on Windows XP using TeeChart2010 Standard. I have set up a simple chart with two series. One on the left axis and one on the right axis. The scales of the axes are very different. When try to zoom using a rectangle from top left to bottom right, the left and right axes now both the same scale (actually the scale of the right axis). The series associated with the left axis does not show anymore as the values are much smaller than the right axis. See attached pictures for better explanation.
Attachments
Zoomed.png
Zoomed.png (16.34 KiB) Viewed 4799 times
Zooming.png
Zooming.png (16.75 KiB) Viewed 4795 times
Unzoomed.png
Unzoomed.png (17.2 KiB) Viewed 4793 times

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem with zooming in Chart

Post by Yeray » Mon May 31, 2010 8:58 am

Hi Diarmid,

So in the pictures above, you'd like the left axis to bee set from 0.268 to 0.292 (aprox), isn't it? In that case I'm afraid you should do it manually. Here there are some tips you'll need:
- Zooming & Scrolling article
- Custom axes do not zoom. Any solutions? FAQ

If you still have problems with it, please don't hesitate to let us know.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Diarmid
Newbie
Newbie
Posts: 12
Joined: Fri Apr 30, 2010 12:00 am

Re: Problem with zooming in Chart

Post by Diarmid » Mon May 31, 2010 6:08 pm

Hi There,

I wanted the zoom to make the left axis go from 0.268 - 0.292 and the right axis to go from to zoom in 458.5 - 462.5. From what you are saying, using the rectangle will only change the right axis correctly. Is this behaviour repeatable? Will it always put things to the scale of the right axis or will it sometimes put it to the scale of the left axis?

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem with zooming in Chart

Post by Yeray » Wed Jun 02, 2010 8:13 am

Hi Diarmid,

Take a look at the following example. It works as I understood you want to:

Code: Select all

uses series;

var fast1, fast2: TFastLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  fast1:=Chart1.AddSeries(TFastLineSeries.Create(self)) as TFastLineSeries;
  fast2:=Chart1.AddSeries(TFastLineSeries.Create(self)) as TFastLineSeries;

  for i:=0 to 99 do
  begin
    fast1.Add(random*0.005 + 0.16);
    fast2.Add(random*4 + 460);
  end;

  fast2.VertAxis:=aRightAxis;
  fast2.Color:=clRed;

  With Chart1.Axes.Left do
  begin
    SetMinMax(0.16,0.3);
    Axis.Color:=fast1.Color;
    MinorTicks.Color:=fast1.Color;
    Ticks.Color:=fast1.Color;
    LabelsFont.Color:=fast1.Color;
  end;

  with Chart1.Axes.Right do
  begin
    SetMinMax(440,464);
    Axis.Color:=fast2.Color;
    MinorTicks.Color:=fast2.Color;
    Ticks.Color:=fast2.Color;
    LabelsFont.Color:=fast2.Color;
  end;
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  With Chart1.Axes.Left do
    SetMinMax(CalcPosPoint(Chart1.Zoom.Y1),CalcPosPoint(Chart1.Zoom.Y0));
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Diarmid
Newbie
Newbie
Posts: 12
Joined: Fri Apr 30, 2010 12:00 am

Re: Problem with zooming in Chart

Post by Diarmid » Wed Jun 02, 2010 5:43 pm

I created a new project and inserted the computer code that you posted and I get the exact same result as previous. The scale of the left axis becomes the same as the scale of the right axis. That is not what I want...

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem with zooming in Chart

Post by Yeray » Thu Jun 03, 2010 3:05 pm

Hi Diarmid,

Have you created the OnZoom event?
Find attached a simple project.
Attachments
zoomtest.zip
(1.62 KiB) Downloaded 250 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Diarmid
Newbie
Newbie
Posts: 12
Joined: Fri Apr 30, 2010 12:00 am

Re: Problem with zooming in Chart

Post by Diarmid » Sun Jun 06, 2010 3:06 am

Right. Both your sample code and the sample program work. I need to get more sleep. Your help is very much appreciated.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem with zooming in Chart

Post by Yeray » Mon Jun 07, 2010 7:34 am

Hi Diarmid,

You're welcome!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply