Programmatically Add Annotation to Waveform Graph at Cursor Location

제품 및 환경

이 섹션은 예제 생성에 사용된 제품과 OS를 표시합니다.

아래의 제품을 비롯한 NI 소프트웨어를 다운로드하시려면를 방문하십시오.


  • LabVIEW

코드 및 문서



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

NI 커뮤니티에 있는 예제 코드 교환의 예제 코드는 MIT 라이센스로 라이센스가 부여됩니다.