# Set bar color depends on field value

**URL:** https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818
**Category:** Kibana
**Created:** [March 27, 2018, 8:38pm UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818 "2018-03-27T20:38:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Tomasz\_Szandala](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@Tomasz\_Szandala](https://discuss.elastic.co/u/Tomasz_Szandala)
#### Post date: [March 27, 2018, 8:38pm UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818/1 "2018-03-27T20:38:46Z")

</div>

Greetings,  
I have vertical bars visualisation, that show duration of software compilation steps (X-axis are steps, Y-axis is duration). I would like to set GREEN color, when field "success" is true and RED on opposite.  
I I assume I have to do it with JSON input but I canno find any example

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 28, 2018, 3:02am UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818/2 "2018-03-28T03:02:05Z")

</div>

Are you just looking for a way to customize the colors for the data series? You can do that in the legend:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/7/079bea609deedd703b951bb97a18d1891d10ca10.png)

---

<div class="post-metadata">

### Author: ![Tomasz\_Szandala](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@Tomasz\_Szandala](https://discuss.elastic.co/u/Tomasz_Szandala)
#### Post date: [March 28, 2018, 5:42am UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818/3 "2018-03-28T05:42:20Z")

</div>

No, something like this: ![success_or_not](https://us1.discourse-cdn.com/elastic/original/3X/6/3/631f251cca39740c1ecc73eec9feb2a99645df16.png)

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [March 28, 2018, 5:20pm UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818/4 "2018-03-28T17:20:24Z")

</div>

Sure, you can make the x-axis aggregated by `terms`, choose the field that has the A, B, and C as the term, and split the series by another terms aggregation, choosing the field that has the `true` and `false` as that term.

You can also change the bar chart from stacked (default) to "normal" to get everything as multiple bars per term.

## Aggregations:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c915970bb26902ee6b3c273e40bb7040b1c9f0b7.png)

## Select normal mode for the metrics mode:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0c0ff8c31ccc74e36c92bb32990d06f024dbdcb2.png)

Then pick the colors in the legend as I showed in my first response: a red for false and a green for true.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 25, 2018, 5:20pm UTC](https://discuss.elastic.co/t/set-bar-color-depends-on-field-value/125818/5 "2018-04-25T17:20:27Z")

</div>

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