Fix: chart resets viewport on click and drawings trigger wrong data reload#104
Open
MalkinK wants to merge 1 commit into
Open
Fix: chart resets viewport on click and drawings trigger wrong data reload#104MalkinK wants to merge 1 commit into
MalkinK wants to merge 1 commit into
Conversation
…eload Bug 1: ChartRenderer.updateSeries() calls fitContent() unconditionally on every update. Any user interaction (click, scroll, zoom) that coincides with a realtime update causes the chart to snap back to full-range view, losing the user's scroll/zoom position. Fix: Add _initialFitDone flag so fitContent() only fires once on first data load. Add resetFitState() for symbol/interval changes. Bug 2: Clicking a drawing triggers loadSymbolData() but the layout's interval is hardcoded to "1D" in the template, and loadSymbolData() doesn't sync its interval arg back to reactive state. This causes subsequent loads to use the stale default interval. Fix: Add interval as a reactive @Property() on oak-view-layout.ts, bind template to it instead of hardcoded "1D". In loadSymbolData(), sync symbol/interval back to reactive properties and Store. Files changed: - src/components/ChartRenderer.ts: _initialFitDone guard + resetFitState() - src/oak-view-layout.ts: interval reactive property + template binding - src/oak-view-chart.ts: state sync in loadSymbolData() + resetFitState() call Tested: 12/12 Playwright headless tests pass, build succeeds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two related bugs that degrade the user experience when interacting with the chart:
Bug 1: Chart jumps/resets zoom on every click
ChartRenderer.updateSeries()callsfitContent()unconditionally every time it runs. SinceupdateSeries()istriggered by realtime data updates, any user interaction (click, scroll, zoom) that coincides with an update causes
the chart to snap back to the full-range view, losing the user's scroll/zoom position.
Root cause:
fitContent()at line 360 ofChartRenderer.tsfires on everyupdateSeries()call with no guard.Bug 2: Clicking a drawing triggers a full data reload with wrong interval
When a user clicks on a drawing (e.g., Parallel Channel), it triggers
loadSymbolData()via event propagation.Because the layout's
intervalproperty is hardcoded to"1D"in the template andloadSymbolData()doesn't syncits interval parameter back to the component's reactive state, subsequent loads use the stale default interval
instead of the one actually displayed.
Root cause:
oak-view-layout.tshasinterval="1D"hardcoded in the toolbar template instead of binding to a reactiveproperty
oak-view-chart.tsloadSymbolData()doesn't sync thesymbol/intervalargs back tothis.symbol/this.intervalor the Store, so internal state drifts from what's renderedFix
ChartRenderer.ts
_initialFitDoneflag —fitContent()only fires once on first data load, not on everyupdateSeries()callresetFitState()method — called when symbol/interval changes so new data gets one auto-fitdispose()for clean lifecycleoak-view-layout.ts
intervalas a@property()reactive attribute (was missing entirely)${this.interval}instead of hardcoded"1D"oak-view-chart.ts
loadSymbolData(): syncsymbolandintervalback to reactive properties and Store before loading dataresetFitState()when configuring timescale for new intervalTesting
pane toggles)
npm run build(no new errors introduced)Changes