One datapoint with different colours depending on value

Dear all,

i tried now many ways but i am always stuck !

I have a temperature measurement which i easily want to change the colour with values below 0°C!
Below it should be blue and greater than 0°C it should be green.

I condigured two times the same value with different WHERE clauses:
SELECT last("value") FROM "MyDatapoint.w_temperatur" WHERE ("value" > 0) AND $timeFilter GROUP BY time($__interval) fill(null)

The second one accordingly
SELECT last("value") FROM "MyDatapoint.w_temperatur" WHERE ("value" <= 0) AND $timeFilter GROUP BY time($__interval) fill(null)

This is working very well but the curve looks very disaapointing because it is not lined the datapoints. Just the values:

I tried already the function fill(previous) BUT then a get flat lines for the values that doesnt match the WHERE clause - so also not nice !

Anybody how has an idea how i can solve this issue for in my opinion very easy example ?

IMHO you have unrealistic expectations.Grafana can’t set colour per datapoint, only per time series (series of datapoint). You have divided your original time series into 2 time series ("value" > 0 and "value" <= 0) and configured different colours correctly.

You can may “smooth” graph with MEAN function (I’m not sure why you have used LAST) and then eventually create more granular graph - don’t use default $__interval macro, but define own time grouping - e.g. 1m, 5m, 15m - whatever fits your needs and sampling frequency. You can also use subquery and use inner query only to fill missing datapoints.

Hello,
okay I tried it and have to use time(1h). But doesn’t that mean that the values are now shortened and do not see any longer the real (last or max) values ?
Also I only can make < and > and >= not so I have it empty all there where it is zero:

InfluxDB documentation is a good start to understand InfluxDB, e.g. how time grouping works in your case - https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#group-by-time-intervals-and-fill

Okay, thank you I got it working somehow - maybe I workaround but I put independently if the value changes a datapoint in the DB every minute so that I can use time(1m).

Works fine for me.

There is only one point missing !
I have now shown values >0 and values <0 so I have an empty spot exactly when the value is 0.

Why I can’t use greater or equal than like >= or => ???
Both is not working.
How do i do it ?

MacGyver tip:
Draw a full green graph with z=-1 value and after draw a limited blue graph with z=1 value front of green.

1 Like