SetPosition Method

You use the SetPosition method to to specify the current view position of the ChScrollView object of a Chart component. Returns Nothing.

expression**.SetPosition(HorizontalPosition**, VerticalPosition)

*expression   * Required. An expression that returns a ChScrollView object.

HorizontalPosition   Required Long.

VerticalPosition   Required Long.

Remarks

Using this method to specify the current scroll view position has the same effect as setting the HorizontalPosition and VerticalPosition properties individually. If you use the SetPosition method rather than the HorizontalPosition and VerticalPosition properties individually, however, less repainting will occur.

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; 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.

The VerticalPosition and HorizontalPosition properties describe the upper-left corner of the visible plot area. The VerticalExtent and HorizontalExtent properties describe the lower-right corner of the visible plot area. Because you will frequently work with these properties together, you can use SetPosition method to specify the upper-left corner of the visible plot area and the SetExtent method to specify the lower-right corner.

Example

This example shows the lower-left corner of a zoomed chart in the lower-left corner of the visible plot area.

Dim lngVE
Dim lngHE
Dim lngVEM
Dim lngHEM
Dim objScrollView

Set objScrollView = ChartSpace1.Charts(0).ScrollView
lngVE = objScrollView.VerticalExtent
lngHE = objScrollView.HorizontalExtent
lngVEM = objScrollView.VerticalExtentMax
lngHEM = objScrollView.HorizontalExtentMax

' 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
 objScrollView.SetPosition 0, objScrollView.VerticalPosition + (lngVEM - lngVE)
End If

Applies to | ChScrollView Object