elastic-charts icon indicating copy to clipboard operation
elastic-charts copied to clipboard

Visual overlapping of annotation icon and vertical axis tick/label

Open dej611 opened this issue 3 years ago • 6 comments

Describe the bug

We use the annotation system to draw thresholds in Lens, and upon adding the Icon marker associated with the annotation, it was noticed that it is possible a collision of the marker with the vertical axis.

image

Kibana Cross Issues https://github.com/elastic/kibana/issues/112793

dej611 avatar Sep 22 '21 09:09 dej611

As of right now I believe we leave it to the user to set the value of the annotation gutter, if you will, such that it has the width or height it needs. This would be through theme.chartPaddings. Is this true @markov00?

In you case you are using the eui theme which removes the axes ticks making this collision more apparent.

I think we could improve this to be automatic in the future but there are cases like annotations outside and adaptive markBody that make it more difficult.

Screen Recording 2021-09-22 at 08 58 51 AM

nickofthyme avatar Sep 22 '21 14:09 nickofthyme

I made some experiments with annotation on the left/right/bottom axes tweaking some parameters.

Initial state with overlap:

Screenshot 2021-09-22 at 19 25 53

Here's using the chartPaddings parameter (better, but the axes should shrink together with the chart IMHO):

Screenshot 2021-09-22 at 19 27 18

Here's using the tickLabels.padding (better but the padding is applied in any direction around the label, not just between the label and the axis):

Screenshot 2021-09-22 at 19 26 32

dej611 avatar Sep 22 '21 17:09 dej611

Yes @nickofthyme, at the moment this is true, we don't automatically allocate space for the icon on the axis. Together with the nick workaround, I can suggest to move the icon to the opposite side of the axis to avoid collisions and to have a clean axis.

If you are in the bad situation of having a dual-axis chart (highly discouraged) is advised to keep the icon near the relative axis draw it inside the chart (better if placed on the top/bottom of the line annotation.

Remember that you can also use directly the value instead if just an icon as in the below example.

Finally you can also have the icon externally placed without adding the tickLabel.padding but using the tickLine:{size: sizeoftheicon, visible: true, stroke: 'transparent'} this will add a 'transparent' tick line that can be used in replacement of the tick padding.

Also another possibility, that doesn't fully resolve but can help reading the chart is to color the axis with the same color of the annotation line to improve, for non-color blinded person, the link between the axis and the annotation in a dual axis situation

Screenshot 2021-09-22 at 19 41 18

https://codesandbox.io/s/summer-browser-q4upn?file=/src/App.tsx

markov00 avatar Sep 22 '21 17:09 markov00

you can also use tickLabel: {padding: { inner: size_of_the_marker } } instead of tickLabel:{padding: size_of_the_marker}} to

markov00 avatar Sep 22 '21 17:09 markov00

you can also use tickLabel: {padding: { inner: size_of_the_marker } } instead of tickLabel:{padding: size_of_the_marker}} to

I think this one is the best tradeoff at the moment. Screenshot 2021-09-23 at 11 33 45

If you are in the bad situation of having a dual-axis chart (highly discouraged) is advised to keep the icon near the relative axis draw it inside the chart (better if placed on the top/bottom of the line annotation.

This is definitely an interesting idea and something we might consider given https://github.com/elastic/kibana/issues/112921

Also another possibility, that doesn't fully resolve but can help reading the chart is to color the axis with the same color of the annotation line to improve, for non-color blinded person, the link between the axis and the annotation in a dual axis situation

Screenshot 2021-09-22 at 19 41 18

This makes sense, but I doubt is compatible with a generic case where the user can have multiple annotations on the same axis with distinct colors as in our use case.

dej611 avatar Sep 23 '21 09:09 dej611

Managed to find a solution for all the various combinations (title + tick labels, title only, etc...) in this PR combining all the padding/margin parameters in the Axis component: https://github.com/elastic/kibana/pull/112952

dej611 avatar Sep 23 '21 12:09 dej611