LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph legend text color

Hello,

I saw a couple of posts regarding changing the text color of a graph legend, but they were fairly old so I'm not sure if it has been addressed or not.  My basic question; is there a way to change the color of the legend text?  I didn't see anything in the help documentation, but I did find the attribute "ATTR_PLOT_LG_TEXT_COLOR" in the code.   I tried it, but CVI give an error....

" NON-FATAL RUN-TIME ERROR:   "graph.c", line 80, col 5, thread id 0x000004F8:   Library function error (return value == -46 [0xffffffd2]). The attribute passed is not valid"

I can change the background find using "ATTR_LEGEND_PLOT_BGCOLOR" but obviously the text is impossible to read with many background colors.

Thanks
0 Kudos
Message 1 of 3
(2,922 Views)

Howdy gtoph,

 

An awesome example to look at is the graphlegend example in the Example Finder (Help >> Example Finder >> Index (type "graphs")). This example demonstrates how to programmatically set graph legend options such as color, position, size, and sample plot display.

 

To set the color of the legend text, you could use the statement

 

SetPlotAttribute (panel, PANEL_GRAPH, plotHandle, ATTR_PLOT_LG_TEXT_COLOR, "Color");

 

In this case to set that specific color property, you will need to reference the actual plot on the graph control you want to change (plotHandle).  Some legend settings such as the visibility are accessed via the actual graph control. For example, to set the legend visibility, you would say

 

SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_LEGEND_VISIBLE, "0 or 1")

 

Hope this helps!

 

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 2 of 3
(2,918 Views)
ahh whoops, should have realized it was releated to the individual plot and not the legend as a whole.  Thanks for the info.
0 Kudos
Message 3 of 3
(2,908 Views)