While we did not design the SPC Chart routines with zooming in mind, you can implement zooming, using ChartZoom routines described in the QCChart2D manual.
Read the chapter on zooming in the QCChart2D manual, and run and study the ZoomExamples example program in the QCChart2D examples.
You can add a zoom with stack class to your main TimeVariableControlChart derived class:
c#
public class SPCApplicationUserControl1 : com.quinncurtis.spcchartnet.SPCTimeVariableControlChart
{
private class ZoomWithStack : ChartZoom
{
public ZoomWithStack(ChartView component, PhysicalCoordinates transform, bool brescale)
: base(component, transform, brescale)
{
}
public override void OnMouseDown(MouseEventArgs mouseevent)
{
if ((mouseevent.Button & MouseButtons.Right) != 0)
this.PopZoomStack();
else
base.OnMouseDown(mouseevent);
}
}
.
.
.
VB
Public Class SPCApplicationUserControl1
Inherits com.quinncurtis.spcchartnet.SPCTimeVariableControlChart
Private Class ZoomWithStack
Inherits ChartZoom
Public Sub New(ByVal component As ChartView, ByVal transform As PhysicalCoordinates, ByVal brescale As Boolean)
MyBase.New(component, transform, brescale)
End Sub 'New
Public Overrides Sub OnMouseDown(ByVal mouseevent As MouseEventArgs)
If (mouseevent.Button And System.Windows.Forms.MouseButtons.Right) <> 0 Then
Me.PopZoomStack()
Else
MyBase.OnMouseDown(mouseevent)
End If
End Sub 'OnMouseDown
End Class 'ZoomWithStack
Instantiate the ZoomWithStack class at the bottom of the InitializeChart inititialization section.
c#
.
.
.
this.AutoScalePrimaryChartYRange();
this.AutoScaleSecondaryChartYRange();
this.RebuildChartUsingCurrentData();
// Add this code for zooming
ZoomWithStack zoomObj = new ZoomWithStack(this, this.PrimaryChart.PPhysTransform1, true);
zoomObj.SetButtonMask(MouseButtons.Left);
zoomObj.SetZoomYEnable(true);
zoomObj.SetZoomXEnable(true);
zoomObj.SetZoomXRoundMode(ChartObj.AUTOAXES_FAR);
zoomObj.SetZoomYRoundMode(ChartObj.AUTOAXES_FAR);
zoomObj.SetEnable(true);
zoomObj.SetZoomStackEnable(true);
this.SetCurrentMouseListener(zoomObj);
}
VB
.
.
Me.AutoScalePrimaryChartYRange()
Me.AutoScaleSecondaryChartYRange()
Me.RebuildChartUsingCurrentData()
' Add this code for zooming
Dim zoomObj As New ZoomWithStack(Me, Me.PrimaryChart.PPhysTransform1, True)
zoomObj.SetButtonMask(System.Windows.Forms.MouseButtons.Left)
zoomObj.SetZoomYEnable(True)
zoomObj.SetZoomXEnable(True)
zoomObj.SetZoomXRoundMode(ChartObj.AUTOAXES_FAR)
zoomObj.SetZoomYRoundMode(ChartObj.AUTOAXES_FAR)
zoomObj.SetEnable(True)
zoomObj.SetZoomStackEnable(True)
' set range limits to 0.01, 0.01
zoomObj.SetZoomRangeLimitsRatio(New Dimension(0.01, 0.01))
Me.SetCurrentMouseListener(zoomObj)
End Sub 'InitializeChart
It will only work for one chart at a time (PrimaryChart or SecondaryChart).
You can download the complete c# file here: http://quinn-curtis.com/downloadsoftware/examplecode/SPCApplicationWithZoom.txt . You can RENAME the file SPCApplicationUserControl1 and replace the file of the existing name in the SPCApplication1 example program.