apexcharts-card
apexcharts-card copied to clipboard
group_by historical values are volatile/fluctuate (show different historical values - affected by time the chart is rendered)
Checklist
- [ x] I updated the card to the latest version available
- [ x] I cleared the cache of my browser
- [ x] I verified that I'm really running the lastest version in my browser console
- [x ] I checked if there is another issue opened with the same problem
Describe the bug Depending on the time (during the day) when I run/display the chart card, the historical chart entries are different. See the attached screenshot of the same bar chart top left of the screenshot - every time the values shown are different. What I noticed is that the popup shows date and time and the time part equals to the time of the rendering. Yes, I'm sure the data are not altered, the only thing that fluctuate is the rendered bar chart.
See chart definition below.
Version of the card Version: latest release
To Reproduce This is the configuration I used:
- type: custom:apexcharts-card
graph_span: 10d
update_interval: 1d
header:
show: true
title: Person count
series:
- entity: sensor.zoom_person_count
type: column
name: zoom
group_by:
func: sum
duration: 1day
- entity: sensor.second_person_count
type: column
name: fixed
group_by:
func: sum
duration: 1day
Screenshots
If applicable, add screenshots to help explain your problem.
Expected behavior Historical data presentation should be stable and exactly the same no matter when chart is rendered.
Desktop (please complete the following information):
- Browser Firefox
- Version 120.0
@d123456temp I came across it too - I agree it's not ideal. If not default, it would be good if the group by had an option to align to some period that relates to the group duration.
As a temporary solution, if you set a start or end time, that 'pins' the grouping to that period.
Example:
span:
end: hour
+1
It's hard to imagine a use-case in which this is the desired behavior for grouping (align the buckets to the current time, rather than a static value that would be stable over time).
- One option would be to always align the last bucket end to the soonest future multiple of the
group_by.duration(if the series is grouped). E.g. if the duration is1mand the current time is 10:21:48, align the end of the last bucket to 10:22:00 - ~Another option would be to overload the
spanoption so that if you provide astartorendvalue that is less than thegraph_span, you would get this behavior of snapping the start/end of the graph to the nearest multiple of the provided span value. This is actually what I thoughtspanwas for until I read it more carefully. E.g. if you provide aspan.endvalue of1mand it is less than thegraph_spanvalue of30m, then the whole graph would just line up to the nearest minute.~
Update: I had tried the span.start and it did not produce a desired result, but hadn't tried span.end. I Agree with @edwardhorsford that somewhat counterintuitively, this does do what I want. I still think maybe the default bucket alignment for grouped series should be updated.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.
Commenting to keep alive.
There's no default alignment with bucketing, that's what end and start are made for.