Color coding bar metric

Hey there.
I am currently setting up a dashboard with some bar diagrams.
It is possible to set different colors for entries. But is it also possible to have a wildcard in the selection?


For example, having anything starting with "SMP" in one color?
"SMP*", would be my first guess, but it doesn't seem to work.

Is there another solution?

Hello @Simon_Thies

Welcome to the community!!

In Lens I was not able to use the color as Men's* or Women's* , same issue as you reported.

As a work around I did below to use the color in it is helpful :

For my current field say category.keyword, i had above values.

Using below runtime field I divided the data into required categories of color example Men's & Women's

if (doc['category.keyword'].size() != 0) {
  def val = doc['category.keyword'].value;
  if (val.contains("Women's")) {
    emit("Women's");
  } else if (val.contains("Men's")) {
    emit("Men's");
  }
}

Then since now there are only 2 values for my new field , I have applied the color on this new field category_runtime & same is available on the chart.

Thanks!!

Hey, thanks for your reply.
The solution indeed looks nice, but I can't figure out, where to set a runtime field.

Hello @Simon_Thies

For the index , if you have configured a data view so going to Discover using below option can add a runtime field :

Thanks!!

Hi @Simon_Thies

while it is not possible to apply partial matching to the Lens color mapping feature, I've found a close feature request you could track for it here: [Lens] Improve color assignment UI for multi fields · Issue #202822 · elastic/kibana · GitHub

1 Like