From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detemine the sub-plot clicked within a stacked chart

Solved!
Go to solution

I would like to use the mouse up (Mods:Double click) to detect which plot area of a stacked waveform chart was clicked.  There doesn't seem to be a property which effectively says "Clicked within plot area n".  Just properties which identify coordinates relative to some reference which I can't seem to find within the labView help (For stacked plots).

 

Is there a property or a common method for calculating the plot area selected?

 

Thanks,

 

XL600

0 Kudos
Message 1 of 9
(3,762 Views)

If I understood well, this could help you.

 

Stack chart Index.png

0 Kudos
Message 2 of 9
(3,723 Views)

That is how the charts are populated, yes.  But if I click on one of the stacked plot axes and capture the mouse up event, how would I detect which axis was clicked and where in that specific axis the click occurred?

0 Kudos
Message 3 of 9
(3,698 Views)
Solution
Accepted by topic author xl600

AYanez a écrit :

If I understood well, this could help you.

 

 


It is more complicated than that. The plot area bounds gives the bounds value for the active plot. For stacked plots the default is plot 0. So this gives you the bounds for the first plot area. You need to get the number of plots and activate them to get the bounds values for each plot area. Then when the mouse is clicked you have to find if it the coordinates are included in one of the plot area.

 

Here how to do it. I leave it to the OP to modify it for mouse up double click event.

 

Ben64

 

determine plot area clicked.png

Message 4 of 9
(3,682 Views)

Ahh, so the mouse click coords are relative to the same origin as the plot bound rectangle verticies?  I don't have my LV system available at the moment so I can't check.  But the technique you use us exactly what I need!  I can't wait to give it a try on Monday.

 

thanks!

0 Kudos
Message 5 of 9
(3,666 Views)

xl600 a écrit :

Ahh, so the mouse click coords are relative to the same origin as the plot bound rectangle verticies?  I don't have my LV system available at the moment so I can't check.  But the technique you use us exactly what I need!  I can't wait to give it a try on Monday.

 

thanks!


Yes, they are both absolute coordinates using the FP origin.

 

Ben64

0 Kudos
Message 6 of 9
(3,647 Views)

It works like a charm.  I did tweak the idea a bit thouugh.  I have many signals in each of the stacked plots and wanted to avoid reading the value data array (I'm also using dynamic signals) just to determine the number of plots.  When I used your approach, I would get a number of plots matching my signal count, and not the number of plots themselves.  I realized that it isn't an error to set the ActPlot to a higher value so I created a subVI to get the boundaries in a rapid fashion so I can just calculate the boundaries on the mouse click event.  My selected chart changes so I also didn't want to store the boundaries.  Why NI doesn't provide a property for NumPlots is a mystery.  Seems obvious that users would want to iterate through plots.

 

Get plot boundaries.png

Which Plot.png

0 Kudos
Message 7 of 9
(3,587 Views)

You could get rid of the delete array element by changing the equal to not equal, the loop stop condition to continue if TRUE and to conditionnally index the plot bounds using the output of the not equal comparison. I always try to avoid adding something that have to be removed after.

 

Ben64

 

Get Bounds.png

0 Kudos
Message 8 of 9
(3,575 Views)

And right back at you!

 

Get plot boundaries_RevA.png

Thanks again!

 

 

0 Kudos
Message 9 of 9
(3,565 Views)