hyperprop-charting-library 0.1.153 → 0.1.154
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 +112 -18
- package/dist/hyperprop-charting-library.d.ts +40 -1
- package/dist/hyperprop-charting-library.js +109 -18
- package/dist/index.cjs +112 -18
- package/dist/index.d.cts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +109 -18
- package/package.json +1 -1
|
@@ -22,6 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CHART_THEMES: () => CHART_THEMES,
|
|
24
24
|
CHART_THEME_NAMES: () => CHART_THEME_NAMES,
|
|
25
|
+
DRAWING_ICON_STROKE_WIDTH: () => DRAWING_ICON_STROKE_WIDTH,
|
|
26
|
+
DRAWING_ICON_VIEWBOX: () => DRAWING_ICON_VIEWBOX,
|
|
27
|
+
DRAWING_TOOL_ICONS: () => DRAWING_TOOL_ICONS,
|
|
25
28
|
FIB_DEFAULT_PALETTE: () => FIB_DEFAULT_PALETTE,
|
|
26
29
|
POSITION_DEFAULT_COLORS: () => POSITION_DEFAULT_COLORS,
|
|
27
30
|
SCRIPT_SOURCE_INPUT_VALUES: () => SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -3168,6 +3171,94 @@ var compileScriptIndicator = (definition) => {
|
|
|
3168
3171
|
return plugin;
|
|
3169
3172
|
};
|
|
3170
3173
|
|
|
3174
|
+
// src/icons.ts
|
|
3175
|
+
var DRAWING_ICON_VIEWBOX = 28;
|
|
3176
|
+
var DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
3177
|
+
var dot = (cx, cy) => ({ kind: "circle", cx, cy, r: 2.1 });
|
|
3178
|
+
var path = (d, extra) => ({
|
|
3179
|
+
kind: "path",
|
|
3180
|
+
d,
|
|
3181
|
+
...extra
|
|
3182
|
+
});
|
|
3183
|
+
var DRAWING_TOOL_ICONS = {
|
|
3184
|
+
"cursor-cross": [path("M14 4v6.5M14 17.5V24M4 14h6.5M17.5 14H24")],
|
|
3185
|
+
"cursor-dot": [{ kind: "circle", cx: 14, cy: 14, r: 2.6, fill: true }],
|
|
3186
|
+
"cursor-arrow": [path("M10 4.5v16.4l4.3-4.1 3 6.7 2.9-1.3-3-6.7h5.9L10 4.5Z")],
|
|
3187
|
+
trendline: [dot(7, 21), dot(21, 7), path("M8.6 19.4 19.4 8.6")],
|
|
3188
|
+
"horizontal-line": [dot(14, 14), path("M3.5 14h8.4M16.1 14h8.4")],
|
|
3189
|
+
"vertical-line": [dot(14, 14), path("M14 3.5v8.4M14 16.1v8.4")],
|
|
3190
|
+
ray: [dot(7.5, 20.5), path("M9 19 24 4")],
|
|
3191
|
+
arrow: [dot(6, 22), path("M7.6 20.4 21.4 6.6"), path("M14.6 6.2h7.2v7.2")],
|
|
3192
|
+
"parallel-channel": [dot(6, 17), dot(17, 6), path("M7.5 15.5 15.5 7.5"), path("M11 23.5 23.5 11")],
|
|
3193
|
+
"fib-retracement": [
|
|
3194
|
+
dot(6, 7),
|
|
3195
|
+
path("M9.6 7h14.9"),
|
|
3196
|
+
path("M3.5 14h21"),
|
|
3197
|
+
dot(6, 21),
|
|
3198
|
+
path("M9.6 21h14.9")
|
|
3199
|
+
],
|
|
3200
|
+
"fib-extension": [
|
|
3201
|
+
dot(6.5, 21.5),
|
|
3202
|
+
dot(12.5, 6.5),
|
|
3203
|
+
path("M7.5 19.1l4-9.2"),
|
|
3204
|
+
path("M17 7h7.5M17 14h7.5M17 21h7.5")
|
|
3205
|
+
],
|
|
3206
|
+
// Long/short: three price levels (target, entry, stop) with anchor dots and
|
|
3207
|
+
// a dotted "price path" diagonal running from entry toward the target.
|
|
3208
|
+
"long-position": [
|
|
3209
|
+
dot(5, 6.5),
|
|
3210
|
+
path("M8.6 6.5h15.9"),
|
|
3211
|
+
dot(5, 16),
|
|
3212
|
+
path("M8.6 16h10.3"),
|
|
3213
|
+
dot(21, 16),
|
|
3214
|
+
path("M8.6 22.5h15.9"),
|
|
3215
|
+
dot(5, 22.5),
|
|
3216
|
+
path("M10.5 14 22 7.8", { dash: "2 3.2" })
|
|
3217
|
+
],
|
|
3218
|
+
"short-position": [
|
|
3219
|
+
dot(5, 21.5),
|
|
3220
|
+
path("M8.6 21.5h15.9"),
|
|
3221
|
+
dot(5, 12),
|
|
3222
|
+
path("M8.6 12h10.3"),
|
|
3223
|
+
dot(21, 12),
|
|
3224
|
+
path("M8.6 5.5h15.9"),
|
|
3225
|
+
dot(5, 5.5),
|
|
3226
|
+
path("M10.5 14 22 20.2", { dash: "2 3.2" })
|
|
3227
|
+
],
|
|
3228
|
+
"price-range": [
|
|
3229
|
+
path("M8 5h12M8 23h12"),
|
|
3230
|
+
path("M14 7v14"),
|
|
3231
|
+
path("M11.2 9.8 14 7l2.8 2.8M11.2 18.2 14 21l2.8-2.8")
|
|
3232
|
+
],
|
|
3233
|
+
// Fixed range VP: two vertical range anchors with the profile bars attached
|
|
3234
|
+
// to the left one.
|
|
3235
|
+
"fixed-range-volume-profile": [
|
|
3236
|
+
path("M5 3.5v15.4"),
|
|
3237
|
+
dot(5, 21.5),
|
|
3238
|
+
dot(23, 6.5),
|
|
3239
|
+
path("M23 9.1v15.4"),
|
|
3240
|
+
{ kind: "rect", x: 5, y: 6, width: 7, height: 3.2 },
|
|
3241
|
+
{ kind: "rect", x: 5, y: 11, width: 10.5, height: 3.2 },
|
|
3242
|
+
{ kind: "rect", x: 5, y: 16, width: 4.5, height: 3.2 }
|
|
3243
|
+
],
|
|
3244
|
+
measure: [
|
|
3245
|
+
path("M4.5 18.5 18.5 4.5l5 5L9.5 23.5Z"),
|
|
3246
|
+
path("m8 15 1.8 1.8M11.5 11.5 14 14M15 8l1.8 1.8")
|
|
3247
|
+
],
|
|
3248
|
+
rectangle: [
|
|
3249
|
+
dot(6, 8),
|
|
3250
|
+
dot(22, 8),
|
|
3251
|
+
dot(22, 20),
|
|
3252
|
+
dot(6, 20),
|
|
3253
|
+
path("M8.1 8h11.8M8.1 20h11.8M6 10.1v7.8M22 10.1v7.8")
|
|
3254
|
+
],
|
|
3255
|
+
ellipse: [path("M6.1 14a7.9 6.9 0 1 0 15.8 0 7.9 6.9 0 1 0-15.8 0"), dot(4, 14), dot(24, 14)],
|
|
3256
|
+
brush: [dot(5, 20), path("M6.9 18.4c2.6-6 5-.6 8.4-3.2 3-2.3 5.4-6 8.2-7.9")],
|
|
3257
|
+
text: [path("M7 8.5V6h14v2.5"), path("M14 6v16M11 22h6")],
|
|
3258
|
+
note: [path("M5.5 5h17v11.5l-6 6h-11V5Z"), path("M22.5 16.5h-6v6")],
|
|
3259
|
+
callout: [path("M4.5 6h19v11.5H13L8 22.5v-5H4.5V6Z")]
|
|
3260
|
+
};
|
|
3261
|
+
|
|
3171
3262
|
// src/themes.ts
|
|
3172
3263
|
var CHART_THEMES = {
|
|
3173
3264
|
midnight: {
|
|
@@ -4690,9 +4781,9 @@ function createChart(element, options = {}) {
|
|
|
4690
4781
|
const groupThousands = (value, decimals) => {
|
|
4691
4782
|
const negative = value < 0;
|
|
4692
4783
|
const fixed = Math.abs(value).toFixed(decimals);
|
|
4693
|
-
const
|
|
4694
|
-
const intPart =
|
|
4695
|
-
const decPart =
|
|
4784
|
+
const dot2 = fixed.indexOf(".");
|
|
4785
|
+
const intPart = dot2 === -1 ? fixed : fixed.slice(0, dot2);
|
|
4786
|
+
const decPart = dot2 === -1 ? "" : fixed.slice(dot2);
|
|
4696
4787
|
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
4697
4788
|
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
4698
4789
|
};
|
|
@@ -7272,12 +7363,12 @@ function createChart(element, options = {}) {
|
|
|
7272
7363
|
const upColumns = new Path2D();
|
|
7273
7364
|
const downColumns = new Path2D();
|
|
7274
7365
|
for (const column of seriesColumns) {
|
|
7275
|
-
const
|
|
7366
|
+
const path2 = column.close >= column.open ? upColumns : downColumns;
|
|
7276
7367
|
const x = column.x + 0.5;
|
|
7277
7368
|
const top = crisp(yFromPrice(column.high));
|
|
7278
7369
|
const bottom = crisp(yFromPrice(column.low));
|
|
7279
|
-
|
|
7280
|
-
|
|
7370
|
+
path2.moveTo(x, top);
|
|
7371
|
+
path2.lineTo(x, bottom === top ? bottom + 1 : bottom);
|
|
7281
7372
|
}
|
|
7282
7373
|
ctx.lineWidth = 1;
|
|
7283
7374
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7420,16 +7511,16 @@ function createChart(element, options = {}) {
|
|
|
7420
7511
|
const displayLow = isLastCandle && actualDirection === "down" ? Math.min(point.l, displayClose) : point.l;
|
|
7421
7512
|
const roundedCenterX = Math.round(chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth);
|
|
7422
7513
|
const direction = isLastCandle ? actualDirection : getCandleDirectionByIndex(index);
|
|
7423
|
-
const
|
|
7514
|
+
const path2 = direction === "up" ? upBars : downBars;
|
|
7424
7515
|
const centerX = roundedCenterX + 0.5;
|
|
7425
|
-
|
|
7426
|
-
|
|
7516
|
+
path2.moveTo(centerX, crisp(yFromPrice(displayHigh)));
|
|
7517
|
+
path2.lineTo(centerX, crisp(yFromPrice(displayLow)));
|
|
7427
7518
|
const openY = crisp(yFromPrice(point.o));
|
|
7428
7519
|
const closeY = crisp(yFromPrice(displayClose));
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7520
|
+
path2.moveTo(centerX - tickLength, openY);
|
|
7521
|
+
path2.lineTo(centerX, openY);
|
|
7522
|
+
path2.moveTo(centerX, closeY);
|
|
7523
|
+
path2.lineTo(centerX + tickLength, closeY);
|
|
7433
7524
|
}
|
|
7434
7525
|
ctx.lineWidth = Math.max(1, candleWickWidth);
|
|
7435
7526
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7497,7 +7588,7 @@ function createChart(element, options = {}) {
|
|
|
7497
7588
|
for (const plan of comparePlans) {
|
|
7498
7589
|
const color = plan.state.options.color ?? "#f59e0b";
|
|
7499
7590
|
const lineWidth = Math.max(1, plan.state.options.lineWidth ?? 1.5);
|
|
7500
|
-
const
|
|
7591
|
+
const path2 = new Path2D();
|
|
7501
7592
|
let started = false;
|
|
7502
7593
|
let firstX = 0;
|
|
7503
7594
|
let lastX = 0;
|
|
@@ -7505,11 +7596,11 @@ function createChart(element, options = {}) {
|
|
|
7505
7596
|
let lastPrice = Number.NaN;
|
|
7506
7597
|
const emit = (x, y) => {
|
|
7507
7598
|
if (!started) {
|
|
7508
|
-
|
|
7599
|
+
path2.moveTo(x, y);
|
|
7509
7600
|
firstX = x;
|
|
7510
7601
|
started = true;
|
|
7511
7602
|
} else {
|
|
7512
|
-
|
|
7603
|
+
path2.lineTo(x, y);
|
|
7513
7604
|
}
|
|
7514
7605
|
lastX = x;
|
|
7515
7606
|
lastY = y;
|
|
@@ -7567,7 +7658,7 @@ function createChart(element, options = {}) {
|
|
|
7567
7658
|
}
|
|
7568
7659
|
if (!started) continue;
|
|
7569
7660
|
if (plan.state.options.style === "area") {
|
|
7570
|
-
const fillPath = new Path2D(
|
|
7661
|
+
const fillPath = new Path2D(path2);
|
|
7571
7662
|
fillPath.lineTo(lastX, chartBottom);
|
|
7572
7663
|
fillPath.lineTo(firstX, chartBottom);
|
|
7573
7664
|
fillPath.closePath();
|
|
@@ -7581,7 +7672,7 @@ function createChart(element, options = {}) {
|
|
|
7581
7672
|
ctx.strokeStyle = color;
|
|
7582
7673
|
ctx.lineWidth = lineWidth;
|
|
7583
7674
|
ctx.lineJoin = "round";
|
|
7584
|
-
ctx.stroke(
|
|
7675
|
+
ctx.stroke(path2);
|
|
7585
7676
|
ctx.restore();
|
|
7586
7677
|
if (Number.isFinite(lastPrice)) {
|
|
7587
7678
|
const label = plan.state.options.label ?? plan.state.options.id;
|
|
@@ -12386,6 +12477,9 @@ function createChart(element, options = {}) {
|
|
|
12386
12477
|
0 && (module.exports = {
|
|
12387
12478
|
CHART_THEMES,
|
|
12388
12479
|
CHART_THEME_NAMES,
|
|
12480
|
+
DRAWING_ICON_STROKE_WIDTH,
|
|
12481
|
+
DRAWING_ICON_VIEWBOX,
|
|
12482
|
+
DRAWING_TOOL_ICONS,
|
|
12389
12483
|
FIB_DEFAULT_PALETTE,
|
|
12390
12484
|
POSITION_DEFAULT_COLORS,
|
|
12391
12485
|
SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -1441,6 +1441,45 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1441
1441
|
*/
|
|
1442
1442
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1443
1443
|
|
|
1444
|
+
/**
|
|
1445
|
+
* Hyperprop drawing-tool icon pack — framework-agnostic geometry.
|
|
1446
|
+
*
|
|
1447
|
+
* Original artwork drawn in the visual language traders know from desktop
|
|
1448
|
+
* charting platforms: a 28x28 grid, thin round-capped outlines, and hollow
|
|
1449
|
+
* "anchor" dots on anything line-based (a dot marks a draggable point of the
|
|
1450
|
+
* tool). The data here is plain shape descriptions so every consumer renders
|
|
1451
|
+
* the identical set: the web terminal maps it to DOM `<svg>` elements and the
|
|
1452
|
+
* mobile app to react-native-svg components.
|
|
1453
|
+
*
|
|
1454
|
+
* Design rules when adding icons:
|
|
1455
|
+
* - viewBox 0 0 28 28, strokeWidth 1.6, round caps/joins, no fill (except
|
|
1456
|
+
* shapes marked `fill: true`).
|
|
1457
|
+
* - Anchor dots are hollow circles r=2.1; lines stop ~1.5px short of them.
|
|
1458
|
+
* - Keep 3.5px padding to the edges so glyphs optically match.
|
|
1459
|
+
*/
|
|
1460
|
+
type DrawingIconShape = {
|
|
1461
|
+
kind: "path";
|
|
1462
|
+
d: string;
|
|
1463
|
+
dash?: string;
|
|
1464
|
+
fill?: boolean;
|
|
1465
|
+
} | {
|
|
1466
|
+
kind: "circle";
|
|
1467
|
+
cx: number;
|
|
1468
|
+
cy: number;
|
|
1469
|
+
r: number;
|
|
1470
|
+
fill?: boolean;
|
|
1471
|
+
} | {
|
|
1472
|
+
kind: "rect";
|
|
1473
|
+
x: number;
|
|
1474
|
+
y: number;
|
|
1475
|
+
width: number;
|
|
1476
|
+
height: number;
|
|
1477
|
+
};
|
|
1478
|
+
type DrawingIconName = "cursor-cross" | "cursor-dot" | "cursor-arrow" | "trendline" | "horizontal-line" | "vertical-line" | "ray" | "arrow" | "parallel-channel" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "fixed-range-volume-profile" | "measure" | "rectangle" | "ellipse" | "brush" | "text" | "note" | "callout";
|
|
1479
|
+
declare const DRAWING_ICON_VIEWBOX = 28;
|
|
1480
|
+
declare const DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
1481
|
+
declare const DRAWING_TOOL_ICONS: Record<DrawingIconName, DrawingIconShape[]>;
|
|
1482
|
+
|
|
1444
1483
|
/**
|
|
1445
1484
|
* Built-in palettes.
|
|
1446
1485
|
*
|
|
@@ -1465,4 +1504,4 @@ declare const SESSION_PRESETS: Record<SessionPresetName, SessionSpec>;
|
|
|
1465
1504
|
|
|
1466
1505
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1467
1506
|
|
|
1468
|
-
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
|
1507
|
+
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, DRAWING_ICON_STROKE_WIDTH, DRAWING_ICON_VIEWBOX, DRAWING_TOOL_ICONS, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingIconName, type DrawingIconShape, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
|
@@ -3132,6 +3132,94 @@ var compileScriptIndicator = (definition) => {
|
|
|
3132
3132
|
return plugin;
|
|
3133
3133
|
};
|
|
3134
3134
|
|
|
3135
|
+
// src/icons.ts
|
|
3136
|
+
var DRAWING_ICON_VIEWBOX = 28;
|
|
3137
|
+
var DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
3138
|
+
var dot = (cx, cy) => ({ kind: "circle", cx, cy, r: 2.1 });
|
|
3139
|
+
var path = (d, extra) => ({
|
|
3140
|
+
kind: "path",
|
|
3141
|
+
d,
|
|
3142
|
+
...extra
|
|
3143
|
+
});
|
|
3144
|
+
var DRAWING_TOOL_ICONS = {
|
|
3145
|
+
"cursor-cross": [path("M14 4v6.5M14 17.5V24M4 14h6.5M17.5 14H24")],
|
|
3146
|
+
"cursor-dot": [{ kind: "circle", cx: 14, cy: 14, r: 2.6, fill: true }],
|
|
3147
|
+
"cursor-arrow": [path("M10 4.5v16.4l4.3-4.1 3 6.7 2.9-1.3-3-6.7h5.9L10 4.5Z")],
|
|
3148
|
+
trendline: [dot(7, 21), dot(21, 7), path("M8.6 19.4 19.4 8.6")],
|
|
3149
|
+
"horizontal-line": [dot(14, 14), path("M3.5 14h8.4M16.1 14h8.4")],
|
|
3150
|
+
"vertical-line": [dot(14, 14), path("M14 3.5v8.4M14 16.1v8.4")],
|
|
3151
|
+
ray: [dot(7.5, 20.5), path("M9 19 24 4")],
|
|
3152
|
+
arrow: [dot(6, 22), path("M7.6 20.4 21.4 6.6"), path("M14.6 6.2h7.2v7.2")],
|
|
3153
|
+
"parallel-channel": [dot(6, 17), dot(17, 6), path("M7.5 15.5 15.5 7.5"), path("M11 23.5 23.5 11")],
|
|
3154
|
+
"fib-retracement": [
|
|
3155
|
+
dot(6, 7),
|
|
3156
|
+
path("M9.6 7h14.9"),
|
|
3157
|
+
path("M3.5 14h21"),
|
|
3158
|
+
dot(6, 21),
|
|
3159
|
+
path("M9.6 21h14.9")
|
|
3160
|
+
],
|
|
3161
|
+
"fib-extension": [
|
|
3162
|
+
dot(6.5, 21.5),
|
|
3163
|
+
dot(12.5, 6.5),
|
|
3164
|
+
path("M7.5 19.1l4-9.2"),
|
|
3165
|
+
path("M17 7h7.5M17 14h7.5M17 21h7.5")
|
|
3166
|
+
],
|
|
3167
|
+
// Long/short: three price levels (target, entry, stop) with anchor dots and
|
|
3168
|
+
// a dotted "price path" diagonal running from entry toward the target.
|
|
3169
|
+
"long-position": [
|
|
3170
|
+
dot(5, 6.5),
|
|
3171
|
+
path("M8.6 6.5h15.9"),
|
|
3172
|
+
dot(5, 16),
|
|
3173
|
+
path("M8.6 16h10.3"),
|
|
3174
|
+
dot(21, 16),
|
|
3175
|
+
path("M8.6 22.5h15.9"),
|
|
3176
|
+
dot(5, 22.5),
|
|
3177
|
+
path("M10.5 14 22 7.8", { dash: "2 3.2" })
|
|
3178
|
+
],
|
|
3179
|
+
"short-position": [
|
|
3180
|
+
dot(5, 21.5),
|
|
3181
|
+
path("M8.6 21.5h15.9"),
|
|
3182
|
+
dot(5, 12),
|
|
3183
|
+
path("M8.6 12h10.3"),
|
|
3184
|
+
dot(21, 12),
|
|
3185
|
+
path("M8.6 5.5h15.9"),
|
|
3186
|
+
dot(5, 5.5),
|
|
3187
|
+
path("M10.5 14 22 20.2", { dash: "2 3.2" })
|
|
3188
|
+
],
|
|
3189
|
+
"price-range": [
|
|
3190
|
+
path("M8 5h12M8 23h12"),
|
|
3191
|
+
path("M14 7v14"),
|
|
3192
|
+
path("M11.2 9.8 14 7l2.8 2.8M11.2 18.2 14 21l2.8-2.8")
|
|
3193
|
+
],
|
|
3194
|
+
// Fixed range VP: two vertical range anchors with the profile bars attached
|
|
3195
|
+
// to the left one.
|
|
3196
|
+
"fixed-range-volume-profile": [
|
|
3197
|
+
path("M5 3.5v15.4"),
|
|
3198
|
+
dot(5, 21.5),
|
|
3199
|
+
dot(23, 6.5),
|
|
3200
|
+
path("M23 9.1v15.4"),
|
|
3201
|
+
{ kind: "rect", x: 5, y: 6, width: 7, height: 3.2 },
|
|
3202
|
+
{ kind: "rect", x: 5, y: 11, width: 10.5, height: 3.2 },
|
|
3203
|
+
{ kind: "rect", x: 5, y: 16, width: 4.5, height: 3.2 }
|
|
3204
|
+
],
|
|
3205
|
+
measure: [
|
|
3206
|
+
path("M4.5 18.5 18.5 4.5l5 5L9.5 23.5Z"),
|
|
3207
|
+
path("m8 15 1.8 1.8M11.5 11.5 14 14M15 8l1.8 1.8")
|
|
3208
|
+
],
|
|
3209
|
+
rectangle: [
|
|
3210
|
+
dot(6, 8),
|
|
3211
|
+
dot(22, 8),
|
|
3212
|
+
dot(22, 20),
|
|
3213
|
+
dot(6, 20),
|
|
3214
|
+
path("M8.1 8h11.8M8.1 20h11.8M6 10.1v7.8M22 10.1v7.8")
|
|
3215
|
+
],
|
|
3216
|
+
ellipse: [path("M6.1 14a7.9 6.9 0 1 0 15.8 0 7.9 6.9 0 1 0-15.8 0"), dot(4, 14), dot(24, 14)],
|
|
3217
|
+
brush: [dot(5, 20), path("M6.9 18.4c2.6-6 5-.6 8.4-3.2 3-2.3 5.4-6 8.2-7.9")],
|
|
3218
|
+
text: [path("M7 8.5V6h14v2.5"), path("M14 6v16M11 22h6")],
|
|
3219
|
+
note: [path("M5.5 5h17v11.5l-6 6h-11V5Z"), path("M22.5 16.5h-6v6")],
|
|
3220
|
+
callout: [path("M4.5 6h19v11.5H13L8 22.5v-5H4.5V6Z")]
|
|
3221
|
+
};
|
|
3222
|
+
|
|
3135
3223
|
// src/themes.ts
|
|
3136
3224
|
var CHART_THEMES = {
|
|
3137
3225
|
midnight: {
|
|
@@ -4654,9 +4742,9 @@ function createChart(element, options = {}) {
|
|
|
4654
4742
|
const groupThousands = (value, decimals) => {
|
|
4655
4743
|
const negative = value < 0;
|
|
4656
4744
|
const fixed = Math.abs(value).toFixed(decimals);
|
|
4657
|
-
const
|
|
4658
|
-
const intPart =
|
|
4659
|
-
const decPart =
|
|
4745
|
+
const dot2 = fixed.indexOf(".");
|
|
4746
|
+
const intPart = dot2 === -1 ? fixed : fixed.slice(0, dot2);
|
|
4747
|
+
const decPart = dot2 === -1 ? "" : fixed.slice(dot2);
|
|
4660
4748
|
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
4661
4749
|
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
4662
4750
|
};
|
|
@@ -7236,12 +7324,12 @@ function createChart(element, options = {}) {
|
|
|
7236
7324
|
const upColumns = new Path2D();
|
|
7237
7325
|
const downColumns = new Path2D();
|
|
7238
7326
|
for (const column of seriesColumns) {
|
|
7239
|
-
const
|
|
7327
|
+
const path2 = column.close >= column.open ? upColumns : downColumns;
|
|
7240
7328
|
const x = column.x + 0.5;
|
|
7241
7329
|
const top = crisp(yFromPrice(column.high));
|
|
7242
7330
|
const bottom = crisp(yFromPrice(column.low));
|
|
7243
|
-
|
|
7244
|
-
|
|
7331
|
+
path2.moveTo(x, top);
|
|
7332
|
+
path2.lineTo(x, bottom === top ? bottom + 1 : bottom);
|
|
7245
7333
|
}
|
|
7246
7334
|
ctx.lineWidth = 1;
|
|
7247
7335
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7384,16 +7472,16 @@ function createChart(element, options = {}) {
|
|
|
7384
7472
|
const displayLow = isLastCandle && actualDirection === "down" ? Math.min(point.l, displayClose) : point.l;
|
|
7385
7473
|
const roundedCenterX = Math.round(chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth);
|
|
7386
7474
|
const direction = isLastCandle ? actualDirection : getCandleDirectionByIndex(index);
|
|
7387
|
-
const
|
|
7475
|
+
const path2 = direction === "up" ? upBars : downBars;
|
|
7388
7476
|
const centerX = roundedCenterX + 0.5;
|
|
7389
|
-
|
|
7390
|
-
|
|
7477
|
+
path2.moveTo(centerX, crisp(yFromPrice(displayHigh)));
|
|
7478
|
+
path2.lineTo(centerX, crisp(yFromPrice(displayLow)));
|
|
7391
7479
|
const openY = crisp(yFromPrice(point.o));
|
|
7392
7480
|
const closeY = crisp(yFromPrice(displayClose));
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7481
|
+
path2.moveTo(centerX - tickLength, openY);
|
|
7482
|
+
path2.lineTo(centerX, openY);
|
|
7483
|
+
path2.moveTo(centerX, closeY);
|
|
7484
|
+
path2.lineTo(centerX + tickLength, closeY);
|
|
7397
7485
|
}
|
|
7398
7486
|
ctx.lineWidth = Math.max(1, candleWickWidth);
|
|
7399
7487
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7461,7 +7549,7 @@ function createChart(element, options = {}) {
|
|
|
7461
7549
|
for (const plan of comparePlans) {
|
|
7462
7550
|
const color = plan.state.options.color ?? "#f59e0b";
|
|
7463
7551
|
const lineWidth = Math.max(1, plan.state.options.lineWidth ?? 1.5);
|
|
7464
|
-
const
|
|
7552
|
+
const path2 = new Path2D();
|
|
7465
7553
|
let started = false;
|
|
7466
7554
|
let firstX = 0;
|
|
7467
7555
|
let lastX = 0;
|
|
@@ -7469,11 +7557,11 @@ function createChart(element, options = {}) {
|
|
|
7469
7557
|
let lastPrice = Number.NaN;
|
|
7470
7558
|
const emit = (x, y) => {
|
|
7471
7559
|
if (!started) {
|
|
7472
|
-
|
|
7560
|
+
path2.moveTo(x, y);
|
|
7473
7561
|
firstX = x;
|
|
7474
7562
|
started = true;
|
|
7475
7563
|
} else {
|
|
7476
|
-
|
|
7564
|
+
path2.lineTo(x, y);
|
|
7477
7565
|
}
|
|
7478
7566
|
lastX = x;
|
|
7479
7567
|
lastY = y;
|
|
@@ -7531,7 +7619,7 @@ function createChart(element, options = {}) {
|
|
|
7531
7619
|
}
|
|
7532
7620
|
if (!started) continue;
|
|
7533
7621
|
if (plan.state.options.style === "area") {
|
|
7534
|
-
const fillPath = new Path2D(
|
|
7622
|
+
const fillPath = new Path2D(path2);
|
|
7535
7623
|
fillPath.lineTo(lastX, chartBottom);
|
|
7536
7624
|
fillPath.lineTo(firstX, chartBottom);
|
|
7537
7625
|
fillPath.closePath();
|
|
@@ -7545,7 +7633,7 @@ function createChart(element, options = {}) {
|
|
|
7545
7633
|
ctx.strokeStyle = color;
|
|
7546
7634
|
ctx.lineWidth = lineWidth;
|
|
7547
7635
|
ctx.lineJoin = "round";
|
|
7548
|
-
ctx.stroke(
|
|
7636
|
+
ctx.stroke(path2);
|
|
7549
7637
|
ctx.restore();
|
|
7550
7638
|
if (Number.isFinite(lastPrice)) {
|
|
7551
7639
|
const label = plan.state.options.label ?? plan.state.options.id;
|
|
@@ -12349,6 +12437,9 @@ function createChart(element, options = {}) {
|
|
|
12349
12437
|
export {
|
|
12350
12438
|
CHART_THEMES,
|
|
12351
12439
|
CHART_THEME_NAMES,
|
|
12440
|
+
DRAWING_ICON_STROKE_WIDTH,
|
|
12441
|
+
DRAWING_ICON_VIEWBOX,
|
|
12442
|
+
DRAWING_TOOL_ICONS,
|
|
12352
12443
|
FIB_DEFAULT_PALETTE,
|
|
12353
12444
|
POSITION_DEFAULT_COLORS,
|
|
12354
12445
|
SCRIPT_SOURCE_INPUT_VALUES,
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CHART_THEMES: () => CHART_THEMES,
|
|
24
24
|
CHART_THEME_NAMES: () => CHART_THEME_NAMES,
|
|
25
|
+
DRAWING_ICON_STROKE_WIDTH: () => DRAWING_ICON_STROKE_WIDTH,
|
|
26
|
+
DRAWING_ICON_VIEWBOX: () => DRAWING_ICON_VIEWBOX,
|
|
27
|
+
DRAWING_TOOL_ICONS: () => DRAWING_TOOL_ICONS,
|
|
25
28
|
FIB_DEFAULT_PALETTE: () => FIB_DEFAULT_PALETTE,
|
|
26
29
|
POSITION_DEFAULT_COLORS: () => POSITION_DEFAULT_COLORS,
|
|
27
30
|
SCRIPT_SOURCE_INPUT_VALUES: () => SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -3168,6 +3171,94 @@ var compileScriptIndicator = (definition) => {
|
|
|
3168
3171
|
return plugin;
|
|
3169
3172
|
};
|
|
3170
3173
|
|
|
3174
|
+
// src/icons.ts
|
|
3175
|
+
var DRAWING_ICON_VIEWBOX = 28;
|
|
3176
|
+
var DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
3177
|
+
var dot = (cx, cy) => ({ kind: "circle", cx, cy, r: 2.1 });
|
|
3178
|
+
var path = (d, extra) => ({
|
|
3179
|
+
kind: "path",
|
|
3180
|
+
d,
|
|
3181
|
+
...extra
|
|
3182
|
+
});
|
|
3183
|
+
var DRAWING_TOOL_ICONS = {
|
|
3184
|
+
"cursor-cross": [path("M14 4v6.5M14 17.5V24M4 14h6.5M17.5 14H24")],
|
|
3185
|
+
"cursor-dot": [{ kind: "circle", cx: 14, cy: 14, r: 2.6, fill: true }],
|
|
3186
|
+
"cursor-arrow": [path("M10 4.5v16.4l4.3-4.1 3 6.7 2.9-1.3-3-6.7h5.9L10 4.5Z")],
|
|
3187
|
+
trendline: [dot(7, 21), dot(21, 7), path("M8.6 19.4 19.4 8.6")],
|
|
3188
|
+
"horizontal-line": [dot(14, 14), path("M3.5 14h8.4M16.1 14h8.4")],
|
|
3189
|
+
"vertical-line": [dot(14, 14), path("M14 3.5v8.4M14 16.1v8.4")],
|
|
3190
|
+
ray: [dot(7.5, 20.5), path("M9 19 24 4")],
|
|
3191
|
+
arrow: [dot(6, 22), path("M7.6 20.4 21.4 6.6"), path("M14.6 6.2h7.2v7.2")],
|
|
3192
|
+
"parallel-channel": [dot(6, 17), dot(17, 6), path("M7.5 15.5 15.5 7.5"), path("M11 23.5 23.5 11")],
|
|
3193
|
+
"fib-retracement": [
|
|
3194
|
+
dot(6, 7),
|
|
3195
|
+
path("M9.6 7h14.9"),
|
|
3196
|
+
path("M3.5 14h21"),
|
|
3197
|
+
dot(6, 21),
|
|
3198
|
+
path("M9.6 21h14.9")
|
|
3199
|
+
],
|
|
3200
|
+
"fib-extension": [
|
|
3201
|
+
dot(6.5, 21.5),
|
|
3202
|
+
dot(12.5, 6.5),
|
|
3203
|
+
path("M7.5 19.1l4-9.2"),
|
|
3204
|
+
path("M17 7h7.5M17 14h7.5M17 21h7.5")
|
|
3205
|
+
],
|
|
3206
|
+
// Long/short: three price levels (target, entry, stop) with anchor dots and
|
|
3207
|
+
// a dotted "price path" diagonal running from entry toward the target.
|
|
3208
|
+
"long-position": [
|
|
3209
|
+
dot(5, 6.5),
|
|
3210
|
+
path("M8.6 6.5h15.9"),
|
|
3211
|
+
dot(5, 16),
|
|
3212
|
+
path("M8.6 16h10.3"),
|
|
3213
|
+
dot(21, 16),
|
|
3214
|
+
path("M8.6 22.5h15.9"),
|
|
3215
|
+
dot(5, 22.5),
|
|
3216
|
+
path("M10.5 14 22 7.8", { dash: "2 3.2" })
|
|
3217
|
+
],
|
|
3218
|
+
"short-position": [
|
|
3219
|
+
dot(5, 21.5),
|
|
3220
|
+
path("M8.6 21.5h15.9"),
|
|
3221
|
+
dot(5, 12),
|
|
3222
|
+
path("M8.6 12h10.3"),
|
|
3223
|
+
dot(21, 12),
|
|
3224
|
+
path("M8.6 5.5h15.9"),
|
|
3225
|
+
dot(5, 5.5),
|
|
3226
|
+
path("M10.5 14 22 20.2", { dash: "2 3.2" })
|
|
3227
|
+
],
|
|
3228
|
+
"price-range": [
|
|
3229
|
+
path("M8 5h12M8 23h12"),
|
|
3230
|
+
path("M14 7v14"),
|
|
3231
|
+
path("M11.2 9.8 14 7l2.8 2.8M11.2 18.2 14 21l2.8-2.8")
|
|
3232
|
+
],
|
|
3233
|
+
// Fixed range VP: two vertical range anchors with the profile bars attached
|
|
3234
|
+
// to the left one.
|
|
3235
|
+
"fixed-range-volume-profile": [
|
|
3236
|
+
path("M5 3.5v15.4"),
|
|
3237
|
+
dot(5, 21.5),
|
|
3238
|
+
dot(23, 6.5),
|
|
3239
|
+
path("M23 9.1v15.4"),
|
|
3240
|
+
{ kind: "rect", x: 5, y: 6, width: 7, height: 3.2 },
|
|
3241
|
+
{ kind: "rect", x: 5, y: 11, width: 10.5, height: 3.2 },
|
|
3242
|
+
{ kind: "rect", x: 5, y: 16, width: 4.5, height: 3.2 }
|
|
3243
|
+
],
|
|
3244
|
+
measure: [
|
|
3245
|
+
path("M4.5 18.5 18.5 4.5l5 5L9.5 23.5Z"),
|
|
3246
|
+
path("m8 15 1.8 1.8M11.5 11.5 14 14M15 8l1.8 1.8")
|
|
3247
|
+
],
|
|
3248
|
+
rectangle: [
|
|
3249
|
+
dot(6, 8),
|
|
3250
|
+
dot(22, 8),
|
|
3251
|
+
dot(22, 20),
|
|
3252
|
+
dot(6, 20),
|
|
3253
|
+
path("M8.1 8h11.8M8.1 20h11.8M6 10.1v7.8M22 10.1v7.8")
|
|
3254
|
+
],
|
|
3255
|
+
ellipse: [path("M6.1 14a7.9 6.9 0 1 0 15.8 0 7.9 6.9 0 1 0-15.8 0"), dot(4, 14), dot(24, 14)],
|
|
3256
|
+
brush: [dot(5, 20), path("M6.9 18.4c2.6-6 5-.6 8.4-3.2 3-2.3 5.4-6 8.2-7.9")],
|
|
3257
|
+
text: [path("M7 8.5V6h14v2.5"), path("M14 6v16M11 22h6")],
|
|
3258
|
+
note: [path("M5.5 5h17v11.5l-6 6h-11V5Z"), path("M22.5 16.5h-6v6")],
|
|
3259
|
+
callout: [path("M4.5 6h19v11.5H13L8 22.5v-5H4.5V6Z")]
|
|
3260
|
+
};
|
|
3261
|
+
|
|
3171
3262
|
// src/themes.ts
|
|
3172
3263
|
var CHART_THEMES = {
|
|
3173
3264
|
midnight: {
|
|
@@ -4690,9 +4781,9 @@ function createChart(element, options = {}) {
|
|
|
4690
4781
|
const groupThousands = (value, decimals) => {
|
|
4691
4782
|
const negative = value < 0;
|
|
4692
4783
|
const fixed = Math.abs(value).toFixed(decimals);
|
|
4693
|
-
const
|
|
4694
|
-
const intPart =
|
|
4695
|
-
const decPart =
|
|
4784
|
+
const dot2 = fixed.indexOf(".");
|
|
4785
|
+
const intPart = dot2 === -1 ? fixed : fixed.slice(0, dot2);
|
|
4786
|
+
const decPart = dot2 === -1 ? "" : fixed.slice(dot2);
|
|
4696
4787
|
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
4697
4788
|
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
4698
4789
|
};
|
|
@@ -7272,12 +7363,12 @@ function createChart(element, options = {}) {
|
|
|
7272
7363
|
const upColumns = new Path2D();
|
|
7273
7364
|
const downColumns = new Path2D();
|
|
7274
7365
|
for (const column of seriesColumns) {
|
|
7275
|
-
const
|
|
7366
|
+
const path2 = column.close >= column.open ? upColumns : downColumns;
|
|
7276
7367
|
const x = column.x + 0.5;
|
|
7277
7368
|
const top = crisp(yFromPrice(column.high));
|
|
7278
7369
|
const bottom = crisp(yFromPrice(column.low));
|
|
7279
|
-
|
|
7280
|
-
|
|
7370
|
+
path2.moveTo(x, top);
|
|
7371
|
+
path2.lineTo(x, bottom === top ? bottom + 1 : bottom);
|
|
7281
7372
|
}
|
|
7282
7373
|
ctx.lineWidth = 1;
|
|
7283
7374
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7420,16 +7511,16 @@ function createChart(element, options = {}) {
|
|
|
7420
7511
|
const displayLow = isLastCandle && actualDirection === "down" ? Math.min(point.l, displayClose) : point.l;
|
|
7421
7512
|
const roundedCenterX = Math.round(chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth);
|
|
7422
7513
|
const direction = isLastCandle ? actualDirection : getCandleDirectionByIndex(index);
|
|
7423
|
-
const
|
|
7514
|
+
const path2 = direction === "up" ? upBars : downBars;
|
|
7424
7515
|
const centerX = roundedCenterX + 0.5;
|
|
7425
|
-
|
|
7426
|
-
|
|
7516
|
+
path2.moveTo(centerX, crisp(yFromPrice(displayHigh)));
|
|
7517
|
+
path2.lineTo(centerX, crisp(yFromPrice(displayLow)));
|
|
7427
7518
|
const openY = crisp(yFromPrice(point.o));
|
|
7428
7519
|
const closeY = crisp(yFromPrice(displayClose));
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7520
|
+
path2.moveTo(centerX - tickLength, openY);
|
|
7521
|
+
path2.lineTo(centerX, openY);
|
|
7522
|
+
path2.moveTo(centerX, closeY);
|
|
7523
|
+
path2.lineTo(centerX + tickLength, closeY);
|
|
7433
7524
|
}
|
|
7434
7525
|
ctx.lineWidth = Math.max(1, candleWickWidth);
|
|
7435
7526
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7497,7 +7588,7 @@ function createChart(element, options = {}) {
|
|
|
7497
7588
|
for (const plan of comparePlans) {
|
|
7498
7589
|
const color = plan.state.options.color ?? "#f59e0b";
|
|
7499
7590
|
const lineWidth = Math.max(1, plan.state.options.lineWidth ?? 1.5);
|
|
7500
|
-
const
|
|
7591
|
+
const path2 = new Path2D();
|
|
7501
7592
|
let started = false;
|
|
7502
7593
|
let firstX = 0;
|
|
7503
7594
|
let lastX = 0;
|
|
@@ -7505,11 +7596,11 @@ function createChart(element, options = {}) {
|
|
|
7505
7596
|
let lastPrice = Number.NaN;
|
|
7506
7597
|
const emit = (x, y) => {
|
|
7507
7598
|
if (!started) {
|
|
7508
|
-
|
|
7599
|
+
path2.moveTo(x, y);
|
|
7509
7600
|
firstX = x;
|
|
7510
7601
|
started = true;
|
|
7511
7602
|
} else {
|
|
7512
|
-
|
|
7603
|
+
path2.lineTo(x, y);
|
|
7513
7604
|
}
|
|
7514
7605
|
lastX = x;
|
|
7515
7606
|
lastY = y;
|
|
@@ -7567,7 +7658,7 @@ function createChart(element, options = {}) {
|
|
|
7567
7658
|
}
|
|
7568
7659
|
if (!started) continue;
|
|
7569
7660
|
if (plan.state.options.style === "area") {
|
|
7570
|
-
const fillPath = new Path2D(
|
|
7661
|
+
const fillPath = new Path2D(path2);
|
|
7571
7662
|
fillPath.lineTo(lastX, chartBottom);
|
|
7572
7663
|
fillPath.lineTo(firstX, chartBottom);
|
|
7573
7664
|
fillPath.closePath();
|
|
@@ -7581,7 +7672,7 @@ function createChart(element, options = {}) {
|
|
|
7581
7672
|
ctx.strokeStyle = color;
|
|
7582
7673
|
ctx.lineWidth = lineWidth;
|
|
7583
7674
|
ctx.lineJoin = "round";
|
|
7584
|
-
ctx.stroke(
|
|
7675
|
+
ctx.stroke(path2);
|
|
7585
7676
|
ctx.restore();
|
|
7586
7677
|
if (Number.isFinite(lastPrice)) {
|
|
7587
7678
|
const label = plan.state.options.label ?? plan.state.options.id;
|
|
@@ -12386,6 +12477,9 @@ function createChart(element, options = {}) {
|
|
|
12386
12477
|
0 && (module.exports = {
|
|
12387
12478
|
CHART_THEMES,
|
|
12388
12479
|
CHART_THEME_NAMES,
|
|
12480
|
+
DRAWING_ICON_STROKE_WIDTH,
|
|
12481
|
+
DRAWING_ICON_VIEWBOX,
|
|
12482
|
+
DRAWING_TOOL_ICONS,
|
|
12389
12483
|
FIB_DEFAULT_PALETTE,
|
|
12390
12484
|
POSITION_DEFAULT_COLORS,
|
|
12391
12485
|
SCRIPT_SOURCE_INPUT_VALUES,
|
package/dist/index.d.cts
CHANGED
|
@@ -1441,6 +1441,45 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1441
1441
|
*/
|
|
1442
1442
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1443
1443
|
|
|
1444
|
+
/**
|
|
1445
|
+
* Hyperprop drawing-tool icon pack — framework-agnostic geometry.
|
|
1446
|
+
*
|
|
1447
|
+
* Original artwork drawn in the visual language traders know from desktop
|
|
1448
|
+
* charting platforms: a 28x28 grid, thin round-capped outlines, and hollow
|
|
1449
|
+
* "anchor" dots on anything line-based (a dot marks a draggable point of the
|
|
1450
|
+
* tool). The data here is plain shape descriptions so every consumer renders
|
|
1451
|
+
* the identical set: the web terminal maps it to DOM `<svg>` elements and the
|
|
1452
|
+
* mobile app to react-native-svg components.
|
|
1453
|
+
*
|
|
1454
|
+
* Design rules when adding icons:
|
|
1455
|
+
* - viewBox 0 0 28 28, strokeWidth 1.6, round caps/joins, no fill (except
|
|
1456
|
+
* shapes marked `fill: true`).
|
|
1457
|
+
* - Anchor dots are hollow circles r=2.1; lines stop ~1.5px short of them.
|
|
1458
|
+
* - Keep 3.5px padding to the edges so glyphs optically match.
|
|
1459
|
+
*/
|
|
1460
|
+
type DrawingIconShape = {
|
|
1461
|
+
kind: "path";
|
|
1462
|
+
d: string;
|
|
1463
|
+
dash?: string;
|
|
1464
|
+
fill?: boolean;
|
|
1465
|
+
} | {
|
|
1466
|
+
kind: "circle";
|
|
1467
|
+
cx: number;
|
|
1468
|
+
cy: number;
|
|
1469
|
+
r: number;
|
|
1470
|
+
fill?: boolean;
|
|
1471
|
+
} | {
|
|
1472
|
+
kind: "rect";
|
|
1473
|
+
x: number;
|
|
1474
|
+
y: number;
|
|
1475
|
+
width: number;
|
|
1476
|
+
height: number;
|
|
1477
|
+
};
|
|
1478
|
+
type DrawingIconName = "cursor-cross" | "cursor-dot" | "cursor-arrow" | "trendline" | "horizontal-line" | "vertical-line" | "ray" | "arrow" | "parallel-channel" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "fixed-range-volume-profile" | "measure" | "rectangle" | "ellipse" | "brush" | "text" | "note" | "callout";
|
|
1479
|
+
declare const DRAWING_ICON_VIEWBOX = 28;
|
|
1480
|
+
declare const DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
1481
|
+
declare const DRAWING_TOOL_ICONS: Record<DrawingIconName, DrawingIconShape[]>;
|
|
1482
|
+
|
|
1444
1483
|
/**
|
|
1445
1484
|
* Built-in palettes.
|
|
1446
1485
|
*
|
|
@@ -1465,4 +1504,4 @@ declare const SESSION_PRESETS: Record<SessionPresetName, SessionSpec>;
|
|
|
1465
1504
|
|
|
1466
1505
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1467
1506
|
|
|
1468
|
-
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
|
1507
|
+
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, DRAWING_ICON_STROKE_WIDTH, DRAWING_ICON_VIEWBOX, DRAWING_TOOL_ICONS, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingIconName, type DrawingIconShape, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -1441,6 +1441,45 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1441
1441
|
*/
|
|
1442
1442
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1443
1443
|
|
|
1444
|
+
/**
|
|
1445
|
+
* Hyperprop drawing-tool icon pack — framework-agnostic geometry.
|
|
1446
|
+
*
|
|
1447
|
+
* Original artwork drawn in the visual language traders know from desktop
|
|
1448
|
+
* charting platforms: a 28x28 grid, thin round-capped outlines, and hollow
|
|
1449
|
+
* "anchor" dots on anything line-based (a dot marks a draggable point of the
|
|
1450
|
+
* tool). The data here is plain shape descriptions so every consumer renders
|
|
1451
|
+
* the identical set: the web terminal maps it to DOM `<svg>` elements and the
|
|
1452
|
+
* mobile app to react-native-svg components.
|
|
1453
|
+
*
|
|
1454
|
+
* Design rules when adding icons:
|
|
1455
|
+
* - viewBox 0 0 28 28, strokeWidth 1.6, round caps/joins, no fill (except
|
|
1456
|
+
* shapes marked `fill: true`).
|
|
1457
|
+
* - Anchor dots are hollow circles r=2.1; lines stop ~1.5px short of them.
|
|
1458
|
+
* - Keep 3.5px padding to the edges so glyphs optically match.
|
|
1459
|
+
*/
|
|
1460
|
+
type DrawingIconShape = {
|
|
1461
|
+
kind: "path";
|
|
1462
|
+
d: string;
|
|
1463
|
+
dash?: string;
|
|
1464
|
+
fill?: boolean;
|
|
1465
|
+
} | {
|
|
1466
|
+
kind: "circle";
|
|
1467
|
+
cx: number;
|
|
1468
|
+
cy: number;
|
|
1469
|
+
r: number;
|
|
1470
|
+
fill?: boolean;
|
|
1471
|
+
} | {
|
|
1472
|
+
kind: "rect";
|
|
1473
|
+
x: number;
|
|
1474
|
+
y: number;
|
|
1475
|
+
width: number;
|
|
1476
|
+
height: number;
|
|
1477
|
+
};
|
|
1478
|
+
type DrawingIconName = "cursor-cross" | "cursor-dot" | "cursor-arrow" | "trendline" | "horizontal-line" | "vertical-line" | "ray" | "arrow" | "parallel-channel" | "fib-retracement" | "fib-extension" | "long-position" | "short-position" | "price-range" | "fixed-range-volume-profile" | "measure" | "rectangle" | "ellipse" | "brush" | "text" | "note" | "callout";
|
|
1479
|
+
declare const DRAWING_ICON_VIEWBOX = 28;
|
|
1480
|
+
declare const DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
1481
|
+
declare const DRAWING_TOOL_ICONS: Record<DrawingIconName, DrawingIconShape[]>;
|
|
1482
|
+
|
|
1444
1483
|
/**
|
|
1445
1484
|
* Built-in palettes.
|
|
1446
1485
|
*
|
|
@@ -1465,4 +1504,4 @@ declare const SESSION_PRESETS: Record<SessionPresetName, SessionSpec>;
|
|
|
1465
1504
|
|
|
1466
1505
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1467
1506
|
|
|
1468
|
-
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
|
1507
|
+
export { type AccessibilityOptions, type AlertActionEvent, type AlertCondition, type AlertOptions, type AlertTriggerEvent, type AnimationOptions, type AxisOptions, type BarMarkOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartTimezone, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, DRAWING_ICON_STROKE_WIDTH, DRAWING_ICON_VIEWBOX, DRAWING_TOOL_ICONS, type DashPatternOptions, type DataLineOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingIconName, type DrawingIconShape, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type HistoryOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type IndicatorUpdateOptions, type KeyboardOptions, type LabelsOptions, type MarkClickEvent, type MarkHoverEvent, type MarkShape, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, type ReplayStartOptions, type ReplayState, SCRIPT_SOURCE_INPUT_VALUES, SESSION_PRESETS, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type SessionOptions, type SessionPresetName, type SessionSegment, type SessionSpec, type TickerLineOptions, type TimeFormat, type TimescaleMarkOptions, type TouchOptions, type TradeMarkerOptions, type UndoRedoState, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, isValidTimeZone, validateScriptSource };
|
package/dist/index.js
CHANGED
|
@@ -3132,6 +3132,94 @@ var compileScriptIndicator = (definition) => {
|
|
|
3132
3132
|
return plugin;
|
|
3133
3133
|
};
|
|
3134
3134
|
|
|
3135
|
+
// src/icons.ts
|
|
3136
|
+
var DRAWING_ICON_VIEWBOX = 28;
|
|
3137
|
+
var DRAWING_ICON_STROKE_WIDTH = 1.6;
|
|
3138
|
+
var dot = (cx, cy) => ({ kind: "circle", cx, cy, r: 2.1 });
|
|
3139
|
+
var path = (d, extra) => ({
|
|
3140
|
+
kind: "path",
|
|
3141
|
+
d,
|
|
3142
|
+
...extra
|
|
3143
|
+
});
|
|
3144
|
+
var DRAWING_TOOL_ICONS = {
|
|
3145
|
+
"cursor-cross": [path("M14 4v6.5M14 17.5V24M4 14h6.5M17.5 14H24")],
|
|
3146
|
+
"cursor-dot": [{ kind: "circle", cx: 14, cy: 14, r: 2.6, fill: true }],
|
|
3147
|
+
"cursor-arrow": [path("M10 4.5v16.4l4.3-4.1 3 6.7 2.9-1.3-3-6.7h5.9L10 4.5Z")],
|
|
3148
|
+
trendline: [dot(7, 21), dot(21, 7), path("M8.6 19.4 19.4 8.6")],
|
|
3149
|
+
"horizontal-line": [dot(14, 14), path("M3.5 14h8.4M16.1 14h8.4")],
|
|
3150
|
+
"vertical-line": [dot(14, 14), path("M14 3.5v8.4M14 16.1v8.4")],
|
|
3151
|
+
ray: [dot(7.5, 20.5), path("M9 19 24 4")],
|
|
3152
|
+
arrow: [dot(6, 22), path("M7.6 20.4 21.4 6.6"), path("M14.6 6.2h7.2v7.2")],
|
|
3153
|
+
"parallel-channel": [dot(6, 17), dot(17, 6), path("M7.5 15.5 15.5 7.5"), path("M11 23.5 23.5 11")],
|
|
3154
|
+
"fib-retracement": [
|
|
3155
|
+
dot(6, 7),
|
|
3156
|
+
path("M9.6 7h14.9"),
|
|
3157
|
+
path("M3.5 14h21"),
|
|
3158
|
+
dot(6, 21),
|
|
3159
|
+
path("M9.6 21h14.9")
|
|
3160
|
+
],
|
|
3161
|
+
"fib-extension": [
|
|
3162
|
+
dot(6.5, 21.5),
|
|
3163
|
+
dot(12.5, 6.5),
|
|
3164
|
+
path("M7.5 19.1l4-9.2"),
|
|
3165
|
+
path("M17 7h7.5M17 14h7.5M17 21h7.5")
|
|
3166
|
+
],
|
|
3167
|
+
// Long/short: three price levels (target, entry, stop) with anchor dots and
|
|
3168
|
+
// a dotted "price path" diagonal running from entry toward the target.
|
|
3169
|
+
"long-position": [
|
|
3170
|
+
dot(5, 6.5),
|
|
3171
|
+
path("M8.6 6.5h15.9"),
|
|
3172
|
+
dot(5, 16),
|
|
3173
|
+
path("M8.6 16h10.3"),
|
|
3174
|
+
dot(21, 16),
|
|
3175
|
+
path("M8.6 22.5h15.9"),
|
|
3176
|
+
dot(5, 22.5),
|
|
3177
|
+
path("M10.5 14 22 7.8", { dash: "2 3.2" })
|
|
3178
|
+
],
|
|
3179
|
+
"short-position": [
|
|
3180
|
+
dot(5, 21.5),
|
|
3181
|
+
path("M8.6 21.5h15.9"),
|
|
3182
|
+
dot(5, 12),
|
|
3183
|
+
path("M8.6 12h10.3"),
|
|
3184
|
+
dot(21, 12),
|
|
3185
|
+
path("M8.6 5.5h15.9"),
|
|
3186
|
+
dot(5, 5.5),
|
|
3187
|
+
path("M10.5 14 22 20.2", { dash: "2 3.2" })
|
|
3188
|
+
],
|
|
3189
|
+
"price-range": [
|
|
3190
|
+
path("M8 5h12M8 23h12"),
|
|
3191
|
+
path("M14 7v14"),
|
|
3192
|
+
path("M11.2 9.8 14 7l2.8 2.8M11.2 18.2 14 21l2.8-2.8")
|
|
3193
|
+
],
|
|
3194
|
+
// Fixed range VP: two vertical range anchors with the profile bars attached
|
|
3195
|
+
// to the left one.
|
|
3196
|
+
"fixed-range-volume-profile": [
|
|
3197
|
+
path("M5 3.5v15.4"),
|
|
3198
|
+
dot(5, 21.5),
|
|
3199
|
+
dot(23, 6.5),
|
|
3200
|
+
path("M23 9.1v15.4"),
|
|
3201
|
+
{ kind: "rect", x: 5, y: 6, width: 7, height: 3.2 },
|
|
3202
|
+
{ kind: "rect", x: 5, y: 11, width: 10.5, height: 3.2 },
|
|
3203
|
+
{ kind: "rect", x: 5, y: 16, width: 4.5, height: 3.2 }
|
|
3204
|
+
],
|
|
3205
|
+
measure: [
|
|
3206
|
+
path("M4.5 18.5 18.5 4.5l5 5L9.5 23.5Z"),
|
|
3207
|
+
path("m8 15 1.8 1.8M11.5 11.5 14 14M15 8l1.8 1.8")
|
|
3208
|
+
],
|
|
3209
|
+
rectangle: [
|
|
3210
|
+
dot(6, 8),
|
|
3211
|
+
dot(22, 8),
|
|
3212
|
+
dot(22, 20),
|
|
3213
|
+
dot(6, 20),
|
|
3214
|
+
path("M8.1 8h11.8M8.1 20h11.8M6 10.1v7.8M22 10.1v7.8")
|
|
3215
|
+
],
|
|
3216
|
+
ellipse: [path("M6.1 14a7.9 6.9 0 1 0 15.8 0 7.9 6.9 0 1 0-15.8 0"), dot(4, 14), dot(24, 14)],
|
|
3217
|
+
brush: [dot(5, 20), path("M6.9 18.4c2.6-6 5-.6 8.4-3.2 3-2.3 5.4-6 8.2-7.9")],
|
|
3218
|
+
text: [path("M7 8.5V6h14v2.5"), path("M14 6v16M11 22h6")],
|
|
3219
|
+
note: [path("M5.5 5h17v11.5l-6 6h-11V5Z"), path("M22.5 16.5h-6v6")],
|
|
3220
|
+
callout: [path("M4.5 6h19v11.5H13L8 22.5v-5H4.5V6Z")]
|
|
3221
|
+
};
|
|
3222
|
+
|
|
3135
3223
|
// src/themes.ts
|
|
3136
3224
|
var CHART_THEMES = {
|
|
3137
3225
|
midnight: {
|
|
@@ -4654,9 +4742,9 @@ function createChart(element, options = {}) {
|
|
|
4654
4742
|
const groupThousands = (value, decimals) => {
|
|
4655
4743
|
const negative = value < 0;
|
|
4656
4744
|
const fixed = Math.abs(value).toFixed(decimals);
|
|
4657
|
-
const
|
|
4658
|
-
const intPart =
|
|
4659
|
-
const decPart =
|
|
4745
|
+
const dot2 = fixed.indexOf(".");
|
|
4746
|
+
const intPart = dot2 === -1 ? fixed : fixed.slice(0, dot2);
|
|
4747
|
+
const decPart = dot2 === -1 ? "" : fixed.slice(dot2);
|
|
4660
4748
|
const grouped = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
4661
4749
|
return `${negative ? "-" : ""}${grouped}${decPart}`;
|
|
4662
4750
|
};
|
|
@@ -7236,12 +7324,12 @@ function createChart(element, options = {}) {
|
|
|
7236
7324
|
const upColumns = new Path2D();
|
|
7237
7325
|
const downColumns = new Path2D();
|
|
7238
7326
|
for (const column of seriesColumns) {
|
|
7239
|
-
const
|
|
7327
|
+
const path2 = column.close >= column.open ? upColumns : downColumns;
|
|
7240
7328
|
const x = column.x + 0.5;
|
|
7241
7329
|
const top = crisp(yFromPrice(column.high));
|
|
7242
7330
|
const bottom = crisp(yFromPrice(column.low));
|
|
7243
|
-
|
|
7244
|
-
|
|
7331
|
+
path2.moveTo(x, top);
|
|
7332
|
+
path2.lineTo(x, bottom === top ? bottom + 1 : bottom);
|
|
7245
7333
|
}
|
|
7246
7334
|
ctx.lineWidth = 1;
|
|
7247
7335
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7384,16 +7472,16 @@ function createChart(element, options = {}) {
|
|
|
7384
7472
|
const displayLow = isLastCandle && actualDirection === "down" ? Math.min(point.l, displayClose) : point.l;
|
|
7385
7473
|
const roundedCenterX = Math.round(chartLeft + (index + 0.5 - xStart) / xSpan * chartWidth);
|
|
7386
7474
|
const direction = isLastCandle ? actualDirection : getCandleDirectionByIndex(index);
|
|
7387
|
-
const
|
|
7475
|
+
const path2 = direction === "up" ? upBars : downBars;
|
|
7388
7476
|
const centerX = roundedCenterX + 0.5;
|
|
7389
|
-
|
|
7390
|
-
|
|
7477
|
+
path2.moveTo(centerX, crisp(yFromPrice(displayHigh)));
|
|
7478
|
+
path2.lineTo(centerX, crisp(yFromPrice(displayLow)));
|
|
7391
7479
|
const openY = crisp(yFromPrice(point.o));
|
|
7392
7480
|
const closeY = crisp(yFromPrice(displayClose));
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7481
|
+
path2.moveTo(centerX - tickLength, openY);
|
|
7482
|
+
path2.lineTo(centerX, openY);
|
|
7483
|
+
path2.moveTo(centerX, closeY);
|
|
7484
|
+
path2.lineTo(centerX + tickLength, closeY);
|
|
7397
7485
|
}
|
|
7398
7486
|
ctx.lineWidth = Math.max(1, candleWickWidth);
|
|
7399
7487
|
ctx.strokeStyle = mergedOptions.upColor;
|
|
@@ -7461,7 +7549,7 @@ function createChart(element, options = {}) {
|
|
|
7461
7549
|
for (const plan of comparePlans) {
|
|
7462
7550
|
const color = plan.state.options.color ?? "#f59e0b";
|
|
7463
7551
|
const lineWidth = Math.max(1, plan.state.options.lineWidth ?? 1.5);
|
|
7464
|
-
const
|
|
7552
|
+
const path2 = new Path2D();
|
|
7465
7553
|
let started = false;
|
|
7466
7554
|
let firstX = 0;
|
|
7467
7555
|
let lastX = 0;
|
|
@@ -7469,11 +7557,11 @@ function createChart(element, options = {}) {
|
|
|
7469
7557
|
let lastPrice = Number.NaN;
|
|
7470
7558
|
const emit = (x, y) => {
|
|
7471
7559
|
if (!started) {
|
|
7472
|
-
|
|
7560
|
+
path2.moveTo(x, y);
|
|
7473
7561
|
firstX = x;
|
|
7474
7562
|
started = true;
|
|
7475
7563
|
} else {
|
|
7476
|
-
|
|
7564
|
+
path2.lineTo(x, y);
|
|
7477
7565
|
}
|
|
7478
7566
|
lastX = x;
|
|
7479
7567
|
lastY = y;
|
|
@@ -7531,7 +7619,7 @@ function createChart(element, options = {}) {
|
|
|
7531
7619
|
}
|
|
7532
7620
|
if (!started) continue;
|
|
7533
7621
|
if (plan.state.options.style === "area") {
|
|
7534
|
-
const fillPath = new Path2D(
|
|
7622
|
+
const fillPath = new Path2D(path2);
|
|
7535
7623
|
fillPath.lineTo(lastX, chartBottom);
|
|
7536
7624
|
fillPath.lineTo(firstX, chartBottom);
|
|
7537
7625
|
fillPath.closePath();
|
|
@@ -7545,7 +7633,7 @@ function createChart(element, options = {}) {
|
|
|
7545
7633
|
ctx.strokeStyle = color;
|
|
7546
7634
|
ctx.lineWidth = lineWidth;
|
|
7547
7635
|
ctx.lineJoin = "round";
|
|
7548
|
-
ctx.stroke(
|
|
7636
|
+
ctx.stroke(path2);
|
|
7549
7637
|
ctx.restore();
|
|
7550
7638
|
if (Number.isFinite(lastPrice)) {
|
|
7551
7639
|
const label = plan.state.options.label ?? plan.state.options.id;
|
|
@@ -12349,6 +12437,9 @@ function createChart(element, options = {}) {
|
|
|
12349
12437
|
export {
|
|
12350
12438
|
CHART_THEMES,
|
|
12351
12439
|
CHART_THEME_NAMES,
|
|
12440
|
+
DRAWING_ICON_STROKE_WIDTH,
|
|
12441
|
+
DRAWING_ICON_VIEWBOX,
|
|
12442
|
+
DRAWING_TOOL_ICONS,
|
|
12352
12443
|
FIB_DEFAULT_PALETTE,
|
|
12353
12444
|
POSITION_DEFAULT_COLORS,
|
|
12354
12445
|
SCRIPT_SOURCE_INPUT_VALUES,
|