Rules for annotation position?

29 views
Skip to first unread message

JENNIFER WOODSON

unread,
Jan 8, 2019, 5:11:00 PM1/8/19
to Google Visualization API
Are the rules for positioning/placing annotations on bar charts documented anywhere? Specifically, on a stacked bar chart, what are the rules Google uses for positioning an annotation when the annotation is wider than the bar? If a bar is not wide enough for the annotation, Google moves it. I'd like to know the rules for this and how to circumvent them.

I'm using a mutation observer to center annotations on the bars of a stacked bar chart (see this StackOverflow post). This works well, except for when a bar is not wide enough to fit the annotation. When Google moves the label, it collides with the next one. I'd like to override Google's defaults to prevent annotations from overlapping.

Daniel LaLiberte

unread,
Jan 8, 2019, 8:47:32 PM1/8/19
to Google Visualization API
Hi Jennifer

The implicit rules for deciding whether to move an annotation out of the bar are based on whether it can fit inside the bar, and there is no override to force it to draw inside the bar regardless.  

The collision between annotations is unfortunate, and I have been working on strategies for automatically moving annotations around so they avoid collision.  I'm not sure when that will be available.

Your best workaround might be to make all the annotations smaller, if that works at all.  

On Tue, Jan 8, 2019 at 5:11 PM JENNIFER WOODSON <jennifer...@dpsk12.net> wrote:
Are the rules for positioning/placing annotations on bar charts documented anywhere? Specifically, on a stacked bar chart, what are the rules Google uses for positioning an annotation when the annotation is wider than the bar? If a bar is not wide enough for the annotation, Google moves it. I'd like to know the rules for this and how to circumvent them.

I'm using a mutation observer to center annotations on the bars of a stacked bar chart (see this StackOverflow post). This works well, except for when a bar is not wide enough to fit the annotation. When Google moves the label, it collides with the next one. I'd like to override Google's defaults to prevent annotations from overlapping.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/8718df8b-6812-4174-8bb2-979ee2b862d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

JENNIFER WOODSON

unread,
Jan 10, 2019, 10:51:31 AM1/10/19
to Google Visualization API
Hi Daniel,

Thank you for your response. I can adjust the size some, but not enough to fix the issue. 

Is there anything you can tell me about how far the annotations are moved when they don't fit inside the bar? i.e., can you tell me anything about how the offset is calculated?

I'm already manipulating the x coordinate, but it gets shifted when it doesn't fit inside the bar. I don't mind to do a little more math to get the label where I need it, and any information about how and where the annotation is moved would help with precision.

Thanks,
Jennifer


On Tuesday, January 8, 2019 at 6:47:32 PM UTC-7, Daniel LaLiberte wrote:
Hi Jennifer

The implicit rules for deciding whether to move an annotation out of the bar are based on whether it can fit inside the bar, and there is no override to force it to draw inside the bar regardless.  

The collision between annotations is unfortunate, and I have been working on strategies for automatically moving annotations around so they avoid collision.  I'm not sure when that will be available.

Your best workaround might be to make all the annotations smaller, if that works at all.  

On Tue, Jan 8, 2019 at 5:11 PM JENNIFER WOODSON <jennifer...@dpsk12.net> wrote:
Are the rules for positioning/placing annotations on bar charts documented anywhere? Specifically, on a stacked bar chart, what are the rules Google uses for positioning an annotation when the annotation is wider than the bar? If a bar is not wide enough for the annotation, Google moves it. I'd like to know the rules for this and how to circumvent them.

I'm using a mutation observer to center annotations on the bars of a stacked bar chart (see this StackOverflow post). This works well, except for when a bar is not wide enough to fit the annotation. When Google moves the label, it collides with the next one. I'd like to override Google's defaults to prevent annotations from overlapping.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

Daniel LaLiberte

unread,
Jan 10, 2019, 11:17:00 AM1/10/19
to Google Visualization API
If you use the annotations.alwaysOutside option, you'll see where annotations end up when they don't fit inside the bar.  

I'm not finding any explicit padding for when the position of the annotation is outside the bar, so I believe it is just based on the font size and the number of lines of annotation text, such that the bottom of the text is just above the top of the bar.   For the inside position, there is a hard-coded minimum margin of 2 pixels between the top of the bar and the top of the annotation text.

On Thu, Jan 10, 2019 at 10:51 AM JENNIFER WOODSON <jennifer...@dpsk12.net> wrote:
Hi Daniel,

Thank you for your response. I can adjust the size some, but not enough to fix the issue. 

Is there anything you can tell me about how far the annotations are moved when they don't fit inside the bar? i.e., can you tell me anything about how the offset is calculated?

I'm already manipulating the x coordinate, but it gets shifted when it doesn't fit inside the bar. I don't mind to do a little more math to get the label where I need it, and any information about how and where the annotation is moved would help with precision.

Thanks,
Jennifer

On Tuesday, January 8, 2019 at 6:47:32 PM UTC-7, Daniel LaLiberte wrote:
Hi Jennifer

The implicit rules for deciding whether to move an annotation out of the bar are based on whether it can fit inside the bar, and there is no override to force it to draw inside the bar regardless.  

The collision between annotations is unfortunate, and I have been working on strategies for automatically moving annotations around so they avoid collision.  I'm not sure when that will be available.

Your best workaround might be to make all the annotations smaller, if that works at all.  

On Tue, Jan 8, 2019 at 5:11 PM JENNIFER WOODSON <jennifer...@dpsk12.net> wrote:
Are the rules for positioning/placing annotations on bar charts documented anywhere? Specifically, on a stacked bar chart, what are the rules Google uses for positioning an annotation when the annotation is wider than the bar? If a bar is not wide enough for the annotation, Google moves it. I'd like to know the rules for this and how to circumvent them.

I'm using a mutation observer to center annotations on the bars of a stacked bar chart (see this StackOverflow post). This works well, except for when a bar is not wide enough to fit the annotation. When Google moves the label, it collides with the next one. I'd like to override Google's defaults to prevent annotations from overlapping.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages