LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adapt Color of XY Legend

Hello,

 

does anyone know if it is possible to programmatically adapt the background color of the legend of a xy plot?

 

I can alter the color of the main plot via a property node but I couldn’t find an appropriate property node for this need.

 

I would be thankful for any piece of advice.

 

Best regards,

Franz

0 Kudos
Message 1 of 14
(3,676 Views)

Dear Franz,

 

the background of the legend cannot be set separately, it changes together with the bacground colour of the plot area. So you can use the property node of the graph to change the background colours:

Plot Area>>Colors>>BG Color.

I have made you some screenshots for clarification.

 

Best Regards,

Akos

National Instruments

 

Download All
0 Kudos
Message 2 of 14
(3,631 Views)

If that is something you really want, you can always make it transparent, and put something behind it that does change colors. Like a picture ring, a decoration or a picture control. Or a Boolean indicator with two colors.

 

This could turn into a nightmare, for instance auto sizing of the legend will not automatically adopt to the other object...

Message 3 of 14
(3,626 Views)

Hello Akin,

 

thank you very much for your answer, however this is not the exact method I wanted to conduct.

 

I actually wanted to recolor the grey area in the Legend. It is possible via the Property Node “Frame Colour” for the main diagram, but this Node is not applied for the legend background.

 

Background of my question is, that I would like to create a Screenshot of the Diagram by the method “Export Image” and before exporting it, I would like to recolor the grey area in a white background and reverse this afterwards.

By only applying the method “Export Image” the grey areas will also be exported.

 

Best regards,

Franz  

0 Kudos
Message 4 of 14
(3,613 Views)

Unless that property node exists and is hiding so well we haven't found it, it doesn't seem like you can.

 

What you could do as a workaround is create a second graph that you've assigned the alternate colors to.  When you programmatically want to capture the image, you capture it from the alternate plot.  You might need to change the visibility of the regular plot and alternate plot so show it, then switch back when done.

0 Kudos
Message 5 of 14
(3,610 Views)

Hello Franz,

 

if you use the browse option of the property node, you can find the PlotArea:Colors property (Plot Area>>Colors>>All Elements), but this doesn't change the colour of the part you would like to either.

 

Best Regards,

Ákos

0 Kudos
Message 6 of 14
(3,606 Views)

@F.S94 wrote:

thank you very much for your answer, however this is not the exact method I wanted to conduct.


What is wrong with this? It is probably the only workable method.

 

Note that you can get a reference to the legend (and even it's elements). But you need a user to click in the legend at least once...

0 Kudos
Message 7 of 14
(3,597 Views)

Let's be clear here as to what colors the OP is talking about.  The title talks about the color of the legend.  The latest picture looks like he wants the frame color of the legend box itself.  He is not looking at plot areas.

0 Kudos
Message 8 of 14
(3,592 Views)

Graph Legend Colors.PNGGraph Legend Colors diagram.PNG

 

Setting the Graphs frame color is a problem for me. It won't actually update the frame color until I stop the VI. In LV13, so maybe that got fixed. EDIT: the same solution will do the trick.

0 Kudos
Message 9 of 14
(3,580 Views)

Interesting.  So the VI you posted is telling me that the frame of the plot legend is actually a decoration exists on the front panel and is not a part of the graph control itself?

 

That begs the question, how do you change the color on a specific one?  I duplicated the chart and ran the VI.  With you VI, there was exactly one decoration in the array.  So I figured putting the 2nd chart would give me two.  Nope, still only one decoration in the array, and its color does not change.

0 Kudos
Message 10 of 14
(3,572 Views)