LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

annotation X position, what am I doing wrong

Hi,

I've been wrestling with this for the past couple of days and am hoping someone can shed some light for me.

 
I have an applicatoin where I am acquiring data for hours, and have code automating placing of annotations at certain events, for post-analysis purposes.   My code uses the annotation mode "1", which is single plot.  I chose this because the annotation snaps nicely right on the graph at the location I want.  However, the annotation label does not appear to be behaving as advertised in the help file.  I am wiring the "index" property of the annotation to the "sample" number of our data we are graphing.  Looking at the "Annotation List Property" in the help file, it reads the the Label Offset:X property is "The X coordinate of the label position, relative to the annotation.".  Well, when I set the X to offset 0, the Label seems to always stick to the very left of the graph.  So, in fiddling around trying to get the label X to match the Annotation X, I wired the current sample index to the Label Offset:X.  This seems to do the trick, at first.  After acquiring for some time, it becomes apparent the the label is slowly becoming more and more offset from the annotation, to the RIGHT this time.  After a period of  hours, it becomes quite exhaggerated as you can see by the attached image, to the point of the label becoming next to useless, because it is so far removed from the annotation position as to make it difficult to associate label and annotation.  One thing to note however, is that for a time during the long acquisition, the label appeared correct, right over the annotation, then on subsequent annotation the behavior went back to the label being far off to the right, more and more as time goes by.

So according the help file, I would think that I could wire the x label offset to 0, and the label should always appear in the same X as the annotation (whose index is the current sample value).  But this is not the case as you can see by the attachment. 

I have seen the other post regarding someone elses problems with the Y positon, and have played around with changing the annotation mode to "0" (free), defining the positions, but I ran into the same problem of the label being stuck on the left, and the same behavior as above when wiring the index to the X label offset. 

So, if I want to keep using an annotation mode of "1" (single plot), what is the secret to getting the annotation labels always above the annotations themselves?

Any insight much appreciated.

David Jenkinson
0 Kudos
Message 1 of 38
(5,877 Views)

Also here are a couple images of the code for each case....

 

Thanks

David J.

Download All
0 Kudos
Message 2 of 38
(5,870 Views)
Also one more, here is what I am getting after several  hours....attached.  This is when wiring the X offset to the "index" of the annotation.
0 Kudos
Message 3 of 38
(5,850 Views)
What version of LV are you using?  I have used Label Offset.X several times in LV 8.2.1 and it works exactly as you hope it would (0 offset keeps the name centered over the point).  With the sample index, you are just giving it an ever-increasing offset.  With 0 offset, it is hard to tell from the pictures what is wrong (seems ok to me).
0 Kudos
Message 4 of 38
(5,844 Views)

I am using LV 8.5.1.  Take a look at the attached image "Graph Display - Zero as X offset.png".  That is what I am seeing when I use 0 offset for x.  What are your other annotation settings?  I attached another image "annotation defaults.png", and am only programmatically changing the X and Y label offset, index, visible, and name from those defaults (see the LV diagram image "Code - Zero as X offset.png").  I am changing the y offset to 100 also, to get the text a little above the annotation away from the data so the arrow can point down to it.

 

I'd be interested in knowing what default annotation settings you are using.  Is it possible to post an image of  your default settings?  

 

Thanks

David J.

0 Kudos
Message 5 of 38
(5,841 Views)
I don't have the VI on the machine I am sitting behind now, but the settings would be the ones you seem to be using.  Mode 1 with some y offest to move the name up and 0 x offset.  I can't explain what is happening in your pictures.  My next step would be to double check (via a probe or indicator) your AnntList just to make sure it agrees with what you think you are writing.  You could also allow dragging and watch the list as you drag some of the annotations around.
0 Kudos
Message 6 of 38
(5,824 Views)

Very weird.  When checking the content of 2 annotations themselves after inserting them with a label offset X of 0 and Y of 100, The annotation offsets in the annotation list are mysteriously changed to:

 

 Label offset X,Label offset Y

3.48471,100.618

 -5.49587,100.214

 

And the appearance is the labels are railed up against the left of the graph, with the annotation itself properly placed.

 

I did discover something though.  In my graph, I am setting Xscale.Multiplier to .05, because we are acquiring data at 20Hz.  When I hardcoded the multiplier to 1, annotations begin behaving as expected, with them perfectly aligned above the annotation.  So there is an interaction with Xscale.multiplier and Label Offset x which I can't seem to figure out the rhyme or reason.  I see there is a Xscale annotation property, but it takes only integers, and when I try to set it to 20, I get an "out of bounds" error of some sort.  I am thinking this may be time to call support.

 

 

0 Kudos
Message 7 of 38
(5,759 Views)

I have always scaled the data instead of the axis, which you could probably do.  Just for fun, try the following:

 

Label Offset.X = Index * (1 - Xscale.Multiplier)

Message 8 of 38
(5,744 Views)

Very interesting Darin, I think you may have hit on something, although I am a bit confused as to why.  Can you explain?  I had previously hardwired the x offset to the index, but did not subtract from 1 first.  It appeared to work ok at first, but I got the effect of the annotation slowly walking off to the right over a very long duration (24+ hours).  I am going to run my long test to make sure the annotations behave with this new method.  Thanks very much for your input. 

 

I have also opened an issue with phone support and am interested what they have to say.

 

 Regards,

David J.

0 Kudos
Message 9 of 38
(5,726 Views)

I wish I could tell you that I applied my LV Ninja skills and immediately struck upon the answer.  However, it was more of a SWAG (stupid wild-a* guess).  I knew the index was involved from your original picture, but there was still another number in play.  I have never scaled an axis, so that didn't occur to me until you mentioned 0.05.  At that point I figured the offset was either 0.95*Index or 1.05*Index and the original picture showed that 1.0*Index was too much, so it had to be 0.95 or (1 - 0.05)*Index.

 

Probably not the intended behavior by NI, just one of those cases they missed until now.  Fortunately in this case there seems to be an easy work-around.

Message 10 of 38
(5,719 Views)