hyperprop-charting-library 0.1.134 → 0.1.136
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 +753 -8
- package/dist/hyperprop-charting-library.d.ts +66 -2
- package/dist/hyperprop-charting-library.js +753 -8
- package/dist/index.cjs +753 -8
- package/dist/index.d.cts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +753 -8
- package/docs/API.md +61 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -90,7 +90,25 @@ interface ChartOptions {
|
|
|
90
90
|
drawings?: DrawingObjectOptions[];
|
|
91
91
|
}
|
|
92
92
|
type IndicatorPane = "overlay" | "separate";
|
|
93
|
-
type DrawingToolType = "horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "rectangle" | "text" | "note"
|
|
93
|
+
type DrawingToolType = "horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "rectangle" | "text" | "note"
|
|
94
|
+
/** Three-point parallel channel: two clicks set the base line, a third sets the offset. */
|
|
95
|
+
| "parallel-channel"
|
|
96
|
+
/** Two-anchor bounding-box ellipse (created like `rectangle`). */
|
|
97
|
+
| "ellipse"
|
|
98
|
+
/** Trendline with an arrowhead at the second point. */
|
|
99
|
+
| "arrow"
|
|
100
|
+
/** Freehand polyline: press and drag to draw, release to commit. */
|
|
101
|
+
| "brush"
|
|
102
|
+
/** Text box with a connector line pointing at an anchored bar/price. */
|
|
103
|
+
| "callout"
|
|
104
|
+
/**
|
|
105
|
+
* TradingView-style ruler. Unlike every other tool it is transient: the
|
|
106
|
+
* measurement overlay is never added to the drawings list (no
|
|
107
|
+
* `onDrawingsChange`), and it clears on the next click, on Escape, or when
|
|
108
|
+
* the tool changes. Also reachable without arming the tool via Shift+drag
|
|
109
|
+
* on the plot.
|
|
110
|
+
*/
|
|
111
|
+
| "measure";
|
|
94
112
|
interface DrawingPoint {
|
|
95
113
|
index: number;
|
|
96
114
|
price: number;
|
|
@@ -552,6 +570,14 @@ interface ChartInstance {
|
|
|
552
570
|
removeDrawing: (id: string) => void;
|
|
553
571
|
clearDrawings: () => void;
|
|
554
572
|
onDrawingsChange: (handler: ((drawings: DrawingObjectOptions[]) => void) | null) => void;
|
|
573
|
+
/**
|
|
574
|
+
* Fires whenever the active drawing tool changes — including when the chart
|
|
575
|
+
* auto-reverts to the cursor after a tool completes (every drawing tool does
|
|
576
|
+
* this once its shape is placed; the transient `measure` tool does it after
|
|
577
|
+
* every measurement). Lets host toolbars stay in sync without polling
|
|
578
|
+
* `getActiveDrawingTool()`.
|
|
579
|
+
*/
|
|
580
|
+
onActiveDrawingToolChange: (handler: ((tool: DrawingToolType | null) => void) | null) => void;
|
|
555
581
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
556
582
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
557
583
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
@@ -572,6 +598,28 @@ interface ChartInstance {
|
|
|
572
598
|
updateIndicator: (id: string, patch: Partial<IndicatorInstanceOptions>) => void;
|
|
573
599
|
removeIndicator: (id: string) => void;
|
|
574
600
|
setIndicators: (indicators: IndicatorInstanceOptions[]) => void;
|
|
601
|
+
/**
|
|
602
|
+
* Snapshot the full user-visible chart setup (chart type, viewport,
|
|
603
|
+
* drawings, indicators, magnet mode, drawing defaults) as one versioned,
|
|
604
|
+
* JSON-serializable blob. Persist it anywhere and restore with `loadState`.
|
|
605
|
+
*/
|
|
606
|
+
saveState: () => ChartSavedState;
|
|
607
|
+
/**
|
|
608
|
+
* Restore a `saveState()` snapshot. Tolerant of partial blobs — missing
|
|
609
|
+
* sections are left untouched, so it also works as a bulk setter. Register
|
|
610
|
+
* any custom script indicator plugins *before* calling this, otherwise
|
|
611
|
+
* their instances are dropped with a console warning.
|
|
612
|
+
*/
|
|
613
|
+
loadState: (state: Partial<ChartSavedState>) => void;
|
|
614
|
+
/**
|
|
615
|
+
* Render the current frame to an image data URL (default PNG). Everything
|
|
616
|
+
* drawn on the chart canvas is included — candles, indicators, drawings,
|
|
617
|
+
* legends — at the device pixel ratio the chart renders at.
|
|
618
|
+
*/
|
|
619
|
+
takeScreenshot: (options?: {
|
|
620
|
+
type?: "image/png" | "image/jpeg";
|
|
621
|
+
quality?: number;
|
|
622
|
+
}) => string;
|
|
575
623
|
resize: (width?: number, height?: number) => void;
|
|
576
624
|
destroy: () => void;
|
|
577
625
|
}
|
|
@@ -595,6 +643,22 @@ interface ViewportState {
|
|
|
595
643
|
/** Manual Y-axis max override (null = auto-scale). */
|
|
596
644
|
yMax: number | null;
|
|
597
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* Everything a host needs to persist to restore the user's chart setup with
|
|
648
|
+
* one `loadState()` call: series style, viewport, drawings, indicator
|
|
649
|
+
* instances, magnet mode and per-tool drawing defaults. Chart *data* is not
|
|
650
|
+
* included — feed bars through `setData` as usual. Custom (script) indicator
|
|
651
|
+
* plugins must be registered before `loadState` so their instances resolve.
|
|
652
|
+
*/
|
|
653
|
+
interface ChartSavedState {
|
|
654
|
+
version: 1;
|
|
655
|
+
chartType: ChartType;
|
|
656
|
+
viewport: ViewportState;
|
|
657
|
+
drawings: DrawingObjectOptions[];
|
|
658
|
+
indicators: IndicatorInstanceOptions[];
|
|
659
|
+
magnetMode: "none" | "weak" | "strong";
|
|
660
|
+
drawingDefaults: Partial<Record<DrawingToolType, DrawingDefaults>>;
|
|
661
|
+
}
|
|
598
662
|
|
|
599
663
|
interface ScriptIndicatorInputDef {
|
|
600
664
|
key: string;
|
|
@@ -662,4 +726,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
662
726
|
|
|
663
727
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
664
728
|
|
|
665
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, 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 ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|
|
729
|
+
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 ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -90,7 +90,25 @@ interface ChartOptions {
|
|
|
90
90
|
drawings?: DrawingObjectOptions[];
|
|
91
91
|
}
|
|
92
92
|
type IndicatorPane = "overlay" | "separate";
|
|
93
|
-
type DrawingToolType = "horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "rectangle" | "text" | "note"
|
|
93
|
+
type DrawingToolType = "horizontal-line" | "vertical-line" | "trendline" | "ray" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "rectangle" | "text" | "note"
|
|
94
|
+
/** Three-point parallel channel: two clicks set the base line, a third sets the offset. */
|
|
95
|
+
| "parallel-channel"
|
|
96
|
+
/** Two-anchor bounding-box ellipse (created like `rectangle`). */
|
|
97
|
+
| "ellipse"
|
|
98
|
+
/** Trendline with an arrowhead at the second point. */
|
|
99
|
+
| "arrow"
|
|
100
|
+
/** Freehand polyline: press and drag to draw, release to commit. */
|
|
101
|
+
| "brush"
|
|
102
|
+
/** Text box with a connector line pointing at an anchored bar/price. */
|
|
103
|
+
| "callout"
|
|
104
|
+
/**
|
|
105
|
+
* TradingView-style ruler. Unlike every other tool it is transient: the
|
|
106
|
+
* measurement overlay is never added to the drawings list (no
|
|
107
|
+
* `onDrawingsChange`), and it clears on the next click, on Escape, or when
|
|
108
|
+
* the tool changes. Also reachable without arming the tool via Shift+drag
|
|
109
|
+
* on the plot.
|
|
110
|
+
*/
|
|
111
|
+
| "measure";
|
|
94
112
|
interface DrawingPoint {
|
|
95
113
|
index: number;
|
|
96
114
|
price: number;
|
|
@@ -552,6 +570,14 @@ interface ChartInstance {
|
|
|
552
570
|
removeDrawing: (id: string) => void;
|
|
553
571
|
clearDrawings: () => void;
|
|
554
572
|
onDrawingsChange: (handler: ((drawings: DrawingObjectOptions[]) => void) | null) => void;
|
|
573
|
+
/**
|
|
574
|
+
* Fires whenever the active drawing tool changes — including when the chart
|
|
575
|
+
* auto-reverts to the cursor after a tool completes (every drawing tool does
|
|
576
|
+
* this once its shape is placed; the transient `measure` tool does it after
|
|
577
|
+
* every measurement). Lets host toolbars stay in sync without polling
|
|
578
|
+
* `getActiveDrawingTool()`.
|
|
579
|
+
*/
|
|
580
|
+
onActiveDrawingToolChange: (handler: ((tool: DrawingToolType | null) => void) | null) => void;
|
|
555
581
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
556
582
|
onDrawingDoubleClick: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
557
583
|
onDrawingEditText: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
@@ -572,6 +598,28 @@ interface ChartInstance {
|
|
|
572
598
|
updateIndicator: (id: string, patch: Partial<IndicatorInstanceOptions>) => void;
|
|
573
599
|
removeIndicator: (id: string) => void;
|
|
574
600
|
setIndicators: (indicators: IndicatorInstanceOptions[]) => void;
|
|
601
|
+
/**
|
|
602
|
+
* Snapshot the full user-visible chart setup (chart type, viewport,
|
|
603
|
+
* drawings, indicators, magnet mode, drawing defaults) as one versioned,
|
|
604
|
+
* JSON-serializable blob. Persist it anywhere and restore with `loadState`.
|
|
605
|
+
*/
|
|
606
|
+
saveState: () => ChartSavedState;
|
|
607
|
+
/**
|
|
608
|
+
* Restore a `saveState()` snapshot. Tolerant of partial blobs — missing
|
|
609
|
+
* sections are left untouched, so it also works as a bulk setter. Register
|
|
610
|
+
* any custom script indicator plugins *before* calling this, otherwise
|
|
611
|
+
* their instances are dropped with a console warning.
|
|
612
|
+
*/
|
|
613
|
+
loadState: (state: Partial<ChartSavedState>) => void;
|
|
614
|
+
/**
|
|
615
|
+
* Render the current frame to an image data URL (default PNG). Everything
|
|
616
|
+
* drawn on the chart canvas is included — candles, indicators, drawings,
|
|
617
|
+
* legends — at the device pixel ratio the chart renders at.
|
|
618
|
+
*/
|
|
619
|
+
takeScreenshot: (options?: {
|
|
620
|
+
type?: "image/png" | "image/jpeg";
|
|
621
|
+
quality?: number;
|
|
622
|
+
}) => string;
|
|
575
623
|
resize: (width?: number, height?: number) => void;
|
|
576
624
|
destroy: () => void;
|
|
577
625
|
}
|
|
@@ -595,6 +643,22 @@ interface ViewportState {
|
|
|
595
643
|
/** Manual Y-axis max override (null = auto-scale). */
|
|
596
644
|
yMax: number | null;
|
|
597
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* Everything a host needs to persist to restore the user's chart setup with
|
|
648
|
+
* one `loadState()` call: series style, viewport, drawings, indicator
|
|
649
|
+
* instances, magnet mode and per-tool drawing defaults. Chart *data* is not
|
|
650
|
+
* included — feed bars through `setData` as usual. Custom (script) indicator
|
|
651
|
+
* plugins must be registered before `loadState` so their instances resolve.
|
|
652
|
+
*/
|
|
653
|
+
interface ChartSavedState {
|
|
654
|
+
version: 1;
|
|
655
|
+
chartType: ChartType;
|
|
656
|
+
viewport: ViewportState;
|
|
657
|
+
drawings: DrawingObjectOptions[];
|
|
658
|
+
indicators: IndicatorInstanceOptions[];
|
|
659
|
+
magnetMode: "none" | "weak" | "strong";
|
|
660
|
+
drawingDefaults: Partial<Record<DrawingToolType, DrawingDefaults>>;
|
|
661
|
+
}
|
|
598
662
|
|
|
599
663
|
interface ScriptIndicatorInputDef {
|
|
600
664
|
key: string;
|
|
@@ -662,4 +726,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
|
|
|
662
726
|
|
|
663
727
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
664
728
|
|
|
665
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, 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 ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|
|
729
|
+
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 ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptPlotSpec, type TickerLineOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, validateScriptSource };
|