# Can I define color range in Object

**URL:** <https://discuss.elastic.co/t/can-i-define-color-range-in-object/266095>\
**Category:** Kibana\
**Created:** [March 3, 2021, 11:35am UTC](https://discuss.elastic.co/t/can-i-define-color-range-in-object/266095 "2021-03-03T11:35:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [March 5, 2021, 4:17am UTC](https://discuss.elastic.co/t/can-i-define-color-range-in-object/266095/2 "2021-03-05T04:17:06Z")

</div>

I see that you are looking for conditional coloring in Canvas. There are few threads which discuss this in detail.See if it helps:

> [@Conditional colouring using kibana canvas expression editor](https://discuss.elastic.co/t/conditional-colouring-using-kibana-canvas-expression-editor/177929/7):
>
> @Catherine_Liu I have basically the same problem not with the font color but with the background color I have just one condition instead of two my approach is quite like the fist you gave to ksunil. I do a select count(\*) and if it is greater than 0 the backround should be green otherwise it should be red. The expression editor looks like below filters | essql query="SELECT \* FROM uacuser WHERE logintime \> NOW() - INTERVAL 1 MONTH AND disabled = 0" | math "size(userid)" | metric "Users logge…

and there is a GH issue as well

> <https://github.com/elastic/kibana/issues/35496>
>
> \*\*Describe the feature:\*\*
> As a Canvas users, I want to change the appearance of… an element based upon an underlying value. For example, set the metric font to red if a value under a specified threshold. 
> 
> \*\*Describe a specific use case for the feature:\*\*
> Whether I'm building a report or dashboard in Canvas, I may way want to emphasize a negative state by putting more visual emphasis on an element. This could be useful when there are a high level of negative occurrences (errors, security findings, etc.); likewise for positive occurrences. This could also be used for positioning, size, etc.
> 
> You can currently do this through the expression editor like so:
> \`\`\`
> demodata
> | math "unique(country)"
> | metric "Countries" 
> metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color={if {gt 10} then=red else=black} align="center" lHeight=48}
> \`\`\`
> 
> It is a question that comes up regularly which is why adding it to the UI (side panel settings) would be a nice way make this feature more discoverable. At first, it may simply be enough UI to handle two states that equate to an \`if then else\` statement. In the initial version, this could be visually assembled with some simple text inputs.
> 
> I can provide mockups, if necessary, when this is ready to be worked on.

Hope it helps  
Thanks  
Rashmi

cc @Catherine_Liu

---

_[View the full topic](https://discuss.elastic.co/t/can-i-define-color-range-in-object/266095)._
