Repository navigation
fix(chart): keep candles at normal width when few bars exist - #48
Open
niravpatidar37 wants to merge 1 commit into
Open
niravpatidar37 wants to merge 1 commit into
niravpatidar37 wants to merge 1 commit into
Conversation
fitContent() stretched early-session 1D data (e.g. 13 five-minute bars at 10:30) across the whole panel, producing ~70 px candles. Reserve the full 9:30-16:00 session (78 slots) on 1D, and at least 60 slots elsewhere, so the chart fills in left to right like a normal terminal.
niravpatidar37
added a commit
to niravpatidar37/OpenTerminal
that referenced
this pull request
Oct 20, 2026
fitContent() stretched early-session 1D data (e.g. 13 five-minute bars at 10:30) across the whole panel, producing ~70 px candles. Reserve the full 9:30-16:00 session (78 slots) on 1D, and at least 60 slots elsewhere, so the chart fills in left to right like a normal terminal. Squash of fix/chart-bar-width (also proposed alone as ErTasselli#48).
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
On short histories the chart calls
timeScale().fitContent(), which stretches however many bars exist across the whole panel. Early in the session this is very visible: at 10:30 ET a 1D chart has about 13 five-minute bars, so each candle is drawn about 70 px wide. They only look normal near the close. New listings with little history on longer ranges get the same giant bars.Fix
One file,
web/components/widgets/ChartWidget.tsx. When there are fewer bars than a minimum, set the visible logical range instead of fitting:fitContent()as before.The range starts at
-1.5so the first candle isn't clipped at the left edge.Verification
next build(lint + types) andtscare clean onmain, and the 26 existing tests pass.fitContent(), so they're unchanged.Notes
main, andgit merge-treeshows it merges cleanly with Security hardening + live data, alerts, Greeks, CSV, heatmap fixes, learning features (paper trading, tooltips, replay), logo #43's head.main, the Nasdaq provider returns daily candles for 1D (fixed by the intraday builder in Security hardening + live data, alerts, Greeks, CSV, heatmap fixes, learning features (paper trading, tooltips, replay), logo #43). With this change those few daily bars also render at normal width instead of filling the panel.Security impact: none. This is client-side chart viewport logic only, with no new inputs, network calls or rendering of external data.