Set initial zoom
Set initial zoom
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
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
Hi.
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 thisbut this prevents the user to zoom out to 1:1 again.
Code: Select all
tChart1.Axes.Left.Automatic = true;
tChart1.Axes.Bottom.Automatic = true;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Set initial zoom
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:will automatically unzoom and rescale axis scales
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
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Elizabeth,
If I understand you correctly you'll be looking for something similar to: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.
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/
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/
Set initial zoom
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
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
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Elizabeth,
Try setting ZoomPercent to 140. This works as expected with TeeChart version 1.1.1544.23908.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.
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?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.
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/
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/
Setting initial zoom
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
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
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Elizabeth,
Please post the app to:
news://www.berneda.com/steema.public.attachments
Many thanks!
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?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.
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/
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/
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hi Elizabeth,
OK.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.
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.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.
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/
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/