@rioaxyz/sonrchart 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -497,6 +497,13 @@ interface SonrChartHandle {
497
497
  getVolumeTrendBars(): number;
498
498
  setVolumeTrendBars(bars: number): void;
499
499
  subscribeVolumeTrendBars(cb: (bars: number) => void): () => void;
500
+ /** Whether the volume-trend header row is on (#79). Chart-level state so
501
+ * any control (the indicators menu, a host button) can toggle it and a
502
+ * mounted <ChartHeader> shows/hides its row live. Default off; the
503
+ * header's `volumeTrend` prop seeds it on. */
504
+ getVolumeTrendEnabled(): boolean;
505
+ setVolumeTrendEnabled(on: boolean): void;
506
+ subscribeVolumeTrendEnabled(cb: (on: boolean) => void): () => void;
500
507
  }
501
508
  declare const SonrChart: react.ForwardRefExoticComponent<SonrChartProps & react.RefAttributes<SonrChartHandle>>;
502
509
 
@@ -642,6 +649,10 @@ interface IndicatorOption {
642
649
  label: string;
643
650
  pane?: "main" | "new";
644
651
  }
652
+ /** Menu row for the volume-trend header row (#79). Not a KLineChart study —
653
+ * toggling it flips the chart-level flag (setVolumeTrendEnabled) that a
654
+ * mounted <ChartHeader> follows. */
655
+ declare const VOLUME_TREND_OPTION = "VOLTREND";
645
656
  declare const DEFAULT_INDICATOR_OPTIONS: IndicatorOption[];
646
657
  declare function IndicatorMenu({ chartRef, options, className, labels, }: {
647
658
  chartRef: RefObject<SonrChartHandle>;
@@ -937,10 +948,12 @@ interface ChartHeaderProps {
937
948
  source?: string;
938
949
  /** Precision for O/H/L/C/change (defaults to 2). */
939
950
  pricePrecision?: number;
940
- /** Volume-trend row (#79): `true` shows it with the chart-level lookback
951
+ /** Volume-trend row (#79): `true` turns it on with the chart-level lookback
941
952
  * (default 3 bars, editable in the settings dialog); a number also sets
942
- * that lookback. Shown on a second line below the symbol/OHLC row; tracks
943
- * the same bar as the OHLC (crosshair, falling back to the latest bar). */
953
+ * that lookback. The on/off state lives on the chart handle, so it's also
954
+ * toggleable from the indicators menu ("VOLTREND") — this prop seeds it on.
955
+ * Shown on a second line below the symbol/OHLC row; tracks the same bar as
956
+ * the OHLC (crosshair, falling back to the latest bar). */
944
957
  volumeTrend?: boolean | number;
945
958
  labels?: Partial<Labels>;
946
959
  className?: string;
@@ -1169,4 +1182,4 @@ interface SessionColors {
1169
1182
  declare const DEFAULT_SESSION_COLORS: SessionColors;
1170
1183
  declare function registerSonrIndicators(): void;
1171
1184
 
1172
- export { BRUSH_OVERLAY, type Bar, type BrandCorner, BrandMark, type BrandMarkProps, type BrushStyle, type BrushTool, CandleMenu, type CandleStyle, type CandleStyleOption, ChartHeader, type ChartHeaderProps, type ChartState, ChartToolbar, type CompareSpec, ConfirmDialog, DEFAULT_CANDLE_STYLES, DEFAULT_DRAWING_TOOLS, DEFAULT_HALT_BADGE, DEFAULT_INDICATOR_OPTIONS, DEFAULT_LABELS, DEFAULT_RANGES, DEFAULT_RESOLUTIONS, DEFAULT_SESSION_COLORS, DEFAULT_TIMEZONE, DEFAULT_TIMEZONES, DEFAULT_VOLUME_TREND_BARS, type DataSource, DataWindow, type DrawingRow, type DrawingSnapshot, type DrawingSnapshotItem, DrawingTemplateStore, type DrawingTool, type DrawingToolOption, DrawingToolbar, EXTENDED_DRAWING_TOOLS, EXTENDED_OVERLAYS, FIB_EXTENSION_LEVELS, GoToDateDialog, HALT_INDICATOR, type HaltBadge, type HaltBadgeData, IndicatorMenu, type IndicatorOption, type IndicatorRow, type IndicatorSpec, type Interval, type Labels, type Magnet, type MarketPhase, MarketStatus, type MarketStatusProps, NavControlBar, ObjectTree, type OrderLine, PALETTE, PATTERN_INDICATOR, type PatternMarker, type PriceLabels, type PriceLine, type PriceScale, PriceScaleMenu, type QuoteFormat, type RangeOption, type ResolutionOption, SERIES_INDICATOR, SESSION_INDICATOR, SHAPE_ELLIPSE, SHAPE_OVERLAYS, SHAPE_PRICE_RANGE, SHAPE_RECTANGLE, SHAPE_RISK_REWARD, SHAPE_TRIANGLE, SONR_TRADE_BOX, SaveLoadDialog, type SessionTint, SettingsModal, type ShortcutAction, SonrChart, type SonrChartHandle, type SonrChartProps, SonrChartShell, type SonrChartShellProps, type SymbolInfo, SymbolInfoDialog, SymbolSearch, type SymbolSearchResult, TEXT_OVERLAY, type TextData, type Theme, TimeframeBar, TimezoneMenu, type TimezoneOption, ToolbarButton, UNIT_MS, USER_DRAWING_GROUP, VWAP_INDICATOR, type VolumeTrend, WATERMARK_INDICATOR, type WatermarkData, type WatermarkOptions, arrowHeadPoints, dateRangeLabel, downloadSnapshot, drawingLabel, ensureDefaultStyles, fibSequence, formatWithUnit, getCSSCustomProperty, getRegisteredTheme, getTimezoneApi, humanDuration, isChartState, isEditableTarget, marketStatus, mergeLabels, normalizeHalt, parseLocalDateTime, parseResolution, priceRangeLabel, registerExtendedDrawings, registerShapeOverlays, registerSonrIndicators, registerTextOverlay, registerTheme, registerTradeReview, resolutionLabel, resolutionMs, resolveShortcut, resolveThemeStyles, riskRewardStats, setCSSCustomProperty, themeStyles, timezoneLabel, toHeikinAshi, tradeBoxFigures, volumeTrend };
1185
+ export { BRUSH_OVERLAY, type Bar, type BrandCorner, BrandMark, type BrandMarkProps, type BrushStyle, type BrushTool, CandleMenu, type CandleStyle, type CandleStyleOption, ChartHeader, type ChartHeaderProps, type ChartState, ChartToolbar, type CompareSpec, ConfirmDialog, DEFAULT_CANDLE_STYLES, DEFAULT_DRAWING_TOOLS, DEFAULT_HALT_BADGE, DEFAULT_INDICATOR_OPTIONS, DEFAULT_LABELS, DEFAULT_RANGES, DEFAULT_RESOLUTIONS, DEFAULT_SESSION_COLORS, DEFAULT_TIMEZONE, DEFAULT_TIMEZONES, DEFAULT_VOLUME_TREND_BARS, type DataSource, DataWindow, type DrawingRow, type DrawingSnapshot, type DrawingSnapshotItem, DrawingTemplateStore, type DrawingTool, type DrawingToolOption, DrawingToolbar, EXTENDED_DRAWING_TOOLS, EXTENDED_OVERLAYS, FIB_EXTENSION_LEVELS, GoToDateDialog, HALT_INDICATOR, type HaltBadge, type HaltBadgeData, IndicatorMenu, type IndicatorOption, type IndicatorRow, type IndicatorSpec, type Interval, type Labels, type Magnet, type MarketPhase, MarketStatus, type MarketStatusProps, NavControlBar, ObjectTree, type OrderLine, PALETTE, PATTERN_INDICATOR, type PatternMarker, type PriceLabels, type PriceLine, type PriceScale, PriceScaleMenu, type QuoteFormat, type RangeOption, type ResolutionOption, SERIES_INDICATOR, SESSION_INDICATOR, SHAPE_ELLIPSE, SHAPE_OVERLAYS, SHAPE_PRICE_RANGE, SHAPE_RECTANGLE, SHAPE_RISK_REWARD, SHAPE_TRIANGLE, SONR_TRADE_BOX, SaveLoadDialog, type SessionTint, SettingsModal, type ShortcutAction, SonrChart, type SonrChartHandle, type SonrChartProps, SonrChartShell, type SonrChartShellProps, type SymbolInfo, SymbolInfoDialog, SymbolSearch, type SymbolSearchResult, TEXT_OVERLAY, type TextData, type Theme, TimeframeBar, TimezoneMenu, type TimezoneOption, ToolbarButton, UNIT_MS, USER_DRAWING_GROUP, VOLUME_TREND_OPTION, VWAP_INDICATOR, type VolumeTrend, WATERMARK_INDICATOR, type WatermarkData, type WatermarkOptions, arrowHeadPoints, dateRangeLabel, downloadSnapshot, drawingLabel, ensureDefaultStyles, fibSequence, formatWithUnit, getCSSCustomProperty, getRegisteredTheme, getTimezoneApi, humanDuration, isChartState, isEditableTarget, marketStatus, mergeLabels, normalizeHalt, parseLocalDateTime, parseResolution, priceRangeLabel, registerExtendedDrawings, registerShapeOverlays, registerSonrIndicators, registerTextOverlay, registerTheme, registerTradeReview, resolutionLabel, resolutionMs, resolveShortcut, resolveThemeStyles, riskRewardStats, setCSSCustomProperty, themeStyles, timezoneLabel, toHeikinAshi, tradeBoxFigures, volumeTrend };
package/dist/index.d.ts CHANGED
@@ -497,6 +497,13 @@ interface SonrChartHandle {
497
497
  getVolumeTrendBars(): number;
498
498
  setVolumeTrendBars(bars: number): void;
499
499
  subscribeVolumeTrendBars(cb: (bars: number) => void): () => void;
500
+ /** Whether the volume-trend header row is on (#79). Chart-level state so
501
+ * any control (the indicators menu, a host button) can toggle it and a
502
+ * mounted <ChartHeader> shows/hides its row live. Default off; the
503
+ * header's `volumeTrend` prop seeds it on. */
504
+ getVolumeTrendEnabled(): boolean;
505
+ setVolumeTrendEnabled(on: boolean): void;
506
+ subscribeVolumeTrendEnabled(cb: (on: boolean) => void): () => void;
500
507
  }
501
508
  declare const SonrChart: react.ForwardRefExoticComponent<SonrChartProps & react.RefAttributes<SonrChartHandle>>;
502
509
 
@@ -642,6 +649,10 @@ interface IndicatorOption {
642
649
  label: string;
643
650
  pane?: "main" | "new";
644
651
  }
652
+ /** Menu row for the volume-trend header row (#79). Not a KLineChart study —
653
+ * toggling it flips the chart-level flag (setVolumeTrendEnabled) that a
654
+ * mounted <ChartHeader> follows. */
655
+ declare const VOLUME_TREND_OPTION = "VOLTREND";
645
656
  declare const DEFAULT_INDICATOR_OPTIONS: IndicatorOption[];
646
657
  declare function IndicatorMenu({ chartRef, options, className, labels, }: {
647
658
  chartRef: RefObject<SonrChartHandle>;
@@ -937,10 +948,12 @@ interface ChartHeaderProps {
937
948
  source?: string;
938
949
  /** Precision for O/H/L/C/change (defaults to 2). */
939
950
  pricePrecision?: number;
940
- /** Volume-trend row (#79): `true` shows it with the chart-level lookback
951
+ /** Volume-trend row (#79): `true` turns it on with the chart-level lookback
941
952
  * (default 3 bars, editable in the settings dialog); a number also sets
942
- * that lookback. Shown on a second line below the symbol/OHLC row; tracks
943
- * the same bar as the OHLC (crosshair, falling back to the latest bar). */
953
+ * that lookback. The on/off state lives on the chart handle, so it's also
954
+ * toggleable from the indicators menu ("VOLTREND") — this prop seeds it on.
955
+ * Shown on a second line below the symbol/OHLC row; tracks the same bar as
956
+ * the OHLC (crosshair, falling back to the latest bar). */
944
957
  volumeTrend?: boolean | number;
945
958
  labels?: Partial<Labels>;
946
959
  className?: string;
@@ -1169,4 +1182,4 @@ interface SessionColors {
1169
1182
  declare const DEFAULT_SESSION_COLORS: SessionColors;
1170
1183
  declare function registerSonrIndicators(): void;
1171
1184
 
1172
- export { BRUSH_OVERLAY, type Bar, type BrandCorner, BrandMark, type BrandMarkProps, type BrushStyle, type BrushTool, CandleMenu, type CandleStyle, type CandleStyleOption, ChartHeader, type ChartHeaderProps, type ChartState, ChartToolbar, type CompareSpec, ConfirmDialog, DEFAULT_CANDLE_STYLES, DEFAULT_DRAWING_TOOLS, DEFAULT_HALT_BADGE, DEFAULT_INDICATOR_OPTIONS, DEFAULT_LABELS, DEFAULT_RANGES, DEFAULT_RESOLUTIONS, DEFAULT_SESSION_COLORS, DEFAULT_TIMEZONE, DEFAULT_TIMEZONES, DEFAULT_VOLUME_TREND_BARS, type DataSource, DataWindow, type DrawingRow, type DrawingSnapshot, type DrawingSnapshotItem, DrawingTemplateStore, type DrawingTool, type DrawingToolOption, DrawingToolbar, EXTENDED_DRAWING_TOOLS, EXTENDED_OVERLAYS, FIB_EXTENSION_LEVELS, GoToDateDialog, HALT_INDICATOR, type HaltBadge, type HaltBadgeData, IndicatorMenu, type IndicatorOption, type IndicatorRow, type IndicatorSpec, type Interval, type Labels, type Magnet, type MarketPhase, MarketStatus, type MarketStatusProps, NavControlBar, ObjectTree, type OrderLine, PALETTE, PATTERN_INDICATOR, type PatternMarker, type PriceLabels, type PriceLine, type PriceScale, PriceScaleMenu, type QuoteFormat, type RangeOption, type ResolutionOption, SERIES_INDICATOR, SESSION_INDICATOR, SHAPE_ELLIPSE, SHAPE_OVERLAYS, SHAPE_PRICE_RANGE, SHAPE_RECTANGLE, SHAPE_RISK_REWARD, SHAPE_TRIANGLE, SONR_TRADE_BOX, SaveLoadDialog, type SessionTint, SettingsModal, type ShortcutAction, SonrChart, type SonrChartHandle, type SonrChartProps, SonrChartShell, type SonrChartShellProps, type SymbolInfo, SymbolInfoDialog, SymbolSearch, type SymbolSearchResult, TEXT_OVERLAY, type TextData, type Theme, TimeframeBar, TimezoneMenu, type TimezoneOption, ToolbarButton, UNIT_MS, USER_DRAWING_GROUP, VWAP_INDICATOR, type VolumeTrend, WATERMARK_INDICATOR, type WatermarkData, type WatermarkOptions, arrowHeadPoints, dateRangeLabel, downloadSnapshot, drawingLabel, ensureDefaultStyles, fibSequence, formatWithUnit, getCSSCustomProperty, getRegisteredTheme, getTimezoneApi, humanDuration, isChartState, isEditableTarget, marketStatus, mergeLabels, normalizeHalt, parseLocalDateTime, parseResolution, priceRangeLabel, registerExtendedDrawings, registerShapeOverlays, registerSonrIndicators, registerTextOverlay, registerTheme, registerTradeReview, resolutionLabel, resolutionMs, resolveShortcut, resolveThemeStyles, riskRewardStats, setCSSCustomProperty, themeStyles, timezoneLabel, toHeikinAshi, tradeBoxFigures, volumeTrend };
1185
+ export { BRUSH_OVERLAY, type Bar, type BrandCorner, BrandMark, type BrandMarkProps, type BrushStyle, type BrushTool, CandleMenu, type CandleStyle, type CandleStyleOption, ChartHeader, type ChartHeaderProps, type ChartState, ChartToolbar, type CompareSpec, ConfirmDialog, DEFAULT_CANDLE_STYLES, DEFAULT_DRAWING_TOOLS, DEFAULT_HALT_BADGE, DEFAULT_INDICATOR_OPTIONS, DEFAULT_LABELS, DEFAULT_RANGES, DEFAULT_RESOLUTIONS, DEFAULT_SESSION_COLORS, DEFAULT_TIMEZONE, DEFAULT_TIMEZONES, DEFAULT_VOLUME_TREND_BARS, type DataSource, DataWindow, type DrawingRow, type DrawingSnapshot, type DrawingSnapshotItem, DrawingTemplateStore, type DrawingTool, type DrawingToolOption, DrawingToolbar, EXTENDED_DRAWING_TOOLS, EXTENDED_OVERLAYS, FIB_EXTENSION_LEVELS, GoToDateDialog, HALT_INDICATOR, type HaltBadge, type HaltBadgeData, IndicatorMenu, type IndicatorOption, type IndicatorRow, type IndicatorSpec, type Interval, type Labels, type Magnet, type MarketPhase, MarketStatus, type MarketStatusProps, NavControlBar, ObjectTree, type OrderLine, PALETTE, PATTERN_INDICATOR, type PatternMarker, type PriceLabels, type PriceLine, type PriceScale, PriceScaleMenu, type QuoteFormat, type RangeOption, type ResolutionOption, SERIES_INDICATOR, SESSION_INDICATOR, SHAPE_ELLIPSE, SHAPE_OVERLAYS, SHAPE_PRICE_RANGE, SHAPE_RECTANGLE, SHAPE_RISK_REWARD, SHAPE_TRIANGLE, SONR_TRADE_BOX, SaveLoadDialog, type SessionTint, SettingsModal, type ShortcutAction, SonrChart, type SonrChartHandle, type SonrChartProps, SonrChartShell, type SonrChartShellProps, type SymbolInfo, SymbolInfoDialog, SymbolSearch, type SymbolSearchResult, TEXT_OVERLAY, type TextData, type Theme, TimeframeBar, TimezoneMenu, type TimezoneOption, ToolbarButton, UNIT_MS, USER_DRAWING_GROUP, VOLUME_TREND_OPTION, VWAP_INDICATOR, type VolumeTrend, WATERMARK_INDICATOR, type WatermarkData, type WatermarkOptions, arrowHeadPoints, dateRangeLabel, downloadSnapshot, drawingLabel, ensureDefaultStyles, fibSequence, formatWithUnit, getCSSCustomProperty, getRegisteredTheme, getTimezoneApi, humanDuration, isChartState, isEditableTarget, marketStatus, mergeLabels, normalizeHalt, parseLocalDateTime, parseResolution, priceRangeLabel, registerExtendedDrawings, registerShapeOverlays, registerSonrIndicators, registerTextOverlay, registerTheme, registerTradeReview, resolutionLabel, resolutionMs, resolveShortcut, resolveThemeStyles, riskRewardStats, setCSSCustomProperty, themeStyles, timezoneLabel, toHeikinAshi, tradeBoxFigures, volumeTrend };
package/dist/index.js CHANGED
@@ -15572,6 +15572,8 @@ var SonrChart = forwardRef(function SonrChart2({
15572
15572
  const trendSubs = useRef2(/* @__PURE__ */ new Set());
15573
15573
  const trendBarsRef = useRef2(DEFAULT_VOLUME_TREND_BARS);
15574
15574
  const trendBarsSubs = useRef2(/* @__PURE__ */ new Set());
15575
+ const trendOnRef = useRef2(false);
15576
+ const trendOnSubs = useRef2(/* @__PURE__ */ new Set());
15575
15577
  const crosshairActiveRef = useRef2(false);
15576
15578
  const headerIdxRef = useRef2(-1);
15577
15579
  const emitHeaderAt = (list, idx) => {
@@ -15876,6 +15878,16 @@ var SonrChart = forwardRef(function SonrChart2({
15876
15878
  subscribeVolumeTrendBars: (cb) => {
15877
15879
  trendBarsSubs.current.add(cb);
15878
15880
  return () => trendBarsSubs.current.delete(cb);
15881
+ },
15882
+ getVolumeTrendEnabled: () => trendOnRef.current,
15883
+ setVolumeTrendEnabled: (on) => {
15884
+ if (on === trendOnRef.current) return;
15885
+ trendOnRef.current = on;
15886
+ trendOnSubs.current.forEach((cb) => cb(on));
15887
+ },
15888
+ subscribeVolumeTrendEnabled: (cb) => {
15889
+ trendOnSubs.current.add(cb);
15890
+ return () => trendOnSubs.current.delete(cb);
15879
15891
  }
15880
15892
  },
15881
15893
  // paneHeights/priceScale captured by closure; recreated per render is fine.
@@ -16628,6 +16640,7 @@ function mergeLabels(over) {
16628
16640
 
16629
16641
  // src/IndicatorMenu.tsx
16630
16642
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
16643
+ var VOLUME_TREND_OPTION = "VOLTREND";
16631
16644
  var DEFAULT_INDICATOR_OPTIONS = [
16632
16645
  // Price-pane overlays.
16633
16646
  { name: "MA", label: "Moving Average", pane: "main" },
@@ -16640,6 +16653,7 @@ var DEFAULT_INDICATOR_OPTIONS = [
16640
16653
  { name: "VWAP", label: "Volume Weighted Avg Price", pane: "main" },
16641
16654
  // Sub-pane oscillators & volume studies.
16642
16655
  { name: "VOL", label: "Volume", pane: "new" },
16656
+ { name: VOLUME_TREND_OPTION, label: "Volume Trend (header row)" },
16643
16657
  { name: "MACD", label: "MACD", pane: "new" },
16644
16658
  { name: "RSI", label: "Relative Strength Index", pane: "new" },
16645
16659
  { name: "KDJ", label: "KDJ Stochastic", pane: "new" },
@@ -16670,12 +16684,27 @@ function IndicatorMenu({
16670
16684
  const [active, setActive] = useState3([]);
16671
16685
  const { open, toggle: toggleOpen, pos, triggerRef, panelRef } = useDropdown();
16672
16686
  useEffect3(() => {
16673
- const t = setTimeout(() => setActive(chartRef.current?.listIndicators() ?? []), 0);
16674
- return () => clearTimeout(t);
16687
+ let unsubOn;
16688
+ const t = setTimeout(() => {
16689
+ const h = chartRef.current;
16690
+ const base = h?.listIndicators() ?? [];
16691
+ setActive(h?.getVolumeTrendEnabled?.() ? [...base, VOLUME_TREND_OPTION] : base);
16692
+ unsubOn = h?.subscribeVolumeTrendEnabled?.(
16693
+ (on) => setActive((a) => on ? a.includes(VOLUME_TREND_OPTION) ? a : [...a, VOLUME_TREND_OPTION] : a.filter((n) => n !== VOLUME_TREND_OPTION))
16694
+ );
16695
+ }, 0);
16696
+ return () => {
16697
+ clearTimeout(t);
16698
+ unsubOn?.();
16699
+ };
16675
16700
  }, [chartRef]);
16676
16701
  const toggle = (opt) => {
16677
16702
  const handle = chartRef.current;
16678
16703
  if (!handle) return;
16704
+ if (opt.name === VOLUME_TREND_OPTION) {
16705
+ handle.setVolumeTrendEnabled?.(!active.includes(opt.name));
16706
+ return;
16707
+ }
16679
16708
  if (active.includes(opt.name)) {
16680
16709
  handle.removeIndicator(opt.name);
16681
16710
  setActive((a) => a.filter((n) => n !== opt.name));
@@ -18957,20 +18986,23 @@ function ChartHeader({ chartRef, symbol, interval, source, pricePrecision = 2, v
18957
18986
  const L = useMemo12(() => mergeLabels(labels), [labels]);
18958
18987
  const [bar, setBar] = useState14({ current: null, prev: null });
18959
18988
  const [trend, setTrend] = useState14(null);
18960
- const trendOn = volumeTrend2 === true || typeof volumeTrend2 === "number" && volumeTrend2 > 0;
18989
+ const [trendOn, setTrendOn] = useState14(false);
18990
+ const seedOn = volumeTrend2 === true || typeof volumeTrend2 === "number" && volumeTrend2 > 0;
18961
18991
  useEffect16(() => {
18962
18992
  let cancelled = false;
18963
18993
  let unsub;
18964
- let unsubTrend;
18994
+ let unsubOn;
18965
18995
  const attach = () => {
18966
18996
  if (cancelled) return;
18967
18997
  const h = chartRef.current;
18968
18998
  if (h?.subscribeHeaderBar) {
18969
18999
  unsub = h.subscribeHeaderBar((current, prev) => setBar({ current, prev }));
18970
- if (trendOn) {
19000
+ if (seedOn) {
18971
19001
  if (typeof volumeTrend2 === "number") h.setVolumeTrendBars?.(volumeTrend2);
18972
- unsubTrend = h.subscribeVolumeTrend?.((t) => setTrend(t));
19002
+ h.setVolumeTrendEnabled?.(true);
18973
19003
  }
19004
+ setTrendOn(h.getVolumeTrendEnabled?.() ?? seedOn);
19005
+ unsubOn = h.subscribeVolumeTrendEnabled?.(setTrendOn);
18974
19006
  } else {
18975
19007
  setTimeout(attach, 50);
18976
19008
  }
@@ -18979,9 +19011,17 @@ function ChartHeader({ chartRef, symbol, interval, source, pricePrecision = 2, v
18979
19011
  return () => {
18980
19012
  cancelled = true;
18981
19013
  unsub?.();
18982
- unsubTrend?.();
19014
+ unsubOn?.();
18983
19015
  };
18984
- }, [chartRef, volumeTrend2, trendOn]);
19016
+ }, [chartRef, volumeTrend2, seedOn]);
19017
+ useEffect16(() => {
19018
+ if (!trendOn) {
19019
+ setTrend(null);
19020
+ return;
19021
+ }
19022
+ const unsubTrend = chartRef.current?.subscribeVolumeTrend?.((t) => setTrend(t));
19023
+ return () => unsubTrend?.();
19024
+ }, [chartRef, trendOn]);
18985
19025
  const k = bar.current;
18986
19026
  const up = (k?.close ?? 0) >= (k?.open ?? 0);
18987
19027
  const dirClass = up ? "sonr-hd-up" : "sonr-hd-down";
@@ -19669,6 +19709,7 @@ export {
19669
19709
  ToolbarButton,
19670
19710
  UNIT_MS,
19671
19711
  USER_DRAWING_GROUP,
19712
+ VOLUME_TREND_OPTION,
19672
19713
  VWAP_INDICATOR,
19673
19714
  WATERMARK_INDICATOR,
19674
19715
  arrowHeadPoints,