openalgo-charts 1.0.9 → 1.0.10

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.
@@ -828,6 +828,8 @@ declare class Pane {
828
828
  /** Remove a series record if present; returns true if it was found. */
829
829
  removeSeries(record: SeriesRecord): boolean;
830
830
  series(): readonly SeriesRecord[];
831
+ /** Primitives attached to this pane, in draw order. */
832
+ primitives(): readonly IPrimitive[];
831
833
  addPrimitive(primitive: IPrimitive, host: PrimitiveHost): void;
832
834
  /** Remove a primitive if present; returns true if it was found. */
833
835
  removePrimitive(primitive: IPrimitive): boolean;
@@ -1408,6 +1410,53 @@ declare class EventMarkers implements IPrimitive {
1408
1410
  hitTest(x: number, y: number): PrimitiveHit | null;
1409
1411
  }
1410
1412
 
1413
+ /**
1414
+ * Time navigator (ARCHITECTURE.md §8) — the hover-revealed zoom / step controls
1415
+ * that sit just above the time axis: `−` `+` to zoom, `‹` `›` to step one bar.
1416
+ *
1417
+ * Invisible until the pointer nears the bottom of the chart, so a clean chart
1418
+ * stays clean. It fades in and out rather than snapping, which is what keeps it
1419
+ * from reading as a glitch when the cursor crosses the reveal band.
1420
+ *
1421
+ * Reveal is driven by an explicit `setPointer` from the chart, **not** by
1422
+ * `rc.hoverId`. Hover ids come from `bestHit`, which picks the nearest primitive
1423
+ * — so a drawing or an order line near the bottom of the chart would win the
1424
+ * hit and silently hide the controls. Pointer position is the honest input here;
1425
+ * hit-testing still owns the buttons themselves.
1426
+ */
1427
+
1428
+ /** Command each button runs. These are `Chart` shortcut command ids. */
1429
+ type TimeNavigatorAction = 'zoomOut' | 'zoomIn' | 'panLeftBar' | 'panRightBar';
1430
+ interface TimeNavigatorOptions {
1431
+ /** Prefix for hit ids. Lets a host run more than one. */
1432
+ id: string;
1433
+ /** Buttons, left to right. A `null` inserts a gap between groups. */
1434
+ buttons: readonly (TimeNavigatorAction | null)[];
1435
+ /** Button box size in media px. */
1436
+ size: number;
1437
+ /** Gap between buttons, and the wider gap a `null` produces. */
1438
+ gap: number;
1439
+ groupGap: number;
1440
+ /** Distance from the bottom of the plot to the bottom of the buttons. */
1441
+ bottomMargin: number;
1442
+ /**
1443
+ * Height of the reveal band above the plot bottom. The pointer anywhere in
1444
+ * this band brings the controls in.
1445
+ */
1446
+ revealHeight: number;
1447
+ /** Seconds the fade takes. 0 disables the animation. */
1448
+ fadeSeconds: number;
1449
+ /** Tooltip label per action. */
1450
+ labels: Record<TimeNavigatorAction, string>;
1451
+ /** Optional keyboard hint shown next to the label, e.g. `"Ctrl + −"`. */
1452
+ hints: Partial<Record<TimeNavigatorAction, string>>;
1453
+ /** Show the tooltip above the hovered button. */
1454
+ showTooltip: boolean;
1455
+ font: number;
1456
+ radius: number;
1457
+ zOrder: ZOrder;
1458
+ }
1459
+
1411
1460
  /**
1412
1461
  * Top-level chart orchestrator (ARCHITECTURE.md §3.3). Owns the shared
1413
1462
  * DataLayer + time scale, the panes, the invalidate mask, and the render loop.
@@ -1468,6 +1517,12 @@ interface ChartOptions {
1468
1517
  * `(s) => new Date(s * 1000).toISOString().slice(11, 16)`.
1469
1518
  */
1470
1519
  timeFormatter?: (utcSeconds: number, tickMark?: TickMarkType) => string;
1520
+ /**
1521
+ * Hover-revealed zoom / step controls above the time axis (TradingView-style).
1522
+ * `true` by default — they stay invisible until the pointer nears the bottom
1523
+ * of the chart. Pass `false` to drop them, or an options object to restyle.
1524
+ */
1525
+ timeNavigator?: boolean | Partial<TimeNavigatorOptions>;
1471
1526
  }
1472
1527
  interface AddSeriesOptions {
1473
1528
  /** Target pane index (0 = price). Higher panes are created on demand. */
@@ -1603,6 +1658,9 @@ declare class Chart {
1603
1658
  private _priceScaleOptions;
1604
1659
  private _timeFormatter;
1605
1660
  private _leftAxisWidth;
1661
+ private _timeNav;
1662
+ /** Pane the navigator is currently attached to, so it can follow the bottom. */
1663
+ private _timeNavPane;
1606
1664
  constructor(container: HTMLElement, options?: ChartOptions);
1607
1665
  /** Register a callback fired when the user pans near the left (oldest) edge. */
1608
1666
  setHistoryLoader(loader: () => void): void;
@@ -1875,6 +1933,22 @@ declare class Chart {
1875
1933
  private _handleLegendAction;
1876
1934
  /** Cumulative top + height of each pane, by weight (the source of truth for hit-testing). */
1877
1935
  private _paneLayout;
1936
+ /**
1937
+ * Keyboard hints for the navigator tooltips, read from the live keymap so a
1938
+ * rebind shows up in the tooltip instead of a stale hardcoded string. The
1939
+ * one-bar step buttons have no default binding, so they get no hint.
1940
+ */
1941
+ private _navHints;
1942
+ /**
1943
+ * Keep the navigator on the bottom pane — it belongs just above the time
1944
+ * axis, and adding or removing a pane moves which one that is.
1945
+ */
1946
+ private _syncTimeNavPane;
1947
+ /**
1948
+ * Push the pointer to the navigator and keep painting while it fades, so the
1949
+ * animation runs even when nothing else on the chart is changing.
1950
+ */
1951
+ private _feedTimeNav;
1878
1952
  private _renderContext;
1879
1953
  private _observeSize;
1880
1954
  private _onFrame;
package/dist/index.d.ts CHANGED
@@ -707,6 +707,8 @@ declare class Pane {
707
707
  /** Remove a series record if present; returns true if it was found. */
708
708
  removeSeries(record: SeriesRecord): boolean;
709
709
  series(): readonly SeriesRecord[];
710
+ /** Primitives attached to this pane, in draw order. */
711
+ primitives(): readonly IPrimitive[];
710
712
  addPrimitive(primitive: IPrimitive, host: PrimitiveHost): void;
711
713
  /** Remove a primitive if present; returns true if it was found. */
712
714
  removePrimitive(primitive: IPrimitive): boolean;
@@ -1532,6 +1534,98 @@ declare class EventMarkers implements IPrimitive {
1532
1534
  hitTest(x: number, y: number): PrimitiveHit | null;
1533
1535
  }
1534
1536
 
1537
+ /**
1538
+ * Time navigator (ARCHITECTURE.md §8) — the hover-revealed zoom / step controls
1539
+ * that sit just above the time axis: `−` `+` to zoom, `‹` `›` to step one bar.
1540
+ *
1541
+ * Invisible until the pointer nears the bottom of the chart, so a clean chart
1542
+ * stays clean. It fades in and out rather than snapping, which is what keeps it
1543
+ * from reading as a glitch when the cursor crosses the reveal band.
1544
+ *
1545
+ * Reveal is driven by an explicit `setPointer` from the chart, **not** by
1546
+ * `rc.hoverId`. Hover ids come from `bestHit`, which picks the nearest primitive
1547
+ * — so a drawing or an order line near the bottom of the chart would win the
1548
+ * hit and silently hide the controls. Pointer position is the honest input here;
1549
+ * hit-testing still owns the buttons themselves.
1550
+ */
1551
+
1552
+ /** Command each button runs. These are `Chart` shortcut command ids. */
1553
+ type TimeNavigatorAction = 'zoomOut' | 'zoomIn' | 'panLeftBar' | 'panRightBar';
1554
+ interface TimeNavigatorOptions {
1555
+ /** Prefix for hit ids. Lets a host run more than one. */
1556
+ id: string;
1557
+ /** Buttons, left to right. A `null` inserts a gap between groups. */
1558
+ buttons: readonly (TimeNavigatorAction | null)[];
1559
+ /** Button box size in media px. */
1560
+ size: number;
1561
+ /** Gap between buttons, and the wider gap a `null` produces. */
1562
+ gap: number;
1563
+ groupGap: number;
1564
+ /** Distance from the bottom of the plot to the bottom of the buttons. */
1565
+ bottomMargin: number;
1566
+ /**
1567
+ * Height of the reveal band above the plot bottom. The pointer anywhere in
1568
+ * this band brings the controls in.
1569
+ */
1570
+ revealHeight: number;
1571
+ /** Seconds the fade takes. 0 disables the animation. */
1572
+ fadeSeconds: number;
1573
+ /** Tooltip label per action. */
1574
+ labels: Record<TimeNavigatorAction, string>;
1575
+ /** Optional keyboard hint shown next to the label, e.g. `"Ctrl + −"`. */
1576
+ hints: Partial<Record<TimeNavigatorAction, string>>;
1577
+ /** Show the tooltip above the hovered button. */
1578
+ showTooltip: boolean;
1579
+ font: number;
1580
+ radius: number;
1581
+ zOrder: ZOrder;
1582
+ }
1583
+ declare const DEFAULT_TIME_NAVIGATOR_OPTIONS: TimeNavigatorOptions;
1584
+ declare class TimeNavigator implements IPrimitive {
1585
+ private _opts;
1586
+ private _host;
1587
+ /** Button geometry from the last paint, in media px relative to the plot. */
1588
+ private _boxes;
1589
+ /** Pointer in plot-local media px, or null when it left the pane. */
1590
+ private _pointer;
1591
+ /** 0 hidden, 1 fully shown. Eased toward the target each frame. */
1592
+ private _opacity;
1593
+ private _lastFrameMs;
1594
+ private _now;
1595
+ constructor(opts?: Partial<TimeNavigatorOptions>, now?: () => number);
1596
+ attached(host: PrimitiveHost): void;
1597
+ detached(): void;
1598
+ zOrder(): ZOrder;
1599
+ options(): TimeNavigatorOptions;
1600
+ setOptions(patch: Partial<TimeNavigatorOptions>): void;
1601
+ /**
1602
+ * Tell the navigator where the pointer is, in plot-local media px. `null`
1603
+ * when it leaves. The chart calls this; hosts driving their own navigator
1604
+ * should too.
1605
+ */
1606
+ setPointer(p: {
1607
+ x: number;
1608
+ y: number;
1609
+ } | null): void;
1610
+ /** True when the pointer is inside the reveal band. */
1611
+ private _revealed;
1612
+ private _targetOpacity;
1613
+ /** Top of the reveal band, recomputed each paint from the plot height. */
1614
+ private _revealTop;
1615
+ /** Whether the fade is still running — the chart keeps painting while true. */
1616
+ animating(): boolean;
1617
+ draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
1618
+ /** Which button the pointer is over, or null. */
1619
+ private _hoveredAction;
1620
+ private _button;
1621
+ private _tooltip;
1622
+ /**
1623
+ * Buttons hit-test only while visible, so a hidden navigator never steals a
1624
+ * click from the chart body underneath it.
1625
+ */
1626
+ hitTest(x: number, y: number): PrimitiveHit | null;
1627
+ }
1628
+
1535
1629
  /**
1536
1630
  * Top-level chart orchestrator (ARCHITECTURE.md §3.3). Owns the shared
1537
1631
  * DataLayer + time scale, the panes, the invalidate mask, and the render loop.
@@ -1592,6 +1686,12 @@ interface ChartOptions {
1592
1686
  * `(s) => new Date(s * 1000).toISOString().slice(11, 16)`.
1593
1687
  */
1594
1688
  timeFormatter?: (utcSeconds: number, tickMark?: TickMarkType) => string;
1689
+ /**
1690
+ * Hover-revealed zoom / step controls above the time axis (TradingView-style).
1691
+ * `true` by default — they stay invisible until the pointer nears the bottom
1692
+ * of the chart. Pass `false` to drop them, or an options object to restyle.
1693
+ */
1694
+ timeNavigator?: boolean | Partial<TimeNavigatorOptions>;
1595
1695
  }
1596
1696
  interface AddSeriesOptions {
1597
1697
  /** Target pane index (0 = price). Higher panes are created on demand. */
@@ -1729,6 +1829,9 @@ declare class Chart {
1729
1829
  private _priceScaleOptions;
1730
1830
  private _timeFormatter;
1731
1831
  private _leftAxisWidth;
1832
+ private _timeNav;
1833
+ /** Pane the navigator is currently attached to, so it can follow the bottom. */
1834
+ private _timeNavPane;
1732
1835
  constructor(container: HTMLElement, options?: ChartOptions);
1733
1836
  /** Register a callback fired when the user pans near the left (oldest) edge. */
1734
1837
  setHistoryLoader(loader: () => void): void;
@@ -2001,6 +2104,22 @@ declare class Chart {
2001
2104
  private _handleLegendAction;
2002
2105
  /** Cumulative top + height of each pane, by weight (the source of truth for hit-testing). */
2003
2106
  private _paneLayout;
2107
+ /**
2108
+ * Keyboard hints for the navigator tooltips, read from the live keymap so a
2109
+ * rebind shows up in the tooltip instead of a stale hardcoded string. The
2110
+ * one-bar step buttons have no default binding, so they get no hint.
2111
+ */
2112
+ private _navHints;
2113
+ /**
2114
+ * Keep the navigator on the bottom pane — it belongs just above the time
2115
+ * axis, and adding or removing a pane moves which one that is.
2116
+ */
2117
+ private _syncTimeNavPane;
2118
+ /**
2119
+ * Push the pointer to the navigator and keep painting while it fades, so the
2120
+ * animation runs even when nothing else on the chart is changing.
2121
+ */
2122
+ private _feedTimeNav;
2004
2123
  private _renderContext;
2005
2124
  private _observeSize;
2006
2125
  private _onFrame;
@@ -2964,4 +3083,4 @@ declare function lerp(a: number, b: number, t: number): number;
2964
3083
  */
2965
3084
  declare function roundToTick(value: number, step: number): number;
2966
3085
 
2967
- export { ALT_PRESET, type AddSeriesOptions, type AggTick, BUILTIN_COMMANDS, type Bar, type BarUpdate, type BarsRequest, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, CandleBuilder, type CandleBuilderOptions, type CandleStyle, type CandleUpdate, Chart, type ChartEvent, type ChartOptions, type ChartState, type ChartTheme, type CrosshairMoveEvent, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, type DataFeed, type DepthLevel, type DrawItem, EventMarkers, FakeDataFeed, type FeedScheduler, type HistogramStyle, INDICATOR_LINE_STYLES, INDICATOR_SOURCES, type IPrimitive, IST_OFFSET_SECONDS, type IndicatorApi, type IndicatorAttachContext, type IndicatorDescriptor, type IndicatorHost, type IndicatorInput, type IndicatorLevel, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, InvalidationLevel, type KeymapEntry, type LateTickPolicy, type LegendValue, type LinePoint, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OriginalTime, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PlaceOrder, type PositionSide, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveHit, type PrimitiveHost, type PrimitiveRenderContext, type RendererEntry, type RestoreReport, type SeriesApi, type SeriesDataItem, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, type Tick, TickBarAggregator, type TickMarkType, type TickTimeframe, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, type UnsubscribeFn, VERSION, type VolumeMode, type WatermarkPosition, type Whitespace, type WsControlMessage, type WsMode, type WsState, type ZOrder, atr, autoscaleRange, bestHit, bitmapSize, clamp, compactVolume, conflateBars, conflateItems, conflationGroupSize, createChart, darkTheme, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, formatCombo, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, generateBars, getChartType, getIndicator, hasIndicator, indicatorDefaults, indicatorStyleInputs, intervalToSeconds, isNewIstDay, isReservedCombo, isValidCombo, isWhitespace, istStringToUtcSeconds, lerp, lightTheme, mapHistoryResponse, mapOrder, mapPosition, markerSizePx, mergeBars, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, plotStyleKeys, precisionForStep, registerChartType, registerIndicator, registeredChartTypes, registeredIndicators, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, snapToDevicePixel, sourceValue, sourceValues, supertrend, supertrendSeries, toBar, trueRange, utcSecondsToIstDateString, utcSecondsToIstParts, version, verticalGradient, watermarkRect };
3086
+ export { ALT_PRESET, type AddSeriesOptions, type AggTick, BUILTIN_COMMANDS, type Bar, type BarUpdate, type BarsRequest, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, CandleBuilder, type CandleBuilderOptions, type CandleStyle, type CandleUpdate, Chart, type ChartEvent, type ChartOptions, type ChartState, type ChartTheme, type CrosshairMoveEvent, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIME_NAVIGATOR_OPTIONS, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, type DataFeed, type DepthLevel, type DrawItem, EventMarkers, FakeDataFeed, type FeedScheduler, type HistogramStyle, INDICATOR_LINE_STYLES, INDICATOR_SOURCES, type IPrimitive, IST_OFFSET_SECONDS, type IndicatorApi, type IndicatorAttachContext, type IndicatorDescriptor, type IndicatorHost, type IndicatorInput, type IndicatorLevel, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, InvalidationLevel, type KeymapEntry, type LateTickPolicy, type LegendValue, type LinePoint, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OriginalTime, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PlaceOrder, type PositionSide, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveHit, type PrimitiveHost, type PrimitiveRenderContext, type RendererEntry, type RestoreReport, type SeriesApi, type SeriesDataItem, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, type Tick, TickBarAggregator, type TickMarkType, type TickTimeframe, TimeNavigator, type TimeNavigatorAction, type TimeNavigatorOptions, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, type UnsubscribeFn, VERSION, type VolumeMode, type WatermarkPosition, type Whitespace, type WsControlMessage, type WsMode, type WsState, type ZOrder, atr, autoscaleRange, bestHit, bitmapSize, clamp, compactVolume, conflateBars, conflateItems, conflationGroupSize, createChart, darkTheme, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, formatCombo, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, generateBars, getChartType, getIndicator, hasIndicator, indicatorDefaults, indicatorStyleInputs, intervalToSeconds, isNewIstDay, isReservedCombo, isValidCombo, isWhitespace, istStringToUtcSeconds, lerp, lightTheme, mapHistoryResponse, mapOrder, mapPosition, markerSizePx, mergeBars, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, plotStyleKeys, precisionForStep, registerChartType, registerIndicator, registeredChartTypes, registeredIndicators, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, snapToDevicePixel, sourceValue, sourceValues, supertrend, supertrendSeries, toBar, trueRange, utcSecondsToIstDateString, utcSecondsToIstParts, version, verticalGradient, watermarkRect };