From 11:00 PM CST Friday, Apr 11th - 1:30 PM CST Saturday, Apr 12th, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

Operating Graph Controls

Operating Graph Controls

When you set a graph control to any mode other than indicator mode, you can operate graph cursors and zoom and pan the viewport from the keyboard or with the mouse. You also can use the mouse to operate graph annotations or access a customization menu from the graph legend.

Graph Cursors

You can associate one or more cursors with graph controls. Use cursors to select a point or region of the graph for more processing or analysis. If you set the mode of the graph control to hot, cursors generate commit events. If you want to use cursors in a graph control, set the graph control to a mode other than indicator.

You can traverse the graph with both free-form and snap-to-point cursors. By default, graph cursors for which ATTR_CURSOR_MODE is VAL_SNAP_TO_POINT snap to the closest point, polygon, waveform, X, XY , or Y plot. If you want to prevent cursors from snapping to a certain plot, set ATTR_PLOT_SNAPPABLE for the plot to FALSE.

You can use the keyboard to operate a graph as described in the following table:

Keyboard Actions for Cursors

Type of Cursor
When you press...
You select...
Free-form and snap-to-point <Page-Up> Previous cursor.
<Page-Down> Next cursor.
Free-form Left arrow key Left 10 pixels.
Right arrow key Right 10 pixels.
Up arrow key Up 10 pixels.
Down arrow key Down 10 pixels.
<Shift>-left arrow key Left 1 pixel.
<Shift>-right arrow key Right 1 pixel.
<Shift>-up arrow key Up 1 pixel.
<Shift>-down arrow key Down 1 pixel.
<Ctrl>-left arrow key To the left edge of the plot area.
<Ctrl>-right arrow key To the right edge of the plot area.
<Ctrl>-up arrow key To the top edge of the plot area.
<Ctrl>-down arrow key To the bottom edge of the plot area.
<Home> To the lower left corner of the plot area.
<End> To the upper right corner of the plot area.
Snap-to-point Left arrow key To the previous point on the current plot.
Right arrow key To the next point on the current plot.
Up arrow key To the next point on the current plot.
Down arrow key To the previous point on the current plot.
<Shift>-left arrow key Back 10 points on the current plot.
<Shift>-right arrow key Forward 10 points on the current plot.
<Shift>-up arrow key Forward 10 points on the current plot.
<Shift>-down arrow key Back 10 points on the current plot.
<Ctrl>-left arrow key Left to the closest point in the x direction on the current plot.
<Ctrl>-right arrow key Right to the closest point in the x direction on the current plot.
<Ctrl>-up arrow key Up to the closest point in the y direction on the current plot.
<Ctrl>-down arrow key Down to the closest point in the y direction on the current plot.
<Home> To the first visible point on the current plot.
<End> To the last visible point on the current plot.
<Shift-Page Up> To the previous plot.
<Shift-Page Down> To the next plot.

If you configure the graph as a hot control, you generate an event whenever you press one of the keys in the preceding table.

You can use the mouse to operate a graph with cursors in the following ways:

  • Drag a cursor to move it. If the cursor is in snap-to-point mode, the cursor tracks the mouse until you release the mouse button, and then the cursor snaps to the nearest data point. If the cursor is in free-form mode, the cursor tracks the mouse until you release the mouse button, and then the cursor stays at the new position.
  • Move a cursor left and right by holding down <Shift> and dragging the vertical cross hair line projecting outward from the cursor position. Likewise, you can move a cursor up and down by dragging the horizontal cross hair line.

The following behaviors generate a commit event in a graph control that you set to hot mode:

  • When the user moves the cursor with the arrow keys
  • When the user releases the mouse after moving a cursor

Value changed events are generated continuously while a user drags a graph cursor.

Graph Annotations

You can add annotations to graph controls to mark specific data points on the graph. If you want to operate annotations in a graph control, set the graph control to a mode other than indicator. Use the mouse to move an annotation caption. This action generates value changed events continuously. You generate a commit event when you release the mouse after moving an annotation caption. When you drag an annotation caption, the caption moves to the front of the z-plane order. The caption moves back to its original z-plane position when you release the mouse.

Interactive Graph Legend

If you enable ATTR_LEGEND_INTERACTIVE or enable the Interactive Legend option in the User Interface Editor Legend Settings dialog box, you give users the ability to edit various plot attributes at run time. When you enable this attribute or option, a user can right-click a graph legend at run time to launch a customization menu, which includes items such as plot color, plot style, and so on. You also can use the customization menu to rename the selected plot. Some customization menu items are not available for all plot styles.

Note  The customization menu is unavailable if the graph is in indicator mode.

Editing Axis Labels

If you enable ATTR_ENABLE_EDITABLE_AXES or enable the Editable graph axes option in the User Interface Editor Edit Graph dialog box, you give users the ability to edit graph axis labels at run time.

Note  This functionality is available only if the graph is in normal or hot mode and the axis scaling mode is set to VAL_MANUAL or VAL_LOCK. If you enable the ATTR_XUSE_LABEL_STRINGS or ATTR_YUSE_LABEL_STRINGS attribute, you cannot use editable axis labels. If you set ATTR_XFORMAT or ATTR_YFORMAT to VAL_RELATIVE_TIME_FORMAT or VAL_ABSOLUTE_TIME_FORMAT, you also cannot use editable axis labels.

If you enable this attribute, a user can double-click the minimum or maximum axis label value to edit it. When the user modifies the value, the axis range changes based on the new value and LabWindows/CVI generates an EVENT_AXIS_VAL_CHANGE event. If the user double-clicks a label value that is not the minimum or maximum, the graph does not change.

If the user modifies a label value so that the minimum value becomes greater than or equal to the maximum value (or so that the maximum value becomes less than or equal to the minimum value), LabWindows/CVI pans the axis range. For example, if a graph has an x-axis range with 0 as the minimum and 10 as the maximum, and the user changes the minimum to 20, LabWindows/CVI displays the graph so that its x-axis ranges from 20 to 30. If the user enters an invalid number or string, LabWindows/CVI ignores the input and reverts the label to its original value.

If you set ATTR_XMAP_MODE or ATTR_YMAP_MODE to VAL_LOG or if you enable the Log Scale option in the User Interface Editor Edit Axis Settings dialog box, LabWindows/CVI will coerce the value the user enters to a valid log value. If the user modifies a label value so that the new minimum value becomes greater than the existing maximum value or the new maximum value becomes less than the existing minimum value, LabWindows/CVI pans the log scales by the difference in power between the original minimum and maximum values. For example, if the graph has an x-axis range with 1 as the minimum and 100 as the maximum, and the user changes the minimum to 1,000, the new maximum is the new value (1,000) times the original difference in power (100) for a result of 100,000.

Note Note  Refer to the ATTR_XLOOSE_FIT_AUTOSCALING_UNIT or ATTR_YLOOSE_FIT_AUTOSCALING_UNIT topics for more information about how LabWindows/CVI determines new minimum and maximum values using loose fit linear and logarithmic autoscaling units.

Editing Axis Labels in the User Interface Editor

You also can edit graph axis values in the User Interface Editor using the Operate Tool, Edit Text Tool, or Quick Edit Window. When you edit graph axis values in the User Interface Editor, the graph must be in normal or hot mode, but you do not have to enable ATTR_ENABLE_EDITABLE_AXES or set the axis scaling mode to VAL_MANUAL or VAL_LOCK. LabWindows/CVI saves the new graph axis values if you use the Edit Text Tool or Quick Edit Window but does not save the new values if you use the Operate Tool.

Zooming and Panning on Graphs

You can use zooming—the ability to expand or contract the viewport around a particular point or area—in graph controls. When you zoom in, the logical area contained in the viewport gets smaller, showing the area with more resolution. When you zoom out, the viewport shows a wider area. You can also use panning, the ability to shift the viewport.

By default, zooming and panning are disabled. To enable zooming and panning in a graph control, set the graph control to a mode other than indicator. Then set one of the following available zooming modes in the Edit Graph dialog box or programmatically:

  • If you set Zoom style to Zoom to rectangle in the Edit Graph dialog box or set ATTR_ZOOM_STYLE to VAL_ZOOM_TO_RECT, users can define a rectangular zone that will become the new limits of the graph. To select these bounds, press <Ctrl> and click and hold the left mouse button to define the first corner of the box. Drag the mouse to define the opposite corner of the rectangle. When you are satisfied with the new boundaries of the graph, release the mouse button.
  • If you set Zoom style to X-zoom or Y-zoom in the Edit Graph dialog box or set ATTR_ZOOM_STYLE to VAL_ZOOM_XAXIS or VAL_ZOOM_YAXIS, users can zoom along a single axis. Select a rectangle as you do with Zoom to rectangle and within this zone, the view will zoom in along the specified axis.
  • If you set Zoom style to Zoom around point in the Edit Graph dialog box or set ATTR_ZOOM_STYLE to VAL_ZOOM_AROUND_PT, users can select a point around which to zoom. Press <Ctrl> and click and hold the left mouse button to select a point. The resolution in the viewport increases dynamically until you release the mouse; you can release <Ctrl> anytime. If you drag the mouse, the zooming continues recentered on the new point under the cursor. To stop zooming, release the left mouse button.

To pan, press <Ctrl-Shift>, click and hold the left mouse button, and drag the mouse to new point. The graph viewport scrolls so that a new portion of the graph is visible. You can drag the mouse anywhere on the screen, even beyond the viewport. Panning is available whenever you enable zooming.

To zoom out, press <Ctrl> and click and hold the right mouse button. In Zoom around point mode, the resolution in the viewport decreases dynamically until you release the mouse. In all other modes, the resolution incrementally decreases by 10% along the zoomed axes. You also can undo up to 25 of the most recent pans or zooms by pressing <Ctrl-Space> to reverse each successive change.

Note Note  If you enable autoscaling for the graph, autoscaling is disabled while you zoom or pan. If you plot additional data during zooming or panning, LabWindows/CVI completes the zooming or panning and then displays the new data with autoscaling.
Was this information helpful?

Help us improve your future ni.com experience.

Did you find the documentation you were looking for?

Submit