LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

custom graph legend menu RIGHT_CLICK event

Hey everyone.  I'm developing a feature for a graph control that displays multiple plots over a span of time.

 

It would be helpful to my user to give some amount of focus or highlight to one of the many plots. I realize there is the plot thickness feature built into the legend with interactive mode turned on.  That's great!

 

However, this graph can run for 4 days and the sample rate tends to be once every 10 seconds.  So there's hundreds of thousands of data points.  Hence, simply thickening the plot helps, but the user loses resolution.

 

So I'm experimenting with the  ATTR_PLOT_OPACITY feature. So here's what I did:

 

1) I added a custom control menu item (NewCtrlMenuItem) with its own callback function.

2) In the callback, I set this plotID to be opaque and all other plots to be less (giving a dimmed look).

3) I also set the checkmark for this menu item. 

 

2018-05-21 11_48_00-P vs. T.png

 

Now the only problem with this approach is that the checkmark in this exclusive OR arrangement is only relevant to one plot ever!  So what I really need to do is on the RIGHT_CLICK event, reassess if the plot in question was dimmed before.  Otherwise, set up a new single opaque plot and dim the rest.

 

 

But, it turns out that GetActiveLegendItem doesn't work on the EVENT_RIGHT_CLICK event for the graph control.  Apparently, the legend item isn't "active" until you do a left click / commit on the legend.

 

Also, I tried the EVENT_INTERACTIVE_LEGEND event, but this to is reserved only for when the user left-clicks (commit).

 

I'm surprised that GetActiveLegendItem isn't finding the plot that's highlighted.  Am I missing another approach?

0 Kudos
Message 1 of 6
(2,434 Views)

This is really cool! I'm curious, would it be possible to use the left-click to select an active plot, and whichever plot is active, make that one opaque? What I'm thinking there is that the user could click through the plots, and we could use the left click callback to determine if it was currently dimmed or not, bypassing the need for a menu item.

 

That said, if there's already functionality attached to left clicking a plot, I would understand wanting to go through the menu item. Just a thought!

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 2 of 6
(2,393 Views)

Thanks, Claire!

 

Yes, that's a good idea.  In fact, my user even suggested that approach first -- just allow direct left clicking on a plot in the plot area.

 

However, as you mentioned, I already have left click reserved for creating a vertical line cursor which then gives active measurement of Y-axis values along the corresponding X-axis point.

 

 

But if hypothetically we changed to a left-click activation, you are right.  It would simply be a matter of looking up that discovered plot's opacity, then dimming the rest.  This is probably more elegant and direct.

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

Ah, as suspected 🙂

 

A quick question to clarify current behavior--when you right click on the legends, does it currently just create a menu for the legend as a whole, or for each plot? It might help to post the version of the graph code for forum-users to fiddle with (if possible, of course)!

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 4 of 6
(2,367 Views)

I'm not sure what you're asking.  I'm using the interactive setting of the graph control, which creates a built-in control menu whose menu items do correspond to the particular legend plot ID that you were over when you right-click.

 

I've put these concepts into a project (which I first posted over on my legend mover thread)

 

It's a bit buggy, but I think you get the idea.

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

Ah, apologies for the unclear question! I think you answered it though--I was hoping to understand if right clicking on a legend item did identify the item specifically. In that case, I was wondering if a flag in the code would work, set either dimmed or un-dimmed upon the action taken.

 

I haven't had a chance to take a look at the code, so just hypotheticals at the moment. 

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 6 of 6
(2,316 Views)