apexcharts-card icon indicating copy to clipboard operation
apexcharts-card copied to clipboard

group_by historical values are volatile/fluctuate (show different historical values - affected by time the chart is rendered)

Open d123456temp opened this issue 1 year ago • 7 comments

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. charts_20240111_133601 chart_20240111_215619 2024-01-10

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 avatar Jan 11 '24 21:01 d123456temp

@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

edwardhorsford avatar Feb 18 '24 15:02 edwardhorsford

+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).

  1. 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 is 1m and the current time is 10:21:48, align the end of the last bucket to 10:22:00
  2. ~Another option would be to overload the span option so that if you provide a start or end value that is less than the graph_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 thought span was for until I read it more carefully. E.g. if you provide a span.end value of 1m and it is less than the graph_span value of 30m, 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.

benkrejci avatar Apr 03 '24 14:04 benkrejci

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.

github-actions[bot] avatar Jun 03 '24 02:06 github-actions[bot]

Commenting to keep alive.

edwardhorsford avatar Jun 03 '24 09:06 edwardhorsford

There's no default alignment with bucketing, that's what end and start are made for.

RomRider avatar Jul 05 '24 16:07 RomRider