VerticalPosition Property
You use the VerticalPosition property to specify or determine the current vertical view position of the ChScrollView object. Returns a Long. Read/write Long.
expression .VerticalPosition
expression Required. An expression that returns a ChScrollView object.
Remarks
You use methods and properties of the ChScrollView object to retrieve information about and control the view of a chart. The portion of the Chart component that displays the chart itself is the visible plot area and it can display the entire chart or a portion of the chart. When only a portion of the chart is displayed in the visible plot area, the effect is as if you have zoomed in on that portion of the chart and the remainder of the chart is contained within a virtual plot area that extends beyond the boundary of the visible plot area. For information on how the values of the properties of the ChScrollView object relate to each other, see the ChScrollView object topic.
When the VerticalPosition property equals zero, the top of the plot area will be at the top of the scroll view window. The VerticalPosition property can be a negative number. For example if VerticalPosition = (-0.25 * VerticalExtentMax)
, the plot area will be pushed down by 25% of the virtual height of the plot area.
Example
The following code shows different ways of working with the properties and methods of the ChScrollView object.
Dim lngVP
Dim lngHP
Dim lngVE
Dim lngHE
Dim lngVEM
Dim lngHEM
Dim objScrollView
Set objScrollView = ChartSpace1.Charts(0).ScrollView
lngVP = objScrollView.VerticalPosition
lngHP = objScrollView.HorizontalPosition
lngVE = objScrollView.VerticalExtent
lngHE = objScrollView.HorizontalExtent
lngVEM = objScrollView.VerticalExtentMax
lngHEM = objScrollView.HorizontalExtentMax
' Toggle the scroll view between unzoomed and 200% zoomed:
If lngVE = lngVEM And lngHE = lngHEM Then
' Chart is not zoomed so zoom to 200%.
objScrollView.VerticalExtentMax = objScrollView.VerticalExtentMax * 2
objScrollView.HorizontalExtentMax = objScrollView.HorizontalExtentMax * 2
Else
' Chart is zoomed, return it to unzoomed state.
objScrollView.VerticalExtentMax = objScrollView.VerticalExtent
objScrollView.HorizontalExtentMax = objScrollView.HorizontalExtent
End If
' For zoomed chart, display lower left corner of virtual plot area in
' the lower left corner of the visible plot area.
If lngVE <> lngVEM Or lngHE <> lngHEM Then
' Move bottom edge of virtual plot area to bottom of visible plot area.
objScrollView.VerticalPosition = objScrollView.VerticalPosition + (lngVEM - lngVM)
' Move left edge of virtual plot area to left edge of visilble plot area.
objScrollView.HorizontalPosition = 0
End If
' This example does the same thing as the previous example using the SetPosition method.
If lngVE <> lngVEM Or lngHE <> lngHEM Then
objScrollView.SetPosition 0, objScrollView.VerticalPosition + (lngVEM - lngVE)
End If