I have a few data streams that display percentages, but I can’t get it neatly into a stacked bar chart.
can someone help please?
so what I want to achieve is a bar chart, which shows the percentages per day. which can go up to 100% in total.
from(bucket: "home_assistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "%")
|> filter(fn: (r) => r["friendly_name"] == "Android Auto ratio" or r["friendly_name"] == "Zone basicfit ratio" or r["friendly_name"] == "Zone thuis ratio" or r["friendly_name"] == "Zone werk ratio")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["domain"] == "sensor")
|> filter(fn: (r) => r["entity_id"] == "android_auto_ratio" or r["entity_id"] == "zone_basicfit_ratio" or r["entity_id"] == "zone_thuis_ratio" or r["entity_id"] == "zone_werk_ratio")
|> aggregateWindow(every: 1d, fn: last, createEmpty: false)
|> yield(name: "last")
but the result is like this, but that’s strange because some days are 100% for one sensor. which is not correct:
Hello @JBoesh,
I’d suggest trying to change the visualization from graph to bar to start.
You can also click the customize button and get some more options there that might help.
I’m not sure why you’re not getting the data you expect.
Please note that aggregateWindow() aggregates data in 1d intervals using the Unix epoch (1970-01-01T00:00:00Z UTC) as the start.
You can have aggregateWindow start grouping intervals based on the start date with this:
For me to help you further I ask that you add a limi(n:20), delete the aggregatewindow function, and share the CSV output here please.