From 78a3e9d6353868cb5f2856eeca0993c90b20da22 Mon Sep 17 00:00:00 2001 From: Maksim Kostromin Date: Thu, 3 Dec 2026 11:03:29 -0500 Subject: [PATCH] fix(viewer): tradingview charts open on their own view, last candle near the scale --- src/viewer/app/tv-chart.test.ts | 6 ++---- src/viewer/app/tv-chart.ts | 14 +++++--------- src/viewer/ui/Fundamentals.tsx | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/viewer/app/tv-chart.test.ts b/src/viewer/app/tv-chart.test.ts index ee04140..aea5839 100644 --- a/src/viewer/app/tv-chart.test.ts +++ b/src/viewer/app/tv-chart.test.ts @@ -36,10 +36,8 @@ test('the widget follows the interval, theme and language, and never lets the sy expect(c.allow_symbol_change).toBe(false); // no volume bars under the price (owner 2026-12-03) expect(c.hide_volume).toBe(true); - // drawn as after three clicks on the chart's +: Weekly eight months; the small m keeps our interval (a capital M switches it) - expect(c.range).toBe('8m'); - expect(tvConfig('AAPL', 'D', true, 'en', 'x', '#000').range).toBe('2m'); - expect(tvConfig('AAPL', 'M', true, 'en', 'x', '#000').range).toBe('33m'); + // no range: TradingView's own view of the interval, the last candle near the price scale (a range left ~10 empty candles) + expect('range' in c).toBe(false); expect(tvConfig('AAPL', 'D', false, 'en', 'tv-2', '#368727').theme).toBe('light'); }); diff --git a/src/viewer/app/tv-chart.ts b/src/viewer/app/tv-chart.ts index 0f11595..c11dfcf 100644 --- a/src/viewer/app/tv-chart.ts +++ b/src/viewer/app/tv-chart.ts @@ -64,14 +64,11 @@ export function candleOverrides(c: CandleColors): Record = { D: '2m', W: '8m', M: '33m' }; +// No `range`: each chart opens on TradingView's own view of its interval, about 2.5 months of Daily, 9 months of Weekly +// and 3.5 years of Monthly, with the last candle 4 to 5 candles from the price scale. A `range` (2m, 8m, 33m from the +// owner's "press + 3 times", 2026-12-03) fit those spans but left about 10 empty candles at the right; the owner asked for +// the default look instead (2026-12-03: "we must checge this ... when click here [↻] to this"). The right room itself is +// not ours to set: tv.js passes overrides for it, the chart ignores them (checked in Chrome 2026-12-03) /** * the widget's settings: our interval, theme, language and card colour; no symbol change, no toolbar (our pills pick the @@ -86,7 +83,6 @@ export function tvConfig(ticker: string, interval: TvInterval, dark: boolean, la autosize: true, symbol: tvSymbol(ticker), interval, - range: TV_RANGE[interval], timezone: 'America/New_York', theme: dark ? 'dark' : 'light', style: '1', diff --git a/src/viewer/ui/Fundamentals.tsx b/src/viewer/ui/Fundamentals.tsx index 0bf9ec3..0cfce73 100644 --- a/src/viewer/ui/Fundamentals.tsx +++ b/src/viewer/ui/Fundamentals.tsx @@ -82,7 +82,7 @@ export function FundamentalsLink({ p, className, children }: { p: Position; clas const sizes = asSplit(pr.fundamentalsSplit[set], shown.length); const saveSizes = (v: number[]) => setPrefs({ fundamentalsSplit: { ...prefs.get().fundamentalsSplit, [set]: v } }); // ↻ draws the charts again as they open (owner 2026-12-03: "if i want to reset i will click refresh and it should - // refresh to standard"): each one's own history range, equal widths + // refresh to standard"): each in TradingView's own view of its interval, equal widths const reset = () => { const rest = { ...prefs.get().fundamentalsSplit }; delete rest[set];