hyperprop-charting-library 0.1.135 → 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/index.d.cts CHANGED
@@ -91,6 +91,16 @@ interface ChartOptions {
91
91
  }
92
92
  type IndicatorPane = "overlay" | "separate";
93
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"
94
104
  /**
95
105
  * TradingView-style ruler. Unlike every other tool it is transient: the
96
106
  * measurement overlay is never added to the drawings list (no
@@ -588,6 +598,28 @@ interface ChartInstance {
588
598
  updateIndicator: (id: string, patch: Partial<IndicatorInstanceOptions>) => void;
589
599
  removeIndicator: (id: string) => void;
590
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;
591
623
  resize: (width?: number, height?: number) => void;
592
624
  destroy: () => void;
593
625
  }
@@ -611,6 +643,22 @@ interface ViewportState {
611
643
  /** Manual Y-axis max override (null = auto-scale). */
612
644
  yMax: number | null;
613
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
+ }
614
662
 
615
663
  interface ScriptIndicatorInputDef {
616
664
  key: string;
@@ -678,4 +726,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
678
726
 
679
727
  declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
680
728
 
681
- 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
@@ -91,6 +91,16 @@ interface ChartOptions {
91
91
  }
92
92
  type IndicatorPane = "overlay" | "separate";
93
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"
94
104
  /**
95
105
  * TradingView-style ruler. Unlike every other tool it is transient: the
96
106
  * measurement overlay is never added to the drawings list (no
@@ -588,6 +598,28 @@ interface ChartInstance {
588
598
  updateIndicator: (id: string, patch: Partial<IndicatorInstanceOptions>) => void;
589
599
  removeIndicator: (id: string) => void;
590
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;
591
623
  resize: (width?: number, height?: number) => void;
592
624
  destroy: () => void;
593
625
  }
@@ -611,6 +643,22 @@ interface ViewportState {
611
643
  /** Manual Y-axis max override (null = auto-scale). */
612
644
  yMax: number | null;
613
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
+ }
614
662
 
615
663
  interface ScriptIndicatorInputDef {
616
664
  key: string;
@@ -678,4 +726,4 @@ declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) =>
678
726
 
679
727
  declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
680
728
 
681
- 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 };