hyperprop-charting-library 0.1.137 → 0.1.139
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/hyperprop-charting-library.cjs +653 -2
- package/dist/hyperprop-charting-library.d.ts +168 -1
- package/dist/hyperprop-charting-library.js +653 -2
- package/dist/index.cjs +653 -2
- package/dist/index.d.cts +168 -1
- package/dist/index.d.ts +168 -1
- package/dist/index.js +653 -2
- package/docs/API.md +151 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -78,6 +78,9 @@ interface ChartOptions {
|
|
|
78
78
|
pinOutOfRangeLines?: boolean;
|
|
79
79
|
doubleClickEnabled?: boolean;
|
|
80
80
|
doubleClickAction?: "reset" | "placeLimitOrder";
|
|
81
|
+
keyboard?: KeyboardOptions;
|
|
82
|
+
accessibility?: AccessibilityOptions;
|
|
83
|
+
downsampling?: DownsamplingOptions;
|
|
81
84
|
crosshair?: CrosshairOptions;
|
|
82
85
|
grid?: GridOptions;
|
|
83
86
|
watermark?: WatermarkOptions;
|
|
@@ -164,6 +167,36 @@ interface DrawingSelectEvent {
|
|
|
164
167
|
pointIndex?: number;
|
|
165
168
|
x: number;
|
|
166
169
|
y: number;
|
|
170
|
+
/** On-screen box of the drawing, for anchoring a host toolbar to it. */
|
|
171
|
+
bounds?: DrawingBounds;
|
|
172
|
+
}
|
|
173
|
+
/** Canvas-pixel bounding box of a drawing, relative to the chart canvas. */
|
|
174
|
+
interface DrawingBounds {
|
|
175
|
+
left: number;
|
|
176
|
+
top: number;
|
|
177
|
+
right: number;
|
|
178
|
+
bottom: number;
|
|
179
|
+
centerX: number;
|
|
180
|
+
centerY: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Emitted whenever the selected drawing's on-screen box moves — selection,
|
|
184
|
+
* deselection (payload `null`), drag, edit, pan, zoom or resize. Hosts render
|
|
185
|
+
* their own floating toolbar and position it from `bounds`, keeping it inside
|
|
186
|
+
* `plot`; the chart never has to draw toolbar chrome itself.
|
|
187
|
+
*/
|
|
188
|
+
interface DrawingSelectionChangeEvent {
|
|
189
|
+
drawing: DrawingObjectOptions;
|
|
190
|
+
bounds: DrawingBounds;
|
|
191
|
+
/** Plot rectangle, so a toolbar can be clamped inside the chart area. */
|
|
192
|
+
plot: {
|
|
193
|
+
left: number;
|
|
194
|
+
top: number;
|
|
195
|
+
right: number;
|
|
196
|
+
bottom: number;
|
|
197
|
+
};
|
|
198
|
+
/** True while the drawing is actively being dragged or resized. */
|
|
199
|
+
dragging: boolean;
|
|
167
200
|
}
|
|
168
201
|
interface DrawingHoverEvent {
|
|
169
202
|
drawing: DrawingObjectOptions | null;
|
|
@@ -470,6 +503,106 @@ interface CrosshairPriceActionEvent {
|
|
|
470
503
|
y: number;
|
|
471
504
|
price: number;
|
|
472
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* What the pointer was over when the context menu was requested. Hosts switch
|
|
508
|
+
* on this to show the right menu instead of re-deriving it from coordinates.
|
|
509
|
+
*/
|
|
510
|
+
type ChartContextMenuRegion = "plot" | "drawing" | "indicator-pane" | "x-axis" | "y-axis";
|
|
511
|
+
interface ChartContextMenuEvent {
|
|
512
|
+
region: ChartContextMenuRegion;
|
|
513
|
+
/** Canvas-relative position. */
|
|
514
|
+
x: number;
|
|
515
|
+
y: number;
|
|
516
|
+
/** Viewport position, ready to place a DOM menu without re-measuring. */
|
|
517
|
+
clientX: number;
|
|
518
|
+
clientY: number;
|
|
519
|
+
/** Price under the pointer (main pane regions only). */
|
|
520
|
+
price?: number;
|
|
521
|
+
index?: number;
|
|
522
|
+
time?: string;
|
|
523
|
+
point?: OhlcDataPoint;
|
|
524
|
+
/** Set for region "drawing"; the drawing is also selected by the chart. */
|
|
525
|
+
drawing?: DrawingObjectOptions;
|
|
526
|
+
drawingTarget?: "line" | "handle";
|
|
527
|
+
pointIndex?: number;
|
|
528
|
+
/** Set for region "indicator-pane". */
|
|
529
|
+
indicator?: {
|
|
530
|
+
id: string;
|
|
531
|
+
type: string;
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/** Built-in keyboard actions, reported after the chart applies them. */
|
|
535
|
+
type ChartKeyboardAction = "delete-drawing" | "cancel" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
|
|
536
|
+
interface ChartKeyboardShortcutEvent {
|
|
537
|
+
action: ChartKeyboardAction;
|
|
538
|
+
/** The originating `KeyboardEvent.key`. */
|
|
539
|
+
key: string;
|
|
540
|
+
shiftKey: boolean;
|
|
541
|
+
/** The drawing that was removed, for "delete-drawing" (so hosts can undo). */
|
|
542
|
+
drawing?: DrawingObjectOptions;
|
|
543
|
+
}
|
|
544
|
+
interface KeyboardOptions {
|
|
545
|
+
/**
|
|
546
|
+
* Master switch for the built-in shortcuts. Shortcuts only fire while the
|
|
547
|
+
* chart canvas has focus, so they never swallow typing in host inputs.
|
|
548
|
+
* Default true.
|
|
549
|
+
*/
|
|
550
|
+
enabled?: boolean;
|
|
551
|
+
/** Bars panned per arrow-key press (Shift multiplies by 10). Default 1. */
|
|
552
|
+
panBars?: number;
|
|
553
|
+
/** Delete/Backspace removes the selected drawing. Default true. */
|
|
554
|
+
deleteSelectedDrawing?: boolean;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Deep zoom-out rendering. Once bars are narrower than `thresholdPx`, several
|
|
558
|
+
* of them share a pixel column and drawing each one is wasted work, so the
|
|
559
|
+
* chart aggregates every column into one min/max bucket: path operations then
|
|
560
|
+
* scale with the chart's width instead of the number of bars. Extremes are
|
|
561
|
+
* preserved exactly (a spike never disappears), which is why this uses
|
|
562
|
+
* min/max rather than sampling.
|
|
563
|
+
*/
|
|
564
|
+
interface DownsamplingOptions {
|
|
565
|
+
/** Default true. */
|
|
566
|
+
enabled?: boolean;
|
|
567
|
+
/** Bar width in pixels below which columns are aggregated. Default 1.5. */
|
|
568
|
+
thresholdPx?: number;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* An extra instrument overlaid on the main pane ("compare" in TradingView).
|
|
572
|
+
* The host owns the data and keeps it fresh; the chart aligns it to the main
|
|
573
|
+
* series by timestamp and draws it.
|
|
574
|
+
*/
|
|
575
|
+
interface CompareSeriesOptions {
|
|
576
|
+
id: string;
|
|
577
|
+
/** Shown on the right-axis tag, e.g. "NQ1!". */
|
|
578
|
+
label?: string;
|
|
579
|
+
/** Bars for the compared instrument; aligned to the main series by time. */
|
|
580
|
+
data: OhlcDataPoint[];
|
|
581
|
+
color?: string;
|
|
582
|
+
lineWidth?: number;
|
|
583
|
+
style?: "line" | "area";
|
|
584
|
+
/**
|
|
585
|
+
* "percent" (default) normalises both instruments to their first visible
|
|
586
|
+
* bar so shapes can be compared regardless of nominal price — the same
|
|
587
|
+
* thing TradingView does when you add a comparison. "price" plots the raw
|
|
588
|
+
* values on the main scale, which only makes sense for related instruments.
|
|
589
|
+
*/
|
|
590
|
+
scale?: "percent" | "price";
|
|
591
|
+
visible?: boolean;
|
|
592
|
+
/** Let this series widen the price scale. Default true. */
|
|
593
|
+
includeInAutoScale?: boolean;
|
|
594
|
+
}
|
|
595
|
+
interface AccessibilityOptions {
|
|
596
|
+
/** aria-label on the canvas. Default "Price chart". */
|
|
597
|
+
label?: string;
|
|
598
|
+
/**
|
|
599
|
+
* Longer description exposed via aria-description, e.g. the symbol and
|
|
600
|
+
* interval currently shown.
|
|
601
|
+
*/
|
|
602
|
+
description?: string;
|
|
603
|
+
/** Make the canvas focusable so keyboard users can reach it. Default true. */
|
|
604
|
+
focusable?: boolean;
|
|
605
|
+
}
|
|
473
606
|
interface TickerLineOptions {
|
|
474
607
|
visible?: boolean;
|
|
475
608
|
style?: "solid" | "dotted" | "dashed";
|
|
@@ -581,6 +714,29 @@ interface ChartInstance {
|
|
|
581
714
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
582
715
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
583
716
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
717
|
+
/**
|
|
718
|
+
* Selection geometry stream for a host-rendered floating toolbar. Fires on
|
|
719
|
+
* select/deselect and on every frame where the selected drawing's box moves
|
|
720
|
+
* (drag, pan, zoom, resize), so the toolbar can track the shape instead of
|
|
721
|
+
* sitting in a fixed corner. Payload is `null` when nothing is selected.
|
|
722
|
+
*/
|
|
723
|
+
onSelectionChange: (handler: ((event: DrawingSelectionChangeEvent | null) => void) | null) => void;
|
|
724
|
+
/** Current selection and its on-screen box, for imperative reads. */
|
|
725
|
+
getSelectedDrawing: () => {
|
|
726
|
+
drawing: DrawingObjectOptions;
|
|
727
|
+
bounds: DrawingBounds;
|
|
728
|
+
} | null;
|
|
729
|
+
/**
|
|
730
|
+
* Right-click (or long-press equivalent) with everything the host needs to
|
|
731
|
+
* open the correct menu: which region was hit, the price/bar under the
|
|
732
|
+
* pointer, and the drawing or indicator pane it landed on. The chart always
|
|
733
|
+
* suppresses the browser's native menu.
|
|
734
|
+
*/
|
|
735
|
+
onContextMenu: (handler: ((event: ChartContextMenuEvent) => void) | null) => void;
|
|
736
|
+
/** Fires after a built-in keyboard shortcut is applied. */
|
|
737
|
+
onKeyboardShortcut: (handler: ((event: ChartKeyboardShortcutEvent) => void) | null) => void;
|
|
738
|
+
/** Focus the chart canvas so keyboard shortcuts apply to it. */
|
|
739
|
+
focus: () => void;
|
|
584
740
|
setMagnetMode: (mode: "none" | "weak" | "strong") => void;
|
|
585
741
|
getMagnetMode: () => "none" | "weak" | "strong";
|
|
586
742
|
/**
|
|
@@ -592,6 +748,17 @@ interface ChartInstance {
|
|
|
592
748
|
*/
|
|
593
749
|
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
594
750
|
getPriceScale: () => PriceScaleOptions;
|
|
751
|
+
/**
|
|
752
|
+
* Overlay other instruments on the main pane for comparison. Series are
|
|
753
|
+
* aligned to the main series by timestamp (last known value carries forward
|
|
754
|
+
* across gaps) and, by default, normalised to percent change from the first
|
|
755
|
+
* visible bar so differently-priced instruments stay comparable. Data is not
|
|
756
|
+
* part of `saveState()` — the host re-supplies it.
|
|
757
|
+
*/
|
|
758
|
+
setCompareSeries: (series: CompareSeriesOptions[]) => void;
|
|
759
|
+
addCompareSeries: (series: CompareSeriesOptions) => void;
|
|
760
|
+
removeCompareSeries: (id: string) => void;
|
|
761
|
+
getCompareSeries: () => CompareSeriesOptions[];
|
|
595
762
|
cancelDrawing: () => boolean;
|
|
596
763
|
setTradeMarkers: (markers: TradeMarkerOptions[]) => void;
|
|
597
764
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
@@ -781,4 +948,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
781
948
|
|
|
782
949
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
783
950
|
|
|
784
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type ChartSavedState, type ChartType, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
951
|
+
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,9 @@ interface ChartOptions {
|
|
|
78
78
|
pinOutOfRangeLines?: boolean;
|
|
79
79
|
doubleClickEnabled?: boolean;
|
|
80
80
|
doubleClickAction?: "reset" | "placeLimitOrder";
|
|
81
|
+
keyboard?: KeyboardOptions;
|
|
82
|
+
accessibility?: AccessibilityOptions;
|
|
83
|
+
downsampling?: DownsamplingOptions;
|
|
81
84
|
crosshair?: CrosshairOptions;
|
|
82
85
|
grid?: GridOptions;
|
|
83
86
|
watermark?: WatermarkOptions;
|
|
@@ -164,6 +167,36 @@ interface DrawingSelectEvent {
|
|
|
164
167
|
pointIndex?: number;
|
|
165
168
|
x: number;
|
|
166
169
|
y: number;
|
|
170
|
+
/** On-screen box of the drawing, for anchoring a host toolbar to it. */
|
|
171
|
+
bounds?: DrawingBounds;
|
|
172
|
+
}
|
|
173
|
+
/** Canvas-pixel bounding box of a drawing, relative to the chart canvas. */
|
|
174
|
+
interface DrawingBounds {
|
|
175
|
+
left: number;
|
|
176
|
+
top: number;
|
|
177
|
+
right: number;
|
|
178
|
+
bottom: number;
|
|
179
|
+
centerX: number;
|
|
180
|
+
centerY: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Emitted whenever the selected drawing's on-screen box moves — selection,
|
|
184
|
+
* deselection (payload `null`), drag, edit, pan, zoom or resize. Hosts render
|
|
185
|
+
* their own floating toolbar and position it from `bounds`, keeping it inside
|
|
186
|
+
* `plot`; the chart never has to draw toolbar chrome itself.
|
|
187
|
+
*/
|
|
188
|
+
interface DrawingSelectionChangeEvent {
|
|
189
|
+
drawing: DrawingObjectOptions;
|
|
190
|
+
bounds: DrawingBounds;
|
|
191
|
+
/** Plot rectangle, so a toolbar can be clamped inside the chart area. */
|
|
192
|
+
plot: {
|
|
193
|
+
left: number;
|
|
194
|
+
top: number;
|
|
195
|
+
right: number;
|
|
196
|
+
bottom: number;
|
|
197
|
+
};
|
|
198
|
+
/** True while the drawing is actively being dragged or resized. */
|
|
199
|
+
dragging: boolean;
|
|
167
200
|
}
|
|
168
201
|
interface DrawingHoverEvent {
|
|
169
202
|
drawing: DrawingObjectOptions | null;
|
|
@@ -470,6 +503,106 @@ interface CrosshairPriceActionEvent {
|
|
|
470
503
|
y: number;
|
|
471
504
|
price: number;
|
|
472
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* What the pointer was over when the context menu was requested. Hosts switch
|
|
508
|
+
* on this to show the right menu instead of re-deriving it from coordinates.
|
|
509
|
+
*/
|
|
510
|
+
type ChartContextMenuRegion = "plot" | "drawing" | "indicator-pane" | "x-axis" | "y-axis";
|
|
511
|
+
interface ChartContextMenuEvent {
|
|
512
|
+
region: ChartContextMenuRegion;
|
|
513
|
+
/** Canvas-relative position. */
|
|
514
|
+
x: number;
|
|
515
|
+
y: number;
|
|
516
|
+
/** Viewport position, ready to place a DOM menu without re-measuring. */
|
|
517
|
+
clientX: number;
|
|
518
|
+
clientY: number;
|
|
519
|
+
/** Price under the pointer (main pane regions only). */
|
|
520
|
+
price?: number;
|
|
521
|
+
index?: number;
|
|
522
|
+
time?: string;
|
|
523
|
+
point?: OhlcDataPoint;
|
|
524
|
+
/** Set for region "drawing"; the drawing is also selected by the chart. */
|
|
525
|
+
drawing?: DrawingObjectOptions;
|
|
526
|
+
drawingTarget?: "line" | "handle";
|
|
527
|
+
pointIndex?: number;
|
|
528
|
+
/** Set for region "indicator-pane". */
|
|
529
|
+
indicator?: {
|
|
530
|
+
id: string;
|
|
531
|
+
type: string;
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/** Built-in keyboard actions, reported after the chart applies them. */
|
|
535
|
+
type ChartKeyboardAction = "delete-drawing" | "cancel" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
|
|
536
|
+
interface ChartKeyboardShortcutEvent {
|
|
537
|
+
action: ChartKeyboardAction;
|
|
538
|
+
/** The originating `KeyboardEvent.key`. */
|
|
539
|
+
key: string;
|
|
540
|
+
shiftKey: boolean;
|
|
541
|
+
/** The drawing that was removed, for "delete-drawing" (so hosts can undo). */
|
|
542
|
+
drawing?: DrawingObjectOptions;
|
|
543
|
+
}
|
|
544
|
+
interface KeyboardOptions {
|
|
545
|
+
/**
|
|
546
|
+
* Master switch for the built-in shortcuts. Shortcuts only fire while the
|
|
547
|
+
* chart canvas has focus, so they never swallow typing in host inputs.
|
|
548
|
+
* Default true.
|
|
549
|
+
*/
|
|
550
|
+
enabled?: boolean;
|
|
551
|
+
/** Bars panned per arrow-key press (Shift multiplies by 10). Default 1. */
|
|
552
|
+
panBars?: number;
|
|
553
|
+
/** Delete/Backspace removes the selected drawing. Default true. */
|
|
554
|
+
deleteSelectedDrawing?: boolean;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Deep zoom-out rendering. Once bars are narrower than `thresholdPx`, several
|
|
558
|
+
* of them share a pixel column and drawing each one is wasted work, so the
|
|
559
|
+
* chart aggregates every column into one min/max bucket: path operations then
|
|
560
|
+
* scale with the chart's width instead of the number of bars. Extremes are
|
|
561
|
+
* preserved exactly (a spike never disappears), which is why this uses
|
|
562
|
+
* min/max rather than sampling.
|
|
563
|
+
*/
|
|
564
|
+
interface DownsamplingOptions {
|
|
565
|
+
/** Default true. */
|
|
566
|
+
enabled?: boolean;
|
|
567
|
+
/** Bar width in pixels below which columns are aggregated. Default 1.5. */
|
|
568
|
+
thresholdPx?: number;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* An extra instrument overlaid on the main pane ("compare" in TradingView).
|
|
572
|
+
* The host owns the data and keeps it fresh; the chart aligns it to the main
|
|
573
|
+
* series by timestamp and draws it.
|
|
574
|
+
*/
|
|
575
|
+
interface CompareSeriesOptions {
|
|
576
|
+
id: string;
|
|
577
|
+
/** Shown on the right-axis tag, e.g. "NQ1!". */
|
|
578
|
+
label?: string;
|
|
579
|
+
/** Bars for the compared instrument; aligned to the main series by time. */
|
|
580
|
+
data: OhlcDataPoint[];
|
|
581
|
+
color?: string;
|
|
582
|
+
lineWidth?: number;
|
|
583
|
+
style?: "line" | "area";
|
|
584
|
+
/**
|
|
585
|
+
* "percent" (default) normalises both instruments to their first visible
|
|
586
|
+
* bar so shapes can be compared regardless of nominal price — the same
|
|
587
|
+
* thing TradingView does when you add a comparison. "price" plots the raw
|
|
588
|
+
* values on the main scale, which only makes sense for related instruments.
|
|
589
|
+
*/
|
|
590
|
+
scale?: "percent" | "price";
|
|
591
|
+
visible?: boolean;
|
|
592
|
+
/** Let this series widen the price scale. Default true. */
|
|
593
|
+
includeInAutoScale?: boolean;
|
|
594
|
+
}
|
|
595
|
+
interface AccessibilityOptions {
|
|
596
|
+
/** aria-label on the canvas. Default "Price chart". */
|
|
597
|
+
label?: string;
|
|
598
|
+
/**
|
|
599
|
+
* Longer description exposed via aria-description, e.g. the symbol and
|
|
600
|
+
* interval currently shown.
|
|
601
|
+
*/
|
|
602
|
+
description?: string;
|
|
603
|
+
/** Make the canvas focusable so keyboard users can reach it. Default true. */
|
|
604
|
+
focusable?: boolean;
|
|
605
|
+
}
|
|
473
606
|
interface TickerLineOptions {
|
|
474
607
|
visible?: boolean;
|
|
475
608
|
style?: "solid" | "dotted" | "dashed";
|
|
@@ -581,6 +714,29 @@ interface ChartInstance {
|
|
|
581
714
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
582
715
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
583
716
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
717
|
+
/**
|
|
718
|
+
* Selection geometry stream for a host-rendered floating toolbar. Fires on
|
|
719
|
+
* select/deselect and on every frame where the selected drawing's box moves
|
|
720
|
+
* (drag, pan, zoom, resize), so the toolbar can track the shape instead of
|
|
721
|
+
* sitting in a fixed corner. Payload is `null` when nothing is selected.
|
|
722
|
+
*/
|
|
723
|
+
onSelectionChange: (handler: ((event: DrawingSelectionChangeEvent | null) => void) | null) => void;
|
|
724
|
+
/** Current selection and its on-screen box, for imperative reads. */
|
|
725
|
+
getSelectedDrawing: () => {
|
|
726
|
+
drawing: DrawingObjectOptions;
|
|
727
|
+
bounds: DrawingBounds;
|
|
728
|
+
} | null;
|
|
729
|
+
/**
|
|
730
|
+
* Right-click (or long-press equivalent) with everything the host needs to
|
|
731
|
+
* open the correct menu: which region was hit, the price/bar under the
|
|
732
|
+
* pointer, and the drawing or indicator pane it landed on. The chart always
|
|
733
|
+
* suppresses the browser's native menu.
|
|
734
|
+
*/
|
|
735
|
+
onContextMenu: (handler: ((event: ChartContextMenuEvent) => void) | null) => void;
|
|
736
|
+
/** Fires after a built-in keyboard shortcut is applied. */
|
|
737
|
+
onKeyboardShortcut: (handler: ((event: ChartKeyboardShortcutEvent) => void) | null) => void;
|
|
738
|
+
/** Focus the chart canvas so keyboard shortcuts apply to it. */
|
|
739
|
+
focus: () => void;
|
|
584
740
|
setMagnetMode: (mode: "none" | "weak" | "strong") => void;
|
|
585
741
|
getMagnetMode: () => "none" | "weak" | "strong";
|
|
586
742
|
/**
|
|
@@ -592,6 +748,17 @@ interface ChartInstance {
|
|
|
592
748
|
*/
|
|
593
749
|
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
594
750
|
getPriceScale: () => PriceScaleOptions;
|
|
751
|
+
/**
|
|
752
|
+
* Overlay other instruments on the main pane for comparison. Series are
|
|
753
|
+
* aligned to the main series by timestamp (last known value carries forward
|
|
754
|
+
* across gaps) and, by default, normalised to percent change from the first
|
|
755
|
+
* visible bar so differently-priced instruments stay comparable. Data is not
|
|
756
|
+
* part of `saveState()` — the host re-supplies it.
|
|
757
|
+
*/
|
|
758
|
+
setCompareSeries: (series: CompareSeriesOptions[]) => void;
|
|
759
|
+
addCompareSeries: (series: CompareSeriesOptions) => void;
|
|
760
|
+
removeCompareSeries: (id: string) => void;
|
|
761
|
+
getCompareSeries: () => CompareSeriesOptions[];
|
|
595
762
|
cancelDrawing: () => boolean;
|
|
596
763
|
setTradeMarkers: (markers: TradeMarkerOptions[]) => void;
|
|
597
764
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
@@ -781,4 +948,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
781
948
|
|
|
782
949
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
783
950
|
|
|
784
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type ChartSavedState, type ChartType, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
951
|
+
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|