TChart Allow zoom

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

TChart Allow zoom

Post by Herman » Mon Jan 17, 2005 2:06 am

I write the save and load chart by myself. Because there is many more things to be saved in my application.
What property can be affected by allow zoom?
I want to save the things after user doing zooming in a chart.
But I don't know what property to be saved.

Thank you

Herman

Pep
Site Admin
Site Admin
Posts: 3277
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jan 17, 2005 7:31 am

Hi Herman,

it's saved in the Allow property, i.e :
Chart1.Zoom.Allow := true;

Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

Post by Herman » Mon Jan 17, 2005 9:38 am

AllowZoom is just a boolean isn't?
then how to know, the position that user have click on a chart for zooming

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Jan 17, 2005 11:33 am

Hi.

You can use the chart OnZoom event to retrieve zoom rectangle start and end position:

Code: Select all

procedure TForm1.Chart1Zoom(Sender: TObject);
var startpoint, endpoint: TPoint;
begin
  startpoint.X := Chart1.Zoom.X0;
  startpoint.Y := Chart1.Zoom.Y0;
  endpoint.X := Chart1.Zoom.X1;
  endpoint.Y := Chart1.Zoom.Y1;
end;
Please note that startpoint and endpoint denote the zooming rectangle start and end point, expressed in screen pixels. If you want real axis values, use chart axis CalcPosPoint method for transformation.
Marjan Slatinek,
http://www.steema.com

Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

Post by Herman » Tue Jan 18, 2005 5:41 am

It still not working. I test like this.
Add samething to chart1 and chart2.
Chart1's allowzoom is set to true.
Then i zoom some part of chart1. Then click apply changes to chart2.
I want it to display the same thing.
Instead of using chart2->Assign(chart1).
I want to know exactly what property effected by allowzoom.

void __fastcall TForm1::Add(Tobject *Sender)
{
int i;

for(i = 0; i < 501; i++)
{
Chart1->Series[0]->AddY(i*10);
Chart2->Series[0]->AddY(i*10);
}
}

void __fastcall TForm1::Apply(TObject *Sender)
{
Chart2->Zoom->X0 = Chart1->Zoom->X0;
Chart2->Zoom->X1 = Chart1->Zoom->X1;
Chart2->Zoom->Y0 = Chart1->Zoom->Y0;
Chart2->Zoom->Y1 = Chart1->Zoom->Y1;

}

Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

Post by Herman » Tue Jan 18, 2005 10:17 am

I have found the property that could possibly affect by allowzoom.
Not so sure...but it does show the things i want.
My sample code is like this:

Chart2->LeftAxis->Automatic = false;
Chart2->LeftAxis->AutomaticMinimum = false;
Chart2->LeftAxis->AutomaticMaximum = false;

Chart2->LeftAxis->Minimum = Chart1->LeftAxis->Minimum;
Chart2->LeftAxis->MinimumOffset = Chart1->LeftAxis->MinimumOffset;
Chart2->LeftAxis->Maximum = Chart1->LeftAxis->Maximum;
Chart2->LeftAxis->MaximumOffset = Chart1->LeftAxis->MaximumOffset;

Chart2->BottomAxis->Automatic = false;
Chart2->BottomAxis->AutomaticMinimum = false;
Chart2->BottomAxis->AutomaticMaximum = false;

Chart2->BottomAxis->Minimum = Chart1->BottomAxis->Minimum;
Chart2->BottomAxis->MinimumOffset = Chart1->BottomAxis->MinimumOffset;
Chart2->BottomAxis->Maximum = Chart1->BottomAxis->Maximum;
Chart2->BottomAxis->MaximumOffset = Chart1->BottomAxis->MaximumOffset;

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Jan 18, 2005 1:59 pm

Hi, Herman.

Yes. Zooming and scrolling ulitmately only changes axis scales (explained in TeeChart VCL FAQ, see this link).
When you're zooming or scrolling chart the end result is chart axis minimum and maximum values will change. So, if you know axis ranges (minimum and maximum values), you can copy these properties to second chart and you'll get a synchronized zoom.
Marjan Slatinek,
http://www.steema.com

Post Reply