Visualize Library - Pie chart

Hi everyone,

I have a pie chart which shows percentage of two values (Success or Failure) count. I want to filter for example If sum of count greater then 1000, Then show me the pie chart otherwise not. How can I provide that?

The problem is, For example 5 request failing and 5 request success, It gives me %50 success percentage. But thats not problem for us and I do not want to see pie chart If total count size less then 1000

image

Thanks,

I don't think there is a mechanism to conditionally show visualizations in Kibana. Maybe you can achieve that with Vega and its condition property, but I'm not that proficient in the component, so there's a chance I'm not right, sorry.

Also, feel free to create a Feature Request in the Kibana tracker with as much detail as possible on your use case.

we have this enhancement here - It sounds similar so i'll put a reference to this post [Lens] Allow client-side bucket filtering of numbers by selecting the visible number range · Issue #86190 · elastic/kibana · GitHub

1 Like

I think in Lens it may be possible to do something.

Maybe this is a long stretch of the Lens Formula feature, while waiting for the conditionals support in it, you can model the problem this way:

ifOverThousandOutputOne( overall_sum(count()) ) * overall_sum(count())

The ifOverThousandOutputOne is an hypothetical function we can model this way:

  • if the overall_sum(count()) minus X (in your case 1000) is above 0 output 1
  • otherwise output 0

One way to model this hypothetical function is to use the clamp math function:

clamp( overall_sum(count()) - 1000, 0, 1)

The clamp function will return a value between 0 or 1 in this case, but what it is used here is to return 0 for all those values below 1000 ( 5 - 1000 = -995 which be clamped to 0). If you have values between 0 and 1 there are still some tricks available, but if you working with count() do not worry that they are all integers.

At this point the full formula can be:

clamp( overall_sum(count()) - 1000, 0, 1) * overall_sum(count())

Some examples here for overall_sum(count()) as 5 and 2000:

clamp((5 - 1000), 0, 1) * 5 => 0
clamp((2000 - 1000), 0, 1) * 2000 => 2000

Of course you can replace overall_sum(count()) with any other function you like.

The resulting chart will be a little bit misleading in case of <1000, but a good title may mitigate that - as all slices will have a 0 size:

Would that help?

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