Example: 2D Graph Events

Measurement Studio User Interface

Example: 2D Graph Events

Demonstrates interaction with data displayed on the Measurement Studio 2D Graph.

Description

This example displays the many ways you can interactively and programmatically interact with data displayed on a Measurement Studio 2D Graph in Visual Basic. Use the TrackMode property to pan, zoom, or generate cursor or plot events in the graph. See the description below the TrackMode listbox for information about the selected TrackMode.

You can set the TrackMode option to one of the following values either in the graph property pages or programmatically:

Plot Area Events

Plot & Cursor Events

Cursors (CursorChange event)

PanXY

PanX

PanY

ZoomXY

ZoomX

ZoomY

Plot Area Events

Select the Plot Area Events TrackMode to generate Mouse events anywhere on the graph. The Mouse events return the x position and y position of the mouse on the graph. As you move the mouse, notice how the values in Plot Area Events change accordingly. The Plot Area Mouse events also indicate when the left or right mouse button is clicked and released anywhere on the graph.

Plot and Cursor Events

Select the Plot & Cursor Events TrackMode to generate both Mouse events along plot and Cursor events anywhere on the graph. The PlotMouse events return the x position and y position of the cursor location and the point index, or the exact point on the plot. The PlotMouse events also indicate when the left or right mouse button is pressed or released on the plot. Unlike the PlotMouse events, the Cursor events are generated anywhere on the plot area. The Cursor events return the x position and y position of the crosshair and specify if the left or right mouse button is pressed or released in the graph area.

Cursor Change

Select Cursors to interactively drag a cursor anywhere on the graph and generate the CursorChange event. CursorChange returns the x position and y position of the crosshair.

Note: If you want to generate both Cursor and Plot events, you have to use the Plot & Cursor TrackMode and write event procedures to move the cursor programmatically when a CursorMouse event occurs.

Pan

Use the Pan modes to move the plot horizontally and/or vertically. Panning is useful when the entire plot is not visible in the plot area. Select PanXY to drag the plot both horizontally and vertically. Click and drag on the graph to pan the plot. Use PanX to limit interaction to horizontal panning. Select PanY to limit interaction to vertical panning. To reset the plot area to its original view, select the Reset After Zooming or Panning button.

Zoom

Use the Zoom modes to reset the graph view to a specific region of the plot, which is useful when you want to focus on a particular region of a graph. ZoomXY selects a region horizontally and vertically. Click and drag to the region you want to zoom in on. ZoomX selects an area of the plot horizontally only. ZoomY selects an area vertically only. Select the Reset After Zooming or Panning Button to reset the view.

Controls, Properties, Methods, and Events

This example demonstrates the following controls, properties, methods, and events:

CWGraph

TrackMode

CWCursor

SnapMode

Example Location

Samples\UI\Graph\Events