charts-core 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts-core.js +1863 -1523
- 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,149 +1,149 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var ws = Object.defineProperty;
|
|
2
|
+
var Ms = (i, e, t) => e in i ? ws(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var g = (i, e, t) => Ms(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import * as k from "d3";
|
|
5
|
-
const
|
|
6
|
-
const { svg: e, config: t, y:
|
|
5
|
+
const Ts = (i) => {
|
|
6
|
+
const { svg: e, config: t, y: s, width: r } = i, { margin: n, yAxis: o } = t, { customTicks: l, tickFormat: h, tickValues: d, ticks: u, isShow: _ } = o;
|
|
7
7
|
if (!_) return null;
|
|
8
|
-
e.append("g").attr("transform", `translate(${r -
|
|
9
|
-
let p = k.axisRight(
|
|
10
|
-
l &&
|
|
11
|
-
const y = Number(v), b = (
|
|
8
|
+
e.append("g").attr("transform", `translate(${r - n.right},0)`).call((m) => {
|
|
9
|
+
let p = k.axisRight(s);
|
|
10
|
+
l && h ? p = p.tickFormat(h) : p = p.tickFormat((v) => {
|
|
11
|
+
const y = Number(v), b = (x) => x.toString().replace(/\.0+$/, "");
|
|
12
12
|
return Math.abs(y) >= 1e12 ? b(y / 1e12) + "T" : Math.abs(y) >= 1e9 ? b(y / 1e9) + "B" : Math.abs(y) >= 1e6 ? b(y / 1e6) + "M" : Math.abs(y) >= 1e3 ? b(y / 1e3) + "K" : b(y);
|
|
13
|
-
}), l && u && (p = Array.isArray(u) ? p.ticks(...u) : p.ticks(u)), l && d && (p = p.tickValues(d)),
|
|
14
|
-
}).call((
|
|
13
|
+
}), l && u && (p = Array.isArray(u) ? p.ticks(...u) : p.ticks(u)), l && d && (p = p.tickValues(d)), m.call(p);
|
|
14
|
+
}).call((m) => {
|
|
15
15
|
let p = [];
|
|
16
|
-
|
|
17
|
-
}).call((
|
|
18
|
-
const p =
|
|
16
|
+
m.selectAll(".tick").each((v) => p.push(v)), i.yTicks = p;
|
|
17
|
+
}).call((m) => m.select(".domain").remove()).call((m) => m.selectAll(".tick line").remove()).call((m) => {
|
|
18
|
+
const p = m.selectAll(".tick text");
|
|
19
19
|
p.classed("sc-charts__y-axis-tick", !0).attr("text-anchor", "start");
|
|
20
20
|
const v = p.nodes().map((b) => b.getBBox().width), y = Math.max(...v);
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
|
|
21
|
+
m.selectAll(".tick").each(function(b, x) {
|
|
22
|
+
var W;
|
|
23
|
+
const C = k.select(this), M = C.select("text"), E = v[x], $ = y - E, F = C.append("g").attr("transform", "translate(10, 0)");
|
|
24
|
+
M.attr("x", $), M.remove(), (W = F.node()) == null || W.appendChild(M.node());
|
|
25
25
|
});
|
|
26
26
|
}).attr("font-family", "inherit");
|
|
27
|
-
},
|
|
28
|
-
const { svg: e, config: t, x:
|
|
27
|
+
}, Cs = (i) => {
|
|
28
|
+
const { svg: e, config: t, x: s, height: r } = i, { margin: n, xAxis: o } = t, { isShow: l, tickValues: h, tickFormat: d, customTicks: u, ticks: _ } = o;
|
|
29
29
|
if (!l) return null;
|
|
30
|
-
e.append("g").attr("transform", `translate(0,${r -
|
|
31
|
-
let p = k.axisBottom(
|
|
32
|
-
u ? (d && (p = p.tickFormat(d)), _ && (p = Array.isArray(_) ? p.ticks(..._) : p.ticks(_)),
|
|
33
|
-
}).call((
|
|
30
|
+
e.append("g").attr("transform", `translate(0,${r - n.bottom})`).call((m) => {
|
|
31
|
+
let p = k.axisBottom(s);
|
|
32
|
+
u ? (d && (p = p.tickFormat(d)), _ && (p = Array.isArray(_) ? p.ticks(..._) : p.ticks(_)), h && (p = p.tickValues(h))) : p.ticks(5), m.call(p);
|
|
33
|
+
}).call((m) => m.select(".domain").remove()).call((m) => {
|
|
34
34
|
let p = [];
|
|
35
|
-
|
|
36
|
-
}).call((
|
|
37
|
-
},
|
|
38
|
-
const { svg: e, config: t, y:
|
|
39
|
-
margin:
|
|
35
|
+
m.selectAll(".tick").each((v) => p.push(v)), i.xTicks = p;
|
|
36
|
+
}).call((m) => m.selectAll(".tick line").remove()).call((m) => m.selectAll(".tick text").classed("sc-charts__x-axis-tick", !0)).attr("font-family", "inherit");
|
|
37
|
+
}, As = (i) => {
|
|
38
|
+
const { svg: e, config: t, y: s, width: r } = i, {
|
|
39
|
+
margin: n,
|
|
40
40
|
grid: { horizontalStyle: o }
|
|
41
41
|
} = t;
|
|
42
42
|
if (o !== "none") {
|
|
43
43
|
if (o.startsWith("zero-line")) {
|
|
44
|
-
const l = e.append("line").attr("x1", 0 +
|
|
44
|
+
const l = e.append("line").attr("x1", 0 + n.left).attr("x2", r - n.right).attr("y1", s(0)).attr("y2", s(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
45
45
|
o === "zero-line-dashed" && l.attr("stroke-dasharray", "4 4");
|
|
46
46
|
}
|
|
47
|
-
o.startsWith("every-line") && (i.yTicks ||
|
|
48
|
-
const d = e.append("line").attr("x1", 0 +
|
|
47
|
+
o.startsWith("every-line") && (i.yTicks || s.ticks()).forEach((h) => {
|
|
48
|
+
const d = e.append("line").attr("x1", 0 + n.left).attr("x2", r - n.right).attr("y1", s(h)).attr("y2", s(h)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
49
49
|
o === "every-line-dashed" && d.attr("stroke-dasharray", "4 4");
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
},
|
|
52
|
+
}, Ss = (i) => {
|
|
53
53
|
const e = Array.from(i.childNodes);
|
|
54
54
|
for (let t = 0; t < e.length; t++)
|
|
55
55
|
i.removeChild(e[t]);
|
|
56
|
-
},
|
|
56
|
+
}, ks = (i) => {
|
|
57
57
|
const e = "http://www.w3.org/2000/svg", t = document.createElement("div");
|
|
58
58
|
t.className = "sc-charts__hovered-circles-tooltip-container", t.style.display = "none";
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const s = document.createElement("div");
|
|
60
|
+
s.className = "sc-charts__hovered-circles-tooltip";
|
|
61
61
|
const r = document.createElement("div");
|
|
62
62
|
r.className = "sc-charts__hovered-circles-tooltip-arrow";
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const n = document.createElementNS(e, "svg");
|
|
64
|
+
n.setAttribute("width", "12"), n.setAttribute("height", "4"), n.setAttribute("viewBox", "0 0 12 4"), n.setAttribute("fill", "none"), n.setAttribute("xmlns", e);
|
|
65
65
|
const o = document.createElementNS(e, "path");
|
|
66
|
-
return o.setAttribute("d", "M6 4L0 0H12L6 4Z"),
|
|
66
|
+
return o.setAttribute("d", "M6 4L0 0H12L6 4Z"), n.appendChild(o), r.appendChild(n), t.append(r), t.append(s), i.append(t), {
|
|
67
67
|
tooltipContainer: t,
|
|
68
|
-
tooltip:
|
|
68
|
+
tooltip: s,
|
|
69
69
|
tooltipArrow: r
|
|
70
70
|
};
|
|
71
|
-
},
|
|
71
|
+
}, Es = (i, e, {
|
|
72
72
|
x: t,
|
|
73
|
-
y:
|
|
73
|
+
y: s,
|
|
74
74
|
r = 3.5,
|
|
75
|
-
hr:
|
|
75
|
+
hr: n = 0
|
|
76
76
|
}) => {
|
|
77
77
|
if (e)
|
|
78
|
-
return i.append("image").attr("x", t - 6).attr("y",
|
|
78
|
+
return i.append("image").attr("x", t - 6).attr("y", s - 6).attr("width", 12).attr("height", 12).attr(
|
|
79
79
|
"href",
|
|
80
80
|
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTMiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMyAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzE0NTJfNTAwOSkiPgo8cGF0aCBkPSJNNi41MzY0NiAxMS41Njg4QzkuMjA1ODYgMTEuNTY4OCAxMS4zNjk4IDkuNDA0ODMgMTEuMzY5OCA2LjczNTQzQzExLjM2OTggNC4wNjYwNiA5LjIwNTg2IDEuOTAyMSA2LjUzNjQ2IDEuOTAyMUMzLjg2NzA4IDEuOTAyMSAxLjcwMzEyIDQuMDY2MDYgMS43MDMxMiA2LjczNTQzQzEuNzAzMTIgOS40MDQ4MyAzLjg2NzA4IDExLjU2ODggNi41MzY0NiAxMS41Njg4WiIgZmlsbD0iI0ZDRUJFOSIvPgo8cGF0aCBkPSJNMy4xMTcxOSAxMC4xNTM1TDkuOTQ3MTkgMy4zMjM0OSIgc3Ryb2tlPSIjRjE4MTY5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTYuNTM2NDYgMTEuNTY4OEM5LjIwNTg2IDExLjU2ODggMTEuMzY5OCA5LjQwNDgzIDExLjM2OTggNi43MzU0M0MxMS4zNjk4IDQuMDY2MDYgOS4yMDU4NiAxLjkwMjEgNi41MzY0NiAxLjkwMjFDMy44NjcwOSAxLjkwMjEgMS43MDMxMiA0LjA2NjA2IDEuNzAzMTIgNi43MzU0M0MxLjcwMzEyIDkuNDA0ODMgMy44NjcwOSAxMS41Njg4IDYuNTM2NDYgMTEuNTY4OFoiIHN0cm9rZT0iI0YxODE2OSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMTQ1Ml81MDA5Ij4KPHJlY3Qgd2lkdGg9IjEyIiBoZWlnaHQ9IjEyIiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC41MzUxNTYgMC43MzUzNTIpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
|
|
81
81
|
);
|
|
82
82
|
{
|
|
83
83
|
const o = i.append("g");
|
|
84
|
-
return o.append("circle").attr("cx", t).attr("cy",
|
|
84
|
+
return o.append("circle").attr("cx", t).attr("cy", s).attr("r", r).classed("sc-charts__hovered-circles", !0), o.append("circle").attr("cx", t).attr("cy", s).attr("r", r + n).classed("sc-charts__hovered-circles_add", !0), o;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
function
|
|
87
|
+
function Ds(i, e, t, s) {
|
|
88
88
|
if (!i) return null;
|
|
89
|
-
const r = i.width / 2,
|
|
90
|
-
return
|
|
89
|
+
const r = i.width / 2, n = e - r, o = e + r;
|
|
90
|
+
return n < t ? t : o > s ? s - i.width : e - r;
|
|
91
91
|
}
|
|
92
|
-
const
|
|
93
|
-
const { svg: e, config: t, x:
|
|
94
|
-
margin:
|
|
95
|
-
grid: { verticalStyle: d, tooltipNode: u, hoverCirclesRadius: _, hoverCirclesAdditionalArea:
|
|
92
|
+
const yt = (i, { x1: e, x2: t, y1: s, y2: r }) => i.append("line").attr("x1", e).attr("x2", t).attr("y1", s).attr("y2", r).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1), Ls = (i) => {
|
|
93
|
+
const { svg: e, config: t, x: s, y: r, height: n, data: o, wrapperNode: l } = i, {
|
|
94
|
+
margin: h,
|
|
95
|
+
grid: { verticalStyle: d, tooltipNode: u, hoverCirclesRadius: _, hoverCirclesAdditionalArea: m }
|
|
96
96
|
} = t;
|
|
97
|
-
if (d !== "none" && (d.startsWith("every-line") && (i.xTicks ||
|
|
98
|
-
const y = e.append("line").attr("x1",
|
|
97
|
+
if (d !== "none" && (d.startsWith("every-line") && (i.xTicks || s.ticks()).forEach((v) => {
|
|
98
|
+
const y = e.append("line").attr("x1", s(v)).attr("x2", s(v)).attr("y1", h.top).attr("y2", n - h.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
99
99
|
d === "every-line-dashed" && y.attr("stroke-dasharray", "4 4");
|
|
100
100
|
}), d === "hovered-circles")) {
|
|
101
|
-
const p = r.range()[0], v =
|
|
102
|
-
|
|
103
|
-
const { tooltipContainer: b, tooltip:
|
|
104
|
-
o.forEach((
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
x:
|
|
101
|
+
const p = r.range()[0], v = s(o[0].date), y = s(o[o.length - 1].date);
|
|
102
|
+
yt(e, { x1: v, x2: y, y1: p, y2: p });
|
|
103
|
+
const { tooltipContainer: b, tooltip: x, tooltipArrow: C } = ks(l);
|
|
104
|
+
o.forEach((M, E) => {
|
|
105
|
+
const $ = s(M.date), F = r(M.value), W = o[E - 1], Z = E > 0 && W && M.value === W.value;
|
|
106
|
+
Z || yt(e, { x1: $, x2: $, y1: F, y2: p });
|
|
107
|
+
const ke = Es(e, Z, {
|
|
108
|
+
x: $,
|
|
109
109
|
y: p,
|
|
110
110
|
r: _,
|
|
111
|
-
hr:
|
|
111
|
+
hr: m
|
|
112
112
|
});
|
|
113
|
-
u &&
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
u && ke.on("mouseover", function() {
|
|
114
|
+
Ss(x), b.style.display = "block", x.append(u({ date: M.date, value: Z ? null : M.value }));
|
|
115
|
+
const Ee = x.getBoundingClientRect(), De = Ds(
|
|
116
|
+
Ee,
|
|
117
|
+
s(M.date),
|
|
118
118
|
i.config.margin.left - i.config.grid.tooltipArrowSize,
|
|
119
119
|
i.width - i.config.margin.right + i.config.grid.tooltipArrowSize
|
|
120
120
|
);
|
|
121
|
-
|
|
121
|
+
x.style.left = De + "px", C.style.left = s(M.date) + "px";
|
|
122
122
|
}).on("mouseout", function() {
|
|
123
123
|
b.style.display = "none";
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
},
|
|
130
|
-
const { svg: e, config: t, width:
|
|
131
|
-
|
|
127
|
+
}, Ns = (i) => {
|
|
128
|
+
As(i), Ls(i);
|
|
129
|
+
}, Hs = (i) => {
|
|
130
|
+
const { svg: e, config: t, width: s, height: r } = i, { margin: n, logo: o } = t;
|
|
131
|
+
Cs(i), Ts(i), o && e.append("image").attr("xlink:href", t.theme === "dark" ? o.picDarkTheme : o.picLightTheme).attr("width", o.width).attr("height", o.height).attr("x", o.x ?? (s - n.left - n.right) / 2 - o.width / 2 + n.left).attr("y", o.y ?? (r - n.top - n.bottom) / 2 - o.height / 2 + n.top), Ns(i);
|
|
132
132
|
}, de = (i, e, t) => {
|
|
133
|
-
let
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
}),
|
|
133
|
+
let s = i.select(`#${e}`);
|
|
134
|
+
return s.empty() && (s = i.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", e)), s.attr("x1", t.x1).attr("y1", t.x2).attr("x2", t.y1).attr("y2", t.y2), t.stops.forEach(({ offset: r, stopColor: n }) => {
|
|
135
|
+
s.append("stop").attr("offset", r).attr("stop-color", n);
|
|
136
|
+
}), s;
|
|
137
137
|
}, ie = (i) => {
|
|
138
138
|
const e = k.select(i).select("defs");
|
|
139
139
|
return e.empty() ? k.select(i).append("defs") : e;
|
|
140
|
-
},
|
|
140
|
+
}, Pt = (i) => {
|
|
141
141
|
const {
|
|
142
142
|
y: e,
|
|
143
143
|
config: { margin: t }
|
|
144
|
-
} = i,
|
|
145
|
-
return { x: 0, y: r, width: "100%", height:
|
|
146
|
-
},
|
|
144
|
+
} = i, s = e.range()[0] - e(0), r = e.range()[0] - s >= 0 ? e.range()[0] - s : 0, n = s + t.bottom >= 0 ? s + t.bottom : 0;
|
|
145
|
+
return { x: 0, y: r, width: "100%", height: n };
|
|
146
|
+
}, bt = (i, e) => ({
|
|
147
147
|
...i,
|
|
148
148
|
...e,
|
|
149
149
|
margin: {
|
|
@@ -178,151 +178,151 @@ const bt = (i, { x1: e, x2: t, y1: n, y2: r }) => i.append("line").attr("x1", e)
|
|
|
178
178
|
...i.selection,
|
|
179
179
|
...e == null ? void 0 : e.selection
|
|
180
180
|
}
|
|
181
|
-
}),
|
|
182
|
-
const t = i.node(),
|
|
181
|
+
}), xt = (i, e = {}) => {
|
|
182
|
+
const t = i.node(), s = ie(t), r = (l, h) => de(s, 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: h },
|
|
190
|
+
{ offset: "60%", stopColor: h },
|
|
191
191
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
192
192
|
]
|
|
193
193
|
});
|
|
194
194
|
r("gradient-range-borders-up", "var(--sc-color-selection-up)"), r("gradient-range-borders-down", "var(--sc-color-selection-down)");
|
|
195
|
-
const
|
|
195
|
+
const n = "sc-charts__border-range-line", o = i.append("line").classed(n, !0).style("display", e.hidden ? "none" : "block");
|
|
196
196
|
return {
|
|
197
|
-
className(l,
|
|
198
|
-
l === "remove" ? o.classed(`${
|
|
197
|
+
className(l, h) {
|
|
198
|
+
l === "remove" ? o.classed(`${n}${h}`, !1) : o.classed(`${n}${h}`, !0);
|
|
199
199
|
},
|
|
200
|
-
update({ x1: l, x2:
|
|
201
|
-
l !== void 0 && o.attr("x1", l),
|
|
200
|
+
update({ x1: l, x2: h, y1: d, y2: u, hidden: _ }) {
|
|
201
|
+
l !== void 0 && o.attr("x1", l), h !== void 0 && o.attr("x2", h), d !== void 0 && o.attr("y1", d), u !== void 0 && o.attr("y2", u), _ !== void 0 && o.style("display", _ ? "none" : "block");
|
|
202
202
|
},
|
|
203
203
|
destroy() {
|
|
204
204
|
o.remove();
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
-
},
|
|
208
|
-
const t = i.append("circle").attr("r", e.radius || 4).style("display", e.hidden ? "none" : "block"),
|
|
209
|
-
return
|
|
210
|
-
className(r,
|
|
211
|
-
r === "remove" ? t.classed(`${
|
|
207
|
+
}, je = (i, e = {}) => {
|
|
208
|
+
const t = i.append("circle").attr("r", e.radius || 4).style("display", e.hidden ? "none" : "block"), s = e.className || "";
|
|
209
|
+
return s && t.classed(s, !0), {
|
|
210
|
+
className(r, n) {
|
|
211
|
+
r === "remove" ? t.classed(`${s}${n}`, !1) : t.classed(`${s}${n}`, !0);
|
|
212
212
|
},
|
|
213
|
-
update({ cx: r, cy:
|
|
214
|
-
r !== void 0 && t.attr("cx", r),
|
|
213
|
+
update({ cx: r, cy: n, hidden: o, fill: l }) {
|
|
214
|
+
r !== void 0 && t.attr("cx", r), n !== void 0 && t.attr("cy", n), l !== void 0 && t.attr("fill", l), o !== void 0 && t.style("display", o ? "none" : "block");
|
|
215
215
|
},
|
|
216
216
|
destroy() {
|
|
217
217
|
t.remove();
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
|
-
},
|
|
221
|
-
const t = "sc-charts__hover-line",
|
|
222
|
-
return ((l,
|
|
220
|
+
}, Is = (i, e = {}) => {
|
|
221
|
+
const t = "sc-charts__hover-line", s = i.append("line").style("display", e.hidden ? "none" : "block").classed(t, !0), r = i.node(), n = ie(r);
|
|
222
|
+
return ((l, h) => de(n, 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: h },
|
|
230
|
+
{ offset: "75%", stopColor: h },
|
|
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" ?
|
|
234
|
+
className(l, h) {
|
|
235
|
+
l === "remove" ? s.classed(`${t}${h}`, !1) : s.classed(`${t}${h}`, !0);
|
|
236
236
|
},
|
|
237
|
-
update({ x1: l, x2:
|
|
238
|
-
l !== void 0 &&
|
|
237
|
+
update({ x1: l, x2: h, y1: d, y2: u, hidden: _ }) {
|
|
238
|
+
l !== void 0 && s.attr("x1", l), h !== void 0 && s.attr("x2", h), d !== void 0 && s.attr("y1", d), u !== void 0 && s.attr("y2", u), _ !== void 0 && s.style("display", _ ? "none" : "block");
|
|
239
239
|
},
|
|
240
240
|
destroy() {
|
|
241
|
-
|
|
241
|
+
s.remove();
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
}, K = "sc-charts__range-tooltip",
|
|
244
|
+
}, K = "sc-charts__range-tooltip", wt = k.timeFormat("%b %e, %I:%M %p"), Rs = (i) => {
|
|
245
245
|
const e = k.format(",.2f");
|
|
246
246
|
return `${i < 0 ? "-" : ""}$${e(Math.abs(i))}`;
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function Fs(i) {
|
|
249
249
|
const e = "http://www.w3.org/2000/svg", t = document.createElement("div");
|
|
250
250
|
t.className = K, t.style.position = "absolute", t.style.top = "0", t.style.pointerEvents = "none", t.style.display = "none", i.append(t);
|
|
251
|
-
const n = document.createElement("div");
|
|
252
|
-
n.className = `${K}-container`, t.append(n);
|
|
253
|
-
const r = document.createElement("div");
|
|
254
|
-
r.className = `${K}-sum`, n.append(r);
|
|
255
251
|
const s = document.createElement("div");
|
|
256
|
-
s.className = `${K}-
|
|
252
|
+
s.className = `${K}-container`, t.append(s);
|
|
253
|
+
const r = document.createElement("div");
|
|
254
|
+
r.className = `${K}-sum`, s.append(r);
|
|
255
|
+
const n = document.createElement("div");
|
|
256
|
+
n.className = `${K}-sum-icon`;
|
|
257
257
|
const o = document.createElementNS(e, "svg");
|
|
258
258
|
o.setAttribute("width", "14"), o.setAttribute("height", "14"), o.setAttribute("viewBox", "0 0 14 14"), o.setAttribute("fill", "none"), o.setAttribute("xmlns", e);
|
|
259
259
|
const l = document.createElementNS(e, "path");
|
|
260
260
|
l.setAttribute(
|
|
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
|
-
), l.setAttribute("fill", "currentColor"), o.appendChild(l),
|
|
264
|
-
const
|
|
265
|
-
r.append(
|
|
263
|
+
), l.setAttribute("fill", "currentColor"), o.appendChild(l), n.appendChild(o), r.append(n);
|
|
264
|
+
const h = document.createElement("div");
|
|
265
|
+
r.append(h);
|
|
266
266
|
const d = document.createElement("div");
|
|
267
|
-
return d.className = `${K}-time`,
|
|
267
|
+
return d.className = `${K}-time`, s.append(d), { wrapper: t, sumNode: h, timeNode: d };
|
|
268
268
|
}
|
|
269
|
-
const
|
|
270
|
-
const { wrapper: e, sumNode: t, timeNode:
|
|
269
|
+
const zs = (i) => {
|
|
270
|
+
const { wrapper: e, sumNode: t, timeNode: s } = Fs(i.wrapperNode);
|
|
271
271
|
return {
|
|
272
|
-
className(r,
|
|
273
|
-
r === "remove" ? e.classList.remove(`${K}${
|
|
272
|
+
className(r, n) {
|
|
273
|
+
r === "remove" ? e.classList.remove(`${K}${n}`) : e.classList.add(`${K}${n}`);
|
|
274
274
|
},
|
|
275
|
-
update({ leftPoint: r, rightPoint:
|
|
276
|
-
if (r &&
|
|
277
|
-
const u =
|
|
275
|
+
update({ leftPoint: r, rightPoint: n, x: o, y: l, hidden: h, closest: d }) {
|
|
276
|
+
if (r && n && d && o !== void 0) {
|
|
277
|
+
const u = n.value - r.value, { sumFormatter: _, timeFormatter: m } = i.config.selection, p = (i.x(n.date) + i.x(r.date)) / 2, v = i.x(d.date) < p ? "left" : "right";
|
|
278
278
|
let y = "", b = "";
|
|
279
279
|
if (_)
|
|
280
|
-
y = _({ left: r.value, right:
|
|
280
|
+
y = _({ left: r.value, right: n.value, direction: v });
|
|
281
281
|
else {
|
|
282
|
-
const
|
|
283
|
-
y = `${
|
|
282
|
+
const x = (u / Math.abs(r.value) * 100).toFixed(2);
|
|
283
|
+
y = `${Rs(u)} (${x}%)`;
|
|
284
284
|
}
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
let
|
|
288
|
-
const
|
|
289
|
-
|
|
285
|
+
m ? b = m({ left: r.date, right: n.date, direction: v }) : b = `${wt(r.date)} to ${wt(n.date)}`, t.textContent = y, s.textContent = b, requestAnimationFrame(() => {
|
|
286
|
+
const x = e.getBoundingClientRect(), C = i.wrapperNode.getBoundingClientRect(), M = i.x(r.date), E = i.x(n.date);
|
|
287
|
+
let F = (M + E) / 2 - x.width / 2;
|
|
288
|
+
const W = 0, Z = C.width - x.width;
|
|
289
|
+
F < W && (F = W), F > Z && (F = Z), e.style.left = `${F}px`, e.style.top = `${l}px`;
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
h !== void 0 && (e.style.display = h ? "none" : "block");
|
|
293
293
|
},
|
|
294
294
|
destroy() {
|
|
295
295
|
e.remove();
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
}, he = "sc-charts__hover-tooltip", Xe = 16,
|
|
298
|
+
}, he = "sc-charts__hover-tooltip", Xe = 16, Bs = k.timeFormat("%a, %b %d, %-I:%M %p"), $s = (i) => {
|
|
299
299
|
const e = k.format(",.2f");
|
|
300
300
|
return `${i < 0 ? "-" : ""}$${e(Math.abs(i))}`;
|
|
301
301
|
};
|
|
302
|
-
function
|
|
302
|
+
function Ps(i) {
|
|
303
303
|
const e = document.createElement("div");
|
|
304
304
|
e.className = `${he}-container`, e.style.position = "absolute", e.style.top = "0", e.style.pointerEvents = "none", e.style.display = "none", i.appendChild(e);
|
|
305
305
|
const t = document.createElement("div");
|
|
306
306
|
t.className = `${he}-sum`, e.appendChild(t);
|
|
307
|
-
const
|
|
308
|
-
return
|
|
307
|
+
const s = document.createElement("div");
|
|
308
|
+
return s.className = `${he}-time`, e.appendChild(s), { wrapper: e, sumNode: t, timeNode: s };
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function Os(i, e, t) {
|
|
311
311
|
return i ? e + Xe + i.width < t ? e + Xe : e - Xe - i.width : null;
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
const { wrapper: e, sumNode: t, timeNode:
|
|
313
|
+
const Ys = (i) => {
|
|
314
|
+
const { wrapper: e, sumNode: t, timeNode: s } = Ps(i.wrapperNode);
|
|
315
315
|
return {
|
|
316
|
-
className(r,
|
|
317
|
-
r === "remove" ? e.classList.remove(`${he}${
|
|
316
|
+
className(r, n) {
|
|
317
|
+
r === "remove" ? e.classList.remove(`${he}${n}`) : e.classList.add(`${he}${n}`);
|
|
318
318
|
},
|
|
319
|
-
update({ hidden: r, dataItem:
|
|
320
|
-
if (
|
|
319
|
+
update({ hidden: r, dataItem: n }) {
|
|
320
|
+
if (n) {
|
|
321
321
|
const { sumFormatter: o, timeFormatter: l } = i.config.hover;
|
|
322
|
-
t.textContent = o ? o(
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
i.x(
|
|
322
|
+
t.textContent = o ? o(n.value) : $s(n.value), s.textContent = l ? l(n.date) : Bs(n.date), requestAnimationFrame(() => {
|
|
323
|
+
const h = e.getBoundingClientRect(), d = Os(
|
|
324
|
+
h,
|
|
325
|
+
i.x(n.date),
|
|
326
326
|
i.width - i.config.margin.right
|
|
327
327
|
);
|
|
328
328
|
d && (e.style.left = d + "px");
|
|
@@ -334,7 +334,7 @@ const Yn = (i) => {
|
|
|
334
334
|
e.remove();
|
|
335
335
|
}
|
|
336
336
|
};
|
|
337
|
-
},
|
|
337
|
+
}, js = {
|
|
338
338
|
margin: { top: 10, right: 30, bottom: 20, left: 10 },
|
|
339
339
|
theme: "light",
|
|
340
340
|
logo: {
|
|
@@ -385,8 +385,8 @@ const Yn = (i) => {
|
|
|
385
385
|
},
|
|
386
386
|
enableBelowZeroLine: !1,
|
|
387
387
|
curveTension: 1
|
|
388
|
-
},
|
|
389
|
-
const { svg: e, data: t, x:
|
|
388
|
+
}, Ae = (i) => k.curveCardinal.tension(i.config.curveTension), Xs = (i) => {
|
|
389
|
+
const { svg: e, data: t, x: s, y: r, config: n } = i, o = e.node(), l = ie(o);
|
|
390
390
|
de(l, "main-line-area-gradient", {
|
|
391
391
|
x1: "0%",
|
|
392
392
|
y1: "0%",
|
|
@@ -397,14 +397,14 @@ const Yn = (i) => {
|
|
|
397
397
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
398
398
|
]
|
|
399
399
|
});
|
|
400
|
-
const d = k.area().x((
|
|
400
|
+
const d = k.area().x((m) => s(m.date)).y0(r.range()[0]).y1((m) => r(m.value)).curve(Ae(i)), u = "sc-charts__main-line-area", _ = e.append("path").datum(t).attr("d", d).attr("class", u).classed(`${u}_hidden`, !n.hasMainLineArea);
|
|
401
401
|
return {
|
|
402
|
-
className(
|
|
403
|
-
|
|
402
|
+
className(m, p) {
|
|
403
|
+
m === "remove" ? _.classed(`${u}${p}`, !1) : _.classed(`${u}${p}`, !0);
|
|
404
404
|
},
|
|
405
|
-
update({ data:
|
|
406
|
-
if (
|
|
407
|
-
if (!
|
|
405
|
+
update({ data: m, hidden: p }) {
|
|
406
|
+
if (m !== void 0 && _.datum(m).attr("d", d), p !== void 0) {
|
|
407
|
+
if (!n.hasMainLineArea) return null;
|
|
408
408
|
_.classed(`${u}_hidden`, p);
|
|
409
409
|
}
|
|
410
410
|
},
|
|
@@ -412,9 +412,9 @@ const Yn = (i) => {
|
|
|
412
412
|
_.remove();
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
|
-
},
|
|
416
|
-
const t = "sc-charts__range-line-area", { svg:
|
|
417
|
-
de(_,
|
|
415
|
+
}, Ws = (i, e = {}) => {
|
|
416
|
+
const t = "sc-charts__range-line-area", { svg: s, x: r, y: n, config: o, data: l, chartId: h } = i, { clip: d } = e, u = s.node(), _ = ie(u), m = "range-line-area-gradient";
|
|
417
|
+
de(_, m + "_up", {
|
|
418
418
|
x1: "0%",
|
|
419
419
|
y1: "0%",
|
|
420
420
|
x2: "0%",
|
|
@@ -423,7 +423,7 @@ const Yn = (i) => {
|
|
|
423
423
|
{ offset: "0%", stopColor: "var(--sc-color-selection-up)" },
|
|
424
424
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
425
425
|
]
|
|
426
|
-
}), de(_,
|
|
426
|
+
}), de(_, m + "_down", {
|
|
427
427
|
x1: "0%",
|
|
428
428
|
y1: "0%",
|
|
429
429
|
x2: "0%",
|
|
@@ -433,59 +433,59 @@ const Yn = (i) => {
|
|
|
433
433
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
434
434
|
]
|
|
435
435
|
});
|
|
436
|
-
const p = k.area().x((
|
|
436
|
+
const p = k.area().x((C) => r(C.date)).y0(n.range()[0]).y1((C) => n(C.value)).curve(Ae(i)), v = `${h}-clip-${t}`, b = _.append("clipPath").attr("id", v).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), x = s.append("path").datum(l).attr("d", p).attr("class", t).classed(`${t}_hidden`, !o.hasMainLineArea).attr("clip-path", `url(#${v})`);
|
|
437
437
|
return {
|
|
438
|
-
className(
|
|
439
|
-
|
|
438
|
+
className(C, M) {
|
|
439
|
+
C === "remove" ? x.classed(`${t}${M}`, !1) : x.classed(`${t}${M}`, !0);
|
|
440
440
|
},
|
|
441
|
-
update({ data:
|
|
442
|
-
|
|
441
|
+
update({ data: C, hidden: M, clip: E }) {
|
|
442
|
+
C !== void 0 && x.datum(C).attr("d", p), M !== void 0 && x.classed(`${t}_hidden`, M), E !== void 0 && b.attr("x", E.x).attr("y", E.y).attr("width", E.width).attr("height", E.height);
|
|
443
443
|
},
|
|
444
444
|
destroy() {
|
|
445
|
-
|
|
445
|
+
x.remove();
|
|
446
446
|
}
|
|
447
447
|
};
|
|
448
|
-
},
|
|
449
|
-
const { svg: t, data:
|
|
448
|
+
}, We = (i, e) => {
|
|
449
|
+
const { svg: t, data: s, x: r, y: n, chartId: o } = i, { baseClassName: l, id: h, clip: d } = e, u = t.node(), _ = ie(u), m = k.line().x((x) => r(x.date)).y((x) => n(x.value)).curve(Ae(i)), p = `${o}-clip-${l}`, y = _.append("clipPath").attr("id", p).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), b = t.append("path").classed(l, !0).datum(s).attr("d", m).attr("id", h).attr("clip-path", `url(#${p})`);
|
|
450
450
|
return {
|
|
451
|
-
className(
|
|
452
|
-
|
|
451
|
+
className(x, C) {
|
|
452
|
+
x === "remove" ? b.classed(`${l}${C}`, !1) : b.classed(`${l}${C}`, !0);
|
|
453
453
|
},
|
|
454
|
-
update({ data:
|
|
455
|
-
|
|
454
|
+
update({ data: x, clip: C, hidden: M }) {
|
|
455
|
+
x !== void 0 && b.datum(x).attr("d", m), M !== void 0 && b.classed(`${l}_hidden`, M), C !== void 0 && y.attr("x", C.x).attr("y", C.y).attr("width", C.width).attr("height", C.height);
|
|
456
456
|
},
|
|
457
457
|
destroy() {
|
|
458
458
|
b.remove();
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
|
-
},
|
|
462
|
-
const { svg: t, data:
|
|
461
|
+
}, Gs = (i, e) => {
|
|
462
|
+
const { svg: t, data: s, x: r, y: n, chartId: o, config: l } = i, { baseClassName: h, id: d, clip: u } = e, _ = t.node(), m = ie(_), p = k.line().x((C) => r(C.date)).y((C) => n(C.value)).curve(Ae(i)), v = `${o}-clip-${h}`, b = m.append("clipPath").attr("id", v).append("rect").attr("x", (u == null ? void 0 : u.x) || 0).attr("y", (u == null ? void 0 : u.y) || 0).attr("width", (u == null ? void 0 : u.width) || "100%").attr("height", (u == null ? void 0 : u.height) || "100%"), x = t.append("path").classed(h, !0).datum(s).attr("d", p).attr("id", d).attr("clip-path", `url(#${v})`);
|
|
463
463
|
return {
|
|
464
|
-
className(
|
|
465
|
-
|
|
464
|
+
className(C, M) {
|
|
465
|
+
C === "remove" ? x.classed(`${h}${M}`, !1) : x.classed(`${h}${M}`, !0);
|
|
466
466
|
},
|
|
467
|
-
update({ data:
|
|
468
|
-
|
|
467
|
+
update({ data: C, clip: M, hidden: E }) {
|
|
468
|
+
C !== void 0 && x.datum(C).attr("d", p), E !== void 0 && x.classed(`${h}_hidden`, E), M !== void 0 && (l.hover.transitionName === "default" ? b.transition().duration(l.hover.transitionDuration).attr("x", M.x).attr("y", M.y).attr("width", M.width).attr("height", M.height).ease(k.easeLinear) : b.attr("x", M.x).attr("y", M.y).attr("width", M.width).attr("height", M.height));
|
|
469
469
|
},
|
|
470
470
|
destroy() {
|
|
471
|
-
|
|
471
|
+
x.remove();
|
|
472
472
|
}
|
|
473
473
|
};
|
|
474
|
-
},
|
|
474
|
+
}, Us = (i) => {
|
|
475
475
|
const e = Math.abs(i);
|
|
476
476
|
let t;
|
|
477
477
|
return e >= 1e9 ? t = (i / 1e9).toFixed(1) + "B" : e >= 1e6 ? t = (i / 1e6).toFixed(1) + "M" : e >= 1e3 ? t = (i / 1e3).toFixed(1) + "K" : t = i.toFixed(1), t;
|
|
478
|
-
},
|
|
479
|
-
const { svg: t, data:
|
|
478
|
+
}, Zs = (i, e) => {
|
|
479
|
+
const { svg: t, data: s, x: r, y: n } = i, { baseClassName: o } = e, l = t.append("g").classed(o, !0), h = l.append("circle").attr("r", 5).classed(`${o}-circle`, !0), d = l.append("text").attr("text-anchor", "middle").attr("dy", "-9px").classed(`${o}-label`, !0);
|
|
480
480
|
return ((_) => {
|
|
481
481
|
if (!_ || _.length === 0) return;
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
const y = i.config.extremePointFormatter ||
|
|
485
|
-
d.attr("x", p).attr("y", v).text(y(
|
|
486
|
-
})(
|
|
487
|
-
className(_,
|
|
488
|
-
_ === "remove" ? l.classed(`${o}${
|
|
482
|
+
const m = _[_.length - 1], p = r(m.date), v = n(m.value);
|
|
483
|
+
h.attr("cx", p).attr("cy", v);
|
|
484
|
+
const y = i.config.extremePointFormatter || Us;
|
|
485
|
+
d.attr("x", p).attr("y", v).text(y(m.value));
|
|
486
|
+
})(s), {
|
|
487
|
+
className(_, m) {
|
|
488
|
+
_ === "remove" ? l.classed(`${o}${m}`, !1) : l.classed(`${o}${m}`, !0);
|
|
489
489
|
},
|
|
490
490
|
update({ hidden: _ }) {
|
|
491
491
|
_ !== void 0 && l.classed(`${o}_hidden`, _);
|
|
@@ -494,71 +494,71 @@ const Yn = (i) => {
|
|
|
494
494
|
l.remove();
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
|
-
},
|
|
498
|
-
const e =
|
|
497
|
+
}, Vs = (i) => {
|
|
498
|
+
const e = We(i, {
|
|
499
499
|
baseClassName: "sc-charts__main-line",
|
|
500
500
|
id: `${i.chartId}-sc-charts__main-line`
|
|
501
|
-
}), t =
|
|
502
|
-
let
|
|
503
|
-
i.config.hasExtremePoint && (
|
|
501
|
+
}), t = Xs(i);
|
|
502
|
+
let s = null;
|
|
503
|
+
i.config.hasExtremePoint && (s = Zs(i, {
|
|
504
504
|
baseClassName: "sc-charts__extreme-point"
|
|
505
505
|
}));
|
|
506
|
-
const r =
|
|
506
|
+
const r = Is(i.svg), n = Gs(i, {
|
|
507
507
|
baseClassName: "sc-charts__highlight-line",
|
|
508
508
|
id: `${i.chartId}-sc-charts__highlight-line`,
|
|
509
509
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
510
510
|
});
|
|
511
511
|
let o = null;
|
|
512
|
-
i.config.enableBelowZeroLine && (o =
|
|
512
|
+
i.config.enableBelowZeroLine && (o = We(i, {
|
|
513
513
|
baseClassName: "sc-charts__below-zero-line",
|
|
514
514
|
id: `${i.chartId}-sc-charts__below-zero-line`,
|
|
515
|
-
clip:
|
|
515
|
+
clip: Pt(i)
|
|
516
516
|
}));
|
|
517
|
-
const l =
|
|
517
|
+
const l = je(i.svg, {
|
|
518
518
|
className: "sc-charts__hover-circle",
|
|
519
519
|
hidden: !0
|
|
520
|
-
}),
|
|
520
|
+
}), h = xt(i.svg), d = xt(i.svg), u = We(i, {
|
|
521
521
|
baseClassName: "sc-charts__range-line",
|
|
522
522
|
id: `${i.chartId}-sc-charts__range-line`,
|
|
523
523
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
524
|
-
}), _ =
|
|
524
|
+
}), _ = je(i.svg, {
|
|
525
525
|
className: "sc-charts__range-circle-left",
|
|
526
526
|
hidden: !0
|
|
527
|
-
}),
|
|
527
|
+
}), m = je(i.svg, {
|
|
528
528
|
className: "sc-charts__range-circle-right",
|
|
529
529
|
hidden: !0
|
|
530
|
-
}), p =
|
|
530
|
+
}), p = zs(i), v = Ys(i), y = Ws(i);
|
|
531
531
|
return {
|
|
532
532
|
hoverLine: r,
|
|
533
533
|
hoverCircle: l,
|
|
534
|
-
rangeBorderLeft:
|
|
534
|
+
rangeBorderLeft: h,
|
|
535
535
|
rangeBorderRight: d,
|
|
536
536
|
rangeLine: u,
|
|
537
537
|
rangeLineArea: y,
|
|
538
538
|
rangeCircleLeft: _,
|
|
539
|
-
rangeCircleRight:
|
|
539
|
+
rangeCircleRight: m,
|
|
540
540
|
mainLine: e,
|
|
541
541
|
rangeTooltip: p,
|
|
542
|
-
highlightLine:
|
|
542
|
+
highlightLine: n,
|
|
543
543
|
hoverTooltip: v,
|
|
544
544
|
mainLineArea: t,
|
|
545
545
|
belowZeroLine: o,
|
|
546
|
-
extremePoint:
|
|
546
|
+
extremePoint: s
|
|
547
547
|
};
|
|
548
|
-
},
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
548
|
+
}, Js = (i, e, t) => {
|
|
549
|
+
const s = i.match(/^(\d+)([dMhmw])$/);
|
|
550
|
+
if (!s)
|
|
551
551
|
return console.warn("Invalid hoverRange:", i), {
|
|
552
552
|
x: 0,
|
|
553
553
|
y: 0,
|
|
554
554
|
width: "100%",
|
|
555
555
|
height: "100%"
|
|
556
556
|
};
|
|
557
|
-
const [, r,
|
|
557
|
+
const [, r, n] = s, o = parseInt(r, 10), [l, h] = t.domain();
|
|
558
558
|
let d = new Date(l);
|
|
559
|
-
for (; d <
|
|
559
|
+
for (; d < h; ) {
|
|
560
560
|
let u = new Date(d);
|
|
561
|
-
switch (
|
|
561
|
+
switch (n) {
|
|
562
562
|
case "M":
|
|
563
563
|
u.setMinutes(u.getMinutes() + o);
|
|
564
564
|
break;
|
|
@@ -583,19 +583,19 @@ const Yn = (i) => {
|
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
585
|
if (e >= d && e < u) {
|
|
586
|
-
const _ = t(d),
|
|
586
|
+
const _ = t(d), m = t(u);
|
|
587
587
|
return {
|
|
588
588
|
x: _,
|
|
589
589
|
y: 0,
|
|
590
|
-
width:
|
|
590
|
+
width: m - _,
|
|
591
591
|
height: "100%"
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
594
|
d = new Date(u);
|
|
595
595
|
}
|
|
596
|
-
if (e.getTime() ===
|
|
597
|
-
let u = new Date(
|
|
598
|
-
switch (
|
|
596
|
+
if (e.getTime() === h.getTime()) {
|
|
597
|
+
let u = new Date(h);
|
|
598
|
+
switch (n) {
|
|
599
599
|
case "M":
|
|
600
600
|
u.setMinutes(u.getMinutes() - o);
|
|
601
601
|
break;
|
|
@@ -609,14 +609,14 @@ const Yn = (i) => {
|
|
|
609
609
|
u.setDate(u.getDate() - o * 7);
|
|
610
610
|
break;
|
|
611
611
|
case "m":
|
|
612
|
-
u = new Date(
|
|
612
|
+
u = new Date(h.getFullYear(), h.getMonth() - o, 1);
|
|
613
613
|
break;
|
|
614
614
|
}
|
|
615
|
-
const _ = t(u),
|
|
615
|
+
const _ = t(u), m = t(h);
|
|
616
616
|
return {
|
|
617
617
|
x: _,
|
|
618
618
|
y: 0,
|
|
619
|
-
width:
|
|
619
|
+
width: m - _,
|
|
620
620
|
height: "100%"
|
|
621
621
|
};
|
|
622
622
|
}
|
|
@@ -626,49 +626,49 @@ const Yn = (i) => {
|
|
|
626
626
|
width: "100%",
|
|
627
627
|
height: "100%"
|
|
628
628
|
};
|
|
629
|
-
},
|
|
629
|
+
}, Mt = (i, e) => {
|
|
630
630
|
var d;
|
|
631
631
|
const {
|
|
632
632
|
x: t,
|
|
633
|
-
y:
|
|
633
|
+
y: s,
|
|
634
634
|
elements: r,
|
|
635
|
-
config: { margin:
|
|
635
|
+
config: { margin: n },
|
|
636
636
|
height: o
|
|
637
637
|
} = i;
|
|
638
638
|
r.hoverLine.update({
|
|
639
639
|
x1: t(e.date),
|
|
640
640
|
x2: t(e.date),
|
|
641
|
-
y1:
|
|
642
|
-
y2: o -
|
|
641
|
+
y1: n.top,
|
|
642
|
+
y2: o - n.bottom,
|
|
643
643
|
hidden: !1
|
|
644
644
|
}), r.hoverCircle.update({
|
|
645
645
|
cx: t(e.date),
|
|
646
|
-
cy:
|
|
646
|
+
cy: s(e.value),
|
|
647
647
|
hidden: !1
|
|
648
648
|
}), r.hoverTooltip.update({
|
|
649
649
|
dataItem: e,
|
|
650
650
|
hidden: !1
|
|
651
651
|
});
|
|
652
|
-
const l =
|
|
652
|
+
const l = Js(i.config.hover.range, e.date, t);
|
|
653
653
|
r.highlightLine.update({
|
|
654
654
|
clip: l,
|
|
655
655
|
hidden: !1
|
|
656
656
|
});
|
|
657
|
-
const
|
|
658
|
-
|
|
657
|
+
const h = s.range()[0] - s(0) + n.bottom;
|
|
658
|
+
h >= 0 && ((d = r.belowZeroLine) == null || d.update({
|
|
659
659
|
clip: {
|
|
660
660
|
...l,
|
|
661
|
-
y:
|
|
662
|
-
height:
|
|
661
|
+
y: s(0),
|
|
662
|
+
height: h
|
|
663
663
|
}
|
|
664
664
|
})), r.mainLine.className("add", "_muted");
|
|
665
665
|
}, Tt = (i) => {
|
|
666
666
|
var t;
|
|
667
667
|
const { elements: e } = i;
|
|
668
668
|
e.hoverLine.update({ hidden: !0 }), e.hoverCircle.update({ hidden: !0 }), e.highlightLine.update({ hidden: !0 }), e.mainLine.className("remove", "_muted"), e.hoverTooltip.update({ hidden: !0 }), i.action !== "selection" && ((t = e.belowZeroLine) == null || t.update({
|
|
669
|
-
clip:
|
|
669
|
+
clip: Pt(i)
|
|
670
670
|
}));
|
|
671
|
-
},
|
|
671
|
+
}, Qs = (i, e) => {
|
|
672
672
|
[
|
|
673
673
|
"rangeBorderLeft",
|
|
674
674
|
"rangeBorderRight",
|
|
@@ -677,36 +677,36 @@ const Yn = (i) => {
|
|
|
677
677
|
"rangeLine",
|
|
678
678
|
"rangeLineArea",
|
|
679
679
|
"rangeTooltip"
|
|
680
|
-
].forEach((
|
|
681
|
-
e ? (i[
|
|
680
|
+
].forEach((s) => {
|
|
681
|
+
e ? (i[s].className("remove", "_down"), i[s].className("add", "_up")) : (i[s].className("remove", "_up"), i[s].className("add", "_down"));
|
|
682
682
|
});
|
|
683
|
-
},
|
|
683
|
+
}, qs = (i, e, t) => {
|
|
684
684
|
var v;
|
|
685
685
|
const {
|
|
686
|
-
x:
|
|
686
|
+
x: s,
|
|
687
687
|
y: r,
|
|
688
|
-
config: { margin:
|
|
688
|
+
config: { margin: n },
|
|
689
689
|
height: o,
|
|
690
690
|
elements: l
|
|
691
|
-
} = i,
|
|
691
|
+
} = i, h = s(e.date) < s(t.date) ? e : t, d = s(e.date) >= s(t.date) ? e : t, u = d.value - h.value >= 0, _ = s(h.date), m = s(d.date), p = m - _;
|
|
692
692
|
l.rangeBorderLeft.update({
|
|
693
693
|
x1: _,
|
|
694
694
|
x2: _,
|
|
695
|
-
y1:
|
|
696
|
-
y2: o -
|
|
695
|
+
y1: n.top,
|
|
696
|
+
y2: o - n.bottom,
|
|
697
697
|
hidden: !1
|
|
698
698
|
}), l.rangeBorderRight.update({
|
|
699
|
-
x1:
|
|
700
|
-
x2:
|
|
701
|
-
y1:
|
|
702
|
-
y2: o -
|
|
699
|
+
x1: m,
|
|
700
|
+
x2: m,
|
|
701
|
+
y1: n.top,
|
|
702
|
+
y2: o - n.bottom,
|
|
703
703
|
hidden: !1
|
|
704
704
|
}), l.rangeCircleLeft.update({
|
|
705
705
|
cx: _,
|
|
706
|
-
cy: r(
|
|
706
|
+
cy: r(h.value),
|
|
707
707
|
hidden: !1
|
|
708
708
|
}), l.rangeCircleRight.update({
|
|
709
|
-
cx:
|
|
709
|
+
cx: m,
|
|
710
710
|
cy: r(d.value),
|
|
711
711
|
hidden: !1
|
|
712
712
|
}), l.rangeLine.update({
|
|
@@ -727,498 +727,498 @@ const Yn = (i) => {
|
|
|
727
727
|
hidden: !1
|
|
728
728
|
}), l.rangeTooltip.update({
|
|
729
729
|
rightPoint: d,
|
|
730
|
-
leftPoint:
|
|
730
|
+
leftPoint: h,
|
|
731
731
|
closest: t,
|
|
732
732
|
x: _ + p / 2,
|
|
733
733
|
y: 0,
|
|
734
734
|
hidden: !1
|
|
735
735
|
}), (v = l.belowZeroLine) == null || v.update({
|
|
736
736
|
hidden: !0
|
|
737
|
-
}), l.mainLineArea.update({ hidden: !0 }),
|
|
738
|
-
},
|
|
737
|
+
}), l.mainLineArea.update({ hidden: !0 }), Qs(l, u), l.mainLine.className("add", "_selected-muted");
|
|
738
|
+
}, Ct = (i) => {
|
|
739
739
|
var t;
|
|
740
740
|
const { elements: e } = i;
|
|
741
741
|
e.rangeLine.update({ hidden: !0 }), e.rangeLineArea.update({ hidden: !0 }), e.rangeBorderLeft.update({ hidden: !0 }), e.rangeBorderRight.update({ hidden: !0 }), e.rangeCircleLeft.update({ hidden: !0 }), e.rangeCircleRight.update({ hidden: !0 }), e.rangeTooltip.update({ hidden: !0 }), e.mainLine.className("remove", "_selected-muted"), e.mainLineArea.update({ hidden: !1 }), (t = e.belowZeroLine) == null || t.update({ hidden: !1 });
|
|
742
|
-
},
|
|
743
|
-
const { svg: e, data: t, x:
|
|
742
|
+
}, Ks = (i) => {
|
|
743
|
+
const { svg: e, data: t, x: s, config: r, width: n, height: o } = i, { margin: l, hover: h, selection: d } = r;
|
|
744
744
|
let u = null, _ = !1;
|
|
745
|
-
const
|
|
746
|
-
(y, b) => Math.abs(
|
|
745
|
+
const m = (v) => t.reduce(
|
|
746
|
+
(y, b) => Math.abs(s(y.date) - v) < Math.abs(s(b.date) - v) ? y : b
|
|
747
747
|
);
|
|
748
|
-
e.append("rect").attr("width",
|
|
749
|
-
const [y] = k.pointer(v, this), b =
|
|
750
|
-
!_ &&
|
|
748
|
+
e.append("rect").attr("width", n - l.left - l.right).attr("height", o - l.top - l.bottom).attr("x", l.left).attr("y", l.top).attr("fill", "transparent").on("mousemove", function(v) {
|
|
749
|
+
const [y] = k.pointer(v, this), b = m(y);
|
|
750
|
+
!_ && h.enable ? (i.action = "hover", Mt(i, b)) : (i.action = _ ? "selection" : "none", Tt(i)), u && d.enable && (i.action = "selection", qs(i, u, b));
|
|
751
751
|
}).on("mouseleave", () => {
|
|
752
|
-
i.action = "none", _ = !1, u = null, Tt(i),
|
|
752
|
+
i.action = "none", _ = !1, u = null, Tt(i), Ct(i);
|
|
753
753
|
}).on("mousedown", function(v) {
|
|
754
754
|
if (d.enable) {
|
|
755
755
|
_ = !0, i.action = "selection";
|
|
756
756
|
const [y] = k.pointer(v, this);
|
|
757
|
-
u =
|
|
757
|
+
u = m(y);
|
|
758
758
|
}
|
|
759
759
|
}).on("mouseup", function(v) {
|
|
760
|
-
const [y] = k.pointer(v, this), b =
|
|
761
|
-
_ = !1, u = null, i.action = "hover", d.enable &&
|
|
760
|
+
const [y] = k.pointer(v, this), b = m(y);
|
|
761
|
+
_ = !1, u = null, i.action = "hover", d.enable && Ct(i), h.enable && Mt(i, b);
|
|
762
762
|
});
|
|
763
|
-
},
|
|
764
|
-
const { margin:
|
|
765
|
-
return
|
|
766
|
-
},
|
|
767
|
-
const { margin:
|
|
768
|
-
return k.scaleLinear().domain([
|
|
769
|
-
},
|
|
763
|
+
}, en = (i, e, t) => {
|
|
764
|
+
const { margin: s } = e, r = k.scaleTime(), n = k.extent(i, (o) => new Date(o.date));
|
|
765
|
+
return n[0] == null || n[1] == null ? r : r.domain([n[0], n[1]]).range([s.left, t - s.right]);
|
|
766
|
+
}, tn = (i, e, t) => {
|
|
767
|
+
const { margin: s } = e, r = k.max(i, (o) => o.value) ?? 0, n = k.min(i, (o) => o.value) ?? 0;
|
|
768
|
+
return k.scaleLinear().domain([n, r]).range([t - s.bottom, s.top]);
|
|
769
|
+
}, Er = (i, e) => {
|
|
770
770
|
const t = k.select(i);
|
|
771
771
|
if (t.empty())
|
|
772
772
|
return console.error(`Element with selector ${i} not found!`), null;
|
|
773
773
|
if (!e.chartId || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.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
|
-
const
|
|
777
|
-
let o =
|
|
776
|
+
const s = t.append("div"), r = s.append("svg"), n = t.node();
|
|
777
|
+
let o = n.getBoundingClientRect(), l = o.width, h = o.height, d = bt({ ...js }, e.config), u = e.data;
|
|
778
778
|
const _ = () => {
|
|
779
|
-
o =
|
|
779
|
+
o = n.getBoundingClientRect(), l = o.width, h = o.height, m({ data: u, config: d });
|
|
780
780
|
};
|
|
781
781
|
window.addEventListener("resize", _);
|
|
782
|
-
const
|
|
783
|
-
v && p.config && (d =
|
|
784
|
-
const y = u.map((
|
|
785
|
-
|
|
786
|
-
const
|
|
782
|
+
const m = (p, v = !1) => {
|
|
783
|
+
v && p.config && (d = bt(d, p.config)), v && p.data && (u = p.data);
|
|
784
|
+
const y = u.map((E) => ({ date: new Date(E.date), value: E.value })).sort((E, $) => E.date.getTime() - $.date.getTime()), b = en(y, d, l), x = tn(y, d, h);
|
|
785
|
+
s.attr("class", `sc-charts sc-charts__${d.theme}`), r.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${l} ${h}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
|
|
786
|
+
const C = {
|
|
787
787
|
chartId: e.chartId,
|
|
788
788
|
svg: r,
|
|
789
|
-
wrapperNode:
|
|
789
|
+
wrapperNode: s.node(),
|
|
790
790
|
data: y,
|
|
791
791
|
x: b,
|
|
792
|
-
y:
|
|
792
|
+
y: x,
|
|
793
793
|
config: d,
|
|
794
794
|
action: "none",
|
|
795
795
|
width: l,
|
|
796
|
-
height:
|
|
796
|
+
height: h
|
|
797
797
|
};
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
...
|
|
801
|
-
elements:
|
|
798
|
+
Hs(C);
|
|
799
|
+
const M = {
|
|
800
|
+
...C,
|
|
801
|
+
elements: Vs(C)
|
|
802
802
|
};
|
|
803
|
-
|
|
803
|
+
Ks(M);
|
|
804
804
|
};
|
|
805
|
-
return
|
|
806
|
-
update: (p) =>
|
|
805
|
+
return m(e), {
|
|
806
|
+
update: (p) => m(p, !0),
|
|
807
807
|
destroy: () => {
|
|
808
808
|
window.removeEventListener("resize", _), r.remove();
|
|
809
809
|
}
|
|
810
810
|
};
|
|
811
811
|
};
|
|
812
812
|
var be = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
813
|
-
function
|
|
813
|
+
function sn(i) {
|
|
814
814
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
815
815
|
}
|
|
816
816
|
var le = { exports: {} };
|
|
817
817
|
le.exports;
|
|
818
|
-
var
|
|
819
|
-
function
|
|
820
|
-
return
|
|
821
|
-
var t = 200,
|
|
822
|
-
|
|
823
|
-
var
|
|
818
|
+
var At;
|
|
819
|
+
function nn() {
|
|
820
|
+
return At || (At = 1, function(i, e) {
|
|
821
|
+
var t = 200, s = "__lodash_hash_undefined__", r = 800, n = 16, o = 9007199254740991, l = "[object Arguments]", h = "[object Array]", d = "[object AsyncFunction]", u = "[object Boolean]", _ = "[object Date]", m = "[object Error]", p = "[object Function]", v = "[object GeneratorFunction]", y = "[object Map]", b = "[object Number]", x = "[object Null]", C = "[object Object]", M = "[object Proxy]", E = "[object RegExp]", $ = "[object Set]", F = "[object String]", W = "[object Undefined]", Z = "[object WeakMap]", ke = "[object ArrayBuffer]", Ee = "[object DataView]", De = "[object Float32Array]", Qt = "[object Float64Array]", qt = "[object Int8Array]", Kt = "[object Int16Array]", ei = "[object Int32Array]", ti = "[object Uint8Array]", ii = "[object Uint8ClampedArray]", si = "[object Uint16Array]", ni = "[object Uint32Array]", ri = /[\\^$.*+?()[\]{}|]/g, ai = /^\[object .+?Constructor\]$/, oi = /^(?:0|[1-9]\d*)$/, L = {};
|
|
822
|
+
L[De] = L[Qt] = L[qt] = L[Kt] = L[ei] = L[ti] = L[ii] = L[si] = L[ni] = !0, L[l] = L[h] = L[ke] = L[u] = L[Ee] = L[_] = L[m] = L[p] = L[y] = L[b] = L[C] = L[E] = L[$] = L[F] = L[Z] = !1;
|
|
823
|
+
var Je = typeof be == "object" && be && be.Object === Object && be, li = typeof self == "object" && self && self.Object === Object && self, se = Je || li || Function("return this")(), Qe = e && !e.nodeType && e, ne = Qe && !0 && i && !i.nodeType && i, qe = ne && ne.exports === Qe, Le = qe && Je.process, Ke = function() {
|
|
824
824
|
try {
|
|
825
|
-
var a =
|
|
825
|
+
var a = ne && ne.require && ne.require("util").types;
|
|
826
826
|
return a || Le && Le.binding && Le.binding("util");
|
|
827
827
|
} catch {
|
|
828
828
|
}
|
|
829
|
-
}(),
|
|
830
|
-
function ci(a,
|
|
829
|
+
}(), et = Ke && Ke.isTypedArray;
|
|
830
|
+
function ci(a, c, f) {
|
|
831
831
|
switch (f.length) {
|
|
832
832
|
case 0:
|
|
833
|
-
return a.call(
|
|
833
|
+
return a.call(c);
|
|
834
834
|
case 1:
|
|
835
|
-
return a.call(
|
|
835
|
+
return a.call(c, f[0]);
|
|
836
836
|
case 2:
|
|
837
|
-
return a.call(
|
|
837
|
+
return a.call(c, f[0], f[1]);
|
|
838
838
|
case 3:
|
|
839
|
-
return a.call(
|
|
839
|
+
return a.call(c, f[0], f[1], f[2]);
|
|
840
840
|
}
|
|
841
|
-
return a.apply(
|
|
841
|
+
return a.apply(c, f);
|
|
842
842
|
}
|
|
843
|
-
function hi(a,
|
|
844
|
-
for (var f = -1,
|
|
845
|
-
|
|
846
|
-
return
|
|
843
|
+
function hi(a, c) {
|
|
844
|
+
for (var f = -1, w = Array(a); ++f < a; )
|
|
845
|
+
w[f] = c(f);
|
|
846
|
+
return w;
|
|
847
847
|
}
|
|
848
848
|
function di(a) {
|
|
849
|
-
return function(
|
|
850
|
-
return a(
|
|
849
|
+
return function(c) {
|
|
850
|
+
return a(c);
|
|
851
851
|
};
|
|
852
852
|
}
|
|
853
|
-
function ui(a,
|
|
854
|
-
return a == null ? void 0 : a[
|
|
853
|
+
function ui(a, c) {
|
|
854
|
+
return a == null ? void 0 : a[c];
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function gi(a, c) {
|
|
857
857
|
return function(f) {
|
|
858
|
-
return a(
|
|
858
|
+
return a(c(f));
|
|
859
859
|
};
|
|
860
860
|
}
|
|
861
|
-
var
|
|
862
|
-
var a = /[^.]+$/.exec(
|
|
861
|
+
var fi = Array.prototype, _i = Function.prototype, ue = Object.prototype, Ne = se["__core-js_shared__"], ge = _i.toString, V = ue.hasOwnProperty, tt = function() {
|
|
862
|
+
var a = /[^.]+$/.exec(Ne && Ne.keys && Ne.keys.IE_PROTO || "");
|
|
863
863
|
return a ? "Symbol(src)_1." + a : "";
|
|
864
|
-
}(),
|
|
865
|
-
"^" +
|
|
866
|
-
),
|
|
867
|
-
|
|
868
|
-
var
|
|
864
|
+
}(), it = ue.toString, mi = ge.call(Object), pi = RegExp(
|
|
865
|
+
"^" + ge.call(V).replace(ri, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
866
|
+
), fe = qe ? se.Buffer : void 0, st = se.Symbol, nt = se.Uint8Array;
|
|
867
|
+
fe && fe.allocUnsafe;
|
|
868
|
+
var rt = gi(Object.getPrototypeOf, Object), at = Object.create, vi = ue.propertyIsEnumerable, yi = fi.splice, J = st ? st.toStringTag : void 0, _e = function() {
|
|
869
869
|
try {
|
|
870
|
-
var a =
|
|
870
|
+
var a = Re(Object, "defineProperty");
|
|
871
871
|
return a({}, "", {}), a;
|
|
872
872
|
} catch {
|
|
873
873
|
}
|
|
874
|
-
}(), bi =
|
|
874
|
+
}(), bi = fe ? fe.isBuffer : void 0, ot = Math.max, xi = Date.now, lt = Re(se, "Map"), re = Re(Object, "create"), wi = /* @__PURE__ */ function() {
|
|
875
875
|
function a() {
|
|
876
876
|
}
|
|
877
|
-
return function(
|
|
878
|
-
if (!q(
|
|
877
|
+
return function(c) {
|
|
878
|
+
if (!q(c))
|
|
879
879
|
return {};
|
|
880
|
-
if (
|
|
881
|
-
return
|
|
882
|
-
a.prototype =
|
|
880
|
+
if (at)
|
|
881
|
+
return at(c);
|
|
882
|
+
a.prototype = c;
|
|
883
883
|
var f = new a();
|
|
884
884
|
return a.prototype = void 0, f;
|
|
885
885
|
};
|
|
886
886
|
}();
|
|
887
887
|
function Q(a) {
|
|
888
|
-
var
|
|
889
|
-
for (this.clear(); ++
|
|
890
|
-
var
|
|
891
|
-
this.set(
|
|
888
|
+
var c = -1, f = a == null ? 0 : a.length;
|
|
889
|
+
for (this.clear(); ++c < f; ) {
|
|
890
|
+
var w = a[c];
|
|
891
|
+
this.set(w[0], w[1]);
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
894
|
function Mi() {
|
|
895
895
|
this.__data__ = re ? re(null) : {}, this.size = 0;
|
|
896
896
|
}
|
|
897
|
-
function Ci(a) {
|
|
898
|
-
var h = this.has(a) && delete this.__data__[a];
|
|
899
|
-
return this.size -= h ? 1 : 0, h;
|
|
900
|
-
}
|
|
901
897
|
function Ti(a) {
|
|
902
|
-
var
|
|
898
|
+
var c = this.has(a) && delete this.__data__[a];
|
|
899
|
+
return this.size -= c ? 1 : 0, c;
|
|
900
|
+
}
|
|
901
|
+
function Ci(a) {
|
|
902
|
+
var c = this.__data__;
|
|
903
903
|
if (re) {
|
|
904
|
-
var f =
|
|
905
|
-
return f ===
|
|
904
|
+
var f = c[a];
|
|
905
|
+
return f === s ? void 0 : f;
|
|
906
906
|
}
|
|
907
|
-
return V.call(
|
|
907
|
+
return V.call(c, a) ? c[a] : void 0;
|
|
908
908
|
}
|
|
909
909
|
function Ai(a) {
|
|
910
|
-
var
|
|
911
|
-
return re ?
|
|
910
|
+
var c = this.__data__;
|
|
911
|
+
return re ? c[a] !== void 0 : V.call(c, a);
|
|
912
912
|
}
|
|
913
|
-
function Si(a,
|
|
913
|
+
function Si(a, c) {
|
|
914
914
|
var f = this.__data__;
|
|
915
|
-
return this.size += this.has(a) ? 0 : 1, f[a] = re &&
|
|
915
|
+
return this.size += this.has(a) ? 0 : 1, f[a] = re && c === void 0 ? s : c, this;
|
|
916
916
|
}
|
|
917
|
-
Q.prototype.clear = Mi, Q.prototype.delete =
|
|
917
|
+
Q.prototype.clear = Mi, Q.prototype.delete = Ti, Q.prototype.get = Ci, Q.prototype.has = Ai, Q.prototype.set = Si;
|
|
918
918
|
function G(a) {
|
|
919
|
-
var
|
|
920
|
-
for (this.clear(); ++
|
|
921
|
-
var
|
|
922
|
-
this.set(
|
|
919
|
+
var c = -1, f = a == null ? 0 : a.length;
|
|
920
|
+
for (this.clear(); ++c < f; ) {
|
|
921
|
+
var w = a[c];
|
|
922
|
+
this.set(w[0], w[1]);
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
925
|
function ki() {
|
|
926
926
|
this.__data__ = [], this.size = 0;
|
|
927
927
|
}
|
|
928
928
|
function Ei(a) {
|
|
929
|
-
var
|
|
929
|
+
var c = this.__data__, f = me(c, a);
|
|
930
930
|
if (f < 0)
|
|
931
931
|
return !1;
|
|
932
|
-
var
|
|
933
|
-
return f ==
|
|
932
|
+
var w = c.length - 1;
|
|
933
|
+
return f == w ? c.pop() : yi.call(c, f, 1), --this.size, !0;
|
|
934
934
|
}
|
|
935
935
|
function Di(a) {
|
|
936
|
-
var
|
|
937
|
-
return f < 0 ? void 0 :
|
|
936
|
+
var c = this.__data__, f = me(c, a);
|
|
937
|
+
return f < 0 ? void 0 : c[f][1];
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function Li(a) {
|
|
940
940
|
return me(this.__data__, a) > -1;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
var f = this.__data__,
|
|
944
|
-
return
|
|
942
|
+
function Ni(a, c) {
|
|
943
|
+
var f = this.__data__, w = me(f, a);
|
|
944
|
+
return w < 0 ? (++this.size, f.push([a, c])) : f[w][1] = c, this;
|
|
945
945
|
}
|
|
946
|
-
G.prototype.clear = ki, G.prototype.delete = Ei, G.prototype.get = Di, G.prototype.has =
|
|
946
|
+
G.prototype.clear = ki, G.prototype.delete = Ei, G.prototype.get = Di, G.prototype.has = Li, G.prototype.set = Ni;
|
|
947
947
|
function ee(a) {
|
|
948
|
-
var
|
|
949
|
-
for (this.clear(); ++
|
|
950
|
-
var
|
|
951
|
-
this.set(
|
|
948
|
+
var c = -1, f = a == null ? 0 : a.length;
|
|
949
|
+
for (this.clear(); ++c < f; ) {
|
|
950
|
+
var w = a[c];
|
|
951
|
+
this.set(w[0], w[1]);
|
|
952
952
|
}
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function Hi() {
|
|
955
955
|
this.size = 0, this.__data__ = {
|
|
956
956
|
hash: new Q(),
|
|
957
|
-
map: new (
|
|
957
|
+
map: new (lt || G)(),
|
|
958
958
|
string: new Q()
|
|
959
959
|
};
|
|
960
960
|
}
|
|
961
|
-
function
|
|
962
|
-
var
|
|
963
|
-
return this.size -=
|
|
961
|
+
function Ii(a) {
|
|
962
|
+
var c = ve(this, a).delete(a);
|
|
963
|
+
return this.size -= c ? 1 : 0, c;
|
|
964
964
|
}
|
|
965
965
|
function Ri(a) {
|
|
966
966
|
return ve(this, a).get(a);
|
|
967
967
|
}
|
|
968
|
-
function
|
|
968
|
+
function Fi(a) {
|
|
969
969
|
return ve(this, a).has(a);
|
|
970
970
|
}
|
|
971
|
-
function
|
|
972
|
-
var f = ve(this, a),
|
|
973
|
-
return f.set(a,
|
|
971
|
+
function zi(a, c) {
|
|
972
|
+
var f = ve(this, a), w = f.size;
|
|
973
|
+
return f.set(a, c), this.size += f.size == w ? 0 : 1, this;
|
|
974
974
|
}
|
|
975
|
-
ee.prototype.clear =
|
|
975
|
+
ee.prototype.clear = Hi, ee.prototype.delete = Ii, ee.prototype.get = Ri, ee.prototype.has = Fi, ee.prototype.set = zi;
|
|
976
976
|
function te(a) {
|
|
977
|
-
var
|
|
978
|
-
this.size =
|
|
977
|
+
var c = this.__data__ = new G(a);
|
|
978
|
+
this.size = c.size;
|
|
979
979
|
}
|
|
980
980
|
function Bi() {
|
|
981
981
|
this.__data__ = new G(), this.size = 0;
|
|
982
982
|
}
|
|
983
|
-
function
|
|
984
|
-
var
|
|
985
|
-
return this.size =
|
|
983
|
+
function $i(a) {
|
|
984
|
+
var c = this.__data__, f = c.delete(a);
|
|
985
|
+
return this.size = c.size, f;
|
|
986
986
|
}
|
|
987
987
|
function Pi(a) {
|
|
988
988
|
return this.__data__.get(a);
|
|
989
989
|
}
|
|
990
|
-
function
|
|
990
|
+
function Oi(a) {
|
|
991
991
|
return this.__data__.has(a);
|
|
992
992
|
}
|
|
993
|
-
function
|
|
993
|
+
function Yi(a, c) {
|
|
994
994
|
var f = this.__data__;
|
|
995
995
|
if (f instanceof G) {
|
|
996
|
-
var
|
|
997
|
-
if (!
|
|
998
|
-
return
|
|
999
|
-
f = this.__data__ = new ee(
|
|
996
|
+
var w = f.__data__;
|
|
997
|
+
if (!lt || w.length < t - 1)
|
|
998
|
+
return w.push([a, c]), this.size = ++f.size, this;
|
|
999
|
+
f = this.__data__ = new ee(w);
|
|
1000
1000
|
}
|
|
1001
|
-
return f.set(a,
|
|
1002
|
-
}
|
|
1003
|
-
te.prototype.clear = Bi, te.prototype.delete =
|
|
1004
|
-
function
|
|
1005
|
-
var f =
|
|
1006
|
-
for (var
|
|
1007
|
-
|
|
1008
|
-
(
|
|
1009
|
-
A && (
|
|
1010
|
-
|
|
1011
|
-
|
|
1001
|
+
return f.set(a, c), this.size = f.size, this;
|
|
1002
|
+
}
|
|
1003
|
+
te.prototype.clear = Bi, te.prototype.delete = $i, te.prototype.get = Pi, te.prototype.has = Oi, te.prototype.set = Yi;
|
|
1004
|
+
function ji(a, c) {
|
|
1005
|
+
var f = Be(a), w = !f && ze(a), A = !f && !w && gt(a), D = !f && !w && !A && _t(a), N = f || w || A || D, S = N ? hi(a.length, String) : [], H = S.length;
|
|
1006
|
+
for (var P in a)
|
|
1007
|
+
N && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1008
|
+
(P == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1009
|
+
A && (P == "offset" || P == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1010
|
+
D && (P == "buffer" || P == "byteLength" || P == "byteOffset") || // Skip index properties.
|
|
1011
|
+
dt(P, H)) || S.push(P);
|
|
1012
1012
|
return S;
|
|
1013
1013
|
}
|
|
1014
|
-
function
|
|
1015
|
-
(f !== void 0 && !ye(a[
|
|
1014
|
+
function He(a, c, f) {
|
|
1015
|
+
(f !== void 0 && !ye(a[c], f) || f === void 0 && !(c in a)) && Ie(a, c, f);
|
|
1016
1016
|
}
|
|
1017
|
-
function
|
|
1018
|
-
var
|
|
1019
|
-
(!(V.call(a,
|
|
1017
|
+
function Xi(a, c, f) {
|
|
1018
|
+
var w = a[c];
|
|
1019
|
+
(!(V.call(a, c) && ye(w, f)) || f === void 0 && !(c in a)) && Ie(a, c, f);
|
|
1020
1020
|
}
|
|
1021
|
-
function me(a,
|
|
1021
|
+
function me(a, c) {
|
|
1022
1022
|
for (var f = a.length; f--; )
|
|
1023
|
-
if (ye(a[f][0],
|
|
1023
|
+
if (ye(a[f][0], c))
|
|
1024
1024
|
return f;
|
|
1025
1025
|
return -1;
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1028
|
-
|
|
1027
|
+
function Ie(a, c, f) {
|
|
1028
|
+
c == "__proto__" && _e ? _e(a, c, {
|
|
1029
1029
|
configurable: !0,
|
|
1030
1030
|
enumerable: !0,
|
|
1031
1031
|
value: f,
|
|
1032
1032
|
writable: !0
|
|
1033
|
-
}) : a[
|
|
1033
|
+
}) : a[c] = f;
|
|
1034
1034
|
}
|
|
1035
|
-
var
|
|
1035
|
+
var Wi = ns();
|
|
1036
1036
|
function pe(a) {
|
|
1037
|
-
return a == null ? a === void 0 ?
|
|
1037
|
+
return a == null ? a === void 0 ? W : x : J && J in Object(a) ? rs(a) : ds(a);
|
|
1038
1038
|
}
|
|
1039
|
-
function
|
|
1039
|
+
function ct(a) {
|
|
1040
1040
|
return ae(a) && pe(a) == l;
|
|
1041
1041
|
}
|
|
1042
1042
|
function Gi(a) {
|
|
1043
|
-
if (!q(a) ||
|
|
1043
|
+
if (!q(a) || cs(a))
|
|
1044
1044
|
return !1;
|
|
1045
|
-
var
|
|
1046
|
-
return
|
|
1047
|
-
}
|
|
1048
|
-
function Zi(a) {
|
|
1049
|
-
return ae(a) && _t(a.length) && !!D[pe(a)];
|
|
1045
|
+
var c = Pe(a) ? pi : ai;
|
|
1046
|
+
return c.test(_s(a));
|
|
1050
1047
|
}
|
|
1051
1048
|
function Ui(a) {
|
|
1049
|
+
return ae(a) && ft(a.length) && !!L[pe(a)];
|
|
1050
|
+
}
|
|
1051
|
+
function Zi(a) {
|
|
1052
1052
|
if (!q(a))
|
|
1053
|
-
return
|
|
1054
|
-
var
|
|
1055
|
-
for (var
|
|
1056
|
-
|
|
1053
|
+
return hs(a);
|
|
1054
|
+
var c = ut(a), f = [];
|
|
1055
|
+
for (var w in a)
|
|
1056
|
+
w == "constructor" && (c || !V.call(a, w)) || f.push(w);
|
|
1057
1057
|
return f;
|
|
1058
1058
|
}
|
|
1059
|
-
function
|
|
1060
|
-
a !==
|
|
1061
|
-
if (A || (A = new te()), q(
|
|
1062
|
-
Vi(a,
|
|
1059
|
+
function ht(a, c, f, w, A) {
|
|
1060
|
+
a !== c && Wi(c, function(D, N) {
|
|
1061
|
+
if (A || (A = new te()), q(D))
|
|
1062
|
+
Vi(a, c, N, f, ht, w, A);
|
|
1063
1063
|
else {
|
|
1064
|
-
var S =
|
|
1065
|
-
S === void 0 && (S =
|
|
1064
|
+
var S = w ? w(Fe(a, N), D, N + "", a, c, A) : void 0;
|
|
1065
|
+
S === void 0 && (S = D), He(a, N, S);
|
|
1066
1066
|
}
|
|
1067
|
-
},
|
|
1067
|
+
}, mt);
|
|
1068
1068
|
}
|
|
1069
|
-
function Vi(a,
|
|
1070
|
-
var S =
|
|
1071
|
-
if (
|
|
1072
|
-
|
|
1069
|
+
function Vi(a, c, f, w, A, D, N) {
|
|
1070
|
+
var S = Fe(a, f), H = Fe(c, f), P = N.get(H);
|
|
1071
|
+
if (P) {
|
|
1072
|
+
He(a, f, P);
|
|
1073
1073
|
return;
|
|
1074
1074
|
}
|
|
1075
|
-
var z =
|
|
1075
|
+
var z = D ? D(S, H, f + "", a, c, N) : void 0, oe = z === void 0;
|
|
1076
1076
|
if (oe) {
|
|
1077
|
-
var
|
|
1078
|
-
z =
|
|
1077
|
+
var Oe = Be(H), Ye = !Oe && gt(H), vt = !Oe && !Ye && _t(H);
|
|
1078
|
+
z = H, Oe || Ye || vt ? Be(S) ? z = S : ms(S) ? z = ts(S) : Ye ? (oe = !1, z = qi(H)) : vt ? (oe = !1, z = es(H)) : z = [] : ps(H) || ze(H) ? (z = S, ze(S) ? z = vs(S) : (!q(S) || Pe(S)) && (z = as(H))) : oe = !1;
|
|
1079
1079
|
}
|
|
1080
|
-
oe && (
|
|
1080
|
+
oe && (N.set(H, z), A(z, H, w, D, N), N.delete(H)), He(a, f, z);
|
|
1081
1081
|
}
|
|
1082
|
-
function Ji(a,
|
|
1083
|
-
return
|
|
1082
|
+
function Ji(a, c) {
|
|
1083
|
+
return gs(us(a, c, pt), a + "");
|
|
1084
1084
|
}
|
|
1085
|
-
var Qi = _e ? function(a,
|
|
1085
|
+
var Qi = _e ? function(a, c) {
|
|
1086
1086
|
return _e(a, "toString", {
|
|
1087
1087
|
configurable: !0,
|
|
1088
1088
|
enumerable: !1,
|
|
1089
|
-
value:
|
|
1089
|
+
value: bs(c),
|
|
1090
1090
|
writable: !0
|
|
1091
1091
|
});
|
|
1092
|
-
} :
|
|
1093
|
-
function qi(a,
|
|
1092
|
+
} : pt;
|
|
1093
|
+
function qi(a, c) {
|
|
1094
1094
|
return a.slice();
|
|
1095
1095
|
}
|
|
1096
1096
|
function Ki(a) {
|
|
1097
|
-
var
|
|
1098
|
-
return new
|
|
1097
|
+
var c = new a.constructor(a.byteLength);
|
|
1098
|
+
return new nt(c).set(new nt(a)), c;
|
|
1099
1099
|
}
|
|
1100
|
-
function
|
|
1100
|
+
function es(a, c) {
|
|
1101
1101
|
var f = Ki(a.buffer);
|
|
1102
1102
|
return new a.constructor(f, a.byteOffset, a.length);
|
|
1103
1103
|
}
|
|
1104
|
-
function
|
|
1105
|
-
var f = -1,
|
|
1106
|
-
for (
|
|
1107
|
-
|
|
1108
|
-
return
|
|
1104
|
+
function ts(a, c) {
|
|
1105
|
+
var f = -1, w = a.length;
|
|
1106
|
+
for (c || (c = Array(w)); ++f < w; )
|
|
1107
|
+
c[f] = a[f];
|
|
1108
|
+
return c;
|
|
1109
1109
|
}
|
|
1110
|
-
function
|
|
1110
|
+
function is(a, c, f, w) {
|
|
1111
1111
|
var A = !f;
|
|
1112
1112
|
f || (f = {});
|
|
1113
|
-
for (var
|
|
1114
|
-
var S =
|
|
1115
|
-
|
|
1113
|
+
for (var D = -1, N = c.length; ++D < N; ) {
|
|
1114
|
+
var S = c[D], H = void 0;
|
|
1115
|
+
H === void 0 && (H = a[S]), A ? Ie(f, S, H) : Xi(f, S, H);
|
|
1116
1116
|
}
|
|
1117
1117
|
return f;
|
|
1118
1118
|
}
|
|
1119
|
-
function
|
|
1120
|
-
return Ji(function(
|
|
1121
|
-
var
|
|
1122
|
-
for (
|
|
1123
|
-
var S = f[
|
|
1124
|
-
S && a(
|
|
1119
|
+
function ss(a) {
|
|
1120
|
+
return Ji(function(c, f) {
|
|
1121
|
+
var w = -1, A = f.length, D = A > 1 ? f[A - 1] : void 0, N = A > 2 ? f[2] : void 0;
|
|
1122
|
+
for (D = a.length > 3 && typeof D == "function" ? (A--, D) : void 0, N && os(f[0], f[1], N) && (D = A < 3 ? void 0 : D, A = 1), c = Object(c); ++w < A; ) {
|
|
1123
|
+
var S = f[w];
|
|
1124
|
+
S && a(c, S, w, D);
|
|
1125
1125
|
}
|
|
1126
|
-
return
|
|
1126
|
+
return c;
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
|
-
function
|
|
1130
|
-
return function(
|
|
1131
|
-
for (var A = -1,
|
|
1132
|
-
var
|
|
1133
|
-
if (f(
|
|
1129
|
+
function ns(a) {
|
|
1130
|
+
return function(c, f, w) {
|
|
1131
|
+
for (var A = -1, D = Object(c), N = w(c), S = N.length; S--; ) {
|
|
1132
|
+
var H = N[++A];
|
|
1133
|
+
if (f(D[H], H, D) === !1)
|
|
1134
1134
|
break;
|
|
1135
1135
|
}
|
|
1136
|
-
return
|
|
1136
|
+
return c;
|
|
1137
1137
|
};
|
|
1138
1138
|
}
|
|
1139
|
-
function ve(a,
|
|
1139
|
+
function ve(a, c) {
|
|
1140
1140
|
var f = a.__data__;
|
|
1141
|
-
return
|
|
1141
|
+
return ls(c) ? f[typeof c == "string" ? "string" : "hash"] : f.map;
|
|
1142
1142
|
}
|
|
1143
|
-
function
|
|
1144
|
-
var f = ui(a,
|
|
1143
|
+
function Re(a, c) {
|
|
1144
|
+
var f = ui(a, c);
|
|
1145
1145
|
return Gi(f) ? f : void 0;
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1148
|
-
var
|
|
1147
|
+
function rs(a) {
|
|
1148
|
+
var c = V.call(a, J), f = a[J];
|
|
1149
1149
|
try {
|
|
1150
1150
|
a[J] = void 0;
|
|
1151
|
-
var
|
|
1151
|
+
var w = !0;
|
|
1152
1152
|
} catch {
|
|
1153
1153
|
}
|
|
1154
|
-
var A =
|
|
1155
|
-
return
|
|
1154
|
+
var A = it.call(a);
|
|
1155
|
+
return w && (c ? a[J] = f : delete a[J]), A;
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return typeof a.constructor == "function" && !
|
|
1157
|
+
function as(a) {
|
|
1158
|
+
return typeof a.constructor == "function" && !ut(a) ? wi(rt(a)) : {};
|
|
1159
1159
|
}
|
|
1160
|
-
function
|
|
1160
|
+
function dt(a, c) {
|
|
1161
1161
|
var f = typeof a;
|
|
1162
|
-
return
|
|
1162
|
+
return c = c ?? o, !!c && (f == "number" || f != "symbol" && oi.test(a)) && a > -1 && a % 1 == 0 && a < c;
|
|
1163
1163
|
}
|
|
1164
|
-
function
|
|
1164
|
+
function os(a, c, f) {
|
|
1165
1165
|
if (!q(f))
|
|
1166
1166
|
return !1;
|
|
1167
|
-
var
|
|
1168
|
-
return (
|
|
1167
|
+
var w = typeof c;
|
|
1168
|
+
return (w == "number" ? $e(f) && dt(c, f.length) : w == "string" && c in f) ? ye(f[c], a) : !1;
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1171
|
-
var
|
|
1172
|
-
return
|
|
1170
|
+
function ls(a) {
|
|
1171
|
+
var c = typeof a;
|
|
1172
|
+
return c == "string" || c == "number" || c == "symbol" || c == "boolean" ? a !== "__proto__" : a === null;
|
|
1173
1173
|
}
|
|
1174
|
-
function
|
|
1175
|
-
return !!
|
|
1174
|
+
function cs(a) {
|
|
1175
|
+
return !!tt && tt in a;
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1178
|
-
var
|
|
1177
|
+
function ut(a) {
|
|
1178
|
+
var c = a && a.constructor, f = typeof c == "function" && c.prototype || ue;
|
|
1179
1179
|
return a === f;
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1182
|
-
var
|
|
1181
|
+
function hs(a) {
|
|
1182
|
+
var c = [];
|
|
1183
1183
|
if (a != null)
|
|
1184
1184
|
for (var f in Object(a))
|
|
1185
|
-
|
|
1186
|
-
return
|
|
1185
|
+
c.push(f);
|
|
1186
|
+
return c;
|
|
1187
1187
|
}
|
|
1188
|
-
function
|
|
1189
|
-
return
|
|
1188
|
+
function ds(a) {
|
|
1189
|
+
return it.call(a);
|
|
1190
1190
|
}
|
|
1191
|
-
function
|
|
1192
|
-
return
|
|
1193
|
-
for (var
|
|
1194
|
-
|
|
1191
|
+
function us(a, c, f) {
|
|
1192
|
+
return c = ot(c === void 0 ? a.length - 1 : c, 0), function() {
|
|
1193
|
+
for (var w = arguments, A = -1, D = ot(w.length - c, 0), N = Array(D); ++A < D; )
|
|
1194
|
+
N[A] = w[c + A];
|
|
1195
1195
|
A = -1;
|
|
1196
|
-
for (var S = Array(
|
|
1197
|
-
S[A] =
|
|
1198
|
-
return S[
|
|
1196
|
+
for (var S = Array(c + 1); ++A < c; )
|
|
1197
|
+
S[A] = w[A];
|
|
1198
|
+
return S[c] = f(N), ci(a, this, S);
|
|
1199
1199
|
};
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1202
|
-
if (!(
|
|
1203
|
-
return a[
|
|
1201
|
+
function Fe(a, c) {
|
|
1202
|
+
if (!(c === "constructor" && typeof a[c] == "function") && c != "__proto__")
|
|
1203
|
+
return a[c];
|
|
1204
1204
|
}
|
|
1205
|
-
var
|
|
1206
|
-
function
|
|
1207
|
-
var
|
|
1205
|
+
var gs = fs(Qi);
|
|
1206
|
+
function fs(a) {
|
|
1207
|
+
var c = 0, f = 0;
|
|
1208
1208
|
return function() {
|
|
1209
|
-
var
|
|
1210
|
-
if (f =
|
|
1211
|
-
if (++
|
|
1209
|
+
var w = xi(), A = n - (w - f);
|
|
1210
|
+
if (f = w, A > 0) {
|
|
1211
|
+
if (++c >= r)
|
|
1212
1212
|
return arguments[0];
|
|
1213
1213
|
} else
|
|
1214
|
-
|
|
1214
|
+
c = 0;
|
|
1215
1215
|
return a.apply(void 0, arguments);
|
|
1216
1216
|
};
|
|
1217
1217
|
}
|
|
1218
|
-
function
|
|
1218
|
+
function _s(a) {
|
|
1219
1219
|
if (a != null) {
|
|
1220
1220
|
try {
|
|
1221
|
-
return
|
|
1221
|
+
return ge.call(a);
|
|
1222
1222
|
} catch {
|
|
1223
1223
|
}
|
|
1224
1224
|
try {
|
|
@@ -1228,78 +1228,78 @@ function ss() {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
return "";
|
|
1230
1230
|
}
|
|
1231
|
-
function ye(a,
|
|
1232
|
-
return a ===
|
|
1231
|
+
function ye(a, c) {
|
|
1232
|
+
return a === c || a !== a && c !== c;
|
|
1233
1233
|
}
|
|
1234
|
-
var
|
|
1234
|
+
var ze = ct(/* @__PURE__ */ function() {
|
|
1235
1235
|
return arguments;
|
|
1236
|
-
}()) ?
|
|
1236
|
+
}()) ? ct : function(a) {
|
|
1237
1237
|
return ae(a) && V.call(a, "callee") && !vi.call(a, "callee");
|
|
1238
|
-
},
|
|
1239
|
-
function
|
|
1240
|
-
return a != null &&
|
|
1238
|
+
}, Be = Array.isArray;
|
|
1239
|
+
function $e(a) {
|
|
1240
|
+
return a != null && ft(a.length) && !Pe(a);
|
|
1241
1241
|
}
|
|
1242
|
-
function
|
|
1243
|
-
return ae(a) &&
|
|
1242
|
+
function ms(a) {
|
|
1243
|
+
return ae(a) && $e(a);
|
|
1244
1244
|
}
|
|
1245
|
-
var gt = bi ||
|
|
1246
|
-
function
|
|
1245
|
+
var gt = bi || xs;
|
|
1246
|
+
function Pe(a) {
|
|
1247
1247
|
if (!q(a))
|
|
1248
1248
|
return !1;
|
|
1249
|
-
var
|
|
1250
|
-
return
|
|
1249
|
+
var c = pe(a);
|
|
1250
|
+
return c == p || c == v || c == d || c == M;
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1252
|
+
function ft(a) {
|
|
1253
1253
|
return typeof a == "number" && a > -1 && a % 1 == 0 && a <= o;
|
|
1254
1254
|
}
|
|
1255
1255
|
function q(a) {
|
|
1256
|
-
var
|
|
1257
|
-
return a != null && (
|
|
1256
|
+
var c = typeof a;
|
|
1257
|
+
return a != null && (c == "object" || c == "function");
|
|
1258
1258
|
}
|
|
1259
1259
|
function ae(a) {
|
|
1260
1260
|
return a != null && typeof a == "object";
|
|
1261
1261
|
}
|
|
1262
|
-
function
|
|
1263
|
-
if (!ae(a) || pe(a) !=
|
|
1262
|
+
function ps(a) {
|
|
1263
|
+
if (!ae(a) || pe(a) != C)
|
|
1264
1264
|
return !1;
|
|
1265
|
-
var
|
|
1266
|
-
if (
|
|
1265
|
+
var c = rt(a);
|
|
1266
|
+
if (c === null)
|
|
1267
1267
|
return !0;
|
|
1268
|
-
var f = V.call(
|
|
1269
|
-
return typeof f == "function" && f instanceof f &&
|
|
1268
|
+
var f = V.call(c, "constructor") && c.constructor;
|
|
1269
|
+
return typeof f == "function" && f instanceof f && ge.call(f) == mi;
|
|
1270
1270
|
}
|
|
1271
|
-
var
|
|
1272
|
-
function
|
|
1273
|
-
return
|
|
1271
|
+
var _t = et ? di(et) : Ui;
|
|
1272
|
+
function vs(a) {
|
|
1273
|
+
return is(a, mt(a));
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1276
|
-
return
|
|
1275
|
+
function mt(a) {
|
|
1276
|
+
return $e(a) ? ji(a) : Zi(a);
|
|
1277
1277
|
}
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1278
|
+
var ys = ss(function(a, c, f) {
|
|
1279
|
+
ht(a, c, f);
|
|
1280
1280
|
});
|
|
1281
|
-
function
|
|
1281
|
+
function bs(a) {
|
|
1282
1282
|
return function() {
|
|
1283
1283
|
return a;
|
|
1284
1284
|
};
|
|
1285
1285
|
}
|
|
1286
|
-
function
|
|
1286
|
+
function pt(a) {
|
|
1287
1287
|
return a;
|
|
1288
1288
|
}
|
|
1289
|
-
function
|
|
1289
|
+
function xs() {
|
|
1290
1290
|
return !1;
|
|
1291
1291
|
}
|
|
1292
|
-
i.exports =
|
|
1292
|
+
i.exports = ys;
|
|
1293
1293
|
}(le, le.exports)), le.exports;
|
|
1294
1294
|
}
|
|
1295
|
-
var
|
|
1296
|
-
const
|
|
1295
|
+
var rn = nn();
|
|
1296
|
+
const we = /* @__PURE__ */ sn(rn), St = 12, an = {
|
|
1297
1297
|
candles: {
|
|
1298
1298
|
direction: "right",
|
|
1299
|
-
offset: `${Math.round(
|
|
1299
|
+
offset: `${Math.round(St / 2)}px`,
|
|
1300
1300
|
style: "filled",
|
|
1301
1301
|
strokeWidth: 1,
|
|
1302
|
-
baseWidth:
|
|
1302
|
+
baseWidth: St,
|
|
1303
1303
|
bodyRatio: 0.7,
|
|
1304
1304
|
zoomOnWheel: "both"
|
|
1305
1305
|
},
|
|
@@ -1329,17 +1329,17 @@ const Ce = /* @__PURE__ */ ns(rs), kt = 12, as = {
|
|
|
1329
1329
|
},
|
|
1330
1330
|
markers: []
|
|
1331
1331
|
};
|
|
1332
|
-
class
|
|
1332
|
+
class on {
|
|
1333
1333
|
constructor(e) {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const t =
|
|
1334
|
+
g(this, "_candles");
|
|
1335
|
+
g(this, "_xAxis");
|
|
1336
|
+
g(this, "_yAxis");
|
|
1337
|
+
g(this, "_guides");
|
|
1338
|
+
const t = we({}, an, e);
|
|
1339
1339
|
this._candles = t.candles, this._xAxis = t.xAxis, this._yAxis = t.yAxis, this._guides = t.guides;
|
|
1340
1340
|
}
|
|
1341
1341
|
update(e) {
|
|
1342
|
-
const t =
|
|
1342
|
+
const t = we(
|
|
1343
1343
|
{},
|
|
1344
1344
|
{
|
|
1345
1345
|
candles: this._candles,
|
|
@@ -1367,18 +1367,18 @@ class os {
|
|
|
1367
1367
|
return this._guides;
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
1370
|
-
class
|
|
1370
|
+
class O {
|
|
1371
1371
|
constructor(e) {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1372
|
+
g(this, "_x");
|
|
1373
|
+
g(this, "_y");
|
|
1374
|
+
g(this, "_width");
|
|
1375
|
+
g(this, "_height");
|
|
1376
1376
|
let t;
|
|
1377
1377
|
if (!e)
|
|
1378
1378
|
t = { x: 0, y: 0, width: 0, height: 0 };
|
|
1379
1379
|
else if (e instanceof HTMLElement || e instanceof Element) {
|
|
1380
|
-
const { x:
|
|
1381
|
-
t = { x:
|
|
1380
|
+
const { x: s, y: r, width: n, height: o } = e.getBoundingClientRect();
|
|
1381
|
+
t = { x: s, y: r, width: n, height: o };
|
|
1382
1382
|
} else
|
|
1383
1383
|
t = e;
|
|
1384
1384
|
this._x = t.x, this._y = t.y, this._width = t.width, this._height = t.height;
|
|
@@ -1408,47 +1408,47 @@ class P {
|
|
|
1408
1408
|
return this._y + this._height;
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
|
-
class
|
|
1411
|
+
class ln {
|
|
1412
1412
|
constructor(e, t) {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
const { xAxis:
|
|
1419
|
-
this._chart = new
|
|
1413
|
+
g(this, "_chart", new O());
|
|
1414
|
+
g(this, "_area", new O());
|
|
1415
|
+
g(this, "_xAxis", new O());
|
|
1416
|
+
g(this, "_yAxis", new O());
|
|
1417
|
+
g(this, "_axisIntersection", new O());
|
|
1418
|
+
const { xAxis: s, yAxis: r } = t;
|
|
1419
|
+
this._chart = new O(e), this._calc(s, r);
|
|
1420
1420
|
}
|
|
1421
1421
|
_calc(e, t) {
|
|
1422
|
-
const
|
|
1423
|
-
this._area = new
|
|
1422
|
+
const s = e.isShow ? e.height : 0, r = t.isShow ? t.width : 0, n = this._chart.height - s, o = this._chart.width - r;
|
|
1423
|
+
this._area = new O({
|
|
1424
1424
|
x: t.position === "left" ? r : 0,
|
|
1425
|
-
y: e.position === "top" ?
|
|
1425
|
+
y: e.position === "top" ? s : 0,
|
|
1426
1426
|
width: o,
|
|
1427
|
-
height:
|
|
1428
|
-
}), this._xAxis = new
|
|
1429
|
-
y: e.position === "top" ? 0 :
|
|
1427
|
+
height: n
|
|
1428
|
+
}), this._xAxis = new O({
|
|
1429
|
+
y: e.position === "top" ? 0 : n,
|
|
1430
1430
|
x: t.position === "left" ? r : 0,
|
|
1431
|
-
height:
|
|
1431
|
+
height: s,
|
|
1432
1432
|
width: o
|
|
1433
|
-
}), this._yAxis = new
|
|
1434
|
-
y: e.position === "top" ?
|
|
1433
|
+
}), this._yAxis = new O({
|
|
1434
|
+
y: e.position === "top" ? s : 0,
|
|
1435
1435
|
x: t.position === "left" ? 0 : o,
|
|
1436
1436
|
width: r,
|
|
1437
|
-
height:
|
|
1438
|
-
}), this._axisIntersection = new
|
|
1439
|
-
y: e.position === "top" ? 0 :
|
|
1437
|
+
height: n
|
|
1438
|
+
}), this._axisIntersection = new O({
|
|
1439
|
+
y: e.position === "top" ? 0 : n,
|
|
1440
1440
|
x: t.position === "left" ? 0 : o,
|
|
1441
1441
|
width: r,
|
|
1442
|
-
height:
|
|
1442
|
+
height: s
|
|
1443
1443
|
});
|
|
1444
1444
|
}
|
|
1445
1445
|
updateConfig(e) {
|
|
1446
|
-
const { xAxis: t, yAxis:
|
|
1447
|
-
this._calc(t,
|
|
1446
|
+
const { xAxis: t, yAxis: s } = e;
|
|
1447
|
+
this._calc(t, s);
|
|
1448
1448
|
}
|
|
1449
1449
|
update(e) {
|
|
1450
|
-
const { xAxis: t, yAxis:
|
|
1451
|
-
this._chart = new
|
|
1450
|
+
const { xAxis: t, yAxis: s } = e.config;
|
|
1451
|
+
this._chart = new O(e.container), this._calc(t, s);
|
|
1452
1452
|
}
|
|
1453
1453
|
get area() {
|
|
1454
1454
|
return this._area;
|
|
@@ -1466,57 +1466,73 @@ class ls {
|
|
|
1466
1466
|
return this._chart;
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
-
const
|
|
1470
|
-
function
|
|
1469
|
+
const Ot = (i) => i ? new Date(i.close_time).getTime() - new Date(i.open_time).getTime() : 0;
|
|
1470
|
+
function cn(i, e) {
|
|
1471
1471
|
if (i.length < 2) return [];
|
|
1472
1472
|
const t = [];
|
|
1473
|
-
for (let
|
|
1474
|
-
const r = i[
|
|
1473
|
+
for (let s = 0; s < i.length - 1; s++) {
|
|
1474
|
+
const r = i[s].close_time.getTime(), n = i[s].open_time.getTime(), l = new Date(i[s + 1].open_time).getTime() - r;
|
|
1475
1475
|
if (l >= e) {
|
|
1476
|
-
const
|
|
1477
|
-
for (let u = 1; u <=
|
|
1478
|
-
d.push(
|
|
1476
|
+
const h = Math.floor(l / e), d = [];
|
|
1477
|
+
for (let u = 1; u <= h; u++)
|
|
1478
|
+
d.push(n + u * e);
|
|
1479
1479
|
d.length > 0 && t.push(d);
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
1482
|
return t;
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1485
|
-
const
|
|
1486
|
-
return
|
|
1487
|
-
if (
|
|
1488
|
-
const
|
|
1489
|
-
(
|
|
1484
|
+
function kt(i, e) {
|
|
1485
|
+
const t = Ot(i[0]), s = cn(i, t), r = [];
|
|
1486
|
+
return s.forEach((n) => {
|
|
1487
|
+
if (n.length === 0) return;
|
|
1488
|
+
const o = i.find((_) => _.close_time.getTime() === n[0]), l = i.find(
|
|
1489
|
+
(_) => _.open_time.getTime() === n[n.length - 1] + t
|
|
1490
1490
|
);
|
|
1491
|
-
if (!
|
|
1491
|
+
if (!o || !l)
|
|
1492
1492
|
throw new Error("[CS_Data] error while creating missing data");
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1493
|
+
const h = o.close, d = l.open;
|
|
1494
|
+
let u = h;
|
|
1495
|
+
n.forEach((_, m) => {
|
|
1496
|
+
const p = (d - u) / n.length;
|
|
1497
|
+
let v = u + p * m, y = v + p;
|
|
1498
|
+
const b = Math.abs(v - y);
|
|
1499
|
+
let x = Math.max(v, y) + b / 2, C = Math.min(v, y) - b / 2;
|
|
1500
|
+
if (e.trade) {
|
|
1501
|
+
const E = [...e.trade.entries, ...e.trade.exits].find(($) => {
|
|
1502
|
+
const F = $.time.getTime();
|
|
1503
|
+
return F >= _ && F < _ + t;
|
|
1504
|
+
});
|
|
1505
|
+
E && (E.type === "buy" ? (C = E.price, y = Math.max(C, y), v = y + b, x = Math.max(v, y) + b / 2, u = v) : E.type === "sell" && (x = E.price, y = Math.min(x, y), v = y - b, C = Math.min(v, y) - b / 2, u = v));
|
|
1506
|
+
}
|
|
1507
|
+
const M = {
|
|
1508
|
+
open_time: new Date(_),
|
|
1509
|
+
close_time: new Date(_ + t),
|
|
1510
|
+
open: v,
|
|
1511
|
+
close: y,
|
|
1512
|
+
high: x,
|
|
1513
|
+
low: C
|
|
1502
1514
|
};
|
|
1503
|
-
|
|
1515
|
+
r.push(M);
|
|
1504
1516
|
});
|
|
1505
|
-
}),
|
|
1517
|
+
}), r;
|
|
1506
1518
|
}
|
|
1507
|
-
class
|
|
1508
|
-
constructor(e) {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
this
|
|
1519
|
+
class hn {
|
|
1520
|
+
constructor(e, t) {
|
|
1521
|
+
g(this, "_initialData", []);
|
|
1522
|
+
g(this, "_preparedData", []);
|
|
1523
|
+
g(this, "_missingData", []);
|
|
1524
|
+
g(this, "_count", 0);
|
|
1525
|
+
g(this, "_model");
|
|
1526
|
+
this._model = t, this.update(e);
|
|
1514
1527
|
}
|
|
1515
1528
|
_prepare(e) {
|
|
1516
|
-
return e.map((t) => ({ ...t, open_time: new Date(t.open_time), close_time: new Date(t.close_time) })).sort((t,
|
|
1529
|
+
return e.map((t) => ({ ...t, open_time: new Date(t.open_time), close_time: new Date(t.close_time) })).sort((t, s) => t.open_time.getTime() - s.open_time.getTime());
|
|
1517
1530
|
}
|
|
1518
1531
|
update(e) {
|
|
1519
|
-
this._initialData = e, this._preparedData = this._prepare(e), this._missingData =
|
|
1532
|
+
this._initialData = e, this._preparedData = this._prepare(e), this._missingData = kt(this._preparedData, this._model), this._count = this._preparedData.length + this._missingData.length;
|
|
1533
|
+
}
|
|
1534
|
+
updateMissingCandles() {
|
|
1535
|
+
this._missingData = kt(this._preparedData, this._model);
|
|
1520
1536
|
}
|
|
1521
1537
|
get initialData() {
|
|
1522
1538
|
return this._initialData;
|
|
@@ -1534,29 +1550,29 @@ class ds {
|
|
|
1534
1550
|
return this._count;
|
|
1535
1551
|
}
|
|
1536
1552
|
}
|
|
1537
|
-
class
|
|
1553
|
+
class dn {
|
|
1538
1554
|
constructor() {
|
|
1539
|
-
|
|
1555
|
+
g(this, "listeners", {});
|
|
1540
1556
|
}
|
|
1541
1557
|
subscribe(e, t) {
|
|
1542
1558
|
return this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(t), () => this.unsubscribe(e, t);
|
|
1543
1559
|
}
|
|
1544
1560
|
unsubscribe(e, t) {
|
|
1545
|
-
var
|
|
1546
|
-
this.listeners[e] = ((
|
|
1561
|
+
var s;
|
|
1562
|
+
this.listeners[e] = ((s = this.listeners[e]) == null ? void 0 : s.filter((r) => r !== t)) || [];
|
|
1547
1563
|
}
|
|
1548
1564
|
emit(e, ...t) {
|
|
1549
1565
|
var r;
|
|
1550
|
-
const
|
|
1551
|
-
(r = this.listeners[e]) == null || r.forEach((
|
|
1552
|
-
s
|
|
1566
|
+
const s = t[0];
|
|
1567
|
+
(r = this.listeners[e]) == null || r.forEach((n) => {
|
|
1568
|
+
n(s);
|
|
1553
1569
|
});
|
|
1554
1570
|
}
|
|
1555
1571
|
}
|
|
1556
|
-
class
|
|
1572
|
+
class Ze {
|
|
1557
1573
|
constructor(e, t) {
|
|
1558
|
-
|
|
1559
|
-
|
|
1574
|
+
g(this, "_scale");
|
|
1575
|
+
g(this, "_onChange");
|
|
1560
1576
|
this._scale = e, this._onChange = t;
|
|
1561
1577
|
}
|
|
1562
1578
|
reConstruct(e) {
|
|
@@ -1586,7 +1602,7 @@ class Ve {
|
|
|
1586
1602
|
return this._scale.tickFormat(e, t);
|
|
1587
1603
|
}
|
|
1588
1604
|
copy() {
|
|
1589
|
-
return new
|
|
1605
|
+
return new Ze(this._scale.copy(), this._onChange);
|
|
1590
1606
|
}
|
|
1591
1607
|
raw() {
|
|
1592
1608
|
return this._scale;
|
|
@@ -1595,10 +1611,10 @@ class Ve {
|
|
|
1595
1611
|
return this._scale(e);
|
|
1596
1612
|
}
|
|
1597
1613
|
}
|
|
1598
|
-
class
|
|
1614
|
+
class Ve {
|
|
1599
1615
|
constructor(e, t) {
|
|
1600
|
-
|
|
1601
|
-
|
|
1616
|
+
g(this, "_scale");
|
|
1617
|
+
g(this, "_onChange");
|
|
1602
1618
|
this._scale = e, this._onChange = t;
|
|
1603
1619
|
}
|
|
1604
1620
|
reConstruct(e) {
|
|
@@ -1630,7 +1646,7 @@ class Je {
|
|
|
1630
1646
|
return this._scale.tickFormat(e, t);
|
|
1631
1647
|
}
|
|
1632
1648
|
copy() {
|
|
1633
|
-
return new
|
|
1649
|
+
return new Ve(this._scale.copy(), this._onChange);
|
|
1634
1650
|
}
|
|
1635
1651
|
raw() {
|
|
1636
1652
|
return this._scale;
|
|
@@ -1639,12 +1655,12 @@ class Je {
|
|
|
1639
1655
|
return this._scale(e);
|
|
1640
1656
|
}
|
|
1641
1657
|
}
|
|
1642
|
-
const
|
|
1658
|
+
const un = (i) => {
|
|
1643
1659
|
const e = i.match(/^(\d+)([a-zA-Z]+)$/);
|
|
1644
1660
|
if (!e)
|
|
1645
1661
|
throw new Error(`Invalid offset format: "${i}"`);
|
|
1646
1662
|
return [parseInt(e[1]), e[2]];
|
|
1647
|
-
},
|
|
1663
|
+
}, gn = {
|
|
1648
1664
|
s: 1e3,
|
|
1649
1665
|
M: 1e3 * 60,
|
|
1650
1666
|
h: 1e3 * 60 * 60,
|
|
@@ -1653,41 +1669,41 @@ const fs = (i) => {
|
|
|
1653
1669
|
}, Et = (i) => {
|
|
1654
1670
|
const {
|
|
1655
1671
|
candles: { preparedData: e, count: t },
|
|
1656
|
-
layout: { area:
|
|
1672
|
+
layout: { area: s, xAxis: r },
|
|
1657
1673
|
config: {
|
|
1658
|
-
candles: { offset:
|
|
1674
|
+
candles: { offset: n, direction: o, baseWidth: l, bodyRatio: h }
|
|
1659
1675
|
}
|
|
1660
|
-
} = i, d = k.extent(e, (
|
|
1676
|
+
} = i, d = k.extent(e, (E) => new Date(E.open_time));
|
|
1661
1677
|
if (!d[0] || !d[1])
|
|
1662
1678
|
throw new Error("Cannot create scales: data is empty or invalid");
|
|
1663
|
-
const u = d[0].getTime(), _ = d[1].getTime(),
|
|
1679
|
+
const u = d[0].getTime(), _ = d[1].getTime(), m = _ - u, p = l / h * t, v = m * (s.width / p), y = o === "left" ? [d[0], new Date(u + v)] : [new Date(_ - v), d[1]];
|
|
1664
1680
|
let b = k.scaleTime().domain(y).range([r.x, r.width]);
|
|
1665
|
-
const [
|
|
1666
|
-
let
|
|
1667
|
-
return
|
|
1668
|
-
new Date(y[0].getTime() +
|
|
1669
|
-
new Date(y[1].getTime() +
|
|
1681
|
+
const [x, C] = un(n);
|
|
1682
|
+
let M = 0;
|
|
1683
|
+
return C === "px" ? M = b.invert(r.x + x).getTime() - b.invert(r.x).getTime() : M = gn[C] * x, M *= o === "left" ? -1 : 1, b.domain([
|
|
1684
|
+
new Date(y[0].getTime() + M),
|
|
1685
|
+
new Date(y[1].getTime() + M)
|
|
1670
1686
|
]), b;
|
|
1671
1687
|
}, Dt = (i) => {
|
|
1672
1688
|
const {
|
|
1673
1689
|
candles: { preparedData: e },
|
|
1674
1690
|
layout: { yAxis: t }
|
|
1675
|
-
} = i,
|
|
1676
|
-
if (
|
|
1691
|
+
} = i, s = k.min(e, (n) => n.low), r = k.max(e, (n) => n.high);
|
|
1692
|
+
if (s === void 0 || r === void 0)
|
|
1677
1693
|
throw new Error("Cannot create scales: data is empty or invalid");
|
|
1678
|
-
return k.scaleLinear().domain([
|
|
1694
|
+
return k.scaleLinear().domain([s, r]).range([t.y + t.height, t.y]);
|
|
1679
1695
|
};
|
|
1680
|
-
class
|
|
1696
|
+
class fn {
|
|
1681
1697
|
constructor(e) {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
this._model = e, this._scaleX = new
|
|
1698
|
+
g(this, "_scaleX");
|
|
1699
|
+
g(this, "_scaleY");
|
|
1700
|
+
g(this, "_scaleFactorX", 1);
|
|
1701
|
+
g(this, "_scaleFactorY", 1);
|
|
1702
|
+
g(this, "_model");
|
|
1703
|
+
this._model = e, this._scaleX = new Ze(
|
|
1688
1704
|
Et(this._model),
|
|
1689
1705
|
() => e.eventBus.emit("scale_event")
|
|
1690
|
-
), this._scaleY = new
|
|
1706
|
+
), this._scaleY = new Ve(
|
|
1691
1707
|
Dt(this._model),
|
|
1692
1708
|
() => e.eventBus.emit("scale_event")
|
|
1693
1709
|
);
|
|
@@ -1714,12 +1730,107 @@ class _s {
|
|
|
1714
1730
|
this._scaleFactorY = e;
|
|
1715
1731
|
}
|
|
1716
1732
|
}
|
|
1717
|
-
class
|
|
1733
|
+
class Lt {
|
|
1734
|
+
static parseTrades({ entry: e, exit: t }) {
|
|
1735
|
+
const s = e.map((n) => ({
|
|
1736
|
+
...n,
|
|
1737
|
+
kind: "entry",
|
|
1738
|
+
time: new Date(n.time)
|
|
1739
|
+
})), r = t.map((n) => ({
|
|
1740
|
+
...n,
|
|
1741
|
+
kind: "exit",
|
|
1742
|
+
time: new Date(n.time)
|
|
1743
|
+
}));
|
|
1744
|
+
return [...s, ...r];
|
|
1745
|
+
}
|
|
1746
|
+
static mapTradesToCandles(e, t) {
|
|
1747
|
+
return t.map((s) => {
|
|
1748
|
+
const r = e.filter(
|
|
1749
|
+
(n) => n.time >= s.open_time && n.time < s.close_time
|
|
1750
|
+
);
|
|
1751
|
+
return { candle: s, trades: r };
|
|
1752
|
+
}).filter((s) => s.trades.length > 0);
|
|
1753
|
+
}
|
|
1754
|
+
static createMarker(e, t, s) {
|
|
1755
|
+
return {
|
|
1756
|
+
type: "horizontal",
|
|
1757
|
+
value: s[e === "entry" ? "low" : "high"],
|
|
1758
|
+
formatter: (r) => `${e === "entry" ? "Entry" : "Exit"} | ${r}`,
|
|
1759
|
+
mainColor: t.main,
|
|
1760
|
+
lineColor: t.line,
|
|
1761
|
+
textColor: t.text
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
class _n {
|
|
1766
|
+
constructor(e, { entry: t = [], exit: s = [] }) {
|
|
1767
|
+
g(this, "_model");
|
|
1768
|
+
g(this, "_rawEntry");
|
|
1769
|
+
g(this, "_rawExit");
|
|
1770
|
+
g(this, "_mapped", []);
|
|
1771
|
+
g(this, "_entry", []);
|
|
1772
|
+
g(this, "_exit", []);
|
|
1773
|
+
g(this, "_timeRange", []);
|
|
1774
|
+
g(this, "_activeTradeTime", null);
|
|
1775
|
+
g(this, "_hoveredTradeTime", null);
|
|
1776
|
+
this._rawEntry = t, this._rawExit = s, this._model = e, this.recalculate();
|
|
1777
|
+
}
|
|
1778
|
+
_calcTimeRange() {
|
|
1779
|
+
const { allData: e } = this._model.candles, t = e.map((h) => h.open_time.getTime()), s = Ot(e[0]), r = Math.min(...this._entry.map((h) => h.time.getTime())), n = Math.max(...this._exit.map((h) => h.time.getTime())), o = t.findIndex((h) => h <= r && h + s >= r), l = t.findIndex((h) => h <= n && h + s >= n);
|
|
1780
|
+
return t.slice(o === -1 ? 0 : o, (l === -1 ? t.length - 1 : l) + 1);
|
|
1781
|
+
}
|
|
1782
|
+
recalculate() {
|
|
1783
|
+
const e = Lt.parseTrades({
|
|
1784
|
+
entry: this._rawEntry,
|
|
1785
|
+
exit: this._rawExit
|
|
1786
|
+
});
|
|
1787
|
+
this._mapped = Lt.mapTradesToCandles(e, this._model.candles.allData);
|
|
1788
|
+
const t = this._mapped.flatMap((s) => s.trades);
|
|
1789
|
+
this._entry = t.filter((s) => s.kind === "entry"), this._exit = t.filter((s) => s.kind === "exit"), this._timeRange = this._calcTimeRange();
|
|
1790
|
+
}
|
|
1791
|
+
updateTrade({ entry: e, exit: t }) {
|
|
1792
|
+
this._rawEntry = e, this._rawExit = t, this.recalculate();
|
|
1793
|
+
}
|
|
1794
|
+
setActiveTrade(e) {
|
|
1795
|
+
this._activeTradeTime = e, this._mapped = this._mapped.map((t) => ({
|
|
1796
|
+
...t,
|
|
1797
|
+
isActive: t.candle.open_time.getTime() === e
|
|
1798
|
+
}));
|
|
1799
|
+
}
|
|
1800
|
+
setHoveredTrade(e) {
|
|
1801
|
+
this._hoveredTradeTime = e, this._mapped = this._mapped.map((t) => ({
|
|
1802
|
+
...t,
|
|
1803
|
+
isHovered: t.candle.open_time.getTime() === e
|
|
1804
|
+
}));
|
|
1805
|
+
}
|
|
1806
|
+
get hasActiveTrade() {
|
|
1807
|
+
return this._activeTradeTime !== null;
|
|
1808
|
+
}
|
|
1809
|
+
get hasHoveredTrade() {
|
|
1810
|
+
return this._hoveredTradeTime !== null;
|
|
1811
|
+
}
|
|
1812
|
+
get tradedCandles() {
|
|
1813
|
+
return this._mapped;
|
|
1814
|
+
}
|
|
1815
|
+
get entries() {
|
|
1816
|
+
return this._entry;
|
|
1817
|
+
}
|
|
1818
|
+
get exits() {
|
|
1819
|
+
return this._exit;
|
|
1820
|
+
}
|
|
1821
|
+
get timeRange() {
|
|
1822
|
+
return this._timeRange;
|
|
1823
|
+
}
|
|
1824
|
+
get hasTrade() {
|
|
1825
|
+
return !!(this._rawEntry.length && this._rawExit.length);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
class mn {
|
|
1718
1829
|
constructor(e, t) {
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1830
|
+
g(this, "_rawMarkers");
|
|
1831
|
+
g(this, "_markers", []);
|
|
1832
|
+
g(this, "_model");
|
|
1833
|
+
g(this, "_defaults", {
|
|
1723
1834
|
mainColor: "#000000",
|
|
1724
1835
|
textColor: "#ffffff",
|
|
1725
1836
|
lineColor: "#000000",
|
|
@@ -1733,33 +1844,33 @@ class Yt {
|
|
|
1733
1844
|
rebuild() {
|
|
1734
1845
|
const {
|
|
1735
1846
|
layout: { area: e, chart: t },
|
|
1736
|
-
config:
|
|
1737
|
-
scales: { x: r, y:
|
|
1847
|
+
config: s,
|
|
1848
|
+
scales: { x: r, y: n },
|
|
1738
1849
|
colorScheme: {
|
|
1739
1850
|
userMarkers: { default: o }
|
|
1740
1851
|
}
|
|
1741
1852
|
} = this._model;
|
|
1742
1853
|
this._markers = this._rawMarkers.map((l) => {
|
|
1743
1854
|
var u, _;
|
|
1744
|
-
const
|
|
1855
|
+
const h = {
|
|
1745
1856
|
mainColor: l.mainColor ?? o.main,
|
|
1746
1857
|
textColor: l.textColor ?? o.text,
|
|
1747
1858
|
lineColor: l.lineColor ?? o.line
|
|
1748
1859
|
};
|
|
1749
1860
|
if ((l.type ?? "horizontal") === "horizontal") {
|
|
1750
|
-
const
|
|
1861
|
+
const m = l, p = n.map(m.value), y = (m.formatter ?? ((u = this._defaults.formatter) == null ? void 0 : u.horizontal) ?? ((b) => b.toString()))(m.value);
|
|
1751
1862
|
return {
|
|
1752
|
-
value:
|
|
1863
|
+
value: m.value,
|
|
1753
1864
|
type: "horizontal",
|
|
1754
1865
|
text: y,
|
|
1755
1866
|
x: e.x,
|
|
1756
1867
|
y: p,
|
|
1757
1868
|
lineLength: t.width,
|
|
1758
|
-
position:
|
|
1759
|
-
...
|
|
1869
|
+
position: s.yAxis.position,
|
|
1870
|
+
...h
|
|
1760
1871
|
};
|
|
1761
1872
|
} else {
|
|
1762
|
-
const
|
|
1873
|
+
const m = l, p = m.value instanceof Date ? m.value : new Date(m.value), v = r.map(p), b = (m.formatter ?? ((_ = this._defaults.formatter) == null ? void 0 : _.vertical) ?? ((x) => x.toLocaleString()))(p);
|
|
1763
1874
|
return {
|
|
1764
1875
|
value: p,
|
|
1765
1876
|
type: "vertical",
|
|
@@ -1767,8 +1878,8 @@ class Yt {
|
|
|
1767
1878
|
x: v,
|
|
1768
1879
|
y: e.y,
|
|
1769
1880
|
lineLength: t.height,
|
|
1770
|
-
position:
|
|
1771
|
-
...
|
|
1881
|
+
position: s.xAxis.position,
|
|
1882
|
+
...h
|
|
1772
1883
|
};
|
|
1773
1884
|
}
|
|
1774
1885
|
});
|
|
@@ -1780,176 +1891,89 @@ class Yt {
|
|
|
1780
1891
|
return this._markers;
|
|
1781
1892
|
}
|
|
1782
1893
|
}
|
|
1783
|
-
class
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
...s,
|
|
1791
|
-
kind: "exit",
|
|
1792
|
-
time: new Date(s.time)
|
|
1793
|
-
}));
|
|
1794
|
-
return [...n, ...r];
|
|
1795
|
-
}
|
|
1796
|
-
static mapTradesToCandles(e, t) {
|
|
1797
|
-
return t.map((n) => {
|
|
1798
|
-
const r = e.filter(
|
|
1799
|
-
(s) => s.time >= n.open_time && s.time < n.close_time
|
|
1800
|
-
);
|
|
1801
|
-
return { candle: n, trades: r };
|
|
1802
|
-
}).filter((n) => n.trades.length > 0);
|
|
1803
|
-
}
|
|
1804
|
-
static createMarker(e, t, n) {
|
|
1805
|
-
return {
|
|
1806
|
-
type: "horizontal",
|
|
1807
|
-
value: n[e === "entry" ? "low" : "high"],
|
|
1808
|
-
formatter: (r) => `${e === "entry" ? "Entry" : "Exit"} | ${r}`,
|
|
1809
|
-
mainColor: t.main,
|
|
1810
|
-
lineColor: t.line,
|
|
1811
|
-
textColor: t.text
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
class ms {
|
|
1816
|
-
constructor(e, { entry: t = [], exit: n = [] }) {
|
|
1817
|
-
m(this, "_model");
|
|
1818
|
-
m(this, "_rawEntry");
|
|
1819
|
-
m(this, "_rawExit");
|
|
1820
|
-
m(this, "_mapped", []);
|
|
1821
|
-
m(this, "_entry", []);
|
|
1822
|
-
m(this, "_exit", []);
|
|
1823
|
-
m(this, "_markers");
|
|
1824
|
-
m(this, "_timeRange", []);
|
|
1825
|
-
m(this, "_activeTradeTime", null);
|
|
1826
|
-
this._rawEntry = t, this._rawExit = n, this._model = e, this._markers = new Yt(e, []), this.recalculate();
|
|
1827
|
-
}
|
|
1828
|
-
_createMarkers() {
|
|
1829
|
-
const { trade: e } = this._model.colorScheme;
|
|
1830
|
-
return this._mapped.flatMap(({ candle: t, trades: n }) => {
|
|
1831
|
-
const r = [];
|
|
1832
|
-
return n.some((s) => s.kind === "entry") && r.push(xe.createMarker("entry", e.entryMarker, t)), n.some((s) => s.kind === "exit") && r.push(xe.createMarker("exit", e.exitMarker, t)), r;
|
|
1894
|
+
class pn {
|
|
1895
|
+
constructor() {
|
|
1896
|
+
g(this, "bg", "#FFFFFF");
|
|
1897
|
+
g(this, "axisIntersection", "#FFFFFF");
|
|
1898
|
+
g(this, "xAxis", {
|
|
1899
|
+
bg: "#FFFFFF",
|
|
1900
|
+
text: "#7F7F83"
|
|
1833
1901
|
});
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
return t.slice(o === -1 ? 0 : o, (l === -1 ? t.length - 1 : l) + 1);
|
|
1838
|
-
}
|
|
1839
|
-
recalculate() {
|
|
1840
|
-
const e = xe.parseTrades({
|
|
1841
|
-
entry: this._rawEntry,
|
|
1842
|
-
exit: this._rawExit
|
|
1902
|
+
g(this, "yAxis", {
|
|
1903
|
+
bg: "#FFFFFF",
|
|
1904
|
+
text: "#7F7F83"
|
|
1843
1905
|
});
|
|
1844
|
-
this
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
this
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1906
|
+
g(this, "candles", {
|
|
1907
|
+
risingFill: "#56B683",
|
|
1908
|
+
risingStroke: "#000000",
|
|
1909
|
+
fallingFill: "#F18169",
|
|
1910
|
+
fallingStroke: "#000000",
|
|
1911
|
+
noDataFill: ["#d9d9da", "#ededed"],
|
|
1912
|
+
noDataStroke: "#000000"
|
|
1913
|
+
});
|
|
1914
|
+
g(this, "guides", {
|
|
1915
|
+
horizontalMarker: {
|
|
1916
|
+
main: "#1C2026",
|
|
1917
|
+
text: "#ffffff",
|
|
1918
|
+
line: "#1C2026"
|
|
1919
|
+
},
|
|
1920
|
+
verticalMarker: {
|
|
1921
|
+
main: "#1C2026",
|
|
1922
|
+
text: "#ffffff",
|
|
1923
|
+
line: "#1C2026"
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
g(this, "trade");
|
|
1927
|
+
g(this, "userMarkers");
|
|
1928
|
+
this.trade = {
|
|
1929
|
+
buyLabel: {
|
|
1930
|
+
main: this.candles.risingFill,
|
|
1931
|
+
text: "#ffffff"
|
|
1932
|
+
},
|
|
1933
|
+
sellLabel: {
|
|
1934
|
+
main: this.candles.fallingFill,
|
|
1935
|
+
text: "#ffffff"
|
|
1936
|
+
},
|
|
1937
|
+
connectionLine: "#D9D9DA",
|
|
1938
|
+
tradeBorders: "#EDEDED",
|
|
1939
|
+
activeLabel: "#007AFF"
|
|
1940
|
+
}, this.userMarkers = {
|
|
1941
|
+
default: {
|
|
1942
|
+
main: "#EDEDED",
|
|
1943
|
+
text: "#000000",
|
|
1944
|
+
line: "#EDEDED"
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1871
1947
|
}
|
|
1872
|
-
|
|
1873
|
-
return
|
|
1948
|
+
toObject() {
|
|
1949
|
+
return {
|
|
1950
|
+
bg: this.bg,
|
|
1951
|
+
axisIntersection: this.axisIntersection,
|
|
1952
|
+
xAxis: this.xAxis,
|
|
1953
|
+
yAxis: this.yAxis,
|
|
1954
|
+
candles: this.candles,
|
|
1955
|
+
guides: this.guides,
|
|
1956
|
+
trade: this.trade,
|
|
1957
|
+
userMarkers: this.userMarkers
|
|
1958
|
+
};
|
|
1874
1959
|
}
|
|
1875
1960
|
}
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
axisIntersection: "#FFFFFF",
|
|
1879
|
-
xAxis: {
|
|
1880
|
-
bg: "#FFFFFF",
|
|
1881
|
-
text: "#7F7F83"
|
|
1882
|
-
},
|
|
1883
|
-
yAxis: {
|
|
1884
|
-
bg: "#FFFFFF",
|
|
1885
|
-
text: "#7F7F83"
|
|
1886
|
-
},
|
|
1887
|
-
candles: {
|
|
1888
|
-
risingFill: "#56B683",
|
|
1889
|
-
risingStroke: "#000000",
|
|
1890
|
-
fallingFill: "#F18169",
|
|
1891
|
-
fallingStroke: "#000000",
|
|
1892
|
-
noDataFill: ["#d9d9da", "#ededed"],
|
|
1893
|
-
noDataStroke: "#000000"
|
|
1894
|
-
},
|
|
1895
|
-
guides: {
|
|
1896
|
-
horizontalMarker: {
|
|
1897
|
-
main: "#1C2026",
|
|
1898
|
-
text: "#ffffff",
|
|
1899
|
-
line: "#1C2026"
|
|
1900
|
-
},
|
|
1901
|
-
verticalMarker: {
|
|
1902
|
-
main: "#1C2026",
|
|
1903
|
-
text: "#ffffff",
|
|
1904
|
-
line: "#1C2026"
|
|
1905
|
-
}
|
|
1906
|
-
},
|
|
1907
|
-
trade: {
|
|
1908
|
-
entryMarker: {
|
|
1909
|
-
main: "#56B683",
|
|
1910
|
-
text: "#ffffff",
|
|
1911
|
-
line: "#56B683"
|
|
1912
|
-
},
|
|
1913
|
-
exitMarker: {
|
|
1914
|
-
main: "#F18169",
|
|
1915
|
-
text: "#ffffff",
|
|
1916
|
-
line: "#F18169"
|
|
1917
|
-
},
|
|
1918
|
-
entryLabel: {
|
|
1919
|
-
main: "#56B683",
|
|
1920
|
-
text: "#ffffff"
|
|
1921
|
-
},
|
|
1922
|
-
exitLabel: {
|
|
1923
|
-
main: "#F18169",
|
|
1924
|
-
text: "#ffffff"
|
|
1925
|
-
},
|
|
1926
|
-
connectionLine: "#D9D9DA",
|
|
1927
|
-
tradeBorders: "#EDEDED",
|
|
1928
|
-
activeLabel: "#007AFF"
|
|
1929
|
-
},
|
|
1930
|
-
userMarkers: {
|
|
1931
|
-
default: {
|
|
1932
|
-
main: "#EDEDED",
|
|
1933
|
-
text: "#000000",
|
|
1934
|
-
line: "#EDEDED"
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
};
|
|
1938
|
-
class vs {
|
|
1961
|
+
const vn = new pn().toObject();
|
|
1962
|
+
class yn {
|
|
1939
1963
|
constructor(e) {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
const t =
|
|
1964
|
+
g(this, "_bg");
|
|
1965
|
+
g(this, "_candles");
|
|
1966
|
+
g(this, "_xAxis");
|
|
1967
|
+
g(this, "_yAxis");
|
|
1968
|
+
g(this, "_guides");
|
|
1969
|
+
g(this, "_axisIntersection");
|
|
1970
|
+
g(this, "_trade");
|
|
1971
|
+
g(this, "_userMarkers");
|
|
1972
|
+
const t = we({}, vn, e);
|
|
1949
1973
|
this._candles = t.candles, this._bg = t.bg, this._xAxis = t.xAxis, this._yAxis = t.yAxis, this._guides = t.guides, this._axisIntersection = t.axisIntersection, this._trade = t.trade, this._userMarkers = t.userMarkers;
|
|
1950
1974
|
}
|
|
1951
1975
|
update(e) {
|
|
1952
|
-
const t =
|
|
1976
|
+
const t = we(
|
|
1953
1977
|
{},
|
|
1954
1978
|
{
|
|
1955
1979
|
bg: this._bg,
|
|
@@ -1990,27 +2014,27 @@ class vs {
|
|
|
1990
2014
|
return this._userMarkers;
|
|
1991
2015
|
}
|
|
1992
2016
|
}
|
|
1993
|
-
class
|
|
2017
|
+
class bn {
|
|
1994
2018
|
constructor({
|
|
1995
2019
|
chartId: e,
|
|
1996
2020
|
container: t,
|
|
1997
|
-
candles:
|
|
2021
|
+
candles: s,
|
|
1998
2022
|
config: r,
|
|
1999
|
-
trade:
|
|
2023
|
+
trade: n = { entry: [], exit: [] },
|
|
2000
2024
|
userMarkers: o = [],
|
|
2001
2025
|
colorScheme: l
|
|
2002
2026
|
}) {
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
this._chartId = e, this._container = t, this._candles = new
|
|
2027
|
+
g(this, "_chartId");
|
|
2028
|
+
g(this, "_container");
|
|
2029
|
+
g(this, "_eventBus", new dn());
|
|
2030
|
+
g(this, "_candles");
|
|
2031
|
+
g(this, "_config");
|
|
2032
|
+
g(this, "_colorScheme");
|
|
2033
|
+
g(this, "_layout");
|
|
2034
|
+
g(this, "_scaleManager");
|
|
2035
|
+
g(this, "_trade");
|
|
2036
|
+
g(this, "_userMarkers");
|
|
2037
|
+
this._chartId = e, this._container = t, this._candles = new hn(s, this), this._config = new on(r), this._colorScheme = new yn(l), this._layout = new ln(t, this._config), this._scaleManager = new fn(this), this._trade = new _n(this, n), this._candles.updateMissingCandles(), this._trade.recalculate(), this._userMarkers = new mn(this, o);
|
|
2014
2038
|
}
|
|
2015
2039
|
init() {
|
|
2016
2040
|
this._eventBus.emit("init_model");
|
|
@@ -2067,18 +2091,18 @@ class ys {
|
|
|
2067
2091
|
return this._colorScheme;
|
|
2068
2092
|
}
|
|
2069
2093
|
}
|
|
2070
|
-
const
|
|
2094
|
+
const xe = window.devicePixelRatio || 2;
|
|
2071
2095
|
class R {
|
|
2072
|
-
constructor({ tag: e, className: t, id:
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
this._tag = e || "div", this._className = t || "", this._id =
|
|
2080
|
-
const
|
|
2081
|
-
this._className && (
|
|
2096
|
+
constructor({ tag: e, className: t, id: s, textContent: r }) {
|
|
2097
|
+
g(this, "_tag");
|
|
2098
|
+
g(this, "_className");
|
|
2099
|
+
g(this, "_id");
|
|
2100
|
+
g(this, "_textContent");
|
|
2101
|
+
g(this, "_node");
|
|
2102
|
+
g(this, "_absolutePosition", new DOMRect());
|
|
2103
|
+
this._tag = e || "div", this._className = t || "", this._id = s || "", this._textContent = r || "";
|
|
2104
|
+
const n = document.createElement(this._tag);
|
|
2105
|
+
this._className && (n.className = this._className), this._id && (n.id = this._id), this._textContent && (n.textContent = this._textContent), this._node = n;
|
|
2082
2106
|
}
|
|
2083
2107
|
get node() {
|
|
2084
2108
|
return this._node;
|
|
@@ -2099,24 +2123,24 @@ class R {
|
|
|
2099
2123
|
this._absolutePosition = this._node.getBoundingClientRect();
|
|
2100
2124
|
}
|
|
2101
2125
|
}
|
|
2102
|
-
class
|
|
2103
|
-
constructor({ className: t, id:
|
|
2126
|
+
class Me extends R {
|
|
2127
|
+
constructor({ className: t, id: s, width: r, height: n, isMain: o }) {
|
|
2104
2128
|
super({
|
|
2105
2129
|
tag: "canvas",
|
|
2106
2130
|
className: `${t} sc-charts-cs__canvas ${o ? "" : "sc-charts-cs__canvas-additional"}`,
|
|
2107
|
-
id:
|
|
2131
|
+
id: s
|
|
2108
2132
|
});
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
this._width = r, this._height =
|
|
2133
|
+
g(this, "_ctx");
|
|
2134
|
+
g(this, "_width");
|
|
2135
|
+
g(this, "_height");
|
|
2136
|
+
g(this, "background", null);
|
|
2137
|
+
this._width = r, this._height = n, this.updateSize({ width: r, height: n });
|
|
2114
2138
|
const l = this._node.getContext("2d");
|
|
2115
2139
|
if (!l) throw new Error("Failed to get 2D context");
|
|
2116
|
-
l.scale(
|
|
2140
|
+
l.scale(xe, xe), this._ctx = l;
|
|
2117
2141
|
}
|
|
2118
|
-
updateSize({ width: t, height:
|
|
2119
|
-
t && (this._node.width = t *
|
|
2142
|
+
updateSize({ width: t, height: s }) {
|
|
2143
|
+
t && (this._node.width = t * xe, this._node.style.width = `${t}px`, this._width = t), s && (this._node.height = s * xe, this._node.style.height = `${s}px`, this._height = s);
|
|
2120
2144
|
}
|
|
2121
2145
|
clear() {
|
|
2122
2146
|
this.background ? (this._ctx.save(), this._ctx.fillStyle = this.background, this._ctx.fillRect(0, 0, this._width, this._height), this._ctx.restore()) : this._ctx.clearRect(0, 0, this._width, this._height);
|
|
@@ -2131,24 +2155,24 @@ class Te extends R {
|
|
|
2131
2155
|
return this._height;
|
|
2132
2156
|
}
|
|
2133
2157
|
}
|
|
2134
|
-
function
|
|
2158
|
+
function Te(i) {
|
|
2135
2159
|
"@babel/helpers - typeof";
|
|
2136
|
-
return
|
|
2160
|
+
return Te = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
2137
2161
|
return typeof e;
|
|
2138
2162
|
} : function(e) {
|
|
2139
2163
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
2140
|
-
},
|
|
2164
|
+
}, Te(i);
|
|
2141
2165
|
}
|
|
2142
|
-
var
|
|
2143
|
-
function
|
|
2144
|
-
if (i = i || "", e = e || {}, i instanceof
|
|
2166
|
+
var xn = /^\s+/, wn = /\s+$/;
|
|
2167
|
+
function T(i, e) {
|
|
2168
|
+
if (i = i || "", e = e || {}, i instanceof T)
|
|
2145
2169
|
return i;
|
|
2146
|
-
if (!(this instanceof
|
|
2147
|
-
return new
|
|
2148
|
-
var t =
|
|
2170
|
+
if (!(this instanceof T))
|
|
2171
|
+
return new T(i, e);
|
|
2172
|
+
var t = Mn(i);
|
|
2149
2173
|
this._originalInput = i, this._r = t.r, this._g = t.g, this._b = t.b, this._a = t.a, this._roundA = Math.round(100 * this._a) / 100, this._format = e.format || t.format, this._gradientType = e.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = t.ok;
|
|
2150
2174
|
}
|
|
2151
|
-
|
|
2175
|
+
T.prototype = {
|
|
2152
2176
|
isDark: function() {
|
|
2153
2177
|
return this.getBrightness() < 128;
|
|
2154
2178
|
},
|
|
@@ -2172,14 +2196,14 @@ M.prototype = {
|
|
|
2172
2196
|
return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
|
|
2173
2197
|
},
|
|
2174
2198
|
getLuminance: function() {
|
|
2175
|
-
var e = this.toRgb(), t,
|
|
2176
|
-
return t = e.r / 255,
|
|
2199
|
+
var e = this.toRgb(), t, s, r, n, o, l;
|
|
2200
|
+
return t = e.r / 255, s = e.g / 255, r = e.b / 255, t <= 0.03928 ? n = t / 12.92 : n = Math.pow((t + 0.055) / 1.055, 2.4), s <= 0.03928 ? o = s / 12.92 : o = Math.pow((s + 0.055) / 1.055, 2.4), r <= 0.03928 ? l = r / 12.92 : l = Math.pow((r + 0.055) / 1.055, 2.4), 0.2126 * n + 0.7152 * o + 0.0722 * l;
|
|
2177
2201
|
},
|
|
2178
2202
|
setAlpha: function(e) {
|
|
2179
|
-
return this._a =
|
|
2203
|
+
return this._a = Yt(e), this._roundA = Math.round(100 * this._a) / 100, this;
|
|
2180
2204
|
},
|
|
2181
2205
|
toHsv: function() {
|
|
2182
|
-
var e =
|
|
2206
|
+
var e = Ht(this._r, this._g, this._b);
|
|
2183
2207
|
return {
|
|
2184
2208
|
h: e.h * 360,
|
|
2185
2209
|
s: e.s,
|
|
@@ -2188,8 +2212,8 @@ M.prototype = {
|
|
|
2188
2212
|
};
|
|
2189
2213
|
},
|
|
2190
2214
|
toHsvString: function() {
|
|
2191
|
-
var e =
|
|
2192
|
-
return this._a == 1 ? "hsv(" + t + ", " +
|
|
2215
|
+
var e = Ht(this._r, this._g, this._b), t = Math.round(e.h * 360), s = Math.round(e.s * 100), r = Math.round(e.v * 100);
|
|
2216
|
+
return this._a == 1 ? "hsv(" + t + ", " + s + "%, " + r + "%)" : "hsva(" + t + ", " + s + "%, " + r + "%, " + this._roundA + ")";
|
|
2193
2217
|
},
|
|
2194
2218
|
toHsl: function() {
|
|
2195
2219
|
var e = Nt(this._r, this._g, this._b);
|
|
@@ -2201,8 +2225,8 @@ M.prototype = {
|
|
|
2201
2225
|
};
|
|
2202
2226
|
},
|
|
2203
2227
|
toHslString: function() {
|
|
2204
|
-
var e = Nt(this._r, this._g, this._b), t = Math.round(e.h * 360),
|
|
2205
|
-
return this._a == 1 ? "hsl(" + t + ", " +
|
|
2228
|
+
var e = Nt(this._r, this._g, this._b), t = Math.round(e.h * 360), s = Math.round(e.s * 100), r = Math.round(e.l * 100);
|
|
2229
|
+
return this._a == 1 ? "hsl(" + t + ", " + s + "%, " + r + "%)" : "hsla(" + t + ", " + s + "%, " + r + "%, " + this._roundA + ")";
|
|
2206
2230
|
},
|
|
2207
2231
|
toHex: function(e) {
|
|
2208
2232
|
return It(this._r, this._g, this._b, e);
|
|
@@ -2211,7 +2235,7 @@ M.prototype = {
|
|
|
2211
2235
|
return "#" + this.toHex(e);
|
|
2212
2236
|
},
|
|
2213
2237
|
toHex8: function(e) {
|
|
2214
|
-
return
|
|
2238
|
+
return Sn(this._r, this._g, this._b, this._a, e);
|
|
2215
2239
|
},
|
|
2216
2240
|
toHex8String: function(e) {
|
|
2217
2241
|
return "#" + this.toHex8(e);
|
|
@@ -2229,102 +2253,102 @@ M.prototype = {
|
|
|
2229
2253
|
},
|
|
2230
2254
|
toPercentageRgb: function() {
|
|
2231
2255
|
return {
|
|
2232
|
-
r: Math.round(
|
|
2233
|
-
g: Math.round(
|
|
2234
|
-
b: Math.round(
|
|
2256
|
+
r: Math.round(I(this._r, 255) * 100) + "%",
|
|
2257
|
+
g: Math.round(I(this._g, 255) * 100) + "%",
|
|
2258
|
+
b: Math.round(I(this._b, 255) * 100) + "%",
|
|
2235
2259
|
a: this._a
|
|
2236
2260
|
};
|
|
2237
2261
|
},
|
|
2238
2262
|
toPercentageRgbString: function() {
|
|
2239
|
-
return this._a == 1 ? "rgb(" + Math.round(
|
|
2263
|
+
return this._a == 1 ? "rgb(" + Math.round(I(this._r, 255) * 100) + "%, " + Math.round(I(this._g, 255) * 100) + "%, " + Math.round(I(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(I(this._r, 255) * 100) + "%, " + Math.round(I(this._g, 255) * 100) + "%, " + Math.round(I(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
|
2240
2264
|
},
|
|
2241
2265
|
toName: function() {
|
|
2242
|
-
return this._a === 0 ? "transparent" : this._a < 1 ? !1 :
|
|
2266
|
+
return this._a === 0 ? "transparent" : this._a < 1 ? !1 : $n[It(this._r, this._g, this._b, !0)] || !1;
|
|
2243
2267
|
},
|
|
2244
2268
|
toFilter: function(e) {
|
|
2245
|
-
var t = "#" +
|
|
2269
|
+
var t = "#" + Rt(this._r, this._g, this._b, this._a), s = t, r = this._gradientType ? "GradientType = 1, " : "";
|
|
2246
2270
|
if (e) {
|
|
2247
|
-
var
|
|
2248
|
-
|
|
2271
|
+
var n = T(e);
|
|
2272
|
+
s = "#" + Rt(n._r, n._g, n._b, n._a);
|
|
2249
2273
|
}
|
|
2250
|
-
return "progid:DXImageTransform.Microsoft.gradient(" + r + "startColorstr=" + t + ",endColorstr=" +
|
|
2274
|
+
return "progid:DXImageTransform.Microsoft.gradient(" + r + "startColorstr=" + t + ",endColorstr=" + s + ")";
|
|
2251
2275
|
},
|
|
2252
2276
|
toString: function(e) {
|
|
2253
2277
|
var t = !!e;
|
|
2254
2278
|
e = e || this._format;
|
|
2255
|
-
var
|
|
2256
|
-
return
|
|
2279
|
+
var s = !1, r = this._a < 1 && this._a >= 0, n = !t && r && (e === "hex" || e === "hex6" || e === "hex3" || e === "hex4" || e === "hex8" || e === "name");
|
|
2280
|
+
return n ? e === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (s = this.toRgbString()), e === "prgb" && (s = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (s = this.toHexString()), e === "hex3" && (s = this.toHexString(!0)), e === "hex4" && (s = this.toHex8String(!0)), e === "hex8" && (s = this.toHex8String()), e === "name" && (s = this.toName()), e === "hsl" && (s = this.toHslString()), e === "hsv" && (s = this.toHsvString()), s || this.toHexString());
|
|
2257
2281
|
},
|
|
2258
2282
|
clone: function() {
|
|
2259
|
-
return
|
|
2283
|
+
return T(this.toString());
|
|
2260
2284
|
},
|
|
2261
2285
|
_applyModification: function(e, t) {
|
|
2262
|
-
var
|
|
2263
|
-
return this._r =
|
|
2286
|
+
var s = e.apply(null, [this].concat([].slice.call(t)));
|
|
2287
|
+
return this._r = s._r, this._g = s._g, this._b = s._b, this.setAlpha(s._a), this;
|
|
2264
2288
|
},
|
|
2265
2289
|
lighten: function() {
|
|
2266
|
-
return this._applyModification(
|
|
2290
|
+
return this._applyModification(Ln, arguments);
|
|
2267
2291
|
},
|
|
2268
2292
|
brighten: function() {
|
|
2269
|
-
return this._applyModification(
|
|
2293
|
+
return this._applyModification(Nn, arguments);
|
|
2270
2294
|
},
|
|
2271
2295
|
darken: function() {
|
|
2272
|
-
return this._applyModification(
|
|
2296
|
+
return this._applyModification(Hn, arguments);
|
|
2273
2297
|
},
|
|
2274
2298
|
desaturate: function() {
|
|
2275
|
-
return this._applyModification(
|
|
2299
|
+
return this._applyModification(kn, arguments);
|
|
2276
2300
|
},
|
|
2277
2301
|
saturate: function() {
|
|
2278
|
-
return this._applyModification(
|
|
2302
|
+
return this._applyModification(En, arguments);
|
|
2279
2303
|
},
|
|
2280
2304
|
greyscale: function() {
|
|
2281
|
-
return this._applyModification(
|
|
2305
|
+
return this._applyModification(Dn, arguments);
|
|
2282
2306
|
},
|
|
2283
2307
|
spin: function() {
|
|
2284
|
-
return this._applyModification(
|
|
2308
|
+
return this._applyModification(In, arguments);
|
|
2285
2309
|
},
|
|
2286
2310
|
_applyCombination: function(e, t) {
|
|
2287
2311
|
return e.apply(null, [this].concat([].slice.call(t)));
|
|
2288
2312
|
},
|
|
2289
2313
|
analogous: function() {
|
|
2290
|
-
return this._applyCombination(
|
|
2314
|
+
return this._applyCombination(zn, arguments);
|
|
2291
2315
|
},
|
|
2292
2316
|
complement: function() {
|
|
2293
|
-
return this._applyCombination(
|
|
2317
|
+
return this._applyCombination(Rn, arguments);
|
|
2294
2318
|
},
|
|
2295
2319
|
monochromatic: function() {
|
|
2296
|
-
return this._applyCombination(
|
|
2320
|
+
return this._applyCombination(Bn, arguments);
|
|
2297
2321
|
},
|
|
2298
2322
|
splitcomplement: function() {
|
|
2299
|
-
return this._applyCombination(
|
|
2323
|
+
return this._applyCombination(Fn, arguments);
|
|
2300
2324
|
},
|
|
2301
2325
|
// Disabled until https://github.com/bgrins/TinyColor/issues/254
|
|
2302
2326
|
// polyad: function (number) {
|
|
2303
2327
|
// return this._applyCombination(polyad, [number]);
|
|
2304
2328
|
// },
|
|
2305
2329
|
triad: function() {
|
|
2306
|
-
return this._applyCombination(
|
|
2330
|
+
return this._applyCombination(Ft, [3]);
|
|
2307
2331
|
},
|
|
2308
2332
|
tetrad: function() {
|
|
2309
|
-
return this._applyCombination(
|
|
2333
|
+
return this._applyCombination(Ft, [4]);
|
|
2310
2334
|
}
|
|
2311
2335
|
};
|
|
2312
|
-
|
|
2313
|
-
if (
|
|
2336
|
+
T.fromRatio = function(i, e) {
|
|
2337
|
+
if (Te(i) == "object") {
|
|
2314
2338
|
var t = {};
|
|
2315
|
-
for (var
|
|
2316
|
-
i.hasOwnProperty(
|
|
2339
|
+
for (var s in i)
|
|
2340
|
+
i.hasOwnProperty(s) && (s === "a" ? t[s] = i[s] : t[s] = ce(i[s]));
|
|
2317
2341
|
i = t;
|
|
2318
2342
|
}
|
|
2319
|
-
return
|
|
2343
|
+
return T(i, e);
|
|
2320
2344
|
};
|
|
2321
|
-
function
|
|
2345
|
+
function Mn(i) {
|
|
2322
2346
|
var e = {
|
|
2323
2347
|
r: 0,
|
|
2324
2348
|
g: 0,
|
|
2325
2349
|
b: 0
|
|
2326
|
-
}, t = 1,
|
|
2327
|
-
return typeof i == "string" && (i =
|
|
2350
|
+
}, t = 1, s = null, r = null, n = null, o = !1, l = !1;
|
|
2351
|
+
return typeof i == "string" && (i = jn(i)), Te(i) == "object" && (U(i.r) && U(i.g) && U(i.b) ? (e = Tn(i.r, i.g, i.b), o = !0, l = String(i.r).substr(-1) === "%" ? "prgb" : "rgb") : U(i.h) && U(i.s) && U(i.v) ? (s = ce(i.s), r = ce(i.v), e = An(i.h, s, r), o = !0, l = "hsv") : U(i.h) && U(i.s) && U(i.l) && (s = ce(i.s), n = ce(i.l), e = Cn(i.h, s, n), o = !0, l = "hsl"), i.hasOwnProperty("a") && (t = i.a)), t = Yt(t), {
|
|
2328
2352
|
ok: o,
|
|
2329
2353
|
format: i.format || l,
|
|
2330
2354
|
r: Math.min(255, Math.max(e.r, 0)),
|
|
@@ -2333,230 +2357,230 @@ function ws(i) {
|
|
|
2333
2357
|
a: t
|
|
2334
2358
|
};
|
|
2335
2359
|
}
|
|
2336
|
-
function
|
|
2360
|
+
function Tn(i, e, t) {
|
|
2337
2361
|
return {
|
|
2338
|
-
r:
|
|
2339
|
-
g:
|
|
2340
|
-
b:
|
|
2362
|
+
r: I(i, 255) * 255,
|
|
2363
|
+
g: I(e, 255) * 255,
|
|
2364
|
+
b: I(t, 255) * 255
|
|
2341
2365
|
};
|
|
2342
2366
|
}
|
|
2343
2367
|
function Nt(i, e, t) {
|
|
2344
|
-
i =
|
|
2345
|
-
var
|
|
2346
|
-
if (
|
|
2347
|
-
|
|
2368
|
+
i = I(i, 255), e = I(e, 255), t = I(t, 255);
|
|
2369
|
+
var s = Math.max(i, e, t), r = Math.min(i, e, t), n, o, l = (s + r) / 2;
|
|
2370
|
+
if (s == r)
|
|
2371
|
+
n = o = 0;
|
|
2348
2372
|
else {
|
|
2349
|
-
var
|
|
2350
|
-
switch (o = l > 0.5 ?
|
|
2373
|
+
var h = s - r;
|
|
2374
|
+
switch (o = l > 0.5 ? h / (2 - s - r) : h / (s + r), s) {
|
|
2351
2375
|
case i:
|
|
2352
|
-
|
|
2376
|
+
n = (e - t) / h + (e < t ? 6 : 0);
|
|
2353
2377
|
break;
|
|
2354
2378
|
case e:
|
|
2355
|
-
|
|
2379
|
+
n = (t - i) / h + 2;
|
|
2356
2380
|
break;
|
|
2357
2381
|
case t:
|
|
2358
|
-
|
|
2382
|
+
n = (i - e) / h + 4;
|
|
2359
2383
|
break;
|
|
2360
2384
|
}
|
|
2361
|
-
|
|
2385
|
+
n /= 6;
|
|
2362
2386
|
}
|
|
2363
2387
|
return {
|
|
2364
|
-
h:
|
|
2388
|
+
h: n,
|
|
2365
2389
|
s: o,
|
|
2366
2390
|
l
|
|
2367
2391
|
};
|
|
2368
2392
|
}
|
|
2369
|
-
function
|
|
2370
|
-
var
|
|
2371
|
-
i =
|
|
2393
|
+
function Cn(i, e, t) {
|
|
2394
|
+
var s, r, n;
|
|
2395
|
+
i = I(i, 360), e = I(e, 100), t = I(t, 100);
|
|
2372
2396
|
function o(d, u, _) {
|
|
2373
2397
|
return _ < 0 && (_ += 1), _ > 1 && (_ -= 1), _ < 1 / 6 ? d + (u - d) * 6 * _ : _ < 1 / 2 ? u : _ < 2 / 3 ? d + (u - d) * (2 / 3 - _) * 6 : d;
|
|
2374
2398
|
}
|
|
2375
2399
|
if (e === 0)
|
|
2376
|
-
|
|
2400
|
+
s = r = n = t;
|
|
2377
2401
|
else {
|
|
2378
|
-
var l = t < 0.5 ? t * (1 + e) : t + e - t * e,
|
|
2379
|
-
|
|
2402
|
+
var l = t < 0.5 ? t * (1 + e) : t + e - t * e, h = 2 * t - l;
|
|
2403
|
+
s = o(h, l, i + 1 / 3), r = o(h, l, i), n = o(h, l, i - 1 / 3);
|
|
2380
2404
|
}
|
|
2381
2405
|
return {
|
|
2382
|
-
r:
|
|
2406
|
+
r: s * 255,
|
|
2383
2407
|
g: r * 255,
|
|
2384
|
-
b:
|
|
2408
|
+
b: n * 255
|
|
2385
2409
|
};
|
|
2386
2410
|
}
|
|
2387
|
-
function
|
|
2388
|
-
i =
|
|
2389
|
-
var
|
|
2390
|
-
if (o =
|
|
2391
|
-
|
|
2411
|
+
function Ht(i, e, t) {
|
|
2412
|
+
i = I(i, 255), e = I(e, 255), t = I(t, 255);
|
|
2413
|
+
var s = Math.max(i, e, t), r = Math.min(i, e, t), n, o, l = s, h = s - r;
|
|
2414
|
+
if (o = s === 0 ? 0 : h / s, s == r)
|
|
2415
|
+
n = 0;
|
|
2392
2416
|
else {
|
|
2393
|
-
switch (
|
|
2417
|
+
switch (s) {
|
|
2394
2418
|
case i:
|
|
2395
|
-
|
|
2419
|
+
n = (e - t) / h + (e < t ? 6 : 0);
|
|
2396
2420
|
break;
|
|
2397
2421
|
case e:
|
|
2398
|
-
|
|
2422
|
+
n = (t - i) / h + 2;
|
|
2399
2423
|
break;
|
|
2400
2424
|
case t:
|
|
2401
|
-
|
|
2425
|
+
n = (i - e) / h + 4;
|
|
2402
2426
|
break;
|
|
2403
2427
|
}
|
|
2404
|
-
|
|
2428
|
+
n /= 6;
|
|
2405
2429
|
}
|
|
2406
2430
|
return {
|
|
2407
|
-
h:
|
|
2431
|
+
h: n,
|
|
2408
2432
|
s: o,
|
|
2409
2433
|
v: l
|
|
2410
2434
|
};
|
|
2411
2435
|
}
|
|
2412
|
-
function
|
|
2413
|
-
i =
|
|
2414
|
-
var
|
|
2436
|
+
function An(i, e, t) {
|
|
2437
|
+
i = I(i, 360) * 6, e = I(e, 100), t = I(t, 100);
|
|
2438
|
+
var s = Math.floor(i), r = i - s, n = t * (1 - e), o = t * (1 - r * e), l = t * (1 - (1 - r) * e), h = s % 6, d = [t, o, n, n, l, t][h], u = [l, t, t, o, n, n][h], _ = [n, n, l, t, t, o][h];
|
|
2415
2439
|
return {
|
|
2416
2440
|
r: d * 255,
|
|
2417
2441
|
g: u * 255,
|
|
2418
2442
|
b: _ * 255
|
|
2419
2443
|
};
|
|
2420
2444
|
}
|
|
2421
|
-
function It(i, e, t,
|
|
2422
|
-
var r = [
|
|
2423
|
-
return
|
|
2445
|
+
function It(i, e, t, s) {
|
|
2446
|
+
var r = [X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16))];
|
|
2447
|
+
return s && r[0].charAt(0) == r[0].charAt(1) && r[1].charAt(0) == r[1].charAt(1) && r[2].charAt(0) == r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
|
|
2424
2448
|
}
|
|
2425
|
-
function
|
|
2426
|
-
var
|
|
2427
|
-
return r &&
|
|
2449
|
+
function Sn(i, e, t, s, r) {
|
|
2450
|
+
var n = [X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16)), X(jt(s))];
|
|
2451
|
+
return r && n[0].charAt(0) == n[0].charAt(1) && n[1].charAt(0) == n[1].charAt(1) && n[2].charAt(0) == n[2].charAt(1) && n[3].charAt(0) == n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
|
|
2428
2452
|
}
|
|
2429
|
-
function
|
|
2430
|
-
var r = [
|
|
2453
|
+
function Rt(i, e, t, s) {
|
|
2454
|
+
var r = [X(jt(s)), X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16))];
|
|
2431
2455
|
return r.join("");
|
|
2432
2456
|
}
|
|
2433
|
-
|
|
2434
|
-
return !i || !e ? !1 :
|
|
2457
|
+
T.equals = function(i, e) {
|
|
2458
|
+
return !i || !e ? !1 : T(i).toRgbString() == T(e).toRgbString();
|
|
2435
2459
|
};
|
|
2436
|
-
|
|
2437
|
-
return
|
|
2460
|
+
T.random = function() {
|
|
2461
|
+
return T.fromRatio({
|
|
2438
2462
|
r: Math.random(),
|
|
2439
2463
|
g: Math.random(),
|
|
2440
2464
|
b: Math.random()
|
|
2441
2465
|
});
|
|
2442
2466
|
};
|
|
2443
|
-
function
|
|
2467
|
+
function kn(i, e) {
|
|
2444
2468
|
e = e === 0 ? 0 : e || 10;
|
|
2445
|
-
var t =
|
|
2446
|
-
return t.s -= e / 100, t.s =
|
|
2469
|
+
var t = T(i).toHsl();
|
|
2470
|
+
return t.s -= e / 100, t.s = Se(t.s), T(t);
|
|
2447
2471
|
}
|
|
2448
|
-
function
|
|
2472
|
+
function En(i, e) {
|
|
2449
2473
|
e = e === 0 ? 0 : e || 10;
|
|
2450
|
-
var t =
|
|
2451
|
-
return t.s += e / 100, t.s =
|
|
2474
|
+
var t = T(i).toHsl();
|
|
2475
|
+
return t.s += e / 100, t.s = Se(t.s), T(t);
|
|
2452
2476
|
}
|
|
2453
|
-
function
|
|
2454
|
-
return
|
|
2477
|
+
function Dn(i) {
|
|
2478
|
+
return T(i).desaturate(100);
|
|
2455
2479
|
}
|
|
2456
|
-
function
|
|
2480
|
+
function Ln(i, e) {
|
|
2457
2481
|
e = e === 0 ? 0 : e || 10;
|
|
2458
|
-
var t =
|
|
2459
|
-
return t.l += e / 100, t.l =
|
|
2482
|
+
var t = T(i).toHsl();
|
|
2483
|
+
return t.l += e / 100, t.l = Se(t.l), T(t);
|
|
2460
2484
|
}
|
|
2461
|
-
function
|
|
2485
|
+
function Nn(i, e) {
|
|
2462
2486
|
e = e === 0 ? 0 : e || 10;
|
|
2463
|
-
var t =
|
|
2464
|
-
return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))),
|
|
2487
|
+
var t = T(i).toRgb();
|
|
2488
|
+
return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), T(t);
|
|
2465
2489
|
}
|
|
2466
|
-
function
|
|
2490
|
+
function Hn(i, e) {
|
|
2467
2491
|
e = e === 0 ? 0 : e || 10;
|
|
2468
|
-
var t =
|
|
2469
|
-
return t.l -= e / 100, t.l =
|
|
2492
|
+
var t = T(i).toHsl();
|
|
2493
|
+
return t.l -= e / 100, t.l = Se(t.l), T(t);
|
|
2470
2494
|
}
|
|
2471
|
-
function
|
|
2472
|
-
var t =
|
|
2473
|
-
return t.h =
|
|
2495
|
+
function In(i, e) {
|
|
2496
|
+
var t = T(i).toHsl(), s = (t.h + e) % 360;
|
|
2497
|
+
return t.h = s < 0 ? 360 + s : s, T(t);
|
|
2474
2498
|
}
|
|
2475
|
-
function
|
|
2476
|
-
var e =
|
|
2477
|
-
return e.h = (e.h + 180) % 360,
|
|
2499
|
+
function Rn(i) {
|
|
2500
|
+
var e = T(i).toHsl();
|
|
2501
|
+
return e.h = (e.h + 180) % 360, T(e);
|
|
2478
2502
|
}
|
|
2479
|
-
function
|
|
2503
|
+
function Ft(i, e) {
|
|
2480
2504
|
if (isNaN(e) || e <= 0)
|
|
2481
2505
|
throw new Error("Argument to polyad must be a positive number");
|
|
2482
|
-
for (var t =
|
|
2483
|
-
|
|
2484
|
-
h: (t.h +
|
|
2506
|
+
for (var t = T(i).toHsl(), s = [T(i)], r = 360 / e, n = 1; n < e; n++)
|
|
2507
|
+
s.push(T({
|
|
2508
|
+
h: (t.h + n * r) % 360,
|
|
2485
2509
|
s: t.s,
|
|
2486
2510
|
l: t.l
|
|
2487
2511
|
}));
|
|
2488
|
-
return
|
|
2512
|
+
return s;
|
|
2489
2513
|
}
|
|
2490
|
-
function
|
|
2491
|
-
var e =
|
|
2492
|
-
return [
|
|
2514
|
+
function Fn(i) {
|
|
2515
|
+
var e = T(i).toHsl(), t = e.h;
|
|
2516
|
+
return [T(i), T({
|
|
2493
2517
|
h: (t + 72) % 360,
|
|
2494
2518
|
s: e.s,
|
|
2495
2519
|
l: e.l
|
|
2496
|
-
}),
|
|
2520
|
+
}), T({
|
|
2497
2521
|
h: (t + 216) % 360,
|
|
2498
2522
|
s: e.s,
|
|
2499
2523
|
l: e.l
|
|
2500
2524
|
})];
|
|
2501
2525
|
}
|
|
2502
|
-
function
|
|
2526
|
+
function zn(i, e, t) {
|
|
2503
2527
|
e = e || 6, t = t || 30;
|
|
2504
|
-
var
|
|
2505
|
-
for (
|
|
2506
|
-
|
|
2507
|
-
return
|
|
2528
|
+
var s = T(i).toHsl(), r = 360 / t, n = [T(i)];
|
|
2529
|
+
for (s.h = (s.h - (r * e >> 1) + 720) % 360; --e; )
|
|
2530
|
+
s.h = (s.h + r) % 360, n.push(T(s));
|
|
2531
|
+
return n;
|
|
2508
2532
|
}
|
|
2509
|
-
function
|
|
2533
|
+
function Bn(i, e) {
|
|
2510
2534
|
e = e || 6;
|
|
2511
|
-
for (var t =
|
|
2512
|
-
o.push(
|
|
2513
|
-
h:
|
|
2535
|
+
for (var t = T(i).toHsv(), s = t.h, r = t.s, n = t.v, o = [], l = 1 / e; e--; )
|
|
2536
|
+
o.push(T({
|
|
2537
|
+
h: s,
|
|
2514
2538
|
s: r,
|
|
2515
|
-
v:
|
|
2516
|
-
})),
|
|
2539
|
+
v: n
|
|
2540
|
+
})), n = (n + l) % 1;
|
|
2517
2541
|
return o;
|
|
2518
2542
|
}
|
|
2519
|
-
|
|
2543
|
+
T.mix = function(i, e, t) {
|
|
2520
2544
|
t = t === 0 ? 0 : t || 50;
|
|
2521
|
-
var
|
|
2522
|
-
r: (r.r -
|
|
2523
|
-
g: (r.g -
|
|
2524
|
-
b: (r.b -
|
|
2525
|
-
a: (r.a -
|
|
2545
|
+
var s = T(i).toRgb(), r = T(e).toRgb(), n = t / 100, o = {
|
|
2546
|
+
r: (r.r - s.r) * n + s.r,
|
|
2547
|
+
g: (r.g - s.g) * n + s.g,
|
|
2548
|
+
b: (r.b - s.b) * n + s.b,
|
|
2549
|
+
a: (r.a - s.a) * n + s.a
|
|
2526
2550
|
};
|
|
2527
|
-
return
|
|
2551
|
+
return T(o);
|
|
2528
2552
|
};
|
|
2529
|
-
|
|
2530
|
-
var t =
|
|
2531
|
-
return (Math.max(t.getLuminance(),
|
|
2553
|
+
T.readability = function(i, e) {
|
|
2554
|
+
var t = T(i), s = T(e);
|
|
2555
|
+
return (Math.max(t.getLuminance(), s.getLuminance()) + 0.05) / (Math.min(t.getLuminance(), s.getLuminance()) + 0.05);
|
|
2532
2556
|
};
|
|
2533
|
-
|
|
2534
|
-
var
|
|
2535
|
-
switch (
|
|
2557
|
+
T.isReadable = function(i, e, t) {
|
|
2558
|
+
var s = T.readability(i, e), r, n;
|
|
2559
|
+
switch (n = !1, r = Xn(t), r.level + r.size) {
|
|
2536
2560
|
case "AAsmall":
|
|
2537
2561
|
case "AAAlarge":
|
|
2538
|
-
|
|
2562
|
+
n = s >= 4.5;
|
|
2539
2563
|
break;
|
|
2540
2564
|
case "AAlarge":
|
|
2541
|
-
|
|
2565
|
+
n = s >= 3;
|
|
2542
2566
|
break;
|
|
2543
2567
|
case "AAAsmall":
|
|
2544
|
-
|
|
2568
|
+
n = s >= 7;
|
|
2545
2569
|
break;
|
|
2546
2570
|
}
|
|
2547
|
-
return
|
|
2571
|
+
return n;
|
|
2548
2572
|
};
|
|
2549
|
-
|
|
2550
|
-
var
|
|
2551
|
-
t = t || {}, o = t.includeFallbackColors, l = t.level,
|
|
2573
|
+
T.mostReadable = function(i, e, t) {
|
|
2574
|
+
var s = null, r = 0, n, o, l, h;
|
|
2575
|
+
t = t || {}, o = t.includeFallbackColors, l = t.level, h = t.size;
|
|
2552
2576
|
for (var d = 0; d < e.length; d++)
|
|
2553
|
-
|
|
2554
|
-
return
|
|
2577
|
+
n = T.readability(i, e[d]), n > r && (r = n, s = T(e[d]));
|
|
2578
|
+
return T.isReadable(i, s, {
|
|
2555
2579
|
level: l,
|
|
2556
|
-
size:
|
|
2557
|
-
}) || !o ?
|
|
2580
|
+
size: h
|
|
2581
|
+
}) || !o ? s : (t.includeFallbackColors = !1, T.mostReadable(i, ["#fff", "#000"], t));
|
|
2558
2582
|
};
|
|
2559
|
-
var Ue =
|
|
2583
|
+
var Ue = T.names = {
|
|
2560
2584
|
aliceblue: "f0f8ff",
|
|
2561
2585
|
antiquewhite: "faebd7",
|
|
2562
2586
|
aqua: "0ff",
|
|
@@ -2706,54 +2730,54 @@ var Ue = M.names = {
|
|
|
2706
2730
|
whitesmoke: "f5f5f5",
|
|
2707
2731
|
yellow: "ff0",
|
|
2708
2732
|
yellowgreen: "9acd32"
|
|
2709
|
-
},
|
|
2710
|
-
function
|
|
2733
|
+
}, $n = T.hexNames = Pn(Ue);
|
|
2734
|
+
function Pn(i) {
|
|
2711
2735
|
var e = {};
|
|
2712
2736
|
for (var t in i)
|
|
2713
2737
|
i.hasOwnProperty(t) && (e[i[t]] = t);
|
|
2714
2738
|
return e;
|
|
2715
2739
|
}
|
|
2716
|
-
function
|
|
2740
|
+
function Yt(i) {
|
|
2717
2741
|
return i = parseFloat(i), (isNaN(i) || i < 0 || i > 1) && (i = 1), i;
|
|
2718
2742
|
}
|
|
2719
|
-
function
|
|
2720
|
-
|
|
2721
|
-
var t =
|
|
2743
|
+
function I(i, e) {
|
|
2744
|
+
On(i) && (i = "100%");
|
|
2745
|
+
var t = Yn(i);
|
|
2722
2746
|
return i = Math.min(e, Math.max(0, parseFloat(i))), t && (i = parseInt(i * e, 10) / 100), Math.abs(i - e) < 1e-6 ? 1 : i % e / parseFloat(e);
|
|
2723
2747
|
}
|
|
2724
|
-
function
|
|
2748
|
+
function Se(i) {
|
|
2725
2749
|
return Math.min(1, Math.max(0, i));
|
|
2726
2750
|
}
|
|
2727
|
-
function
|
|
2751
|
+
function B(i) {
|
|
2728
2752
|
return parseInt(i, 16);
|
|
2729
2753
|
}
|
|
2730
|
-
function
|
|
2754
|
+
function On(i) {
|
|
2731
2755
|
return typeof i == "string" && i.indexOf(".") != -1 && parseFloat(i) === 1;
|
|
2732
2756
|
}
|
|
2733
|
-
function
|
|
2757
|
+
function Yn(i) {
|
|
2734
2758
|
return typeof i == "string" && i.indexOf("%") != -1;
|
|
2735
2759
|
}
|
|
2736
|
-
function
|
|
2760
|
+
function X(i) {
|
|
2737
2761
|
return i.length == 1 ? "0" + i : "" + i;
|
|
2738
2762
|
}
|
|
2739
2763
|
function ce(i) {
|
|
2740
2764
|
return i <= 1 && (i = i * 100 + "%"), i;
|
|
2741
2765
|
}
|
|
2742
|
-
function
|
|
2766
|
+
function jt(i) {
|
|
2743
2767
|
return Math.round(parseFloat(i) * 255).toString(16);
|
|
2744
2768
|
}
|
|
2745
2769
|
function zt(i) {
|
|
2746
|
-
return
|
|
2770
|
+
return B(i) / 255;
|
|
2747
2771
|
}
|
|
2748
|
-
var
|
|
2749
|
-
var i = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + i + ")",
|
|
2772
|
+
var Y = function() {
|
|
2773
|
+
var i = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + i + ")", s = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?", r = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?";
|
|
2750
2774
|
return {
|
|
2751
2775
|
CSS_UNIT: new RegExp(t),
|
|
2752
|
-
rgb: new RegExp("rgb" +
|
|
2776
|
+
rgb: new RegExp("rgb" + s),
|
|
2753
2777
|
rgba: new RegExp("rgba" + r),
|
|
2754
|
-
hsl: new RegExp("hsl" +
|
|
2778
|
+
hsl: new RegExp("hsl" + s),
|
|
2755
2779
|
hsla: new RegExp("hsla" + r),
|
|
2756
|
-
hsv: new RegExp("hsv" +
|
|
2780
|
+
hsv: new RegExp("hsv" + s),
|
|
2757
2781
|
hsva: new RegExp("hsva" + r),
|
|
2758
2782
|
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
2759
2783
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
@@ -2761,11 +2785,11 @@ var H = function() {
|
|
|
2761
2785
|
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
2762
2786
|
};
|
|
2763
2787
|
}();
|
|
2764
|
-
function
|
|
2765
|
-
return !!
|
|
2788
|
+
function U(i) {
|
|
2789
|
+
return !!Y.CSS_UNIT.exec(i);
|
|
2766
2790
|
}
|
|
2767
|
-
function
|
|
2768
|
-
i = i.replace(
|
|
2791
|
+
function jn(i) {
|
|
2792
|
+
i = i.replace(xn, "").replace(wn, "").toLowerCase();
|
|
2769
2793
|
var e = !1;
|
|
2770
2794
|
if (Ue[i])
|
|
2771
2795
|
i = Ue[i], e = !0;
|
|
@@ -2778,58 +2802,58 @@ function js(i) {
|
|
|
2778
2802
|
format: "name"
|
|
2779
2803
|
};
|
|
2780
2804
|
var t;
|
|
2781
|
-
return (t =
|
|
2805
|
+
return (t = Y.rgb.exec(i)) ? {
|
|
2782
2806
|
r: t[1],
|
|
2783
2807
|
g: t[2],
|
|
2784
2808
|
b: t[3]
|
|
2785
|
-
} : (t =
|
|
2809
|
+
} : (t = Y.rgba.exec(i)) ? {
|
|
2786
2810
|
r: t[1],
|
|
2787
2811
|
g: t[2],
|
|
2788
2812
|
b: t[3],
|
|
2789
2813
|
a: t[4]
|
|
2790
|
-
} : (t =
|
|
2814
|
+
} : (t = Y.hsl.exec(i)) ? {
|
|
2791
2815
|
h: t[1],
|
|
2792
2816
|
s: t[2],
|
|
2793
2817
|
l: t[3]
|
|
2794
|
-
} : (t =
|
|
2818
|
+
} : (t = Y.hsla.exec(i)) ? {
|
|
2795
2819
|
h: t[1],
|
|
2796
2820
|
s: t[2],
|
|
2797
2821
|
l: t[3],
|
|
2798
2822
|
a: t[4]
|
|
2799
|
-
} : (t =
|
|
2823
|
+
} : (t = Y.hsv.exec(i)) ? {
|
|
2800
2824
|
h: t[1],
|
|
2801
2825
|
s: t[2],
|
|
2802
2826
|
v: t[3]
|
|
2803
|
-
} : (t =
|
|
2827
|
+
} : (t = Y.hsva.exec(i)) ? {
|
|
2804
2828
|
h: t[1],
|
|
2805
2829
|
s: t[2],
|
|
2806
2830
|
v: t[3],
|
|
2807
2831
|
a: t[4]
|
|
2808
|
-
} : (t =
|
|
2809
|
-
r:
|
|
2810
|
-
g:
|
|
2811
|
-
b:
|
|
2832
|
+
} : (t = Y.hex8.exec(i)) ? {
|
|
2833
|
+
r: B(t[1]),
|
|
2834
|
+
g: B(t[2]),
|
|
2835
|
+
b: B(t[3]),
|
|
2812
2836
|
a: zt(t[4]),
|
|
2813
2837
|
format: e ? "name" : "hex8"
|
|
2814
|
-
} : (t =
|
|
2815
|
-
r:
|
|
2816
|
-
g:
|
|
2817
|
-
b:
|
|
2838
|
+
} : (t = Y.hex6.exec(i)) ? {
|
|
2839
|
+
r: B(t[1]),
|
|
2840
|
+
g: B(t[2]),
|
|
2841
|
+
b: B(t[3]),
|
|
2818
2842
|
format: e ? "name" : "hex"
|
|
2819
|
-
} : (t =
|
|
2820
|
-
r:
|
|
2821
|
-
g:
|
|
2822
|
-
b:
|
|
2843
|
+
} : (t = Y.hex4.exec(i)) ? {
|
|
2844
|
+
r: B(t[1] + "" + t[1]),
|
|
2845
|
+
g: B(t[2] + "" + t[2]),
|
|
2846
|
+
b: B(t[3] + "" + t[3]),
|
|
2823
2847
|
a: zt(t[4] + "" + t[4]),
|
|
2824
2848
|
format: e ? "name" : "hex8"
|
|
2825
|
-
} : (t =
|
|
2826
|
-
r:
|
|
2827
|
-
g:
|
|
2828
|
-
b:
|
|
2849
|
+
} : (t = Y.hex3.exec(i)) ? {
|
|
2850
|
+
r: B(t[1] + "" + t[1]),
|
|
2851
|
+
g: B(t[2] + "" + t[2]),
|
|
2852
|
+
b: B(t[3] + "" + t[3]),
|
|
2829
2853
|
format: e ? "name" : "hex"
|
|
2830
2854
|
} : !1;
|
|
2831
2855
|
}
|
|
2832
|
-
function
|
|
2856
|
+
function Xn(i) {
|
|
2833
2857
|
var e, t;
|
|
2834
2858
|
return i = i || {
|
|
2835
2859
|
level: "AA",
|
|
@@ -2839,17 +2863,17 @@ function Ys(i) {
|
|
|
2839
2863
|
size: t
|
|
2840
2864
|
};
|
|
2841
2865
|
}
|
|
2842
|
-
function
|
|
2843
|
-
const
|
|
2844
|
-
i.fillStyle = y(
|
|
2845
|
-
const b = Math.min(_,
|
|
2846
|
-
i.fillRect(
|
|
2847
|
-
}
|
|
2848
|
-
function
|
|
2849
|
-
const { strokeWidth: t, style:
|
|
2850
|
-
e.candles.missingData.forEach((l,
|
|
2851
|
-
const d = r.noDataFill[
|
|
2852
|
-
|
|
2866
|
+
function Xt(i, e, t, { fillColor: s, strokeColor: r, candleWidth: n, strokeWidth: o }, l) {
|
|
2867
|
+
const h = (M) => t.scales.x.map(M), d = (M) => t.scales.y.map(M), u = h(e.open_time), _ = d(e.open), m = d(e.close), p = t.trade.timeRange.includes(e.open_time.getTime()), v = t.trade.timeRange.length && !p, y = (M) => v ? T.mix(M, l).toString() : M;
|
|
2868
|
+
i.fillStyle = y(s), i.strokeStyle = y(r), i.lineWidth = o, i.beginPath(), i.moveTo(u, d(e.high)), i.lineTo(u, d(e.low)), i.stroke();
|
|
2869
|
+
const b = Math.min(_, m), x = Math.abs(m - _), C = u - n / 2;
|
|
2870
|
+
i.fillRect(C, b, n, x), i.strokeRect(C, b, n, x);
|
|
2871
|
+
}
|
|
2872
|
+
function Wn(i, e) {
|
|
2873
|
+
const { strokeWidth: t, style: s } = e.config.candles, { candles: r, bg: n } = e.colorScheme, o = e.config.candles.baseWidth * e.scales.factorX;
|
|
2874
|
+
e.candles.missingData.forEach((l, h) => {
|
|
2875
|
+
const d = r.noDataFill[h % r.noDataFill.length], u = s === "filled" ? d : r.noDataStroke;
|
|
2876
|
+
Xt(
|
|
2853
2877
|
i,
|
|
2854
2878
|
l,
|
|
2855
2879
|
e,
|
|
@@ -2859,21 +2883,21 @@ function Ws(i, e) {
|
|
|
2859
2883
|
candleWidth: o,
|
|
2860
2884
|
strokeWidth: t
|
|
2861
2885
|
},
|
|
2862
|
-
|
|
2886
|
+
n
|
|
2863
2887
|
);
|
|
2864
2888
|
});
|
|
2865
2889
|
}
|
|
2866
|
-
function
|
|
2867
|
-
const { strokeWidth: t, style:
|
|
2890
|
+
function Gn(i, e) {
|
|
2891
|
+
const { strokeWidth: t, style: s } = e.config.candles, r = e.config.candles.baseWidth * e.scales.factorX, { candles: n, bg: o } = e.colorScheme;
|
|
2868
2892
|
e.candles.preparedData.forEach((l) => {
|
|
2869
|
-
const
|
|
2870
|
-
|
|
2893
|
+
const h = l.close >= l.open ? "up" : "down", d = h === "up" ? n.risingFill : n.fallingFill, u = h === "up" ? n.risingStroke : n.fallingStroke;
|
|
2894
|
+
Xt(
|
|
2871
2895
|
i,
|
|
2872
2896
|
l,
|
|
2873
2897
|
e,
|
|
2874
2898
|
{
|
|
2875
2899
|
fillColor: d,
|
|
2876
|
-
strokeColor:
|
|
2900
|
+
strokeColor: s === "filled" ? d : u,
|
|
2877
2901
|
candleWidth: r,
|
|
2878
2902
|
strokeWidth: t
|
|
2879
2903
|
},
|
|
@@ -2881,65 +2905,65 @@ function Xs(i, e) {
|
|
|
2881
2905
|
);
|
|
2882
2906
|
});
|
|
2883
2907
|
}
|
|
2884
|
-
class
|
|
2908
|
+
class Un {
|
|
2885
2909
|
static renderAll(e, t) {
|
|
2886
|
-
|
|
2910
|
+
Wn(e, t), Gn(e, t);
|
|
2887
2911
|
}
|
|
2888
2912
|
}
|
|
2889
|
-
const
|
|
2890
|
-
function
|
|
2913
|
+
const Bt = 10;
|
|
2914
|
+
function Zn(i, e) {
|
|
2891
2915
|
const {
|
|
2892
2916
|
layout: { xAxis: t },
|
|
2893
|
-
colorScheme: { xAxis:
|
|
2917
|
+
colorScheme: { xAxis: s },
|
|
2894
2918
|
config: { xAxis: r },
|
|
2895
|
-
scales:
|
|
2896
|
-
} = e, o =
|
|
2897
|
-
const d =
|
|
2898
|
-
return /AM|PM/.test(d) ? k.timeFormat("%H:%M")(
|
|
2919
|
+
scales: n
|
|
2920
|
+
} = e, o = n.x.ticks(Bt), l = (h) => {
|
|
2921
|
+
const d = n.x.tickFormat(Bt)(h);
|
|
2922
|
+
return /AM|PM/.test(d) ? k.timeFormat("%H:%M")(h) : d;
|
|
2899
2923
|
};
|
|
2900
|
-
i.save(), i.fillStyle =
|
|
2901
|
-
const d =
|
|
2924
|
+
i.save(), i.fillStyle = s.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = s.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((h) => {
|
|
2925
|
+
const d = n.x.map(h), u = l(h);
|
|
2902
2926
|
i.fillText(u, d, t.y + t.height / 2);
|
|
2903
2927
|
});
|
|
2904
2928
|
}
|
|
2905
|
-
function
|
|
2929
|
+
function Vn(i, e) {
|
|
2906
2930
|
const {
|
|
2907
2931
|
layout: { yAxis: t },
|
|
2908
|
-
colorScheme: { yAxis:
|
|
2932
|
+
colorScheme: { yAxis: s },
|
|
2909
2933
|
config: { yAxis: r },
|
|
2910
|
-
scales:
|
|
2911
|
-
} = e, o =
|
|
2912
|
-
i.save(), i.fillStyle =
|
|
2913
|
-
const d =
|
|
2934
|
+
scales: n
|
|
2935
|
+
} = e, o = n.y.ticks(6), l = n.y.tickFormat(6);
|
|
2936
|
+
i.save(), i.fillStyle = s.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = s.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((h) => {
|
|
2937
|
+
const d = n.y.map(h), u = l(h);
|
|
2914
2938
|
i.fillText(u, t.x + t.width / 2, d);
|
|
2915
2939
|
});
|
|
2916
2940
|
}
|
|
2917
|
-
const
|
|
2941
|
+
const Jn = (i, e) => {
|
|
2918
2942
|
const {
|
|
2919
2943
|
layout: { axisIntersection: t },
|
|
2920
|
-
colorScheme:
|
|
2944
|
+
colorScheme: s
|
|
2921
2945
|
} = e;
|
|
2922
|
-
i.save(), i.fillStyle =
|
|
2946
|
+
i.save(), i.fillStyle = s.axisIntersection, i.fillRect(
|
|
2923
2947
|
t.x,
|
|
2924
2948
|
t.y,
|
|
2925
2949
|
t.width,
|
|
2926
2950
|
t.height
|
|
2927
2951
|
), i.restore();
|
|
2928
2952
|
};
|
|
2929
|
-
class
|
|
2953
|
+
class Ge {
|
|
2930
2954
|
static xAxis(e, t) {
|
|
2931
|
-
|
|
2955
|
+
Zn(e, t);
|
|
2932
2956
|
}
|
|
2933
2957
|
static yAxis(e, t) {
|
|
2934
|
-
|
|
2958
|
+
Vn(e, t);
|
|
2935
2959
|
}
|
|
2936
2960
|
static intersection(e, t) {
|
|
2937
|
-
|
|
2961
|
+
Jn(e, t);
|
|
2938
2962
|
}
|
|
2939
2963
|
}
|
|
2940
|
-
class
|
|
2964
|
+
class Qn {
|
|
2941
2965
|
constructor(e) {
|
|
2942
|
-
|
|
2966
|
+
g(this, "_target");
|
|
2943
2967
|
this._target = e;
|
|
2944
2968
|
}
|
|
2945
2969
|
mousemove(e) {
|
|
@@ -2957,95 +2981,98 @@ class Js {
|
|
|
2957
2981
|
wheel(e) {
|
|
2958
2982
|
this._target.addEventListener("wheel", e);
|
|
2959
2983
|
}
|
|
2984
|
+
dblclick(e) {
|
|
2985
|
+
this._target.addEventListener("dblclick", e);
|
|
2986
|
+
}
|
|
2960
2987
|
}
|
|
2961
2988
|
class j {
|
|
2962
|
-
static line(e, { lineColor: t, type:
|
|
2963
|
-
e.save(), e.strokeStyle = t || "#777777", e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(r,
|
|
2989
|
+
static line(e, { lineColor: t, type: s, x: r, y: n, lineLength: o }) {
|
|
2990
|
+
e.save(), e.strokeStyle = t || "#777777", e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(r, n), e.lineTo(r + (s === "h" ? o : 0), n + (s === "v" ? o : 0)), e.stroke(), e.restore();
|
|
2964
2991
|
}
|
|
2965
2992
|
static _basicLabel(e, {
|
|
2966
2993
|
text: t,
|
|
2967
|
-
mainColor:
|
|
2994
|
+
mainColor: s,
|
|
2968
2995
|
textColor: r,
|
|
2969
|
-
position:
|
|
2996
|
+
position: n
|
|
2970
2997
|
}) {
|
|
2971
|
-
e.textContent = t, e.style.backgroundColor =
|
|
2998
|
+
e.textContent = t, e.style.backgroundColor = s ?? "#777777", e.style.color = r ?? "#ffffff", e.style[n] = "0px";
|
|
2972
2999
|
}
|
|
2973
|
-
static label_h(e, { text: t, y:
|
|
2974
|
-
j._basicLabel(e, { text: t, mainColor: r, textColor:
|
|
3000
|
+
static label_h(e, { text: t, y: s, mainColor: r, textColor: n, position: o }) {
|
|
3001
|
+
j._basicLabel(e, { text: t, mainColor: r, textColor: n, position: o }), e.style.top = s + "px", e.style.transform = "translateY(-50%)";
|
|
2975
3002
|
}
|
|
2976
|
-
static label_v(e, { text: t, x:
|
|
2977
|
-
j._basicLabel(e, { text: t, mainColor: r, textColor:
|
|
3003
|
+
static label_v(e, { text: t, x: s, mainColor: r, textColor: n, position: o }) {
|
|
3004
|
+
j._basicLabel(e, { text: t, mainColor: r, textColor: n, position: o }), e.style.left = s + "px", e.style.transform = "translateX(-50%)";
|
|
2978
3005
|
}
|
|
2979
3006
|
static horizontalMarker({
|
|
2980
3007
|
node: e,
|
|
2981
3008
|
ctx: t,
|
|
2982
|
-
x:
|
|
3009
|
+
x: s,
|
|
2983
3010
|
y: r,
|
|
2984
|
-
lineLength:
|
|
3011
|
+
lineLength: n,
|
|
2985
3012
|
text: o,
|
|
2986
3013
|
textColor: l,
|
|
2987
|
-
mainColor:
|
|
3014
|
+
mainColor: h,
|
|
2988
3015
|
lineColor: d,
|
|
2989
3016
|
position: u
|
|
2990
3017
|
}) {
|
|
2991
3018
|
j.line(t, {
|
|
2992
3019
|
type: "h",
|
|
2993
|
-
x:
|
|
3020
|
+
x: s,
|
|
2994
3021
|
y: r,
|
|
2995
|
-
lineLength:
|
|
3022
|
+
lineLength: n,
|
|
2996
3023
|
lineColor: d
|
|
2997
3024
|
}), j.label_h(e, {
|
|
2998
3025
|
text: o,
|
|
2999
3026
|
y: r,
|
|
3000
3027
|
textColor: l,
|
|
3001
|
-
mainColor:
|
|
3028
|
+
mainColor: h,
|
|
3002
3029
|
position: u
|
|
3003
3030
|
});
|
|
3004
3031
|
}
|
|
3005
3032
|
static verticalMarker({
|
|
3006
3033
|
node: e,
|
|
3007
3034
|
ctx: t,
|
|
3008
|
-
x:
|
|
3035
|
+
x: s,
|
|
3009
3036
|
y: r,
|
|
3010
|
-
lineLength:
|
|
3037
|
+
lineLength: n,
|
|
3011
3038
|
text: o,
|
|
3012
3039
|
textColor: l,
|
|
3013
|
-
mainColor:
|
|
3040
|
+
mainColor: h,
|
|
3014
3041
|
lineColor: d,
|
|
3015
3042
|
position: u
|
|
3016
3043
|
}) {
|
|
3017
3044
|
j.line(t, {
|
|
3018
3045
|
type: "v",
|
|
3019
|
-
x:
|
|
3046
|
+
x: s,
|
|
3020
3047
|
y: r,
|
|
3021
|
-
lineLength:
|
|
3048
|
+
lineLength: n,
|
|
3022
3049
|
lineColor: d
|
|
3023
3050
|
}), j.label_v(e, {
|
|
3024
3051
|
text: o,
|
|
3025
|
-
x:
|
|
3052
|
+
x: s,
|
|
3026
3053
|
textColor: l,
|
|
3027
|
-
mainColor:
|
|
3054
|
+
mainColor: h,
|
|
3028
3055
|
position: u
|
|
3029
3056
|
});
|
|
3030
3057
|
}
|
|
3031
3058
|
}
|
|
3032
|
-
class
|
|
3059
|
+
class qn {
|
|
3033
3060
|
constructor(e, t) {
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3061
|
+
g(this, "_canvas");
|
|
3062
|
+
g(this, "_parent");
|
|
3063
|
+
g(this, "_horizontalMarker");
|
|
3064
|
+
g(this, "_verticalMarker");
|
|
3038
3065
|
this._canvas = t;
|
|
3039
|
-
const
|
|
3040
|
-
this._parent =
|
|
3066
|
+
const s = new R({ tag: "div", className: "sc-charts-cs__guide-markers" });
|
|
3067
|
+
this._parent = s;
|
|
3041
3068
|
const r = new R({
|
|
3042
3069
|
tag: "div",
|
|
3043
3070
|
className: "sc-charts-cs__guide-marker sc-charts-cs__guide-marker-h"
|
|
3044
|
-
}),
|
|
3071
|
+
}), n = new R({
|
|
3045
3072
|
tag: "div",
|
|
3046
3073
|
className: "sc-charts-cs__guide-marker sc-charts-cs__guide-marker-v"
|
|
3047
3074
|
});
|
|
3048
|
-
this._horizontalMarker = r, this._verticalMarker =
|
|
3075
|
+
this._horizontalMarker = r, this._verticalMarker = n, s.append(r.node), s.append(n.node), e.append(s.node), this.hide();
|
|
3049
3076
|
}
|
|
3050
3077
|
update(e) {
|
|
3051
3078
|
this._verticalMarker.node.style.display = e.isShowX ? "flex" : "none", this._horizontalMarker.node.style.display = e.isShowY ? "flex" : "none";
|
|
@@ -3056,11 +3083,11 @@ class Qs {
|
|
|
3056
3083
|
show() {
|
|
3057
3084
|
this._verticalMarker.node.style.display = "flex", this._horizontalMarker.node.style.display = "flex";
|
|
3058
3085
|
}
|
|
3059
|
-
render(e, { x: t, y:
|
|
3086
|
+
render(e, { x: t, y: s }) {
|
|
3060
3087
|
this._canvas.clear();
|
|
3061
3088
|
const {
|
|
3062
|
-
layout: { area: r, chart:
|
|
3063
|
-
config: { guides: o, yAxis: l, xAxis:
|
|
3089
|
+
layout: { area: r, chart: n },
|
|
3090
|
+
config: { guides: o, yAxis: l, xAxis: h },
|
|
3064
3091
|
colorScheme: {
|
|
3065
3092
|
guides: { horizontalMarker: d, verticalMarker: u }
|
|
3066
3093
|
}
|
|
@@ -3069,9 +3096,9 @@ class Qs {
|
|
|
3069
3096
|
ctx: this._canvas.ctx,
|
|
3070
3097
|
node: this._horizontalMarker.node,
|
|
3071
3098
|
x: r.left,
|
|
3072
|
-
y:
|
|
3073
|
-
lineLength:
|
|
3074
|
-
text: e.scales.y.invert(
|
|
3099
|
+
y: s,
|
|
3100
|
+
lineLength: n.width,
|
|
3101
|
+
text: e.scales.y.invert(s).toFixed(2),
|
|
3075
3102
|
position: l.position,
|
|
3076
3103
|
mainColor: d.main,
|
|
3077
3104
|
lineColor: d.line,
|
|
@@ -3080,10 +3107,10 @@ class Qs {
|
|
|
3080
3107
|
ctx: this._canvas.ctx,
|
|
3081
3108
|
node: this._verticalMarker.node,
|
|
3082
3109
|
text: k.timeFormat("%a %d, %b %y %H:%M")(e.scales.x.invert(t)),
|
|
3083
|
-
position:
|
|
3110
|
+
position: h.position,
|
|
3084
3111
|
x: t,
|
|
3085
3112
|
y: r.top,
|
|
3086
|
-
lineLength:
|
|
3113
|
+
lineLength: n.height,
|
|
3087
3114
|
mainColor: u.main,
|
|
3088
3115
|
lineColor: u.line,
|
|
3089
3116
|
textColor: u.text
|
|
@@ -3093,148 +3120,124 @@ class Qs {
|
|
|
3093
3120
|
this._canvas.clear(), this._parent.remove();
|
|
3094
3121
|
}
|
|
3095
3122
|
}
|
|
3096
|
-
function
|
|
3123
|
+
function Ce(i) {
|
|
3097
3124
|
return i * 0.1875;
|
|
3098
3125
|
}
|
|
3099
|
-
const
|
|
3100
|
-
const _ = o / 16,
|
|
3126
|
+
const Kn = (i, { mainColor: e, textColor: t, symbol: s, x: r, y: n, size: o, fontSize: l }) => {
|
|
3127
|
+
const _ = o / 16, m = 16 * _, p = r - m / 2, v = n;
|
|
3101
3128
|
i.save(), i.translate(p, v), i.scale(_, _), i.beginPath(), i.moveTo(7.85696, 0.288512), i.lineTo(4.53377, 3.11938), i.bezierCurveTo(4.17982, 3.42089, 4.39305, 4, 4.85801, 4), i.lineTo(11.2275, 4), i.bezierCurveTo(11.6818, 4, 11.9006, 3.44302, 11.5678, 3.13374), i.lineTo(8.52156, 0.302869), i.bezierCurveTo(8.33575, 0.130189, 8.05007, 0.124018, 7.85696, 0.288512), i.closePath(), i.fillStyle = e, i.fill(), i.beginPath(), i.moveTo(0, 7), i.bezierCurveTo(0, 4.79086, 1.79086, 3, 4, 3), i.lineTo(12, 3), i.bezierCurveTo(14.2091, 3, 16, 4.79086, 16, 7), i.lineTo(16, 15), i.bezierCurveTo(16, 17.2091, 14.2091, 19, 12, 19), i.lineTo(4, 19), i.bezierCurveTo(1.79086, 19, 0, 17.2091, 0, 15), i.lineTo(0, 7), i.closePath(), i.fillStyle = e, i.fill(), i.restore(), i.save(), i.font = `bold ${l}px sans-serif`, i.textAlign = "center", i.textBaseline = "top", i.textAlign = "center", i.textBaseline = "middle";
|
|
3102
|
-
const y =
|
|
3103
|
-
i.fillStyle = t, i.fillText(
|
|
3104
|
-
},
|
|
3105
|
-
const _ = o / 16,
|
|
3129
|
+
const y = n + _ * 3 + 0.5, b = _ * 16, x = y + b / 2;
|
|
3130
|
+
i.fillStyle = t, i.fillText(s, r, x), i.restore();
|
|
3131
|
+
}, er = (i, { mainColor: e, textColor: t, symbol: s, x: r, y: n, size: o, fontSize: l }) => {
|
|
3132
|
+
const _ = o / 16, m = 16 * _, p = r - m / 2, v = n;
|
|
3106
3133
|
i.save(), i.translate(p, v), i.scale(_, -_), i.beginPath(), i.moveTo(7.85696, 0.288512), i.lineTo(4.53377, 3.11938), i.bezierCurveTo(4.17982, 3.42089, 4.39305, 4, 4.85801, 4), i.lineTo(11.2275, 4), i.bezierCurveTo(11.6818, 4, 11.9006, 3.44302, 11.5678, 3.13374), i.lineTo(8.52156, 0.302869), i.bezierCurveTo(8.33575, 0.130189, 8.05007, 0.124018, 7.85696, 0.288512), i.closePath(), i.fillStyle = e, i.fill(), i.beginPath(), i.moveTo(0, 7), i.bezierCurveTo(0, 4.79086, 1.79086, 3, 4, 3), i.lineTo(12, 3), i.bezierCurveTo(14.2091, 3, 16, 4.79086, 16, 7), i.lineTo(16, 15), i.bezierCurveTo(16, 17.2091, 14.2091, 19, 12, 19), i.lineTo(4, 19), i.bezierCurveTo(1.79086, 19, 0, 17.2091, 0, 15), i.lineTo(0, 7), i.closePath(), i.fillStyle = e, i.fill(), i.restore(), i.save(), i.font = `bold ${l}px sans-serif`, i.textAlign = "center", i.textBaseline = "middle";
|
|
3107
|
-
const y = _ * 16, b =
|
|
3108
|
-
i.fillStyle = t, i.fillText(
|
|
3134
|
+
const y = _ * 16, b = n - _ * 19 + y / 2;
|
|
3135
|
+
i.fillStyle = t, i.fillText(s, r, b), i.restore();
|
|
3109
3136
|
};
|
|
3110
|
-
function
|
|
3137
|
+
function tr(i, e) {
|
|
3111
3138
|
const {
|
|
3112
3139
|
trade: { tradedCandles: t },
|
|
3113
|
-
scales: { x:
|
|
3114
|
-
colorScheme:
|
|
3115
|
-
} = e, o = 4;
|
|
3116
|
-
t.forEach(({ isActive:
|
|
3117
|
-
const
|
|
3118
|
-
|
|
3119
|
-
const
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3140
|
+
scales: { x: s, y: r },
|
|
3141
|
+
colorScheme: n
|
|
3142
|
+
} = e, { trade: o } = n, l = 4;
|
|
3143
|
+
t.forEach(({ isHovered: h, isActive: d, candle: u, trades: _ }) => {
|
|
3144
|
+
const m = s.map(u.open_time);
|
|
3145
|
+
_.forEach((p) => {
|
|
3146
|
+
const v = p.type === "buy", y = v ? o.buyLabel.text : o.sellLabel.text, b = v ? "B" : "S", x = v ? r.map(u.low) + l : r.map(u.high) - l, C = v ? Kn : er;
|
|
3147
|
+
let M = v ? o.buyLabel.main : o.sellLabel.main;
|
|
3148
|
+
h && (M = T.mix(M, n.bg, 20).toString()), d && (M = o.activeLabel), C(i, {
|
|
3149
|
+
x: m,
|
|
3150
|
+
y: x,
|
|
3151
|
+
symbol: b,
|
|
3152
|
+
mainColor: M,
|
|
3153
|
+
textColor: y,
|
|
3126
3154
|
size: 16,
|
|
3127
3155
|
fontSize: 12
|
|
3128
3156
|
});
|
|
3129
3157
|
});
|
|
3130
3158
|
});
|
|
3131
3159
|
}
|
|
3132
|
-
function
|
|
3160
|
+
function ir(i, e) {
|
|
3133
3161
|
const {
|
|
3134
|
-
scales: { x: t, factorX:
|
|
3162
|
+
scales: { x: t, factorX: s },
|
|
3135
3163
|
layout: { area: r },
|
|
3136
|
-
trade: { tradedCandles:
|
|
3137
|
-
config: { candles:
|
|
3164
|
+
trade: { tradedCandles: n, exits: o, entries: l },
|
|
3165
|
+
config: { candles: h },
|
|
3138
3166
|
colorScheme: { trade: d }
|
|
3139
3167
|
} = e;
|
|
3140
|
-
if (
|
|
3141
|
-
const u =
|
|
3168
|
+
if (n.length === 0) return;
|
|
3169
|
+
const u = n.map((m) => m.candle).sort((m, p) => m.open_time.getTime() - p.open_time.getTime()), _ = h.baseWidth / 2 * s + h.strokeWidth / 2;
|
|
3142
3170
|
if (i.save(), i.lineWidth = 1, i.strokeStyle = d.tradeBorders, l.length) {
|
|
3143
|
-
const
|
|
3144
|
-
i.beginPath(), i.moveTo(
|
|
3171
|
+
const m = t.map(u[0].open_time) - _;
|
|
3172
|
+
i.beginPath(), i.moveTo(m, r.y), i.lineTo(m, r.y + r.height), i.stroke();
|
|
3145
3173
|
}
|
|
3146
3174
|
if (o.length) {
|
|
3147
|
-
const
|
|
3148
|
-
i.beginPath(), i.moveTo(
|
|
3175
|
+
const m = t.map(u[u.length - 1].open_time) + _;
|
|
3176
|
+
i.beginPath(), i.moveTo(m, r.y), i.lineTo(m, r.y + r.height), i.stroke();
|
|
3149
3177
|
}
|
|
3150
3178
|
i.restore();
|
|
3151
3179
|
}
|
|
3152
|
-
const
|
|
3180
|
+
const sr = (i, e) => {
|
|
3153
3181
|
const {
|
|
3154
|
-
scales: { x: t, y:
|
|
3155
|
-
trade: { tradedCandles: r, entries:
|
|
3182
|
+
scales: { x: t, y: s },
|
|
3183
|
+
trade: { tradedCandles: r, entries: n, exits: o },
|
|
3156
3184
|
colorScheme: { trade: l }
|
|
3157
3185
|
} = e;
|
|
3158
3186
|
i.save();
|
|
3159
|
-
const
|
|
3187
|
+
const h = (u) => {
|
|
3160
3188
|
var _;
|
|
3161
3189
|
return (_ = r.find(
|
|
3162
|
-
(
|
|
3190
|
+
(m) => u.getTime() >= m.candle.open_time.getTime() && u.getTime() < m.candle.close_time.getTime()
|
|
3163
3191
|
)) == null ? void 0 : _.candle;
|
|
3164
3192
|
}, d = (u, _) => {
|
|
3165
|
-
const
|
|
3166
|
-
if (!
|
|
3167
|
-
const v = t.map(
|
|
3168
|
-
|
|
3193
|
+
const m = h(u.time), p = h(_.time);
|
|
3194
|
+
if (!m || !p) return;
|
|
3195
|
+
const v = t.map(m.open_time), y = t.map(p.open_time);
|
|
3196
|
+
let b, x;
|
|
3197
|
+
u.type === "buy" ? (b = s.map(m.low), x = s.map(p.high)) : (b = s.map(m.high), x = s.map(p.low)), i.beginPath(), i.setLineDash([4, 4]), i.strokeStyle = l.connectionLine, i.moveTo(v, b), i.lineTo(y, x), i.stroke(), i.setLineDash([]);
|
|
3169
3198
|
};
|
|
3170
|
-
if (
|
|
3171
|
-
o.forEach((u) => d(
|
|
3172
|
-
else if (o.length === 1 &&
|
|
3173
|
-
|
|
3174
|
-
else if (
|
|
3175
|
-
d(
|
|
3176
|
-
else if (
|
|
3177
|
-
const u =
|
|
3178
|
-
d(u
|
|
3199
|
+
if (n.length === 1 && o.length > 1)
|
|
3200
|
+
o.forEach((u) => d(n[0], u));
|
|
3201
|
+
else if (o.length === 1 && n.length > 1)
|
|
3202
|
+
n.forEach((u) => d(u, o[0]));
|
|
3203
|
+
else if (n.length === 1 && o.length === 1)
|
|
3204
|
+
d(n[0], o[0]);
|
|
3205
|
+
else if (n.length > 0 && o.length > 0) {
|
|
3206
|
+
const u = n.reduce((m, p) => m.time < p.time ? m : p), _ = o.reduce((m, p) => m.time > p.time ? m : p);
|
|
3207
|
+
d(u, _);
|
|
3179
3208
|
}
|
|
3180
3209
|
i.restore();
|
|
3181
3210
|
};
|
|
3182
|
-
class
|
|
3183
|
-
constructor(
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
this.renderMarker(n, s.node);
|
|
3211
|
+
class Wt extends R {
|
|
3212
|
+
constructor({ className: t, isAdaptPosition: s } = {}) {
|
|
3213
|
+
super({ tag: "div", className: t });
|
|
3214
|
+
g(this, "_isAdaptPosition");
|
|
3215
|
+
this._isAdaptPosition = !!s;
|
|
3216
|
+
}
|
|
3217
|
+
show({ x: t, y: s, parent: r, offset: n = 8 }) {
|
|
3218
|
+
let o = t + n, l = s + n;
|
|
3219
|
+
if (this._isAdaptPosition) {
|
|
3220
|
+
this.updateAbsolutePosition();
|
|
3221
|
+
const h = this.absolutePosition, d = {
|
|
3222
|
+
top: 0,
|
|
3223
|
+
left: 0,
|
|
3224
|
+
bottom: r.bottom - r.top,
|
|
3225
|
+
right: r.right - r.left
|
|
3226
|
+
};
|
|
3227
|
+
o + h.width > d.right && (o = t - h.width - n, o < d.left + n && (o = d.left + n)), l + h.height > d.bottom && (l = s - h.height - n, l < d.top + n && (l = d.top + n));
|
|
3200
3228
|
}
|
|
3229
|
+
this.node.style.opacity = "1", this.node.style.visibility = "visible", this.node.style.left = `${o}px`, this.node.style.top = `${l}px`;
|
|
3201
3230
|
}
|
|
3202
|
-
|
|
3203
|
-
this.
|
|
3204
|
-
}
|
|
3205
|
-
getIdFromMarker(e) {
|
|
3206
|
-
const t = e.type === "horizontal" ? "h" : "v", n = e.value instanceof Date ? e.value.getTime().toString() : e.value.toString().replace(".", "d");
|
|
3207
|
-
return `${t}_${n}`;
|
|
3208
|
-
}
|
|
3209
|
-
removeObsoleteItems(e) {
|
|
3210
|
-
for (const t in this.items)
|
|
3211
|
-
e.has(t) || (this.items[t].remove(), delete this.items[t]);
|
|
3212
|
-
}
|
|
3213
|
-
createMarkerElement(e) {
|
|
3214
|
-
const t = new R({
|
|
3215
|
-
tag: "div",
|
|
3216
|
-
className: `${this.className}-item`
|
|
3217
|
-
});
|
|
3218
|
-
return this.parent.append(t.node), this.items[e] = t, t;
|
|
3219
|
-
}
|
|
3220
|
-
renderMarker(e, t) {
|
|
3221
|
-
e.type === "horizontal" ? j.horizontalMarker({
|
|
3222
|
-
ctx: this.canvas.ctx,
|
|
3223
|
-
node: t,
|
|
3224
|
-
...e
|
|
3225
|
-
}) : j.verticalMarker({
|
|
3226
|
-
ctx: this.canvas.ctx,
|
|
3227
|
-
node: t,
|
|
3228
|
-
...e
|
|
3229
|
-
});
|
|
3231
|
+
hide() {
|
|
3232
|
+
this.node.style.opacity = "0", this.node.style.visibility = "hidden";
|
|
3230
3233
|
}
|
|
3231
3234
|
}
|
|
3232
|
-
class nr extends
|
|
3235
|
+
class nr extends Wt {
|
|
3233
3236
|
constructor() {
|
|
3234
|
-
super({
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3237
|
+
super({ className: "sc-charts-cs__trade-label-tooltip", isAdaptPosition: !0 });
|
|
3238
|
+
g(this, "_title");
|
|
3239
|
+
g(this, "_manyBox");
|
|
3240
|
+
g(this, "_oneBox");
|
|
3238
3241
|
this._title = new R({
|
|
3239
3242
|
tag: "div",
|
|
3240
3243
|
className: "sc-charts-cs__trade-label-tooltip-title"
|
|
@@ -3244,85 +3247,68 @@ class nr extends R {
|
|
|
3244
3247
|
}), this._oneBox = new R({
|
|
3245
3248
|
tag: "div",
|
|
3246
3249
|
className: "sc-charts-cs__trade-label-tooltip-box_one"
|
|
3247
|
-
});
|
|
3250
|
+
}), this.node.append(this._title.node, this._oneBox.node, this._manyBox.node);
|
|
3248
3251
|
}
|
|
3249
|
-
_createLineNodes(t,
|
|
3252
|
+
_createLineNodes(t, s) {
|
|
3250
3253
|
const r = [];
|
|
3251
|
-
for (const
|
|
3252
|
-
if (
|
|
3254
|
+
for (const n of Object.keys(s))
|
|
3255
|
+
if (n in t) {
|
|
3253
3256
|
const o = new R({
|
|
3254
3257
|
tag: "div",
|
|
3255
3258
|
className: `sc-charts-cs__trade-label-tooltip-line
|
|
3256
|
-
sc-charts-cs__trade-label-tooltip-line-key-${
|
|
3259
|
+
sc-charts-cs__trade-label-tooltip-line-key-${n}`
|
|
3257
3260
|
});
|
|
3258
|
-
let l = t[
|
|
3259
|
-
|
|
3260
|
-
const
|
|
3261
|
-
o.append(
|
|
3261
|
+
let l = t[n].toString();
|
|
3262
|
+
n === "kind" && (l = this._formatDate(t.time));
|
|
3263
|
+
const h = new R({ tag: "strong", textContent: s[n] }), d = new R({ tag: "span", textContent: l });
|
|
3264
|
+
o.append(h.node, d.node), r.push(o.node);
|
|
3262
3265
|
}
|
|
3263
3266
|
return r;
|
|
3264
3267
|
}
|
|
3265
3268
|
_formatDate(t) {
|
|
3266
|
-
const
|
|
3269
|
+
const s = new Intl.DateTimeFormat("en-US", {
|
|
3267
3270
|
hour: "2-digit",
|
|
3268
3271
|
minute: "2-digit",
|
|
3269
3272
|
day: "2-digit",
|
|
3270
3273
|
month: "short",
|
|
3271
3274
|
year: "numeric",
|
|
3272
3275
|
hour12: !1
|
|
3273
|
-
}).format(t), [r,
|
|
3274
|
-
return `${r}, ${
|
|
3276
|
+
}).format(t), [r, n, o] = s.split(", ");
|
|
3277
|
+
return `${r}, ${n} ${o}`;
|
|
3275
3278
|
}
|
|
3276
3279
|
_clearTooltip() {
|
|
3277
3280
|
this._title.node.style.display = "none", this._oneBox.node.style.display = "none", this._oneBox.node.replaceChildren(), this._manyBox.node.style.display = "none", this._manyBox.node.replaceChildren();
|
|
3278
3281
|
}
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
const _ = this._createLineNodes(r[0], {
|
|
3289
|
-
price: "Price:",
|
|
3290
|
-
profit: "Realized P&L:",
|
|
3291
|
-
volume: "Volume:",
|
|
3292
|
-
percentage: "% of position:"
|
|
3293
|
-
});
|
|
3294
|
-
this._oneBox.append(..._), this.node.append(this._title.node, this._oneBox.node);
|
|
3295
|
-
} else if (r.length > 1) {
|
|
3296
|
-
this._manyBox.node.style.display = "flex";
|
|
3297
|
-
const _ = r.map((g) => {
|
|
3298
|
-
const p = new R({ tag: "div" }), v = this._createLineNodes(g, {
|
|
3299
|
-
kind: g.kind === "entry" ? "Entry:" : "Exit:",
|
|
3300
|
-
price: "Price:"
|
|
3282
|
+
updateContent(t) {
|
|
3283
|
+
if (t.length) {
|
|
3284
|
+
if (this._clearTooltip(), t.length === 1) {
|
|
3285
|
+
this._title.node.style.display = "flex", this._oneBox.node.style.display = "flex", this._title.node.textContent = this._formatDate(t[0].time);
|
|
3286
|
+
const s = this._createLineNodes(t[0], {
|
|
3287
|
+
price: "Price:",
|
|
3288
|
+
profit: "Realized P&L:",
|
|
3289
|
+
volume: "Volume:",
|
|
3290
|
+
percentage: "% of position:"
|
|
3301
3291
|
});
|
|
3302
|
-
|
|
3303
|
-
})
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
}
|
|
3316
|
-
hide() {
|
|
3317
|
-
this.node.style.opacity = "0", this.node.style.visibility = "hidden";
|
|
3292
|
+
this._oneBox.append(...s), this.node.append(this._title.node, this._oneBox.node);
|
|
3293
|
+
} else if (t.length > 1) {
|
|
3294
|
+
this._manyBox.node.style.display = "flex";
|
|
3295
|
+
const s = t.map((r) => {
|
|
3296
|
+
const n = new R({ tag: "div" }), o = this._createLineNodes(r, {
|
|
3297
|
+
kind: r.kind === "entry" ? "Entry:" : "Exit:",
|
|
3298
|
+
price: "Price:"
|
|
3299
|
+
});
|
|
3300
|
+
return n.append(...o), n.node;
|
|
3301
|
+
});
|
|
3302
|
+
this._manyBox.append(...s), this.node.append(this._manyBox.node);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3318
3305
|
}
|
|
3319
3306
|
}
|
|
3320
|
-
class
|
|
3321
|
-
constructor(
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
this._canvas = new Te({ className: "sc-charts-cs__canvas-trade", width: r, height: s }), this._labelTooltip = new nr(), n.append(this._canvas.node), t.append(this._labelTooltip.node), this._markerManager = new Zt(e, "sc-charts-cs__canvas-trade-markers");
|
|
3307
|
+
class rr {
|
|
3308
|
+
constructor({ domParent: e, canvasParent: t, width: s, height: r }) {
|
|
3309
|
+
g(this, "_canvas");
|
|
3310
|
+
g(this, "_labelTooltip");
|
|
3311
|
+
this._canvas = new Me({ className: "sc-charts-cs__canvas-trade", width: s, height: r }), this._labelTooltip = new nr(), t.append(this._canvas.node), e.append(this._labelTooltip.node);
|
|
3326
3312
|
}
|
|
3327
3313
|
get canvas() {
|
|
3328
3314
|
return this._canvas;
|
|
@@ -3331,58 +3317,94 @@ class sr {
|
|
|
3331
3317
|
return this._labelTooltip;
|
|
3332
3318
|
}
|
|
3333
3319
|
renderAll(e) {
|
|
3334
|
-
this._canvas.clear(),
|
|
3320
|
+
this._canvas.clear(), ir(this._canvas.ctx, e), tr(this._canvas.ctx, e), sr(this._canvas.ctx, e);
|
|
3335
3321
|
}
|
|
3336
3322
|
}
|
|
3337
|
-
class
|
|
3323
|
+
class ar {
|
|
3324
|
+
constructor(e, t) {
|
|
3325
|
+
g(this, "canvas");
|
|
3326
|
+
g(this, "parent");
|
|
3327
|
+
g(this, "items", {});
|
|
3328
|
+
g(this, "className");
|
|
3329
|
+
this.className = t, this.canvas = new Me({
|
|
3330
|
+
width: e.width,
|
|
3331
|
+
height: e.height,
|
|
3332
|
+
className: `${t}-canvas`
|
|
3333
|
+
}), e.canvasesContainer.append(this.canvas.node), this.parent = new R({ tag: "div", className: t }), e.domElements.append(this.parent.node);
|
|
3334
|
+
}
|
|
3335
|
+
render(e) {
|
|
3336
|
+
const t = new Set(e.map(this.getIdFromMarker));
|
|
3337
|
+
this.canvas.clear(), this.removeObsoleteItems(t);
|
|
3338
|
+
for (const s of e) {
|
|
3339
|
+
const r = this.getIdFromMarker(s), n = this.items[r] ?? this.createMarkerElement(r);
|
|
3340
|
+
this.renderMarker(s, n.node);
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
clear() {
|
|
3344
|
+
this.canvas.clear(), this.parent.remove();
|
|
3345
|
+
}
|
|
3346
|
+
getIdFromMarker(e) {
|
|
3347
|
+
const t = e.type === "horizontal" ? "h" : "v", s = e.value instanceof Date ? e.value.getTime().toString() : e.value.toString().replace(".", "d");
|
|
3348
|
+
return `${t}_${s}`;
|
|
3349
|
+
}
|
|
3350
|
+
removeObsoleteItems(e) {
|
|
3351
|
+
for (const t in this.items)
|
|
3352
|
+
e.has(t) || (this.items[t].remove(), delete this.items[t]);
|
|
3353
|
+
}
|
|
3354
|
+
createMarkerElement(e) {
|
|
3355
|
+
const t = new R({
|
|
3356
|
+
tag: "div",
|
|
3357
|
+
className: `${this.className}-item`
|
|
3358
|
+
});
|
|
3359
|
+
return this.parent.append(t.node), this.items[e] = t, t;
|
|
3360
|
+
}
|
|
3361
|
+
renderMarker(e, t) {
|
|
3362
|
+
e.type === "horizontal" ? j.horizontalMarker({
|
|
3363
|
+
ctx: this.canvas.ctx,
|
|
3364
|
+
node: t,
|
|
3365
|
+
...e
|
|
3366
|
+
}) : j.verticalMarker({
|
|
3367
|
+
ctx: this.canvas.ctx,
|
|
3368
|
+
node: t,
|
|
3369
|
+
...e
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
class or extends Wt {
|
|
3338
3374
|
constructor() {
|
|
3339
|
-
super({ className: "sc-charts-cs__candle-tooltip_nodata" });
|
|
3375
|
+
super({ className: "sc-charts-cs__candle-tooltip_nodata", isAdaptPosition: !0 });
|
|
3340
3376
|
const e = new R({ tag: "p" });
|
|
3341
3377
|
e.node.textContent = "No data from broker", this.append(e.node);
|
|
3342
3378
|
}
|
|
3343
|
-
show({ x: e, y: t, layout: n }) {
|
|
3344
|
-
this.node.style.opacity = "1", this.node.style.visibility = "visible", this.updateAbsolutePosition();
|
|
3345
|
-
const r = this.absolutePosition, s = {
|
|
3346
|
-
top: 0,
|
|
3347
|
-
left: 0,
|
|
3348
|
-
bottom: n.chart.bottom - n.chart.top,
|
|
3349
|
-
right: n.chart.right - n.chart.left
|
|
3350
|
-
}, o = 8;
|
|
3351
|
-
let l = e + o, c = t + o;
|
|
3352
|
-
l + r.width > s.right && (l = e - r.width - o, l < s.left + o && (l = s.left + o)), c + r.height > s.bottom && (c = t - r.height - o, c < s.top + o && (c = s.top + o)), this.node.style.left = `${l}px`, this.node.style.top = `${c}px`;
|
|
3353
|
-
}
|
|
3354
|
-
hide() {
|
|
3355
|
-
this.node.style.opacity = "0", this.node.style.visibility = "hidden";
|
|
3356
|
-
}
|
|
3357
3379
|
}
|
|
3358
|
-
class
|
|
3380
|
+
class lr {
|
|
3359
3381
|
constructor(e) {
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3382
|
+
g(this, "_container");
|
|
3383
|
+
g(this, "_width");
|
|
3384
|
+
g(this, "_height");
|
|
3385
|
+
g(this, "_wrapper");
|
|
3386
|
+
g(this, "_domElements");
|
|
3387
|
+
g(this, "_canvasesContainer");
|
|
3388
|
+
g(this, "_mainCanvas");
|
|
3389
|
+
g(this, "_guidesCanvas");
|
|
3390
|
+
g(this, "_bindingManager");
|
|
3391
|
+
g(this, "_userMarkers");
|
|
3392
|
+
g(this, "_guideMarkers");
|
|
3393
|
+
g(this, "_trade");
|
|
3394
|
+
g(this, "_noDataTooltip");
|
|
3373
3395
|
this._container = e, this._wrapper = new R({ tag: "div", className: "sc-charts-cs" }), e.append(this._wrapper.node);
|
|
3374
|
-
const { width: t, height:
|
|
3375
|
-
this._width = t, this._height =
|
|
3396
|
+
const { width: t, height: s } = e.getBoundingClientRect();
|
|
3397
|
+
this._width = t, this._height = s, this._mainCanvas = new Me({
|
|
3376
3398
|
className: "sc-charts-cs__canvas-main",
|
|
3377
3399
|
width: t,
|
|
3378
|
-
height:
|
|
3400
|
+
height: s,
|
|
3379
3401
|
isMain: !0
|
|
3380
|
-
}), this._guidesCanvas = new
|
|
3402
|
+
}), this._guidesCanvas = new Me({ className: "sc-charts-cs__canvas-guides", width: t, height: s }), this._domElements = new R({ tag: "div", className: "sc-charts-cs__dom-elements" }), this._canvasesContainer = new R({ tag: "div", className: "sc-charts-cs__canvases" }), this._noDataTooltip = new or(), this._canvasesContainer.append(this._mainCanvas.node), this._wrapper.append(this._canvasesContainer.node, this._domElements.node), this._mainCanvas.updateAbsolutePosition(), this._bindingManager = new Qn(this._mainCanvas.node), this._userMarkers = new ar(this, "sc-charts-cs__user-markers"), this._trade = new rr({
|
|
3381
3403
|
width: t,
|
|
3382
|
-
height:
|
|
3404
|
+
height: s,
|
|
3383
3405
|
canvasParent: this._canvasesContainer,
|
|
3384
3406
|
domParent: this._domElements
|
|
3385
|
-
}), this._guideMarkers = new
|
|
3407
|
+
}), this._guideMarkers = new qn(this._domElements, this._guidesCanvas), this._domElements.append(this._noDataTooltip.node), this._canvasesContainer.append(this._guidesCanvas.node);
|
|
3386
3408
|
}
|
|
3387
3409
|
get container() {
|
|
3388
3410
|
return this._container;
|
|
@@ -3424,66 +3446,12 @@ class ar {
|
|
|
3424
3446
|
return this._noDataTooltip;
|
|
3425
3447
|
}
|
|
3426
3448
|
renderAll(e) {
|
|
3427
|
-
this._mainCanvas.clear(),
|
|
3428
|
-
}
|
|
3429
|
-
setCursor(e, t = !1) {
|
|
3430
|
-
const n = {
|
|
3431
|
-
x_axis: t ? "grabbing" : "ew-resize",
|
|
3432
|
-
y_axis: t ? "grabbing" : "ns-resize",
|
|
3433
|
-
area: t ? "grabbing" : "crosshair",
|
|
3434
|
-
default: "default"
|
|
3435
|
-
};
|
|
3436
|
-
this._mainCanvas.node.style.cursor = n[e];
|
|
3437
|
-
}
|
|
3438
|
-
}
|
|
3439
|
-
const or = (i, e) => {
|
|
3440
|
-
e.scales.x.setRange([0, e.layout.area.width]);
|
|
3441
|
-
const t = e.scales.x.domain(), n = e.scales.x.range(), r = e.scales.x.invert(n[0] - i).getTime() - t[0].getTime();
|
|
3442
|
-
e.scales.x.setDomain([
|
|
3443
|
-
new Date(t[0].getTime() + r),
|
|
3444
|
-
new Date(t[1].getTime() + r)
|
|
3445
|
-
]);
|
|
3446
|
-
}, lr = (i, e) => {
|
|
3447
|
-
e.scales.y.setRange([e.layout.area.height, 0]);
|
|
3448
|
-
const t = e.scales.y.domain(), n = e.scales.y.range(), r = e.scales.y.invert(n[0] - i) - t[0];
|
|
3449
|
-
e.scales.y.setDomain([t[0] + r, t[1] + r]);
|
|
3450
|
-
}, cr = 2e-3, Ut = { x: 0.2, y: 0.2 }, hr = 1e-3, Vt = (i, e, t) => Math.max(i, t + e * cr), Jt = (i, e) => Math.abs(i - e) > hr, Bt = (i, e) => {
|
|
3451
|
-
const t = e.scales.factorX, n = Vt(Ut.x, i, t);
|
|
3452
|
-
if (Jt(n, t)) {
|
|
3453
|
-
e.scales.factorX = n;
|
|
3454
|
-
const r = t / n, [s, o] = e.scales.x.domain(), l = s.getTime(), c = o.getTime(), d = new Date(l + (c - l) * r);
|
|
3455
|
-
e.scales.x.setDomain([s, d]);
|
|
3456
|
-
}
|
|
3457
|
-
}, Ot = (i, e) => {
|
|
3458
|
-
const t = e.scales.factorX, n = Vt(Ut.y, -i, t);
|
|
3459
|
-
if (Jt(n, t)) {
|
|
3460
|
-
e.scales.factorY = n;
|
|
3461
|
-
const r = t / n, [s, o] = e.scales.y.domain(), l = s + (o - s) * r;
|
|
3462
|
-
e.scales.y.setDomain([s, l]);
|
|
3449
|
+
this._mainCanvas.clear(), Un.renderAll(this._mainCanvas.ctx, e), Ge.xAxis(this._mainCanvas.ctx, e), Ge.yAxis(this._mainCanvas.ctx, e), Ge.intersection(this._mainCanvas.ctx, e), this._trade.renderAll(e), this._userMarkers.render(e.userMarkers.data);
|
|
3463
3450
|
}
|
|
3464
|
-
};
|
|
3465
|
-
function Pt(i, e, t) {
|
|
3466
|
-
const { xAxis: n, yAxis: r, area: s } = t, o = i >= n.x && i <= n.x + n.width && e >= n.y && e <= n.y + n.height, l = i >= r.x && i <= r.x + r.width && e >= r.y && e <= r.y + r.height, c = i >= s.x && i <= s.x + s.width && e >= s.y && e <= s.y + s.height;
|
|
3467
|
-
return o ? "x_axis" : l ? "y_axis" : c ? "area" : null;
|
|
3468
|
-
}
|
|
3469
|
-
function dr(i, e, t) {
|
|
3470
|
-
const {
|
|
3471
|
-
candles: { missingData: n },
|
|
3472
|
-
scales: { x: r, y: s },
|
|
3473
|
-
config: {
|
|
3474
|
-
candles: { baseWidth: o }
|
|
3475
|
-
}
|
|
3476
|
-
} = t;
|
|
3477
|
-
for (const l of n) {
|
|
3478
|
-
const c = r.map(l.open_time), d = s.map(l.high), u = s.map(l.low);
|
|
3479
|
-
if (i >= c - o / 2 && i <= c + o / 2 && e >= Math.min(d, u) && e <= Math.max(d, u))
|
|
3480
|
-
return l;
|
|
3481
|
-
}
|
|
3482
|
-
return null;
|
|
3483
3451
|
}
|
|
3484
|
-
class
|
|
3452
|
+
class cr {
|
|
3485
3453
|
constructor(e) {
|
|
3486
|
-
|
|
3454
|
+
g(this, "logColors", {
|
|
3487
3455
|
init_model: "color: green",
|
|
3488
3456
|
scale_event: "color: orange",
|
|
3489
3457
|
update_config: "color: blue",
|
|
@@ -3492,34 +3460,34 @@ class ur {
|
|
|
3492
3460
|
update_user_markers: "color: brown",
|
|
3493
3461
|
update_color_scheme: "color: teal"
|
|
3494
3462
|
});
|
|
3495
|
-
|
|
3463
|
+
g(this, "ignoredLogEvents", []);
|
|
3496
3464
|
e && (this.ignoredLogEvents = e);
|
|
3497
3465
|
}
|
|
3498
3466
|
log(e, t) {
|
|
3499
3467
|
if (this.ignoredLogEvents.includes(e)) return;
|
|
3500
|
-
const
|
|
3468
|
+
const s = this.logColors[e] || "color: gray";
|
|
3501
3469
|
let r;
|
|
3502
3470
|
try {
|
|
3503
3471
|
r = JSON.parse(JSON.stringify(t));
|
|
3504
3472
|
} catch {
|
|
3505
3473
|
r = t;
|
|
3506
3474
|
}
|
|
3507
|
-
console.log(`%c[SUBSCRIBE] ${e}`,
|
|
3475
|
+
console.log(`%c[SUBSCRIBE] ${e}`, s, r);
|
|
3508
3476
|
}
|
|
3509
3477
|
}
|
|
3510
|
-
class
|
|
3478
|
+
class hr {
|
|
3511
3479
|
constructor(e, t) {
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
this._model = e, this._view = t, this._enableLogging = !1, this._logger = new
|
|
3480
|
+
g(this, "_model");
|
|
3481
|
+
g(this, "_view");
|
|
3482
|
+
g(this, "_enableLogging");
|
|
3483
|
+
g(this, "_logger");
|
|
3484
|
+
this._model = e, this._view = t, this._enableLogging = !1, this._logger = new cr(["scale_event"]);
|
|
3517
3485
|
}
|
|
3518
3486
|
subscribeWithLogging(e, t) {
|
|
3519
|
-
const
|
|
3487
|
+
const s = (r) => {
|
|
3520
3488
|
this._enableLogging && this._logger.log(e, r), t(r);
|
|
3521
3489
|
};
|
|
3522
|
-
this._model.subscribe(e,
|
|
3490
|
+
this._model.subscribe(e, s);
|
|
3523
3491
|
}
|
|
3524
3492
|
// [TODO]: optimize renderers, call only the necessary ones. Get rid of this._view.renderAll
|
|
3525
3493
|
init() {
|
|
@@ -3528,7 +3496,7 @@ class fr {
|
|
|
3528
3496
|
}), this.subscribeWithLogging("scale_event", () => {
|
|
3529
3497
|
this._model.userMarkers.rebuild(), this._model.trade.recalculate(), this._view.renderAll(this._model);
|
|
3530
3498
|
}), this.subscribeWithLogging("update_config", (e) => {
|
|
3531
|
-
this._model.config.update(e), this._model.layout.updateConfig(this._model.config), this._model.scales.recalculate(), this._model.userMarkers.rebuild(), this.
|
|
3499
|
+
this._model.config.update(e), this._model.layout.updateConfig(this._model.config), this._model.scales.recalculate(), this._model.userMarkers.rebuild(), this._view.renderAll(this._model);
|
|
3532
3500
|
}), this.subscribeWithLogging("update_candles", (e) => {
|
|
3533
3501
|
this._model.candles.update(e), this._model.trade.recalculate(), this._model.scales.recalculate(), this._view.renderAll(this._model);
|
|
3534
3502
|
}), this.subscribeWithLogging("update_trade", (e) => {
|
|
@@ -3537,45 +3505,447 @@ class fr {
|
|
|
3537
3505
|
this._model.userMarkers.updateMarkers(e), this._view.userMarkers.render(this._model.userMarkers.data);
|
|
3538
3506
|
}), this.subscribeWithLogging("update_color_scheme", (e) => {
|
|
3539
3507
|
this._model.colorScheme.update(e), this._view.renderAll(this._model);
|
|
3540
|
-
}), this.subscribeWithLogging("open_trade_label_tooltip", ({ trade: e, x: t, y:
|
|
3541
|
-
this._model.trade.setActiveTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.show({
|
|
3508
|
+
}), this.subscribeWithLogging("open_trade_label_tooltip", ({ trade: e, x: t, y: s }) => {
|
|
3509
|
+
this._model.trade.setActiveTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.updateContent(e.trades), this._view.trade.labelTooltip.show({ x: t, y: s, parent: this._model.layout.chart });
|
|
3542
3510
|
}), this.subscribeWithLogging("close_trade_label_tooltip", () => {
|
|
3543
3511
|
this._model.trade.setActiveTrade(null), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.hide();
|
|
3544
3512
|
}), this.subscribeWithLogging("hover_nodata_candle", ({ x: e, y: t }) => {
|
|
3545
|
-
this._view.noDataTooltip.show({ x: e, y: t,
|
|
3513
|
+
this._view.noDataTooltip.show({ x: e, y: t, parent: this._model.layout.area });
|
|
3546
3514
|
}), this.subscribeWithLogging("leave_nodata_candle", () => {
|
|
3547
3515
|
this._view.noDataTooltip.hide();
|
|
3516
|
+
}), this.subscribeWithLogging("mouseover_trade_label_tooltip", (e) => {
|
|
3517
|
+
this._model.trade.setHoveredTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model);
|
|
3518
|
+
}), this.subscribeWithLogging("mouseleave_trade_label_tooltip", () => {
|
|
3519
|
+
this._model.trade.setHoveredTrade(null), this._view.trade.renderAll(this._model);
|
|
3548
3520
|
});
|
|
3549
3521
|
}
|
|
3550
3522
|
}
|
|
3523
|
+
class $t {
|
|
3524
|
+
constructor() {
|
|
3525
|
+
g(this, "_map", /* @__PURE__ */ new Map());
|
|
3526
|
+
}
|
|
3527
|
+
add(e, t, s) {
|
|
3528
|
+
let r = this._map.get(e);
|
|
3529
|
+
r || (r = {}, this._map.set(e, r)), r[t] || (r[t] = /* @__PURE__ */ new Set()), r[t].add(s);
|
|
3530
|
+
}
|
|
3531
|
+
remove(e, t, s) {
|
|
3532
|
+
var n;
|
|
3533
|
+
const r = this._map.get(e);
|
|
3534
|
+
(n = r == null ? void 0 : r[t]) == null || n.delete(s);
|
|
3535
|
+
}
|
|
3536
|
+
removeAll(e) {
|
|
3537
|
+
this._map.delete(e);
|
|
3538
|
+
}
|
|
3539
|
+
emit(e, t) {
|
|
3540
|
+
const s = this._map.get(e), r = s == null ? void 0 : s[t.type];
|
|
3541
|
+
if (!r) return !1;
|
|
3542
|
+
let n = !1;
|
|
3543
|
+
const o = {
|
|
3544
|
+
...t,
|
|
3545
|
+
stopPropagation: () => {
|
|
3546
|
+
n = !0;
|
|
3547
|
+
}
|
|
3548
|
+
};
|
|
3549
|
+
for (const l of r)
|
|
3550
|
+
if (l(o), n) break;
|
|
3551
|
+
return n;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
class dr {
|
|
3555
|
+
constructor() {
|
|
3556
|
+
g(this, "_elements", []);
|
|
3557
|
+
g(this, "_listeners", new $t());
|
|
3558
|
+
g(this, "_lastHovered", /* @__PURE__ */ new Set());
|
|
3559
|
+
g(this, "_dragContext", null);
|
|
3560
|
+
}
|
|
3561
|
+
get isDragging() {
|
|
3562
|
+
return this._dragContext !== null;
|
|
3563
|
+
}
|
|
3564
|
+
register(...e) {
|
|
3565
|
+
this._elements.push(...e);
|
|
3566
|
+
}
|
|
3567
|
+
unregister(e) {
|
|
3568
|
+
this._elements = this._elements.filter((t) => t !== e), this._listeners.removeAll(e), this._lastHovered.delete(e);
|
|
3569
|
+
}
|
|
3570
|
+
clear() {
|
|
3571
|
+
this._elements = [], this._listeners = new $t(), this._lastHovered.clear();
|
|
3572
|
+
}
|
|
3573
|
+
on(e, t, s) {
|
|
3574
|
+
this._listeners.add(e, t, s);
|
|
3575
|
+
}
|
|
3576
|
+
off(e, t, s) {
|
|
3577
|
+
this._listeners.remove(e, t, s);
|
|
3578
|
+
}
|
|
3579
|
+
dispatchMouseMove(e, t) {
|
|
3580
|
+
if (this._dragContext) {
|
|
3581
|
+
this._emitSingle(this._dragContext.target, {
|
|
3582
|
+
type: "drag",
|
|
3583
|
+
target: this._dragContext.target,
|
|
3584
|
+
x: e,
|
|
3585
|
+
y: t,
|
|
3586
|
+
prevX: this._dragContext.lastX,
|
|
3587
|
+
prevY: this._dragContext.lastY
|
|
3588
|
+
}), this._dragContext.lastX = e, this._dragContext.lastY = t;
|
|
3589
|
+
return;
|
|
3590
|
+
}
|
|
3591
|
+
const s = this._getHitsAt(e, t), r = new Set(s.map((n) => n.target));
|
|
3592
|
+
for (const n of s)
|
|
3593
|
+
if (!this._lastHovered.has(n.target) && this._emitSingle(n.target, {
|
|
3594
|
+
type: "mouseover",
|
|
3595
|
+
target: n.target,
|
|
3596
|
+
x: n.x,
|
|
3597
|
+
y: n.y
|
|
3598
|
+
}) || this._emitSingle(n.target, {
|
|
3599
|
+
type: "mousemove",
|
|
3600
|
+
target: n.target,
|
|
3601
|
+
x: n.x,
|
|
3602
|
+
y: n.y
|
|
3603
|
+
})) break;
|
|
3604
|
+
for (const n of this._lastHovered)
|
|
3605
|
+
r.has(n) || this._emitSingle(n, {
|
|
3606
|
+
type: "mouseleave",
|
|
3607
|
+
target: n,
|
|
3608
|
+
x: e,
|
|
3609
|
+
y: t
|
|
3610
|
+
});
|
|
3611
|
+
this._lastHovered = r;
|
|
3612
|
+
}
|
|
3613
|
+
dispatchMouseDown(e, t) {
|
|
3614
|
+
const s = this._getHitsAt(e, t);
|
|
3615
|
+
if (s.length === 0) {
|
|
3616
|
+
this._dragContext = null;
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
this._dragContext = null;
|
|
3620
|
+
for (const r of s)
|
|
3621
|
+
if (this._emitSingle(r.target, {
|
|
3622
|
+
type: "mousedown",
|
|
3623
|
+
target: r.target,
|
|
3624
|
+
x: r.x,
|
|
3625
|
+
y: r.y
|
|
3626
|
+
})) {
|
|
3627
|
+
this._dragContext = { target: r.target, lastX: e, lastY: t };
|
|
3628
|
+
break;
|
|
3629
|
+
}
|
|
3630
|
+
!this._dragContext && s.length > 0 && (this._dragContext = { target: s[s.length - 1].target, lastX: e, lastY: t });
|
|
3631
|
+
}
|
|
3632
|
+
dispatchMouseUp(e, t) {
|
|
3633
|
+
this._dragContext && this._emitSingle(this._dragContext.target, {
|
|
3634
|
+
type: "mouseup",
|
|
3635
|
+
target: this._dragContext.target,
|
|
3636
|
+
x: e,
|
|
3637
|
+
y: t
|
|
3638
|
+
}), this._dragContext = null;
|
|
3639
|
+
}
|
|
3640
|
+
dispatchClick(e, t) {
|
|
3641
|
+
const s = this._getHitsAt(e, t);
|
|
3642
|
+
for (const r of s)
|
|
3643
|
+
if (this._emitSingle(r.target, {
|
|
3644
|
+
type: "click",
|
|
3645
|
+
target: r.target,
|
|
3646
|
+
x: r.x,
|
|
3647
|
+
y: r.y
|
|
3648
|
+
})) break;
|
|
3649
|
+
}
|
|
3650
|
+
dispatchDblClick(e, t) {
|
|
3651
|
+
const s = this._getHitsAt(e, t);
|
|
3652
|
+
for (const r of s)
|
|
3653
|
+
if (this._emitSingle(r.target, {
|
|
3654
|
+
type: "dblclick",
|
|
3655
|
+
target: r.target,
|
|
3656
|
+
x: r.x,
|
|
3657
|
+
y: r.y
|
|
3658
|
+
})) break;
|
|
3659
|
+
}
|
|
3660
|
+
dispatchWheel(e, t, s, r, n) {
|
|
3661
|
+
const o = this._getHitsAt(e, t);
|
|
3662
|
+
for (const l of o)
|
|
3663
|
+
if (this._emitSingle(l.target, {
|
|
3664
|
+
type: "wheel",
|
|
3665
|
+
target: l.target,
|
|
3666
|
+
x: l.x,
|
|
3667
|
+
y: l.y,
|
|
3668
|
+
deltaX: s,
|
|
3669
|
+
deltaY: r,
|
|
3670
|
+
deltaZ: n
|
|
3671
|
+
})) break;
|
|
3672
|
+
}
|
|
3673
|
+
hitTestAll(e, t) {
|
|
3674
|
+
return this._getHitsAt(e, t);
|
|
3675
|
+
}
|
|
3676
|
+
_getHitsAt(e, t) {
|
|
3677
|
+
return this._elements.map((s) => s.hitTest(e, t)).filter((s) => s !== null);
|
|
3678
|
+
}
|
|
3679
|
+
_emitSingle(e, t) {
|
|
3680
|
+
let s = !1;
|
|
3681
|
+
const r = {
|
|
3682
|
+
...t,
|
|
3683
|
+
stopPropagation() {
|
|
3684
|
+
s = !0;
|
|
3685
|
+
}
|
|
3686
|
+
};
|
|
3687
|
+
return this._listeners.emit(e, r), s;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
class ur {
|
|
3691
|
+
constructor(e) {
|
|
3692
|
+
this.model = e;
|
|
3693
|
+
}
|
|
3694
|
+
hitTest(e, t) {
|
|
3695
|
+
const {
|
|
3696
|
+
candles: { missingData: s },
|
|
3697
|
+
scales: { x: r, y: n },
|
|
3698
|
+
config: {
|
|
3699
|
+
candles: { baseWidth: o }
|
|
3700
|
+
}
|
|
3701
|
+
} = this.model;
|
|
3702
|
+
for (const l of s) {
|
|
3703
|
+
const h = r.map(l.open_time), d = n.map(l.high), u = n.map(l.low), _ = h - o / 2, m = h + o / 2, p = Math.min(d, u), v = Math.max(d, u);
|
|
3704
|
+
if (e >= _ && e <= m && t >= p && t <= v)
|
|
3705
|
+
return {
|
|
3706
|
+
target: this,
|
|
3707
|
+
x: e,
|
|
3708
|
+
y: t,
|
|
3709
|
+
type: "candle",
|
|
3710
|
+
candle: l
|
|
3711
|
+
};
|
|
3712
|
+
}
|
|
3713
|
+
return null;
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3551
3716
|
class gr {
|
|
3552
3717
|
constructor(e, t) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3718
|
+
g(this, "_model");
|
|
3719
|
+
g(this, "_hitManager");
|
|
3720
|
+
g(this, "_hit");
|
|
3721
|
+
this._model = e, this._hitManager = t, this._hit = new ur(e), this._hitManager.register(this._hit);
|
|
3722
|
+
}
|
|
3723
|
+
register() {
|
|
3724
|
+
this._hitManager.on(this._hit, "mouseover", (e) => {
|
|
3725
|
+
const t = this._hit.hitTest(e.x, e.y);
|
|
3726
|
+
if (!t) return;
|
|
3727
|
+
const s = this._model.scales.x.map(t.candle.open_time), r = this._model.scales.y.map(t.candle.high) - 4;
|
|
3728
|
+
this._model.eventBus.emit("hover_nodata_candle", { x: s, y: r });
|
|
3729
|
+
}), this._hitManager.on(this._hit, "mouseleave", () => {
|
|
3730
|
+
this._model.eventBus.emit("leave_nodata_candle");
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
class fr {
|
|
3735
|
+
constructor(e) {
|
|
3736
|
+
this.model = e;
|
|
3737
|
+
}
|
|
3738
|
+
hitTest(e, t) {
|
|
3739
|
+
const { tradedCandles: s } = this.model.trade, { x: r, y: n } = this.model.scales, o = 16, l = 4;
|
|
3740
|
+
for (const { candle: h, trades: d } of s) {
|
|
3741
|
+
const u = r.map(h.open_time), _ = o, m = o, p = d[0].type === "buy", v = u + this.model.config.candles.baseWidth / 2, y = p ? n.map(h.low) + l + Ce(o) : n.map(h.high) - l - o - Ce(o), b = e >= v - _ / 2 && e <= v + _ / 2, x = t >= y && t <= y + m;
|
|
3742
|
+
if (b && x)
|
|
3743
|
+
return {
|
|
3744
|
+
target: this,
|
|
3745
|
+
type: "trade-label",
|
|
3746
|
+
x: e,
|
|
3747
|
+
y: t,
|
|
3748
|
+
candle: h,
|
|
3749
|
+
trades: d
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
return null;
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
class _r {
|
|
3756
|
+
constructor(e, t) {
|
|
3757
|
+
g(this, "_model");
|
|
3758
|
+
g(this, "_hitManager");
|
|
3759
|
+
g(this, "_tradeLabelHit");
|
|
3760
|
+
this._model = e, this._hitManager = t, this._tradeLabelHit = new fr(e), this._hitManager.register(this._tradeLabelHit);
|
|
3761
|
+
}
|
|
3762
|
+
register() {
|
|
3763
|
+
this._hitManager.on(this._tradeLabelHit, "click", (e) => {
|
|
3764
|
+
const t = this._tradeLabelHit.hitTest(e.x, e.y);
|
|
3765
|
+
if (!t) return;
|
|
3766
|
+
const s = this._model.scales.x.map(t.candle.open_time), r = this._model.scales.y.map(
|
|
3767
|
+
t.trades[0].type === "buy" ? t.candle.low : t.candle.high
|
|
3768
|
+
), n = t.trades[0].type === "buy" ? r + 4 + Ce(16) + 8 : r - 4 - 16 - Ce(16) + 8;
|
|
3769
|
+
this._model.eventBus.emit("open_trade_label_tooltip", {
|
|
3770
|
+
trade: { candle: t.candle, trades: t.trades },
|
|
3771
|
+
x: s,
|
|
3772
|
+
y: n
|
|
3773
|
+
});
|
|
3774
|
+
}), this._hitManager.on(this._tradeLabelHit, "mouseover", (e) => {
|
|
3775
|
+
const t = this._tradeLabelHit.hitTest(e.x, e.y);
|
|
3776
|
+
t && this._model.eventBus.emit("mouseover_trade_label_tooltip", {
|
|
3777
|
+
candle: t.candle,
|
|
3778
|
+
trades: t.trades
|
|
3779
|
+
});
|
|
3780
|
+
}), this._hitManager.on(this._tradeLabelHit, "mouseleave", () => {
|
|
3781
|
+
this._model.eventBus.emit("mouseleave_trade_label_tooltip");
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
class mr {
|
|
3786
|
+
constructor(e) {
|
|
3787
|
+
this.model = e;
|
|
3788
|
+
}
|
|
3789
|
+
hitTest(e, t) {
|
|
3790
|
+
const { xAxis: s } = this.model.layout;
|
|
3791
|
+
return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
|
|
3792
|
+
target: this,
|
|
3793
|
+
x: e,
|
|
3794
|
+
y: t,
|
|
3795
|
+
type: "x-axis"
|
|
3796
|
+
} : null;
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
const pr = (i, e) => {
|
|
3800
|
+
e.scales.x.setRange([0, e.layout.area.width]);
|
|
3801
|
+
const t = e.scales.x.domain(), s = e.scales.x.range(), r = e.scales.x.invert(s[0] - i).getTime() - t[0].getTime();
|
|
3802
|
+
e.scales.x.setDomain([
|
|
3803
|
+
new Date(t[0].getTime() + r),
|
|
3804
|
+
new Date(t[1].getTime() + r)
|
|
3805
|
+
]);
|
|
3806
|
+
}, vr = (i, e) => {
|
|
3807
|
+
e.scales.y.setRange([e.layout.area.height, 0]);
|
|
3808
|
+
const t = e.scales.y.domain(), s = e.scales.y.range(), r = e.scales.y.invert(s[0] - i) - t[0];
|
|
3809
|
+
e.scales.y.setDomain([t[0] + r, t[1] + r]);
|
|
3810
|
+
}, yr = 2e-3, Gt = { x: 0.2, y: 0.2 }, br = 1e-3, Ut = (i, e, t) => Math.max(i, t + e * yr), Zt = (i, e) => Math.abs(i - e) > br, Vt = (i, e) => {
|
|
3811
|
+
const t = e.scales.factorX, s = Ut(Gt.x, i, t);
|
|
3812
|
+
if (Zt(s, t)) {
|
|
3813
|
+
e.scales.factorX = s;
|
|
3814
|
+
const r = t / s, [n, o] = e.scales.x.domain(), l = n.getTime(), h = o.getTime(), d = new Date(l + (h - l) * r);
|
|
3815
|
+
e.scales.x.setDomain([n, d]);
|
|
3816
|
+
}
|
|
3817
|
+
}, Jt = (i, e) => {
|
|
3818
|
+
const t = e.scales.factorX, s = Ut(Gt.y, -i, t);
|
|
3819
|
+
if (Zt(s, t)) {
|
|
3820
|
+
e.scales.factorY = s;
|
|
3821
|
+
const r = t / s, [n, o] = e.scales.y.domain(), l = n + (o - n) * r;
|
|
3822
|
+
e.scales.y.setDomain([n, l]);
|
|
3823
|
+
}
|
|
3824
|
+
};
|
|
3825
|
+
class xr {
|
|
3826
|
+
constructor(e) {
|
|
3827
|
+
this.model = e;
|
|
3828
|
+
}
|
|
3829
|
+
hitTest(e, t) {
|
|
3830
|
+
const { area: s } = this.model.layout;
|
|
3831
|
+
return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
|
|
3832
|
+
target: this,
|
|
3833
|
+
x: e,
|
|
3834
|
+
y: t,
|
|
3835
|
+
type: "area"
|
|
3836
|
+
} : null;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
class wr {
|
|
3840
|
+
constructor(e) {
|
|
3841
|
+
this.model = e;
|
|
3842
|
+
}
|
|
3843
|
+
hitTest(e, t) {
|
|
3844
|
+
const { yAxis: s } = this.model.layout;
|
|
3845
|
+
return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
|
|
3846
|
+
target: this,
|
|
3847
|
+
x: e,
|
|
3848
|
+
y: t,
|
|
3849
|
+
type: "y-axis"
|
|
3850
|
+
} : null;
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
class Mr {
|
|
3854
|
+
constructor(e, t) {
|
|
3855
|
+
g(this, "_model");
|
|
3856
|
+
g(this, "_hitManager");
|
|
3857
|
+
g(this, "_hit");
|
|
3858
|
+
this._model = e, this._hitManager = t, this._hit = new mr(e), this._hitManager.register(this._hit);
|
|
3859
|
+
}
|
|
3860
|
+
register() {
|
|
3861
|
+
this._hitManager.on(this._hit, "drag", (e) => {
|
|
3862
|
+
const t = e.x - (e.prevX ?? e.x);
|
|
3863
|
+
Vt(t, this._model);
|
|
3864
|
+
}), this._hitManager.on(this._hit, "dblclick", () => {
|
|
3865
|
+
this._model.eventBus.emit("update_config", {});
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
class Tr {
|
|
3870
|
+
constructor(e, t) {
|
|
3871
|
+
g(this, "_model");
|
|
3872
|
+
g(this, "_hitManager");
|
|
3873
|
+
g(this, "_hit");
|
|
3874
|
+
this._model = e, this._hitManager = t, this._hit = new wr(e), this._hitManager.register(this._hit);
|
|
3875
|
+
}
|
|
3876
|
+
register() {
|
|
3877
|
+
this._hitManager.on(this._hit, "drag", (e) => {
|
|
3878
|
+
const t = e.y - (e.prevY ?? e.y);
|
|
3879
|
+
Jt(t, this._model);
|
|
3880
|
+
}), this._hitManager.on(this._hit, "dblclick", () => {
|
|
3881
|
+
this._model.eventBus.emit("update_config", {});
|
|
3882
|
+
});
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
class Cr {
|
|
3886
|
+
constructor(e, t, s) {
|
|
3887
|
+
g(this, "_model");
|
|
3888
|
+
g(this, "_view");
|
|
3889
|
+
g(this, "_hitManager");
|
|
3890
|
+
g(this, "_hit");
|
|
3891
|
+
this._model = e, this._view = t, this._hitManager = s, this._hit = new xr(e), this._hitManager.register(this._hit);
|
|
3892
|
+
}
|
|
3893
|
+
register() {
|
|
3894
|
+
this._hitManager.on(this._hit, "mousemove", (e) => {
|
|
3895
|
+
this._view.guideMarkers.show(), this._view.guideMarkers.render(this._model, { x: e.x, y: e.y });
|
|
3896
|
+
}), this._hitManager.on(this._hit, "mouseleave", () => {
|
|
3897
|
+
this._view.guideMarkers.hide();
|
|
3898
|
+
}), this._hitManager.on(this._hit, "drag", (e) => {
|
|
3899
|
+
const t = e.x - (e.prevX ?? e.x), s = e.y - (e.prevY ?? e.y);
|
|
3900
|
+
pr(t, this._model), vr(s, this._model), this._view.guideMarkers.render(this._model, { x: e.x, y: e.y });
|
|
3901
|
+
}), this._hitManager.on(this._hit, "wheel", (e) => {
|
|
3902
|
+
var r, n;
|
|
3903
|
+
if (!e.deltaY) return;
|
|
3904
|
+
const t = -e.deltaY, s = (n = (r = this._model.config) == null ? void 0 : r.candles) == null ? void 0 : n.zoomOnWheel;
|
|
3905
|
+
["x", "both"].includes(s) && Vt(t, this._model), ["y", "both"].includes(s) && Jt(t, this._model);
|
|
3906
|
+
});
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
class Ar {
|
|
3910
|
+
constructor(e, t, s) {
|
|
3911
|
+
g(this, "_hitManager");
|
|
3912
|
+
g(this, "_candlesHandler");
|
|
3913
|
+
g(this, "_tradeLabelsHandler");
|
|
3914
|
+
g(this, "_xAxisHandler");
|
|
3915
|
+
g(this, "_yAxisHandler");
|
|
3916
|
+
g(this, "_areaHandler");
|
|
3917
|
+
this._hitManager = s, this._candlesHandler = new gr(e, this._hitManager), this._tradeLabelsHandler = new _r(e, this._hitManager), this._xAxisHandler = new Mr(e, this._hitManager), this._yAxisHandler = new Tr(e, this._hitManager), this._areaHandler = new Cr(e, t, this._hitManager);
|
|
3918
|
+
}
|
|
3919
|
+
register() {
|
|
3920
|
+
this._candlesHandler.register(), this._tradeLabelsHandler.register(), this._xAxisHandler.register(), this._yAxisHandler.register(), this._areaHandler.register();
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
class Sr {
|
|
3924
|
+
constructor(e, t) {
|
|
3925
|
+
g(this, "_model");
|
|
3926
|
+
g(this, "_view");
|
|
3927
|
+
g(this, "_subscriptionsManager");
|
|
3928
|
+
g(this, "_hitManager", new dr());
|
|
3929
|
+
g(this, "_boundMouseMove", this.onDocumentMouseMove.bind(this));
|
|
3930
|
+
g(this, "_boundMouseUp", this.onDocumentMouseUp.bind(this));
|
|
3931
|
+
this._model = e, this._view = t, this._subscriptionsManager = new hr(e, t);
|
|
3564
3932
|
}
|
|
3565
3933
|
init() {
|
|
3566
|
-
this._subscriptionsManager.init(), this._model.init(), this._view.binding.mousemove(this.onMouseMove.bind(this)), this._view.binding.
|
|
3934
|
+
this._subscriptionsManager.init(), this._model.init(), this._view.binding.mousemove(this.onMouseMove.bind(this)), this._view.binding.mousedown(this.onMouseDown.bind(this)), this._view.binding.mouseup(this.onMouseUp.bind(this)), this._view.binding.wheel(this.onWheel.bind(this)), this._view.binding.mouseleave(this.onMouseLeave.bind(this)), this._view.binding.dblclick(this.onDoubleClick.bind(this)), window.addEventListener("scroll", this.onWindowScroll.bind(this), { passive: !0 }), document.addEventListener("click", this.onDocumentClick.bind(this)), new Ar(this._model, this._view, this._hitManager).register();
|
|
3935
|
+
}
|
|
3936
|
+
onWindowScroll() {
|
|
3937
|
+
this._view.mainCanvas.updateAbsolutePosition();
|
|
3938
|
+
}
|
|
3939
|
+
onMouseLeave() {
|
|
3940
|
+
this._hitManager.isDragging || (this._hitManager.dispatchMouseMove(-1 / 0, -1 / 0), document.removeEventListener("mousemove", this._boundMouseMove), document.removeEventListener("mouseup", this._boundMouseUp));
|
|
3941
|
+
}
|
|
3942
|
+
onDoubleClick(e) {
|
|
3943
|
+
const { x: t, y: s } = this.getMouseRelative(e);
|
|
3944
|
+
this._hitManager.dispatchDblClick(t, s);
|
|
3567
3945
|
}
|
|
3568
3946
|
onDocumentClick(e) {
|
|
3569
|
-
const t = this.getMouseRelative(e)
|
|
3570
|
-
|
|
3571
|
-
const u = r.map(c.open_time), _ = o, g = o;
|
|
3572
|
-
for (const p of d) {
|
|
3573
|
-
const v = p.type === "buy", y = u + this._model.config.candles.baseWidth / 2, b = v ? s.map(c.low) + l + Me(o) : s.map(c.high) - l - o - Me(o), w = t.x >= y - _ / 2 && t.x <= y + _ / 2, T = t.y >= b && t.y <= b + g;
|
|
3574
|
-
if (w && T)
|
|
3575
|
-
return;
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
this._model.trade.hasActiveTrade && this._model.eventBus.emit("close_trade_label_tooltip");
|
|
3947
|
+
const t = this.getMouseRelative(e);
|
|
3948
|
+
this._hitManager.dispatchClick(t.x, t.y), !this._hitManager.hitTestAll(t.x, t.y).find((r) => r.type === "trade-label") && this._model.trade.hasActiveTrade && this._model.eventBus.emit("close_trade_label_tooltip");
|
|
3579
3949
|
}
|
|
3580
3950
|
getMouseRelative(e) {
|
|
3581
3951
|
return {
|
|
@@ -3583,85 +3953,55 @@ class gr {
|
|
|
3583
3953
|
y: e.clientY - this._view.mainCanvas.absolutePosition.top
|
|
3584
3954
|
};
|
|
3585
3955
|
}
|
|
3956
|
+
onDocumentMouseMove(e) {
|
|
3957
|
+
const { x: t, y: s } = this.getMouseRelative(e);
|
|
3958
|
+
this._hitManager.dispatchMouseMove(t, s);
|
|
3959
|
+
}
|
|
3586
3960
|
onMouseDown(e) {
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
this._lastMouseX = t, this._lastMouseY = n, this._activeZone = Pt(t, n, this._model.layout), e.preventDefault(), document.addEventListener("mousemove", this._boundMouseMove), document.addEventListener("mouseup", this._boundMouseUp);
|
|
3961
|
+
const { x: t, y: s } = this.getMouseRelative(e);
|
|
3962
|
+
this._hitManager.dispatchMouseDown(t, s), e.preventDefault(), document.addEventListener("mouseup", this._boundMouseUp), this._hitManager.isDragging && document.addEventListener("mousemove", this._boundMouseMove);
|
|
3590
3963
|
}
|
|
3591
3964
|
onMouseUp(e) {
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
for (const { candle: l, trades: c } of t) {
|
|
3595
|
-
const d = n.map(l.open_time), u = s, _ = s;
|
|
3596
|
-
for (const g of c) {
|
|
3597
|
-
const p = g.type === "buy", v = d + this._model.config.candles.baseWidth / 2, y = p ? r.map(l.low) + o + Me(s) : r.map(l.high) - o - s - Me(s), b = this.getMouseRelative(e), w = b.x >= v - u / 2 && b.x <= v + u / 2, T = b.y >= y && b.y <= y + _;
|
|
3598
|
-
if (w && T) {
|
|
3599
|
-
this._model.eventBus.emit("open_trade_label_tooltip", {
|
|
3600
|
-
trade: { candle: l, trades: c },
|
|
3601
|
-
x: d,
|
|
3602
|
-
y: y + _ / 2
|
|
3603
|
-
});
|
|
3604
|
-
return;
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
document.removeEventListener("mousemove", this._boundMouseMove), document.removeEventListener("mouseup", this._boundMouseUp);
|
|
3609
|
-
}
|
|
3610
|
-
onDocumentMouseMove(e) {
|
|
3611
|
-
if (!this._isDragging || !this._activeZone) return;
|
|
3612
|
-
const { x: t, y: n } = this.getMouseRelative(e), r = t - this._lastMouseX, s = n - this._lastMouseY;
|
|
3613
|
-
this._activeZone === "x_axis" && Bt(r, this._model), this._activeZone === "y_axis" && Ot(s, this._model), this._activeZone === "area" && (or(r, this._model), lr(s, this._model), this._lastMouseX = t, this._lastMouseY = n), this._lastMouseX = t, this._lastMouseY = n, this._activeZone === "area" && (this._view.guideMarkers.show(), this._view.guideMarkers.render(this._model, { x: t, y: n }), this._view.setCursor(this._activeZone ?? "default", !0));
|
|
3965
|
+
const t = this.getMouseRelative(e);
|
|
3966
|
+
this._hitManager.dispatchMouseUp(t.x, t.y), document.removeEventListener("mouseup", this._boundMouseUp);
|
|
3614
3967
|
}
|
|
3615
|
-
onDocumentMouseUp() {
|
|
3616
|
-
|
|
3968
|
+
onDocumentMouseUp(e) {
|
|
3969
|
+
const { x: t, y: s } = this.getMouseRelative(e);
|
|
3970
|
+
this._hitManager.dispatchMouseUp(t, s), document.removeEventListener("mouseup", this._boundMouseUp), document.removeEventListener("mousemove", this._boundMouseMove);
|
|
3617
3971
|
}
|
|
3618
3972
|
onMouseMove(e) {
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
const l = dr(t, n, this._model);
|
|
3627
|
-
if (l && (!this._hoveredCandle || this._hoveredCandle.candle !== l)) {
|
|
3628
|
-
const c = s.map(l.open_time), d = o.map(l.high) - 4;
|
|
3629
|
-
this._hoveredCandle = { candle: l, x: c, y: d }, this._model.eventBus.emit("hover_nodata_candle", { x: c, y: d });
|
|
3630
|
-
}
|
|
3631
|
-
!l && this._hoveredCandle && (this._hoveredCandle = null, this._model.eventBus.emit("leave_nodata_candle"));
|
|
3632
|
-
} else
|
|
3633
|
-
this._hoveredCandle = null, this._view.guideMarkers.hide(), this._model.eventBus.emit("leave_nodata_candle");
|
|
3634
|
-
}
|
|
3635
|
-
onMouseLeave() {
|
|
3636
|
-
this._activeZone = null, this._hoveredCandle = null, this._view.guideMarkers.hide(), this._model.eventBus.emit("leave_nodata_candle");
|
|
3973
|
+
var n;
|
|
3974
|
+
if (!this._hitManager.isDragging) {
|
|
3975
|
+
const { x: o, y: l } = this.getMouseRelative(e);
|
|
3976
|
+
this._hitManager.dispatchMouseMove(o, l);
|
|
3977
|
+
}
|
|
3978
|
+
const { x: t, y: s } = this.getMouseRelative(e), r = this._hitManager.hitTestAll(t, s);
|
|
3979
|
+
(n = r[0]) != null && n.type && (r[0].type === "area" ? this._view.mainCanvas.node.style.cursor = "crosshair" : r[0].type === "trade-label" ? this._view.mainCanvas.node.style.cursor = "pointer" : r[0].type === "x-axis" ? this._view.mainCanvas.node.style.cursor = "ew-resize" : r[0].type === "y-axis" ? this._view.mainCanvas.node.style.cursor = "ns-resize" : this._view.mainCanvas.node.style.cursor = "default");
|
|
3637
3980
|
}
|
|
3638
3981
|
onWheel(e) {
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
m(this, "_controller");
|
|
3650
|
-
const c = document.querySelector(e);
|
|
3651
|
-
if (!c) throw new Error(`Element with selector "${e}" not found!`);
|
|
3982
|
+
e.preventDefault(), this._hitManager.dispatchWheel(e.offsetX, e.offsetY, e.deltaX, e.deltaY, e.deltaZ);
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
class Dr {
|
|
3986
|
+
constructor(e, { chartId: t, candles: s, config: r, trade: n, userMarkers: o, colorScheme: l }) {
|
|
3987
|
+
g(this, "_model");
|
|
3988
|
+
g(this, "_view");
|
|
3989
|
+
g(this, "_controller");
|
|
3990
|
+
const h = document.querySelector(e);
|
|
3991
|
+
if (!h) throw new Error(`Element with selector "${e}" not found!`);
|
|
3652
3992
|
if (!t || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t))
|
|
3653
3993
|
throw new Error(
|
|
3654
3994
|
"chartId is required and must be a valid id (only letters, numbers or underscores. The first character must be a letter)"
|
|
3655
3995
|
);
|
|
3656
|
-
this._model = new
|
|
3996
|
+
this._model = new bn({
|
|
3657
3997
|
chartId: t,
|
|
3658
|
-
candles:
|
|
3998
|
+
candles: s,
|
|
3659
3999
|
config: r,
|
|
3660
|
-
container:
|
|
3661
|
-
trade:
|
|
4000
|
+
container: h,
|
|
4001
|
+
trade: n,
|
|
3662
4002
|
userMarkers: o,
|
|
3663
4003
|
colorScheme: l
|
|
3664
|
-
}), this._view = new
|
|
4004
|
+
}), this._view = new lr(h), this._controller = new Sr(this._model, this._view), this._controller.init();
|
|
3665
4005
|
}
|
|
3666
4006
|
updateConfig(e) {
|
|
3667
4007
|
this._model.updateConfig(e);
|
|
@@ -3680,7 +4020,7 @@ class pr {
|
|
|
3680
4020
|
}
|
|
3681
4021
|
}
|
|
3682
4022
|
export {
|
|
3683
|
-
|
|
3684
|
-
|
|
4023
|
+
Dr as CandlestickChart,
|
|
4024
|
+
Er as createLineChart
|
|
3685
4025
|
};
|
|
3686
4026
|
//# sourceMappingURL=charts-core.js.map
|