@tradecanvas/chart 1.20.0 → 1.22.0
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 +2 -2
- package/dist/{LayoutSession-DepARyHT.js → LayoutSession-C6Romi6A.js} +2 -2
- package/dist/{LayoutSession-DepARyHT.js.map → LayoutSession-C6Romi6A.js.map} +1 -1
- package/dist/{LayoutSession-6FNgfBby.cjs → LayoutSession-D1ggDd0I.cjs} +2 -2
- package/dist/{LayoutSession-6FNgfBby.cjs.map → LayoutSession-D1ggDd0I.cjs.map} +1 -1
- package/dist/finance/BarChart.d.ts +21 -0
- package/dist/finance/BarChart.d.ts.map +1 -0
- package/dist/finance/CalendarChart.d.ts +17 -0
- package/dist/finance/CalendarChart.d.ts.map +1 -0
- package/dist/finance/CounterClockChart.d.ts +23 -0
- package/dist/finance/CounterClockChart.d.ts.map +1 -0
- package/dist/finance/DonutChart.d.ts +17 -0
- package/dist/finance/DonutChart.d.ts.map +1 -0
- package/dist/finance/HeatmapChart.d.ts +3 -0
- package/dist/finance/HeatmapChart.d.ts.map +1 -1
- package/dist/finance/HistogramChart.d.ts +17 -0
- package/dist/finance/HistogramChart.d.ts.map +1 -0
- package/dist/finance/InteractiveChart.d.ts +40 -0
- package/dist/finance/InteractiveChart.d.ts.map +1 -0
- package/dist/finance/MatrixChart.d.ts +18 -0
- package/dist/finance/MatrixChart.d.ts.map +1 -0
- package/dist/finance/ScatterChart.d.ts +17 -0
- package/dist/finance/ScatterChart.d.ts.map +1 -0
- package/dist/finance/index.d.ts +7 -0
- package/dist/finance/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +277 -53
- package/dist/index.js.map +1 -1
- package/dist/widget/index.cjs +1 -1
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +111 -1
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as ee, n as te, o as ne, p as re, r as ie, s as ae, t as oe, u as se, v as ce, x as le, y as ue } from "./LayoutSession-
|
|
2
|
-
import { CHART_STYLE_KEYS as de, DARK_TERMINAL as fe, DARK_THEME as pe, DARK_THEME as me, DEFAULT_DRAWING_STYLE as he, DEFAULT_RECONNECT as
|
|
3
|
-
import { AlertManager as
|
|
1
|
+
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as ee, n as te, o as ne, p as re, r as ie, s as ae, t as oe, u as se, v as ce, x as le, y as ue } from "./LayoutSession-C6Romi6A.js";
|
|
2
|
+
import { CHART_STYLE_KEYS as de, DARK_TERMINAL as fe, DARK_THEME as pe, DARK_THEME as me, DEFAULT_DRAWING_STYLE as he, DEFAULT_RECONNECT as ge, DEFAULT_SIGNAL_STYLE as _e, DEFAULT_STREAM_CONFIG as ve, DEFAULT_TIMEFRAME_FAVORITES as ye, DEFAULT_TRADE_ZONE_STYLE as be, DEFAULT_TRADING_CONFIG as xe, HNX_SESSIONS as Se, HOSE_SESSIONS as Ce, LIGHT_THEME as d, LIGHT_THEME as f, MARKET_CRYPTO as p, MARKET_HNX as m, MARKET_HOSE as h, MARKET_HOSE_ETF as g, MARKET_NYSE as _, MARKET_UPCOM as v, MARKET_VN30F as y, PRICE_SOURCES as b, TC_PALETTE as x, TC_SERIES_COLORS as S, TIMEFRAMES_CRYPTO as C, TIMEFRAMES_FOREX as w, TIMEFRAMES_STOCK as T, UPCOM_SESSIONS as E, VN30F_SESSIONS as D, VN_COLORS as O, VOLUME_ALPHA as k, barsAreDaily as A, computePriceLimits as we, createVNTheme as Te, formatFraction as Ee, formatNumber as De, formatVND as Oe, formatVolumeLoc as ke, fractionTick as Ae, getCurrentSession as je, getLocale as Me, indicatorSource as Ne, isPriceSource as Pe, isTimeFrame as Fe, isValidTimeZone as Ie, marketStatus as Le, normalizeBar as Re, normalizeBarTime as ze, offsetAt as Be, parseIndicatorSource as Ve, parseTimeframe as He, pickBaseTimeframe as Ue, priceFormatterFor as We, priceStepAt as Ge, rankSymbols as Ke, readNews as qe, readQuote as Je, registerLocale as Ye, resampleBars as Xe, roundToPriceStep as Ze, scaleMarketPrices as Qe, setLocale as $e, sourcePrice as et, stepDecimals as tt, t as nt, tickBarCount as rt, timeframeBucketStart as it, timeframeToMs as at, vn30fContracts as ot, vn30fLastTradingDay as st, volumeColor as ct, wallToUtc as lt, zoneOffsetMinutes as ut } from "@tradecanvas/commons";
|
|
3
|
+
import { AlertManager as dt, Animator as ft, BarCountdown as pt, BaseFinanceChart as j, BinanceAdapter as mt, BybitAdapter as ht, ChartLegend as gt, ChartStateManager as _t, CoinbaseAdapter as vt, CompareRenderer as yt, CrosshairTooltip as bt, CurrentPriceLine as xt, DEFAULT_LEGEND_CONFIG as St, DEFAULT_MAX_WEBGL_CHARTS as Ct, DEFAULT_SESSION_HOURS as wt, DataExporter as Tt, DrawingBase as Et, Easing as Dt, FinanceCrosshair as M, GROUP_HEADER as Ot, IndicatorBase as kt, IndicatorValueMap as At, KeyboardHandler as jt, KrakenAdapter as Mt, MAX_ALERT_BARS as Nt, MIN_ALERT_BARS as Pt, MockAdapter as Ft, PaperExecutionAdapter as It, PollingAdapter as Lt, RANGE_PRESETS as Rt, ReplayManager as zt, ResamplingAdapter as Bt, Screenshot as N, SessionBreaks as Vt, SessionShading as Ht, SignalMarkerManager as Ut, StreamManager as Wt, TickAggregator as Gt, TickBarAdapter as Kt, TickBarBuilder as qt, TradeZoneManager as Jt, UndoRedoManager as Yt, VolumeRenderer as Xt, Watermark as Zt, WebSocketAdapter as Qt, barIndexToTime as $t, barIndexToX as en, barIndexToX as P, canvasMeasure as tn, computeBarLayout as nn, computeCalendarLayout as rn, computeCounterClockLayout as an, computeDonutLayout as on, computeHistogramLayout as sn, computeMatrixLayout as cn, computeScatterLayout as ln, correlationMatrix as un, counterClockPhase as dn, counterClockPhase as fn, counterClockPoints as pn, counterClockPoints as mn, formatTooltipTime as hn, histogramBins as gn, hitBar as F, hitDay as I, hitMatrixCell as L, hitSlice as R, isPriceLevelAlert as _n, layoutGroupedTreemap as vn, layoutSquarifiedTreemap as yn, layoutUniformGrid as bn, lttbDownsample as xn, lttbVisibleIndices as Sn, nearestCounterClockPoint as z, nearestPoint as B, niceScale as Cn, priceToY as wn, priceToYMapper as Tn, priceToYMapper as En, rangePresetStart as Dn, renderBarChart as On, renderCalendar as kn, renderCounterClock as An, renderDepthChart as jn, renderDonut as Mn, renderEquityCurve as Nn, renderGauge as Pn, renderHeatmap as Fn, renderHistogram as In, renderMatrix as Ln, renderScatter as Rn, renderSparkline as zn, renderWaterfall as Bn, servesTimeframe as Vn, setMaxWebGLCharts as Hn, shownCount as Un, timeToX as Wn, timestampToBarIndex as Gn, timestampToBarIndex as Kn, toHeikinAshi as qn, toKagi as Jn, toLineBreak as Yn, toPointAndFigure as Xn, toRangeBars as Zn, toRenko as Qn, withResampling as $n, withTickBars as er, xToBarIndex as tr, xToBarIndex as V, xToTime as nr, yToPrice as rr, yToPrice as ir } from "@tradecanvas/core";
|
|
4
4
|
//#region src/frameworks/syncIndicators.ts
|
|
5
|
-
function
|
|
5
|
+
function ar(e) {
|
|
6
6
|
let { id: t, params: n = {}, position: r = null } = typeof e == "string" ? { id: e } : e;
|
|
7
7
|
return JSON.stringify([
|
|
8
8
|
t,
|
|
@@ -10,9 +10,9 @@ function En(e) {
|
|
|
10
10
|
r
|
|
11
11
|
]);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function or(e, t, n) {
|
|
14
14
|
let r = /* @__PURE__ */ new Map(), i = t.map((e) => {
|
|
15
|
-
let t =
|
|
15
|
+
let t = ar(e), n = r.get(t) ?? 0;
|
|
16
16
|
return r.set(t, n + 1), {
|
|
17
17
|
spec: e,
|
|
18
18
|
key: `${t}#${n}`
|
|
@@ -27,18 +27,18 @@ function Dn(e, t, n) {
|
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/plugins/overlayScale.ts
|
|
30
|
-
function
|
|
31
|
-
let { viewport: t, data: n } = e, r =
|
|
30
|
+
function sr(e) {
|
|
31
|
+
let { viewport: t, data: n } = e, r = En(t), i = n.length - 1, a = Math.max(0, Math.floor(t.visibleRange.from)), o = Math.min(i, Math.ceil(t.visibleRange.to)), s = (e) => n.length > 0 ? Kn(e, n) : e;
|
|
32
32
|
return {
|
|
33
|
-
timeToX: (e) =>
|
|
33
|
+
timeToX: (e) => P(s(e), t),
|
|
34
34
|
xToTime: (e) => {
|
|
35
|
-
let r =
|
|
36
|
-
return n.length > 0 ?
|
|
35
|
+
let r = V(e, t);
|
|
36
|
+
return n.length > 0 ? $t(r, n) : r;
|
|
37
37
|
},
|
|
38
|
-
indexToX: (e) =>
|
|
39
|
-
xToIndex: (e) =>
|
|
38
|
+
indexToX: (e) => P(e, t),
|
|
39
|
+
xToIndex: (e) => V(e, t),
|
|
40
40
|
priceToY: r,
|
|
41
|
-
yToPrice: (e) =>
|
|
41
|
+
yToPrice: (e) => ir(e, t),
|
|
42
42
|
barWidth: t.barWidth,
|
|
43
43
|
visible: o < a ? {
|
|
44
44
|
from: 0,
|
|
@@ -51,7 +51,7 @@ function On(e) {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/grid/ChartGrid.ts
|
|
54
|
-
var
|
|
54
|
+
var H = {
|
|
55
55
|
"1x1": {
|
|
56
56
|
cols: 1,
|
|
57
57
|
rows: 1
|
|
@@ -84,7 +84,7 @@ var W = {
|
|
|
84
84
|
cols: 2,
|
|
85
85
|
rows: 3
|
|
86
86
|
}
|
|
87
|
-
},
|
|
87
|
+
}, cr = class {
|
|
88
88
|
root;
|
|
89
89
|
cells = [];
|
|
90
90
|
layout;
|
|
@@ -95,11 +95,11 @@ var W = {
|
|
|
95
95
|
this.options = t, this.layout = t.layout ?? "2x2", this.root = document.createElement("div"), this.root.style.cssText = "display:grid;width:100%;height:100%;overflow:hidden;", e.appendChild(this.root), this.applyLayout(), this.createCells();
|
|
96
96
|
}
|
|
97
97
|
applyLayout() {
|
|
98
|
-
let { cols: e, rows: t } =
|
|
98
|
+
let { cols: e, rows: t } = H[this.layout], n = this.options.gap ?? 1;
|
|
99
99
|
this.root.style.gridTemplateColumns = `repeat(${e}, 1fr)`, this.root.style.gridTemplateRows = `repeat(${t}, 1fr)`, this.root.style.gap = `${n}px`;
|
|
100
100
|
}
|
|
101
101
|
createCells() {
|
|
102
|
-
let { cols: e, rows: t } =
|
|
102
|
+
let { cols: e, rows: t } = H[this.layout], n = e * t;
|
|
103
103
|
for (let e = 0; e < n; e++) this.cells.push(this.createCell(e));
|
|
104
104
|
}
|
|
105
105
|
createCell(e) {
|
|
@@ -144,7 +144,7 @@ var W = {
|
|
|
144
144
|
}
|
|
145
145
|
setLayout(e) {
|
|
146
146
|
if (e === this.layout) return;
|
|
147
|
-
let t = this.cells.length, { cols: n, rows: r } =
|
|
147
|
+
let t = this.cells.length, { cols: n, rows: r } = H[e], i = n * r;
|
|
148
148
|
if (i < t) for (let e = t - 1; e >= i; e--) {
|
|
149
149
|
let t = this.cells[e];
|
|
150
150
|
t.chart.destroy(), t.container.remove(), this.cells.pop();
|
|
@@ -191,13 +191,13 @@ var W = {
|
|
|
191
191
|
this.cells = [], this.root.remove();
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
},
|
|
194
|
+
}, lr = class extends j {
|
|
195
195
|
options;
|
|
196
196
|
constructor(e, t) {
|
|
197
197
|
super(e, t.theme), this.options = t, this.requestRender();
|
|
198
198
|
}
|
|
199
199
|
renderChart(e, t, n, r) {
|
|
200
|
-
|
|
200
|
+
zn(e, t, n, this.options, r);
|
|
201
201
|
}
|
|
202
202
|
update(e) {
|
|
203
203
|
this.options = {
|
|
@@ -211,15 +211,15 @@ var W = {
|
|
|
211
211
|
...e
|
|
212
212
|
}, this.requestRender();
|
|
213
213
|
}
|
|
214
|
-
},
|
|
214
|
+
}, ur = class extends j {
|
|
215
215
|
options;
|
|
216
216
|
crosshair = null;
|
|
217
217
|
constructor(e, t) {
|
|
218
|
-
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new
|
|
218
|
+
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new M(this.canvas, () => this.requestRender())), this.requestRender();
|
|
219
219
|
}
|
|
220
220
|
renderChart(e, t, n, r) {
|
|
221
221
|
let i = this.crosshair?.getPosition() ?? null;
|
|
222
|
-
|
|
222
|
+
jn(e, t, n, this.options, r, i);
|
|
223
223
|
}
|
|
224
224
|
update(e) {
|
|
225
225
|
this.options = {
|
|
@@ -236,15 +236,15 @@ var W = {
|
|
|
236
236
|
destroy() {
|
|
237
237
|
this.crosshair?.destroy(), super.destroy();
|
|
238
238
|
}
|
|
239
|
-
},
|
|
239
|
+
}, U = class extends j {
|
|
240
240
|
options;
|
|
241
241
|
crosshair = null;
|
|
242
242
|
constructor(e, t) {
|
|
243
|
-
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new
|
|
243
|
+
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new M(this.canvas, () => this.requestRender())), this.requestRender();
|
|
244
244
|
}
|
|
245
245
|
renderChart(e, t, n, r) {
|
|
246
246
|
let i = this.crosshair?.getPosition() ?? null;
|
|
247
|
-
|
|
247
|
+
Nn(e, t, n, this.options, r, i);
|
|
248
248
|
}
|
|
249
249
|
update(e, t) {
|
|
250
250
|
this.options = {
|
|
@@ -264,19 +264,24 @@ var W = {
|
|
|
264
264
|
destroy() {
|
|
265
265
|
this.crosshair?.destroy(), super.destroy();
|
|
266
266
|
}
|
|
267
|
-
},
|
|
267
|
+
}, W = class extends j {
|
|
268
268
|
options;
|
|
269
269
|
crosshair = null;
|
|
270
270
|
cachedRects = [];
|
|
271
|
+
cachedGroups = [];
|
|
271
272
|
currentData = [];
|
|
272
273
|
lastLayoutWidth = 0;
|
|
273
274
|
lastLayoutHeight = 0;
|
|
274
275
|
handleClick = null;
|
|
275
276
|
constructor(e, t) {
|
|
276
|
-
super(e, t.theme), this.options = t, this.currentData = t.data ?? [], t.crosshair !== !1 && (this.crosshair = new
|
|
277
|
+
super(e, t.theme), this.options = t, this.currentData = t.data ?? [], t.crosshair !== !1 && (this.crosshair = new M(this.canvas, () => this.requestRender())), t.onCellClick && (this.handleClick = (e) => {
|
|
277
278
|
let t = this.canvas.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
278
279
|
this.onCanvasClick(n, r);
|
|
279
|
-
}, this.canvas.addEventListener("click", this.handleClick)), this.recomputeLayout(), this.requestRender();
|
|
280
|
+
}, this.canvas.addEventListener("click", this.handleClick)), this.applyLabel(), this.recomputeLayout(), this.requestRender();
|
|
281
|
+
}
|
|
282
|
+
applyLabel() {
|
|
283
|
+
let e = new Set(this.currentData.map((e) => e.group).filter(Boolean)).size, t = this.options.grouped && e > 0 ? `Market map of ${this.currentData.length} cells in ${e} groups` : `Heatmap of ${this.currentData.length} cells`;
|
|
284
|
+
this.setLabel(this.options.ariaLabel ?? t);
|
|
280
285
|
}
|
|
281
286
|
recomputeLayout() {
|
|
282
287
|
let e = {
|
|
@@ -285,13 +290,21 @@ var W = {
|
|
|
285
290
|
width: this.width,
|
|
286
291
|
height: this.height
|
|
287
292
|
}, t = this.options.cellPadding ?? 2;
|
|
288
|
-
if (this.lastLayoutWidth = this.width, this.lastLayoutHeight = this.height, this.options.
|
|
293
|
+
if (this.lastLayoutWidth = this.width, this.lastLayoutHeight = this.height, this.cachedGroups = [], this.options.grouped) {
|
|
294
|
+
let { groups: n, cells: r } = vn(this.currentData.map((e) => ({
|
|
295
|
+
id: e.id,
|
|
296
|
+
weight: e.weight ?? (Math.abs(e.value) || 1),
|
|
297
|
+
group: e.group,
|
|
298
|
+
value: e.value
|
|
299
|
+
})), e, t, Ot);
|
|
300
|
+
this.cachedRects = r, this.cachedGroups = n;
|
|
301
|
+
} else if (this.options.weighted) {
|
|
289
302
|
let n = this.currentData.map((e) => ({
|
|
290
303
|
id: e.id,
|
|
291
304
|
weight: e.weight ?? (Math.abs(e.value) || 1)
|
|
292
305
|
}));
|
|
293
|
-
this.cachedRects =
|
|
294
|
-
} else this.cachedRects =
|
|
306
|
+
this.cachedRects = yn(n, e, t);
|
|
307
|
+
} else this.cachedRects = bn(this.currentData.map((e) => ({ id: e.id })), e, t);
|
|
295
308
|
}
|
|
296
309
|
onCanvasClick(e, t) {
|
|
297
310
|
if (this.options.onCellClick) for (let n of this.cachedRects) {
|
|
@@ -306,32 +319,32 @@ var W = {
|
|
|
306
319
|
renderChart(e, t, n, r) {
|
|
307
320
|
(t !== this.lastLayoutWidth || n !== this.lastLayoutHeight) && this.recomputeLayout();
|
|
308
321
|
let i = this.crosshair?.getPosition() ?? null;
|
|
309
|
-
|
|
322
|
+
Fn(e, t, n, this.currentData, this.cachedRects, this.options, r, i, this.cachedGroups);
|
|
310
323
|
}
|
|
311
324
|
update(e) {
|
|
312
325
|
this.currentData = e, this.options = {
|
|
313
326
|
...this.options,
|
|
314
327
|
data: e
|
|
315
|
-
}, this.recomputeLayout(), this.requestRender();
|
|
328
|
+
}, this.applyLabel(), this.recomputeLayout(), this.requestRender();
|
|
316
329
|
}
|
|
317
330
|
setOptions(e) {
|
|
318
331
|
this.options = {
|
|
319
332
|
...this.options,
|
|
320
333
|
...e
|
|
321
|
-
}, e.data && (this.currentData = e.data), this.recomputeLayout(), this.requestRender();
|
|
334
|
+
}, e.data && (this.currentData = e.data), this.applyLabel(), this.recomputeLayout(), this.requestRender();
|
|
322
335
|
}
|
|
323
336
|
destroy() {
|
|
324
337
|
this.crosshair?.destroy(), this.handleClick && this.canvas.removeEventListener("click", this.handleClick), super.destroy();
|
|
325
338
|
}
|
|
326
|
-
},
|
|
339
|
+
}, dr = class extends j {
|
|
327
340
|
options;
|
|
328
341
|
crosshair = null;
|
|
329
342
|
constructor(e, t) {
|
|
330
|
-
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new
|
|
343
|
+
super(e, t.theme), this.options = t, t.crosshair !== !1 && (this.crosshair = new M(this.canvas, () => this.requestRender())), this.requestRender();
|
|
331
344
|
}
|
|
332
345
|
renderChart(e, t, n, r) {
|
|
333
346
|
let i = this.crosshair?.getPosition() ?? null;
|
|
334
|
-
|
|
347
|
+
Bn(e, t, n, this.options, r, i);
|
|
335
348
|
}
|
|
336
349
|
update(e) {
|
|
337
350
|
this.options = {
|
|
@@ -348,12 +361,12 @@ var W = {
|
|
|
348
361
|
destroy() {
|
|
349
362
|
this.crosshair?.destroy(), super.destroy();
|
|
350
363
|
}
|
|
351
|
-
},
|
|
352
|
-
function
|
|
364
|
+
}, fr = 500;
|
|
365
|
+
function pr(e) {
|
|
353
366
|
let t = 1 - e;
|
|
354
367
|
return 1 - t * t * t;
|
|
355
368
|
}
|
|
356
|
-
var
|
|
369
|
+
var mr = class extends j {
|
|
357
370
|
options;
|
|
358
371
|
currentValue;
|
|
359
372
|
targetValue;
|
|
@@ -364,7 +377,7 @@ var Fn = class extends z {
|
|
|
364
377
|
super(e, t.theme), this.options = t, this.currentValue = t.value, this.targetValue = t.value, this.requestRender();
|
|
365
378
|
}
|
|
366
379
|
renderChart(e, t, n, r) {
|
|
367
|
-
|
|
380
|
+
Pn(e, t, n, this.options, r, this.currentValue);
|
|
368
381
|
}
|
|
369
382
|
setValue(e) {
|
|
370
383
|
if (this.options.animate === !1) {
|
|
@@ -394,7 +407,7 @@ var Fn = class extends z {
|
|
|
394
407
|
if (this.animationFrameId !== null) return;
|
|
395
408
|
let e = () => {
|
|
396
409
|
if (this.animationFrameId = null, this.animationStart === null) return;
|
|
397
|
-
let t = this.options.animationDuration ??
|
|
410
|
+
let t = this.options.animationDuration ?? fr, n = performance.now() - this.animationStart, r = Math.min(1, n / Math.max(1, t)), i = pr(r);
|
|
398
411
|
this.currentValue = this.animationFrom + (this.targetValue - this.animationFrom) * i, this.requestRender(), r < 1 ? this.animationFrameId = requestAnimationFrame(e) : (this.currentValue = this.targetValue, this.animationStart = null);
|
|
399
412
|
};
|
|
400
413
|
this.animationFrameId = requestAnimationFrame(e);
|
|
@@ -405,7 +418,218 @@ var Fn = class extends z {
|
|
|
405
418
|
destroy() {
|
|
406
419
|
this.cancelAnimation(), super.destroy();
|
|
407
420
|
}
|
|
408
|
-
},
|
|
421
|
+
}, G = class extends j {
|
|
422
|
+
options;
|
|
423
|
+
layout = null;
|
|
424
|
+
layoutFor = null;
|
|
425
|
+
crosshair;
|
|
426
|
+
onClick = (e) => {
|
|
427
|
+
let t = this.canvas.getBoundingClientRect();
|
|
428
|
+
this.layout && this.clickAt(this.layout, e.clientX - t.left, e.clientY - t.top);
|
|
429
|
+
};
|
|
430
|
+
onMove = (e) => {
|
|
431
|
+
if (!this.layout || !this.clickable()) return;
|
|
432
|
+
let t = this.canvas.getBoundingClientRect();
|
|
433
|
+
this.canvas.style.cursor = this.hits(this.layout, e.clientX - t.left, e.clientY - t.top) ? "pointer" : "";
|
|
434
|
+
};
|
|
435
|
+
constructor(e, t) {
|
|
436
|
+
super(e, t.theme), this.options = t, this.crosshair = new M(this.canvas, () => this.requestRender()), this.canvas.addEventListener("click", this.onClick), this.canvas.addEventListener("pointermove", this.onMove), this.applyLabel(), this.requestRender();
|
|
437
|
+
}
|
|
438
|
+
renderChart(e, t, n, r) {
|
|
439
|
+
let i = this.options.crosshair === !1 ? null : this.crosshair.getPosition(), a = this.layoutFor;
|
|
440
|
+
(!this.layout || !a || a.options !== this.options || a.width !== t || a.height !== n || a.theme !== r) && (this.layout = this.compute(t, n, r, tn(e, r)), this.layoutFor = {
|
|
441
|
+
options: this.options,
|
|
442
|
+
width: t,
|
|
443
|
+
height: n,
|
|
444
|
+
theme: r
|
|
445
|
+
}), this.draw(e, t, n, r, i, this.layout);
|
|
446
|
+
}
|
|
447
|
+
setOptions(e) {
|
|
448
|
+
this.options = {
|
|
449
|
+
...this.options,
|
|
450
|
+
...e
|
|
451
|
+
}, "theme" in e && this.setTheme(e.theme ?? "dark"), this.applyLabel(), this.requestRender();
|
|
452
|
+
}
|
|
453
|
+
applyLabel() {
|
|
454
|
+
this.setLabel(this.options.ariaLabel ?? this.describe());
|
|
455
|
+
}
|
|
456
|
+
destroy() {
|
|
457
|
+
this.crosshair.destroy(), this.canvas.removeEventListener("click", this.onClick), this.canvas.removeEventListener("pointermove", this.onMove), super.destroy();
|
|
458
|
+
}
|
|
459
|
+
}, hr = class extends G {
|
|
460
|
+
compute(e, t, n, r) {
|
|
461
|
+
return nn(this.options, e, t, n, r);
|
|
462
|
+
}
|
|
463
|
+
draw(e, t, n, r, i, a) {
|
|
464
|
+
On(e, t, n, this.options, r, i, a);
|
|
465
|
+
}
|
|
466
|
+
describe() {
|
|
467
|
+
return `Bar chart of ${this.options.series.map((e) => e.name).join(", ")}, ${this.options.categories.length} categories`;
|
|
468
|
+
}
|
|
469
|
+
clickable() {
|
|
470
|
+
return this.options.onBarClick !== void 0;
|
|
471
|
+
}
|
|
472
|
+
hits(e, t, n) {
|
|
473
|
+
return F(e, t, n) !== null;
|
|
474
|
+
}
|
|
475
|
+
clickAt(e, t, n) {
|
|
476
|
+
let r = F(e, t, n);
|
|
477
|
+
r && this.options.onBarClick?.({
|
|
478
|
+
category: r.category,
|
|
479
|
+
series: r.series,
|
|
480
|
+
value: r.value,
|
|
481
|
+
index: r.index
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
update(e, t) {
|
|
485
|
+
this.setOptions({
|
|
486
|
+
categories: e,
|
|
487
|
+
series: t
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}, gr = class extends G {
|
|
491
|
+
compute(e, t, n, r) {
|
|
492
|
+
return on(this.options, e, t, n, r);
|
|
493
|
+
}
|
|
494
|
+
draw(e, t, n, r, i, a) {
|
|
495
|
+
Mn(e, t, n, this.options, r, i, a);
|
|
496
|
+
}
|
|
497
|
+
describe() {
|
|
498
|
+
let e = this.options.data.filter((e) => Number.isFinite(e.value) && e.value > 0).map((e) => e.label).join(", ");
|
|
499
|
+
return `${(this.options.innerRadius ?? .6) > 0 ? "Donut" : "Pie"} chart of ${e}`;
|
|
500
|
+
}
|
|
501
|
+
clickable() {
|
|
502
|
+
return this.options.onSliceClick !== void 0;
|
|
503
|
+
}
|
|
504
|
+
hits(e, t, n) {
|
|
505
|
+
return R(e, t, n) !== null;
|
|
506
|
+
}
|
|
507
|
+
clickAt(e, t, n) {
|
|
508
|
+
let r = R(e, t, n);
|
|
509
|
+
r && this.options.onSliceClick?.(r.slice);
|
|
510
|
+
}
|
|
511
|
+
update(e) {
|
|
512
|
+
this.setOptions({ data: e });
|
|
513
|
+
}
|
|
514
|
+
}, _r = class extends G {
|
|
515
|
+
compute(e, t, n, r) {
|
|
516
|
+
return ln(this.options, e, t, n, r);
|
|
517
|
+
}
|
|
518
|
+
draw(e, t, n, r, i, a) {
|
|
519
|
+
Rn(e, t, n, this.options, r, i, a);
|
|
520
|
+
}
|
|
521
|
+
describe() {
|
|
522
|
+
let e = this.options.series.reduce((e, t) => e + t.points.length, 0);
|
|
523
|
+
return `Scatter chart${this.options.xLabel && this.options.yLabel ? ` of ${this.options.yLabel} against ${this.options.xLabel}` : ""}, ${e} points`;
|
|
524
|
+
}
|
|
525
|
+
clickable() {
|
|
526
|
+
return this.options.onPointClick !== void 0;
|
|
527
|
+
}
|
|
528
|
+
hits(e, t, n) {
|
|
529
|
+
return B(e, t, n) !== null;
|
|
530
|
+
}
|
|
531
|
+
clickAt(e, t, n) {
|
|
532
|
+
let r = B(e, t, n);
|
|
533
|
+
r && this.options.onPointClick?.(r.point, r.series);
|
|
534
|
+
}
|
|
535
|
+
update(e) {
|
|
536
|
+
this.setOptions({ series: e });
|
|
537
|
+
}
|
|
538
|
+
}, vr = class extends G {
|
|
539
|
+
compute(e, t, n, r) {
|
|
540
|
+
return sn(this.options, e, t, n, r);
|
|
541
|
+
}
|
|
542
|
+
draw(e, t, n, r, i, a) {
|
|
543
|
+
In(e, t, n, this.options, r, i, a);
|
|
544
|
+
}
|
|
545
|
+
describe() {
|
|
546
|
+
return `Histogram of ${this.options.values.length} values`;
|
|
547
|
+
}
|
|
548
|
+
clickable() {
|
|
549
|
+
return !1;
|
|
550
|
+
}
|
|
551
|
+
hits() {
|
|
552
|
+
return !1;
|
|
553
|
+
}
|
|
554
|
+
clickAt() {}
|
|
555
|
+
update(e) {
|
|
556
|
+
this.setOptions({ values: e });
|
|
557
|
+
}
|
|
558
|
+
}, yr = class extends G {
|
|
559
|
+
compute(e, t, n, r) {
|
|
560
|
+
return rn(this.options, e, t, n, r);
|
|
561
|
+
}
|
|
562
|
+
draw(e, t, n, r, i, a) {
|
|
563
|
+
kn(e, t, n, this.options, r, i, a);
|
|
564
|
+
}
|
|
565
|
+
describe() {
|
|
566
|
+
let e = this.options.data.map((e) => e.date).filter((e) => /^\d{4}-\d{2}-\d{2}$/.test(e)).sort(), t = this.options.from ?? e[0], n = this.options.to ?? e[e.length - 1];
|
|
567
|
+
return t && n ? `Calendar of daily values from ${t} to ${n}` : "Calendar of daily values";
|
|
568
|
+
}
|
|
569
|
+
clickable() {
|
|
570
|
+
return this.options.onDayClick !== void 0;
|
|
571
|
+
}
|
|
572
|
+
hits(e, t, n) {
|
|
573
|
+
return I(e, t, n)?.day !== void 0;
|
|
574
|
+
}
|
|
575
|
+
clickAt(e, t, n) {
|
|
576
|
+
let r = I(e, t, n)?.day;
|
|
577
|
+
r && this.options.onDayClick?.(r);
|
|
578
|
+
}
|
|
579
|
+
update(e) {
|
|
580
|
+
this.setOptions({ data: e });
|
|
581
|
+
}
|
|
582
|
+
}, K = 12, br = class extends G {
|
|
583
|
+
compute(e, t, n, r) {
|
|
584
|
+
return cn(this.options, e, t, n, r);
|
|
585
|
+
}
|
|
586
|
+
draw(e, t, n, r, i, a) {
|
|
587
|
+
Ln(e, t, n, this.options, r, i, a);
|
|
588
|
+
}
|
|
589
|
+
describe() {
|
|
590
|
+
let { rows: e, columns: t } = this.options;
|
|
591
|
+
return t ? e.length + t.length <= K ? `Matrix of ${e.join(", ")} by ${t.join(", ")}` : `Matrix of ${e.length} rows by ${t.length} columns` : e.length <= K ? `Matrix of ${e.join(", ")}` : `Matrix of ${e.length} rows`;
|
|
592
|
+
}
|
|
593
|
+
clickable() {
|
|
594
|
+
return this.options.onCellClick !== void 0;
|
|
595
|
+
}
|
|
596
|
+
hits(e, t, n) {
|
|
597
|
+
return L(e, t, n) !== null;
|
|
598
|
+
}
|
|
599
|
+
clickAt(e, t, n) {
|
|
600
|
+
let r = L(e, t, n);
|
|
601
|
+
r && this.options.onCellClick?.(r.cell);
|
|
602
|
+
}
|
|
603
|
+
update(e) {
|
|
604
|
+
this.setOptions({ values: e });
|
|
605
|
+
}
|
|
606
|
+
}, xr = class extends G {
|
|
607
|
+
compute(e, t, n, r) {
|
|
608
|
+
return an(this.options, e, t, n, r);
|
|
609
|
+
}
|
|
610
|
+
draw(e, t, n, r, i, a) {
|
|
611
|
+
An(e, t, n, this.options, r, i, a);
|
|
612
|
+
}
|
|
613
|
+
describe() {
|
|
614
|
+
return `Counter-clock chart of price against volume, ${this.options.period ?? 25}-bar averages`;
|
|
615
|
+
}
|
|
616
|
+
clickable() {
|
|
617
|
+
return this.options.onPointClick !== void 0;
|
|
618
|
+
}
|
|
619
|
+
hits(e, t, n) {
|
|
620
|
+
return z(e, t, n) !== null;
|
|
621
|
+
}
|
|
622
|
+
clickAt(e, t, n) {
|
|
623
|
+
let r = z(e, t, n);
|
|
624
|
+
r && this.options.onPointClick?.(r.point);
|
|
625
|
+
}
|
|
626
|
+
getPhase() {
|
|
627
|
+
return fn(mn(this.options.data, this.options.period ?? 25, Un(this.options)));
|
|
628
|
+
}
|
|
629
|
+
update(e) {
|
|
630
|
+
this.setOptions({ data: e });
|
|
631
|
+
}
|
|
632
|
+
}, Sr = [
|
|
409
633
|
"Jan",
|
|
410
634
|
"Feb",
|
|
411
635
|
"Mar",
|
|
@@ -440,7 +664,7 @@ function Y(e) {
|
|
|
440
664
|
if (e.length === 0) return [];
|
|
441
665
|
let t = [];
|
|
442
666
|
for (let n of e) {
|
|
443
|
-
let e =
|
|
667
|
+
let e = it(n.time, "1M"), r = t[t.length - 1];
|
|
444
668
|
r && r.key === e ? r.close = n.equity : t.push({
|
|
445
669
|
key: e,
|
|
446
670
|
close: n.equity
|
|
@@ -453,7 +677,7 @@ function Y(e) {
|
|
|
453
677
|
let a = new Date(e.key), o = a.getUTCFullYear(), s = a.getUTCMonth();
|
|
454
678
|
r.push({
|
|
455
679
|
id: `${o}-${String(s + 1).padStart(2, "0")}`,
|
|
456
|
-
label:
|
|
680
|
+
label: Sr[s],
|
|
457
681
|
group: String(o),
|
|
458
682
|
value: i
|
|
459
683
|
});
|
|
@@ -513,9 +737,9 @@ function Q(e) {
|
|
|
513
737
|
//#endregion
|
|
514
738
|
//#region src/finance/PerformanceDashboard.ts
|
|
515
739
|
function $(e) {
|
|
516
|
-
return !e || e === "dark" ? me : e === "light" ?
|
|
740
|
+
return !e || e === "dark" ? me : e === "light" ? f : e;
|
|
517
741
|
}
|
|
518
|
-
var
|
|
742
|
+
var Cr = class {
|
|
519
743
|
options;
|
|
520
744
|
theme;
|
|
521
745
|
root;
|
|
@@ -558,7 +782,7 @@ var Ln = class {
|
|
|
558
782
|
"gap:14px"
|
|
559
783
|
].join(";"), this.root.appendChild(o);
|
|
560
784
|
let s = this.buildPanel("Equity Curve", i, a);
|
|
561
|
-
s.wrap.style.gridColumn = "1 / -1", o.appendChild(s.wrap), this.equityChart = new
|
|
785
|
+
s.wrap.style.gridColumn = "1 / -1", o.appendChild(s.wrap), this.equityChart = new U(s.body, {
|
|
562
786
|
data: q(t.equityCurve),
|
|
563
787
|
theme: e,
|
|
564
788
|
lineColor: e.candleUp,
|
|
@@ -566,7 +790,7 @@ var Ln = class {
|
|
|
566
790
|
crosshair: !0
|
|
567
791
|
});
|
|
568
792
|
let c = this.buildPanel("Drawdown", i, a);
|
|
569
|
-
o.appendChild(c.wrap), this.drawdownChart = new
|
|
793
|
+
o.appendChild(c.wrap), this.drawdownChart = new U(c.body, {
|
|
570
794
|
data: J(t.equityCurve),
|
|
571
795
|
theme: e,
|
|
572
796
|
lineColor: e.candleDown,
|
|
@@ -575,7 +799,7 @@ var Ln = class {
|
|
|
575
799
|
valueFormat: (e) => `${e.toFixed(1)}%`
|
|
576
800
|
});
|
|
577
801
|
let l = Y(t.equityCurve), u = this.buildPanel("Monthly Returns", i, a);
|
|
578
|
-
o.appendChild(u.wrap), this.heatmap = new
|
|
802
|
+
o.appendChild(u.wrap), this.heatmap = new W(u.body, {
|
|
579
803
|
data: l,
|
|
580
804
|
theme: e,
|
|
581
805
|
showValues: !0,
|
|
@@ -664,6 +888,6 @@ var Ln = class {
|
|
|
664
888
|
}
|
|
665
889
|
};
|
|
666
890
|
//#endregion
|
|
667
|
-
export {
|
|
891
|
+
export { dt as AlertManager, ft as Animator, hr as BarChart, pt as BarCountdown, mt as BinanceAdapter, ht as BybitAdapter, de as CHART_STYLE_KEYS, yr as CalendarChart, i as Chart, cr as ChartGrid, gt as ChartLegend, _t as ChartStateManager, vt as CoinbaseAdapter, yt as CompareRenderer, xr as CounterClockChart, bt as CrosshairTooltip, xt as CurrentPriceLine, fe as DARK_TERMINAL, pe as DARK_THEME, he as DEFAULT_DRAWING_STYLE, r as DEFAULT_HISTORY_PAGE_SIZE, St as DEFAULT_LEGEND_CONFIG, Ct as DEFAULT_MAX_WEBGL_CHARTS, ge as DEFAULT_RECONNECT, wt as DEFAULT_SESSION_HOURS, _e as DEFAULT_SIGNAL_STYLE, ve as DEFAULT_STREAM_CONFIG, ye as DEFAULT_TIMEFRAME_FAVORITES, be as DEFAULT_TRADE_ZONE_STYLE, xe as DEFAULT_TRADING_CONFIG, Tt as DataExporter, e as DataManager, ur as DepthChart, gr as DonutChart, ne as DragDropImporter, Et as DrawingBase, u as EXCHANGE_TIMEZONE, Dt as Easing, U as EquityCurveChart, mr as GaugeChart, le as HISTORY_RETRY_MS, Se as HNX_SESSIONS, Ce as HOSE_SESSIONS, W as HeatmapChart, vr as HistogramChart, kt as IndicatorBase, At as IndicatorValueMap, jt as KeyboardHandler, Mt as KrakenAdapter, d as LIGHT_THEME, ce as LayoutManager, oe as LayoutSession, p as MARKET_CRYPTO, m as MARKET_HNX, h as MARKET_HOSE, g as MARKET_HOSE_ETF, _ as MARKET_NYSE, v as MARKET_UPCOM, y as MARKET_VN30F, Nt as MAX_ALERT_BARS, te as MAX_LAYOUT_NAME, Pt as MIN_ALERT_BARS, br as MatrixChart, Ft as MockAdapter, c as PLUGIN_API_VERSION, b as PRICE_SOURCES, It as PaperExecutionAdapter, Cr as PerformanceDashboard, se as PluginManager, Lt as PollingAdapter, Rt as RANGE_PRESETS, zt as ReplayManager, Bt as ResamplingAdapter, _r as ScatterChart, N as Screenshot, Vt as SessionBreaks, Ht as SessionShading, Ut as SignalMarkerManager, lr as SparklineChart, Wt as StreamManager, x as TC_PALETTE, S as TC_SERIES_COLORS, C as TIMEFRAMES_CRYPTO, w as TIMEFRAMES_FOREX, T as TIMEFRAMES_STOCK, ue as ThemeManager, Gt as TickAggregator, Kt as TickBarAdapter, qt as TickBarBuilder, Jt as TradeZoneManager, E as UPCOM_SESSIONS, Yt as UndoRedoManager, D as VN30F_SESSIONS, O as VN_COLORS, k as VOLUME_ALPHA, Xt as VolumeRenderer, dr as WaterfallChart, Zt as Watermark, Qt as WebSocketAdapter, en as barIndexToX, A as barsAreDaily, ie as cleanLayoutName, a as clearGlobalPlugins, J as computeDrawdownCurve, Y as computeMonthlyReturns, we as computePriceLimits, un as correlationMatrix, dn as counterClockPhase, pn as counterClockPoints, Te as createVNTheme, Ee as formatFraction, De as formatNumber, hn as formatTooltipTime, Oe as formatVND, ke as formatVolumeLoc, Ae as fractionTick, je as getCurrentSession, o as getGlobalPlugins, Me as getLocale, gn as histogramBins, Ne as indicatorSource, _n as isPriceLevelAlert, Pe as isPriceSource, Fe as isTimeFrame, Ie as isValidTimeZone, l as localStorageLayouts, xn as lttbDownsample, Sn as lttbVisibleIndices, Le as marketStatus, n as memoryLayouts, Cn as niceScale, Re as normalizeBar, ze as normalizeBarTime, Be as offsetAt, sr as overlayScale, s as overlaysForLayer, Ve as parseIndicatorSource, ae as parseOHLCV, He as parseTimeframe, Ue as pickBaseTimeframe, t as pluginKey, We as priceFormatterFor, Ge as priceStepAt, wn as priceToY, Tn as priceToYMapper, Dn as rangePresetStart, Ke as rankSymbols, qe as readNews, Je as readQuote, Ye as registerLocale, re as registerPlugin, Xe as resampleBars, Ze as roundToPriceStep, Qe as scaleMarketPrices, Q as selectKeyStats, Vn as servesTimeframe, $e as setLocale, Hn as setMaxWebGLCharts, et as sourcePrice, tt as stepDecimals, or as syncIndicators, nt as t, rt as tickBarCount, Wn as timeToX, at as timeframeToMs, Gn as timestampToBarIndex, q as toEquityPoints, qn as toHeikinAshi, Jn as toKagi, Yn as toLineBreak, Xn as toPointAndFigure, Zn as toRangeBars, Qn as toRenko, ee as unregisterPlugin, ot as vn30fContracts, st as vn30fLastTradingDay, ct as volumeColor, lt as wallToUtc, $n as withResampling, er as withTickBars, tr as xToBarIndex, nr as xToTime, rr as yToPrice, ut as zoneOffsetMinutes };
|
|
668
892
|
|
|
669
893
|
//# sourceMappingURL=index.js.map
|