charts-core 1.1.16 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/charts-core.js
CHANGED
|
@@ -299,7 +299,7 @@ const Ys = (i) => {
|
|
|
299
299
|
const t = D.format(",.2f");
|
|
300
300
|
return `${i < 0 ? "-" : ""}$${t(Math.abs(i))}`;
|
|
301
301
|
};
|
|
302
|
-
function
|
|
302
|
+
function Xs(i) {
|
|
303
303
|
const t = document.createElement("div");
|
|
304
304
|
t.className = `${mt}-container`, t.style.position = "absolute", t.style.top = "0", t.style.pointerEvents = "none", t.style.display = "none", i.appendChild(t);
|
|
305
305
|
const e = document.createElement("div");
|
|
@@ -307,11 +307,11 @@ function Ws(i) {
|
|
|
307
307
|
const s = document.createElement("div");
|
|
308
308
|
return s.className = `${mt}-time`, t.appendChild(s), { wrapper: t, sumNode: e, timeNode: s };
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function Ws(i, t, e) {
|
|
311
311
|
return i ? t + Zt + i.width < e ? t + Zt : t - Zt - i.width : null;
|
|
312
312
|
}
|
|
313
313
|
const Us = (i) => {
|
|
314
|
-
const { wrapper: t, sumNode: e, timeNode: s } =
|
|
314
|
+
const { wrapper: t, sumNode: e, timeNode: s } = Xs(i.wrapperNode);
|
|
315
315
|
return {
|
|
316
316
|
className(n, r) {
|
|
317
317
|
n === "remove" ? t.classList.remove(`${mt}${r}`) : t.classList.add(`${mt}${r}`);
|
|
@@ -320,7 +320,7 @@ const Us = (i) => {
|
|
|
320
320
|
if (r) {
|
|
321
321
|
const { sumFormatter: a, timeFormatter: o } = i.config.hover;
|
|
322
322
|
e.textContent = a ? a(r.value) : js(r.value), s.textContent = o ? o(r.date) : Vs(r.date), requestAnimationFrame(() => {
|
|
323
|
-
const c = t.getBoundingClientRect(), h =
|
|
323
|
+
const c = t.getBoundingClientRect(), h = Ws(
|
|
324
324
|
c,
|
|
325
325
|
i.x(r.date),
|
|
326
326
|
i.width - i.config.margin.right
|
|
@@ -915,7 +915,7 @@ function cn() {
|
|
|
915
915
|
return this.size += this.has(l) ? 0 : 1, m[l] = ct && d === void 0 ? s : d, this;
|
|
916
916
|
}
|
|
917
917
|
tt.prototype.clear = ki, tt.prototype.delete = Di, tt.prototype.get = Li, tt.prototype.has = Ei, tt.prototype.set = Ni;
|
|
918
|
-
function
|
|
918
|
+
function W(l) {
|
|
919
919
|
var d = -1, m = l == null ? 0 : l.length;
|
|
920
920
|
for (this.clear(); ++d < m; ) {
|
|
921
921
|
var M = l[d];
|
|
@@ -943,7 +943,7 @@ function cn() {
|
|
|
943
943
|
var m = this.__data__, M = wt(m, l);
|
|
944
944
|
return M < 0 ? (++this.size, m.push([l, d])) : m[M][1] = d, this;
|
|
945
945
|
}
|
|
946
|
-
|
|
946
|
+
W.prototype.clear = Fi, W.prototype.delete = Ii, W.prototype.get = Bi, W.prototype.has = Hi, W.prototype.set = $i;
|
|
947
947
|
function nt(l) {
|
|
948
948
|
var d = -1, m = l == null ? 0 : l.length;
|
|
949
949
|
for (this.clear(); ++d < m; ) {
|
|
@@ -954,7 +954,7 @@ function cn() {
|
|
|
954
954
|
function Ri() {
|
|
955
955
|
this.size = 0, this.__data__ = {
|
|
956
956
|
hash: new tt(),
|
|
957
|
-
map: new (ve ||
|
|
957
|
+
map: new (ve || W)(),
|
|
958
958
|
string: new tt()
|
|
959
959
|
};
|
|
960
960
|
}
|
|
@@ -974,25 +974,25 @@ function cn() {
|
|
|
974
974
|
}
|
|
975
975
|
nt.prototype.clear = Ri, nt.prototype.delete = zi, nt.prototype.get = Pi, nt.prototype.has = Oi, nt.prototype.set = Yi;
|
|
976
976
|
function rt(l) {
|
|
977
|
-
var d = this.__data__ = new
|
|
977
|
+
var d = this.__data__ = new W(l);
|
|
978
978
|
this.size = d.size;
|
|
979
979
|
}
|
|
980
980
|
function Vi() {
|
|
981
|
-
this.__data__ = new
|
|
981
|
+
this.__data__ = new W(), this.size = 0;
|
|
982
982
|
}
|
|
983
983
|
function ji(l) {
|
|
984
984
|
var d = this.__data__, m = d.delete(l);
|
|
985
985
|
return this.size = d.size, m;
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function Xi(l) {
|
|
988
988
|
return this.__data__.get(l);
|
|
989
989
|
}
|
|
990
|
-
function
|
|
990
|
+
function Wi(l) {
|
|
991
991
|
return this.__data__.has(l);
|
|
992
992
|
}
|
|
993
993
|
function Ui(l, d) {
|
|
994
994
|
var m = this.__data__;
|
|
995
|
-
if (m instanceof
|
|
995
|
+
if (m instanceof W) {
|
|
996
996
|
var M = m.__data__;
|
|
997
997
|
if (!ve || M.length < e - 1)
|
|
998
998
|
return M.push([l, d]), this.size = ++m.size, this;
|
|
@@ -1000,7 +1000,7 @@ function cn() {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
return m.set(l, d), this.size = m.size, this;
|
|
1002
1002
|
}
|
|
1003
|
-
rt.prototype.clear = Vi, rt.prototype.delete = ji, rt.prototype.get =
|
|
1003
|
+
rt.prototype.clear = Vi, rt.prototype.delete = ji, rt.prototype.get = Xi, rt.prototype.has = Wi, rt.prototype.set = Ui;
|
|
1004
1004
|
function Gi(l, d) {
|
|
1005
1005
|
var m = Vt(l), M = !m && Yt(l), S = !m && !M && Ce(l), E = !m && !M && !S && Ae(l), F = m || M || S || E, L = F ? mi(l.length, String) : [], I = L.length;
|
|
1006
1006
|
for (var V in l)
|
|
@@ -1042,7 +1042,7 @@ function cn() {
|
|
|
1042
1042
|
function Ji(l) {
|
|
1043
1043
|
if (!et(l) || gs(l))
|
|
1044
1044
|
return !1;
|
|
1045
|
-
var d =
|
|
1045
|
+
var d = Xt(l) ? wi : di;
|
|
1046
1046
|
return d.test(ys(l));
|
|
1047
1047
|
}
|
|
1048
1048
|
function Qi(l) {
|
|
@@ -1074,8 +1074,8 @@ function cn() {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
var z = E ? E(L, I, m + "", l, d, F) : void 0, dt = z === void 0;
|
|
1076
1076
|
if (dt) {
|
|
1077
|
-
var
|
|
1078
|
-
z = I,
|
|
1077
|
+
var Wt = Vt(I), Ut = !Wt && Ce(I), ke = !Wt && !Ut && Ae(I);
|
|
1078
|
+
z = I, Wt || Ut || ke ? Vt(L) ? z = L : xs(L) ? z = as(L) : Ut ? (dt = !1, z = ss(I)) : ke ? (dt = !1, z = rs(I)) : z = [] : ws(I) || Yt(I) ? (z = L, Yt(L) ? z = Cs(L) : (!et(L) || Xt(L)) && (z = ds(I))) : dt = !1;
|
|
1079
1079
|
}
|
|
1080
1080
|
dt && (F.set(I, z), S(z, I, M, E, F), F.delete(I)), Rt(l, m, z);
|
|
1081
1081
|
}
|
|
@@ -1237,13 +1237,13 @@ function cn() {
|
|
|
1237
1237
|
return ht(l) && J.call(l, "callee") && !Ci.call(l, "callee");
|
|
1238
1238
|
}, Vt = Array.isArray;
|
|
1239
1239
|
function jt(l) {
|
|
1240
|
-
return l != null && Me(l.length) && !
|
|
1240
|
+
return l != null && Me(l.length) && !Xt(l);
|
|
1241
1241
|
}
|
|
1242
1242
|
function xs(l) {
|
|
1243
1243
|
return ht(l) && jt(l);
|
|
1244
1244
|
}
|
|
1245
1245
|
var Ce = Ai || Ts;
|
|
1246
|
-
function
|
|
1246
|
+
function Xt(l) {
|
|
1247
1247
|
if (!et(l))
|
|
1248
1248
|
return !1;
|
|
1249
1249
|
var d = Ct(l);
|
|
@@ -2394,7 +2394,7 @@ A.prototype = {
|
|
|
2394
2394
|
return this._r = s._r, this._g = s._g, this._b = s._b, this.setAlpha(s._a), this;
|
|
2395
2395
|
},
|
|
2396
2396
|
lighten: function() {
|
|
2397
|
-
return this._applyModification(
|
|
2397
|
+
return this._applyModification(Wn, arguments);
|
|
2398
2398
|
},
|
|
2399
2399
|
brighten: function() {
|
|
2400
2400
|
return this._applyModification(Un, arguments);
|
|
@@ -2409,7 +2409,7 @@ A.prototype = {
|
|
|
2409
2409
|
return this._applyModification(jn, arguments);
|
|
2410
2410
|
},
|
|
2411
2411
|
greyscale: function() {
|
|
2412
|
-
return this._applyModification(
|
|
2412
|
+
return this._applyModification(Xn, arguments);
|
|
2413
2413
|
},
|
|
2414
2414
|
spin: function() {
|
|
2415
2415
|
return this._applyModification(Zn, arguments);
|
|
@@ -2434,10 +2434,10 @@ A.prototype = {
|
|
|
2434
2434
|
// return this._applyCombination(polyad, [number]);
|
|
2435
2435
|
// },
|
|
2436
2436
|
triad: function() {
|
|
2437
|
-
return this._applyCombination(
|
|
2437
|
+
return this._applyCombination(Xe, [3]);
|
|
2438
2438
|
},
|
|
2439
2439
|
tetrad: function() {
|
|
2440
|
-
return this._applyCombination(
|
|
2440
|
+
return this._applyCombination(Xe, [4]);
|
|
2441
2441
|
}
|
|
2442
2442
|
};
|
|
2443
2443
|
A.fromRatio = function(i, t) {
|
|
@@ -2550,15 +2550,15 @@ function On(i, t, e) {
|
|
|
2550
2550
|
};
|
|
2551
2551
|
}
|
|
2552
2552
|
function Ve(i, t, e, s) {
|
|
2553
|
-
var n = [
|
|
2553
|
+
var n = [X(Math.round(i).toString(16)), X(Math.round(t).toString(16)), X(Math.round(e).toString(16))];
|
|
2554
2554
|
return s && n[0].charAt(0) == n[0].charAt(1) && n[1].charAt(0) == n[1].charAt(1) && n[2].charAt(0) == n[2].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) : n.join("");
|
|
2555
2555
|
}
|
|
2556
2556
|
function Yn(i, t, e, s, n) {
|
|
2557
|
-
var r = [
|
|
2557
|
+
var r = [X(Math.round(i).toString(16)), X(Math.round(t).toString(16)), X(Math.round(e).toString(16)), X(Ke(s))];
|
|
2558
2558
|
return n && r[0].charAt(0) == r[0].charAt(1) && r[1].charAt(0) == r[1].charAt(1) && r[2].charAt(0) == r[2].charAt(1) && r[3].charAt(0) == r[3].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) + r[3].charAt(0) : r.join("");
|
|
2559
2559
|
}
|
|
2560
2560
|
function je(i, t, e, s) {
|
|
2561
|
-
var n = [
|
|
2561
|
+
var n = [X(Ke(s)), X(Math.round(i).toString(16)), X(Math.round(t).toString(16)), X(Math.round(e).toString(16))];
|
|
2562
2562
|
return n.join("");
|
|
2563
2563
|
}
|
|
2564
2564
|
A.equals = function(i, t) {
|
|
@@ -2581,10 +2581,10 @@ function jn(i, t) {
|
|
|
2581
2581
|
var e = A(i).toHsl();
|
|
2582
2582
|
return e.s += t / 100, e.s = It(e.s), A(e);
|
|
2583
2583
|
}
|
|
2584
|
-
function
|
|
2584
|
+
function Xn(i) {
|
|
2585
2585
|
return A(i).desaturate(100);
|
|
2586
2586
|
}
|
|
2587
|
-
function
|
|
2587
|
+
function Wn(i, t) {
|
|
2588
2588
|
t = t === 0 ? 0 : t || 10;
|
|
2589
2589
|
var e = A(i).toHsl();
|
|
2590
2590
|
return e.l += t / 100, e.l = It(e.l), A(e);
|
|
@@ -2607,7 +2607,7 @@ function qn(i) {
|
|
|
2607
2607
|
var t = A(i).toHsl();
|
|
2608
2608
|
return t.h = (t.h + 180) % 360, A(t);
|
|
2609
2609
|
}
|
|
2610
|
-
function
|
|
2610
|
+
function Xe(i, t) {
|
|
2611
2611
|
if (isNaN(t) || t <= 0)
|
|
2612
2612
|
throw new Error("Argument to polyad must be a positive number");
|
|
2613
2613
|
for (var e = A(i).toHsl(), s = [A(i)], n = 360 / t, r = 1; r < t; r++)
|
|
@@ -2864,7 +2864,7 @@ function ir(i) {
|
|
|
2864
2864
|
function sr(i) {
|
|
2865
2865
|
return typeof i == "string" && i.indexOf("%") != -1;
|
|
2866
2866
|
}
|
|
2867
|
-
function
|
|
2867
|
+
function X(i) {
|
|
2868
2868
|
return i.length == 1 ? "0" + i : "" + i;
|
|
2869
2869
|
}
|
|
2870
2870
|
function gt(i) {
|
|
@@ -2873,7 +2873,7 @@ function gt(i) {
|
|
|
2873
2873
|
function Ke(i) {
|
|
2874
2874
|
return Math.round(parseFloat(i) * 255).toString(16);
|
|
2875
2875
|
}
|
|
2876
|
-
function
|
|
2876
|
+
function We(i) {
|
|
2877
2877
|
return P(i) / 255;
|
|
2878
2878
|
}
|
|
2879
2879
|
var j = function() {
|
|
@@ -2940,7 +2940,7 @@ function nr(i) {
|
|
|
2940
2940
|
r: P(e[1]),
|
|
2941
2941
|
g: P(e[2]),
|
|
2942
2942
|
b: P(e[3]),
|
|
2943
|
-
a:
|
|
2943
|
+
a: We(e[4]),
|
|
2944
2944
|
format: t ? "name" : "hex8"
|
|
2945
2945
|
} : (e = j.hex6.exec(i)) ? {
|
|
2946
2946
|
r: P(e[1]),
|
|
@@ -2951,7 +2951,7 @@ function nr(i) {
|
|
|
2951
2951
|
r: P(e[1] + "" + e[1]),
|
|
2952
2952
|
g: P(e[2] + "" + e[2]),
|
|
2953
2953
|
b: P(e[3] + "" + e[3]),
|
|
2954
|
-
a:
|
|
2954
|
+
a: We(e[4] + "" + e[4]),
|
|
2955
2955
|
format: t ? "name" : "hex8"
|
|
2956
2956
|
} : (e = j.hex3.exec(i)) ? {
|
|
2957
2957
|
r: P(e[1] + "" + e[1]),
|
|
@@ -4030,7 +4030,7 @@ class jr extends Ft {
|
|
|
4030
4030
|
};
|
|
4031
4031
|
}
|
|
4032
4032
|
}
|
|
4033
|
-
class
|
|
4033
|
+
class Xr extends pt {
|
|
4034
4034
|
constructor(e) {
|
|
4035
4035
|
super("candles", e, { CanvasClass: jr });
|
|
4036
4036
|
u(this, "noDataTooltip");
|
|
@@ -4048,7 +4048,7 @@ class Wr extends pt {
|
|
|
4048
4048
|
}
|
|
4049
4049
|
}
|
|
4050
4050
|
}
|
|
4051
|
-
class
|
|
4051
|
+
class Wr {
|
|
4052
4052
|
constructor(t) {
|
|
4053
4053
|
u(this, "container");
|
|
4054
4054
|
u(this, "width");
|
|
@@ -4070,7 +4070,7 @@ class Xr {
|
|
|
4070
4070
|
width: e,
|
|
4071
4071
|
height: s,
|
|
4072
4072
|
isMain: !0
|
|
4073
|
-
}), this.domElements = new k({ tag: "div", className: "sc-charts-cs__dom-elements" }), this.canvasesContainer = new k({ tag: "div", className: "sc-charts-cs__canvases" }), this.canvasesContainer.append(this.mainCanvas.node), this.wrapper.append(this.canvasesContainer.node, this.domElements.node), this.mainCanvas.updateAbsolutePosition(), this.binding = new Fn(this.mainCanvas.node), this.userMarkers = new br(this), this.comments = new $r(this), this.candles = new
|
|
4073
|
+
}), this.domElements = new k({ tag: "div", className: "sc-charts-cs__dom-elements" }), this.canvasesContainer = new k({ tag: "div", className: "sc-charts-cs__canvases" }), this.canvasesContainer.append(this.mainCanvas.node), this.wrapper.append(this.canvasesContainer.node, this.domElements.node), this.mainCanvas.updateAbsolutePosition(), this.binding = new Fn(this.mainCanvas.node), this.userMarkers = new br(this), this.comments = new $r(this), this.candles = new Xr(this), this.trade = new vr(this), this.guideMarkers = new Yr(this);
|
|
4074
4074
|
}
|
|
4075
4075
|
renderAll(t) {
|
|
4076
4076
|
this.mainCanvas.clear(), this.candles.render(t), Jt.xAxis(this.mainCanvas.ctx, t), Jt.yAxis(this.mainCanvas.ctx, t), Jt.intersection(this.mainCanvas.ctx, t), this.trade.renderAll(t), this.userMarkers.render(t.userMarkers.data), this.comments.render(t);
|
|
@@ -4498,16 +4498,22 @@ function na(i, t) {
|
|
|
4498
4498
|
};
|
|
4499
4499
|
}
|
|
4500
4500
|
class ra {
|
|
4501
|
-
constructor(t, e) {
|
|
4501
|
+
constructor(t, e, s) {
|
|
4502
4502
|
u(this, "_model");
|
|
4503
4503
|
u(this, "_hitManager");
|
|
4504
4504
|
u(this, "_hit");
|
|
4505
|
-
this
|
|
4505
|
+
u(this, "_view");
|
|
4506
|
+
this._model = t, this._hitManager = e, this._hit = new ta(t), this._hitManager.register(this._hit), this._view = s;
|
|
4507
|
+
}
|
|
4508
|
+
_limitDx(t) {
|
|
4509
|
+
if (!this._view || t <= 0) return t;
|
|
4510
|
+
const { width: e } = this._view.candles.limiter.absolutePosition, s = this._model.config.candles.limiterOffset, n = this._model.scales.x.convert(this._model.candles.allData[0].open_time), r = this._model.layout.chart.left, a = n - s * 2 - e;
|
|
4511
|
+
return a >= r ? 0 : a + t >= r ? r - a : t;
|
|
4506
4512
|
}
|
|
4507
4513
|
register() {
|
|
4508
4514
|
this._hitManager.on(this._hit, "drag", (t) => {
|
|
4509
|
-
|
|
4510
|
-
this._model.scales.scale("x", -e);
|
|
4515
|
+
let e = t.x - (t.prevX ?? t.x);
|
|
4516
|
+
e = this._limitDx(e), this._model.scales.scale("x", -e);
|
|
4511
4517
|
}), this._hitManager.on(this._hit, "dblclick", () => {
|
|
4512
4518
|
this._model.scales.scale("x", 1, "absolute"), this._model.scales.pan("x", 0, "absolute");
|
|
4513
4519
|
});
|
|
@@ -4537,6 +4543,11 @@ class oa {
|
|
|
4537
4543
|
u(this, "_hit");
|
|
4538
4544
|
this._model = t, this._view = e, this._hitManager = s, this._hit = new ea(t), this._hitManager.register(this._hit);
|
|
4539
4545
|
}
|
|
4546
|
+
_limitDx(t) {
|
|
4547
|
+
if (t <= 0) return t;
|
|
4548
|
+
const { width: e } = this._view.candles.limiter.absolutePosition, s = this._model.config.candles.limiterOffset, n = this._model.scales.x.convert(this._model.candles.allData[0].open_time), r = this._model.layout.chart.left, a = n - s * 2 - e;
|
|
4549
|
+
return a >= r ? 0 : a + t >= r ? r - a : t;
|
|
4550
|
+
}
|
|
4540
4551
|
register() {
|
|
4541
4552
|
this._hitManager.on(
|
|
4542
4553
|
this._hit,
|
|
@@ -4550,8 +4561,9 @@ class oa {
|
|
|
4550
4561
|
this._hit,
|
|
4551
4562
|
"drag",
|
|
4552
4563
|
na(1, (t) => {
|
|
4553
|
-
|
|
4554
|
-
|
|
4564
|
+
let e = t.x - (t.prevX ?? t.x);
|
|
4565
|
+
const s = t.y - (t.prevY ?? t.y);
|
|
4566
|
+
e = this._limitDx(e), this._model.scales.pan("x", e), this._model.scales.pan("y", s), this._view.guideMarkers.render(this._model, { x: t.x, y: t.y });
|
|
4555
4567
|
})
|
|
4556
4568
|
), this._hitManager.on(this._hit, "contextmenu", ({ x: t }) => {
|
|
4557
4569
|
const e = this._model.scales.x.invert(t), s = se.findByDate(e, this._model.candles.allData);
|
|
@@ -4563,7 +4575,12 @@ class oa {
|
|
|
4563
4575
|
var n, r;
|
|
4564
4576
|
if (!t.deltaY) return;
|
|
4565
4577
|
const e = -t.deltaY, s = (r = (n = this._model.config) == null ? void 0 : n.candles) == null ? void 0 : r.zoomOnWheel;
|
|
4566
|
-
["x", "both"].includes(s)
|
|
4578
|
+
if (["x", "both"].includes(s)) {
|
|
4579
|
+
this._model.scales.scale("x", e);
|
|
4580
|
+
const a = this._limitDx(0);
|
|
4581
|
+
a !== 0 && this._model.scales.pan("x", a);
|
|
4582
|
+
}
|
|
4583
|
+
["y", "both"].includes(s) && this._model.scales.scale("y", e);
|
|
4567
4584
|
});
|
|
4568
4585
|
}
|
|
4569
4586
|
}
|
|
@@ -4669,9 +4686,9 @@ class ua {
|
|
|
4669
4686
|
userMarkers: a,
|
|
4670
4687
|
colorScheme: o,
|
|
4671
4688
|
comments: c
|
|
4672
|
-
}), this._view = new
|
|
4689
|
+
}), this._view = new Wr(f), this._controller = new ca(this._model, this._view), h) {
|
|
4673
4690
|
const g = h(this._view.candles.limiter.node);
|
|
4674
|
-
typeof g == "function" && (this._candlesLimiterClean = g);
|
|
4691
|
+
this._view.candles.limiter.updateAbsolutePosition(), typeof g == "function" && (this._candlesLimiterClean = g);
|
|
4675
4692
|
}
|
|
4676
4693
|
this._controller.init();
|
|
4677
4694
|
}
|