Page 1 of 1

ZoomRect units

Posted: Wed May 13, 2009 7:46 pm
by 15052934
Using TChart 8.0 in MSVC 2008.

The documentation I have gives an example of using ZoomRect as follows

//zoom in
TChart1.Zoom.ZoomRect 5, 5, TChart1.Width - 5, TChart1.Height - 5

// zoom out
TChart1.Zoom.ZoomRect - 5, - 5, TChart1.Width + 5, TChart1.Height + 5

which leads me to believe the following would have no affect on the chart:
// no zoom
TChart1.Zoom.ZoomRect 0, 0, TChart1.Width, TChart1.Height

However all of these when converted to C++ (Chart.GetZoom().ZoomRect...) result in zooming out, never in.

So, my question is, how can I find the current zoom rectangle?

For my current purpose I can get around this using zoompercent and playing games with the axis extents, but zoomrect offers a much simpler solution (if I can figure out how it works).

Thanks,

Jeff Bell

Posted: Thu May 14, 2009 10:34 am
by narcis
Hi Jeff,

ZoomRect uses pixels, code below works fine for me here:

Code: Select all

void CV8ExampleDlg::OnButton1() 
{	
	m_Chart1.GetZoom().ZoomRect(100, 100, 300, 300);
}
You should have in mind that you should perform zoom in the chart drawing area, which by default is defined by chart axes:

Code: Select all

m_Chart1.GetZoom().ZoomRect(m_Chart1.GetAxis().GetLeft().GetPosition() + 10,
								m_Chart1.GetAxis().GetLeft().GetIStartPos() + 10,
								m_Chart1.GetAxis().GetBottom().GetIEndPos() - 10,
								m_Chart1.GetAxis().GetBottom().GetPosition() -10);
Zooming the exact drawing area would do nothing as it's the view you already have.

Hope this helps!

Posted: Thu May 14, 2009 2:13 pm
by 15052934
That worked, thanks.