Label overlap #880
-
Hi friends, I had an Idea for label overlay but I couldnt find the list of annotation elements where i can use x, x2, y, y2. Is There some way to get ALL elements ? So i can use the x/y coordenates to know If one element is overlapping another one. Thanks for ur time |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@jlindoso see the discussion: #750 (comment) The "state" of the plugin is containing all annotation elements (both visible and not ones). Nevertheless, can you share your idea? Maybe there could be another way to do it? |
Beta Was this translation helpful? Give feedback.
-
For anyone dealing with this in react.... this solution works across the board. Probably also works in non react envs Put it in your plugins.
Checks all labels for overlap and updates x/y coordinates as needed. At the end, it draws the chart. The afterUpdate hook is SUPER important here. If you use after or before draw you will get stuck in a maximum stack error. afterLayout does not work. I think this algo can be optimized so bear with it lol. |
Beta Was this translation helpful? Give feedback.
Interesting! In this case have a look to #869
If Pr will be accepted and merged, new ‘elements’ field of the context will be available with all visibile elements.
This will solve the missing API and you could implement your logic for label overlapping.
What do you think?