Canvas progress wheel conditional color based on negative values?

Hi,

I am building a dashboard for solar energy monitoring. One of the metrics is showing if you are consuming energy from grid (positive values) or feeding energy into grid (negative values). I want to change the color of progress wheel based on this but it doesn't work with negative numbers.

Basically what I want to do is

filters
| essql query="SELECT last(GridPowerConsumption) as gpc FROM solar"
| math "gpc/30000"
| progress shape="wheel" label={formatnumber "0%"} valueColor={if {gte 0.0} then="red" else="green"}
......

Any chance to make it work?

I guess it would be nice to have wheel progressing in the opposite direction if the value is negative.

In the expense of doubling the queries, I can get it to work but I dont think this is the best way:

filters
| essql query="SELECT last(GridPowerConsumption) as gpc FROM solar"
| math "abs(gpc/30000)"
| progress shape="wheel" label={formatnumber "0%"} valueColor={filters
| essql query="SELECT last(GridPowerConsumption) as gps FROM solar"
| math "gps" if {gte 0.0} then="red" else="green"}
......

ES uses a cache for queries, so there won't be that much of perfomance hit on the cluster, and as long as that solution does what you want, it should be fine.

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