LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically Altering Chart Legends

Hi Everyone,

I am struggling to program chart legends and I am hoping to get some help. My code is simulating a NI9205 with NIMAX and DAQmx.  I am trying to programmatically update the legends by the user specifying the channel names.

 

I am having two problems

  • I can’t get the unused channels to disappear on the legend. I only want the legend to display channel names specified in the “Channel Names” Array. Reading online this seems to be a bug in LabVIEW. Any idea how to get around it?
  • I can’t get the first channel name to be displayed on the legend. I clicked the Execution Highlighting (light bulb). It shows the first channel name being indexed; however, even though it enters the property node the channel name is not displayed on the chart. This has been bothering me for hours, and I don’t know what I am doing wrong. Attached are my codes.

 

ANY INFORMATION WOULD BE APPRECIATED!

Thanks

Image.PNG

Image 2.PNG

Download All
0 Kudos
Message 1 of 6
(2,573 Views)

Hi Kurtz,

 

I can’t get the first channel name to be displayed on the legend. … I don’t know what I am doing wrong.

You did wrong at the chart's property node:

first you set the plot name, then you set the active plot. You need to do that the other way around: first define the active plot, then change it's properties!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(2,540 Views)

Wow... well that did the trick. It works now thank you very much. 

 

Do you have any idea how to remove the unused plots in the legend? 

0 Kudos
Message 3 of 6
(2,520 Views)

To force remove plots, use Legend:Plot Minimum property. It should be used after resizing legend, because changing size of legend increases number of active plots.

 

I would not use legend height. 

Instead (N = number of names): 

1) Remove "Autosize plot legend" checkmark.

2) Put a decoration box at full graph height. Optional, but empty array elements do not look nice, I could not make them completely invisible.

3) Set Num of rows to minimum of graph height (13) and N.

4) Set Legend: Plot Minimum to N

5) If N less or equal to 13, set legend scrollbar Visibility to false.

 

Also:

Remove names array build, transpose and local variable. Autoindexing works for single dimension arrays.

Properties that apply to all legend (size, visibility) should be written once, not in a loop. Only Active plot and Name should be in the loop.

 

Message 4 of 6
(2,511 Views)

Hi Alexander!

All of those tips worked very well. I am pretty sure I implemented everything you mentioned. However, I may have messed up the legend height. Thanks for the help though. 

Image 1.PNGImage 2.PNG

0 Kudos
Message 5 of 6
(2,494 Views)

It turns out that the legend height has become a problem, because it is showing inactive plots. I tried implementing your suggestions, but I must have read them wrong. Any idea what I am doing wrong? 

 

 

0 Kudos
Message 6 of 6
(2,491 Views)