hyperprop-charting-library 0.1.60 → 0.1.61
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.
|
@@ -964,6 +964,8 @@ function createChart(element, options = {}) {
|
|
|
964
964
|
let drawingSelectHandler = null;
|
|
965
965
|
let drawingHoverHandler = null;
|
|
966
966
|
let lastHoveredDrawingId = null;
|
|
967
|
+
const drawingToolDefaults = /* @__PURE__ */ new Map();
|
|
968
|
+
const getDrawingToolDefaults = (tool) => drawingToolDefaults.get(tool) ?? {};
|
|
967
969
|
const emitDrawingsChange = () => {
|
|
968
970
|
drawingsChangeHandler?.(drawings.map((drawing) => serializeDrawing(drawing)));
|
|
969
971
|
};
|
|
@@ -3346,13 +3348,14 @@ function createChart(element, options = {}) {
|
|
|
3346
3348
|
return false;
|
|
3347
3349
|
}
|
|
3348
3350
|
if (activeDrawingTool === "horizontal-line") {
|
|
3351
|
+
const defaults = getDrawingToolDefaults("horizontal-line");
|
|
3349
3352
|
drawings.push(
|
|
3350
3353
|
normalizeDrawingState({
|
|
3351
3354
|
type: "horizontal-line",
|
|
3352
3355
|
points: [point],
|
|
3353
|
-
color: "#38bdf8",
|
|
3354
|
-
style: "
|
|
3355
|
-
width: 1
|
|
3356
|
+
color: defaults.color ?? "#38bdf8",
|
|
3357
|
+
style: defaults.style ?? "solid",
|
|
3358
|
+
width: defaults.width ?? 1
|
|
3356
3359
|
})
|
|
3357
3360
|
);
|
|
3358
3361
|
emitDrawingsChange();
|
|
@@ -3372,12 +3375,13 @@ function createChart(element, options = {}) {
|
|
|
3372
3375
|
draw();
|
|
3373
3376
|
return true;
|
|
3374
3377
|
}
|
|
3378
|
+
const defaults = getDrawingToolDefaults("trendline");
|
|
3375
3379
|
draftDrawing = normalizeDrawingState({
|
|
3376
3380
|
type: "trendline",
|
|
3377
3381
|
points: [point, point],
|
|
3378
|
-
color: "#2563eb",
|
|
3379
|
-
style: "solid",
|
|
3380
|
-
width: 2
|
|
3382
|
+
color: defaults.color ?? "#2563eb",
|
|
3383
|
+
style: defaults.style ?? "solid",
|
|
3384
|
+
width: defaults.width ?? 2
|
|
3381
3385
|
});
|
|
3382
3386
|
draw();
|
|
3383
3387
|
return true;
|
|
@@ -3395,18 +3399,26 @@ function createChart(element, options = {}) {
|
|
|
3395
3399
|
draw();
|
|
3396
3400
|
return true;
|
|
3397
3401
|
}
|
|
3402
|
+
const defaults = getDrawingToolDefaults("fib-retracement");
|
|
3398
3403
|
draftDrawing = normalizeDrawingState({
|
|
3399
3404
|
type: "fib-retracement",
|
|
3400
3405
|
points: [point, point],
|
|
3401
|
-
color: "#2563eb",
|
|
3402
|
-
style: "solid",
|
|
3403
|
-
width: 1
|
|
3406
|
+
color: defaults.color ?? "#2563eb",
|
|
3407
|
+
style: defaults.style ?? "solid",
|
|
3408
|
+
width: defaults.width ?? 1
|
|
3404
3409
|
});
|
|
3405
3410
|
draw();
|
|
3406
3411
|
return true;
|
|
3407
3412
|
}
|
|
3408
3413
|
return false;
|
|
3409
3414
|
};
|
|
3415
|
+
const setDrawingDefaults = (tool, defaults) => {
|
|
3416
|
+
if (defaults === null) {
|
|
3417
|
+
drawingToolDefaults.delete(tool);
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
drawingToolDefaults.set(tool, { ...defaults });
|
|
3421
|
+
};
|
|
3410
3422
|
const updateDrawingDrag = (x, y) => {
|
|
3411
3423
|
if (!drawingDragState) {
|
|
3412
3424
|
return false;
|
|
@@ -4255,6 +4267,7 @@ function createChart(element, options = {}) {
|
|
|
4255
4267
|
onDrawingsChange,
|
|
4256
4268
|
onDrawingSelect,
|
|
4257
4269
|
onDrawingHover,
|
|
4270
|
+
setDrawingDefaults,
|
|
4258
4271
|
setDoubleClickEnabled,
|
|
4259
4272
|
setDoubleClickAction,
|
|
4260
4273
|
registerIndicator,
|
|
@@ -73,6 +73,7 @@ interface DrawingHoverEvent {
|
|
|
73
73
|
x: number;
|
|
74
74
|
y: number;
|
|
75
75
|
}
|
|
76
|
+
type DrawingDefaults = Partial<Pick<DrawingObjectOptions, "color" | "style" | "width">>;
|
|
76
77
|
interface IndicatorInstanceOptions<TInputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
77
78
|
id?: string;
|
|
78
79
|
type: string;
|
|
@@ -405,6 +406,7 @@ interface ChartInstance {
|
|
|
405
406
|
onDrawingsChange: (handler: ((drawings: DrawingObjectOptions[]) => void) | null) => void;
|
|
406
407
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
407
408
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
409
|
+
setDrawingDefaults: (tool: DrawingToolType, defaults: DrawingDefaults | null) => void;
|
|
408
410
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
409
411
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
410
412
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
|
@@ -440,4 +442,4 @@ interface ViewportState {
|
|
|
440
442
|
}
|
|
441
443
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
442
444
|
|
|
443
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
|
445
|
+
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
|
@@ -940,6 +940,8 @@ function createChart(element, options = {}) {
|
|
|
940
940
|
let drawingSelectHandler = null;
|
|
941
941
|
let drawingHoverHandler = null;
|
|
942
942
|
let lastHoveredDrawingId = null;
|
|
943
|
+
const drawingToolDefaults = /* @__PURE__ */ new Map();
|
|
944
|
+
const getDrawingToolDefaults = (tool) => drawingToolDefaults.get(tool) ?? {};
|
|
943
945
|
const emitDrawingsChange = () => {
|
|
944
946
|
drawingsChangeHandler?.(drawings.map((drawing) => serializeDrawing(drawing)));
|
|
945
947
|
};
|
|
@@ -3322,13 +3324,14 @@ function createChart(element, options = {}) {
|
|
|
3322
3324
|
return false;
|
|
3323
3325
|
}
|
|
3324
3326
|
if (activeDrawingTool === "horizontal-line") {
|
|
3327
|
+
const defaults = getDrawingToolDefaults("horizontal-line");
|
|
3325
3328
|
drawings.push(
|
|
3326
3329
|
normalizeDrawingState({
|
|
3327
3330
|
type: "horizontal-line",
|
|
3328
3331
|
points: [point],
|
|
3329
|
-
color: "#38bdf8",
|
|
3330
|
-
style: "
|
|
3331
|
-
width: 1
|
|
3332
|
+
color: defaults.color ?? "#38bdf8",
|
|
3333
|
+
style: defaults.style ?? "solid",
|
|
3334
|
+
width: defaults.width ?? 1
|
|
3332
3335
|
})
|
|
3333
3336
|
);
|
|
3334
3337
|
emitDrawingsChange();
|
|
@@ -3348,12 +3351,13 @@ function createChart(element, options = {}) {
|
|
|
3348
3351
|
draw();
|
|
3349
3352
|
return true;
|
|
3350
3353
|
}
|
|
3354
|
+
const defaults = getDrawingToolDefaults("trendline");
|
|
3351
3355
|
draftDrawing = normalizeDrawingState({
|
|
3352
3356
|
type: "trendline",
|
|
3353
3357
|
points: [point, point],
|
|
3354
|
-
color: "#2563eb",
|
|
3355
|
-
style: "solid",
|
|
3356
|
-
width: 2
|
|
3358
|
+
color: defaults.color ?? "#2563eb",
|
|
3359
|
+
style: defaults.style ?? "solid",
|
|
3360
|
+
width: defaults.width ?? 2
|
|
3357
3361
|
});
|
|
3358
3362
|
draw();
|
|
3359
3363
|
return true;
|
|
@@ -3371,18 +3375,26 @@ function createChart(element, options = {}) {
|
|
|
3371
3375
|
draw();
|
|
3372
3376
|
return true;
|
|
3373
3377
|
}
|
|
3378
|
+
const defaults = getDrawingToolDefaults("fib-retracement");
|
|
3374
3379
|
draftDrawing = normalizeDrawingState({
|
|
3375
3380
|
type: "fib-retracement",
|
|
3376
3381
|
points: [point, point],
|
|
3377
|
-
color: "#2563eb",
|
|
3378
|
-
style: "solid",
|
|
3379
|
-
width: 1
|
|
3382
|
+
color: defaults.color ?? "#2563eb",
|
|
3383
|
+
style: defaults.style ?? "solid",
|
|
3384
|
+
width: defaults.width ?? 1
|
|
3380
3385
|
});
|
|
3381
3386
|
draw();
|
|
3382
3387
|
return true;
|
|
3383
3388
|
}
|
|
3384
3389
|
return false;
|
|
3385
3390
|
};
|
|
3391
|
+
const setDrawingDefaults = (tool, defaults) => {
|
|
3392
|
+
if (defaults === null) {
|
|
3393
|
+
drawingToolDefaults.delete(tool);
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
drawingToolDefaults.set(tool, { ...defaults });
|
|
3397
|
+
};
|
|
3386
3398
|
const updateDrawingDrag = (x, y) => {
|
|
3387
3399
|
if (!drawingDragState) {
|
|
3388
3400
|
return false;
|
|
@@ -4231,6 +4243,7 @@ function createChart(element, options = {}) {
|
|
|
4231
4243
|
onDrawingsChange,
|
|
4232
4244
|
onDrawingSelect,
|
|
4233
4245
|
onDrawingHover,
|
|
4246
|
+
setDrawingDefaults,
|
|
4234
4247
|
setDoubleClickEnabled,
|
|
4235
4248
|
setDoubleClickAction,
|
|
4236
4249
|
registerIndicator,
|
package/dist/index.cjs
CHANGED
|
@@ -964,6 +964,8 @@ function createChart(element, options = {}) {
|
|
|
964
964
|
let drawingSelectHandler = null;
|
|
965
965
|
let drawingHoverHandler = null;
|
|
966
966
|
let lastHoveredDrawingId = null;
|
|
967
|
+
const drawingToolDefaults = /* @__PURE__ */ new Map();
|
|
968
|
+
const getDrawingToolDefaults = (tool) => drawingToolDefaults.get(tool) ?? {};
|
|
967
969
|
const emitDrawingsChange = () => {
|
|
968
970
|
drawingsChangeHandler?.(drawings.map((drawing) => serializeDrawing(drawing)));
|
|
969
971
|
};
|
|
@@ -3346,13 +3348,14 @@ function createChart(element, options = {}) {
|
|
|
3346
3348
|
return false;
|
|
3347
3349
|
}
|
|
3348
3350
|
if (activeDrawingTool === "horizontal-line") {
|
|
3351
|
+
const defaults = getDrawingToolDefaults("horizontal-line");
|
|
3349
3352
|
drawings.push(
|
|
3350
3353
|
normalizeDrawingState({
|
|
3351
3354
|
type: "horizontal-line",
|
|
3352
3355
|
points: [point],
|
|
3353
|
-
color: "#38bdf8",
|
|
3354
|
-
style: "
|
|
3355
|
-
width: 1
|
|
3356
|
+
color: defaults.color ?? "#38bdf8",
|
|
3357
|
+
style: defaults.style ?? "solid",
|
|
3358
|
+
width: defaults.width ?? 1
|
|
3356
3359
|
})
|
|
3357
3360
|
);
|
|
3358
3361
|
emitDrawingsChange();
|
|
@@ -3372,12 +3375,13 @@ function createChart(element, options = {}) {
|
|
|
3372
3375
|
draw();
|
|
3373
3376
|
return true;
|
|
3374
3377
|
}
|
|
3378
|
+
const defaults = getDrawingToolDefaults("trendline");
|
|
3375
3379
|
draftDrawing = normalizeDrawingState({
|
|
3376
3380
|
type: "trendline",
|
|
3377
3381
|
points: [point, point],
|
|
3378
|
-
color: "#2563eb",
|
|
3379
|
-
style: "solid",
|
|
3380
|
-
width: 2
|
|
3382
|
+
color: defaults.color ?? "#2563eb",
|
|
3383
|
+
style: defaults.style ?? "solid",
|
|
3384
|
+
width: defaults.width ?? 2
|
|
3381
3385
|
});
|
|
3382
3386
|
draw();
|
|
3383
3387
|
return true;
|
|
@@ -3395,18 +3399,26 @@ function createChart(element, options = {}) {
|
|
|
3395
3399
|
draw();
|
|
3396
3400
|
return true;
|
|
3397
3401
|
}
|
|
3402
|
+
const defaults = getDrawingToolDefaults("fib-retracement");
|
|
3398
3403
|
draftDrawing = normalizeDrawingState({
|
|
3399
3404
|
type: "fib-retracement",
|
|
3400
3405
|
points: [point, point],
|
|
3401
|
-
color: "#2563eb",
|
|
3402
|
-
style: "solid",
|
|
3403
|
-
width: 1
|
|
3406
|
+
color: defaults.color ?? "#2563eb",
|
|
3407
|
+
style: defaults.style ?? "solid",
|
|
3408
|
+
width: defaults.width ?? 1
|
|
3404
3409
|
});
|
|
3405
3410
|
draw();
|
|
3406
3411
|
return true;
|
|
3407
3412
|
}
|
|
3408
3413
|
return false;
|
|
3409
3414
|
};
|
|
3415
|
+
const setDrawingDefaults = (tool, defaults) => {
|
|
3416
|
+
if (defaults === null) {
|
|
3417
|
+
drawingToolDefaults.delete(tool);
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
drawingToolDefaults.set(tool, { ...defaults });
|
|
3421
|
+
};
|
|
3410
3422
|
const updateDrawingDrag = (x, y) => {
|
|
3411
3423
|
if (!drawingDragState) {
|
|
3412
3424
|
return false;
|
|
@@ -4255,6 +4267,7 @@ function createChart(element, options = {}) {
|
|
|
4255
4267
|
onDrawingsChange,
|
|
4256
4268
|
onDrawingSelect,
|
|
4257
4269
|
onDrawingHover,
|
|
4270
|
+
setDrawingDefaults,
|
|
4258
4271
|
setDoubleClickEnabled,
|
|
4259
4272
|
setDoubleClickAction,
|
|
4260
4273
|
registerIndicator,
|
package/dist/index.d.cts
CHANGED
|
@@ -73,6 +73,7 @@ interface DrawingHoverEvent {
|
|
|
73
73
|
x: number;
|
|
74
74
|
y: number;
|
|
75
75
|
}
|
|
76
|
+
type DrawingDefaults = Partial<Pick<DrawingObjectOptions, "color" | "style" | "width">>;
|
|
76
77
|
interface IndicatorInstanceOptions<TInputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
77
78
|
id?: string;
|
|
78
79
|
type: string;
|
|
@@ -405,6 +406,7 @@ interface ChartInstance {
|
|
|
405
406
|
onDrawingsChange: (handler: ((drawings: DrawingObjectOptions[]) => void) | null) => void;
|
|
406
407
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
407
408
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
409
|
+
setDrawingDefaults: (tool: DrawingToolType, defaults: DrawingDefaults | null) => void;
|
|
408
410
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
409
411
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
410
412
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
|
@@ -440,4 +442,4 @@ interface ViewportState {
|
|
|
440
442
|
}
|
|
441
443
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
442
444
|
|
|
443
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
|
445
|
+
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ interface DrawingHoverEvent {
|
|
|
73
73
|
x: number;
|
|
74
74
|
y: number;
|
|
75
75
|
}
|
|
76
|
+
type DrawingDefaults = Partial<Pick<DrawingObjectOptions, "color" | "style" | "width">>;
|
|
76
77
|
interface IndicatorInstanceOptions<TInputs extends Record<string, unknown> = Record<string, unknown>> {
|
|
77
78
|
id?: string;
|
|
78
79
|
type: string;
|
|
@@ -405,6 +406,7 @@ interface ChartInstance {
|
|
|
405
406
|
onDrawingsChange: (handler: ((drawings: DrawingObjectOptions[]) => void) | null) => void;
|
|
406
407
|
onDrawingSelect: (handler: ((event: DrawingSelectEvent) => void) | null) => void;
|
|
407
408
|
onDrawingHover: (handler: ((event: DrawingHoverEvent) => void) | null) => void;
|
|
409
|
+
setDrawingDefaults: (tool: DrawingToolType, defaults: DrawingDefaults | null) => void;
|
|
408
410
|
setDoubleClickEnabled: (enabled: boolean) => void;
|
|
409
411
|
setDoubleClickAction: (action: "reset" | "placeLimitOrder") => void;
|
|
410
412
|
registerIndicator: (plugin: IndicatorPlugin<any>) => void;
|
|
@@ -440,4 +442,4 @@ interface ViewportState {
|
|
|
440
442
|
}
|
|
441
443
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
442
444
|
|
|
443
|
-
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
|
445
|
+
export { type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartInstance, type ChartOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingToolType, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, type PriceLineOptions, type TickerLineOptions, type ViewportState, type WatermarkOptions, createChart };
|
package/dist/index.js
CHANGED
|
@@ -940,6 +940,8 @@ function createChart(element, options = {}) {
|
|
|
940
940
|
let drawingSelectHandler = null;
|
|
941
941
|
let drawingHoverHandler = null;
|
|
942
942
|
let lastHoveredDrawingId = null;
|
|
943
|
+
const drawingToolDefaults = /* @__PURE__ */ new Map();
|
|
944
|
+
const getDrawingToolDefaults = (tool) => drawingToolDefaults.get(tool) ?? {};
|
|
943
945
|
const emitDrawingsChange = () => {
|
|
944
946
|
drawingsChangeHandler?.(drawings.map((drawing) => serializeDrawing(drawing)));
|
|
945
947
|
};
|
|
@@ -3322,13 +3324,14 @@ function createChart(element, options = {}) {
|
|
|
3322
3324
|
return false;
|
|
3323
3325
|
}
|
|
3324
3326
|
if (activeDrawingTool === "horizontal-line") {
|
|
3327
|
+
const defaults = getDrawingToolDefaults("horizontal-line");
|
|
3325
3328
|
drawings.push(
|
|
3326
3329
|
normalizeDrawingState({
|
|
3327
3330
|
type: "horizontal-line",
|
|
3328
3331
|
points: [point],
|
|
3329
|
-
color: "#38bdf8",
|
|
3330
|
-
style: "
|
|
3331
|
-
width: 1
|
|
3332
|
+
color: defaults.color ?? "#38bdf8",
|
|
3333
|
+
style: defaults.style ?? "solid",
|
|
3334
|
+
width: defaults.width ?? 1
|
|
3332
3335
|
})
|
|
3333
3336
|
);
|
|
3334
3337
|
emitDrawingsChange();
|
|
@@ -3348,12 +3351,13 @@ function createChart(element, options = {}) {
|
|
|
3348
3351
|
draw();
|
|
3349
3352
|
return true;
|
|
3350
3353
|
}
|
|
3354
|
+
const defaults = getDrawingToolDefaults("trendline");
|
|
3351
3355
|
draftDrawing = normalizeDrawingState({
|
|
3352
3356
|
type: "trendline",
|
|
3353
3357
|
points: [point, point],
|
|
3354
|
-
color: "#2563eb",
|
|
3355
|
-
style: "solid",
|
|
3356
|
-
width: 2
|
|
3358
|
+
color: defaults.color ?? "#2563eb",
|
|
3359
|
+
style: defaults.style ?? "solid",
|
|
3360
|
+
width: defaults.width ?? 2
|
|
3357
3361
|
});
|
|
3358
3362
|
draw();
|
|
3359
3363
|
return true;
|
|
@@ -3371,18 +3375,26 @@ function createChart(element, options = {}) {
|
|
|
3371
3375
|
draw();
|
|
3372
3376
|
return true;
|
|
3373
3377
|
}
|
|
3378
|
+
const defaults = getDrawingToolDefaults("fib-retracement");
|
|
3374
3379
|
draftDrawing = normalizeDrawingState({
|
|
3375
3380
|
type: "fib-retracement",
|
|
3376
3381
|
points: [point, point],
|
|
3377
|
-
color: "#2563eb",
|
|
3378
|
-
style: "solid",
|
|
3379
|
-
width: 1
|
|
3382
|
+
color: defaults.color ?? "#2563eb",
|
|
3383
|
+
style: defaults.style ?? "solid",
|
|
3384
|
+
width: defaults.width ?? 1
|
|
3380
3385
|
});
|
|
3381
3386
|
draw();
|
|
3382
3387
|
return true;
|
|
3383
3388
|
}
|
|
3384
3389
|
return false;
|
|
3385
3390
|
};
|
|
3391
|
+
const setDrawingDefaults = (tool, defaults) => {
|
|
3392
|
+
if (defaults === null) {
|
|
3393
|
+
drawingToolDefaults.delete(tool);
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
drawingToolDefaults.set(tool, { ...defaults });
|
|
3397
|
+
};
|
|
3386
3398
|
const updateDrawingDrag = (x, y) => {
|
|
3387
3399
|
if (!drawingDragState) {
|
|
3388
3400
|
return false;
|
|
@@ -4231,6 +4243,7 @@ function createChart(element, options = {}) {
|
|
|
4231
4243
|
onDrawingsChange,
|
|
4232
4244
|
onDrawingSelect,
|
|
4233
4245
|
onDrawingHover,
|
|
4246
|
+
setDrawingDefaults,
|
|
4234
4247
|
setDoubleClickEnabled,
|
|
4235
4248
|
setDoubleClickAction,
|
|
4236
4249
|
registerIndicator,
|