Page 1 of 1

Problem with zooming in Chart

Posted: Fri May 28, 2010 5:31 pm
by 16856060
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.

Re: Problem with zooming in Chart

Posted: Mon May 31, 2010 8:58 am
by yeray
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.

Re: Problem with zooming in Chart

Posted: Mon May 31, 2010 6:08 pm
by 16856060
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?

Re: Problem with zooming in Chart

Posted: Wed Jun 02, 2010 8:13 am
by yeray
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;

Re: Problem with zooming in Chart

Posted: Wed Jun 02, 2010 5:43 pm
by 16856060
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...

Re: Problem with zooming in Chart

Posted: Thu Jun 03, 2010 3:05 pm
by yeray
Hi Diarmid,

Have you created the OnZoom event?
Find attached a simple project.

Re: Problem with zooming in Chart

Posted: Sun Jun 06, 2010 3:06 am
by 16856060
Right. Both your sample code and the sample program work. I need to get more sleep. Your help is very much appreciated.

Re: Problem with zooming in Chart

Posted: Mon Jun 07, 2010 7:34 am
by yeray
Hi Diarmid,

You're welcome!