Page 1 of 1

Dynamic zoom based on another chart zoom event

Posted: Tue Jan 31, 2006 8:58 pm
by 8125625
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,

Posted: Wed Feb 01, 2006 11:52 am
by narcis
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.