@christtrade/depth 0.18.0 → 0.20.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.
Files changed (35) hide show
  1. package/README.md +175 -96
  2. package/depth.cjs +67 -68
  3. package/depth.css +1 -1
  4. package/depth.mjs +67 -68
  5. package/depth.nopreflight.css +1 -1
  6. package/package.json +1 -1
  7. package/types/components/ui/collapse.d.ts +10 -0
  8. package/types/components/ui/resizable.d.ts +1 -1
  9. package/types/core/BarStore.d.ts +69 -0
  10. package/types/core/CellEngines.d.ts +15 -0
  11. package/types/core/ChartModel.d.ts +3 -2
  12. package/types/core/DataEngine.d.ts +15 -2
  13. package/types/core/DepthChart.d.ts +50 -6
  14. package/types/core/ExecutionEngine.d.ts +3 -2
  15. package/types/core/PluginSchedule.d.ts +11 -0
  16. package/types/core/RenderEngine.d.ts +44 -14
  17. package/types/core/ThemeRegistry.d.ts +18 -0
  18. package/types/core/TypedEventBus.d.ts +27 -10
  19. package/types/core/builtin-themes.d.ts +7 -0
  20. package/types/core/index.d.ts +6 -4
  21. package/types/core/plugin-startup.d.ts +4 -2
  22. package/types/core/theme-style.d.ts +9 -0
  23. package/types/hooks/useChartData.d.ts +11 -10
  24. package/types/hooks/useChartHandlers.d.ts +5 -4
  25. package/types/hooks/useChartInteraction.d.ts +5 -4
  26. package/types/hooks/useChartSettings.d.ts +5 -4
  27. package/types/hooks/useChartSubscriptions.d.ts +6 -4
  28. package/types/hooks/useChartView.d.ts +5 -4
  29. package/types/hooks/useRenderEngine.d.ts +2 -50
  30. package/types/interfaces/ICoordinateTransformer.d.ts +0 -1
  31. package/types/interfaces/plugins/IChartPlugin.d.ts +32 -5
  32. package/types/interfaces/plugins/IDrawingPlugin.d.ts +2 -2
  33. package/types/lib/matchingEngine.d.ts +3 -2
  34. package/types/lib/renderers/renderer.d.ts +6 -39
  35. package/types/lib/types/chart-settings.d.ts +16 -0
@@ -5,11 +5,12 @@ import { type Crosshair } from '../lib/renderers/renderer';
5
5
  import { type PluginToolActiveContext } from '../core/DrawingRegistry';
6
6
  import type { ChartTypePlugin, ChartTypeActiveContext } from '../core/PluginRegistry';
7
7
  import { type RenderEngine } from '../core/RenderEngine';
8
+ import { type BarStore } from '../core/BarStore';
8
9
  import { type TypedEventBus } from '../core/TypedEventBus';
9
10
  import { type SessionMapper } from '../core/SessionMapper';
10
11
  import { type TradingSession, type DataLevel, type SymbolInfo } from '../interfaces/IDataAdapter';
11
12
  import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
12
- import { type ViewBounds, type PriceHistory, type TradePoint, type OhlcvBarMs } from '../lib/types';
13
+ import { type ViewBounds, type PriceHistory, type TradePoint } from '../lib/types';
13
14
  import { type FootprintBar } from '../lib/types/footprint';
14
15
  import { type ChartSettings } from '../lib/types/chart-settings';
15
16
  import { type Timeframe } from '../lib/timeframes';
@@ -102,10 +103,10 @@ export interface UseChartInteractionParams {
102
103
  allPriceHistoryRef: MutableRefObject<PriceHistory[]>;
103
104
  ohlcvBarsRef: MutableRefObject<{
104
105
  barNs: bigint;
105
- bars: OhlcvBarMs[];
106
- display: OhlcvBarMs[];
106
+ bars: BarStore;
107
+ display: BarStore;
107
108
  }>;
108
- previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
109
+ previewBarsRef: MutableRefObject<BarStore>;
109
110
  dataLevelRef: MutableRefObject<DataLevel | null>;
110
111
  openBarRef: MutableRefObject<FootprintBar | null>;
111
112
  candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
@@ -1,9 +1,10 @@
1
1
  import { type MutableRefObject } from 'react';
2
- import { type ViewBounds, type TradePoint, type PriceHistory, type OhlcvBarMs } from '../lib/types';
2
+ import { type ViewBounds, type TradePoint, type PriceHistory } from '../lib/types';
3
3
  import { type FootprintBar } from '../lib/types/footprint';
4
4
  import { type ChartSettings } from '../lib/types/chart-settings';
5
5
  import { type DataLevel } from '../interfaces/IDataAdapter';
6
6
  import { type RenderEngine } from '../core/RenderEngine';
7
+ import { type BarStore } from '../core/BarStore';
7
8
  import { type CompactBuffer } from '../lib/compact-buffer';
8
9
  export interface UseChartSettingsParams {
9
10
  chartSettingsRef: MutableRefObject<ChartSettings>;
@@ -14,10 +15,10 @@ export interface UseChartSettingsParams {
14
15
  dataLevelRef: MutableRefObject<DataLevel | null>;
15
16
  ohlcvBarsRef: MutableRefObject<{
16
17
  barNs: bigint;
17
- bars: OhlcvBarMs[];
18
- display: OhlcvBarMs[];
18
+ bars: BarStore;
19
+ display: BarStore;
19
20
  }>;
20
- previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
21
+ previewBarsRef: MutableRefObject<BarStore>;
21
22
  openBarRef: MutableRefObject<FootprintBar | null>;
22
23
  horizonRef: MutableRefObject<bigint>;
23
24
  compactBufRef: MutableRefObject<CompactBuffer>;
@@ -2,10 +2,11 @@ import { type MutableRefObject } from 'react';
2
2
  import { type ChartTypePlugin, type ChartTypeActiveContext } from '../core/PluginRegistry';
3
3
  import { type AccountManager } from '../core/AccountManager';
4
4
  import { type RenderEngine } from '../core/RenderEngine';
5
+ import { type BarStore } from '../core/BarStore';
5
6
  import { type TypedEventBus } from '../core/TypedEventBus';
6
7
  import { type ChartPane, type Indicator } from '../lib/types/indicator-types';
7
8
  import { type ChartSettings } from '../lib/types/chart-settings';
8
- import { type TradePoint, type OhlcvBarMs, type ViewBounds } from '../lib/types';
9
+ import { type TradePoint, type ViewBounds } from '../lib/types';
9
10
  import { type DataLevel } from '../interfaces/IDataAdapter';
10
11
  import { type FootprintBar } from '../lib/types/footprint';
11
12
  import { type SerialTrade } from '../lib/types';
@@ -27,12 +28,12 @@ export interface UseChartSubscriptionsParams {
27
28
  chartSettingsRef: MutableRefObject<ChartSettings>;
28
29
  pluginChartTypeComputedRef: MutableRefObject<Map<string, unknown>>;
29
30
  dataLevelRef: MutableRefObject<DataLevel | null>;
30
- previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
31
+ previewBarsRef: MutableRefObject<BarStore>;
31
32
  candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
32
33
  ohlcvBarsRef: MutableRefObject<{
33
34
  barNs: bigint;
34
- bars: OhlcvBarMs[];
35
- display: OhlcvBarMs[];
35
+ bars: BarStore;
36
+ display: BarStore;
36
37
  }>;
37
38
  openBarRef: MutableRefObject<FootprintBar | null>;
38
39
  viewRef: MutableRefObject<ViewBounds | null>;
@@ -54,6 +55,7 @@ export interface UseChartSubscriptionsParams {
54
55
  autofitIndicatorPanes: () => void;
55
56
  handleAddIndicator: (id: string) => void;
56
57
  handleRemoveIndicator: (id: string) => void;
58
+ userRemoveIndicator: (id: string) => void;
57
59
  onSymbolChange: (symbol: string) => void;
58
60
  /** This layout's live sync switches (a ref: the handlers outlive a render). */
59
61
  syncInLayoutRef: MutableRefObject<SyncInLayout>;
@@ -1,8 +1,9 @@
1
1
  import { type MutableRefObject } from 'react';
2
- import { type ViewBounds, type TradePoint, type PriceHistory, type OhlcvBarMs } from '../lib/types';
2
+ import { type ViewBounds, type TradePoint, type PriceHistory } from '../lib/types';
3
3
  import { type ChartSettings } from '../lib/types/chart-settings';
4
4
  import { type DataLevel } from '../interfaces/IDataAdapter';
5
5
  import { type RenderEngine } from '../core/RenderEngine';
6
+ import { BarStore } from '../core/BarStore';
6
7
  import { type ChartPane, type Indicator } from '../lib/types/indicator-types';
7
8
  import { FootprintBar } from '../core';
8
9
  export interface UseChartViewParams {
@@ -12,11 +13,11 @@ export interface UseChartViewParams {
12
13
  setChartSettings: (updater: ChartSettings | ((prev: ChartSettings) => ChartSettings)) => void;
13
14
  priceHistoryRef: MutableRefObject<PriceHistory[]>;
14
15
  tradesRef: MutableRefObject<TradePoint[]>;
15
- previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
16
+ previewBarsRef: MutableRefObject<BarStore>;
16
17
  ohlcvBarsRef: MutableRefObject<{
17
18
  barNs: bigint;
18
- bars: OhlcvBarMs[];
19
- display: OhlcvBarMs[];
19
+ bars: BarStore;
20
+ display: BarStore;
20
21
  }>;
21
22
  openBarRef: MutableRefObject<FootprintBar>;
22
23
  chartSettingsRef: MutableRefObject<ChartSettings>;
@@ -1,24 +1,7 @@
1
1
  import { type MutableRefObject, type RefObject } from 'react';
2
2
  import { RenderEngine } from '../core/RenderEngine';
3
3
  import { type TypedEventBus } from '../core/TypedEventBus';
4
- import { type ViewBounds, type TradePoint, type PriceHistory, type OhlcvBarMs } from '../lib/types';
5
- import { type ChartPane, type Indicator, type Rect } from '../lib/types/indicator-types';
6
- import { type FootprintBar } from '../lib/types/footprint';
7
- import { type ChartSettings } from '../lib/types/chart-settings';
8
- import { type DataLevel } from '../interfaces/IDataAdapter';
9
- import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
10
- type HeatmapBitmapOffsets = {
11
- x: number;
12
- y: number;
13
- w: number;
14
- h: number;
15
- };
16
- type CacheBounds = {
17
- tMin: bigint;
18
- tMax: bigint;
19
- pMin: number;
20
- pMax: number;
21
- };
4
+ import { type ViewBounds } from '../lib/types';
22
5
  export interface UseRenderEngineParams {
23
6
  renderEngineRef: MutableRefObject<RenderEngine | null>;
24
7
  baseCanvasRef: RefObject<HTMLCanvasElement>;
@@ -29,36 +12,5 @@ export interface UseRenderEngineParams {
29
12
  * other cells can tell our repaints from theirs. */
30
13
  chartId: number;
31
14
  viewRef: MutableRefObject<ViewBounds | null>;
32
- /** Auto-computed right price-axis width (css px). */
33
- priceScaleWidthRef: MutableRefObject<number>;
34
- tradesRef: MutableRefObject<TradePoint[]>;
35
- getLayouts: () => Record<string, Rect>;
36
- heatmapBitmapRef: MutableRefObject<ImageBitmap | null>;
37
- cacheBoundsRef: MutableRefObject<CacheBounds | null>;
38
- heatmapBitmapOffsetsRef: MutableRefObject<HeatmapBitmapOffsets>;
39
- panesRef: MutableRefObject<ChartPane[]>;
40
- indicatorsRef: MutableRefObject<Indicator[]>;
41
- priceHistoryRef: MutableRefObject<PriceHistory[]>;
42
- footprintBarsRef: MutableRefObject<FootprintBar[]>;
43
- activeTimeframeRef: MutableRefObject<{
44
- barNs: bigint;
45
- }>;
46
- chartSettingsRef: MutableRefObject<ChartSettings>;
47
- horizonRef: MutableRefObject<bigint>;
48
- candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
49
- openBarRef: MutableRefObject<FootprintBar | null>;
50
- dataLevelRef: MutableRefObject<DataLevel | null>;
51
- ohlcvBarsRef: MutableRefObject<{
52
- barNs: bigint;
53
- bars: OhlcvBarMs[];
54
- display: OhlcvBarMs[];
55
- }>;
56
- previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
57
- transformer: LiveTransformer;
58
- hideTimeScale: boolean;
59
15
  }
60
- export interface UseRenderEngineResult {
61
- doBaseRedraw: () => void;
62
- }
63
- export declare function useRenderEngine(p: UseRenderEngineParams): UseRenderEngineResult;
64
- export {};
16
+ export declare function useRenderEngine(p: UseRenderEngineParams): void;
@@ -102,4 +102,3 @@ export declare class LiveTransformer {
102
102
  private _pctPriceToY;
103
103
  private _pctYToPrice;
104
104
  }
105
- export type TransformedDrawHook = (ctx: CanvasRenderingContext2D, transformer: LiveTransformer) => void;
@@ -4,13 +4,15 @@
4
4
  * ChartPlugin and is installed through PluginContext.
5
5
  */
6
6
  import type { TypedEventBus, InterceptableEvent, Interceptor } from '../../core/TypedEventBus';
7
- import type { RenderEngine, DrawHook } from '../../core/RenderEngine';
7
+ import type { RenderEngine, DrawHook, DrawPhase } from '../../core/RenderEngine';
8
8
  import type { ExecutionEngine } from '../../core/ExecutionEngine';
9
9
  import type { GlobalChartBus } from '../../core/GlobalChartBus';
10
10
  import type { LiveTransformer } from '../ICoordinateTransformer';
11
+ import type { ChartColors } from '../../lib/types/chart-settings';
11
12
  import type { DataLevel, OhlcvBar, SymbolInfo, TickEvent } from '../IDataAdapter';
12
13
  import type { SerialTrade, PriceHistory } from '../../lib/types';
13
14
  import type { FootprintBar } from '../../lib/types/footprint';
15
+ import type { BarStore } from '../../core/BarStore';
14
16
  import type { BracketAmendment } from '../../lib/types/trading-types';
15
17
  import type { PlaceOrderRequest } from '../../lib/matchingEngine';
16
18
  import type { CommandDef, CvarDef } from '../../console/Console';
@@ -54,8 +56,16 @@ export interface ContextMenuItem {
54
56
  export interface ThemeDef {
55
57
  id: string;
56
58
  name: string;
59
+ /** Dark surfaces or light ones - what `onThemeChange` reports. Defaults to dark. */
60
+ dark?: boolean;
57
61
  /** CSS variables to inject - keys are var names without the leading '--'. */
58
62
  vars: Record<string, string>;
63
+ /**
64
+ * Canvas colors: candles, grid, background, crosshair and the rest. Each one
65
+ * only applies where the user hasn't picked their own; leave a key out to keep
66
+ * the default.
67
+ */
68
+ chart?: Partial<ChartColors>;
59
69
  }
60
70
  export type SettingSchemaType = 'number' | 'string' | 'boolean' | 'color' | 'select';
61
71
  export interface SettingSchema {
@@ -94,6 +104,13 @@ export interface PluginSchedule {
94
104
  timeout(ms: number, fn: () => void): () => void;
95
105
  /** Managed animation-frame callback - auto-cancelled on plugin teardown. */
96
106
  raf(fn: () => void): () => void;
107
+ /**
108
+ * Repeating animation loop, at most `fps` a second, 0 = every frame. Skips frames
109
+ * while the chart is off screen; the first frame back gets one interval as `dt`.
110
+ * `time` is the raf timestamp, `dt` the ms since the last call. Auto-cancelled on
111
+ * plugin teardown.
112
+ */
113
+ frames(fps: number, fn: (time: number, dt: number) => void): () => void;
97
114
  }
98
115
  export type NotifyLevel = 'info' | 'success' | 'warn' | 'error';
99
116
  export interface NotifyOptions {
@@ -124,7 +141,7 @@ export interface PluginExecutionSurface {
124
141
  export interface PluginLifecycle {
125
142
  onSymbolChange(cb: (symbol: string) => void): () => void;
126
143
  onTimeframeChange(cb: (tf: string) => void): () => void;
127
- onThemeChange(cb: (theme: 'light' | 'dark') => void): () => void;
144
+ onThemeChange(cb: (mode: 'light' | 'dark', theme: ThemeDef) => void): () => void;
128
145
  onFocus(cb: (id: number) => void): () => void;
129
146
  onBlur(cb: () => void): () => void;
130
147
  }
@@ -136,7 +153,17 @@ export interface PluginDataSnapshot {
136
153
  trades: SerialTrade[];
137
154
  footprintBars: FootprintBar[];
138
155
  priceHistory: PriceHistory[];
139
- /** Always present - synthesised from footprintBars when dataLevel is l3/tick. */
156
+ /**
157
+ * Every loaded bar, as columns: `bars.close[i]`. Always present - synthesised
158
+ * from footprintBars when dataLevel is l3/tick. Read the columns off it each
159
+ * time; they're swapped as bars load. It's the store the chart draws from so
160
+ * read it, don't change it. `clone()` it for a copy of your own.
161
+ */
162
+ bars: BarStore;
163
+ /**
164
+ * `bars` as objects, built on first read and kept until the bars change.
165
+ * @deprecated ~176 bytes a bar and a full copy - use `bars`.
166
+ */
140
167
  ohlcvBars: OhlcvBar[];
141
168
  /** Populated when dataLevel is tick or l3. */
142
169
  ticks: TickEvent[];
@@ -181,7 +208,7 @@ export interface PluginContext {
181
208
  * data has arrived.
182
209
  *
183
210
  * This is the one you want for "what is the price right now". The last entry
184
- * of `getData().ohlcvBars` is the last bar that was *loaded*, which during
211
+ * of `getData().bars` is the last bar that was *loaded*, which during
185
212
  * replay is somewhere in the future and at the fetch resolution rather than
186
213
  * the charted timeframe.
187
214
  *
@@ -193,7 +220,7 @@ export interface PluginContext {
193
220
  registerPanel(id: string, element: React.ReactNode, title?: string, visible?: boolean): () => void;
194
221
  getSettings<T>(defaults: T): T;
195
222
  saveSettings<T>(patch: Partial<T>): void;
196
- addOverlay(phase: 'before-base' | 'after-base' | 'after-ui', hook: DrawHook): () => void;
223
+ addOverlay(phase: DrawPhase, hook: DrawHook): () => void;
197
224
  registerToolbarItem(item: ToolbarItem): () => void;
198
225
  registerBottomBarItem(id: string, render: () => React.ReactNode): BottomBarHandle;
199
226
  registerContextMenuItem(item: ContextMenuItem): () => void;
@@ -11,7 +11,7 @@
11
11
  import type { ChartPlugin } from './IChartPlugin';
12
12
  import type { Anchor } from '../../lib/types/drawing-types';
13
13
  import type { PluginDrawingRenderContext, PluginDrawingHitContext } from '../../core/DrawingRegistry';
14
- import type { OhlcvBar } from '../IDataAdapter';
14
+ import type { BarStore } from '../../core/BarStore';
15
15
  export interface Point {
16
16
  x: number;
17
17
  y: number;
@@ -54,7 +54,7 @@ export interface DrawingPlugin extends ChartPlugin {
54
54
  /**
55
55
  * Optionally snap an anchor to the nearest bar OHLC value during placement.
56
56
  */
57
- snap?(anchor: Anchor, bars: OhlcvBar[]): Anchor;
57
+ snap?(anchor: Anchor, bars: BarStore): Anchor;
58
58
  /** Serialise anchor positions to a JSON-safe value for persistence. */
59
59
  serialize(anchors: Anchor[]): unknown;
60
60
  /** Restore anchors from a previously serialised value. */
@@ -3,6 +3,7 @@ import type { Order, Fill, Position, BracketLevel, BracketAmendment, PriceTick,
3
3
  import type { MboEvent, PriceHistory } from './types';
4
4
  import type { OhlcvBar, SymbolInfo } from '../interfaces/IDataAdapter';
5
5
  import type { SerialTrade } from './types';
6
+ import { BarStore } from '../core/BarStore';
6
7
  import { TypedEventBus } from '../core';
7
8
  export declare function sanitizeMetadata(meta: Record<string, unknown> | undefined, symbol: string, quantity: number, symbolInfo?: SymbolInfo | null): Record<string, unknown>;
8
9
  export interface FeeSchedule {
@@ -78,12 +79,12 @@ export interface L3MatchingEngine {
78
79
  /** L3 path: ingest a compact buffer and then use seekTo to replay. */
79
80
  ingestCompactBuf: (buf: ArrayBuffer) => void;
80
81
  /** OHLCV path: ingest bars; seekTo advances bar by bar. Resets the replay cursor. */
81
- ingestOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
82
+ ingestOhlcvBars: (bars: OhlcvBar[] | BarStore, barNs?: bigint) => void;
82
83
  /**
83
84
  * OHLCV path: extend the buffer forward without rewinding the replay.
84
85
  * What a stream-append must use - see appendOhlcvBars for why.
85
86
  */
86
- appendOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
87
+ appendOhlcvBars: (bars: OhlcvBar[] | BarStore, barNs?: bigint) => void;
87
88
  /** OHLCV path: ingest finer-resolution bars so seekTo uses accurate mark prices within the open bar. */
88
89
  ingestSupplementalBars?: (bars: Array<{
89
90
  time: number;
@@ -6,6 +6,7 @@ import { ChartSettings } from '../types/chart-settings';
6
6
  import { ActiveDrawingTool, DraftDrawing, Drawing, DrawingAnchorId } from '../types/drawing-types';
7
7
  import { AccountSnapshot, DataLevel, LiveTransformer, OhlcvBar, SymbolInfo } from '../../core';
8
8
  import { SessionMapper } from '../../core/SessionMapper';
9
+ import type { BarStore } from '../../core/BarStore';
9
10
  import { PriceTransition } from '../priceTransition';
10
11
  import { OrdinalModel } from '../series/japaneseCharts';
11
12
  import type { CrosshairSync } from '../types/layout-sync';
@@ -22,17 +23,6 @@ export type Crosshair = {
22
23
  export declare const Y_AXIS_WIDTH = 65;
23
24
  export declare const X_AXIS_HEIGHT = 30;
24
25
  export declare const TRADE_SNAP_RADIUS = 12;
25
- export declare const COLORS: {
26
- background: string;
27
- buyLine: string;
28
- sellLine: string;
29
- grid: string;
30
- label: string;
31
- axisBg: string;
32
- crosshair: string;
33
- crosshairBg: string;
34
- crosshairText: string;
35
- };
36
26
  export declare function computeRightScaleWidth(bounds: ViewBounds, symbolInfo: SymbolInfo | undefined, chartSettings: ChartSettings, hidePriceScale?: boolean, ctx?: CanvasRenderingContext2D | null): number;
37
27
  export declare function drawBaseLayer(canvas: HTMLCanvasElement, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], trades: TradePoint[], priceHistory: PriceHistory[], snapshots: BookSnapshot[], bounds: ViewBounds, footprintBars: FootprintBar[], heatmapBitmap: ImageBitmap | null, bitmapOffsetX: number, bitmapOffsetY: number, bitmapOffsetW: number, bitmapOffsetH: number, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null,
38
28
  /** Live incrementally-built open bar - overrides the cache for the current bucket. */
@@ -42,22 +32,8 @@ openBar: {
42
32
  high: number;
43
33
  low: number;
44
34
  close: number;
45
- } | null, ohlcvBars: {
46
- time: number;
47
- open: number;
48
- high: number;
49
- low: number;
50
- close: number;
51
- volume: number;
52
- }[], transformer: LiveTransformer, isPluginChartType?: boolean, sessionMapper?: SessionMapper, dataLevel?: DataLevel, hidePriceScale?: boolean, hideTimeScale?: boolean, symbolInfo?: SymbolInfo, rightScaleWidth?: number): void;
53
- export declare function drawUILayer(canvas: HTMLCanvasElement, priceHistory: PriceHistory[], trades: TradePoint[], bounds: ViewBounds, crosshair: Crosshair, showTooltip: boolean, selectedTrade: TradePoint | null, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], hoveredDividerIdx: number, hoveringLegend: boolean, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null, ohlcvBars: {
54
- time: number;
55
- open: number;
56
- high: number;
57
- low: number;
58
- close: number;
59
- volume: number;
60
- }[], openBar: OhlcvBar, tradeLines: TradeLine[], tradeLineInteraction: any, hoveredLineId?: string | null, draggingLineId?: string | null, activeTool?: ActiveDrawingTool | null, draggingAnchor?: {
35
+ } | null, ohlcvBars: BarStore, transformer: LiveTransformer, isPluginChartType?: boolean, sessionMapper?: SessionMapper, dataLevel?: DataLevel, hidePriceScale?: boolean, hideTimeScale?: boolean, symbolInfo?: SymbolInfo, rightScaleWidth?: number): void;
36
+ export declare function drawUILayer(canvas: HTMLCanvasElement, priceHistory: PriceHistory[], trades: TradePoint[], bounds: ViewBounds, crosshair: Crosshair, showTooltip: boolean, selectedTrade: TradePoint | null, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], hoveredDividerIdx: number, hoveringLegend: boolean, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null, ohlcvBars: BarStore, openBar: OhlcvBar, tradeLines: TradeLine[], tradeLineInteraction: any, hoveredLineId?: string | null, draggingLineId?: string | null, activeTool?: ActiveDrawingTool | null, draggingAnchor?: {
61
37
  drawingId: string;
62
38
  anchor: DrawingAnchorId;
63
39
  } | null, holdingCtrl?: boolean | null, holdingShift?: boolean | null, footprintBars?: FootprintBar[] | null, drawings?: Drawing[] | null, draft?: DraftDrawing | null, transformer?: LiveTransformer, showShiftInfo?: boolean, shiftInfoAnchor?: {
@@ -76,15 +52,9 @@ export declare function drawHeatmap(ctx: CanvasRenderingContext2D, snapshots: Bo
76
52
  export declare function nearestIndex(priceHistory: PriceHistory[], target: bigint): number;
77
53
  export declare function nearestTradeIndex(trades: TradePoint[], target: bigint): number;
78
54
  export declare function findNearestTrade(clickX: number, clickY: number, trades: TradePoint[], bounds: ViewBounds, chartW: number, chartH: number, chartSettings: ChartSettings, horizon: bigint, transformer: LiveTransformer): TradePoint | null;
55
+ export declare function drawBackground(ctx: CanvasRenderingContext2D, cssW: number, cssH: number, chartSettings: ChartSettings): void;
79
56
  export declare const snapTs: (ts: bigint, tf: bigint, sessionMapper?: SessionMapper | null) => bigint;
80
- export declare const snapPrice: (snappedTs: bigint, rawPrice: number, chartSettings: ChartSettings, footprintBars: FootprintBar[], priceHistory: PriceHistory[], ohlcvBars: {
81
- time: number;
82
- open: number;
83
- high: number;
84
- low: number;
85
- close: number;
86
- volume: number;
87
- }[], dataLevel: DataLevel, horizon: bigint) => number;
57
+ export declare const snapPrice: (snappedTs: bigint, rawPrice: number, chartSettings: ChartSettings, footprintBars: FootprintBar[], priceHistory: PriceHistory[], ohlcvBars: BarStore, dataLevel: DataLevel, horizon: bigint) => number;
88
58
  export declare function drawTooltip(ctx: CanvasRenderingContext2D, mouse: {
89
59
  x: number;
90
60
  y: number;
@@ -97,10 +67,7 @@ export declare function isOrdinalChartType(t: ChartType): boolean;
97
67
  * (column timestamps) and autoscale (visible price extent), so all three derive
98
68
  * from one build.
99
69
  */
100
- export declare function getOrdinalModel(chartType: ChartType, chartSettings: ChartSettings, ohlcvBars: {
101
- time: number;
102
- close: number;
103
- }[] | undefined, candleCache: CandleCache | null, trades: TradePoint[], barNs: bigint): OrdinalModel | null;
70
+ export declare function getOrdinalModel(chartType: ChartType, chartSettings: ChartSettings, ohlcvBars: BarStore | undefined, candleCache: CandleCache | null, trades: TradePoint[], barNs: bigint): OrdinalModel | null;
104
71
  /**
105
72
  * Price extent of the columns currently visible under the transformer's view -
106
73
  * used to auto-scale the y-axis for ordinal charts (whose prices live in the
@@ -42,6 +42,9 @@ export type ChartSettings = {
42
42
  gridVerticalColor: string;
43
43
  crosshairMode: 'normal' | 'magnet' | 'hidden';
44
44
  crosshairColor: string;
45
+ /** The time and price boxes on the crosshair. */
46
+ crosshairLabelColor: string;
47
+ crosshairLabelTextColor: string;
45
48
  crosshairWidth: number;
46
49
  crosshairDash: number[];
47
50
  showBreaks: boolean;
@@ -56,8 +59,16 @@ export type ChartSettings = {
56
59
  statusLineFontSize: number;
57
60
  backgroundColor: string;
58
61
  axisBackgroundColor: string;
62
+ /** Tick labels on the price and time axis. */
63
+ axisTextColor: string;
64
+ /** The line between the plot and the axes. */
65
+ axisBorderColor: string;
66
+ /** Text on the colored price pills on the price axis. */
67
+ priceLabelTextColor: string;
59
68
  showBidLine: boolean;
60
69
  showAskLine: boolean;
70
+ bidLineColor: string;
71
+ askLineColor: string;
61
72
  showMidLine: boolean;
62
73
  showLastTradeLine: boolean;
63
74
  showFills: boolean;
@@ -89,3 +100,8 @@ export declare const DEFAULT_CHART_SETTINGS: ChartSettings;
89
100
  export declare function diffChartSettings(settings: ChartSettings): Partial<ChartSettings>;
90
101
  /** Re-expand a settings diff back onto the current defaults. */
91
102
  export declare function mergeChartSettings(diff?: Partial<ChartSettings>): ChartSettings;
103
+ /** The settings a theme can color. */
104
+ export declare const CHART_COLOR_KEYS: readonly ["upBodyColor", "downBodyColor", "upWickColor", "downWickColor", "upBorderColor", "downBorderColor", "gridHorizontalColor", "gridVerticalColor", "crosshairColor", "crosshairLabelColor", "crosshairLabelTextColor", "breaksColor", "backgroundColor", "axisBackgroundColor", "axisTextColor", "axisBorderColor", "priceLabelTextColor", "bidLineColor", "askLineColor", "heatmapColorBid", "heatmapColorAsk", "priceLineColor", "sessionHighlightColor"];
105
+ export type ChartColorKey = (typeof CHART_COLOR_KEYS)[number];
106
+ export type ChartColors = Pick<ChartSettings, ChartColorKey>;
107
+ export declare function themedSettings(settings: ChartSettings, colors?: Partial<ChartColors>): ChartSettings;