@tradecanvas/chart 1.0.0 → 1.0.2
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/README.md +10 -1
- package/dist/Chart.d.ts +10 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{DragDropImporter-C4x09P7e.js → DragDropImporter-Bxfcj-ND.js} +126 -99
- package/dist/DragDropImporter-Bxfcj-ND.js.map +1 -0
- package/dist/DragDropImporter-Gh27ctnE.cjs +2 -0
- package/dist/DragDropImporter-Gh27ctnE.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/index.cjs +1 -1
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/DragDropImporter-C4x09P7e.js.map +0 -1
- package/dist/DragDropImporter-DeXlngof.cjs +0 -2
- package/dist/DragDropImporter-DeXlngof.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, computePriceLimits as s, mergeBar as c, setLocale as l, timeframeToMs as u } from "@tradecanvas/commons";
|
|
2
|
-
import { AlertDragHandler as d, AlertManager as f, Animator as p, AreaRenderer as m, AxisDragHandler as
|
|
2
|
+
import { AlertDragHandler as d, AlertManager as f, Animator as p, AreaRenderer as m, AxisDragHandler as h, BarCountdown as ee, BarRenderer as te, BaselineRenderer as ne, CandlestickRenderer as g, ChartLegend as re, ChartStateManager as _, CompareRenderer as ie, CrosshairHandler as ae, CrosshairTooltip as oe, CurrentPriceLine as se, DataExporter as v, DepthHeatmapRenderer as ce, DrawingManager as le, DrawingRenderer as ue, EquivolumeRenderer as de, EventBus as fe, GridRenderer as pe, HLCAreaRenderer as me, HollowCandleRenderer as he, IndicatorEngine as y, InteractionManager as ge, KagiRenderer as _e, KeyboardHandler as ve, LineRenderer as ye, LineWithMarkersRenderer as be, MarketProfileRenderer as xe, MeasureOverlay as Se, PanHandler as Ce, PaneResizeHandler as we, PeriodLevelsRenderer as Te, PinnedTooltip as Ee, PivotMarkersRenderer as De, PointAndFigureRenderer as Oe, PriceAxis as ke, RenderEngine as Ae, RenkoRenderer as b, ReplayManager as x, Screenshot as S, SessionBreaks as C, SessionShading as je, SignalMarkerManager as Me, StepLineRenderer as Ne, StreamManager as Pe, TimeAxis as Fe, TradeZoneManager as Ie, TradingManager as Le, TradingRenderer as Re, UndoRedoManager as ze, Viewport as Be, VolumeCandleRenderer as Ve, VolumeProfileRenderer as He, VolumeRenderer as Ue, Watermark as We, ZoomHandler as Ge, findDominantSwing as Ke, registerBuiltInDrawingTools as qe, registerBuiltInIndicators as w, toHeikinAshi as Je, toKagi as Ye, toLineBreak as Xe, toPointAndFigure as Ze, toRangeBars as Qe, toRenko as $e, xToBarIndex as et } from "@tradecanvas/core";
|
|
3
3
|
//#region src/charts/ChartTypeStrategy.ts
|
|
4
|
-
function
|
|
4
|
+
function tt(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case "candlestick":
|
|
7
7
|
case "heikinAshi":
|
|
@@ -9,7 +9,7 @@ function et(e) {
|
|
|
9
9
|
case "rangeBars": return new g();
|
|
10
10
|
case "line": return new ye();
|
|
11
11
|
case "area": return new m();
|
|
12
|
-
case "bar": return new
|
|
12
|
+
case "bar": return new te();
|
|
13
13
|
case "hollowCandle": return new he();
|
|
14
14
|
case "baseline": return new ne();
|
|
15
15
|
case "renko": return new b();
|
|
@@ -23,44 +23,44 @@ function et(e) {
|
|
|
23
23
|
default: return new g();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function nt(e, t) {
|
|
27
27
|
if (t.length === 0) return t;
|
|
28
28
|
switch (e) {
|
|
29
29
|
case "heikinAshi": return Je(t);
|
|
30
|
-
case "renko": return
|
|
30
|
+
case "renko": return $e(t, {
|
|
31
31
|
brickSize: 0,
|
|
32
32
|
useATR: !0,
|
|
33
33
|
atrPeriod: 14
|
|
34
34
|
});
|
|
35
35
|
case "lineBreak": return Xe(t, 3);
|
|
36
36
|
case "kagi": return Ye(t, 4);
|
|
37
|
-
case "pointAndFigure": return Ze(t,
|
|
38
|
-
case "rangeBars": return Qe(t, { rangeSize:
|
|
37
|
+
case "pointAndFigure": return Ze(t, T(t) * .01, 3);
|
|
38
|
+
case "rangeBars": return Qe(t, { rangeSize: T(t) * .005 });
|
|
39
39
|
default: return t;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function T(e) {
|
|
43
43
|
let t = 0;
|
|
44
44
|
for (let n of e) t += n.close;
|
|
45
45
|
return t / e.length;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function rt(e, t) {
|
|
48
48
|
let n = t?.(e);
|
|
49
|
-
return n ? n.createRenderer() :
|
|
49
|
+
return n ? n.createRenderer() : tt(e);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function it(e, t, n) {
|
|
52
52
|
if (t.length === 0) return t;
|
|
53
53
|
let r = n?.(e);
|
|
54
|
-
return r?.transform ? r.transform(t) :
|
|
54
|
+
return r?.transform ? r.transform(t) : nt(e, t);
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/charts/IndicatorPriceRange.ts
|
|
58
|
-
var
|
|
58
|
+
var E = {
|
|
59
59
|
min: 0,
|
|
60
60
|
max: 100
|
|
61
|
-
},
|
|
62
|
-
function
|
|
63
|
-
if (!e) return { ...
|
|
61
|
+
}, D = .1;
|
|
62
|
+
function at(e, t, n) {
|
|
63
|
+
if (!e) return { ...E };
|
|
64
64
|
let r = Infinity, i = -Infinity, a = 0;
|
|
65
65
|
for (let [, o] of e.values) {
|
|
66
66
|
if (a >= t && a <= n) for (let e in o) {
|
|
@@ -69,16 +69,16 @@ function it(e, t, n) {
|
|
|
69
69
|
}
|
|
70
70
|
a++;
|
|
71
71
|
}
|
|
72
|
-
if (r === Infinity) return { ...
|
|
72
|
+
if (r === Infinity) return { ...E };
|
|
73
73
|
let o = i - r || 1;
|
|
74
74
|
return {
|
|
75
|
-
min: r - o *
|
|
76
|
-
max: i + o *
|
|
75
|
+
min: r - o * D,
|
|
76
|
+
max: i + o * D
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
//#endregion
|
|
80
80
|
//#region src/state/AutoSaveScheduler.ts
|
|
81
|
-
var
|
|
81
|
+
var ot = class {
|
|
82
82
|
timer = null;
|
|
83
83
|
delayMs = 0;
|
|
84
84
|
key = null;
|
|
@@ -108,12 +108,12 @@ var at = class {
|
|
|
108
108
|
};
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/DataManager.ts
|
|
111
|
-
function
|
|
111
|
+
function O(e) {
|
|
112
112
|
if (!e || typeof e.time != "number") return !1;
|
|
113
113
|
let { open: t, high: n, low: r, close: i } = e;
|
|
114
114
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function k(e) {
|
|
117
117
|
return {
|
|
118
118
|
...e,
|
|
119
119
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -121,20 +121,20 @@ function A(e) {
|
|
|
121
121
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
var
|
|
124
|
+
var A = class {
|
|
125
125
|
data = [];
|
|
126
126
|
getData() {
|
|
127
127
|
return this.data;
|
|
128
128
|
}
|
|
129
129
|
setData(e) {
|
|
130
|
-
this.data = e.filter(
|
|
130
|
+
this.data = e.filter(O).map(k);
|
|
131
131
|
}
|
|
132
132
|
appendBar(e) {
|
|
133
|
-
|
|
133
|
+
O(e) && this.data.push(k(e));
|
|
134
134
|
}
|
|
135
135
|
updateLastBar(e) {
|
|
136
|
-
if (!
|
|
137
|
-
let t =
|
|
136
|
+
if (!O(e)) return;
|
|
137
|
+
let t = k(e);
|
|
138
138
|
if (this.data.length === 0) {
|
|
139
139
|
this.data.push(t);
|
|
140
140
|
return;
|
|
@@ -150,7 +150,7 @@ var j = class {
|
|
|
150
150
|
clear() {
|
|
151
151
|
this.data = [];
|
|
152
152
|
}
|
|
153
|
-
},
|
|
153
|
+
}, j = class {
|
|
154
154
|
theme;
|
|
155
155
|
constructor(t) {
|
|
156
156
|
!t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
@@ -161,7 +161,7 @@ var j = class {
|
|
|
161
161
|
setTheme(t) {
|
|
162
162
|
t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
|
|
163
163
|
}
|
|
164
|
-
},
|
|
164
|
+
}, M = 200, N = 80, P = class {
|
|
165
165
|
panels = [];
|
|
166
166
|
containerWidth = 0;
|
|
167
167
|
containerHeight = 0;
|
|
@@ -173,8 +173,8 @@ var j = class {
|
|
|
173
173
|
this.panels.push({
|
|
174
174
|
id: e,
|
|
175
175
|
position: n,
|
|
176
|
-
size: r ?? (a ?
|
|
177
|
-
minSize: a ?
|
|
176
|
+
size: r ?? (a ? M : t),
|
|
177
|
+
minSize: a ? N : i,
|
|
178
178
|
content: {
|
|
179
179
|
type: "indicator",
|
|
180
180
|
indicatorInstanceId: e
|
|
@@ -188,7 +188,7 @@ var j = class {
|
|
|
188
188
|
let r = this.panels.find((t) => t.id === e);
|
|
189
189
|
if (r) {
|
|
190
190
|
let e = r.position === "left" || r.position === "right", a = n === "left" || n === "right";
|
|
191
|
-
r.position = n, e !== a && (r.size = a ?
|
|
191
|
+
r.position = n, e !== a && (r.size = a ? M : t, r.minSize = a ? N : i);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
setPanelSize(e, t) {
|
|
@@ -289,11 +289,11 @@ var j = class {
|
|
|
289
289
|
getMainChartRect() {
|
|
290
290
|
return this.resolve().mainChartRect;
|
|
291
291
|
}
|
|
292
|
-
},
|
|
293
|
-
function
|
|
292
|
+
}, st = 1;
|
|
293
|
+
function F(e, t) {
|
|
294
294
|
return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function I(e) {
|
|
297
297
|
switch (e.kind) {
|
|
298
298
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
299
299
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -303,25 +303,25 @@ function L(e) {
|
|
|
303
303
|
}
|
|
304
304
|
//#endregion
|
|
305
305
|
//#region src/plugins/registry.ts
|
|
306
|
-
var
|
|
307
|
-
function st(e) {
|
|
308
|
-
R.set(L(e), e);
|
|
309
|
-
}
|
|
306
|
+
var L = /* @__PURE__ */ new Map();
|
|
310
307
|
function ct(e) {
|
|
311
|
-
|
|
308
|
+
L.set(I(e), e);
|
|
309
|
+
}
|
|
310
|
+
function lt(e) {
|
|
311
|
+
return L.delete(e);
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
return [...
|
|
313
|
+
function R() {
|
|
314
|
+
return [...L.values()];
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
316
|
+
function ut() {
|
|
317
|
+
L.clear();
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/plugins/PluginManager.ts
|
|
321
|
-
var
|
|
321
|
+
var z = class {
|
|
322
322
|
plugins = /* @__PURE__ */ new Map();
|
|
323
323
|
constructor(e, t = {}) {
|
|
324
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
324
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of R()) this.add(e);
|
|
325
325
|
for (let e of t.plugins ?? []) this.add(e);
|
|
326
326
|
}
|
|
327
327
|
register(e) {
|
|
@@ -349,20 +349,20 @@ var B = class {
|
|
|
349
349
|
return e;
|
|
350
350
|
}
|
|
351
351
|
add(e) {
|
|
352
|
-
this.plugins.set(
|
|
352
|
+
this.plugins.set(I(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
353
353
|
}
|
|
354
|
-
},
|
|
354
|
+
}, B = {
|
|
355
355
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
356
356
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
357
357
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
358
358
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
359
359
|
positionClose: (e, t) => e.closePosition(t)
|
|
360
360
|
};
|
|
361
|
-
function
|
|
361
|
+
function dt(e, t) {
|
|
362
362
|
let n = [], r = (e) => t.setOrders(e.data ?? []), i = (e) => t.setPositions(e.data ?? []), a = (e) => t.onError(e.data ?? { message: "Execution error" });
|
|
363
363
|
e.on("orders", r), e.on("positions", i), e.on("error", a), n.push(() => e.off("orders", r), () => e.off("positions", i), () => e.off("error", a));
|
|
364
|
-
for (let r of Object.keys(
|
|
365
|
-
let i =
|
|
364
|
+
for (let r of Object.keys(B)) {
|
|
365
|
+
let i = B[r], a = t.onIntent(r, (n) => {
|
|
366
366
|
Promise.resolve(i(e, n)).catch((e) => t.onError({
|
|
367
367
|
message: `Execution command failed: ${r}`,
|
|
368
368
|
cause: e
|
|
@@ -376,8 +376,8 @@ function ut(e, t) {
|
|
|
376
376
|
}
|
|
377
377
|
//#endregion
|
|
378
378
|
//#region src/Chart.ts
|
|
379
|
-
var
|
|
380
|
-
static version = "1.0.
|
|
379
|
+
var ft = 6, pt = class {
|
|
380
|
+
static version = "1.0.2";
|
|
381
381
|
engine;
|
|
382
382
|
viewport;
|
|
383
383
|
dataManager;
|
|
@@ -400,6 +400,9 @@ var dt = class {
|
|
|
400
400
|
renderScheduled = !1;
|
|
401
401
|
containerSizeCache = null;
|
|
402
402
|
containerSizeCacheTime = 0;
|
|
403
|
+
lastEmittedRange = null;
|
|
404
|
+
lastEmittedPriceRange = null;
|
|
405
|
+
lastEmittedBarWidth = null;
|
|
403
406
|
chartLegend;
|
|
404
407
|
watermark;
|
|
405
408
|
barCountdown;
|
|
@@ -419,7 +422,7 @@ var dt = class {
|
|
|
419
422
|
measureOverlay;
|
|
420
423
|
replayManager;
|
|
421
424
|
undoRedoManager;
|
|
422
|
-
autoSaveScheduler = new
|
|
425
|
+
autoSaveScheduler = new ot((e) => this.saveState(e));
|
|
423
426
|
animator;
|
|
424
427
|
crosshairTooltip;
|
|
425
428
|
pinnedTooltip;
|
|
@@ -471,7 +474,7 @@ var dt = class {
|
|
|
471
474
|
logScale: n.logScale ?? !0,
|
|
472
475
|
timeframes: n.timeframes ?? [],
|
|
473
476
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
474
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new
|
|
477
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new A(), this.themeManager = new j(t.theme), this.layoutManager = new P(), this.indicatorEngine = new y(), this.pluginManager = new z(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new fe(), w(this.indicatorEngine), this.drawingManager = new le(), qe(this.drawingManager), this.drawingRenderer = new ue(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
475
478
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
476
479
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
477
480
|
this.eventBus.emit(e, t);
|
|
@@ -495,7 +498,7 @@ var dt = class {
|
|
|
495
498
|
barIndex: e
|
|
496
499
|
});
|
|
497
500
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
|
|
498
|
-
}), this.chartLegend = new re(), this.chartLegend.setChartType(t.chartType), this.watermark = new We(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ue(), this.volumeProfile = new He(), this.marketProfile = new xe(), this.depthHeatmap = new ce(), this.periodLevels = new Te(), this.pivotMarkers = new De(), this.barCountdown = new
|
|
501
|
+
}), this.chartLegend = new re(), this.chartLegend.setChartType(t.chartType), this.watermark = new We(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ue(), this.volumeProfile = new He(), this.marketProfile = new xe(), this.depthHeatmap = new ce(), this.periodLevels = new Te(), this.pivotMarkers = new De(), this.barCountdown = new ee(), this.sessionBreaks = new C(), this.sessionShading = new je(), this.compareRenderer = new ie(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
499
502
|
visible: t.sessionBreaks.visible ?? !0,
|
|
500
503
|
color: t.sessionBreaks.color,
|
|
501
504
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
@@ -567,14 +570,20 @@ var dt = class {
|
|
|
567
570
|
});
|
|
568
571
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
569
572
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
570
|
-
}), this.replayManager = new x(), this.measureOverlay = new Se(), this.interactionManager = new ge(e), this.features.panning
|
|
571
|
-
|
|
572
|
-
|
|
573
|
+
}), this.replayManager = new x(), this.measureOverlay = new Se(), this.interactionManager = new ge(e), this.features.panning) {
|
|
574
|
+
let e = 0;
|
|
575
|
+
this.interactionManager.setPanHandler(new Ce((t, n) => {
|
|
576
|
+
t && this.viewport.scrollBy(t), n && (e += n, (this.options.autoScale === !1 || Math.abs(e) > ft) && (this.options.autoScale = !1, this.viewport.panPriceRange(n))), this.updateViewportAndRender();
|
|
577
|
+
}, () => {
|
|
578
|
+
e = 0;
|
|
579
|
+
}));
|
|
580
|
+
}
|
|
581
|
+
if (this.features.zooming) {
|
|
573
582
|
this.interactionManager.setZoomHandler(new Ge((e, t) => {
|
|
574
583
|
this.viewport.zoom(e, t), this.updateViewportAndRender();
|
|
575
584
|
}));
|
|
576
|
-
let e = new
|
|
577
|
-
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender();
|
|
585
|
+
let e = new h((e) => {
|
|
586
|
+
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
578
587
|
}, (e) => {
|
|
579
588
|
let t = this.viewport.getState().chartRect.width;
|
|
580
589
|
this.viewport.zoom(1 / e - 1, t / 2), this.updateViewportAndRender();
|
|
@@ -605,7 +614,7 @@ var dt = class {
|
|
|
605
614
|
x: e.x,
|
|
606
615
|
y: e.y
|
|
607
616
|
}), t.length === 0) return;
|
|
608
|
-
let n =
|
|
617
|
+
let n = et(e.x, this.viewport.getState());
|
|
609
618
|
n < 0 || n >= t.length || this.eventBus.emit("barClick", {
|
|
610
619
|
bar: t[n],
|
|
611
620
|
barIndex: n,
|
|
@@ -914,7 +923,7 @@ var dt = class {
|
|
|
914
923
|
}
|
|
915
924
|
connectExecution(e, t = {}) {
|
|
916
925
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
917
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
926
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = dt(e, {
|
|
918
927
|
onIntent: (e, t) => {
|
|
919
928
|
let n = (e) => t(e.payload);
|
|
920
929
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -1351,13 +1360,13 @@ var dt = class {
|
|
|
1351
1360
|
this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
1352
1361
|
}
|
|
1353
1362
|
createChartRenderer(e) {
|
|
1354
|
-
return
|
|
1363
|
+
return rt(e, (e) => this.pluginManager.getChartType(e));
|
|
1355
1364
|
}
|
|
1356
1365
|
getDisplayData() {
|
|
1357
1366
|
if (this.displayDataCache) return this.displayDataCache;
|
|
1358
1367
|
let e = this.dataManager.getData();
|
|
1359
1368
|
if (e.length === 0) return e;
|
|
1360
|
-
let t =
|
|
1369
|
+
let t = it(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
|
|
1361
1370
|
return this.displayDataCache = t, t;
|
|
1362
1371
|
}
|
|
1363
1372
|
scheduleRender() {
|
|
@@ -1386,7 +1395,25 @@ var dt = class {
|
|
|
1386
1395
|
}
|
|
1387
1396
|
}
|
|
1388
1397
|
}
|
|
1389
|
-
e && this.viewport.scrollToEnd(), this.syncRenderContext(), this.engine.requestRender();
|
|
1398
|
+
e && this.viewport.scrollToEnd(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1399
|
+
}
|
|
1400
|
+
emitViewportEvents() {
|
|
1401
|
+
let e = this.viewport.getState(), t = Math.max(0, Math.floor(e.visibleRange.from)), n = Math.max(t, Math.ceil(e.visibleRange.to));
|
|
1402
|
+
(!this.lastEmittedRange || this.lastEmittedRange.from !== t || this.lastEmittedRange.to !== n) && (this.lastEmittedRange = {
|
|
1403
|
+
from: t,
|
|
1404
|
+
to: n
|
|
1405
|
+
}, this.eventBus.emit("visibleRangeChange", {
|
|
1406
|
+
from: t,
|
|
1407
|
+
to: n
|
|
1408
|
+
}));
|
|
1409
|
+
let { min: r, max: i } = e.priceRange;
|
|
1410
|
+
(!this.lastEmittedPriceRange || this.lastEmittedPriceRange.min !== r || this.lastEmittedPriceRange.max !== i) && (this.lastEmittedPriceRange = {
|
|
1411
|
+
min: r,
|
|
1412
|
+
max: i
|
|
1413
|
+
}, this.eventBus.emit("priceRangeChange", {
|
|
1414
|
+
min: r,
|
|
1415
|
+
max: i
|
|
1416
|
+
})), this.lastEmittedBarWidth !== e.barWidth && (this.lastEmittedBarWidth = e.barWidth, this.eventBus.emit("zoomChange", { barWidth: e.barWidth }));
|
|
1390
1417
|
}
|
|
1391
1418
|
getResolvedLayout() {
|
|
1392
1419
|
return this.resolvedLayoutCache ||= this.layoutManager.resolve(), this.resolvedLayoutCache;
|
|
@@ -1398,7 +1425,7 @@ var dt = class {
|
|
|
1398
1425
|
buildPanelRenderInfos() {
|
|
1399
1426
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
1400
1427
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
1401
|
-
let i =
|
|
1428
|
+
let i = at(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
|
|
1402
1429
|
x: e.rect.x,
|
|
1403
1430
|
y: e.rect.y + 20,
|
|
1404
1431
|
width: e.rect.width,
|
|
@@ -1459,7 +1486,7 @@ var dt = class {
|
|
|
1459
1486
|
});
|
|
1460
1487
|
}
|
|
1461
1488
|
drawOverlayPlugins(e, t) {
|
|
1462
|
-
let n =
|
|
1489
|
+
let n = F(this.pluginManager.getOverlays(), t);
|
|
1463
1490
|
if (n.length === 0) return;
|
|
1464
1491
|
let r = {
|
|
1465
1492
|
viewport: this.viewport.getState(),
|
|
@@ -1480,26 +1507,26 @@ var dt = class {
|
|
|
1480
1507
|
} : void 0
|
|
1481
1508
|
} : null;
|
|
1482
1509
|
}
|
|
1483
|
-
},
|
|
1510
|
+
}, V = [
|
|
1484
1511
|
"time",
|
|
1485
1512
|
"timestamp",
|
|
1486
1513
|
"date",
|
|
1487
1514
|
"datetime",
|
|
1488
1515
|
"t"
|
|
1489
|
-
],
|
|
1516
|
+
], H = ["open", "o"], U = ["high", "h"], W = ["low", "l"], G = ["close", "c"], K = [
|
|
1490
1517
|
"volume",
|
|
1491
1518
|
"vol",
|
|
1492
1519
|
"v"
|
|
1493
1520
|
];
|
|
1494
|
-
function
|
|
1521
|
+
function q(e) {
|
|
1495
1522
|
let t = e.trim();
|
|
1496
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
1523
|
+
return t ? t[0] === "[" || t[0] === "{" ? mt(t) : ht(t) : {
|
|
1497
1524
|
data: [],
|
|
1498
1525
|
rowCount: 0,
|
|
1499
1526
|
skipped: 0
|
|
1500
1527
|
};
|
|
1501
1528
|
}
|
|
1502
|
-
function
|
|
1529
|
+
function mt(e) {
|
|
1503
1530
|
let t;
|
|
1504
1531
|
try {
|
|
1505
1532
|
t = JSON.parse(e);
|
|
@@ -1509,19 +1536,19 @@ function ft(e) {
|
|
|
1509
1536
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
1510
1537
|
let n = [], r = 0;
|
|
1511
1538
|
for (let e of t) {
|
|
1512
|
-
let t = Array.isArray(e) ?
|
|
1539
|
+
let t = Array.isArray(e) ? yt(e) : vt(e);
|
|
1513
1540
|
t ? n.push(t) : r++;
|
|
1514
1541
|
}
|
|
1515
|
-
return
|
|
1542
|
+
return Z(n, t.length, r);
|
|
1516
1543
|
}
|
|
1517
|
-
function
|
|
1544
|
+
function ht(e) {
|
|
1518
1545
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
1519
1546
|
if (t.length === 0) return {
|
|
1520
1547
|
data: [],
|
|
1521
1548
|
rowCount: 0,
|
|
1522
1549
|
skipped: 0
|
|
1523
1550
|
};
|
|
1524
|
-
let n =
|
|
1551
|
+
let n = gt(t[0]), r = J(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? _t(r) : {
|
|
1525
1552
|
time: 0,
|
|
1526
1553
|
open: 1,
|
|
1527
1554
|
high: 2,
|
|
@@ -1532,7 +1559,7 @@ function pt(e) {
|
|
|
1532
1559
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
1533
1560
|
let o = [], s = 0;
|
|
1534
1561
|
for (let e = +!!i; e < t.length; e++) {
|
|
1535
|
-
let r =
|
|
1562
|
+
let r = J(t[e], n), i = X(r[a.time]), c = Y(r[a.open]), l = Y(r[a.high]), u = Y(r[a.low]), d = Y(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
1536
1563
|
if (i === null || ![
|
|
1537
1564
|
c,
|
|
1538
1565
|
l,
|
|
@@ -1551,9 +1578,9 @@ function pt(e) {
|
|
|
1551
1578
|
volume: Number.isFinite(f) ? f : 0
|
|
1552
1579
|
});
|
|
1553
1580
|
}
|
|
1554
|
-
return
|
|
1581
|
+
return Z(o, t.length - +!!i, s);
|
|
1555
1582
|
}
|
|
1556
|
-
function
|
|
1583
|
+
function gt(e) {
|
|
1557
1584
|
let t = {
|
|
1558
1585
|
",": 0,
|
|
1559
1586
|
";": 0,
|
|
@@ -1565,7 +1592,7 @@ function mt(e) {
|
|
|
1565
1592
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
1566
1593
|
return n;
|
|
1567
1594
|
}
|
|
1568
|
-
function
|
|
1595
|
+
function J(e, t) {
|
|
1569
1596
|
let n = [], r = "", i = !1;
|
|
1570
1597
|
for (let a = 0; a < e.length; a++) {
|
|
1571
1598
|
let o = e[a];
|
|
@@ -1573,25 +1600,25 @@ function Y(e, t) {
|
|
|
1573
1600
|
}
|
|
1574
1601
|
return n.push(r), n;
|
|
1575
1602
|
}
|
|
1576
|
-
function
|
|
1603
|
+
function _t(e) {
|
|
1577
1604
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
1578
1605
|
return {
|
|
1579
|
-
time: t(
|
|
1580
|
-
open: t(
|
|
1581
|
-
high: t(
|
|
1582
|
-
low: t(
|
|
1583
|
-
close: t(
|
|
1584
|
-
volume: t(
|
|
1606
|
+
time: t(V),
|
|
1607
|
+
open: t(H),
|
|
1608
|
+
high: t(U),
|
|
1609
|
+
low: t(W),
|
|
1610
|
+
close: t(G),
|
|
1611
|
+
volume: t(K)
|
|
1585
1612
|
};
|
|
1586
1613
|
}
|
|
1587
|
-
function
|
|
1614
|
+
function vt(e) {
|
|
1588
1615
|
let t = (t) => {
|
|
1589
1616
|
for (let n of t) {
|
|
1590
1617
|
if (e[n] !== void 0) return e[n];
|
|
1591
1618
|
let t = n.toUpperCase();
|
|
1592
1619
|
if (e[t] !== void 0) return e[t];
|
|
1593
1620
|
}
|
|
1594
|
-
}, n =
|
|
1621
|
+
}, n = X(String(t(V) ?? "")), r = Number(t(H)), i = Number(t(U)), a = Number(t(W)), o = Number(t(G)), s = Number(t(K) ?? 0);
|
|
1595
1622
|
return n === null || ![
|
|
1596
1623
|
r,
|
|
1597
1624
|
i,
|
|
@@ -1606,9 +1633,9 @@ function gt(e) {
|
|
|
1606
1633
|
volume: Number.isFinite(s) ? s : 0
|
|
1607
1634
|
};
|
|
1608
1635
|
}
|
|
1609
|
-
function
|
|
1636
|
+
function yt(e) {
|
|
1610
1637
|
if (e.length < 5) return null;
|
|
1611
|
-
let t =
|
|
1638
|
+
let t = X(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
1612
1639
|
return t === null || ![
|
|
1613
1640
|
n,
|
|
1614
1641
|
r,
|
|
@@ -1623,10 +1650,10 @@ function _t(e) {
|
|
|
1623
1650
|
volume: Number.isFinite(o) ? o : 0
|
|
1624
1651
|
};
|
|
1625
1652
|
}
|
|
1626
|
-
function
|
|
1653
|
+
function Y(e) {
|
|
1627
1654
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
1628
1655
|
}
|
|
1629
|
-
function
|
|
1656
|
+
function X(e) {
|
|
1630
1657
|
let t = e.trim();
|
|
1631
1658
|
if (!t) return null;
|
|
1632
1659
|
let n = Number(t);
|
|
@@ -1634,7 +1661,7 @@ function Z(e) {
|
|
|
1634
1661
|
let r = Date.parse(t);
|
|
1635
1662
|
return Number.isFinite(r) ? r : null;
|
|
1636
1663
|
}
|
|
1637
|
-
function
|
|
1664
|
+
function Z(e, t, n) {
|
|
1638
1665
|
e.sort((e, t) => e.time - t.time);
|
|
1639
1666
|
let r = [];
|
|
1640
1667
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -1646,7 +1673,7 @@ function Q(e, t, n) {
|
|
|
1646
1673
|
}
|
|
1647
1674
|
//#endregion
|
|
1648
1675
|
//#region src/io/DragDropImporter.ts
|
|
1649
|
-
var
|
|
1676
|
+
var Q = class {
|
|
1650
1677
|
host;
|
|
1651
1678
|
overlay = null;
|
|
1652
1679
|
callbacks;
|
|
@@ -1679,7 +1706,7 @@ var vt = class {
|
|
|
1679
1706
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
1680
1707
|
let t = e.dataTransfer?.files?.[0];
|
|
1681
1708
|
if (t) try {
|
|
1682
|
-
let e =
|
|
1709
|
+
let e = q(await t.text());
|
|
1683
1710
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
1684
1711
|
this.callbacks.onData(e.data, e, t);
|
|
1685
1712
|
} catch (e) {
|
|
@@ -1714,6 +1741,6 @@ function $(e) {
|
|
|
1714
1741
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
1715
1742
|
}
|
|
1716
1743
|
//#endregion
|
|
1717
|
-
export {
|
|
1744
|
+
export { ut as a, lt as c, I as d, P as f, z as i, st as l, A as m, q as n, R as o, j as p, pt as r, ct as s, Q as t, F as u };
|
|
1718
1745
|
|
|
1719
|
-
//# sourceMappingURL=DragDropImporter-
|
|
1746
|
+
//# sourceMappingURL=DragDropImporter-Bxfcj-ND.js.map
|