charts-core 1.1.9 → 1.1.10
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 +462 -462
- package/dist/charts-core.js.map +1 -1
- package/dist/charts-core.umd.cjs +3 -3
- package/dist/charts-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/charts-core.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var Ti = Object.defineProperty;
|
|
2
2
|
var Si = (s, t, e) => t in s ? Ti(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import * as
|
|
3
|
+
var h = (s, t, e) => Si(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import * as E from "d3";
|
|
5
5
|
const ki = (s) => {
|
|
6
|
-
const { svg: t, config: e, y: i, width: n } = s, { margin: r, yAxis: a } = e, { customTicks: l, tickFormat:
|
|
6
|
+
const { svg: t, config: e, y: i, width: n } = s, { margin: r, yAxis: a } = e, { customTicks: l, tickFormat: d, tickValues: c, ticks: g, isShow: _ } = a;
|
|
7
7
|
if (!_) return null;
|
|
8
8
|
t.append("g").attr("transform", `translate(${n - r.right},0)`).call((m) => {
|
|
9
|
-
let p =
|
|
10
|
-
l &&
|
|
9
|
+
let p = E.axisRight(i);
|
|
10
|
+
l && d ? p = p.tickFormat(d) : p = p.tickFormat((v) => {
|
|
11
11
|
const b = Number(v), x = (C) => C.toString().replace(/\.0+$/, "");
|
|
12
12
|
return Math.abs(b) >= 1e12 ? x(b / 1e12) + "T" : Math.abs(b) >= 1e9 ? x(b / 1e9) + "B" : Math.abs(b) >= 1e6 ? x(b / 1e6) + "M" : Math.abs(b) >= 1e3 ? x(b / 1e3) + "K" : x(b);
|
|
13
|
-
}), l && g && (p = Array.isArray(g) ? p.ticks(...g) : p.ticks(g)), l &&
|
|
13
|
+
}), l && g && (p = Array.isArray(g) ? p.ticks(...g) : p.ticks(g)), l && c && (p = p.tickValues(c)), m.call(p);
|
|
14
14
|
}).call((m) => {
|
|
15
15
|
let p = [];
|
|
16
16
|
m.selectAll(".tick").each((v) => p.push(v)), s.yTicks = p;
|
|
@@ -20,16 +20,16 @@ const ki = (s) => {
|
|
|
20
20
|
const v = p.nodes().map((x) => x.getBBox().width), b = Math.max(...v);
|
|
21
21
|
m.selectAll(".tick").each(function(x, C) {
|
|
22
22
|
var z;
|
|
23
|
-
const w =
|
|
23
|
+
const w = E.select(this), y = w.select("text"), T = v[C], D = b - T, N = w.append("g").attr("transform", "translate(10, 0)");
|
|
24
24
|
y.attr("x", D), y.remove(), (z = N.node()) == null || z.appendChild(y.node());
|
|
25
25
|
});
|
|
26
26
|
}).attr("font-family", "inherit");
|
|
27
27
|
}, Di = (s) => {
|
|
28
|
-
const { svg: t, config: e, x: i, height: n } = s, { margin: r, xAxis: a } = e, { isShow: l, tickValues:
|
|
28
|
+
const { svg: t, config: e, x: i, height: n } = s, { margin: r, xAxis: a } = e, { isShow: l, tickValues: d, tickFormat: c, customTicks: g, ticks: _ } = a;
|
|
29
29
|
if (!l) return null;
|
|
30
30
|
t.append("g").attr("transform", `translate(0,${n - r.bottom})`).call((m) => {
|
|
31
|
-
let p =
|
|
32
|
-
g ? (
|
|
31
|
+
let p = E.axisBottom(i);
|
|
32
|
+
g ? (c && (p = p.tickFormat(c)), _ && (p = Array.isArray(_) ? p.ticks(..._) : p.ticks(_)), d && (p = p.tickValues(d))) : p.ticks(5), m.call(p);
|
|
33
33
|
}).call((m) => m.select(".domain").remove()).call((m) => {
|
|
34
34
|
let p = [];
|
|
35
35
|
m.selectAll(".tick").each((v) => p.push(v)), s.xTicks = p;
|
|
@@ -44,9 +44,9 @@ const ki = (s) => {
|
|
|
44
44
|
const l = t.append("line").attr("x1", 0 + r.left).attr("x2", n - r.right).attr("y1", i(0)).attr("y2", i(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
45
45
|
a === "zero-line-dashed" && l.attr("stroke-dasharray", "4 4");
|
|
46
46
|
}
|
|
47
|
-
a.startsWith("every-line") && (s.yTicks || i.ticks()).forEach((
|
|
48
|
-
const
|
|
49
|
-
a === "every-line-dashed" &&
|
|
47
|
+
a.startsWith("every-line") && (s.yTicks || i.ticks()).forEach((d) => {
|
|
48
|
+
const c = t.append("line").attr("x1", 0 + r.left).attr("x2", n - r.right).attr("y1", i(d)).attr("y2", i(d)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
49
|
+
a === "every-line-dashed" && c.attr("stroke-dasharray", "4 4");
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}, Li = (s) => {
|
|
@@ -91,13 +91,13 @@ function Fi(s, t, e, i) {
|
|
|
91
91
|
}
|
|
92
92
|
const Se = (s, { x1: t, x2: e, y1: i, y2: n }) => s.append("line").attr("x1", t).attr("x2", e).attr("y1", i).attr("y2", n).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1), Bi = (s) => {
|
|
93
93
|
const { svg: t, config: e, x: i, y: n, height: r, data: a, wrapperNode: l } = s, {
|
|
94
|
-
margin:
|
|
95
|
-
grid: { verticalStyle:
|
|
94
|
+
margin: d,
|
|
95
|
+
grid: { verticalStyle: c, tooltipNode: g, hoverCirclesRadius: _, hoverCirclesAdditionalArea: m }
|
|
96
96
|
} = e;
|
|
97
|
-
if (
|
|
98
|
-
const b = t.append("line").attr("x1", i(v)).attr("x2", i(v)).attr("y1",
|
|
99
|
-
|
|
100
|
-
}),
|
|
97
|
+
if (c !== "none" && (c.startsWith("every-line") && (s.xTicks || i.ticks()).forEach((v) => {
|
|
98
|
+
const b = t.append("line").attr("x1", i(v)).attr("x2", i(v)).attr("y1", d.top).attr("y2", r - d.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
99
|
+
c === "every-line-dashed" && b.attr("stroke-dasharray", "4 4");
|
|
100
|
+
}), c === "hovered-circles")) {
|
|
101
101
|
const p = n.range()[0], v = i(a[0].date), b = i(a[a.length - 1].date);
|
|
102
102
|
Se(t, { x1: v, x2: b, y1: p, y2: p });
|
|
103
103
|
const { tooltipContainer: x, tooltip: C, tooltipArrow: w } = Ni(l);
|
|
@@ -135,8 +135,8 @@ const Se = (s, { x1: t, x2: e, y1: i, y2: n }) => s.append("line").attr("x1", t)
|
|
|
135
135
|
i.append("stop").attr("offset", n).attr("stop-color", r);
|
|
136
136
|
}), i;
|
|
137
137
|
}, nt = (s) => {
|
|
138
|
-
const t =
|
|
139
|
-
return t.empty() ?
|
|
138
|
+
const t = E.select(s).select("defs");
|
|
139
|
+
return t.empty() ? E.select(s).append("defs") : t;
|
|
140
140
|
}, Ge = (s) => {
|
|
141
141
|
const {
|
|
142
142
|
y: t,
|
|
@@ -179,26 +179,26 @@ const Se = (s, { x1: t, x2: e, y1: i, y2: n }) => s.append("line").attr("x1", t)
|
|
|
179
179
|
...t == null ? void 0 : t.selection
|
|
180
180
|
}
|
|
181
181
|
}), De = (s, t = {}) => {
|
|
182
|
-
const e = s.node(), i = nt(e), n = (l,
|
|
182
|
+
const e = s.node(), i = nt(e), n = (l, d) => _t(i, l, {
|
|
183
183
|
x1: "0%",
|
|
184
184
|
y1: "0%",
|
|
185
185
|
x2: "0%",
|
|
186
186
|
y2: "100%",
|
|
187
187
|
stops: [
|
|
188
188
|
{ offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
|
|
189
|
-
{ offset: "20%", stopColor:
|
|
190
|
-
{ offset: "60%", stopColor:
|
|
189
|
+
{ offset: "20%", stopColor: d },
|
|
190
|
+
{ offset: "60%", stopColor: d },
|
|
191
191
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
192
192
|
]
|
|
193
193
|
});
|
|
194
194
|
n("gradient-range-borders-up", "var(--sc-color-selection-up)"), n("gradient-range-borders-down", "var(--sc-color-selection-down)");
|
|
195
195
|
const r = "sc-charts__border-range-line", a = s.append("line").classed(r, !0).style("display", t.hidden ? "none" : "block");
|
|
196
196
|
return {
|
|
197
|
-
className(l,
|
|
198
|
-
l === "remove" ? a.classed(`${r}${
|
|
197
|
+
className(l, d) {
|
|
198
|
+
l === "remove" ? a.classed(`${r}${d}`, !1) : a.classed(`${r}${d}`, !0);
|
|
199
199
|
},
|
|
200
|
-
update({ x1: l, x2:
|
|
201
|
-
l !== void 0 && a.attr("x1", l),
|
|
200
|
+
update({ x1: l, x2: d, y1: c, y2: g, hidden: _ }) {
|
|
201
|
+
l !== void 0 && a.attr("x1", l), d !== void 0 && a.attr("x2", d), c !== void 0 && a.attr("y1", c), g !== void 0 && a.attr("y2", g), _ !== void 0 && a.style("display", _ ? "none" : "block");
|
|
202
202
|
},
|
|
203
203
|
destroy() {
|
|
204
204
|
a.remove();
|
|
@@ -219,30 +219,30 @@ const Se = (s, { x1: t, x2: e, y1: i, y2: n }) => s.append("line").attr("x1", t)
|
|
|
219
219
|
};
|
|
220
220
|
}, zi = (s, t = {}) => {
|
|
221
221
|
const e = "sc-charts__hover-line", i = s.append("line").style("display", t.hidden ? "none" : "block").classed(e, !0), n = s.node(), r = nt(n);
|
|
222
|
-
return ((l,
|
|
222
|
+
return ((l, d) => _t(r, l, {
|
|
223
223
|
x1: "0%",
|
|
224
224
|
y1: "0%",
|
|
225
225
|
x2: "0%",
|
|
226
226
|
y2: "100%",
|
|
227
227
|
stops: [
|
|
228
228
|
{ offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
|
|
229
|
-
{ offset: "15%", stopColor:
|
|
230
|
-
{ offset: "75%", stopColor:
|
|
229
|
+
{ offset: "15%", stopColor: d },
|
|
230
|
+
{ offset: "75%", stopColor: d },
|
|
231
231
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
232
232
|
]
|
|
233
233
|
}))("hover-line-gradient", "var(--sc-color-hover-line)"), {
|
|
234
|
-
className(l,
|
|
235
|
-
l === "remove" ? i.classed(`${e}${
|
|
234
|
+
className(l, d) {
|
|
235
|
+
l === "remove" ? i.classed(`${e}${d}`, !1) : i.classed(`${e}${d}`, !0);
|
|
236
236
|
},
|
|
237
|
-
update({ x1: l, x2:
|
|
238
|
-
l !== void 0 && i.attr("x1", l),
|
|
237
|
+
update({ x1: l, x2: d, y1: c, y2: g, hidden: _ }) {
|
|
238
|
+
l !== void 0 && i.attr("x1", l), d !== void 0 && i.attr("x2", d), c !== void 0 && i.attr("y1", c), g !== void 0 && i.attr("y2", g), _ !== void 0 && i.style("display", _ ? "none" : "block");
|
|
239
239
|
},
|
|
240
240
|
destroy() {
|
|
241
241
|
i.remove();
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
}, tt = "sc-charts__range-tooltip", Ee =
|
|
245
|
-
const t =
|
|
244
|
+
}, tt = "sc-charts__range-tooltip", Ee = E.timeFormat("%b %e, %I:%M %p"), $i = (s) => {
|
|
245
|
+
const t = E.format(",.2f");
|
|
246
246
|
return `${s < 0 ? "-" : ""}$${t(Math.abs(s))}`;
|
|
247
247
|
};
|
|
248
248
|
function Pi(s) {
|
|
@@ -261,10 +261,10 @@ function Pi(s) {
|
|
|
261
261
|
"d",
|
|
262
262
|
"M7 0.5C5.71442 0.5 4.45772 0.881218 3.3888 1.59545C2.31988 2.30968 1.48676 3.32484 0.994786 4.51256C0.502816 5.70028 0.374095 7.00721 0.624899 8.26809C0.875703 9.52896 1.49477 10.6872 2.40381 11.5962C3.31285 12.5052 4.47104 13.1243 5.73192 13.3751C6.99279 13.6259 8.29973 13.4972 9.48744 13.0052C10.6752 12.5132 11.6903 11.6801 12.4046 10.6112C13.1188 9.54229 13.5 8.28558 13.5 7C13.4982 5.27665 12.8128 3.62441 11.5942 2.40582C10.3756 1.18722 8.72335 0.50182 7 0.5ZM9.35375 6.85375C9.30732 6.90024 9.25217 6.93712 9.19147 6.96228C9.13077 6.98744 9.06571 7.00039 9 7.00039C8.93429 7.00039 8.86923 6.98744 8.80853 6.96228C8.74783 6.93712 8.69269 6.90024 8.64625 6.85375L7.5 5.70687V9.5C7.5 9.63261 7.44732 9.75979 7.35356 9.85355C7.25979 9.94732 7.13261 10 7 10C6.86739 10 6.74022 9.94732 6.64645 9.85355C6.55268 9.75979 6.5 9.63261 6.5 9.5V5.70687L5.35375 6.85375C5.25993 6.94757 5.13268 7.00028 5 7.00028C4.86732 7.00028 4.74007 6.94757 4.64625 6.85375C4.55243 6.75993 4.49972 6.63268 4.49972 6.5C4.49972 6.36732 4.55243 6.24007 4.64625 6.14625L6.64625 4.14625C6.69269 4.09976 6.74783 4.06288 6.80853 4.03772C6.86923 4.01256 6.9343 3.99961 7 3.99961C7.06571 3.99961 7.13077 4.01256 7.19147 4.03772C7.25217 4.06288 7.30732 4.09976 7.35375 4.14625L9.35375 6.14625C9.40024 6.19269 9.43712 6.24783 9.46228 6.30853C9.48744 6.36923 9.5004 6.43429 9.5004 6.5C9.5004 6.56571 9.48744 6.63077 9.46228 6.69147C9.43712 6.75217 9.40024 6.80731 9.35375 6.85375Z"
|
|
263
263
|
), l.setAttribute("fill", "currentColor"), a.appendChild(l), r.appendChild(a), n.append(r);
|
|
264
|
+
const d = document.createElement("div");
|
|
265
|
+
n.append(d);
|
|
264
266
|
const c = document.createElement("div");
|
|
265
|
-
|
|
266
|
-
const h = document.createElement("div");
|
|
267
|
-
return h.className = `${tt}-time`, i.append(h), { wrapper: e, sumNode: c, timeNode: h };
|
|
267
|
+
return c.className = `${tt}-time`, i.append(c), { wrapper: e, sumNode: d, timeNode: c };
|
|
268
268
|
}
|
|
269
269
|
const Oi = (s) => {
|
|
270
270
|
const { wrapper: t, sumNode: e, timeNode: i } = Pi(s.wrapperNode);
|
|
@@ -272,9 +272,9 @@ const Oi = (s) => {
|
|
|
272
272
|
className(n, r) {
|
|
273
273
|
n === "remove" ? t.classList.remove(`${tt}${r}`) : t.classList.add(`${tt}${r}`);
|
|
274
274
|
},
|
|
275
|
-
update({ leftPoint: n, rightPoint: r, x: a, y: l, hidden:
|
|
276
|
-
if (n && r &&
|
|
277
|
-
const g = r.value - n.value, { sumFormatter: _, timeFormatter: m } = s.config.selection, p = (s.x(r.date) + s.x(n.date)) / 2, v = s.x(
|
|
275
|
+
update({ leftPoint: n, rightPoint: r, x: a, y: l, hidden: d, closest: c }) {
|
|
276
|
+
if (n && r && c && a !== void 0) {
|
|
277
|
+
const g = r.value - n.value, { sumFormatter: _, timeFormatter: m } = s.config.selection, p = (s.x(r.date) + s.x(n.date)) / 2, v = s.x(c.date) < p ? "left" : "right";
|
|
278
278
|
let b = "", x = "";
|
|
279
279
|
if (_)
|
|
280
280
|
b = _({ left: n.value, right: r.value, direction: v });
|
|
@@ -289,14 +289,14 @@ const Oi = (s) => {
|
|
|
289
289
|
N < z && (N = z), N > O && (N = O), t.style.left = `${N}px`, t.style.top = `${l}px`;
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
d !== void 0 && (t.style.display = d ? "none" : "block");
|
|
293
293
|
},
|
|
294
294
|
destroy() {
|
|
295
295
|
t.remove();
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
}, gt = "sc-charts__hover-tooltip", Ut = 16, Yi =
|
|
299
|
-
const t =
|
|
298
|
+
}, gt = "sc-charts__hover-tooltip", Ut = 16, Yi = E.timeFormat("%a, %b %d, %-I:%M %p"), ji = (s) => {
|
|
299
|
+
const t = E.format(",.2f");
|
|
300
300
|
return `${s < 0 ? "-" : ""}$${t(Math.abs(s))}`;
|
|
301
301
|
};
|
|
302
302
|
function Xi(s) {
|
|
@@ -320,12 +320,12 @@ const Vi = (s) => {
|
|
|
320
320
|
if (r) {
|
|
321
321
|
const { sumFormatter: a, timeFormatter: l } = s.config.hover;
|
|
322
322
|
e.textContent = a ? a(r.value) : ji(r.value), i.textContent = l ? l(r.date) : Yi(r.date), requestAnimationFrame(() => {
|
|
323
|
-
const
|
|
324
|
-
|
|
323
|
+
const d = t.getBoundingClientRect(), c = Wi(
|
|
324
|
+
d,
|
|
325
325
|
s.x(r.date),
|
|
326
326
|
s.width - s.config.margin.right
|
|
327
327
|
);
|
|
328
|
-
|
|
328
|
+
c && (t.style.left = c + "px");
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
n !== void 0 && (t.style.display = n ? "none" : "block");
|
|
@@ -385,7 +385,7 @@ const Vi = (s) => {
|
|
|
385
385
|
},
|
|
386
386
|
enableBelowZeroLine: !1,
|
|
387
387
|
curveTension: 1
|
|
388
|
-
}, Et = (s) =>
|
|
388
|
+
}, Et = (s) => E.curveCardinal.tension(s.config.curveTension), Ui = (s) => {
|
|
389
389
|
const { svg: t, data: e, x: i, y: n, config: r } = s, a = t.node(), l = nt(a);
|
|
390
390
|
_t(l, "main-line-area-gradient", {
|
|
391
391
|
x1: "0%",
|
|
@@ -397,13 +397,13 @@ const Vi = (s) => {
|
|
|
397
397
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
398
398
|
]
|
|
399
399
|
});
|
|
400
|
-
const
|
|
400
|
+
const c = E.area().x((m) => i(m.date)).y0(n.range()[0]).y1((m) => n(m.value)).curve(Et(s)), g = "sc-charts__main-line-area", _ = t.append("path").datum(e).attr("d", c).attr("class", g).classed(`${g}_hidden`, !r.hasMainLineArea);
|
|
401
401
|
return {
|
|
402
402
|
className(m, p) {
|
|
403
403
|
m === "remove" ? _.classed(`${g}${p}`, !1) : _.classed(`${g}${p}`, !0);
|
|
404
404
|
},
|
|
405
405
|
update({ data: m, hidden: p }) {
|
|
406
|
-
if (m !== void 0 && _.datum(m).attr("d",
|
|
406
|
+
if (m !== void 0 && _.datum(m).attr("d", c), p !== void 0) {
|
|
407
407
|
if (!r.hasMainLineArea) return null;
|
|
408
408
|
_.classed(`${g}_hidden`, p);
|
|
409
409
|
}
|
|
@@ -413,7 +413,7 @@ const Vi = (s) => {
|
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
415
|
}, Zi = (s, t = {}) => {
|
|
416
|
-
const e = "sc-charts__range-line-area", { svg: i, x: n, y: r, config: a, data: l, chartId:
|
|
416
|
+
const e = "sc-charts__range-line-area", { svg: i, x: n, y: r, config: a, data: l, chartId: d } = s, { clip: c } = t, g = i.node(), _ = nt(g), m = "range-line-area-gradient";
|
|
417
417
|
_t(_, m + "_up", {
|
|
418
418
|
x1: "0%",
|
|
419
419
|
y1: "0%",
|
|
@@ -433,7 +433,7 @@ const Vi = (s) => {
|
|
|
433
433
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
434
434
|
]
|
|
435
435
|
});
|
|
436
|
-
const p =
|
|
436
|
+
const p = E.area().x((w) => n(w.date)).y0(r.range()[0]).y1((w) => r(w.value)).curve(Et(s)), v = `${d}-clip-${e}`, x = _.append("clipPath").attr("id", v).append("rect").attr("x", (c == null ? void 0 : c.x) || 0).attr("y", (c == null ? void 0 : c.y) || 0).attr("width", (c == null ? void 0 : c.width) || "100%").attr("height", (c == null ? void 0 : c.height) || "100%"), C = i.append("path").datum(l).attr("d", p).attr("class", e).classed(`${e}_hidden`, !a.hasMainLineArea).attr("clip-path", `url(#${v})`);
|
|
437
437
|
return {
|
|
438
438
|
className(w, y) {
|
|
439
439
|
w === "remove" ? C.classed(`${e}${y}`, !1) : C.classed(`${e}${y}`, !0);
|
|
@@ -446,7 +446,7 @@ const Vi = (s) => {
|
|
|
446
446
|
}
|
|
447
447
|
};
|
|
448
448
|
}, Zt = (s, t) => {
|
|
449
|
-
const { svg: e, data: i, x: n, y: r, chartId: a } = s, { baseClassName: l, id:
|
|
449
|
+
const { svg: e, data: i, x: n, y: r, chartId: a } = s, { baseClassName: l, id: d, clip: c } = t, g = e.node(), _ = nt(g), m = E.line().x((C) => n(C.date)).y((C) => r(C.value)).curve(Et(s)), p = `${a}-clip-${l}`, b = _.append("clipPath").attr("id", p).append("rect").attr("x", (c == null ? void 0 : c.x) || 0).attr("y", (c == null ? void 0 : c.y) || 0).attr("width", (c == null ? void 0 : c.width) || "100%").attr("height", (c == null ? void 0 : c.height) || "100%"), x = e.append("path").classed(l, !0).datum(i).attr("d", m).attr("id", d).attr("clip-path", `url(#${p})`);
|
|
450
450
|
return {
|
|
451
451
|
className(C, w) {
|
|
452
452
|
C === "remove" ? x.classed(`${l}${w}`, !1) : x.classed(`${l}${w}`, !0);
|
|
@@ -459,13 +459,13 @@ const Vi = (s) => {
|
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
461
|
}, qi = (s, t) => {
|
|
462
|
-
const { svg: e, data: i, x: n, y: r, chartId: a, config: l } = s, { baseClassName:
|
|
462
|
+
const { svg: e, data: i, x: n, y: r, chartId: a, config: l } = s, { baseClassName: d, id: c, clip: g } = t, _ = e.node(), m = nt(_), p = E.line().x((w) => n(w.date)).y((w) => r(w.value)).curve(Et(s)), v = `${a}-clip-${d}`, x = m.append("clipPath").attr("id", v).append("rect").attr("x", (g == null ? void 0 : g.x) || 0).attr("y", (g == null ? void 0 : g.y) || 0).attr("width", (g == null ? void 0 : g.width) || "100%").attr("height", (g == null ? void 0 : g.height) || "100%"), C = e.append("path").classed(d, !0).datum(i).attr("d", p).attr("id", c).attr("clip-path", `url(#${v})`);
|
|
463
463
|
return {
|
|
464
464
|
className(w, y) {
|
|
465
|
-
w === "remove" ? C.classed(`${
|
|
465
|
+
w === "remove" ? C.classed(`${d}${y}`, !1) : C.classed(`${d}${y}`, !0);
|
|
466
466
|
},
|
|
467
467
|
update({ data: w, clip: y, hidden: T }) {
|
|
468
|
-
w !== void 0 && C.datum(w).attr("d", p), T !== void 0 && C.classed(`${
|
|
468
|
+
w !== void 0 && C.datum(w).attr("d", p), T !== void 0 && C.classed(`${d}_hidden`, T), y !== void 0 && (l.hover.transitionName === "default" ? x.transition().duration(l.hover.transitionDuration).attr("x", y.x).attr("y", y.y).attr("width", y.width).attr("height", y.height).ease(E.easeLinear) : x.attr("x", y.x).attr("y", y.y).attr("width", y.width).attr("height", y.height));
|
|
469
469
|
},
|
|
470
470
|
destroy() {
|
|
471
471
|
C.remove();
|
|
@@ -476,13 +476,13 @@ const Vi = (s) => {
|
|
|
476
476
|
let e;
|
|
477
477
|
return t >= 1e9 ? e = (s / 1e9).toFixed(1) + "B" : t >= 1e6 ? e = (s / 1e6).toFixed(1) + "M" : t >= 1e3 ? e = (s / 1e3).toFixed(1) + "K" : e = s.toFixed(1), e;
|
|
478
478
|
}, Qi = (s, t) => {
|
|
479
|
-
const { svg: e, data: i, x: n, y: r } = s, { baseClassName: a } = t, l = e.append("g").classed(a, !0),
|
|
479
|
+
const { svg: e, data: i, x: n, y: r } = s, { baseClassName: a } = t, l = e.append("g").classed(a, !0), d = l.append("circle").attr("r", 5).classed(`${a}-circle`, !0), c = l.append("text").attr("text-anchor", "middle").attr("dy", "-9px").classed(`${a}-label`, !0);
|
|
480
480
|
return ((_) => {
|
|
481
481
|
if (!_ || _.length === 0) return;
|
|
482
482
|
const m = _[_.length - 1], p = n(m.date), v = r(m.value);
|
|
483
|
-
|
|
483
|
+
d.attr("cx", p).attr("cy", v);
|
|
484
484
|
const b = s.config.extremePointFormatter || Ji;
|
|
485
|
-
|
|
485
|
+
c.attr("x", p).attr("y", v).text(b(m.value));
|
|
486
486
|
})(i), {
|
|
487
487
|
className(_, m) {
|
|
488
488
|
_ === "remove" ? l.classed(`${a}${m}`, !1) : l.classed(`${a}${m}`, !0);
|
|
@@ -517,7 +517,7 @@ const Vi = (s) => {
|
|
|
517
517
|
const l = Gt(s.svg, {
|
|
518
518
|
className: "sc-charts__hover-circle",
|
|
519
519
|
hidden: !0
|
|
520
|
-
}),
|
|
520
|
+
}), d = De(s.svg), c = De(s.svg), g = Zt(s, {
|
|
521
521
|
baseClassName: "sc-charts__range-line",
|
|
522
522
|
id: `${s.chartId}-sc-charts__range-line`,
|
|
523
523
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
@@ -531,8 +531,8 @@ const Vi = (s) => {
|
|
|
531
531
|
return {
|
|
532
532
|
hoverLine: n,
|
|
533
533
|
hoverCircle: l,
|
|
534
|
-
rangeBorderLeft:
|
|
535
|
-
rangeBorderRight:
|
|
534
|
+
rangeBorderLeft: d,
|
|
535
|
+
rangeBorderRight: c,
|
|
536
536
|
rangeLine: g,
|
|
537
537
|
rangeLineArea: b,
|
|
538
538
|
rangeCircleLeft: _,
|
|
@@ -554,10 +554,10 @@ const Vi = (s) => {
|
|
|
554
554
|
width: "100%",
|
|
555
555
|
height: "100%"
|
|
556
556
|
};
|
|
557
|
-
const [, n, r] = i, a = parseInt(n, 10), [l,
|
|
558
|
-
let
|
|
559
|
-
for (;
|
|
560
|
-
let g = new Date(
|
|
557
|
+
const [, n, r] = i, a = parseInt(n, 10), [l, d] = e.domain();
|
|
558
|
+
let c = new Date(l);
|
|
559
|
+
for (; c < d; ) {
|
|
560
|
+
let g = new Date(c);
|
|
561
561
|
switch (r) {
|
|
562
562
|
case "M":
|
|
563
563
|
g.setMinutes(g.getMinutes() + a);
|
|
@@ -572,7 +572,7 @@ const Vi = (s) => {
|
|
|
572
572
|
g.setDate(g.getDate() + a * 7);
|
|
573
573
|
break;
|
|
574
574
|
case "m":
|
|
575
|
-
g = new Date(
|
|
575
|
+
g = new Date(c.getFullYear(), c.getMonth() + a, 1);
|
|
576
576
|
break;
|
|
577
577
|
default:
|
|
578
578
|
return {
|
|
@@ -582,8 +582,8 @@ const Vi = (s) => {
|
|
|
582
582
|
height: "100%"
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
|
-
if (t >=
|
|
586
|
-
const _ = e(
|
|
585
|
+
if (t >= c && t < g) {
|
|
586
|
+
const _ = e(c), m = e(g);
|
|
587
587
|
return {
|
|
588
588
|
x: _,
|
|
589
589
|
y: 0,
|
|
@@ -591,10 +591,10 @@ const Vi = (s) => {
|
|
|
591
591
|
height: "100%"
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
|
-
|
|
594
|
+
c = new Date(g);
|
|
595
595
|
}
|
|
596
|
-
if (t.getTime() ===
|
|
597
|
-
let g = new Date(
|
|
596
|
+
if (t.getTime() === d.getTime()) {
|
|
597
|
+
let g = new Date(d);
|
|
598
598
|
switch (r) {
|
|
599
599
|
case "M":
|
|
600
600
|
g.setMinutes(g.getMinutes() - a);
|
|
@@ -609,10 +609,10 @@ const Vi = (s) => {
|
|
|
609
609
|
g.setDate(g.getDate() - a * 7);
|
|
610
610
|
break;
|
|
611
611
|
case "m":
|
|
612
|
-
g = new Date(
|
|
612
|
+
g = new Date(d.getFullYear(), d.getMonth() - a, 1);
|
|
613
613
|
break;
|
|
614
614
|
}
|
|
615
|
-
const _ = e(g), m = e(
|
|
615
|
+
const _ = e(g), m = e(d);
|
|
616
616
|
return {
|
|
617
617
|
x: _,
|
|
618
618
|
y: 0,
|
|
@@ -627,7 +627,7 @@ const Vi = (s) => {
|
|
|
627
627
|
height: "100%"
|
|
628
628
|
};
|
|
629
629
|
}, Le = (s, t) => {
|
|
630
|
-
var
|
|
630
|
+
var c;
|
|
631
631
|
const {
|
|
632
632
|
x: e,
|
|
633
633
|
y: i,
|
|
@@ -654,12 +654,12 @@ const Vi = (s) => {
|
|
|
654
654
|
clip: l,
|
|
655
655
|
hidden: !1
|
|
656
656
|
});
|
|
657
|
-
const
|
|
658
|
-
|
|
657
|
+
const d = i.range()[0] - i(0) + r.bottom;
|
|
658
|
+
d >= 0 && ((c = n.belowZeroLine) == null || c.update({
|
|
659
659
|
clip: {
|
|
660
660
|
...l,
|
|
661
661
|
y: i(0),
|
|
662
|
-
height:
|
|
662
|
+
height: d
|
|
663
663
|
}
|
|
664
664
|
})), n.mainLine.className("add", "_muted");
|
|
665
665
|
}, Ne = (s) => {
|
|
@@ -688,7 +688,7 @@ const Vi = (s) => {
|
|
|
688
688
|
config: { margin: r },
|
|
689
689
|
height: a,
|
|
690
690
|
elements: l
|
|
691
|
-
} = s,
|
|
691
|
+
} = s, d = i(t.date) < i(e.date) ? t : e, c = i(t.date) >= i(e.date) ? t : e, g = c.value - d.value >= 0, _ = i(d.date), m = i(c.date), p = m - _;
|
|
692
692
|
l.rangeBorderLeft.update({
|
|
693
693
|
x1: _,
|
|
694
694
|
x2: _,
|
|
@@ -703,11 +703,11 @@ const Vi = (s) => {
|
|
|
703
703
|
hidden: !1
|
|
704
704
|
}), l.rangeCircleLeft.update({
|
|
705
705
|
cx: _,
|
|
706
|
-
cy: n(
|
|
706
|
+
cy: n(d.value),
|
|
707
707
|
hidden: !1
|
|
708
708
|
}), l.rangeCircleRight.update({
|
|
709
709
|
cx: m,
|
|
710
|
-
cy: n(
|
|
710
|
+
cy: n(c.value),
|
|
711
711
|
hidden: !1
|
|
712
712
|
}), l.rangeLine.update({
|
|
713
713
|
clip: {
|
|
@@ -726,8 +726,8 @@ const Vi = (s) => {
|
|
|
726
726
|
},
|
|
727
727
|
hidden: !1
|
|
728
728
|
}), l.rangeTooltip.update({
|
|
729
|
-
rightPoint:
|
|
730
|
-
leftPoint:
|
|
729
|
+
rightPoint: c,
|
|
730
|
+
leftPoint: d,
|
|
731
731
|
closest: e,
|
|
732
732
|
x: _ + p / 2,
|
|
733
733
|
y: 0,
|
|
@@ -740,49 +740,49 @@ const Vi = (s) => {
|
|
|
740
740
|
const { elements: t } = s;
|
|
741
741
|
t.rangeLine.update({ hidden: !0 }), t.rangeLineArea.update({ hidden: !0 }), t.rangeBorderLeft.update({ hidden: !0 }), t.rangeBorderRight.update({ hidden: !0 }), t.rangeCircleLeft.update({ hidden: !0 }), t.rangeCircleRight.update({ hidden: !0 }), t.rangeTooltip.update({ hidden: !0 }), t.mainLine.className("remove", "_selected-muted"), t.mainLineArea.update({ hidden: !1 }), (e = t.belowZeroLine) == null || e.update({ hidden: !1 });
|
|
742
742
|
}, nn = (s) => {
|
|
743
|
-
const { svg: t, data: e, x: i, config: n, width: r, height: a } = s, { margin: l, hover:
|
|
743
|
+
const { svg: t, data: e, x: i, config: n, width: r, height: a } = s, { margin: l, hover: d, selection: c } = n;
|
|
744
744
|
let g = null, _ = !1;
|
|
745
745
|
const m = (v) => e.reduce(
|
|
746
746
|
(b, x) => Math.abs(i(b.date) - v) < Math.abs(i(x.date) - v) ? b : x
|
|
747
747
|
);
|
|
748
748
|
t.append("rect").attr("width", r - l.left - l.right).attr("height", a - l.top - l.bottom).attr("x", l.left).attr("y", l.top).attr("fill", "transparent").on("mousemove", function(v) {
|
|
749
|
-
const [b] =
|
|
750
|
-
!_ &&
|
|
749
|
+
const [b] = E.pointer(v, this), x = m(b);
|
|
750
|
+
!_ && d.enable ? (s.action = "hover", Le(s, x)) : (s.action = _ ? "selection" : "none", Ne(s)), g && c.enable && (s.action = "selection", sn(s, g, x));
|
|
751
751
|
}).on("mouseleave", () => {
|
|
752
752
|
s.action = "none", _ = !1, g = null, Ne(s), Ie(s);
|
|
753
753
|
}).on("mousedown", function(v) {
|
|
754
|
-
if (
|
|
754
|
+
if (c.enable) {
|
|
755
755
|
_ = !0, s.action = "selection";
|
|
756
|
-
const [b] =
|
|
756
|
+
const [b] = E.pointer(v, this);
|
|
757
757
|
g = m(b);
|
|
758
758
|
}
|
|
759
759
|
}).on("mouseup", function(v) {
|
|
760
|
-
const [b] =
|
|
761
|
-
_ = !1, g = null, s.action = "hover",
|
|
760
|
+
const [b] = E.pointer(v, this), x = m(b);
|
|
761
|
+
_ = !1, g = null, s.action = "hover", c.enable && Ie(s), d.enable && Le(s, x);
|
|
762
762
|
});
|
|
763
763
|
}, rn = (s, t, e) => {
|
|
764
|
-
const { margin: i } = t, n =
|
|
764
|
+
const { margin: i } = t, n = E.scaleTime(), r = E.extent(s, (a) => new Date(a.date));
|
|
765
765
|
return r[0] == null || r[1] == null ? n : n.domain([r[0], r[1]]).range([i.left, e - i.right]);
|
|
766
766
|
}, an = (s, t, e) => {
|
|
767
|
-
const { margin: i } = t, n =
|
|
768
|
-
return
|
|
767
|
+
const { margin: i } = t, n = E.max(s, (a) => a.value) ?? 0, r = E.min(s, (a) => a.value) ?? 0;
|
|
768
|
+
return E.scaleLinear().domain([r, n]).range([e - i.bottom, i.top]);
|
|
769
769
|
}, oa = (s, t) => {
|
|
770
|
-
const e =
|
|
770
|
+
const e = E.select(s);
|
|
771
771
|
if (e.empty())
|
|
772
772
|
return console.error(`Element with selector ${s} not found!`), null;
|
|
773
773
|
if (!t.chartId || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t.chartId))
|
|
774
774
|
return console.error(`chartId is required and must be a valid id
|
|
775
775
|
(only letters, numbers or underscores. The first character must be a letter)`), null;
|
|
776
776
|
const i = e.append("div"), n = i.append("svg"), r = e.node();
|
|
777
|
-
let a = r.getBoundingClientRect(), l = a.width,
|
|
777
|
+
let a = r.getBoundingClientRect(), l = a.width, d = a.height, c = ke({ ...Gi }, t.config), g = t.data;
|
|
778
778
|
const _ = () => {
|
|
779
|
-
a = r.getBoundingClientRect(), l = a.width,
|
|
779
|
+
a = r.getBoundingClientRect(), l = a.width, d = a.height, m({ data: g, config: c });
|
|
780
780
|
};
|
|
781
781
|
window.addEventListener("resize", _);
|
|
782
782
|
const m = (p, v = !1) => {
|
|
783
|
-
v && p.config && (
|
|
784
|
-
const b = g.map((T) => ({ date: new Date(T.date), value: T.value })).sort((T, D) => T.date.getTime() - D.date.getTime()), x = rn(b,
|
|
785
|
-
i.attr("class", `sc-charts sc-charts__${
|
|
783
|
+
v && p.config && (c = ke(c, p.config)), v && p.data && (g = p.data);
|
|
784
|
+
const b = g.map((T) => ({ date: new Date(T.date), value: T.value })).sort((T, D) => T.date.getTime() - D.date.getTime()), x = rn(b, c, l), C = an(b, c, d);
|
|
785
|
+
i.attr("class", `sc-charts sc-charts__${c.theme}`), n.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${l} ${d}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
|
|
786
786
|
const w = {
|
|
787
787
|
chartId: t.chartId,
|
|
788
788
|
svg: n,
|
|
@@ -790,10 +790,10 @@ const Vi = (s) => {
|
|
|
790
790
|
data: b,
|
|
791
791
|
x,
|
|
792
792
|
y: C,
|
|
793
|
-
config:
|
|
793
|
+
config: c,
|
|
794
794
|
action: "none",
|
|
795
795
|
width: l,
|
|
796
|
-
height:
|
|
796
|
+
height: d
|
|
797
797
|
};
|
|
798
798
|
Ri(w);
|
|
799
799
|
const y = {
|
|
@@ -818,8 +818,8 @@ dt.exports;
|
|
|
818
818
|
var Fe;
|
|
819
819
|
function ln() {
|
|
820
820
|
return Fe || (Fe = 1, function(s, t) {
|
|
821
|
-
var e = 200, i = "__lodash_hash_undefined__", n = 800, r = 16, a = 9007199254740991, l = "[object Arguments]",
|
|
822
|
-
F[Ft] = F[es] = F[ss] = F[is] = F[ns] = F[rs] = F[as] = F[os] = F[ls] = !0, F[l] = F[
|
|
821
|
+
var e = 200, i = "__lodash_hash_undefined__", n = 800, r = 16, a = 9007199254740991, l = "[object Arguments]", d = "[object Array]", c = "[object AsyncFunction]", g = "[object Boolean]", _ = "[object Date]", m = "[object Error]", p = "[object Function]", v = "[object GeneratorFunction]", b = "[object Map]", x = "[object Number]", C = "[object Null]", w = "[object Object]", y = "[object Proxy]", T = "[object RegExp]", D = "[object Set]", N = "[object String]", z = "[object Undefined]", O = "[object WeakMap]", Nt = "[object ArrayBuffer]", It = "[object DataView]", Ft = "[object Float32Array]", es = "[object Float64Array]", ss = "[object Int8Array]", is = "[object Int16Array]", ns = "[object Int32Array]", rs = "[object Uint8Array]", as = "[object Uint8ClampedArray]", os = "[object Uint16Array]", ls = "[object Uint32Array]", cs = /[\\^$.*+?()[\]{}|]/g, hs = /^\[object .+?Constructor\]$/, ds = /^(?:0|[1-9]\d*)$/, F = {};
|
|
822
|
+
F[Ft] = F[es] = F[ss] = F[is] = F[ns] = F[rs] = F[as] = F[os] = F[ls] = !0, F[l] = F[d] = F[Nt] = F[g] = F[It] = F[_] = F[m] = F[p] = F[b] = F[x] = F[w] = F[T] = F[D] = F[N] = F[O] = !1;
|
|
823
823
|
var ne = typeof Ct == "object" && Ct && Ct.Object === Object && Ct, us = typeof self == "object" && self && self.Object === Object && self, rt = ne || us || Function("return this")(), re = t && !t.nodeType && t, at = re && !0 && s && !s.nodeType && s, ae = at && at.exports === re, Bt = ae && ne.process, oe = function() {
|
|
824
824
|
try {
|
|
825
825
|
var o = at && at.require && at.require("util").types;
|
|
@@ -1002,14 +1002,14 @@ function ln() {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
it.prototype.clear = Ys, it.prototype.delete = js, it.prototype.get = Xs, it.prototype.has = Ws, it.prototype.set = Vs;
|
|
1004
1004
|
function Gs(o, u) {
|
|
1005
|
-
var f = Yt(o), M = !f && Ot(o), k = !f && !M && xe(o), I = !f && !M && !k && Ce(o), B = f || M || k || I,
|
|
1005
|
+
var f = Yt(o), M = !f && Ot(o), k = !f && !M && xe(o), I = !f && !M && !k && Ce(o), B = f || M || k || I, L = B ? _s(o.length, String) : [], H = L.length;
|
|
1006
1006
|
for (var Y in o)
|
|
1007
1007
|
B && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1008
1008
|
(Y == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1009
1009
|
k && (Y == "offset" || Y == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1010
1010
|
I && (Y == "buffer" || Y == "byteLength" || Y == "byteOffset") || // Skip index properties.
|
|
1011
|
-
be(Y, H)) ||
|
|
1012
|
-
return
|
|
1011
|
+
be(Y, H)) || L.push(Y);
|
|
1012
|
+
return L;
|
|
1013
1013
|
}
|
|
1014
1014
|
function Rt(o, u, f) {
|
|
1015
1015
|
(f !== void 0 && !wt(o[u], f) || f === void 0 && !(u in o)) && zt(o, u, f);
|
|
@@ -1061,21 +1061,21 @@ function ln() {
|
|
|
1061
1061
|
if (k || (k = new it()), K(I))
|
|
1062
1062
|
Ks(o, u, B, f, ve, M, k);
|
|
1063
1063
|
else {
|
|
1064
|
-
var
|
|
1065
|
-
|
|
1064
|
+
var L = M ? M(Pt(o, B), I, B + "", o, u, k) : void 0;
|
|
1065
|
+
L === void 0 && (L = I), Rt(o, B, L);
|
|
1066
1066
|
}
|
|
1067
1067
|
}, Me);
|
|
1068
1068
|
}
|
|
1069
1069
|
function Ks(o, u, f, M, k, I, B) {
|
|
1070
|
-
var
|
|
1070
|
+
var L = Pt(o, f), H = Pt(u, f), Y = B.get(H);
|
|
1071
1071
|
if (Y) {
|
|
1072
1072
|
Rt(o, f, Y);
|
|
1073
1073
|
return;
|
|
1074
1074
|
}
|
|
1075
|
-
var $ = I ? I(
|
|
1075
|
+
var $ = I ? I(L, H, f + "", o, u, B) : void 0, ct = $ === void 0;
|
|
1076
1076
|
if (ct) {
|
|
1077
1077
|
var Wt = Yt(H), Vt = !Wt && xe(H), Te = !Wt && !Vt && Ce(H);
|
|
1078
|
-
$ = H, Wt || Vt || Te ? Yt(
|
|
1078
|
+
$ = H, Wt || Vt || Te ? Yt(L) ? $ = L : yi(L) ? $ = ri(L) : Vt ? (ct = !1, $ = si(H)) : Te ? (ct = !1, $ = ni(H)) : $ = [] : xi(H) || Ot(H) ? ($ = L, Ot(L) ? $ = wi(L) : (!K(L) || Xt(L)) && ($ = hi(H))) : ct = !1;
|
|
1079
1079
|
}
|
|
1080
1080
|
ct && (B.set(H, $), k($, H, M, I, B), B.delete(H)), Rt(o, f, $);
|
|
1081
1081
|
}
|
|
@@ -1111,8 +1111,8 @@ function ln() {
|
|
|
1111
1111
|
var k = !f;
|
|
1112
1112
|
f || (f = {});
|
|
1113
1113
|
for (var I = -1, B = u.length; ++I < B; ) {
|
|
1114
|
-
var
|
|
1115
|
-
H === void 0 && (H = o[
|
|
1114
|
+
var L = u[I], H = void 0;
|
|
1115
|
+
H === void 0 && (H = o[L]), k ? zt(f, L, H) : Us(f, L, H);
|
|
1116
1116
|
}
|
|
1117
1117
|
return f;
|
|
1118
1118
|
}
|
|
@@ -1120,15 +1120,15 @@ function ln() {
|
|
|
1120
1120
|
return ti(function(u, f) {
|
|
1121
1121
|
var M = -1, k = f.length, I = k > 1 ? f[k - 1] : void 0, B = k > 2 ? f[2] : void 0;
|
|
1122
1122
|
for (I = o.length > 3 && typeof I == "function" ? (k--, I) : void 0, B && di(f[0], f[1], B) && (I = k < 3 ? void 0 : I, k = 1), u = Object(u); ++M < k; ) {
|
|
1123
|
-
var
|
|
1124
|
-
|
|
1123
|
+
var L = f[M];
|
|
1124
|
+
L && o(u, L, M, I);
|
|
1125
1125
|
}
|
|
1126
1126
|
return u;
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
1129
|
function li(o) {
|
|
1130
1130
|
return function(u, f, M) {
|
|
1131
|
-
for (var k = -1, I = Object(u), B = M(u),
|
|
1131
|
+
for (var k = -1, I = Object(u), B = M(u), L = B.length; L--; ) {
|
|
1132
1132
|
var H = B[++k];
|
|
1133
1133
|
if (f(I[H], H, I) === !1)
|
|
1134
1134
|
break;
|
|
@@ -1193,9 +1193,9 @@ function ln() {
|
|
|
1193
1193
|
for (var M = arguments, k = -1, I = fe(M.length - u, 0), B = Array(I); ++k < I; )
|
|
1194
1194
|
B[k] = M[u + k];
|
|
1195
1195
|
k = -1;
|
|
1196
|
-
for (var
|
|
1197
|
-
|
|
1198
|
-
return
|
|
1196
|
+
for (var L = Array(u + 1); ++k < u; )
|
|
1197
|
+
L[k] = M[k];
|
|
1198
|
+
return L[u] = f(B), gs(o, this, L);
|
|
1199
1199
|
};
|
|
1200
1200
|
}
|
|
1201
1201
|
function Pt(o, u) {
|
|
@@ -1247,7 +1247,7 @@ function ln() {
|
|
|
1247
1247
|
if (!K(o))
|
|
1248
1248
|
return !1;
|
|
1249
1249
|
var u = yt(o);
|
|
1250
|
-
return u == p || u == v || u ==
|
|
1250
|
+
return u == p || u == v || u == c || u == y;
|
|
1251
1251
|
}
|
|
1252
1252
|
function we(o) {
|
|
1253
1253
|
return typeof o == "number" && o > -1 && o % 1 == 0 && o <= a;
|
|
@@ -1335,11 +1335,11 @@ const Tt = /* @__PURE__ */ on(cn), Be = 12, hn = {
|
|
|
1335
1335
|
};
|
|
1336
1336
|
class dn {
|
|
1337
1337
|
constructor(t) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1338
|
+
h(this, "_candles");
|
|
1339
|
+
h(this, "_xAxis");
|
|
1340
|
+
h(this, "_yAxis");
|
|
1341
|
+
h(this, "_guides");
|
|
1342
|
+
h(this, "_trade");
|
|
1343
1343
|
const e = Tt({}, hn, t);
|
|
1344
1344
|
this._candles = e.candles, this._xAxis = e.xAxis, this._yAxis = e.yAxis, this._guides = e.guides, this._trade = e.trade;
|
|
1345
1345
|
}
|
|
@@ -1375,10 +1375,10 @@ class dn {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
class j {
|
|
1377
1377
|
constructor(t) {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1378
|
+
h(this, "_x");
|
|
1379
|
+
h(this, "_y");
|
|
1380
|
+
h(this, "_width");
|
|
1381
|
+
h(this, "_height");
|
|
1382
1382
|
let e;
|
|
1383
1383
|
if (!t)
|
|
1384
1384
|
e = { x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -1416,11 +1416,11 @@ class j {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
class un {
|
|
1418
1418
|
constructor(t, e) {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1419
|
+
h(this, "_chart", new j());
|
|
1420
|
+
h(this, "_area", new j());
|
|
1421
|
+
h(this, "_xAxis", new j());
|
|
1422
|
+
h(this, "_yAxis", new j());
|
|
1423
|
+
h(this, "_axisIntersection", new j());
|
|
1424
1424
|
const { xAxis: i, yAxis: n } = e;
|
|
1425
1425
|
this._chart = new j(t), this._calc(i, n);
|
|
1426
1426
|
}
|
|
@@ -1479,10 +1479,10 @@ function _n(s, t) {
|
|
|
1479
1479
|
for (let i = 0; i < s.length - 1; i++) {
|
|
1480
1480
|
const n = s[i].close_time.getTime(), r = s[i].open_time.getTime(), l = new Date(s[i + 1].open_time).getTime() - n;
|
|
1481
1481
|
if (l >= t) {
|
|
1482
|
-
const
|
|
1483
|
-
for (let g = 1; g <=
|
|
1484
|
-
|
|
1485
|
-
|
|
1482
|
+
const d = Math.floor(l / t), c = [];
|
|
1483
|
+
for (let g = 1; g <= d; g++)
|
|
1484
|
+
c.push(r + g * t);
|
|
1485
|
+
c.length > 0 && e.push(c);
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
return e;
|
|
@@ -1496,10 +1496,10 @@ function He(s, t) {
|
|
|
1496
1496
|
);
|
|
1497
1497
|
if (!a || !l)
|
|
1498
1498
|
throw new Error("[CS_Data] error while creating missing data");
|
|
1499
|
-
const
|
|
1500
|
-
let g =
|
|
1499
|
+
const d = a.close, c = l.open;
|
|
1500
|
+
let g = d;
|
|
1501
1501
|
r.forEach((_, m) => {
|
|
1502
|
-
const p = (
|
|
1502
|
+
const p = (c - g) / r.length;
|
|
1503
1503
|
let v = g + p * m, b = v + p;
|
|
1504
1504
|
const x = Math.abs(v - b);
|
|
1505
1505
|
let C = Math.max(v, b) + x / 2, w = Math.min(v, b) - x / 2;
|
|
@@ -1524,12 +1524,12 @@ function He(s, t) {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
class se {
|
|
1526
1526
|
constructor(t, e) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1527
|
+
h(this, "_initialData", []);
|
|
1528
|
+
h(this, "_preparedData", []);
|
|
1529
|
+
h(this, "_missingData", []);
|
|
1530
|
+
h(this, "_count", 0);
|
|
1531
|
+
h(this, "_model");
|
|
1532
|
+
h(this, "_interval", 0);
|
|
1533
1533
|
this._model = e, this.update(t);
|
|
1534
1534
|
}
|
|
1535
1535
|
_prepare(t) {
|
|
@@ -1565,7 +1565,7 @@ class se {
|
|
|
1565
1565
|
}
|
|
1566
1566
|
class fn {
|
|
1567
1567
|
constructor() {
|
|
1568
|
-
|
|
1568
|
+
h(this, "listeners", {});
|
|
1569
1569
|
}
|
|
1570
1570
|
subscribe(t, e) {
|
|
1571
1571
|
return this.listeners[t] || (this.listeners[t] = []), this.listeners[t].push(e), () => this.unsubscribe(t, e);
|
|
@@ -1584,7 +1584,7 @@ class fn {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
class Ue {
|
|
1586
1586
|
constructor() {
|
|
1587
|
-
|
|
1587
|
+
h(this, "_scale");
|
|
1588
1588
|
}
|
|
1589
1589
|
domain() {
|
|
1590
1590
|
const t = this._scale.domain();
|
|
@@ -1620,12 +1620,12 @@ class Ue {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
class Ze extends Ue {
|
|
1622
1622
|
constructor() {
|
|
1623
|
-
super(), this._scale =
|
|
1623
|
+
super(), this._scale = E.scaleTime();
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
1626
|
class mn extends Ue {
|
|
1627
1627
|
constructor() {
|
|
1628
|
-
super(), this._scale =
|
|
1628
|
+
super(), this._scale = E.scaleLinear();
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
1631
|
const Re = { x: 0.2, y: 0.2 }, ze = 1e-3, pn = {
|
|
@@ -1640,9 +1640,9 @@ const Re = { x: 0.2, y: 0.2 }, ze = 1e-3, pn = {
|
|
|
1640
1640
|
return [parseInt(t[1]), t[2]];
|
|
1641
1641
|
}, bn = (s, t) => {
|
|
1642
1642
|
const [e, i] = t.domain().map((l) => l.getTime()), n = s.filter((l) => {
|
|
1643
|
-
const
|
|
1644
|
-
return
|
|
1645
|
-
}), r =
|
|
1643
|
+
const d = l.open_time.getTime();
|
|
1644
|
+
return d >= e && d <= i;
|
|
1645
|
+
}), r = E.min(n, (l) => l.low), a = E.max(n, (l) => l.high);
|
|
1646
1646
|
if (r == null || a == null) throw new Error("Invalid Y data");
|
|
1647
1647
|
return [r, a];
|
|
1648
1648
|
};
|
|
@@ -1651,7 +1651,7 @@ class yn {
|
|
|
1651
1651
|
this.model = t;
|
|
1652
1652
|
}
|
|
1653
1653
|
initX(t) {
|
|
1654
|
-
const e = this.model.candles.preparedData, i =
|
|
1654
|
+
const e = this.model.candles.preparedData, i = E.extent(e, (n) => new Date(n.open_time));
|
|
1655
1655
|
if (!i[0] || !i[1]) throw new Error("Invalid x data");
|
|
1656
1656
|
t.setDomain(i), this.setRange(t, this.model.layout.xAxis), this.setDefaultXDomain(t), this.applyOffset(t);
|
|
1657
1657
|
}
|
|
@@ -1672,7 +1672,7 @@ class yn {
|
|
|
1672
1672
|
config: {
|
|
1673
1673
|
candles: { baseWidth: n, bodyRatio: r, direction: a }
|
|
1674
1674
|
}
|
|
1675
|
-
} = this.model, [l,
|
|
1675
|
+
} = this.model, [l, d] = t.domain().map((p) => p.getTime()), c = d - l, g = n / r * e, _ = c * (i.width / g), m = a === "left" ? [new Date(l), new Date(l + _)] : [new Date(d - _), new Date(d)];
|
|
1676
1676
|
t.setDomain(m);
|
|
1677
1677
|
}
|
|
1678
1678
|
applyOffset(t) {
|
|
@@ -1681,22 +1681,22 @@ class yn {
|
|
|
1681
1681
|
candles: { offset: e, direction: i }
|
|
1682
1682
|
},
|
|
1683
1683
|
layout: { xAxis: n }
|
|
1684
|
-
} = this.model, [r, a] = vn(e), l = a === "px" ? t.invert(n.x + r).getTime() - t.invert(n.x).getTime() : pn[a] * r,
|
|
1685
|
-
t.setDomain([new Date(
|
|
1684
|
+
} = this.model, [r, a] = vn(e), l = a === "px" ? t.invert(n.x + r).getTime() - t.invert(n.x).getTime() : pn[a] * r, d = i === "left" ? -l : l, [c, g] = t.domain();
|
|
1685
|
+
t.setDomain([new Date(c.getTime() + d), new Date(g.getTime() + d)]);
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
1688
|
class xn {
|
|
1689
1689
|
constructor(t) {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1690
|
+
h(this, "_model");
|
|
1691
|
+
h(this, "_scaleX");
|
|
1692
|
+
h(this, "_scaleY");
|
|
1693
|
+
h(this, "_initializer");
|
|
1694
|
+
h(this, "_baseDomain", {
|
|
1695
1695
|
x: [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()],
|
|
1696
1696
|
y: [0, 0]
|
|
1697
1697
|
});
|
|
1698
|
-
|
|
1699
|
-
|
|
1698
|
+
h(this, "scaleFactor", { x: 1, y: 1 });
|
|
1699
|
+
h(this, "panOffset", { x: 0, y: 0 });
|
|
1700
1700
|
this._model = t, this._scaleX = new Ze(), this._scaleY = new mn(), this._initializer = new yn(t), this._initializer.init({ x: this._scaleX, y: this._scaleY }), this._baseDomain = {
|
|
1701
1701
|
x: this._scaleX.domain(),
|
|
1702
1702
|
y: this._scaleY.domain()
|
|
@@ -1731,10 +1731,10 @@ class xn {
|
|
|
1731
1731
|
if (!n.length) return;
|
|
1732
1732
|
const r = Math.min(...n.map((_) => _.low)), a = Math.max(...n.map((_) => _.high)), l = a - r;
|
|
1733
1733
|
if (l === 0) return;
|
|
1734
|
-
const
|
|
1735
|
-
this.scale("y", (
|
|
1736
|
-
const
|
|
1737
|
-
this.pan("y", g -
|
|
1734
|
+
const d = this._baseDomain.y;
|
|
1735
|
+
this.scale("y", (d[1] - d[0]) / l, "absolute");
|
|
1736
|
+
const c = this._scaleY.convert((r + a) / 2), g = this._scaleY.convert((d[0] + d[1]) / 2);
|
|
1737
|
+
this.pan("y", g - c, "absolute");
|
|
1738
1738
|
}
|
|
1739
1739
|
scale(t, e, i = "delta") {
|
|
1740
1740
|
if (i === "absolute") {
|
|
@@ -1754,16 +1754,16 @@ class xn {
|
|
|
1754
1754
|
_updateDomain(t) {
|
|
1755
1755
|
const e = this._baseDomain[t], i = this.scaleFactor[t], n = this.panOffset[t];
|
|
1756
1756
|
if (t === "x") {
|
|
1757
|
-
const [r, a] = e, l = a.getTime() - r.getTime(),
|
|
1757
|
+
const [r, a] = e, l = a.getTime() - r.getTime(), d = l / i, c = r.getTime() + l / 2, g = this._scaleX.invert(0 - n).getTime() - this._scaleX.invert(0).getTime();
|
|
1758
1758
|
this._scaleX.setDomain([
|
|
1759
|
-
new Date(
|
|
1760
|
-
new Date(
|
|
1759
|
+
new Date(c - d / 2 + g),
|
|
1760
|
+
new Date(c + d / 2 + g)
|
|
1761
1761
|
]);
|
|
1762
1762
|
} else {
|
|
1763
|
-
const [r, a] = e, l = a - r,
|
|
1763
|
+
const [r, a] = e, l = a - r, d = l / i, c = r + l / 2, g = this._scaleY.invert(0 - n) - this._scaleY.invert(0);
|
|
1764
1764
|
this._scaleY.setDomain([
|
|
1765
|
-
|
|
1766
|
-
|
|
1765
|
+
c - d / 2 + g,
|
|
1766
|
+
c + d / 2 + g
|
|
1767
1767
|
]);
|
|
1768
1768
|
}
|
|
1769
1769
|
this._model.eventBus.emit("scale_event");
|
|
@@ -1771,14 +1771,14 @@ class xn {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
class wn {
|
|
1773
1773
|
constructor(t, { entry: e = [], exit: i = [] }) {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1774
|
+
h(this, "_model");
|
|
1775
|
+
h(this, "_rawEntry");
|
|
1776
|
+
h(this, "_rawExit");
|
|
1777
|
+
h(this, "_mapped", []);
|
|
1778
|
+
h(this, "_entries", []);
|
|
1779
|
+
h(this, "_exits", []);
|
|
1780
|
+
h(this, "_activeTradeTime", null);
|
|
1781
|
+
h(this, "_hoveredTradeTime", null);
|
|
1782
1782
|
this._model = t, this._rawEntry = e, this._rawExit = i, this.recalculate();
|
|
1783
1783
|
}
|
|
1784
1784
|
_findTradeCandle(t) {
|
|
@@ -1845,8 +1845,8 @@ class wn {
|
|
|
1845
1845
|
const { allData: t, interval: e } = this._model.candles, i = t.map((a) => a.open_time.getTime());
|
|
1846
1846
|
let n = 0, r = i.length - 1;
|
|
1847
1847
|
for (let a = 0; a < i.length; a++) {
|
|
1848
|
-
const l = i[a],
|
|
1849
|
-
if (n === 0 &&
|
|
1848
|
+
const l = i[a], d = l <= this.entryMinTime && l + e >= this.entryMinTime, c = l <= this.exitMaxTime && l + e >= this.exitMaxTime;
|
|
1849
|
+
if (n === 0 && d && (n = a), r === i.length - 1 && c && (r = a), n !== 0 && r !== i.length - 1) break;
|
|
1850
1850
|
}
|
|
1851
1851
|
return i.slice(n, r + 1);
|
|
1852
1852
|
}
|
|
@@ -1859,10 +1859,10 @@ class wn {
|
|
|
1859
1859
|
}
|
|
1860
1860
|
class Cn {
|
|
1861
1861
|
constructor(t, e) {
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1862
|
+
h(this, "_rawMarkers");
|
|
1863
|
+
h(this, "_markers", []);
|
|
1864
|
+
h(this, "_model");
|
|
1865
|
+
h(this, "_defaults", {
|
|
1866
1866
|
mainColor: "#000000",
|
|
1867
1867
|
textColor: "#ffffff",
|
|
1868
1868
|
lineColor: "#000000",
|
|
@@ -1884,7 +1884,7 @@ class Cn {
|
|
|
1884
1884
|
} = this._model;
|
|
1885
1885
|
this._markers = this._rawMarkers.map((l) => {
|
|
1886
1886
|
var g, _;
|
|
1887
|
-
const
|
|
1887
|
+
const d = {
|
|
1888
1888
|
mainColor: l.mainColor ?? a.main,
|
|
1889
1889
|
textColor: l.textColor ?? a.text,
|
|
1890
1890
|
lineColor: l.lineColor ?? a.line
|
|
@@ -1899,7 +1899,7 @@ class Cn {
|
|
|
1899
1899
|
y: p,
|
|
1900
1900
|
lineLength: e.width,
|
|
1901
1901
|
position: i.yAxis.position,
|
|
1902
|
-
...
|
|
1902
|
+
...d
|
|
1903
1903
|
};
|
|
1904
1904
|
} else {
|
|
1905
1905
|
const m = l, p = m.value instanceof Date ? m.value : new Date(m.value), v = n.convert(p), x = (m.formatter ?? ((_ = this._defaults.formatter) == null ? void 0 : _.vertical) ?? ((C) => C.toLocaleString()))(p);
|
|
@@ -1911,7 +1911,7 @@ class Cn {
|
|
|
1911
1911
|
y: t.y,
|
|
1912
1912
|
lineLength: e.height,
|
|
1913
1913
|
position: i.xAxis.position,
|
|
1914
|
-
...
|
|
1914
|
+
...d
|
|
1915
1915
|
};
|
|
1916
1916
|
}
|
|
1917
1917
|
});
|
|
@@ -1925,17 +1925,17 @@ class Cn {
|
|
|
1925
1925
|
}
|
|
1926
1926
|
class Mn {
|
|
1927
1927
|
constructor() {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1928
|
+
h(this, "bg", "#FFFFFF");
|
|
1929
|
+
h(this, "axisIntersection", "#FFFFFF");
|
|
1930
|
+
h(this, "xAxis", {
|
|
1931
1931
|
bg: "#FFFFFF",
|
|
1932
1932
|
text: "#7F7F83"
|
|
1933
1933
|
});
|
|
1934
|
-
|
|
1934
|
+
h(this, "yAxis", {
|
|
1935
1935
|
bg: "#FFFFFF",
|
|
1936
1936
|
text: "#7F7F83"
|
|
1937
1937
|
});
|
|
1938
|
-
|
|
1938
|
+
h(this, "candles", {
|
|
1939
1939
|
risingFill: "#56B683",
|
|
1940
1940
|
risingStroke: "#000000",
|
|
1941
1941
|
fallingFill: "#F18169",
|
|
@@ -1943,7 +1943,7 @@ class Mn {
|
|
|
1943
1943
|
noDataFill: ["#d9d9da", "#ededed"],
|
|
1944
1944
|
noDataStroke: "#000000"
|
|
1945
1945
|
});
|
|
1946
|
-
|
|
1946
|
+
h(this, "guides", {
|
|
1947
1947
|
horizontalMarker: {
|
|
1948
1948
|
main: "#1C2026",
|
|
1949
1949
|
text: "#ffffff",
|
|
@@ -1955,9 +1955,9 @@ class Mn {
|
|
|
1955
1955
|
line: "#1C2026"
|
|
1956
1956
|
}
|
|
1957
1957
|
});
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1958
|
+
h(this, "trade");
|
|
1959
|
+
h(this, "userMarkers");
|
|
1960
|
+
h(this, "comments", {
|
|
1961
1961
|
scaleAnchor: {
|
|
1962
1962
|
bgActive: "#007AFF",
|
|
1963
1963
|
bgInactive: "#A1BBFF",
|
|
@@ -2006,15 +2006,15 @@ class Mn {
|
|
|
2006
2006
|
const An = new Mn().toObject();
|
|
2007
2007
|
class Tn {
|
|
2008
2008
|
constructor(t) {
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2009
|
+
h(this, "_bg");
|
|
2010
|
+
h(this, "_candles");
|
|
2011
|
+
h(this, "_xAxis");
|
|
2012
|
+
h(this, "_yAxis");
|
|
2013
|
+
h(this, "_guides");
|
|
2014
|
+
h(this, "_axisIntersection");
|
|
2015
|
+
h(this, "_trade");
|
|
2016
|
+
h(this, "_userMarkers");
|
|
2017
|
+
h(this, "_comments");
|
|
2018
2018
|
const e = Tt({}, An, t);
|
|
2019
2019
|
this._candles = e.candles, this._bg = e.bg, this._xAxis = e.xAxis, this._yAxis = e.yAxis, this._guides = e.guides, this._axisIntersection = e.axisIntersection, this._trade = e.trade, this._userMarkers = e.userMarkers, this._comments = e.comments;
|
|
2020
2020
|
}
|
|
@@ -2066,8 +2066,8 @@ class Tn {
|
|
|
2066
2066
|
}
|
|
2067
2067
|
class Sn {
|
|
2068
2068
|
constructor(t, e) {
|
|
2069
|
-
|
|
2070
|
-
|
|
2069
|
+
h(this, "_data");
|
|
2070
|
+
h(this, "_callbacks", {
|
|
2071
2071
|
onAdd: () => {
|
|
2072
2072
|
},
|
|
2073
2073
|
onUpdate: () => {
|
|
@@ -2075,8 +2075,8 @@ class Sn {
|
|
|
2075
2075
|
onDelete: () => {
|
|
2076
2076
|
}
|
|
2077
2077
|
});
|
|
2078
|
-
|
|
2079
|
-
|
|
2078
|
+
h(this, "_model");
|
|
2079
|
+
h(this, "_grouped", {});
|
|
2080
2080
|
this._data = (t == null ? void 0 : t.data) || [], this._model = e, this._updateGroups(), t != null && t.onAdd && (this._callbacks.onAdd = t.onAdd), t != null && t.onUpdate && (this._callbacks.onUpdate = t.onUpdate), t != null && t.onDelete && (this._callbacks.onDelete = t.onDelete);
|
|
2081
2081
|
}
|
|
2082
2082
|
_updateGroups() {
|
|
@@ -2116,20 +2116,20 @@ class kn {
|
|
|
2116
2116
|
trade: r = { entry: [], exit: [] },
|
|
2117
2117
|
userMarkers: a = [],
|
|
2118
2118
|
colorScheme: l,
|
|
2119
|
-
comments:
|
|
2119
|
+
comments: d
|
|
2120
2120
|
}) {
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
this._chartId = t, this._container = e, this._candles = new se(i, this), this._config = new dn(n), this._colorScheme = new Tn(l), this._layout = new un(e, this._config), this._scaleManager = new xn(this), this._trade = new wn(this, r), this._candles.updateMissingCandles(), this._trade.recalculate(), this._userMarkers = new Cn(this, a), this._comments = new Sn(
|
|
2121
|
+
h(this, "_chartId");
|
|
2122
|
+
h(this, "_container");
|
|
2123
|
+
h(this, "_eventBus", new fn());
|
|
2124
|
+
h(this, "_candles");
|
|
2125
|
+
h(this, "_config");
|
|
2126
|
+
h(this, "_colorScheme");
|
|
2127
|
+
h(this, "_layout");
|
|
2128
|
+
h(this, "_scaleManager");
|
|
2129
|
+
h(this, "_trade");
|
|
2130
|
+
h(this, "_userMarkers");
|
|
2131
|
+
h(this, "_comments");
|
|
2132
|
+
this._chartId = t, this._container = e, this._candles = new se(i, this), this._config = new dn(n), this._colorScheme = new Tn(l), this._layout = new un(e, this._config), this._scaleManager = new xn(this), this._trade = new wn(this, r), this._candles.updateMissingCandles(), this._trade.recalculate(), this._userMarkers = new Cn(this, a), this._comments = new Sn(d, this);
|
|
2133
2133
|
}
|
|
2134
2134
|
init() {
|
|
2135
2135
|
this._eventBus.emit("init_model");
|
|
@@ -2195,12 +2195,12 @@ class kn {
|
|
|
2195
2195
|
const Mt = window.devicePixelRatio || 2;
|
|
2196
2196
|
class S {
|
|
2197
2197
|
constructor({ tag: t, className: e, id: i, textContent: n }) {
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2198
|
+
h(this, "_tag");
|
|
2199
|
+
h(this, "_className");
|
|
2200
|
+
h(this, "_id");
|
|
2201
|
+
h(this, "_textContent");
|
|
2202
|
+
h(this, "_node");
|
|
2203
|
+
h(this, "_absolutePosition", new DOMRect());
|
|
2204
2204
|
this._tag = t || "div", this._className = e || "", this._id = i || "", this._textContent = n || "";
|
|
2205
2205
|
const r = document.createElement(this._tag);
|
|
2206
2206
|
this._className && (r.className = this._className), this._id && (r.id = this._id), this._textContent && (r.textContent = this._textContent), this._node = r;
|
|
@@ -2238,10 +2238,10 @@ class St extends S {
|
|
|
2238
2238
|
className: `${e} sc-charts-cs__canvas ${a ? "" : "sc-charts-cs__canvas-additional"}`,
|
|
2239
2239
|
id: i
|
|
2240
2240
|
});
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2241
|
+
h(this, "_ctx");
|
|
2242
|
+
h(this, "_width");
|
|
2243
|
+
h(this, "_height");
|
|
2244
|
+
h(this, "background", null);
|
|
2245
2245
|
this._width = n, this._height = r, this.updateSize({ width: n, height: r });
|
|
2246
2246
|
const l = this._node.getContext("2d");
|
|
2247
2247
|
if (!l) throw new Error("Failed to get 2D context");
|
|
@@ -2478,16 +2478,16 @@ function $e(s, t, e) {
|
|
|
2478
2478
|
if (i == n)
|
|
2479
2479
|
r = a = 0;
|
|
2480
2480
|
else {
|
|
2481
|
-
var
|
|
2482
|
-
switch (a = l > 0.5 ?
|
|
2481
|
+
var d = i - n;
|
|
2482
|
+
switch (a = l > 0.5 ? d / (2 - i - n) : d / (i + n), i) {
|
|
2483
2483
|
case s:
|
|
2484
|
-
r = (t - e) /
|
|
2484
|
+
r = (t - e) / d + (t < e ? 6 : 0);
|
|
2485
2485
|
break;
|
|
2486
2486
|
case t:
|
|
2487
|
-
r = (e - s) /
|
|
2487
|
+
r = (e - s) / d + 2;
|
|
2488
2488
|
break;
|
|
2489
2489
|
case e:
|
|
2490
|
-
r = (s - t) /
|
|
2490
|
+
r = (s - t) / d + 4;
|
|
2491
2491
|
break;
|
|
2492
2492
|
}
|
|
2493
2493
|
r /= 6;
|
|
@@ -2501,14 +2501,14 @@ function $e(s, t, e) {
|
|
|
2501
2501
|
function In(s, t, e) {
|
|
2502
2502
|
var i, n, r;
|
|
2503
2503
|
s = R(s, 360), t = R(t, 100), e = R(e, 100);
|
|
2504
|
-
function a(
|
|
2505
|
-
return _ < 0 && (_ += 1), _ > 1 && (_ -= 1), _ < 1 / 6 ?
|
|
2504
|
+
function a(c, g, _) {
|
|
2505
|
+
return _ < 0 && (_ += 1), _ > 1 && (_ -= 1), _ < 1 / 6 ? c + (g - c) * 6 * _ : _ < 1 / 2 ? g : _ < 2 / 3 ? c + (g - c) * (2 / 3 - _) * 6 : c;
|
|
2506
2506
|
}
|
|
2507
2507
|
if (t === 0)
|
|
2508
2508
|
i = n = r = e;
|
|
2509
2509
|
else {
|
|
2510
|
-
var l = e < 0.5 ? e * (1 + t) : e + t - e * t,
|
|
2511
|
-
i = a(
|
|
2510
|
+
var l = e < 0.5 ? e * (1 + t) : e + t - e * t, d = 2 * e - l;
|
|
2511
|
+
i = a(d, l, s + 1 / 3), n = a(d, l, s), r = a(d, l, s - 1 / 3);
|
|
2512
2512
|
}
|
|
2513
2513
|
return {
|
|
2514
2514
|
r: i * 255,
|
|
@@ -2518,19 +2518,19 @@ function In(s, t, e) {
|
|
|
2518
2518
|
}
|
|
2519
2519
|
function Pe(s, t, e) {
|
|
2520
2520
|
s = R(s, 255), t = R(t, 255), e = R(e, 255);
|
|
2521
|
-
var i = Math.max(s, t, e), n = Math.min(s, t, e), r, a, l = i,
|
|
2522
|
-
if (a = i === 0 ? 0 :
|
|
2521
|
+
var i = Math.max(s, t, e), n = Math.min(s, t, e), r, a, l = i, d = i - n;
|
|
2522
|
+
if (a = i === 0 ? 0 : d / i, i == n)
|
|
2523
2523
|
r = 0;
|
|
2524
2524
|
else {
|
|
2525
2525
|
switch (i) {
|
|
2526
2526
|
case s:
|
|
2527
|
-
r = (t - e) /
|
|
2527
|
+
r = (t - e) / d + (t < e ? 6 : 0);
|
|
2528
2528
|
break;
|
|
2529
2529
|
case t:
|
|
2530
|
-
r = (e - s) /
|
|
2530
|
+
r = (e - s) / d + 2;
|
|
2531
2531
|
break;
|
|
2532
2532
|
case e:
|
|
2533
|
-
r = (s - t) /
|
|
2533
|
+
r = (s - t) / d + 4;
|
|
2534
2534
|
break;
|
|
2535
2535
|
}
|
|
2536
2536
|
r /= 6;
|
|
@@ -2543,9 +2543,9 @@ function Pe(s, t, e) {
|
|
|
2543
2543
|
}
|
|
2544
2544
|
function Fn(s, t, e) {
|
|
2545
2545
|
s = R(s, 360) * 6, t = R(t, 100), e = R(e, 100);
|
|
2546
|
-
var i = Math.floor(s), n = s - i, r = e * (1 - t), a = e * (1 - n * t), l = e * (1 - (1 - n) * t),
|
|
2546
|
+
var i = Math.floor(s), n = s - i, r = e * (1 - t), a = e * (1 - n * t), l = e * (1 - (1 - n) * t), d = i % 6, c = [e, a, r, r, l, e][d], g = [l, e, e, a, r, r][d], _ = [r, r, l, e, e, a][d];
|
|
2547
2547
|
return {
|
|
2548
|
-
r:
|
|
2548
|
+
r: c * 255,
|
|
2549
2549
|
g: g * 255,
|
|
2550
2550
|
b: _ * 255
|
|
2551
2551
|
};
|
|
@@ -2679,13 +2679,13 @@ A.isReadable = function(s, t, e) {
|
|
|
2679
2679
|
return r;
|
|
2680
2680
|
};
|
|
2681
2681
|
A.mostReadable = function(s, t, e) {
|
|
2682
|
-
var i = null, n = 0, r, a, l,
|
|
2683
|
-
e = e || {}, a = e.includeFallbackColors, l = e.level,
|
|
2684
|
-
for (var
|
|
2685
|
-
r = A.readability(s, t[
|
|
2682
|
+
var i = null, n = 0, r, a, l, d;
|
|
2683
|
+
e = e || {}, a = e.includeFallbackColors, l = e.level, d = e.size;
|
|
2684
|
+
for (var c = 0; c < t.length; c++)
|
|
2685
|
+
r = A.readability(s, t[c]), r > n && (n = r, i = A(t[c]));
|
|
2686
2686
|
return A.isReadable(s, i, {
|
|
2687
2687
|
level: l,
|
|
2688
|
-
size:
|
|
2688
|
+
size: d
|
|
2689
2689
|
}) || !a ? i : (e.includeFallbackColors = !1, A.mostReadable(s, ["#fff", "#000"], e));
|
|
2690
2690
|
};
|
|
2691
2691
|
var ee = A.names = {
|
|
@@ -2972,21 +2972,21 @@ function Qn(s) {
|
|
|
2972
2972
|
};
|
|
2973
2973
|
}
|
|
2974
2974
|
function Qe(s, t, e, { fillColor: i, strokeColor: n, candleWidth: r, strokeWidth: a }, l) {
|
|
2975
|
-
const
|
|
2976
|
-
s.fillStyle = b(i), s.strokeStyle = b(n), s.lineWidth = a, s.beginPath(), s.moveTo(g,
|
|
2975
|
+
const d = (y) => e.scales.x.convert(y), c = (y) => e.scales.y.convert(y), g = d(t.open_time), _ = c(t.open), m = c(t.close), p = e.trade.timeRange.includes(t.open_time.getTime()), v = e.trade.timeRange.length && !p, b = (y) => v ? A.mix(y, l).toString() : y;
|
|
2976
|
+
s.fillStyle = b(i), s.strokeStyle = b(n), s.lineWidth = a, s.beginPath(), s.moveTo(g, c(t.high)), s.lineTo(g, c(t.low)), s.stroke();
|
|
2977
2977
|
const x = Math.min(_, m), C = Math.abs(m - _), w = g - r / 2;
|
|
2978
2978
|
s.fillRect(w, x, r, C), s.strokeRect(w, x, r, C);
|
|
2979
2979
|
}
|
|
2980
2980
|
function Kn(s, t) {
|
|
2981
2981
|
const { strokeWidth: e, style: i } = t.config.candles, { candles: n, bg: r } = t.colorScheme, a = t.config.candles.baseWidth * t.scales.factorX;
|
|
2982
|
-
t.candles.missingData.forEach((l,
|
|
2983
|
-
const
|
|
2982
|
+
t.candles.missingData.forEach((l, d) => {
|
|
2983
|
+
const c = n.noDataFill[d % n.noDataFill.length], g = i === "filled" ? c : n.noDataStroke;
|
|
2984
2984
|
Qe(
|
|
2985
2985
|
s,
|
|
2986
2986
|
l,
|
|
2987
2987
|
t,
|
|
2988
2988
|
{
|
|
2989
|
-
fillColor:
|
|
2989
|
+
fillColor: c,
|
|
2990
2990
|
strokeColor: g,
|
|
2991
2991
|
candleWidth: a,
|
|
2992
2992
|
strokeWidth: e
|
|
@@ -2998,14 +2998,14 @@ function Kn(s, t) {
|
|
|
2998
2998
|
function tr(s, t) {
|
|
2999
2999
|
const { strokeWidth: e, style: i } = t.config.candles, n = t.config.candles.baseWidth * t.scales.factorX, { candles: r, bg: a } = t.colorScheme;
|
|
3000
3000
|
t.candles.preparedData.forEach((l) => {
|
|
3001
|
-
const
|
|
3001
|
+
const d = l.close >= l.open ? "up" : "down", c = d === "up" ? r.risingFill : r.fallingFill, g = d === "up" ? r.risingStroke : r.fallingStroke;
|
|
3002
3002
|
Qe(
|
|
3003
3003
|
s,
|
|
3004
3004
|
l,
|
|
3005
3005
|
t,
|
|
3006
3006
|
{
|
|
3007
|
-
fillColor:
|
|
3008
|
-
strokeColor: i === "filled" ?
|
|
3007
|
+
fillColor: c,
|
|
3008
|
+
strokeColor: i === "filled" ? c : g,
|
|
3009
3009
|
candleWidth: n,
|
|
3010
3010
|
strokeWidth: e
|
|
3011
3011
|
},
|
|
@@ -3025,10 +3025,10 @@ function ir(s, t) {
|
|
|
3025
3025
|
colorScheme: { xAxis: i },
|
|
3026
3026
|
config: { xAxis: n },
|
|
3027
3027
|
scales: r
|
|
3028
|
-
} = t, a = r.x.ticks(sr), l = (
|
|
3029
|
-
s.save(), s.fillStyle = i.bg, s.fillRect(e.x, e.y, e.width, e.height), s.restore(), s.fillStyle = i.text, s.font = `${n.text.fontSize} ${n.text.font}`, s.textAlign = "center", s.textBaseline = "middle", a.forEach((
|
|
3030
|
-
const
|
|
3031
|
-
s.fillText(
|
|
3028
|
+
} = t, a = r.x.ticks(sr), l = (g) => g.getHours() === 0 && g.getMinutes() === 0, d = E.timeFormat("%d %b"), c = E.timeFormat("%H:%M");
|
|
3029
|
+
s.save(), s.fillStyle = i.bg, s.fillRect(e.x, e.y, e.width, e.height), s.restore(), s.fillStyle = i.text, s.font = `${n.text.fontSize} ${n.text.font}`, s.textAlign = "center", s.textBaseline = "middle", a.forEach((g) => {
|
|
3030
|
+
const _ = r.x.convert(g), m = l(g) ? d(g) : c(g);
|
|
3031
|
+
s.fillText(m, _, e.y + e.height / 2);
|
|
3032
3032
|
});
|
|
3033
3033
|
}
|
|
3034
3034
|
function nr(s, t) {
|
|
@@ -3038,9 +3038,9 @@ function nr(s, t) {
|
|
|
3038
3038
|
config: { yAxis: n },
|
|
3039
3039
|
scales: r
|
|
3040
3040
|
} = t, a = r.y.ticks(6), l = r.y.tickFormat(6);
|
|
3041
|
-
s.save(), s.fillStyle = i.bg, s.fillRect(e.x, e.y, e.width, e.height), s.restore(), s.fillStyle = i.text, s.font = `${n.text.fontSize} ${n.text.font}`, s.textAlign = "center", s.textBaseline = "middle", a.forEach((
|
|
3042
|
-
const
|
|
3043
|
-
s.fillText(g, e.x + e.width / 2,
|
|
3041
|
+
s.save(), s.fillStyle = i.bg, s.fillRect(e.x, e.y, e.width, e.height), s.restore(), s.fillStyle = i.text, s.font = `${n.text.fontSize} ${n.text.font}`, s.textAlign = "center", s.textBaseline = "middle", a.forEach((d) => {
|
|
3042
|
+
const c = r.y.convert(d), g = l(d);
|
|
3043
|
+
s.fillText(g, e.x + e.width / 2, c);
|
|
3044
3044
|
});
|
|
3045
3045
|
}
|
|
3046
3046
|
const rr = (s, t) => {
|
|
@@ -3068,7 +3068,7 @@ class qt {
|
|
|
3068
3068
|
}
|
|
3069
3069
|
class ar {
|
|
3070
3070
|
constructor(t) {
|
|
3071
|
-
|
|
3071
|
+
h(this, "_target");
|
|
3072
3072
|
this._target = t;
|
|
3073
3073
|
}
|
|
3074
3074
|
mousemove(t) {
|
|
@@ -3119,8 +3119,8 @@ class W {
|
|
|
3119
3119
|
lineLength: r,
|
|
3120
3120
|
text: a,
|
|
3121
3121
|
textColor: l,
|
|
3122
|
-
mainColor:
|
|
3123
|
-
lineColor:
|
|
3122
|
+
mainColor: d,
|
|
3123
|
+
lineColor: c,
|
|
3124
3124
|
position: g
|
|
3125
3125
|
}) {
|
|
3126
3126
|
W.line(e, {
|
|
@@ -3128,12 +3128,12 @@ class W {
|
|
|
3128
3128
|
x: i,
|
|
3129
3129
|
y: n,
|
|
3130
3130
|
lineLength: r,
|
|
3131
|
-
lineColor:
|
|
3131
|
+
lineColor: c
|
|
3132
3132
|
}), W.label_h(t, {
|
|
3133
3133
|
text: a,
|
|
3134
3134
|
y: n,
|
|
3135
3135
|
textColor: l,
|
|
3136
|
-
mainColor:
|
|
3136
|
+
mainColor: d,
|
|
3137
3137
|
position: g
|
|
3138
3138
|
});
|
|
3139
3139
|
}
|
|
@@ -3145,8 +3145,8 @@ class W {
|
|
|
3145
3145
|
lineLength: r,
|
|
3146
3146
|
text: a,
|
|
3147
3147
|
textColor: l,
|
|
3148
|
-
mainColor:
|
|
3149
|
-
lineColor:
|
|
3148
|
+
mainColor: d,
|
|
3149
|
+
lineColor: c,
|
|
3150
3150
|
position: g
|
|
3151
3151
|
}) {
|
|
3152
3152
|
W.line(e, {
|
|
@@ -3154,22 +3154,22 @@ class W {
|
|
|
3154
3154
|
x: i,
|
|
3155
3155
|
y: n,
|
|
3156
3156
|
lineLength: r,
|
|
3157
|
-
lineColor:
|
|
3157
|
+
lineColor: c
|
|
3158
3158
|
}), W.label_v(t, {
|
|
3159
3159
|
text: a,
|
|
3160
3160
|
x: i,
|
|
3161
3161
|
textColor: l,
|
|
3162
|
-
mainColor:
|
|
3162
|
+
mainColor: d,
|
|
3163
3163
|
position: g
|
|
3164
3164
|
});
|
|
3165
3165
|
}
|
|
3166
3166
|
}
|
|
3167
3167
|
class or {
|
|
3168
3168
|
constructor(t, e) {
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3169
|
+
h(this, "_canvas");
|
|
3170
|
+
h(this, "_parent");
|
|
3171
|
+
h(this, "_horizontalMarker");
|
|
3172
|
+
h(this, "_verticalMarker");
|
|
3173
3173
|
this._canvas = e;
|
|
3174
3174
|
const i = new S({ tag: "div", className: "sc-charts-cs__guide-markers" });
|
|
3175
3175
|
this._parent = i;
|
|
@@ -3195,9 +3195,9 @@ class or {
|
|
|
3195
3195
|
this._canvas.clear();
|
|
3196
3196
|
const {
|
|
3197
3197
|
layout: { area: n, chart: r },
|
|
3198
|
-
config: { guides: a, yAxis: l, xAxis:
|
|
3198
|
+
config: { guides: a, yAxis: l, xAxis: d },
|
|
3199
3199
|
colorScheme: {
|
|
3200
|
-
guides: { horizontalMarker:
|
|
3200
|
+
guides: { horizontalMarker: c, verticalMarker: g }
|
|
3201
3201
|
}
|
|
3202
3202
|
} = t;
|
|
3203
3203
|
a.isShowY && W.horizontalMarker({
|
|
@@ -3208,14 +3208,14 @@ class or {
|
|
|
3208
3208
|
lineLength: r.width,
|
|
3209
3209
|
text: t.scales.y.invert(i).toFixed(2),
|
|
3210
3210
|
position: l.position,
|
|
3211
|
-
mainColor:
|
|
3212
|
-
lineColor:
|
|
3213
|
-
textColor:
|
|
3211
|
+
mainColor: c.main,
|
|
3212
|
+
lineColor: c.line,
|
|
3213
|
+
textColor: c.text
|
|
3214
3214
|
}), a.isShowX && W.verticalMarker({
|
|
3215
3215
|
ctx: this._canvas.ctx,
|
|
3216
3216
|
node: this._verticalMarker.node,
|
|
3217
|
-
text:
|
|
3218
|
-
position:
|
|
3217
|
+
text: E.timeFormat("%a %d, %b %y %H:%M")(t.scales.x.invert(e)),
|
|
3218
|
+
position: d.position,
|
|
3219
3219
|
x: e,
|
|
3220
3220
|
y: n.top,
|
|
3221
3221
|
lineLength: r.height,
|
|
@@ -3248,12 +3248,12 @@ function hr(s, t) {
|
|
|
3248
3248
|
scales: { x: i, y: n },
|
|
3249
3249
|
colorScheme: r
|
|
3250
3250
|
} = t, { trade: a } = r, l = 4;
|
|
3251
|
-
e.forEach(({ isHovered:
|
|
3251
|
+
e.forEach(({ isHovered: d, isActive: c, candle: g, trades: _ }) => {
|
|
3252
3252
|
const m = i.convert(g.open_time);
|
|
3253
3253
|
_.forEach((p) => {
|
|
3254
3254
|
const v = p.type === "buy", b = v ? a.buyLabel.text : a.sellLabel.text, x = v ? "B" : "S", C = v ? n.convert(g.low) + l : n.convert(g.high) - l, w = v ? lr : cr;
|
|
3255
3255
|
let y = v ? a.buyLabel.main : a.sellLabel.main;
|
|
3256
|
-
|
|
3256
|
+
d && d[1] && d[0] === p.type && (y = A.mix(y, r.bg, 20).toString()), c && c[1] && c[0] === p.type && (y = a.activeLabel), w(s, {
|
|
3257
3257
|
x: m,
|
|
3258
3258
|
y: C,
|
|
3259
3259
|
symbol: x,
|
|
@@ -3270,12 +3270,12 @@ function dr(s, t) {
|
|
|
3270
3270
|
scales: { x: e, factorX: i },
|
|
3271
3271
|
layout: { area: n },
|
|
3272
3272
|
trade: { tradedCandles: r, exits: a, entries: l },
|
|
3273
|
-
config: { candles:
|
|
3274
|
-
colorScheme: { trade:
|
|
3273
|
+
config: { candles: d },
|
|
3274
|
+
colorScheme: { trade: c }
|
|
3275
3275
|
} = t;
|
|
3276
3276
|
if (r.length === 0) return;
|
|
3277
|
-
const g = r.map((m) => m.candle).sort((m, p) => m.open_time.getTime() - p.open_time.getTime()), _ =
|
|
3278
|
-
if (s.save(), s.lineWidth = 1, s.strokeStyle =
|
|
3277
|
+
const g = r.map((m) => m.candle).sort((m, p) => m.open_time.getTime() - p.open_time.getTime()), _ = d.baseWidth / 2 * i + d.strokeWidth / 2;
|
|
3278
|
+
if (s.save(), s.lineWidth = 1, s.strokeStyle = c.tradeBorders, l.length) {
|
|
3279
3279
|
const m = e.convert(g[0].open_time) - _;
|
|
3280
3280
|
s.beginPath(), s.moveTo(m, n.y), s.lineTo(m, n.y + n.height), s.stroke();
|
|
3281
3281
|
}
|
|
@@ -3292,47 +3292,47 @@ const ur = (s, t) => {
|
|
|
3292
3292
|
colorScheme: { trade: l }
|
|
3293
3293
|
} = t;
|
|
3294
3294
|
s.save();
|
|
3295
|
-
const
|
|
3295
|
+
const d = (g) => {
|
|
3296
3296
|
var _;
|
|
3297
3297
|
return (_ = n.find(
|
|
3298
3298
|
(m) => g.getTime() >= m.candle.open_time.getTime() && g.getTime() < m.candle.close_time.getTime()
|
|
3299
3299
|
)) == null ? void 0 : _.candle;
|
|
3300
|
-
},
|
|
3301
|
-
const m =
|
|
3300
|
+
}, c = (g, _) => {
|
|
3301
|
+
const m = d(g.time), p = d(_.time);
|
|
3302
3302
|
if (!m || !p) return;
|
|
3303
3303
|
const v = e.convert(m.open_time), b = e.convert(p.open_time);
|
|
3304
3304
|
let x, C;
|
|
3305
3305
|
g.type === "buy" ? (x = i.convert(m.low), C = i.convert(p.high)) : (x = i.convert(m.high), C = i.convert(p.low)), s.beginPath(), s.setLineDash([4, 4]), s.strokeStyle = l.connectionLine, s.moveTo(v, x), s.lineTo(b, C), s.stroke(), s.setLineDash([]);
|
|
3306
3306
|
};
|
|
3307
3307
|
if (r.length === 1 && a.length > 1)
|
|
3308
|
-
a.forEach((g) =>
|
|
3308
|
+
a.forEach((g) => c(r[0], g));
|
|
3309
3309
|
else if (a.length === 1 && r.length > 1)
|
|
3310
|
-
r.forEach((g) =>
|
|
3310
|
+
r.forEach((g) => c(g, a[0]));
|
|
3311
3311
|
else if (r.length === 1 && a.length === 1)
|
|
3312
|
-
|
|
3312
|
+
c(r[0], a[0]);
|
|
3313
3313
|
else if (r.length > 0 && a.length > 0) {
|
|
3314
3314
|
const g = r.reduce((m, p) => m.time < p.time ? m : p), _ = a.reduce((m, p) => m.time > p.time ? m : p);
|
|
3315
|
-
|
|
3315
|
+
c(g, _);
|
|
3316
3316
|
}
|
|
3317
3317
|
s.restore();
|
|
3318
3318
|
};
|
|
3319
3319
|
class Ke extends S {
|
|
3320
3320
|
constructor({ className: e, isAdaptPosition: i } = {}) {
|
|
3321
3321
|
super({ tag: "div", className: e });
|
|
3322
|
-
|
|
3322
|
+
h(this, "_isAdaptPosition");
|
|
3323
3323
|
this._isAdaptPosition = !!i;
|
|
3324
3324
|
}
|
|
3325
3325
|
show({ x: e, y: i, parent: n, offset: r = 8 }) {
|
|
3326
3326
|
let a = e + r, l = i + r;
|
|
3327
3327
|
if (this._isAdaptPosition) {
|
|
3328
3328
|
this.updateAbsolutePosition();
|
|
3329
|
-
const
|
|
3329
|
+
const d = this.absolutePosition, c = {
|
|
3330
3330
|
top: 0,
|
|
3331
3331
|
left: 0,
|
|
3332
3332
|
bottom: n.bottom - n.top,
|
|
3333
3333
|
right: n.right - n.left
|
|
3334
3334
|
};
|
|
3335
|
-
a +
|
|
3335
|
+
a + d.width > c.right && (a = e - d.width - r, a < c.left + r && (a = c.left + r)), l + d.height > c.bottom && (l = i - d.height - r, l < c.top + r && (l = c.top + r));
|
|
3336
3336
|
}
|
|
3337
3337
|
this.node.style.opacity = "1", this.node.style.visibility = "visible", this.node.style.left = `${a}px`, this.node.style.top = `${l}px`;
|
|
3338
3338
|
}
|
|
@@ -3343,9 +3343,9 @@ class Ke extends S {
|
|
|
3343
3343
|
class gr extends Ke {
|
|
3344
3344
|
constructor() {
|
|
3345
3345
|
super({ className: "sc-charts-cs__trade-label-tooltip", isAdaptPosition: !0 });
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3346
|
+
h(this, "_title");
|
|
3347
|
+
h(this, "_manyBox");
|
|
3348
|
+
h(this, "_oneBox");
|
|
3349
3349
|
this._title = new S({
|
|
3350
3350
|
tag: "div",
|
|
3351
3351
|
className: "sc-charts-cs__trade-label-tooltip-title"
|
|
@@ -3368,8 +3368,8 @@ class gr extends Ke {
|
|
|
3368
3368
|
});
|
|
3369
3369
|
let l = e[r].toString();
|
|
3370
3370
|
r === "kind" && (l = this._formatDate(e.time));
|
|
3371
|
-
const
|
|
3372
|
-
a.append(
|
|
3371
|
+
const d = new S({ tag: "strong", textContent: i[r] }), c = new S({ tag: "span", textContent: l });
|
|
3372
|
+
a.append(d.node, c.node), n.push(a.node);
|
|
3373
3373
|
}
|
|
3374
3374
|
return n;
|
|
3375
3375
|
}
|
|
@@ -3448,13 +3448,13 @@ const mr = 10, pr = 6, vr = 4, br = 12, yr = (s, t) => {
|
|
|
3448
3448
|
trade: { hold: l }
|
|
3449
3449
|
},
|
|
3450
3450
|
config: {
|
|
3451
|
-
trade: { showHoldTime:
|
|
3451
|
+
trade: { showHoldTime: d }
|
|
3452
3452
|
}
|
|
3453
3453
|
} = t;
|
|
3454
|
-
if (!
|
|
3455
|
-
const
|
|
3456
|
-
if (!
|
|
3457
|
-
const _ = e.convert(
|
|
3454
|
+
if (!d) return;
|
|
3455
|
+
const c = n.at(0), g = r.at(-1);
|
|
3456
|
+
if (!c || !g) return;
|
|
3457
|
+
const _ = e.convert(c.candle.open_time), m = e.convert(g.candle.open_time), p = i.convert(((O = n.at(0)) == null ? void 0 : O.price) ?? 0);
|
|
3458
3458
|
s.beginPath(), s.setLineDash([4, 4]), s.strokeStyle = l.main, s.moveTo(_, p), s.lineTo(m, p), s.stroke(), s.setLineDash([]);
|
|
3459
3459
|
const v = (_ + m) / 2, b = `Hold: ${fr(a)}`, C = getComputedStyle(
|
|
3460
3460
|
document.querySelector(".sc-charts-cs") || document.body
|
|
@@ -3470,8 +3470,8 @@ const mr = 10, pr = 6, vr = 4, br = 12, yr = (s, t) => {
|
|
|
3470
3470
|
};
|
|
3471
3471
|
class xr {
|
|
3472
3472
|
constructor({ domParent: t, canvasParent: e, width: i, height: n }) {
|
|
3473
|
-
|
|
3474
|
-
|
|
3473
|
+
h(this, "_canvas");
|
|
3474
|
+
h(this, "_labelTooltip");
|
|
3475
3475
|
this._canvas = new St({ className: "sc-charts-cs__canvas-trade", width: i, height: n }), this._labelTooltip = new gr(), e.append(this._canvas.node), t.append(this._labelTooltip.node);
|
|
3476
3476
|
}
|
|
3477
3477
|
get canvas() {
|
|
@@ -3486,10 +3486,10 @@ class xr {
|
|
|
3486
3486
|
}
|
|
3487
3487
|
class wr {
|
|
3488
3488
|
constructor(t, e) {
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3489
|
+
h(this, "canvas");
|
|
3490
|
+
h(this, "parent");
|
|
3491
|
+
h(this, "items", {});
|
|
3492
|
+
h(this, "className");
|
|
3493
3493
|
this.className = e, this.canvas = new St({
|
|
3494
3494
|
width: t.width,
|
|
3495
3495
|
height: t.height,
|
|
@@ -3544,8 +3544,8 @@ class Cr extends Ke {
|
|
|
3544
3544
|
class et extends S {
|
|
3545
3545
|
constructor(e) {
|
|
3546
3546
|
super(e);
|
|
3547
|
-
|
|
3548
|
-
|
|
3547
|
+
h(this, "_state", {});
|
|
3548
|
+
h(this, "_updateScheduled", !1);
|
|
3549
3549
|
}
|
|
3550
3550
|
get state() {
|
|
3551
3551
|
return this._state;
|
|
@@ -3579,7 +3579,7 @@ class et extends S {
|
|
|
3579
3579
|
const Mr = "sc-charts-cs";
|
|
3580
3580
|
class q {
|
|
3581
3581
|
constructor(t) {
|
|
3582
|
-
|
|
3582
|
+
h(this, "block");
|
|
3583
3583
|
this.block = t;
|
|
3584
3584
|
}
|
|
3585
3585
|
gen(t) {
|
|
@@ -3610,8 +3610,8 @@ function ie(s, t) {
|
|
|
3610
3610
|
if (s.node.contains(a)) return;
|
|
3611
3611
|
const l = document.elementFromPoint(r.clientX, r.clientY);
|
|
3612
3612
|
if (l && s.node.contains(l)) return;
|
|
3613
|
-
const
|
|
3614
|
-
r.clientX >=
|
|
3613
|
+
const d = s.node.getBoundingClientRect();
|
|
3614
|
+
r.clientX >= d.left && r.clientX <= d.right && r.clientY >= d.top && r.clientY <= d.bottom && getComputedStyle(s.node).pointerEvents !== "none" || t(r);
|
|
3615
3615
|
};
|
|
3616
3616
|
document.addEventListener("mousedown", e);
|
|
3617
3617
|
const i = (n = s.destroy) == null ? void 0 : n.bind(s);
|
|
@@ -3621,7 +3621,7 @@ function ie(s, t) {
|
|
|
3621
3621
|
}
|
|
3622
3622
|
class Tr {
|
|
3623
3623
|
constructor() {
|
|
3624
|
-
|
|
3624
|
+
h(this, "node");
|
|
3625
3625
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
3626
3626
|
e.setAttribute("width", "18"), e.setAttribute("height", "4"), e.setAttribute("viewBox", "0 0 18 4"), e.setAttribute("fill", "none"), e.setAttribute("xmlns", t);
|
|
3627
3627
|
const i = [
|
|
@@ -3661,8 +3661,8 @@ const ht = new q("comment-list");
|
|
|
3661
3661
|
class Sr extends S {
|
|
3662
3662
|
constructor({ onDelete: e, onOpenEditor: i, comment: n, layout: r }) {
|
|
3663
3663
|
super({ className: ht.gen("item") });
|
|
3664
|
-
|
|
3665
|
-
|
|
3664
|
+
h(this, "actionTooltip");
|
|
3665
|
+
h(this, "actionsTrigger");
|
|
3666
3666
|
const a = new S({ className: ht.gen("text"), textContent: n.text }), l = new S({
|
|
3667
3667
|
className: ht.gen("created-at"),
|
|
3668
3668
|
textContent: _r(new Date(n.createdAt))
|
|
@@ -3671,22 +3671,22 @@ class Sr extends S {
|
|
|
3671
3671
|
tag: "button",
|
|
3672
3672
|
className: ht.gen("action-trigger")
|
|
3673
3673
|
});
|
|
3674
|
-
const
|
|
3674
|
+
const d = new Ar({
|
|
3675
3675
|
onDelete: e,
|
|
3676
3676
|
onUpdate: i
|
|
3677
3677
|
});
|
|
3678
|
-
this.actionTooltip = ie(
|
|
3678
|
+
this.actionTooltip = ie(d, () => {
|
|
3679
3679
|
this.actionTooltip.setVisible(!1);
|
|
3680
3680
|
}), this.actionsTrigger.node.addEventListener("click", () => {
|
|
3681
3681
|
this.actionsTrigger.updateAbsolutePosition(), this.actionTooltip.updateAbsolutePosition(), this.actionTooltip.node.style.top = this.actionsTrigger.absolutePosition.top - r.chart.top + 20 + "px", this.actionTooltip.node.style.left = this.actionsTrigger.absolutePosition.left - r.chart.left - this.actionTooltip.absolutePosition.width + 10 + "px", this.actionTooltip.setVisible(!0);
|
|
3682
3682
|
});
|
|
3683
|
-
const
|
|
3684
|
-
this.actionTooltip.node.setAttribute("id", `ac-${n.id}`),
|
|
3683
|
+
const c = new S({ className: ht.gen("text-wrap") });
|
|
3684
|
+
this.actionTooltip.node.setAttribute("id", `ac-${n.id}`), c.append(a.node, this.actionsTrigger.node), this.actionsTrigger.append(new Tr().node), this.append(c.node, l.node);
|
|
3685
3685
|
}
|
|
3686
3686
|
}
|
|
3687
3687
|
class kr {
|
|
3688
3688
|
constructor() {
|
|
3689
|
-
|
|
3689
|
+
h(this, "node");
|
|
3690
3690
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
3691
3691
|
e.setAttribute("width", "14"), e.setAttribute("height", "12"), e.setAttribute("viewBox", "0 0 14 12"), e.setAttribute("fill", "none"), e.setAttribute("xmlns", t);
|
|
3692
3692
|
const i = document.createElementNS(t, "path");
|
|
@@ -3698,7 +3698,7 @@ class kr {
|
|
|
3698
3698
|
}
|
|
3699
3699
|
class Dr {
|
|
3700
3700
|
constructor() {
|
|
3701
|
-
|
|
3701
|
+
h(this, "node");
|
|
3702
3702
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
3703
3703
|
e.setAttribute("width", "10"), e.setAttribute("height", "10"), e.setAttribute("viewBox", "0 0 10 10"), e.setAttribute("fill", "none"), e.setAttribute("xmlns", t);
|
|
3704
3704
|
const i = document.createElementNS(t, "path");
|
|
@@ -3711,11 +3711,11 @@ class Dr {
|
|
|
3711
3711
|
class Er extends et {
|
|
3712
3712
|
constructor(e) {
|
|
3713
3713
|
super({ className: "sc-charts-cs__comments-edit" });
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3714
|
+
h(this, "input");
|
|
3715
|
+
h(this, "saveBtn");
|
|
3716
|
+
h(this, "cancelBtn");
|
|
3717
|
+
h(this, "_onSave");
|
|
3718
|
+
h(this, "_onCancel");
|
|
3719
3719
|
this._onSave = e.onSave, this._onCancel = e.onCancel, this.input = new S({ tag: "textarea", className: "sc-charts-cs__comments-edit-input" }), this.saveBtn = new S({
|
|
3720
3720
|
tag: "button",
|
|
3721
3721
|
className: "sc-charts-cs__comments-edit-save-btn"
|
|
@@ -3742,9 +3742,9 @@ const Lr = new q("comment-list");
|
|
|
3742
3742
|
class Nr extends et {
|
|
3743
3743
|
constructor(e, i, n, r = {}) {
|
|
3744
3744
|
super({ tag: "ul", className: Lr.gen(), ...r });
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3745
|
+
h(this, "_elements", {});
|
|
3746
|
+
h(this, "_model");
|
|
3747
|
+
h(this, "_view");
|
|
3748
3748
|
this._model = i, this._view = n, this.state = { items: e, editId: null }, this.render();
|
|
3749
3749
|
}
|
|
3750
3750
|
render() {
|
|
@@ -3784,7 +3784,7 @@ class Nr extends et {
|
|
|
3784
3784
|
}
|
|
3785
3785
|
class Ir {
|
|
3786
3786
|
constructor() {
|
|
3787
|
-
|
|
3787
|
+
h(this, "node");
|
|
3788
3788
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
3789
3789
|
e.setAttribute("width", "14"), e.setAttribute("height", "14"), e.setAttribute("viewBox", "0 0 14 14"), e.setAttribute("fill", "none"), e.setAttribute("xmlns", t);
|
|
3790
3790
|
const i = document.createElementNS(t, "path");
|
|
@@ -3799,9 +3799,9 @@ class ts extends et {
|
|
|
3799
3799
|
constructor({ onAdd: e, blockName: i }) {
|
|
3800
3800
|
At.block = i;
|
|
3801
3801
|
super({ className: At.gen() + " " + Qt.gen() });
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3802
|
+
h(this, "btn");
|
|
3803
|
+
h(this, "input");
|
|
3804
|
+
h(this, "_onAdd");
|
|
3805
3805
|
this._onAdd = e, this.state = { inputValue: "" }, this.input = new S({
|
|
3806
3806
|
tag: "input",
|
|
3807
3807
|
className: At.gen("input") + " " + Qt.gen("input")
|
|
@@ -3831,22 +3831,22 @@ const Fr = new q("list-tooltip"), Kt = 8;
|
|
|
3831
3831
|
class Br extends et {
|
|
3832
3832
|
constructor(e, i, n) {
|
|
3833
3833
|
super({ className: Fr.gen() });
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3834
|
+
h(this, "_list");
|
|
3835
|
+
h(this, "_addField");
|
|
3836
|
+
h(this, "_size", null);
|
|
3837
|
+
h(this, "_model");
|
|
3838
|
+
h(this, "_prevIsShow", !1);
|
|
3839
3839
|
this._model = i, this.state = { isShow: !1, comments: e }, this._list = new Nr(e, i, n), this._addField = new ts({
|
|
3840
3840
|
blockName: "list-tooltip-add",
|
|
3841
3841
|
onAdd: (r) => {
|
|
3842
|
-
const a = e[0].date, l = e[0].price,
|
|
3842
|
+
const a = e[0].date, l = e[0].price, d = {
|
|
3843
3843
|
id: crypto.randomUUID(),
|
|
3844
3844
|
text: r,
|
|
3845
3845
|
date: a,
|
|
3846
3846
|
price: l,
|
|
3847
3847
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3848
3848
|
};
|
|
3849
|
-
i.comments.add(
|
|
3849
|
+
i.comments.add(d);
|
|
3850
3850
|
}
|
|
3851
3851
|
}), this.node.append(this._list.node, this._addField.node);
|
|
3852
3852
|
}
|
|
@@ -3862,7 +3862,7 @@ class Br extends et {
|
|
|
3862
3862
|
}
|
|
3863
3863
|
class Hr {
|
|
3864
3864
|
constructor() {
|
|
3865
|
-
|
|
3865
|
+
h(this, "node");
|
|
3866
3866
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
3867
3867
|
e.setAttribute("width", "16"), e.setAttribute("height", "16"), e.setAttribute("viewBox", "0 0 16 16"), e.setAttribute("fill", "none"), e.setAttribute("xmlns", t);
|
|
3868
3868
|
const i = document.createElementNS(t, "path");
|
|
@@ -3875,7 +3875,7 @@ class Hr {
|
|
|
3875
3875
|
class Rr extends et {
|
|
3876
3876
|
constructor({ x: e, ...i }, n) {
|
|
3877
3877
|
super(i);
|
|
3878
|
-
|
|
3878
|
+
h(this, "_colors");
|
|
3879
3879
|
this._colors = n.colorScheme.comments.scaleAnchor, this.state = {
|
|
3880
3880
|
x: e,
|
|
3881
3881
|
y: n.layout.xAxis.top,
|
|
@@ -3891,23 +3891,23 @@ class Rr extends et {
|
|
|
3891
3891
|
}
|
|
3892
3892
|
const We = new q("comment-box");
|
|
3893
3893
|
class zr extends et {
|
|
3894
|
-
constructor({ boxId: e, model: i, view: n, comments: r, coords: a, onBoxActivate: l, onBoxDeactivate:
|
|
3894
|
+
constructor({ boxId: e, model: i, view: n, comments: r, coords: a, onBoxActivate: l, onBoxDeactivate: d }) {
|
|
3895
3895
|
super({ className: We.gen() });
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
this._boxId = e, this._onBoxActivate = l, this._onBoxDeactivate =
|
|
3896
|
+
h(this, "pointer", new S({ className: "sc-charts-cs__comments-pointer" }));
|
|
3897
|
+
h(this, "tooltip");
|
|
3898
|
+
h(this, "anchor");
|
|
3899
|
+
h(this, "_onBoxActivate");
|
|
3900
|
+
h(this, "_onBoxDeactivate");
|
|
3901
|
+
h(this, "_boxId");
|
|
3902
|
+
this._boxId = e, this._onBoxActivate = l, this._onBoxDeactivate = d, this.state = {
|
|
3903
3903
|
isActive: !1,
|
|
3904
3904
|
comments: r,
|
|
3905
3905
|
coords: a
|
|
3906
3906
|
}, this.pointer.position(a), this.anchor = new Rr({ x: a.x, className: We.gen("anchor") }, i), this.anchor.node.addEventListener("click", () => {
|
|
3907
|
-
const
|
|
3908
|
-
|
|
3909
|
-
}), this.tooltip = ie(new Br(r, i, n), (
|
|
3910
|
-
this.state.isActive && (this.anchor.node.contains(
|
|
3907
|
+
const c = !this.state.isActive;
|
|
3908
|
+
c ? this._onBoxActivate(this._boxId) : this._onBoxDeactivate(this._boxId), this.setState({ isActive: c });
|
|
3909
|
+
}), this.tooltip = ie(new Br(r, i, n), (c) => {
|
|
3910
|
+
this.state.isActive && (this.anchor.node.contains(c.target) || (this._onBoxDeactivate(this._boxId), this.setState({ isActive: !1 })));
|
|
3911
3911
|
}), this.append(this.pointer.node, this.anchor.node, this.tooltip.node), this.render();
|
|
3912
3912
|
}
|
|
3913
3913
|
render() {
|
|
@@ -3917,8 +3917,8 @@ class zr extends et {
|
|
|
3917
3917
|
}
|
|
3918
3918
|
class $r {
|
|
3919
3919
|
static animateTo(t, e, i, n) {
|
|
3920
|
-
const r = t.scales.panOffsetX + (t.layout.area.width / 2 - e), a = t.scales.panOffsetY + (t.layout.area.height / 2 - i), l = 300,
|
|
3921
|
-
const p = m -
|
|
3920
|
+
const r = t.scales.panOffsetX + (t.layout.area.width / 2 - e), a = t.scales.panOffsetY + (t.layout.area.height / 2 - i), l = 300, d = performance.now(), c = t.scales.panOffsetX, g = t.scales.panOffsetY, _ = (m) => {
|
|
3921
|
+
const p = m - d, v = Math.min(p / l, 1), b = v * v * (3 - 2 * v), x = c + (r - c) * b, C = g + (a - g) * b;
|
|
3922
3922
|
t.scales.pan("x", x, "absolute"), t.scales.pan("y", C, "absolute"), v < 1 ? requestAnimationFrame(_) : n == null || n();
|
|
3923
3923
|
};
|
|
3924
3924
|
requestAnimationFrame(_);
|
|
@@ -3940,11 +3940,11 @@ const Pr = {
|
|
|
3940
3940
|
prioritySide: i = "right-bottom",
|
|
3941
3941
|
offset: n = 8
|
|
3942
3942
|
}) => {
|
|
3943
|
-
const { width: r, height: a } = s, l = t.right - t.left,
|
|
3943
|
+
const { width: r, height: a } = s, l = t.right - t.left, d = t.bottom - t.top, c = (w) => {
|
|
3944
3944
|
const { dx: y, dy: T } = Pr[w], D = e.x + (y === 1 ? n : -r - n), N = e.y + (T === 1 ? n : -a - n);
|
|
3945
3945
|
return { x: D, y: N, side: w };
|
|
3946
|
-
}, g = ({ x: w, y }) => w >= 0 && y >= 0 && w + r <= l && y + a <=
|
|
3947
|
-
const w = e.y < 0, y = e.y + a >
|
|
3946
|
+
}, g = ({ x: w, y }) => w >= 0 && y >= 0 && w + r <= l && y + a <= d, _ = () => {
|
|
3947
|
+
const w = e.y < 0, y = e.y + a > d, T = e.x < 0, D = e.x + r > l;
|
|
3948
3948
|
return T && w ? "right-bottom" : T && y ? "right-top" : D && w ? "left-bottom" : D && y ? "left-top" : T ? "right-bottom" : D ? "left-bottom" : w ? "right-bottom" : y ? "right-top" : i;
|
|
3949
3949
|
}, p = [
|
|
3950
3950
|
i,
|
|
@@ -3955,14 +3955,14 @@ const Pr = {
|
|
|
3955
3955
|
].filter((w, y, T) => T.indexOf(w) === y), v = _();
|
|
3956
3956
|
let b = null;
|
|
3957
3957
|
for (const w of [v, ...p]) {
|
|
3958
|
-
const y =
|
|
3958
|
+
const y = c(w);
|
|
3959
3959
|
if (g(y)) {
|
|
3960
3960
|
b = y;
|
|
3961
3961
|
break;
|
|
3962
3962
|
}
|
|
3963
3963
|
}
|
|
3964
|
-
b || (b =
|
|
3965
|
-
const x = Math.min(Math.max(b.x, n), l - r - n), C = Math.min(Math.max(b.y, n),
|
|
3964
|
+
b || (b = c(v));
|
|
3965
|
+
const x = Math.min(Math.max(b.x, n), l - r - n), C = Math.min(Math.max(b.y, n), d - a - n);
|
|
3966
3966
|
return {
|
|
3967
3967
|
x,
|
|
3968
3968
|
y: C,
|
|
@@ -3972,12 +3972,12 @@ const Pr = {
|
|
|
3972
3972
|
class Yr extends et {
|
|
3973
3973
|
constructor() {
|
|
3974
3974
|
super({ className: te.gen() });
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3975
|
+
h(this, "pointer");
|
|
3976
|
+
h(this, "addField");
|
|
3977
|
+
h(this, "menu");
|
|
3978
|
+
h(this, "_size", null);
|
|
3979
|
+
h(this, "_model", null);
|
|
3980
|
+
h(this, "_candle", null);
|
|
3981
3981
|
this.state = { candle: null, isShow: !1, model: null }, this.pointer = new S({ className: te.gen("pointer") }), this.menu = new S({ className: te.gen("menu") }), ie(this.menu, () => {
|
|
3982
3982
|
this.setState({ isShow: !1 });
|
|
3983
3983
|
}), this.addField = new ts({
|
|
@@ -4016,10 +4016,10 @@ class Yr extends et {
|
|
|
4016
4016
|
}
|
|
4017
4017
|
class jr {
|
|
4018
4018
|
constructor(t, e) {
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4019
|
+
h(this, "_container");
|
|
4020
|
+
h(this, "_boxes", {});
|
|
4021
|
+
h(this, "_contextMenu");
|
|
4022
|
+
h(this, "_view");
|
|
4023
4023
|
this._container = new S({ className: e }), this._contextMenu = new Yr(), this._view = t, t.domElements.append(this._container.node, this._contextMenu.node);
|
|
4024
4024
|
}
|
|
4025
4025
|
_getCandleCoords(t, e) {
|
|
@@ -4062,20 +4062,20 @@ class jr {
|
|
|
4062
4062
|
}
|
|
4063
4063
|
class Xr {
|
|
4064
4064
|
constructor(t) {
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4065
|
+
h(this, "_container");
|
|
4066
|
+
h(this, "_width");
|
|
4067
|
+
h(this, "_height");
|
|
4068
|
+
h(this, "_wrapper");
|
|
4069
|
+
h(this, "_domElements");
|
|
4070
|
+
h(this, "_canvasesContainer");
|
|
4071
|
+
h(this, "_mainCanvas");
|
|
4072
|
+
h(this, "_guidesCanvas");
|
|
4073
|
+
h(this, "_bindingManager");
|
|
4074
|
+
h(this, "_userMarkers");
|
|
4075
|
+
h(this, "_guideMarkers");
|
|
4076
|
+
h(this, "_trade");
|
|
4077
|
+
h(this, "_noDataTooltip");
|
|
4078
|
+
h(this, "_comments");
|
|
4079
4079
|
this._container = t, this._wrapper = new S({ tag: "div", className: "sc-charts-cs" }), t.append(this._wrapper.node);
|
|
4080
4080
|
const { width: e, height: i } = t.getBoundingClientRect();
|
|
4081
4081
|
this._width = e, this._height = i, this._mainCanvas = new St({
|
|
@@ -4138,7 +4138,7 @@ class Xr {
|
|
|
4138
4138
|
}
|
|
4139
4139
|
class Wr {
|
|
4140
4140
|
constructor(t) {
|
|
4141
|
-
|
|
4141
|
+
h(this, "logColors", {
|
|
4142
4142
|
init_model: "color: green",
|
|
4143
4143
|
scale_event: "color: orange",
|
|
4144
4144
|
update_config: "color: blue",
|
|
@@ -4147,7 +4147,7 @@ class Wr {
|
|
|
4147
4147
|
update_user_markers: "color: brown",
|
|
4148
4148
|
update_color_scheme: "color: teal"
|
|
4149
4149
|
});
|
|
4150
|
-
|
|
4150
|
+
h(this, "ignoredLogEvents", []);
|
|
4151
4151
|
t && (this.ignoredLogEvents = t);
|
|
4152
4152
|
}
|
|
4153
4153
|
log(t, e) {
|
|
@@ -4164,10 +4164,10 @@ class Wr {
|
|
|
4164
4164
|
}
|
|
4165
4165
|
class Vr {
|
|
4166
4166
|
constructor(t, e) {
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4167
|
+
h(this, "_model");
|
|
4168
|
+
h(this, "_view");
|
|
4169
|
+
h(this, "_enableLogging");
|
|
4170
|
+
h(this, "_logger");
|
|
4171
4171
|
this._model = t, this._view = e, this._enableLogging = !1, this._logger = new Wr(["scale_event"]);
|
|
4172
4172
|
}
|
|
4173
4173
|
subscribeWithLogging(t, e) {
|
|
@@ -4211,7 +4211,7 @@ class Vr {
|
|
|
4211
4211
|
}
|
|
4212
4212
|
class Ve {
|
|
4213
4213
|
constructor() {
|
|
4214
|
-
|
|
4214
|
+
h(this, "_map", /* @__PURE__ */ new Map());
|
|
4215
4215
|
}
|
|
4216
4216
|
add(t, e, i) {
|
|
4217
4217
|
let n = this._map.get(t);
|
|
@@ -4242,10 +4242,10 @@ class Ve {
|
|
|
4242
4242
|
}
|
|
4243
4243
|
class Gr {
|
|
4244
4244
|
constructor() {
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4245
|
+
h(this, "_elements", []);
|
|
4246
|
+
h(this, "_listeners", new Ve());
|
|
4247
|
+
h(this, "_lastHovered", /* @__PURE__ */ new Set());
|
|
4248
|
+
h(this, "_dragContext", null);
|
|
4249
4249
|
}
|
|
4250
4250
|
get isDragging() {
|
|
4251
4251
|
return this._dragContext !== null;
|
|
@@ -4399,7 +4399,7 @@ class Ur {
|
|
|
4399
4399
|
}
|
|
4400
4400
|
} = this.model;
|
|
4401
4401
|
for (const l of i) {
|
|
4402
|
-
const
|
|
4402
|
+
const d = n.convert(l.open_time), c = r.convert(l.high), g = r.convert(l.low), _ = d - a / 2, m = d + a / 2, p = Math.min(c, g), v = Math.max(c, g);
|
|
4403
4403
|
if (t >= _ && t <= m && e >= p && e <= v)
|
|
4404
4404
|
return {
|
|
4405
4405
|
target: this,
|
|
@@ -4414,9 +4414,9 @@ class Ur {
|
|
|
4414
4414
|
}
|
|
4415
4415
|
class Zr {
|
|
4416
4416
|
constructor(t, e) {
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4417
|
+
h(this, "_model");
|
|
4418
|
+
h(this, "_hitManager");
|
|
4419
|
+
h(this, "_hit");
|
|
4420
4420
|
this._model = t, this._hitManager = e, this._hit = new Ur(t), this._hitManager.register(this._hit);
|
|
4421
4421
|
}
|
|
4422
4422
|
register() {
|
|
@@ -4436,12 +4436,12 @@ class qr {
|
|
|
4436
4436
|
}
|
|
4437
4437
|
hitTest(t, e) {
|
|
4438
4438
|
const { tradedCandles: i } = this.model.trade, { x: n, y: r } = this.model.scales, a = 16, l = 4;
|
|
4439
|
-
for (const { candle:
|
|
4440
|
-
const _ = n.convert(
|
|
4439
|
+
for (const { candle: d, trades: c } of i) {
|
|
4440
|
+
const _ = n.convert(d.open_time) + this.model.config.candles.baseWidth / 2, m = a, p = a;
|
|
4441
4441
|
for (const v of ["buy", "sell"]) {
|
|
4442
|
-
const b =
|
|
4442
|
+
const b = c.filter((y) => y.type === v);
|
|
4443
4443
|
if (!b.length) continue;
|
|
4444
|
-
const x = v === "buy" ? r.convert(
|
|
4444
|
+
const x = v === "buy" ? r.convert(d.low) + l + Dt(a) : r.convert(d.high) - l - a - Dt(a), C = t >= _ - m / 2 && t <= _ + m / 2, w = e >= x && e <= x + p;
|
|
4445
4445
|
if (C && w)
|
|
4446
4446
|
return {
|
|
4447
4447
|
target: this,
|
|
@@ -4449,7 +4449,7 @@ class qr {
|
|
|
4449
4449
|
tradeType: v,
|
|
4450
4450
|
x: t,
|
|
4451
4451
|
y: e,
|
|
4452
|
-
candle:
|
|
4452
|
+
candle: d,
|
|
4453
4453
|
trades: b
|
|
4454
4454
|
};
|
|
4455
4455
|
}
|
|
@@ -4459,9 +4459,9 @@ class qr {
|
|
|
4459
4459
|
}
|
|
4460
4460
|
class Jr {
|
|
4461
4461
|
constructor(t, e) {
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4462
|
+
h(this, "_model");
|
|
4463
|
+
h(this, "_hitManager");
|
|
4464
|
+
h(this, "_tradeLabelHit");
|
|
4465
4465
|
this._model = t, this._hitManager = e, this._tradeLabelHit = new qr(t), this._hitManager.register(this._tradeLabelHit);
|
|
4466
4466
|
}
|
|
4467
4467
|
register() {
|
|
@@ -4532,15 +4532,15 @@ class ta {
|
|
|
4532
4532
|
}
|
|
4533
4533
|
class ea {
|
|
4534
4534
|
constructor(t, e) {
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4535
|
+
h(this, "_model");
|
|
4536
|
+
h(this, "_hitManager");
|
|
4537
|
+
h(this, "_hit");
|
|
4538
4538
|
this._model = t, this._hitManager = e, this._hit = new Qr(t), this._hitManager.register(this._hit);
|
|
4539
4539
|
}
|
|
4540
4540
|
register() {
|
|
4541
4541
|
this._hitManager.on(this._hit, "drag", (t) => {
|
|
4542
4542
|
const e = t.x - (t.prevX ?? t.x);
|
|
4543
|
-
this._model.scales.scale("x", e);
|
|
4543
|
+
this._model.scales.scale("x", -e);
|
|
4544
4544
|
}), this._hitManager.on(this._hit, "dblclick", () => {
|
|
4545
4545
|
this._model.scales.scale("x", 1, "absolute"), this._model.scales.pan("x", 0, "absolute");
|
|
4546
4546
|
});
|
|
@@ -4548,15 +4548,15 @@ class ea {
|
|
|
4548
4548
|
}
|
|
4549
4549
|
class sa {
|
|
4550
4550
|
constructor(t, e) {
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4551
|
+
h(this, "_model");
|
|
4552
|
+
h(this, "_hitManager");
|
|
4553
|
+
h(this, "_hit");
|
|
4554
4554
|
this._model = t, this._hitManager = e, this._hit = new ta(t), this._hitManager.register(this._hit);
|
|
4555
4555
|
}
|
|
4556
4556
|
register() {
|
|
4557
4557
|
this._hitManager.on(this._hit, "drag", (t) => {
|
|
4558
4558
|
const e = t.y - (t.prevY ?? t.y);
|
|
4559
|
-
this._model.scales.scale("y", e);
|
|
4559
|
+
this._model.scales.scale("y", -e);
|
|
4560
4560
|
}), this._hitManager.on(this._hit, "dblclick", () => {
|
|
4561
4561
|
this._model.scales.fitYToVisibleCandles();
|
|
4562
4562
|
});
|
|
@@ -4564,10 +4564,10 @@ class sa {
|
|
|
4564
4564
|
}
|
|
4565
4565
|
class ia {
|
|
4566
4566
|
constructor(t, e, i) {
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4567
|
+
h(this, "_model");
|
|
4568
|
+
h(this, "_view");
|
|
4569
|
+
h(this, "_hitManager");
|
|
4570
|
+
h(this, "_hit");
|
|
4571
4571
|
this._model = t, this._view = e, this._hitManager = i, this._hit = new Kr(t), this._hitManager.register(this._hit);
|
|
4572
4572
|
}
|
|
4573
4573
|
register() {
|
|
@@ -4594,12 +4594,12 @@ class ia {
|
|
|
4594
4594
|
}
|
|
4595
4595
|
class na {
|
|
4596
4596
|
constructor(t, e, i) {
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4597
|
+
h(this, "_hitManager");
|
|
4598
|
+
h(this, "_candlesHandler");
|
|
4599
|
+
h(this, "_tradeLabelsHandler");
|
|
4600
|
+
h(this, "_xAxisHandler");
|
|
4601
|
+
h(this, "_yAxisHandler");
|
|
4602
|
+
h(this, "_areaHandler");
|
|
4603
4603
|
this._hitManager = i, this._candlesHandler = new Zr(t, this._hitManager), this._tradeLabelsHandler = new Jr(t, this._hitManager), this._xAxisHandler = new ea(t, this._hitManager), this._yAxisHandler = new sa(t, this._hitManager), this._areaHandler = new ia(t, e, this._hitManager);
|
|
4604
4604
|
}
|
|
4605
4605
|
register() {
|
|
@@ -4608,12 +4608,12 @@ class na {
|
|
|
4608
4608
|
}
|
|
4609
4609
|
class ra {
|
|
4610
4610
|
constructor(t, e) {
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4611
|
+
h(this, "_model");
|
|
4612
|
+
h(this, "_view");
|
|
4613
|
+
h(this, "_subscriptionsManager");
|
|
4614
|
+
h(this, "_hitManager", new Gr());
|
|
4615
|
+
h(this, "_boundMouseMove", this.onDocumentMouseMove.bind(this));
|
|
4616
|
+
h(this, "_boundMouseUp", this.onDocumentMouseUp.bind(this));
|
|
4617
4617
|
this._model = t, this._view = e, this._subscriptionsManager = new Vr(t, e);
|
|
4618
4618
|
}
|
|
4619
4619
|
init() {
|
|
@@ -4674,12 +4674,12 @@ class ra {
|
|
|
4674
4674
|
}
|
|
4675
4675
|
}
|
|
4676
4676
|
class la {
|
|
4677
|
-
constructor(t, { chartId: e, candles: i, config: n, trade: r, userMarkers: a, colorScheme: l, comments:
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
const
|
|
4682
|
-
if (!
|
|
4677
|
+
constructor(t, { chartId: e, candles: i, config: n, trade: r, userMarkers: a, colorScheme: l, comments: d }) {
|
|
4678
|
+
h(this, "_model");
|
|
4679
|
+
h(this, "_view");
|
|
4680
|
+
h(this, "_controller");
|
|
4681
|
+
const c = document.querySelector(t);
|
|
4682
|
+
if (!c) throw new Error(`Element with selector "${t}" not found!`);
|
|
4683
4683
|
if (!e || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e))
|
|
4684
4684
|
throw new Error(
|
|
4685
4685
|
"chartId is required and must be a valid id (only letters, numbers or underscores. The first character must be a letter)"
|
|
@@ -4688,12 +4688,12 @@ class la {
|
|
|
4688
4688
|
chartId: e,
|
|
4689
4689
|
candles: i,
|
|
4690
4690
|
config: n,
|
|
4691
|
-
container:
|
|
4691
|
+
container: c,
|
|
4692
4692
|
trade: r,
|
|
4693
4693
|
userMarkers: a,
|
|
4694
4694
|
colorScheme: l,
|
|
4695
|
-
comments:
|
|
4696
|
-
}), this._view = new Xr(
|
|
4695
|
+
comments: d
|
|
4696
|
+
}), this._view = new Xr(c), this._controller = new ra(this._model, this._view), this._controller.init();
|
|
4697
4697
|
}
|
|
4698
4698
|
updateConfig(t) {
|
|
4699
4699
|
this._model.updateConfig(t);
|