Example Code

Programmatically Add Annotation to Waveform Graph at Cursor Location

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • LabVIEW

Code and Documents



This examples uses several Cursor and Graph properties to allow the user to interactively add annotations to a graph.



This VI plots a simulated waveform in a waveform graph.  A cursor is enabled on the graph.  When the user clicks the "Add Annotation" button a dialog box will pop up requesting the annotation to be added.  After the user inputs the annotation and clicks ok in the dialog box, the annotation text will appear on the graph at the location of the cursor chosen by the user.  The color of the annotation text can be changed, but is not retro-active.  In other words, only future annotations will have the newly chosen color.


An event structure is used to determine when the Add Annotation button is pressed.  The annotation text from the dialog box is the Name input for the annotation cluster.  Each annotation added is an addition and edit of the annotation list associated with waveform graph.  In addition, the position of the annotation is set to be the position of the active cursor, which is determined by the user.  If the user chooses an active cursor that is invalid, then a message window pops up. (The cursor number is greater than or equal to the size of the cursor list- the list is 1 indexed and the active cursor number is 0 indexed)



  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Run the VI
  2. Move the cursor to the desired position of the annotation
  3. Select the cursor that will specify the location of the annotation.
  4. Click Add Annotation
  5. Type your annotation and select OK
  6. Repeat if desired


Additional Information or References

You can change the characteristics of the cursors to free or attached to a plot.  A free cursor will not be bound to the plot on the graph display.  A single-plot cursor will only move along the plot.


Front Panel



Block Diagram







**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.