Conditional colouring using kibana canvas expression editor

@ScottBarnes @sharonva You can't conditionally change the color of the background, because sub-expressions in the render function receive a render object as context and tries to compare your conditional expressions to the render object.

The simple way around this is to add a separate shape element that serves as a background element hooked up to the same datasource where you have access to your datasource to conditionally render the color of the shape.

Another solution would be to pipe the same datasource into the beginning of your conditional sub-expression.

For example:

...
| render containerStyle={
     containerStyle backgroundColor={
       filters | demodata | math "sum(price)" | if {gt 50} then="red" else="green"
     } 
  }
2 Likes