Skip to content

Smoother replay, with step and speed settings - #2882

Merged
Flix6x merged 24 commits into
mainfrom
feat/smooth-replay
Nov 20, 2026
Merged

Flix6x merged 24 commits into
mainfrom
feat/smooth-replay

Conversation

@Flix6x

@Flix6x Flix6x commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Description

Smoother replay on the asset graph and sensor pages, with step and speed settings.
The replay used to move belief time in fixed 1-hour steps with 100 ms between them,
so drawing time slowed it down and finer belief updates were merged.

  • Steady speed: a replay clock ties belief time to the wall clock, so it advances at a constant rate however long frames take to draw; slow frames merge steps rather than slow the replay down
  • Smooth ruler (fast chart): the ruler is an overlay that the browser's compositor moves at the replay rate by itself, so it keeps gliding while the main thread is busy redrawing data, also on crowded charts; the data is drawn at the ruler's own time rather than at the last step boundary, redrawn only when new beliefs became known, and drawn for where the ruler will be when the redraw shows, so it keeps up without getting ahead
  • One-pass re-renders (fast chart): the gridline cap, the rounded step corners and the Zoom/Pan button colours are settled in the render itself instead of in three extra passes, each as costly as the render, which halves the time a replay redraw takes on a crowded chart
  • Auto step from belief timing: the most common interval between belief times within each sensor and source, rounded down to a step that fits a whole number of times in an hour or a day (e.g. "Auto (15 min)"); event timing plays no role
  • Step and speed pickers below the play button, shown while hovering over it (always on touch screens); +/- change the speed (1× = 6 h/s), the step sets how far n and b move, b steps back, as n steps ahead, and r rewinds (plays backward, pausing at the start), as p plays
  • Cheaper steps: beliefs are sorted by belief time once and walked through with an index, instead of re-partitioning all remaining beliefs every step; going back walks back the same way, restoring the belief each one replaced, so stepping back and rewinding cost as little as playing
  • The ruler is included in PNG/SVG exports made during a replay
  • On the sensor page, guard the units dropdown of the upload form, which threw a console error for users who may only view the sensor (no visible effect, as every button further down takes at least the permission to upload data)
  • A replay started while the page was still fetching the time range of its data was stopped once that arrived, because setting the date picker to the range it already showed counted as selecting it and reloaded the chart
  • Docs: new section "Replaying how data became known" in the asset data views
  • Added changelog item in documentation/changelog.rst

Look & Feel

Hover over the play button on a sensor or asset graph page to reveal the Step and Speed pickers.
While playing, the ruler glides over the chart, and the time label below the button shows the belief time the data is drawn for, following the ruler. When paused, the ruler glides to a stop instead of jumping back, the data catches up with it exactly, and the label shows that time.

How to test

  • pytest flexmeasures/ui/tests/js/test_replay_utils.py flexmeasures/ui/tests/js/test_fast_chart.py (the ruler tests need the vendored ECharts)
  • Manually: a sensor with forecasts re-formed every 15 minutes, replayed over two days, showed "Auto (15 min)", and measured ruler speeds of 10.1, 5.0 and 20.0 h/s at 1×, 0.5× and 2× (when 1× was still 10 h/s), within about 13 ms of wall time from a straight line

Further Improvements

  • In the Vega-Lite chart, the ruler and data move per step instead of gliding (the fast chart is the default).

Related Items

...


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

🤖 Generated with Claude Code

https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM

Flix6x and others added 9 commits November 19, 2026 09:54
The ruler was a markLine in the chart option, so moving it meant re-rendering the chart.
As plain zrender elements on their own zlevel, moving it only repaints that layer,
which lets the ruler follow a replay on every animation frame.
It is redrawn after each render and on zooming, in every time-axis subplot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
The replay used to move belief time in fixed 1-hour steps, waiting 100 ms between them,
so drawing time slowed it down and finer belief updates were merged.

- A replay clock ties belief time to the wall clock, so it advances at a constant rate however long frames take;
  the ruler follows it on every animation frame, and the data is redrawn when a step boundary passes and new beliefs became known.
- The step defaults to Auto: the most common interval between belief times within each sensor and source,
  rounded down to a step that fits a whole number of times in an hour or a day.
  Event timing plays no role.
- Step and speed pickers below the play button, with '+' and '-' to change the speed.
- The beliefs are sorted by belief time once, and a timeline walks through them with an index,
  instead of re-partitioning all remaining beliefs and rebuilding the shown data on every step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…orts

The previous commit gave the ruler a canvas layer of its own, which put it above the data.
Repainting the main canvas turns out to take only about a millisecond, even for six series of a year of 15-minute data,
so the ruler goes back onto the main canvas, between the split lines and the series, as it was as a markLine.
Image exports add it back as a markLine, since the on-screen ruler is not part of the chart option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
The label kept naming the step inferred for the previous date range or chart type until the next replay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…lay button

They fade in while hovering over the play button, stay while hovering over or using them,
and linger briefly so the pointer can move from the button to them.
Touch screens, which have no hover, always show them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
The units dropdown of the upload form is only rendered for users who may upload data to the sensor.
For other users, filling it threw, which stopped the rest of the script,
so the buttons to delete the sensor or its data, and to create a forecast, were never wired up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
The previous commit put the ruler behind the data, claiming that is where the markLine ruler was.
It was not: a markLine has z 5, above the series (z 2), and the Vega-Lite chart draws its ruler as the last layer.
Above the data is also where a playhead belongs, as behind the data, bars and filled areas hide it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
It was meant to come with the fix in 8c7961b, but did not make it into that commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x added this to the 1.2.0 milestone Nov 19, 2026
@Flix6x Flix6x added bug Something isn't working enhancement New feature or request UI labels Nov 19, 2026
@Flix6x Flix6x self-assigned this Nov 19, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

…no visible effect

The previous commit's entry, like the commit that guarded the units dropdown, claimed that the script error kept buttons from working for users who may not upload data.
But no such user sees those buttons: triggering forecasts takes the same permission as uploading data, and deleting a sensor or its data takes more.
The error was only a console error for users who may view the sensor and nothing more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x removed the bug Something isn't working label Nov 20, 2026
Flix6x and others added 12 commits November 20, 2026 12:05
Whatever moves along with the clock by itself, such as an animated ruler, needs to hear about the clock only when its anchor changes:
when it is started, paused, sought or set to another rate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ke it jump

On a crowded chart, redrawing the data blocks the main thread for 80 to 150 ms at a time,
and the ruler, drawn on the chart's canvas, could only move between those redraws: in jumps of 20 to 30 px, several times a second.
The ruler is now an HTML element laid over each subplot, moved by a CSS transform animation at the replay's rate,
which the browser runs off the main thread.
Recorded on a page with six subplots of forecasts re-formed every 15 minutes, the ruler moved in every displayed frame (17 ms apart), at most 2.5 px at a time,
against every 83 to 100 ms (up to 267 ms), in jumps of up to 33 px, before.

The replay hands the ruler the clock's motion only when it starts, pauses, seeks or changes speed,
and the animation is started from the moment the clock was read, rather than from the next frame, which comes late exactly while the chart is busy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
While playing, the data follows the last step boundary the clock passed, and on a crowded chart it trails the ruler by the time a redraw takes, too.
On pausing, the data now catches up with the ruler exactly, rather than staying at the last boundary.
On resuming, it stays until the clock passes the next boundary, rather than going back to the previous one;
the same goes for switching to a longer step while playing, which used to take the data back.
Changing the step while paused no longer redraws anything, so it no longer needs its own listener.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
The ruler moves by itself, so it had already moved on by the time it heard about a pause,
all the more as that frame first redrew the data, which can take a hundred milliseconds or more on a crowded chart.
It then jumped back to where the pause was clicked.
Now the clock pauses 50 ms ahead, the ruler glides on to there and stops,
and the data waits a frame whenever the ruler is handed a new motion, so the ruler hears about it in time.
While paused, the data is redrawn once the ruler has stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…he ruler

A redraw on a crowded chart takes about 100 ms, an hour of belief time at 1×,
while the ruler moves on by itself, so the data lagged up to one redraw plus one step behind it.
Now the data is drawn for where the clock will be after the shortest of the last five redraws,
which brings the median lag on a crowded chart from 0.9 h to 0.2 h at 1×,
without the data getting ahead of the ruler, unless a redraw is quicker than all of those.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…raws

Each render was followed by three more passes over the chart, each about as costly as the render itself:
one to cap the time between gridlines, one to cut the rounded corners of stepped lines in pixel space,
and one to colour the Zoom and Pan buttons.
The gridline cap now goes into the option up front, the button colours already did,
and the corners are cut up front at the scale the previous render ended up with,
taking a second pass only when the new render ends up at another scale.
On a crowded asset chart, a replay now redraws every 50 ms instead of every 100 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
At 10 hours per second, a busy day of updates went by too fast to follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ta's time range loads

When the page opens on a known date range, the chart loads right away, while the time range of the data is still being fetched.
Once fetched, the date picker was set to the range it already showed, which counts as selecting it:
that reloaded the chart and stopped any replay started in the meantime.
The picker is now only set when it shows another range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Like n steps ahead, b steps back to the previous step boundary, pausing a playing replay first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
r plays the replay backward, at the chosen speed, from wherever it is, or from the end if it was stopped,
and pauses it if it is rewinding already; p then plays forward again.
Rewinding all the way pauses at the start.
The clock and the ruler run in either direction,
and the belief timeline walks back belief by belief, restoring the beliefs each one replaced,
rather than starting over from the first belief, so rewinding costs as little as playing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…e last step boundary

The fast chart only redraws when new beliefs became known, and merges what became known during a slow redraw,
so rounding down to step boundaries no longer saved redraws; it only let the data trail the ruler by up to a step.
The step now sets how far 'n' and 'b' move.
The Vega chart keeps moving on per step, as it redraws in full to move its ruler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x and others added 2 commits November 20, 2026 23:22
UI users may not know the belief time concept, and the ruler moves along the chart's time axis anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5Qh6UFAnmTwZ4qGuM
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>

# Conflicts:
#	documentation/changelog.rst
@Flix6x
Flix6x merged commit a0c9247 into main Nov 20, 2026
11 checks passed
@Flix6x
Flix6x deleted the feat/smooth-replay branch November 20, 2026 22:51
Flix6x added a commit that referenced this pull request Dec 2, 2026
The tests that main brought in (#2829, #2882) asked the fast chart for the
legacy name chart_for_chargepoint_sessions, which it leaves to Vega-Lite
since this PR; and main replaced the mouseover hook the mocked hover check
relied on, which its real-ECharts hover test now covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x added a commit that referenced this pull request Dec 2, 2026
The replay and one-pass tests main brought in (#2882) render asset charts
without opts.chargePointChart, which an asset chart needs since this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant