Label alignment with two layers (7.15.0)

I have a lens visualization (in version 7.15.0) where I want bar chart showing "Closed" vs "Not closed" where I color "Closed" with green and "Not closed" with red. To be able to set different colors for the bars I use two layers, but the thickness of the bars is halved causing the alignment of the labels to look weird.

Is this a bug or am I doing something wrong?

Hi @tomhe ,

welcome to the Kibana community.

I think you can achieve what you want with a single layer in Lens, with filtered metrics. Here I've used the extension.keyword with "css"/"deb" instead of your Closed/Not closed categories, but the same result applies.

On the "Horizontal axis" you can filter a metric as shown here (click Add advanced options):

Is this what you were looking for?

Yes, that's what I'm looking for. You're right in that I don't need two layers for this.

The alignment is actually correct and the empty space refers to a bar with zero hits.

The trick is to switch to stacked bars.

Bar horizontal:

Bar horizontal stacked:

Going with stacked bars moves the "empty" bar to the end (or beginning) of the bars.

Thank you!

My only problem now is that I prefer to have the number inside the bars like this:


But showing the numbers inside the bars like that is not possible for stacked bars:


So either I can have my color coding or I can have the numbers.

Well, well.

Oh right.
There's an issue for stacked bar you can track for value labels: [Lens] Display total value on top of each bar in the vertical bar chart · Issue #55262 · elastic/kibana · GitHub

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.