Skip to content

Fix history prepend for multi-parameter plots (e.g. drivable target/value) - #89

Merged
Bilchreis merged 1 commit into
mainfrom
fix-prepend-data
Jul 6, 2026
Merged

Fix history prepend for multi-parameter plots (e.g. drivable target/value)#89
Bilchreis merged 1 commit into
mainfrom
fix-prepend-data

Conversation

@Bilchreis

Copy link
Copy Markdown
Owner

Problem

On a drivable module's plot (which shows both value and target series),
shrinking the visible time window and then widening it again only
backfilled history for the value series. target never got its older
data re-prepended.

Root cause

HistoryDB.handle_event("fetch-chart-range", ...) always fetched history
for a single hardcoded parameter — socket.assigns.parameter, which
get_parameter/1 resolves to whichever parameter is literally named
"value". Multi-series plots (e.g. PlotDB.Drivable, whose
param_names/0 returns ["value", "target"]) were never accounted for,
so target's series was silently skipped on every range-based backfill.

Fix

fetch-chart-range now:

  • Looks up the plot's full parameter list via PlotDB.param_list/1
    (already used for live-tick updates) instead of the single cached
    parameter assign.
  • Resolves each parameter name back to its %Parameter{} struct with a
    new resolve_param/2 helper (handles both bare %Parameter{} and
    %Module{} secop objects).
  • Fetches range data and builds trace updates per parameter, then merges
    all seriesUpdates (and any arrayLen) into a single payload via
    merge_trace_updates/1 before pushing one prepend-chart-data-#{id}
    event.

No JS changes needed — the EChartsChart hook already iterates every
entry in seriesUpdates, so it transparently picks up the extra series.

@Bilchreis
Bilchreis merged commit 863908b into main Jul 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant