Skip to content

Fix real-time graph updates: skip inconsistent cases and rescale the Y axis - #3437

Open
Salvialf wants to merge 4 commits into
developfrom
fix/history-graphUpdate-guards
Open

Fix real-time graph updates: skip inconsistent cases and rescale the Y axis#3437
Salvialf wants to merge 4 commits into
developfrom
fix/history-graphUpdate-guards

Conversation

@Salvialf

@Salvialf Salvialf commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

graphUpdate was adding real-time command values to charts unconditionally, without checking whether the chart was in a state where a raw value would actually make sense.

Three cases where this breaks the display:

  • Comparison mode: the reference and comparison series share the same command id. A real-time update was applied to both, even though the comparison series represents a fixed past period and should never receive a "now" value.
  • Grouped charts (groupingType, e.g. sum/average per hour or day): the historical series only contains already-aggregated points (computed server-side via SQL GROUP BY). A real-time update inserted a raw instantaneous value in the middle of these aggregates, creating an artificial spike or drop.
  • Derived/variation charts (derive): the historical series shows the difference between consecutive values, also computed server-side. A real-time update inserted the raw absolute value instead of a variation, for the same kind of visual break.

This change skips the real-time update entirely for a chart/command combination in any of these three cases, instead of silently corrupting the display. It also means the matching series can safely be found with .find() and stop at the first match, now that a chart in comparison mode is excluded upfront (previously up to two series could share the same command id, so every series had to be checked).

Also merged the two separate cmd::update event listeners (jeedom.cmd.refreshValue and jeedom.history.graphUpdate) into one, found while investigating this.

Separately, graphUpdate never re-triggers the Y axis scale calculation after adding a real-time point. The axis min/max are computed once, when the chart is first drawn (setAxisScales), and stay fixed after that unless the user manually zooms or resets the view. A new value exceeding the original range was simply invisible, off the top or bottom of the chart. This only affects charts using the default axis scaling mode (yAxisScaling/yAxisByUnit both enabled, or either one alone); the remaining combination already uses soft bounds that auto-expand. The fix calls setAxisScales again after a successful real-time update.

Known related issues, not addressed here:

  • Past date range: a real-time update still gets appended at the current instant even when the chart displays a fixed past window (outside comparison mode), visually breaking the axis. No reliable client-side signal was found to detect this without risking false positives on genuinely live charts.
  • Relative periods never refresh: a chart drawn with a relative period (day/week/month) only fetches data once, on page load. Left open for a long time (e.g. a wall-mounted dashboard), it never re-queries a rolling window and keeps growing indefinitely via real-time pushes instead of showing a proper "last week" view. Affects both desktop/js/view.js and desktop/js/plan.js, and isn't specific to graphUpdate.

@Salvialf Salvialf added the changelog-fix Use to generate release notes / changelog To be apply on PR label Jul 24, 2026
@Salvialf Salvialf changed the title Skip real-time graph updates when they would misrepresent the data Fix real-time graph updates: skip inconsistent cases and rescale the Y axis Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-fix Use to generate release notes / changelog To be apply on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants