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: 

Problem to fit Y position annotation label Offset, help!

Solved!
Go to solution

Hello,

I am using histogram to draw several values and I want to use annotations to show the value of each bar.

I fit the Y scale to have space for the annotation value using the max value of data. But I can't fit the label offset to have same free space in all the bars. If you see the attached file, you can see the numbers cover the bar and they dont look ok. Do you know any way to fit to get all the values annotations with the same free space with the bar?.

 

Thanks for all.

Fred.

 annotation.png

0 Kudos
Message 1 of 10
(2,999 Views)

Set the label offset to 0,1 for all, it will do the trick.

 

edit: Set the y offset value to a smaller number to have the annotation closer to the top of the bar.

 

Ben64

0 Kudos
Message 2 of 10
(2,986 Views)

Hi Ben,

Thanks for reply!.

Yes, I can to play with the closer value, but It is only one example. I use 7 histograms and its part of one sub-vi the values will vary. I need any way to programmatically fit the y offset value. It seems no sense.

Sometimes with 2 is ok all the values, if its > 10 i need 3... i dont understand.

0 Kudos
Message 3 of 10
(2,969 Views)

I don't understand the issue, the offset is relative to the top of the bar. If the bar height change the distance between the top of the bar and the label stays the same. Why does it sometimes need to be different?

 

Ben64

0 Kudos
Message 4 of 10
(2,955 Views)

Ben,

No, You can check in the example vi. Change the input values and you will see that with diferent values the gap between label and bar is not the same.

annotation2.png

 

Upper example, the first value is 15, and the offset label is 2. You can see is no look good. In the bottom example, with value 9, the same offset label and show good.

0 Kudos
Message 5 of 10
(2,947 Views)

There are many things wrong with your code and you are doing this way too complicated.

 

  • To add an offset to the label, you would use addition, not multiplication.
  • A plain waveform graph is sufficient, since the x values are equally spaced. No need for an xy graph.
  • If you use a spaced bar plot style, you don't need to interlace zeroes.
  • If you would normalize the data to [0..1] Things get easier. You can still annotate with the original values.
  • You only need to bundle the values that differ. All others can be set in the cluster diagram constant once.

 

Here's a quick example. Modify as needed.

 

 

Download All
Message 6 of 10
(2,942 Views)
Solution
Accepted by topic author Fonsi

Of course if certain elements are constant (e.g. the number of bars) many properties need to be written only once before the loop. Here's the code in action using generated random data.

 

 

Download All
Message 7 of 10
(2,930 Views)

thank you so much, altenbach!.

You are the man, it works very good. You are right my design was very complicate.

Yes I use a fixed value of 10 bar. I put  interlace zeroes to do the bars thinner. So the number of annotation is more clear. But your code is better and easier.

Thank a lot!.

Fred

0 Kudos
Message 8 of 10
(2,924 Views)

Fonsi wrote:

Yes I use a fixed value of 10 bar. 


Then just make the y scale from 0..14 and add 2 for the offset. No need to divide by the max. (might need to fine tune based on the exact font size).

0 Kudos
Message 9 of 10
(2,906 Views)

Ok, thanks for help!.

Fred

0 Kudos
Message 10 of 10
(2,899 Views)