Showing values in a graphic bar

Hi! I'm really new to Kibana and Elasticsearch, but I'm trying to visualize data in a specific way that might be difficult.

I'm trying to set up two things:

  1. I want to establish a threshold. For example, if any column has a value less than or equal to 2, I want it to be red.
  2. I want to place the name of the label near the column, just to clarify what the label is so I don't have to check the legend constantly.

Is this possible?? Thank you for reading!!

Welcome!

Well, you could do very mad things with Kibana Lens nowadays, thanks to the awesome Kibana teams...

Using Formulas instead of Quick Functions:

For example, the "pink" part of the bar has the following formula:

(
    average(marketing.cars) - 
    overall_average(average(marketing.cars))
) 
    *
(
    clamp(
        average(marketing.cars) - 
        overall_average(average(marketing.cars)), 0, 1)
)

And the green part has:

average(marketing.cars) - 
(
  clamp(
    average(marketing.cars) - overall_average(average(marketing.cars)),0,1)*(average(marketing.cars)
   -overall_average(average(marketing.cars))))

Hard to understand may be but that could give you some ideas on how to build what you need.

Thank you for your answer! I didn't know I can make all of these in Kibana. However, I think that my question is more specific about visualization. I really dont know how I can make a column change depending on its value.

Could you clarify with an example? Is that the same need as expressed before:

I want to establish a threshold. For example, if any column has a value less than or equal to 2, I want it to be red.

If so, I think I answered with a solution.

I mean, I might be not understanding what you've said. I have some columns, each of them is a value, not depending on anything. The values I'm working with are like that. So now, what I want is to color that specific column depending on that value.

In the example that you have provided, you have a the number of cars pero year, so it's simple because you have the same data and you can do what you are saying.

I'm not sure if I can do what I'm trying to explain.

Thank you a lot and sorry for the problems


These are my columns.

Indeed. As you don't have a X axis, I don't think my solution is possible.

And I don't see how you can do it with Lens. So my guess is that the only workaround is by using Vega.

It's a bit harder as it requires some code but you can do almost whatever you want with it.

It is technically possible to do so, leveraging Lens formula, similar to the way @dadoonet showed before.
But I would recommend 1 metric per chart probably there:

What I've done here is basically define 2 formulas based on a threshold of 1000:

  • Above 1000: is a formula that sets any value above 1000 to its value, or 0 otherwise => ifelse( average(value) >= 1000, average(value), 0)
  • Below 1000: is the same formula but the 2nd and 3rd arguments swapped: ifelse( average(value) >= 1000, 0, average(value))

Then you can set the color per metric as I did in the picture above.
Choosing a stacked vertical bar would make the trick (as 0 int he ifelse would work as a filter between the two metrics).
Of course you could define 2 formulas per metric, but it would be not super manageable.

1 Like

I guess this works because you have here a X axis... Which is not I think what @juandres117 has in this dataset... ::wink:

The concept is still there. Just need to create a layer per metric type and reproduce the same logic

To explain:

  • for each layer define a Filter defined as * with the label of the metric
  • define the 2 formulas for the given metric

This way the horizontal axis is "simulated" and the trick would work.

The only problem would be the legend, which will contain duplicates, but I've hidden it for now.

1 Like

Ha! That's smart! :blush:

Thanks everyone for the answer I think that I've already got it. However, and last question, do you have a good Vega tutorial there?

I have to be sure, so sorry to bother. What do yo mean by a filter defined as *?

Here's a Lens filter as horizontal axis value:

In your case a Filter is just a way to simulate an axis, so defining it as * (match all) works fine as long as a custom label is used for each layer.

Doing like that and putting the formula that you explained me:

ifelse( average(activism.rateValue) >= 1, average(activism.rateValue), 0)

I'm getting an error saying that:
The Formula ifelse( average(activism.rateValue) >= 1, average(activism.rateValue), 0) cannot be parsed

Do you know this?

It looks like you are on an older version of the stack.
What's the version of Es/Kibana?

The ifelse has been introduced in version 8.6.0.

There it is, kibana is in 8.4.3. I should change the version to do this? Or is anyway of getting it done here?

Without ifelse you can approximate a boolean evaluation behaviour with clamp as @dadoonet wrote earlier on.
But it's hard to grasp, and upgrading would bring more nice features in general.

1 Like

And also upgrading will help you to get all the security patches that has been added in the meantime.