Set initial zoom

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lizabeth
Newbie
Newbie
Posts: 24
Joined: Thu Nov 13, 2003 5:00 am
Location: Sweden

Set initial zoom

Post by Lizabeth » Wed Apr 28, 2004 8:34 am

Hi,

I need to set the initial zoom in the chart to values saved from the user's last session. I.e. if the user has zoomed to 2:1, I want the chart to be zoomed to 2:1 when the users starts the application again.

I have tried to use the SetMinMax method for the axes, but this prevents the user to zoom out to 1:1 again.

Is it possible to set the zoom to some percent initially?

Regards Elisabeth

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

Post by Marjan » Wed Apr 28, 2004 9:44 am

Hi.
but this prevents the user to zoom out to 1:1 again.
To unzoom i.e. reset axis scales all you must do is set horizontal and vertical axis Automatic property to true. This will automatically unzoom and rescale axis scales. Something like this

Code: Select all

tChart1.Axes.Left.Automatic = true;
tChart1.Axes.Bottom.Automatic = true;
Marjan Slatinek,
http://www.steema.com

Lizabeth
Newbie
Newbie
Posts: 24
Joined: Thu Nov 13, 2003 5:00 am
Location: Sweden

Set initial zoom

Post by Lizabeth » Mon May 03, 2004 3:20 pm

will automatically unzoom and rescale axis scales
But this is not what I want! I want the user to be the one who zooms out or in - about 10% in each step. Say that the user has zoomed in 50% in a previous session. When she opens the application again I first want the chart to be zoomed those 50%. And when the user clicks the zoom out button I programatically want to set the zoom to 40%. Using code like:

scorePlot.Zoom.ZoomPercent(90);

So from the initially set zoom I do not want the chart to unzoom itself. I want the chart to stay as it is and I want it to be possible to unzoom or zoom programatically from the initial zoom.

Best regards
Elisabeth

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed May 05, 2004 7:21 am

Hi Elizabeth,
So from the initially set zoom I do not want the chart to unzoom itself. I want the chart to stay as it is and I want it to be possible to unzoom or zoom programatically from the initial zoom.
If I understand you correctly you'll be looking for something similar to:

Code: Select all

private MemoryStream stream1;

private void Form1_Load(object sender, System.EventArgs e) {
	button1.Text = "Export";
	button2.Text = "Zoom out to 40%";
	stream1 = new MemoryStream();
	line1.FillSampleValues();
}

private void button1_Click(object sender, System.EventArgs e) {
	tChart1.Export.Template.Save(stream1);
	stream1.Position = 0;
	tChart2.Series.RemoveAllSeries();
	tChart2.Import.Template.Load(stream1);
}

private void tChart1_Zoomed(object sender, System.EventArgs e) {
	tChart1.Axes.Left.Automatic = false;
	tChart1.Axes.Bottom.Automatic = false;
}

private void tChart2_UndoneZoom(object sender, System.EventArgs e) {
	tChart2.Axes.Left.Automatic = true;
	tChart2.Axes.Bottom.Automatic = true;
}

private void button2_Click(object sender, System.EventArgs e) {
	tChart2.Axes.Left.Automatic = true;
	tChart2.Axes.Bottom.Automatic = true;
	tChart2.Zoom.ZoomPercent(40);
}	
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Lizabeth
Newbie
Newbie
Posts: 24
Joined: Thu Nov 13, 2003 5:00 am
Location: Sweden

Set initial zoom

Post by Lizabeth » Wed May 05, 2004 9:05 am

Hi,

Yes, this is almost what I need. But I have set up a test project using your code and there is still one thing that does not work:

private void button2_Click(object sender, System.EventArgs e)
{
tChart2.Axes.Left.Automatic = true;
tChart2.Axes.Bottom.Automatic = true;
tChart2.Zoom.ZoomPercent(40);
}

The line: tChart2.Zoom.ZoomPercent(40); does not work as I expected. The two previous lines zooms the chart out to fit the window, and then I expected the ZoomPercent(40) call to zoom it in 40% again. But this does not happen! The charts remains zoomed out.

I also wonder if it is possible to read the current zoom percent from the chart. I need to persist how much the user has zoomed as an integer or a double in a database and can't use a stream like in your example. I have not found a property like this so I might need to track this myself.

Best regards,
Elisabeth

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed May 05, 2004 10:09 am

Hi Elizabeth,
The line: tChart2.Zoom.ZoomPercent(40); does not work as I expected. The two previous lines zooms the chart out to fit the window, and then I expected the ZoomPercent(40) call to zoom it in 40% again. But this does not happen! The charts remains zoomed out.
Try setting ZoomPercent to 140. This works as expected with TeeChart version 1.1.1544.23908.

I also wonder if it is possible to read the current zoom percent from the chart. I need to persist how much the user has zoomed as an integer or a double in a database and can't use a stream like in your example. I have not found a property like this so I might need to track this myself.
The stream was just an example. What I was trying to prove was that you can get the functionality you need using Axis.Minimum/Maximum (using the Automatic=true/false tricks shown) meaning that these values can be stored in your database. As an aside, and for speed if nothing else, wouldn't be easier to stream a TeeChart TEN file to your database?
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Lizabeth
Newbie
Newbie
Posts: 24
Joined: Thu Nov 13, 2003 5:00 am
Location: Sweden

Setting initial zoom

Post by Lizabeth » Wed May 05, 2004 3:08 pm

Hi,

This tricking turns out not to work anyway. The setting of Automatic to true, fits the series back into the window, before I set the zoom. This means that my buttons that should zoom the chart in or out 10% from the initial zoom, zooms the chart in/out from the chart fit to the window.

Example: The user have zoomed in 150% the previous session. After starting the application she shall see the chart zoomed to 150%. Again after clicking the zoom out button she shall see the chart zoomed 140%.
As it works with your code, when clicking the button the chart is fit to it's window and then zoomed out 10%. Ie the zoom is then 90% which is not correct.

So since you do not seem to have a property to get/set the current zoom for a chart, Is there any other workaround?

best regards,
Elisabeth

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu May 06, 2004 7:00 am

Hi Elizabeth,
Example: The user have zoomed in 150% the previous session. After starting the application she shall see the chart zoomed to 150%. Again after clicking the zoom out button she shall see the chart zoomed 140%.
As it works with your code, when clicking the button the chart is fit to it's window and then zoomed out 10%. Ie the zoom is then 90% which is not correct.
Rather than having to second guess the specific needs of your application, would you be so kind as to create a small VS.NET project for me that I can run "as-is" to reproduce your problem here?

Please post the app to:
news://www.berneda.com/steema.public.attachments

Many thanks!
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Lizabeth
Newbie
Newbie
Posts: 24
Joined: Thu Nov 13, 2003 5:00 am
Location: Sweden

Post by Lizabeth » Thu May 06, 2004 7:18 am

Hi,

It will be easier for me to hold a variable on my own to fix this. So I will solve the problem that way instead.

But I think it would be neat if there was a property to set/get the zoom factor of the plot! It might be needed by several developers/applications.

Best regards
Elisabeth

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu May 06, 2004 7:26 am

Hi Elizabeth,
It will be easier for me to hold a variable on my own to fix this. So I will solve the problem that way instead.
OK.
But I think it would be neat if there was a property to set/get the zoom factor of the plot! It might be needed by several developers/applications.
So, rather than having ZoomPercent as a method you'd like to see it as a read/write property? OK, I'll put it on the wish list.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply