Error in graph panel when displaying stacked series

Hi, was wondering if others have seen this when displaying stacked series using staircase mode.

The first picture is without “stack” option enabled and shows three “sprinkler zones” switching on for a period and then off. This looks as I expected.

But when I stack the series (to show more clearly multiple zones being on at the same time) then it incorrectly shows a diagonal “artifact” even though the previous zone still has a zero value.

It looks as though, the stacked graph is not adhering to the “staircase” option but rather just connecting the two graphical co-ordinates. The InfluxDb query is simply “SELECT status FROM “station” WHERE $timeFilter GROUP BY name_tag” with datapoints as either 0 for “off” and 1 for “on”.

Is this a known problem or something I’ve got wrong in the config ? I’m pretty new to this so appreciate any pointers.

that looks strange, try with fill(0) in your query and make sure the interval aligns

Torkel, Thanks for the response.

If I change the query to the following (I used fill(previous) rather than fill(0) as the previous state should continue until the next new measurement):

SELECT mean(“status”) FROM “station” WHERE $timeFilter GROUP BY time($interval), name_tag fill(previous)

Then I get the correct graph without the diagonal artefacts but only when viewing a relatively small time interval.

Unfortunately, aggregation works against me when I “zoom out” to view say a month’s worth of data. In that situation the time between my zone “on” and “off” events is less than $interval and aggregation returns an unhelpful average (i.e. neither “on” nor “off”). This value then gets repeated by the fill(previous) command until the next set of recorded measurements a few days later. You can see in the graph below that the green and yellow zones appear to be “on” for three consecutive days whereas in reality the zones are on for a few minutes every three days. Aggregation is blending out the “off” events.

I think this boils down to a conflict between the nature of a “binary sensor” (i.e. only two valid states) and the aggregation approach. Aggregation doesn’t really work for a binary sensor as the “mean” is not a valid proxy for that interval. Using min()/max()/sum() etc all have their own problems as they still effectively blend discrete states into one.

Hence, I am keen to see if my original query approach, which avoids aggregation, can be made to work. The graph in my original post can be replicated using the following query, test data and display options:

SELECT "status" FROM "station" WHERE $timeFilter GROUP BY "name_tag"

station,name_tag=Dicksonia status=1 1502969602361792700
station,name_tag=Dicksonia status=0 1502969662371432000
station,name_tag=Bamboo status=1 1502969714569562700
station,name_tag=Dicksonia status=1 1502969775969333000
station,name_tag=Dicksonia status=0 1502969837468813400
station,name_tag=Bamboo status=0 1502969895650165500

It does look as though the shading algorithm is incorrectly shading above the line rather than below in the diagonal section.

I am new to this so if I have got this completely wrong then apologies for taking up time.

You do not need to use mean, you can use last InfluxDB selector function instead