@kumo-charts/core 1.0.0-beta.6 → 1.0.0-beta.7
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/LICENSE +201 -201
- package/NOTICE +11 -11
- package/README.md +23 -23
- package/dist/{aggregator-CsTcgTRK.js → aggregator-DFCDVoFt.js} +3 -3
- package/dist/{alert-book-DNP68WX7.js → alert-book-KgUNJ1Pm.js} +5 -4
- package/dist/alert-engine.d.ts +5 -5
- package/dist/alert-engine.js +10 -10
- package/dist/{alerts-Bv5u4-99.js → alerts-sN1NVz-X.js} +19 -7
- package/dist/alerts.d.ts +1 -1
- package/dist/alerts.js +1 -1
- package/dist/all.d.ts +9 -9
- package/dist/all.js +9 -9
- package/dist/{api-BxS-GfYB.d.ts → api-BWC_Cce5.d.ts} +15 -1
- package/dist/{api-BlJUtij_.d.ts → api-DgviKlaI.d.ts} +1 -1
- package/dist/{bar-store-B_NkvUnA.js → bar-store-B4HFH1h6.js} +21 -3
- package/dist/{calendar-BkI9B9A5.js → calendar-xZYfA5bX.js} +4 -4
- package/dist/{chart-types-pzeZDEp9.js → chart-types-DtRsOwjT.js} +3 -3
- package/dist/chart-types.d.ts +1 -1
- package/dist/chart-types.js +1 -1
- package/dist/collection-RZyV3hnM.js +71 -0
- package/dist/{color-1Osbv2TE.js → color-AsBx5M66.js} +1 -1
- package/dist/{data-B75gRyuP.d.ts → data-RRHroFqK.d.ts} +34 -2
- package/dist/{drawings-DMRwbLsg.js → drawings-C-jyagJI.js} +137 -125
- package/dist/drawings.d.ts +3 -3
- package/dist/drawings.js +1 -1
- package/dist/{frame-Bt85Ejw7.js → frame-790ompHn.js} +5 -6
- package/dist/{index-Bfi0g81h.d.ts → index-B5nL4-fG.d.ts} +4 -2
- package/dist/{index-D12U6YKZ.d.ts → index-BMRUiN6F.d.ts} +2 -2
- package/dist/{index-SSXLg0b-.d.ts → index-Bgl-FJT3.d.ts} +3 -3
- package/dist/{index-BoRy0gWB.d.ts → index-Bp1gL2SV.d.ts} +1 -1
- package/dist/{index-DTrnOP7Q.d.ts → index-CsFnU-ko.d.ts} +1 -1
- package/dist/{index-BpyqTH6i.d.ts → index-D5fdjNJv.d.ts} +14 -2
- package/dist/{index-DvbA0QtQ.d.ts → index-cuDsywlB.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +280 -107
- package/dist/{indicator-store-CSNYNv-H.js → indicator-store-Cj8FkdLe.js} +11 -5
- package/dist/{indicators-7G1DqNSH.js → indicators-KKeZmC6g.js} +30 -9
- package/dist/indicators.d.ts +2 -2
- package/dist/indicators.js +2 -2
- package/dist/kumo-charts.iife.js +7 -7
- package/dist/{module-DxdViSuj.d.ts → module-ma1-rklb.d.ts} +2 -2
- package/dist/{modules-RlaXjRWe.js → modules-D_E0wmaT.js} +1 -1
- package/dist/{price-line-BPw9VyW3.js → price-line-Ctf8YIXI.js} +77 -89
- package/dist/{price-line-CdM5YNlZ.d.ts → price-line-exqgokHI.d.ts} +3 -1
- package/dist/{price-lines-CaLOO6qa.js → price-lines-C9xony-Z.js} +1 -1
- package/dist/{registry-f-A949ov.js → registry-DpycnxXe.js} +8 -4
- package/dist/{replay-_1IoxPdh.js → replay-BglWO-Se.js} +3 -3
- package/dist/replay.d.ts +1 -1
- package/dist/replay.js +1 -1
- package/dist/{series-store-Brd46VuC.js → series-store-DwvvS42F.js} +3 -3
- package/dist/{time-BN0L-hLy.js → time-QUqwrKFO.js} +1 -1
- package/dist/{trading-CjKK5irF.js → trading-BY4NVox9.js} +38 -17
- package/dist/trading.d.ts +1 -1
- package/dist/trading.js +1 -1
- package/dist/{transforms-CtdsqwVk.js → transforms-D07qL7UT.js} +3 -3
- package/dist/{types-Bgjeo6w6.js → types-CEVVGcR9.js} +6 -2
- package/dist/{types-uoxTaiGv.js → types-CgerhCJ3.js} +3 -1
- package/dist/{types-xV6t4aad.d.ts → types-CrxgaGh5.d.ts} +14 -2
- package/dist/{validate-YdhjgZ6g.js → validate-B_z8rO0I.js} +4 -1
- package/dist/{value-format-BieuAeNK.js → value-format-DwSqOZkc.js} +6 -6
- package/dist/{values-Cw8XKIVE.js → values-CIb5EJ5-.js} +18 -10
- package/dist/{values-CtBpceAo.js → values-Hk0_RbLE.js} +5 -5
- package/dist/{volume-profile-ZWM9N-I-.js → volume-profile-Ci-AGdvp.js} +5 -8
- package/dist/volume-profile.d.ts +1 -1
- package/dist/volume-profile.js +1 -1
- package/dist/{watermark-qCkQw950.js → watermark--TmdUE3C.js} +3 -3
- package/dist/watermark.d.ts +1 -1
- package/dist/watermark.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Fn as ValueSource, Ut as LineStyle, l as ChartModule } from "./data-RRHroFqK.js";
|
|
2
|
+
import { a as CollectionApi, i as PriceLineButton, r as PriceDragEvent } from "./price-line-exqgokHI.js";
|
|
3
3
|
//#region src/alerts/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The two bounds of a channel, in either order: at each bar the channel lies between them, e.g.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as checkString, m as fail, r as checkFields, s as checkObject } from "./validate-B_z8rO0I.js";
|
|
2
2
|
//#region src/chart/modules.ts
|
|
3
3
|
const specs = /* @__PURE__ */ new WeakMap();
|
|
4
4
|
/** Makes a module from how it joins a chart. */
|
|
@@ -1,76 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as withAlpha } from "./color-
|
|
1
|
+
import { d as fieldsOf, l as checkString, m as fail, o as checkNumber, r as checkFields, t as checkArray } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { i as withAlpha } from "./color-AsBx5M66.js";
|
|
3
3
|
import { a as font, n as applyStroke, s as snap } from "./canvas-BFRISb50.js";
|
|
4
|
-
import { t as HitPriority } from "./types-
|
|
5
|
-
//#region src/chart/api/collection.ts
|
|
6
|
-
/**
|
|
7
|
-
* What `inputs` bring in place of every object of a collection, by id in their order: each input
|
|
8
|
-
* parsed but for its id, and its id the one it gives, or the next of `prefix` after those of
|
|
9
|
-
* `ids`. Every input is checked before any is numbered, and an id given twice throws; `ids` notes
|
|
10
|
-
* the ids once they are all valid.
|
|
11
|
-
*/
|
|
12
|
-
function replacement(label, inputs, ids, prefix, parse) {
|
|
13
|
-
checkArray(label, inputs);
|
|
14
|
-
const parsed = inputs.map((input, index) => ({
|
|
15
|
-
input,
|
|
16
|
-
settings: parse(input, `${label}[${index}]`)
|
|
17
|
-
}));
|
|
18
|
-
const given = /* @__PURE__ */ new Set();
|
|
19
|
-
parsed.forEach(({ input }, index) => {
|
|
20
|
-
if (input.id !== void 0) {
|
|
21
|
-
const id = checkString(`${label}[${index}].id`, input.id);
|
|
22
|
-
if (given.has(id)) fail(`${label} contains the id "${id}" twice.`);
|
|
23
|
-
given.add(id);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
given.forEach((id) => {
|
|
27
|
-
ids.note(id);
|
|
28
|
-
});
|
|
29
|
-
const items = /* @__PURE__ */ new Map();
|
|
30
|
-
parsed.forEach(({ input, settings }) => {
|
|
31
|
-
const id = input.id ?? ids.next(prefix);
|
|
32
|
-
ids.note(id);
|
|
33
|
-
items.set(id, {
|
|
34
|
-
id,
|
|
35
|
-
...settings
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
return items;
|
|
39
|
-
}
|
|
40
|
-
function collectionApi(core, collection) {
|
|
41
|
-
const mutate = (operation) => core.run(() => {
|
|
42
|
-
const result = operation();
|
|
43
|
-
core.objects.prune();
|
|
44
|
-
core.invalidateLayers("objects");
|
|
45
|
-
return result;
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
set: (inputs) => {
|
|
49
|
-
mutate(() => {
|
|
50
|
-
collection.set(inputs);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
add: (input) => mutate(() => collection.add(input)),
|
|
54
|
-
update: (id, patch) => {
|
|
55
|
-
mutate(() => {
|
|
56
|
-
collection.update(id, patch);
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
remove: (id) => {
|
|
60
|
-
mutate(() => {
|
|
61
|
-
collection.remove(id);
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
clear: () => {
|
|
65
|
-
mutate(() => {
|
|
66
|
-
collection.set([]);
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
get: (id) => collection.get(id),
|
|
70
|
-
list: () => collection.list()
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
//#endregion
|
|
4
|
+
import { t as HitPriority } from "./types-CEVVGcR9.js";
|
|
74
5
|
//#region src/objects/price-line.ts
|
|
75
6
|
/**
|
|
76
7
|
* The value a line dragged to `y` on a scale takes, rounded as the pane writes its values: to their
|
|
@@ -120,8 +51,19 @@ function validateButtons(buttons, label) {
|
|
|
120
51
|
return { ...button };
|
|
121
52
|
});
|
|
122
53
|
}
|
|
54
|
+
const LABEL_ALIGNS = [
|
|
55
|
+
"left",
|
|
56
|
+
"center",
|
|
57
|
+
"right"
|
|
58
|
+
];
|
|
123
59
|
const LABEL_MARGIN = 8;
|
|
124
60
|
const LABEL_GAP = 2;
|
|
61
|
+
/** The room of the arrow at the start of a label pinned to an edge. */
|
|
62
|
+
const ARROW_WIDTH = 16;
|
|
63
|
+
/** Whether a part of a price line is its label pinned to an edge of the plot. */
|
|
64
|
+
function isPinned(part) {
|
|
65
|
+
return part === "pinned" || part.startsWith("pinned:");
|
|
66
|
+
}
|
|
125
67
|
/**
|
|
126
68
|
* Where the labels go: at their lines, each moved down past the one above it, and those that
|
|
127
69
|
* would then leave the plot at the bottom moved up, each above the one below it. Labels of lines
|
|
@@ -145,17 +87,46 @@ function labelCenters(sorted, plotHeight, height) {
|
|
|
145
87
|
}
|
|
146
88
|
return labels.map((label) => label.center);
|
|
147
89
|
}
|
|
148
|
-
/**
|
|
149
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Lays out the labels of price lines at the right of the plot, or where each says, keeping those
|
|
92
|
+
* at the same place along the lines from overlapping.
|
|
93
|
+
* With `pin`, the label of a line above or below the plot stays at the top or bottom edge, those
|
|
94
|
+
* of several lines stacked there in the order of their lines, and no label leaves the plot.
|
|
95
|
+
*/
|
|
96
|
+
function layoutPriceLines(views, plotWidth, plotHeight, fontSize, measure, pin = false) {
|
|
150
97
|
const height = fontSize + 8;
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
const
|
|
98
|
+
const half = height / 2;
|
|
99
|
+
const placed = views.filter((view) => Number.isFinite(view.y)).map((view) => {
|
|
100
|
+
const pinned = !pin ? null : view.y < 0 ? "top" : view.y > plotHeight ? "bottom" : null;
|
|
101
|
+
const y = pinned === "top" ? half : pinned === "bottom" ? plotHeight - half : view.y;
|
|
102
|
+
return {
|
|
103
|
+
view,
|
|
104
|
+
pinned,
|
|
105
|
+
at: pin && !pinned ? Math.max(view.y, half) : y
|
|
106
|
+
};
|
|
107
|
+
}).sort((left, right) => left.at - right.at || left.view.y - right.view.y);
|
|
108
|
+
const centers = [];
|
|
109
|
+
for (const align of LABEL_ALIGNS) {
|
|
110
|
+
const indexes = placed.flatMap(({ view }, index) => (view.align ?? "right") === align ? [index] : []);
|
|
111
|
+
const column = labelCenters(indexes.map((index) => {
|
|
112
|
+
const { view, at } = placed[index];
|
|
113
|
+
return {
|
|
114
|
+
...view,
|
|
115
|
+
y: at
|
|
116
|
+
};
|
|
117
|
+
}), plotHeight, height);
|
|
118
|
+
indexes.forEach((index, at) => {
|
|
119
|
+
centers[index] = column[at] ?? 0;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return placed.map(({ view, pinned }, index) => {
|
|
123
|
+
const arrow = pinned ? ARROW_WIDTH : 0;
|
|
124
|
+
const textWidth = (view.text ? measure(view.text, fontSize) + 12 : 0) + arrow;
|
|
155
125
|
const buttonWidths = view.buttons.map((button) => button.width ?? (button.icon ? height : measure(button.text ?? "", fontSize) + 12));
|
|
156
126
|
const width = textWidth + buttonWidths.reduce((sum, value) => sum + value, 0);
|
|
157
127
|
const labelY = centers[index] ?? view.y;
|
|
158
|
-
const
|
|
128
|
+
const align = view.align ?? "right";
|
|
129
|
+
const left = align === "left" ? LABEL_MARGIN : align === "center" ? (plotWidth - width) / 2 : plotWidth - LABEL_MARGIN - width;
|
|
159
130
|
const top = labelY - height / 2;
|
|
160
131
|
let x = left + textWidth;
|
|
161
132
|
const buttons = view.buttons.map((button, index) => {
|
|
@@ -181,6 +152,8 @@ function layoutPriceLines(views, plotWidth, plotHeight, fontSize, measure) {
|
|
|
181
152
|
width,
|
|
182
153
|
height
|
|
183
154
|
},
|
|
155
|
+
pinned,
|
|
156
|
+
arrow,
|
|
184
157
|
textWidth,
|
|
185
158
|
buttons
|
|
186
159
|
};
|
|
@@ -197,12 +170,15 @@ function hitPriceLines(layouts, point, tolerance) {
|
|
|
197
170
|
priority: HitPriority.button,
|
|
198
171
|
distance: 0
|
|
199
172
|
};
|
|
200
|
-
for (const layout of layouts) if (contains(layout.label, point))
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
173
|
+
for (const layout of layouts) if (contains(layout.label, point)) {
|
|
174
|
+
const part = layout.pinned ? "pinned" : "label";
|
|
175
|
+
return {
|
|
176
|
+
id: layout.view.id,
|
|
177
|
+
part,
|
|
178
|
+
priority: HitPriority.label,
|
|
179
|
+
distance: 0
|
|
180
|
+
};
|
|
181
|
+
}
|
|
206
182
|
let best = null;
|
|
207
183
|
for (const layout of layouts) {
|
|
208
184
|
const distance = Math.abs(point.y - layout.view.y);
|
|
@@ -230,7 +206,7 @@ function paintPriceLines(ctx, layouts, plot, axis, options, icons) {
|
|
|
230
206
|
ctx.stroke();
|
|
231
207
|
const top = plot.y + label.y;
|
|
232
208
|
const left = plot.x + label.x;
|
|
233
|
-
if (layout.labelY !== view.y) {
|
|
209
|
+
if (layout.labelY !== view.y && !layout.pinned) {
|
|
234
210
|
ctx.beginPath();
|
|
235
211
|
ctx.moveTo(left + label.width / 2, y);
|
|
236
212
|
ctx.lineTo(left + label.width / 2, top);
|
|
@@ -241,10 +217,22 @@ function paintPriceLines(ctx, layouts, plot, axis, options, icons) {
|
|
|
241
217
|
ctx.beginPath();
|
|
242
218
|
ctx.roundRect(left, top, label.width, label.height, 3);
|
|
243
219
|
ctx.fill();
|
|
220
|
+
if (layout.pinned) {
|
|
221
|
+
const x = left + layout.arrow / 2 + 1;
|
|
222
|
+
const middle = top + label.height / 2;
|
|
223
|
+
const tip = layout.pinned === "top" ? -1 : 1;
|
|
224
|
+
ctx.fillStyle = options.textColor;
|
|
225
|
+
ctx.beginPath();
|
|
226
|
+
ctx.moveTo(x, middle + tip * 4);
|
|
227
|
+
ctx.lineTo(x - 4, middle - tip * 3);
|
|
228
|
+
ctx.lineTo(x + 4, middle - tip * 3);
|
|
229
|
+
ctx.closePath();
|
|
230
|
+
ctx.fill();
|
|
231
|
+
}
|
|
244
232
|
if (view.text) {
|
|
245
233
|
ctx.fillStyle = options.textColor;
|
|
246
234
|
ctx.textAlign = "center";
|
|
247
|
-
ctx.fillText(view.text, left + layout.textWidth / 2, top + label.height / 2 + .5);
|
|
235
|
+
ctx.fillText(view.text, left + layout.arrow + (layout.textWidth - layout.arrow) / 2, top + label.height / 2 + .5);
|
|
248
236
|
}
|
|
249
237
|
for (const { button, rect } of layout.buttons) {
|
|
250
238
|
const x = plot.x + rect.x;
|
|
@@ -270,7 +258,7 @@ function paintPriceLines(ctx, layouts, plot, axis, options, icons) {
|
|
|
270
258
|
ctx.fillText(button.text, x + rect.width / 2, top + rect.height / 2 + .5);
|
|
271
259
|
}
|
|
272
260
|
}
|
|
273
|
-
if (options.showAxis && view.y >= 0 && view.y <= plot.height) {
|
|
261
|
+
if (options.showAxis && view.axisText !== null && view.y >= 0 && view.y <= plot.height) {
|
|
274
262
|
const height = options.fontSize + 8;
|
|
275
263
|
ctx.fillStyle = view.color;
|
|
276
264
|
ctx.beginPath();
|
|
@@ -283,4 +271,4 @@ function paintPriceLines(ctx, layouts, plot, axis, options, icons) {
|
|
|
283
271
|
}
|
|
284
272
|
}
|
|
285
273
|
//#endregion
|
|
286
|
-
export {
|
|
274
|
+
export { layoutPriceLines as a, isPinned as i, draggedValue as n, paintPriceLines as o, hitPriceLines as r, validateButtons as s, LABEL_ALIGNS as t };
|
|
@@ -40,5 +40,7 @@ interface PriceLineButton {
|
|
|
40
40
|
/** Width in CSS pixels; defaults to fit the content. */
|
|
41
41
|
width?: number;
|
|
42
42
|
}
|
|
43
|
+
/** Where along a price line its label is: at the left of the plot, its middle or its right. */
|
|
44
|
+
type LabelAlign = 'left' | 'center' | 'right';
|
|
43
45
|
//#endregion
|
|
44
|
-
export { CollectionApi as i,
|
|
46
|
+
export { CollectionApi as a, PriceLineButton as i, LabelAlign as n, PriceDragEvent as r, DragPhase as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as formatPaneValue } from "./frame-
|
|
1
|
+
import { n as formatPaneValue } from "./frame-790ompHn.js";
|
|
2
2
|
//#region src/chart/price-lines.ts
|
|
3
3
|
/** How price lines (orders, alerts) of a chart are drawn, dragged and reported. */
|
|
4
4
|
function priceLineHost(core, dragged) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { l as checkString, m as fail, s as checkObject } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { r as deepFreeze } from "./types-CgerhCJ3.js";
|
|
3
3
|
//#region src/options/texts.ts
|
|
4
4
|
/** The value labels of the main series' legend and the countdown's days, alike in every language. */
|
|
5
5
|
const CHART_TEXTS = {
|
|
@@ -121,7 +121,9 @@ function createDefaultOptions(sections = []) {
|
|
|
121
121
|
horizontal: true,
|
|
122
122
|
labels: true,
|
|
123
123
|
style: "dashed",
|
|
124
|
-
snapToBars: true
|
|
124
|
+
snapToBars: true,
|
|
125
|
+
priceLines: null,
|
|
126
|
+
avoidLabels: false
|
|
125
127
|
},
|
|
126
128
|
mainSeries: {
|
|
127
129
|
type: "candles",
|
|
@@ -147,7 +149,9 @@ function createDefaultOptions(sections = []) {
|
|
|
147
149
|
},
|
|
148
150
|
precision: "auto",
|
|
149
151
|
formatter: null,
|
|
150
|
-
minWidth: 48
|
|
152
|
+
minWidth: 48,
|
|
153
|
+
pinLabels: true,
|
|
154
|
+
labelAnchor: "middle"
|
|
151
155
|
},
|
|
152
156
|
latestPrice: {
|
|
153
157
|
line: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as toTime } from "./time-
|
|
3
|
-
import { n as defineModule } from "./modules-
|
|
1
|
+
import { c as checkOneOf, d as fieldsOf, m as fail, o as checkNumber, p as describeValue, r as checkFields } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { n as toTime } from "./time-QUqwrKFO.js";
|
|
3
|
+
import { n as defineModule } from "./modules-D_E0wmaT.js";
|
|
4
4
|
//#region src/replay/api.ts
|
|
5
5
|
function createReplayApi(core, replay) {
|
|
6
6
|
return {
|
package/dist/replay.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ReplayEvent, i as ReplayApi, n as ReplayModule, o as ReplaySettings, r as replay, s as ReplayState, t as ReplayEventMap } from "./index-
|
|
1
|
+
import { a as ReplayEvent, i as ReplayApi, n as ReplayModule, o as ReplaySettings, r as replay, s as ReplayState, t as ReplayEventMap } from "./index-Bp1gL2SV.js";
|
|
2
2
|
export { type ReplayApi, type ReplayEvent, type ReplayEventMap, type ReplayModule, type ReplaySettings, type ReplayState, replay };
|
package/dist/replay.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as replay } from "./replay-
|
|
1
|
+
export { t as replay } from "./replay-BglWO-Se.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as IdSequence, r as checkStyleColors } from "./color-
|
|
3
|
-
import { i as identityBucketer, n as createValueFeed, t as createBarFeed } from "./aggregator-
|
|
1
|
+
import { d as fieldsOf, l as checkString, m as fail, n as checkBoolean, o as checkNumber, r as checkFields } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { l as IdSequence, r as checkStyleColors } from "./color-AsBx5M66.js";
|
|
3
|
+
import { i as identityBucketer, n as createValueFeed, t as createBarFeed } from "./aggregator-DFCDVoFt.js";
|
|
4
4
|
//#region src/series/series-store.ts
|
|
5
5
|
const INPUT_FIELDS = fieldsOf({
|
|
6
6
|
id: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as fail, p as describeValue } from "./validate-B_z8rO0I.js";
|
|
2
2
|
//#region src/data/time.ts
|
|
3
3
|
/** Converts a {@link TimeInput} into epoch milliseconds. Throws on invalid input. */
|
|
4
4
|
function toTime(input, context = "time") {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as toTime } from "./time-
|
|
3
|
-
import { l as IdSequence, n as checkColor, o as MAIN_PANE_ID } from "./color-
|
|
4
|
-
import {
|
|
1
|
+
import { c as checkOneOf, d as fieldsOf, l as checkString, m as fail, n as checkBoolean, o as checkNumber, r as checkFields } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { n as toTime } from "./time-QUqwrKFO.js";
|
|
3
|
+
import { c as RIGHT_SCALE, l as IdSequence, n as checkColor, o as MAIN_PANE_ID } from "./color-AsBx5M66.js";
|
|
4
|
+
import { n as LINE_STYLES } from "./types-CgerhCJ3.js";
|
|
5
5
|
import { a as font, n as applyStroke, r as dashPattern } from "./canvas-BFRISb50.js";
|
|
6
6
|
import { n as shapeDirection, r as traceShape, t as MARKER_SHAPES } from "./shapes-BS99dAcE.js";
|
|
7
7
|
import { t as IconCache } from "./icon-cache-9DXKBCfA.js";
|
|
8
|
-
import {
|
|
9
|
-
import { n as
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
8
|
+
import { r as paneOf, t as HitPriority } from "./types-CEVVGcR9.js";
|
|
9
|
+
import { a as layoutPriceLines, n as draggedValue, o as paintPriceLines, r as hitPriceLines, s as validateButtons, t as LABEL_ALIGNS } from "./price-line-Ctf8YIXI.js";
|
|
10
|
+
import { n as defineModule } from "./modules-D_E0wmaT.js";
|
|
11
|
+
import { n as replacement, t as collectionApi } from "./collection-RZyV3hnM.js";
|
|
12
|
+
import { t as priceLineHost } from "./price-lines-C9xony-Z.js";
|
|
12
13
|
//#region src/trading/markers.ts
|
|
13
14
|
const POSITIONS = [
|
|
14
15
|
"above",
|
|
@@ -299,12 +300,16 @@ const ORDER_FIELDS = fieldsOf({
|
|
|
299
300
|
visible: true,
|
|
300
301
|
color: true,
|
|
301
302
|
lineStyle: true,
|
|
302
|
-
buttons: true
|
|
303
|
+
buttons: true,
|
|
304
|
+
labelAlign: true,
|
|
305
|
+
axisLabel: true,
|
|
306
|
+
tooltip: true
|
|
303
307
|
});
|
|
304
308
|
function parseOrder(input, label = "order") {
|
|
305
309
|
checkFields(label, input, ORDER_FIELDS);
|
|
306
310
|
if (input.label !== void 0) checkString(`${label}.label`, input.label);
|
|
307
311
|
if (input.quantity !== void 0 && typeof input.quantity !== "string") checkNumber(`${label}.quantity`, input.quantity);
|
|
312
|
+
if (input.tooltip !== void 0) checkString(`${label}.tooltip`, input.tooltip);
|
|
308
313
|
return {
|
|
309
314
|
price: checkNumber(`${label}.price`, input.price),
|
|
310
315
|
side: checkOneOf(`${label}.side`, input.side, ["buy", "sell"]),
|
|
@@ -315,7 +320,10 @@ function parseOrder(input, label = "order") {
|
|
|
315
320
|
visible: input.visible === void 0 ? true : checkBoolean(`${label}.visible`, input.visible),
|
|
316
321
|
color: input.color === void 0 ? null : checkColor(`${label}.color`, input.color),
|
|
317
322
|
lineStyle: input.lineStyle === void 0 ? "dashed" : checkOneOf(`${label}.lineStyle`, input.lineStyle, LINE_STYLES),
|
|
318
|
-
buttons: validateButtons(input.buttons, `${label}.buttons`)
|
|
323
|
+
buttons: validateButtons(input.buttons, `${label}.buttons`),
|
|
324
|
+
labelAlign: input.labelAlign === void 0 ? "right" : checkOneOf(`${label}.labelAlign`, input.labelAlign, LABEL_ALIGNS),
|
|
325
|
+
axisLabel: input.axisLabel === void 0 ? true : checkBoolean(`${label}.axisLabel`, input.axisLabel),
|
|
326
|
+
tooltip: input.tooltip === void 0 || input.tooltip === "" ? null : input.tooltip
|
|
319
327
|
};
|
|
320
328
|
}
|
|
321
329
|
function orderInput(order) {
|
|
@@ -327,9 +335,12 @@ function orderInput(order) {
|
|
|
327
335
|
visible: order.visible,
|
|
328
336
|
lineStyle: order.lineStyle,
|
|
329
337
|
buttons: order.buttons.map((button) => ({ ...button })),
|
|
338
|
+
labelAlign: order.labelAlign,
|
|
339
|
+
axisLabel: order.axisLabel,
|
|
330
340
|
...order.label !== null ? { label: order.label } : {},
|
|
331
341
|
...order.quantity !== null ? { quantity: order.quantity } : {},
|
|
332
|
-
...order.color !== null ? { color: order.color } : {}
|
|
342
|
+
...order.color !== null ? { color: order.color } : {},
|
|
343
|
+
...order.tooltip !== null ? { tooltip: order.tooltip } : {}
|
|
333
344
|
};
|
|
334
345
|
}
|
|
335
346
|
/** Orders drawn as draggable price lines on the main pane. */
|
|
@@ -388,19 +399,20 @@ var OrdersDomain = class {
|
|
|
388
399
|
for (const order of this.orders.values()) {
|
|
389
400
|
if (!order.visible) continue;
|
|
390
401
|
const name = order.label ?? (order.side === "buy" ? "BUY" : "SELL");
|
|
391
|
-
const emphasized = context.selection?.kind === "order" && context.selection.id === order.id
|
|
402
|
+
const emphasized = context.selection?.kind === "order" && context.selection.id === order.id;
|
|
392
403
|
views.push({
|
|
393
404
|
id: order.id,
|
|
394
405
|
y: pane.scale.valueToY(order.price),
|
|
395
406
|
color: order.color ?? (order.side === "buy" ? theme.buy : theme.sell),
|
|
396
407
|
text: order.quantity === null ? name : `${name} ${String(order.quantity)}`,
|
|
397
|
-
axisText: this.host.formatValue(pane, order.price),
|
|
408
|
+
axisText: order.axisLabel ? this.host.formatValue(pane, order.price) : null,
|
|
398
409
|
buttons: order.buttons,
|
|
399
410
|
lineStyle: order.lineStyle,
|
|
400
|
-
emphasized
|
|
411
|
+
emphasized,
|
|
412
|
+
align: order.labelAlign
|
|
401
413
|
});
|
|
402
414
|
}
|
|
403
|
-
return layoutPriceLines(views, pane.plot.width, pane.plot.height, font$1.size, (text, size) => context.measureText(text, font(size, font$1.family)));
|
|
415
|
+
return layoutPriceLines(views, pane.plot.width, pane.plot.height, font$1.size, (text, size) => context.measureText(text, font(size, font$1.family)), context.options.priceScale.pinLabels);
|
|
404
416
|
}
|
|
405
417
|
hitTest(context, point) {
|
|
406
418
|
const pane = paneOf(context.frame, MAIN_PANE_ID);
|
|
@@ -418,13 +430,22 @@ var OrdersDomain = class {
|
|
|
418
430
|
kind: "order",
|
|
419
431
|
id: order.id,
|
|
420
432
|
part: hit.part,
|
|
421
|
-
cursor: draggable ? "ns-resize" : "pointer",
|
|
422
|
-
draggable
|
|
433
|
+
cursor: draggable && hit.part === "line" ? "ns-resize" : "pointer",
|
|
434
|
+
draggable,
|
|
435
|
+
...order.tooltip === null || button ? {} : { tooltip: order.tooltip }
|
|
423
436
|
},
|
|
424
437
|
priority: hit.priority,
|
|
425
438
|
distance: hit.distance
|
|
426
439
|
};
|
|
427
440
|
}
|
|
441
|
+
reveal(_context, target) {
|
|
442
|
+
const order = this.orders.get(target.id);
|
|
443
|
+
return order ? {
|
|
444
|
+
pane: MAIN_PANE_ID,
|
|
445
|
+
scale: RIGHT_SCALE,
|
|
446
|
+
value: order.price
|
|
447
|
+
} : null;
|
|
448
|
+
}
|
|
428
449
|
beginDrag(context, target) {
|
|
429
450
|
const order = this.orders.get(target.id);
|
|
430
451
|
const pane = paneOf(context.frame, MAIN_PANE_ID);
|
package/dist/trading.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as MarkerShape } from "./shapes-BeKfp99c.js";
|
|
2
|
-
import { a as OrdersModule, c as Order, d as MarkerInput, f as MarkerPosition, i as OrdersEventMap, l as OrderInput, n as MarkersModule, o as markers, r as OrdersApi, s as orders, t as MarkersApi, u as Marker } from "./index-
|
|
2
|
+
import { a as OrdersModule, c as Order, d as MarkerInput, f as MarkerPosition, i as OrdersEventMap, l as OrderInput, n as MarkersModule, o as markers, r as OrdersApi, s as orders, t as MarkersApi, u as Marker } from "./index-D5fdjNJv.js";
|
|
3
3
|
export { type Marker, type MarkerInput, type MarkerPosition, type MarkerShape, type MarkersApi, type MarkersModule, type Order, type OrderInput, type OrdersApi, type OrdersEventMap, type OrdersModule, markers, orders };
|
package/dist/trading.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as markers, n as orders } from "./trading-
|
|
1
|
+
export { t as markers, n as orders } from "./trading-BY4NVox9.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { o as MAIN_PANE_ID } from "./color-
|
|
3
|
-
import { n as checkSeriesFields } from "./series-store-
|
|
1
|
+
import { c as checkOneOf, l as checkString, m as fail, n as checkBoolean, s as checkObject, t as checkArray } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { o as MAIN_PANE_ID } from "./color-AsBx5M66.js";
|
|
3
|
+
import { n as checkSeriesFields } from "./series-store-DwvvS42F.js";
|
|
4
4
|
//#region src/chart/api/series.ts
|
|
5
5
|
/** Checks a series type definition before it joins a chart. */
|
|
6
6
|
function validateSeriesDefinition(definition) {
|
|
@@ -7,12 +7,16 @@ const HitPriority = {
|
|
|
7
7
|
line: 20,
|
|
8
8
|
body: 10
|
|
9
9
|
};
|
|
10
|
-
/** x of a time in plot coordinates,
|
|
10
|
+
/** x of the center of the bar a time falls in, in plot coordinates, beyond the bars too. */
|
|
11
11
|
function timeToX(context, time) {
|
|
12
|
+
return context.timeScale.indexToX(context.bars.barIndexOf(time));
|
|
13
|
+
}
|
|
14
|
+
/** x of a time in plot coordinates, interpolated and extrapolated between bars. */
|
|
15
|
+
function exactTimeToX(context, time) {
|
|
12
16
|
return context.timeScale.indexToX(context.bars.logicalIndexOf(time));
|
|
13
17
|
}
|
|
14
18
|
function paneOf(frame, paneId) {
|
|
15
19
|
return frame.panes.find((pane) => pane.id === paneId);
|
|
16
20
|
}
|
|
17
21
|
//#endregion
|
|
18
|
-
export {
|
|
22
|
+
export { timeToX as i, exactTimeToX as n, paneOf as r, HitPriority as t };
|
|
@@ -57,5 +57,7 @@ const LINE_STYLES = [
|
|
|
57
57
|
"dashed",
|
|
58
58
|
"dotted"
|
|
59
59
|
];
|
|
60
|
+
/** Where a label of several lines on the price axis lies on its line (`priceScale.labelAnchor`). */
|
|
61
|
+
const LABEL_ANCHORS = ["middle", "firstLine"];
|
|
60
62
|
//#endregion
|
|
61
|
-
export {
|
|
63
|
+
export { isPlainObject as a, deepMerge as i, LINE_STYLES as n, sameData as o, deepFreeze as r, LABEL_ANCHORS as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as Point,
|
|
1
|
+
import { $ as Point, $t as Theme, In as TimeInput, Ut as LineStyle, bn as IntervalUnit, jn as PriceSource, kn as BarsView } from "./data-RRHroFqK.js";
|
|
2
2
|
//#region src/drawings/types.d.ts
|
|
3
3
|
interface DrawingPointInput {
|
|
4
4
|
time: TimeInput;
|
|
@@ -188,8 +188,13 @@ interface DrawingPaintContext<A extends readonly DrawingPoint[] = readonly Drawi
|
|
|
188
188
|
/** The text is being edited in place: paint everything but the text. */
|
|
189
189
|
readonly editing: boolean;
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Where a point hits a drawing: `line` on one of its lines, `body` on its content, as its text, the
|
|
193
|
+
* box of a label or a mark painted solid. A fill is the background of a drawing, never hit: a click
|
|
194
|
+
* there reaches what is under it, and a drawing is taken by its lines. Handles are hit-tested by the
|
|
195
|
+
* chart.
|
|
196
|
+
*/
|
|
191
197
|
interface DrawingHit {
|
|
192
|
-
/** `line` or `body`; handles are hit-tested by the chart. */
|
|
193
198
|
readonly part: 'line' | 'body';
|
|
194
199
|
readonly distance: number;
|
|
195
200
|
}
|
|
@@ -331,6 +336,13 @@ interface DrawingTypeDefinition<A extends readonly DrawingPoint[] = readonly Dra
|
|
|
331
336
|
* logarithmic scale or across gaps between bars too; `style` is the drawing's.
|
|
332
337
|
*/
|
|
333
338
|
moveHandle?(anchors: A, handle: string, to: DrawingPoint, space: DrawingSpace, style: DrawingStyle): readonly DrawingPoint[];
|
|
339
|
+
/**
|
|
340
|
+
* Where `Shift` constrains a dragged handle that is no anchor from: the point it keeps its
|
|
341
|
+
* direction to, such as the other end of the line it is the end of. `null` leaves the handle
|
|
342
|
+
* free, the default. Handles named after anchors are constrained against their neighbour anchor
|
|
343
|
+
* and are not asked.
|
|
344
|
+
*/
|
|
345
|
+
pivotOf?(anchors: A, handle: string, space: DrawingSpace, style: DrawingStyle): DrawingPoint | null;
|
|
334
346
|
/**
|
|
335
347
|
* Highlighted on the axes, as the drawing's `style` draws it. Default: every anchor's value and
|
|
336
348
|
* time while selected.
|
|
@@ -70,6 +70,9 @@ function checkFields(path, value, fields) {
|
|
|
70
70
|
function checkArray(path, value) {
|
|
71
71
|
if (!Array.isArray(value)) fail(`${path} must be an array, received ${describeValue(value)}.`);
|
|
72
72
|
}
|
|
73
|
+
function checkFunction(path, value) {
|
|
74
|
+
if (typeof value !== "function") fail(`${path} must be a function, received ${describeValue(value)}.`);
|
|
75
|
+
}
|
|
73
76
|
function checkFunctionOrNull(path, value) {
|
|
74
77
|
if (value !== null && typeof value !== "function") fail(`${path} must be a function or null, received ${describeValue(value)}.`);
|
|
75
78
|
}
|
|
@@ -84,4 +87,4 @@ function checkTimeZone(path, value) {
|
|
|
84
87
|
return zone;
|
|
85
88
|
}
|
|
86
89
|
//#endregion
|
|
87
|
-
export {
|
|
90
|
+
export { checkFunctionOrNull as a, checkOneOf as c, fieldsOf as d, ChartError as f, runEach as h, checkFunction as i, checkString as l, fail as m, checkBoolean as n, checkNumber as o, describeValue as p, checkFields as r, checkObject as s, checkArray as t, checkTimeZone as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as RIGHT_SCALE, d as includeValue, o as MAIN_PANE_ID } from "./color-
|
|
3
|
-
import {
|
|
1
|
+
import { m as fail, p as describeValue } from "./validate-B_z8rO0I.js";
|
|
2
|
+
import { c as RIGHT_SCALE, d as includeValue, o as MAIN_PANE_ID } from "./color-AsBx5M66.js";
|
|
3
|
+
import { i as deepMerge } from "./types-CgerhCJ3.js";
|
|
4
4
|
//#region src/series/types.ts
|
|
5
5
|
/** Reusable typed-array storage behind {@link SeriesPoints}. */
|
|
6
6
|
var PointBuffer = class {
|
|
@@ -188,14 +188,14 @@ var SeriesContributor = class {
|
|
|
188
188
|
const { bars: store, values, lastValueLabel } = this.entry;
|
|
189
189
|
const last = ((store ?? values)?.length ?? 0) - 1;
|
|
190
190
|
const value = store ? store.close(last) : values?.value(last) ?? NaN;
|
|
191
|
-
if (!lastValueLabel || !Number.isFinite(value)) return
|
|
191
|
+
if (!lastValueLabel || !Number.isFinite(value)) return [];
|
|
192
192
|
const { theme } = this.sources.options;
|
|
193
193
|
const style = styleFor(this.entry, this.entry.definition, this.sources, this.color, this.entry.style);
|
|
194
194
|
const up = !store || value >= store.open(last);
|
|
195
|
-
return {
|
|
195
|
+
return [{
|
|
196
196
|
value: this.placed(value),
|
|
197
197
|
color: style.color ?? (up ? style.upColor ?? theme.up : style.downColor ?? theme.down)
|
|
198
|
-
};
|
|
198
|
+
}];
|
|
199
199
|
}
|
|
200
200
|
emit(scale, jobs) {
|
|
201
201
|
const { from, to } = this.window();
|