LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

automate annotation locations

Hi,

I've been trying out the Annotations in LabVIEW 8.5 and they work well except for a few issues I tend to be having. I have a grpah that needs 5 annotations in them, but they may be anywhere in the graph. What I am trying to avoid is overlap between the annotation labels together. Here are some examples of what I am talking about. The first graph shows a bunch of annotations all overlaping. I zoom in on the graph and they reorder properly and look clean, but I can not allow the graph to always just zoom in on the annotations, I need the graph to be the full view. So the last graph shows how I would like the annotations to automatically orient themselves with each other to get a best fit around the cursor points without overlapping their own space.

Graph As Is


Graph zoomed


Graph moved


Is this something that NI can look into providing or is there another alternative that I can work on in the background? How should I proceed in accomplishing this?
I have used other graphs through active X that can do a better job of annotations, but have a memory leak. If I can find a way to get the NI graphs to mimic these below, I much rather would.

Graph to Mimic



Thanks,

--Kevin
Kevin Shirey | CLA | Champion | Senior Project Engineer II | DMC
0 Kudos
Message 1 of 6
(3,963 Views)

Hi Kevin,

As far as I can tell, this most likely would be best handled as a Product Suggestion. You've done an excellent job in describing the behavior and we appreciate feedback like this from customers like you.

However, there may be a way for you to programmatically move the annotations if they overlap each other.
Try this:
In the Annotation List Property, you can retrieve the position of an annotation label, relative to the annotation. If you know the annotation position, you can then determine the position of the annotation label with respect to the plot area.
Use a Case Structure to handle moving the position of these labels if you find that any of them overlap each other, i.e. the position of one label is equal (or almost equal) to another. The tricky part will be to determine what would be the best alternative position if you need to move an annotation label (assuming you do know the data points in the plot a priori). A simple solution: if you find that an annotation label overlaps another, I would try simply moving it 'n' points in the Y direction. This won't look as nice as your ideal solution, but at least you'll be able to see all labels clearly.

Let us know if you have any specific questions if you choose to attempt this. Moreover, if you've come up with an alternative solution, we would love to hear it.

Cheers,
Emilie K
National Instruments

0 Kudos
Message 2 of 6
(3,925 Views)
So I’ve gotten the Annotations to a ‘usable’ solution for our product. I ended up adding a lot of code to make the usability easier for the user and as fully featured as I could. I submitted a product suggestion form as well. I also documented it all in a word doc for you so look for the attachment with more graphs. I also have some example code I can provide for what I have done.

Improvements I’ve been able to account for:

Y offset to annotation label based on crosshair size
The first hurdle was to show the annotation in the correct position on the cursor. I had to first offset the annotation label by a factor based on the size of the crosshairs (I couldn’t have the annotation drawn right on top of the crosshair as default). So based on the Y scale factor of the plot, I always offset the annotation label in Y +/- an amount to offset it from the crosshair.

Label in + or – Dimension from the crosshair
Another issue is that the annotation label can be off screen based on the tight factors of the plot. If the data reachs the top of the graph, the annotation is lost because it is off the screen in the plot. So, based on the location of the point and the maxima of the Y scale markers, I can decide to offset the annotation label in the negative direction in respect to the crosshair. The graphs below help illustrate that.

Event Structure Code to automate replotting the visible Annotations
   
    Change Cursor color when it moves
    I allow the user to move the cursor so they can easily view the Y value. As you see in the graphs above, when a cursor is moved, I change it to black to note that the user changed its position and it is not the point chosen by the software.
    Redraw annotations when it moves
    When the cursor moves, I have to call my code to update the annotation label. This involves changing the annotation data/location, offset in terms of Y and the +/- flip.
    Zooming on a graph changes visible annotation labels
    When a user changes the scale factor by zooming in on the graph, the visible annotations should change. We may be able to view more or less Annotations so I chose to redraw them. Basically, the annotations are always setup when the data is drawn in the plot, but I make them visible or not.

Showing Annotations based on X, then Y
The difficult part of annotations was altering the location/offset for the label depending on the surrounding annotations. I first prioritize annotations based on the strongest peak first. The graph shows the annotations that fit within X. Then if it doesn't fit within X, show it in Y.

Other features out of my control that would make this better:
Allowable font and size for Annotation Labels.
Automatic visibility and location of annotation labels that can smartly move them slightly to account for crosshairs, surrounding annotations, using a line (not arrow) to point to the annotation location as seen in the graph below which is not from LabVIEW.
Auto redraw the annotations when changes made. I have to defer panel updates to force a redraw of the annoation labels because I get intermittent refesh issues with the labels. Note the 154.1, the 1 gets cut off. By clicking on the label, it gets refreshed, or dragging the window off then on screen.

Kevin Shirey | CLA | Champion | Senior Project Engineer II | DMC
0 Kudos
Message 3 of 6
(3,905 Views)
This is AWESOME, Kevin. Thank you for taking the time to provide this to the NI community. I'm going to make sure your Word .doc is included on the Product Suggestion associated to this topic.
If you have the VIs and you don't mind sharing them, I'd say go for it. I can't guarantee our developers will include any improvements to automatic-annotation-placement by the next release of LabVIEW, so until then, I'm sure other customers might benefit from the work you've already done.
Again, thank you for sharing this insight with us! We appreciate community members like you.
Cheers,
Emilie
0 Kudos
Message 4 of 6
(3,895 Views)

Kevin,

I have also noticed an issue of inconsistency of the graph annotations when you build an application (.exe).  When in the regular VI IDE, a graph annotation name is capable of being moved about by the mouse.  When I build my application, I can not move the name at all, just the actual crosshair annotation and the name moves with it. 

Do you know anything about this problem?

Matt

0 Kudos
Message 5 of 6
(3,593 Views)
Hi Matt,

I haven't noticed a lot of difference in the exe vs. vi behavior. Be sure that the 'locked' property is turned off for the Annotation. I ended up using a Cursor for the crosshair, and an annotation with no crosshairs just for the text. This way the text can be black and the crosshair can be red. however, when you do that, you have to use the Events to track when the cursor is moved and alter the location of the annotation text to follow the cursor. If the graph is on a tab, you may have to force a redraw by making the control invisible/visible after writing the data to the graph if you use multiple plots.

--Kevin
Kevin Shirey | CLA | Champion | Senior Project Engineer II | DMC
0 Kudos
Message 6 of 6
(3,579 Views)