Dynamic zoom based on another chart zoom event

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
anton dizhur
Newbie
Newbie
Posts: 6
Joined: Wed May 26, 2004 4:00 am
Location: New York

Dynamic zoom based on another chart zoom event

Post by anton dizhur » Tue Jan 31, 2006 8:58 pm

I have two charts (contain 2D point series):
order chart : x-axis (6:00 - 17:00) and y-axis (stock price)
size chart : x-axis (6:00 - 17:00) and y-axis (trade size)

If the user zooms in using the mouse drag in order chart, I want to zoom the size chart in the same ratio. E.g. after zooming order chart is from 8:00 to 8:30, I want to programmatically zoom size chart to 8:00 to 8:30.

This is my code to do the dynamic zooming:
private void OrderChart_Zoomed(object sender, EventArgs e)
{
Steema.TeeChart.TChart chart = (Steema.TeeChart.TChart)sender;
Rectangle r = new Rectangle(chart.Zoom.x0, chart.Zoom.y0, chart.Zoom.x1-chart.Zoom.x0, chart.Zoom.y1-chart.Zoom.y0);
SizeChart.Zoom.ZoomRect(r);
}

The end result is not what I want. Two problmes:
1. the x-axis is different (order char : 8:00-8:30, size chart : 7:50 - 9:00)
2. how to I keep y-axis value in the same ratio?


What is the best way to handle this?

Thanks,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 01, 2006 11:52 am

Hi anton,

You can try doing something like:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			tChart1[0].FillSampleValues();
			tChart2[0].FillSampleValues();
		}

		private void tChart1_Zoomed(object sender, System.EventArgs e)
		{
			UpdateAxes();
		}

		private void tChart1_Scroll(object sender, System.EventArgs e)
		{
			UpdateAxes();
		}

		private void tChart1_UndoneZoom(object sender, System.EventArgs e)
		{
			UpdateAxes();
		}

		private void UpdateAxes()
		{
			tChart1.Refresh();
			tChart2.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.Minimum,tChart1.Axes.Bottom.Maximum);			
		}
If that's not what you are looking for, could you please send us an example we can run "as-is" or modify the snippet above so that we can reproduce the problem here?

You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply