charts-core 1.0.10 → 1.0.11
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 +216 -207
- package/dist/charts-core.js.map +1 -1
- package/dist/charts-core.umd.cjs +2 -2
- package/dist/charts-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/charts-core.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import * as x from "d3";
|
|
2
2
|
const P = (e) => {
|
|
3
|
-
const { svg: t, config: r, y: a, width: n } = e, { margin: s, yAxis: o } = r, { customTicks:
|
|
4
|
-
if (!
|
|
5
|
-
t.append("g").attr("transform", `translate(${n - s.right},0)`).call((
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
const f = Number(m), y = (
|
|
3
|
+
const { svg: t, config: r, y: a, width: n } = e, { margin: s, yAxis: o } = r, { customTicks: c, tickFormat: d, tickValues: i, ticks: l, isShow: g } = o;
|
|
4
|
+
if (!g) return null;
|
|
5
|
+
t.append("g").attr("transform", `translate(${n - s.right},0)`).call((u) => {
|
|
6
|
+
let h = x.axisRight(a);
|
|
7
|
+
c && d ? h = h.tickFormat(d) : h = h.tickFormat((m) => {
|
|
8
|
+
const f = Number(m), y = (w) => w.toString().replace(/\.0+$/, "");
|
|
9
9
|
return Math.abs(f) >= 1e12 ? y(f / 1e12) + "T" : Math.abs(f) >= 1e9 ? y(f / 1e9) + "B" : Math.abs(f) >= 1e6 ? y(f / 1e6) + "M" : Math.abs(f) >= 1e3 ? y(f / 1e3) + "K" : y(f);
|
|
10
|
-
}),
|
|
11
|
-
}).call((
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
}).call((
|
|
10
|
+
}), c && l && (h = Array.isArray(l) ? h.ticks(...l) : h.ticks(l)), c && i && (h = h.tickValues(i)), u.call(h);
|
|
11
|
+
}).call((u) => {
|
|
12
|
+
let h = [];
|
|
13
|
+
u.selectAll(".tick").each((m) => h.push(m)), e.yTicks = h;
|
|
14
|
+
}).call((u) => u.select(".domain").remove()).call((u) => u.selectAll(".tick line").remove()).call((u) => {
|
|
15
|
+
const h = u.selectAll(".tick text");
|
|
16
|
+
h.classed("sc-charts__y-axis-tick", !0).attr("text-anchor", "start");
|
|
17
|
+
const m = h.nodes().map((y) => y.getBBox().width), f = Math.max(...m);
|
|
18
|
+
u.selectAll(".tick").each(function(y, w) {
|
|
19
|
+
var A;
|
|
20
|
+
const p = x.select(this), v = p.select("text"), N = m[w], C = f - N, M = p.append("g").attr("transform", "translate(10, 0)");
|
|
21
|
+
v.attr("x", C), v.remove(), (A = M.node()) == null || A.appendChild(v.node());
|
|
22
|
+
});
|
|
23
|
+
}).attr("font-family", "inherit");
|
|
15
24
|
}, W = (e) => {
|
|
16
|
-
const { svg: t, config: r, x: a, height: n } = e, { margin: s, xAxis: o } = r, { isShow:
|
|
17
|
-
if (!
|
|
18
|
-
t.append("g").attr("transform", `translate(0,${n - s.bottom})`).call((
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
}).call((
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
}).call((
|
|
25
|
+
const { svg: t, config: r, x: a, height: n } = e, { margin: s, xAxis: o } = r, { isShow: c, tickValues: d, tickFormat: i, customTicks: l, ticks: g } = o;
|
|
26
|
+
if (!c) return null;
|
|
27
|
+
t.append("g").attr("transform", `translate(0,${n - s.bottom})`).call((u) => {
|
|
28
|
+
let h = x.axisBottom(a);
|
|
29
|
+
l ? (i && (h = h.tickFormat(i)), g && (h = Array.isArray(g) ? h.ticks(...g) : h.ticks(g)), d && (h = h.tickValues(d))) : h.ticks(5), u.call(h);
|
|
30
|
+
}).call((u) => u.select(".domain").remove()).call((u) => {
|
|
31
|
+
let h = [];
|
|
32
|
+
u.selectAll(".tick").each((m) => h.push(m)), e.xTicks = h;
|
|
33
|
+
}).call((u) => u.selectAll(".tick line").remove()).call((u) => u.selectAll(".tick text").classed("sc-charts__x-axis-tick", !0)).attr("font-family", "inherit");
|
|
25
34
|
}, X = (e) => {
|
|
26
35
|
const { svg: t, config: r, y: a, width: n } = e, {
|
|
27
36
|
margin: s,
|
|
@@ -29,8 +38,8 @@ const P = (e) => {
|
|
|
29
38
|
} = r;
|
|
30
39
|
if (o !== "none") {
|
|
31
40
|
if (o.startsWith("zero-line")) {
|
|
32
|
-
const
|
|
33
|
-
o === "zero-line-dashed" &&
|
|
41
|
+
const c = t.append("line").attr("x1", 0 + s.left).attr("x2", n - s.right).attr("y1", a(0)).attr("y2", a(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
42
|
+
o === "zero-line-dashed" && c.attr("stroke-dasharray", "4 4");
|
|
34
43
|
}
|
|
35
44
|
o.startsWith("every-line") && (e.yTicks || a.ticks()).forEach((d) => {
|
|
36
45
|
const i = t.append("line").attr("x1", 0 + s.left).attr("x2", n - s.right).attr("y1", a(d)).attr("y2", a(d)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
@@ -78,35 +87,35 @@ function V(e, t, r, a) {
|
|
|
78
87
|
return s < r ? r : o > a ? a - e.width : t - n;
|
|
79
88
|
}
|
|
80
89
|
const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).attr("x2", r).attr("y1", a).attr("y2", n).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1), K = (e) => {
|
|
81
|
-
const { svg: t, config: r, x: a, y: n, height: s, data: o, wrapperNode:
|
|
90
|
+
const { svg: t, config: r, x: a, y: n, height: s, data: o, wrapperNode: c } = e, {
|
|
82
91
|
margin: d,
|
|
83
|
-
grid: { verticalStyle: i, tooltipNode:
|
|
92
|
+
grid: { verticalStyle: i, tooltipNode: l, hoverCirclesRadius: g, hoverCirclesAdditionalArea: u }
|
|
84
93
|
} = r;
|
|
85
94
|
if (i !== "none" && (i.startsWith("every-line") && (e.xTicks || a.ticks()).forEach((m) => {
|
|
86
95
|
const f = t.append("line").attr("x1", a(m)).attr("x2", a(m)).attr("y1", d.top).attr("y2", s - d.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
87
96
|
i === "every-line-dashed" && f.attr("stroke-dasharray", "4 4");
|
|
88
97
|
}), i === "hovered-circles")) {
|
|
89
|
-
const
|
|
90
|
-
D(t, { x1: m, x2: f, y1:
|
|
91
|
-
const { tooltipContainer: y, tooltip:
|
|
92
|
-
o.forEach((
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const G = U(t,
|
|
96
|
-
x:
|
|
97
|
-
y:
|
|
98
|
-
r:
|
|
99
|
-
hr:
|
|
98
|
+
const h = n.range()[0], m = a(o[0].date), f = a(o[o.length - 1].date);
|
|
99
|
+
D(t, { x1: m, x2: f, y1: h, y2: h });
|
|
100
|
+
const { tooltipContainer: y, tooltip: w, tooltipArrow: p } = J(c);
|
|
101
|
+
o.forEach((v, N) => {
|
|
102
|
+
const C = a(v.date), M = n(v.value), A = o[N - 1], k = N > 0 && A && v.value === A.value;
|
|
103
|
+
k || D(t, { x1: C, x2: C, y1: M, y2: h });
|
|
104
|
+
const G = U(t, k, {
|
|
105
|
+
x: C,
|
|
106
|
+
y: h,
|
|
107
|
+
r: g,
|
|
108
|
+
hr: u
|
|
100
109
|
});
|
|
101
|
-
|
|
102
|
-
Q(
|
|
103
|
-
const H =
|
|
110
|
+
l && G.on("mouseover", function() {
|
|
111
|
+
Q(w), y.style.display = "block", w.append(l({ date: v.date, value: k ? null : v.value }));
|
|
112
|
+
const H = w.getBoundingClientRect(), O = V(
|
|
104
113
|
H,
|
|
105
|
-
a(
|
|
114
|
+
a(v.date),
|
|
106
115
|
e.config.margin.left - e.config.grid.tooltipArrowSize,
|
|
107
116
|
e.width - e.config.margin.right + e.config.grid.tooltipArrowSize
|
|
108
117
|
);
|
|
109
|
-
|
|
118
|
+
w.style.left = O + "px", p.style.left = a(v.date) + "px";
|
|
110
119
|
}).on("mouseout", function() {
|
|
111
120
|
y.style.display = "none";
|
|
112
121
|
});
|
|
@@ -122,7 +131,7 @@ const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).
|
|
|
122
131
|
return a.empty() && (a = e.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", t)), a.attr("x1", r.x1).attr("y1", r.x2).attr("x2", r.y1).attr("y2", r.y2), r.stops.forEach(({ offset: n, stopColor: s }) => {
|
|
123
132
|
a.append("stop").attr("offset", n).attr("stop-color", s);
|
|
124
133
|
}), a;
|
|
125
|
-
},
|
|
134
|
+
}, $ = (e) => {
|
|
126
135
|
const t = x.select(e).select("defs");
|
|
127
136
|
return t.empty() ? x.select(e).append("defs") : t;
|
|
128
137
|
}, Y = (e) => {
|
|
@@ -167,7 +176,7 @@ const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).
|
|
|
167
176
|
...t == null ? void 0 : t.selection
|
|
168
177
|
}
|
|
169
178
|
}), j = (e, t = {}) => {
|
|
170
|
-
const r = e.node(), a =
|
|
179
|
+
const r = e.node(), a = $(r), n = (c, d) => T(a, c, {
|
|
171
180
|
x1: "0%",
|
|
172
181
|
y1: "0%",
|
|
173
182
|
x2: "0%",
|
|
@@ -182,11 +191,11 @@ const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).
|
|
|
182
191
|
n("gradient-range-borders-up", "var(--sc-color-selection-up)"), n("gradient-range-borders-down", "var(--sc-color-selection-down)");
|
|
183
192
|
const s = "sc-charts__border-range-line", o = e.append("line").classed(s, !0).style("display", t.hidden ? "none" : "block");
|
|
184
193
|
return {
|
|
185
|
-
className(
|
|
186
|
-
|
|
194
|
+
className(c, d) {
|
|
195
|
+
c === "remove" ? o.classed(`${s}${d}`, !1) : o.classed(`${s}${d}`, !0);
|
|
187
196
|
},
|
|
188
|
-
update({ x1:
|
|
189
|
-
|
|
197
|
+
update({ x1: c, x2: d, y1: i, y2: l, hidden: g }) {
|
|
198
|
+
c !== void 0 && o.attr("x1", c), d !== void 0 && o.attr("x2", d), i !== void 0 && o.attr("y1", i), l !== void 0 && o.attr("y2", l), g !== void 0 && o.style("display", g ? "none" : "block");
|
|
190
199
|
},
|
|
191
200
|
destroy() {
|
|
192
201
|
o.remove();
|
|
@@ -198,16 +207,16 @@ const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).
|
|
|
198
207
|
className(n, s) {
|
|
199
208
|
n === "remove" ? r.classed(`${a}${s}`, !1) : r.classed(`${a}${s}`, !0);
|
|
200
209
|
},
|
|
201
|
-
update({ cx: n, cy: s, hidden: o, fill:
|
|
202
|
-
n !== void 0 && r.attr("cx", n), s !== void 0 && r.attr("cy", s),
|
|
210
|
+
update({ cx: n, cy: s, hidden: o, fill: c }) {
|
|
211
|
+
n !== void 0 && r.attr("cx", n), s !== void 0 && r.attr("cy", s), c !== void 0 && r.attr("fill", c), o !== void 0 && r.style("display", o ? "none" : "block");
|
|
203
212
|
},
|
|
204
213
|
destroy() {
|
|
205
214
|
r.remove();
|
|
206
215
|
}
|
|
207
216
|
};
|
|
208
217
|
}, te = (e, t = {}) => {
|
|
209
|
-
const r = "sc-charts__hover-line", a = e.append("line").style("display", t.hidden ? "none" : "block").classed(r, !0), n = e.node(), s =
|
|
210
|
-
return ((
|
|
218
|
+
const r = "sc-charts__hover-line", a = e.append("line").style("display", t.hidden ? "none" : "block").classed(r, !0), n = e.node(), s = $(n);
|
|
219
|
+
return ((c, d) => T(s, c, {
|
|
211
220
|
x1: "0%",
|
|
212
221
|
y1: "0%",
|
|
213
222
|
x2: "0%",
|
|
@@ -219,62 +228,62 @@ const D = (e, { x1: t, x2: r, y1: a, y2: n }) => e.append("line").attr("x1", t).
|
|
|
219
228
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
220
229
|
]
|
|
221
230
|
}))("hover-line-gradient", "var(--sc-color-hover-line)"), {
|
|
222
|
-
className(
|
|
223
|
-
|
|
231
|
+
className(c, d) {
|
|
232
|
+
c === "remove" ? a.classed(`${r}${d}`, !1) : a.classed(`${r}${d}`, !0);
|
|
224
233
|
},
|
|
225
|
-
update({ x1:
|
|
226
|
-
|
|
234
|
+
update({ x1: c, x2: d, y1: i, y2: l, hidden: g }) {
|
|
235
|
+
c !== void 0 && a.attr("x1", c), d !== void 0 && a.attr("x2", d), i !== void 0 && a.attr("y1", i), l !== void 0 && a.attr("y2", l), g !== void 0 && a.style("display", g ? "none" : "block");
|
|
227
236
|
},
|
|
228
237
|
destroy() {
|
|
229
238
|
a.remove();
|
|
230
239
|
}
|
|
231
240
|
};
|
|
232
|
-
},
|
|
241
|
+
}, b = "sc-charts__range-tooltip", F = x.timeFormat("%b %e, %I:%M %p"), re = (e) => {
|
|
233
242
|
const t = x.format(",.2f");
|
|
234
243
|
return `${e < 0 ? "-" : ""}$${t(Math.abs(e))}`;
|
|
235
244
|
};
|
|
236
245
|
function ae(e) {
|
|
237
246
|
const t = "http://www.w3.org/2000/svg", r = document.createElement("div");
|
|
238
|
-
r.className =
|
|
247
|
+
r.className = b, r.style.position = "absolute", r.style.top = "0", r.style.pointerEvents = "none", r.style.display = "none", e.append(r);
|
|
239
248
|
const a = document.createElement("div");
|
|
240
|
-
a.className = `${
|
|
249
|
+
a.className = `${b}-container`, r.append(a);
|
|
241
250
|
const n = document.createElement("div");
|
|
242
|
-
n.className = `${
|
|
251
|
+
n.className = `${b}-sum`, a.append(n);
|
|
243
252
|
const s = document.createElement("div");
|
|
244
|
-
s.className = `${
|
|
253
|
+
s.className = `${b}-sum-icon`;
|
|
245
254
|
const o = document.createElementNS(t, "svg");
|
|
246
255
|
o.setAttribute("width", "14"), o.setAttribute("height", "14"), o.setAttribute("viewBox", "0 0 14 14"), o.setAttribute("fill", "none"), o.setAttribute("xmlns", t);
|
|
247
|
-
const
|
|
248
|
-
|
|
256
|
+
const c = document.createElementNS(t, "path");
|
|
257
|
+
c.setAttribute(
|
|
249
258
|
"d",
|
|
250
259
|
"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"
|
|
251
|
-
),
|
|
260
|
+
), c.setAttribute("fill", "currentColor"), o.appendChild(c), s.appendChild(o), n.append(s);
|
|
252
261
|
const d = document.createElement("div");
|
|
253
262
|
n.append(d);
|
|
254
263
|
const i = document.createElement("div");
|
|
255
|
-
return i.className = `${
|
|
264
|
+
return i.className = `${b}-time`, a.append(i), { wrapper: r, sumNode: d, timeNode: i };
|
|
256
265
|
}
|
|
257
266
|
const se = (e) => {
|
|
258
267
|
const { wrapper: t, sumNode: r, timeNode: a } = ae(e.wrapperNode);
|
|
259
268
|
return {
|
|
260
269
|
className(n, s) {
|
|
261
|
-
n === "remove" ? t.classList.remove(`${
|
|
270
|
+
n === "remove" ? t.classList.remove(`${b}${s}`) : t.classList.add(`${b}${s}`);
|
|
262
271
|
},
|
|
263
|
-
update({ leftPoint: n, rightPoint: s, x: o, y:
|
|
272
|
+
update({ leftPoint: n, rightPoint: s, x: o, y: c, hidden: d, closest: i }) {
|
|
264
273
|
if (n && s && i && o !== void 0) {
|
|
265
|
-
const
|
|
274
|
+
const l = s.value - n.value, { sumFormatter: g, timeFormatter: u } = e.config.selection, h = (e.x(s.date) + e.x(n.date)) / 2, m = e.x(i.date) < h ? "left" : "right";
|
|
266
275
|
let f = "", y = "";
|
|
267
|
-
if (
|
|
268
|
-
f =
|
|
276
|
+
if (g)
|
|
277
|
+
f = g({ left: n.value, right: s.value, direction: m });
|
|
269
278
|
else {
|
|
270
|
-
const
|
|
271
|
-
f = `${re(
|
|
279
|
+
const w = (l / Math.abs(n.value) * 100).toFixed(2);
|
|
280
|
+
f = `${re(l)} (${w}%)`;
|
|
272
281
|
}
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
let M = (
|
|
276
|
-
const
|
|
277
|
-
M <
|
|
282
|
+
u ? y = u({ left: n.date, right: s.date, direction: m }) : y = `${F(n.date)} to ${F(s.date)}`, r.textContent = f, a.textContent = y, requestAnimationFrame(() => {
|
|
283
|
+
const w = t.getBoundingClientRect(), p = e.wrapperNode.getBoundingClientRect(), v = e.x(n.date), N = e.x(s.date);
|
|
284
|
+
let M = (v + N) / 2 - w.width / 2;
|
|
285
|
+
const A = 0, k = p.width - w.width;
|
|
286
|
+
M < A && (M = A), M > k && (M = k), t.style.left = `${M}px`, t.style.top = `${c}px`;
|
|
278
287
|
});
|
|
279
288
|
}
|
|
280
289
|
d !== void 0 && (t.style.display = d ? "none" : "block");
|
|
@@ -295,10 +304,10 @@ function ie(e) {
|
|
|
295
304
|
const a = document.createElement("div");
|
|
296
305
|
return a.className = `${L}-time`, t.appendChild(a), { wrapper: t, sumNode: r, timeNode: a };
|
|
297
306
|
}
|
|
298
|
-
function
|
|
307
|
+
function ce(e, t, r) {
|
|
299
308
|
return e ? t + E + e.width < r ? t + E : t - E - e.width : null;
|
|
300
309
|
}
|
|
301
|
-
const
|
|
310
|
+
const le = (e) => {
|
|
302
311
|
const { wrapper: t, sumNode: r, timeNode: a } = ie(e.wrapperNode);
|
|
303
312
|
return {
|
|
304
313
|
className(n, s) {
|
|
@@ -306,9 +315,9 @@ const ce = (e) => {
|
|
|
306
315
|
},
|
|
307
316
|
update({ hidden: n, dataItem: s }) {
|
|
308
317
|
if (s) {
|
|
309
|
-
const { sumFormatter: o, timeFormatter:
|
|
310
|
-
r.textContent = o ? o(s.value) : ne(s.value), a.textContent =
|
|
311
|
-
const d = t.getBoundingClientRect(), i =
|
|
318
|
+
const { sumFormatter: o, timeFormatter: c } = e.config.hover;
|
|
319
|
+
r.textContent = o ? o(s.value) : ne(s.value), a.textContent = c ? c(s.date) : oe(s.date), requestAnimationFrame(() => {
|
|
320
|
+
const d = t.getBoundingClientRect(), i = ce(
|
|
312
321
|
d,
|
|
313
322
|
e.x(s.date),
|
|
314
323
|
e.width - e.config.margin.right
|
|
@@ -374,8 +383,8 @@ const ce = (e) => {
|
|
|
374
383
|
enableBelowZeroLine: !1,
|
|
375
384
|
curveTension: 1
|
|
376
385
|
}, _ = (e) => x.curveCardinal.tension(e.config.curveTension), he = (e) => {
|
|
377
|
-
const { svg: t, data: r, x: a, y: n, config: s } = e, o = t.node(),
|
|
378
|
-
T(
|
|
386
|
+
const { svg: t, data: r, x: a, y: n, config: s } = e, o = t.node(), c = $(o);
|
|
387
|
+
T(c, "main-line-area-gradient", {
|
|
379
388
|
x1: "0%",
|
|
380
389
|
y1: "0%",
|
|
381
390
|
x2: "0%",
|
|
@@ -385,24 +394,24 @@ const ce = (e) => {
|
|
|
385
394
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
386
395
|
]
|
|
387
396
|
});
|
|
388
|
-
const i = x.area().x((
|
|
397
|
+
const i = x.area().x((u) => a(u.date)).y0(n.range()[0]).y1((u) => n(u.value)).curve(_(e)), l = "sc-charts__main-line-area", g = t.append("path").datum(r).attr("d", i).attr("class", l).classed(`${l}_hidden`, !s.hasMainLineArea);
|
|
389
398
|
return {
|
|
390
|
-
className(
|
|
391
|
-
|
|
399
|
+
className(u, h) {
|
|
400
|
+
u === "remove" ? g.classed(`${l}${h}`, !1) : g.classed(`${l}${h}`, !0);
|
|
392
401
|
},
|
|
393
|
-
update({ data:
|
|
394
|
-
if (
|
|
402
|
+
update({ data: u, hidden: h }) {
|
|
403
|
+
if (u !== void 0 && g.datum(u).attr("d", i), h !== void 0) {
|
|
395
404
|
if (!s.hasMainLineArea) return null;
|
|
396
|
-
|
|
405
|
+
g.classed(`${l}_hidden`, h);
|
|
397
406
|
}
|
|
398
407
|
},
|
|
399
408
|
destroy() {
|
|
400
|
-
|
|
409
|
+
g.remove();
|
|
401
410
|
}
|
|
402
411
|
};
|
|
403
412
|
}, ue = (e, t = {}) => {
|
|
404
|
-
const r = "sc-charts__range-line-area", { svg: a, x: n, y: s, config: o, data:
|
|
405
|
-
T(
|
|
413
|
+
const r = "sc-charts__range-line-area", { svg: a, x: n, y: s, config: o, data: c, chartId: d } = e, { clip: i } = t, l = a.node(), g = $(l), u = "range-line-area-gradient";
|
|
414
|
+
T(g, u + "_up", {
|
|
406
415
|
x1: "0%",
|
|
407
416
|
y1: "0%",
|
|
408
417
|
x2: "0%",
|
|
@@ -411,7 +420,7 @@ const ce = (e) => {
|
|
|
411
420
|
{ offset: "0%", stopColor: "var(--sc-color-selection-up)" },
|
|
412
421
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
413
422
|
]
|
|
414
|
-
}), T(
|
|
423
|
+
}), T(g, u + "_down", {
|
|
415
424
|
x1: "0%",
|
|
416
425
|
y1: "0%",
|
|
417
426
|
x2: "0%",
|
|
@@ -421,42 +430,42 @@ const ce = (e) => {
|
|
|
421
430
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
422
431
|
]
|
|
423
432
|
});
|
|
424
|
-
const
|
|
433
|
+
const h = x.area().x((p) => n(p.date)).y0(s.range()[0]).y1((p) => s(p.value)).curve(_(e)), m = `${d}-clip-${r}`, y = g.append("clipPath").attr("id", m).append("rect").attr("x", (i == null ? void 0 : i.x) || 0).attr("y", (i == null ? void 0 : i.y) || 0).attr("width", (i == null ? void 0 : i.width) || "100%").attr("height", (i == null ? void 0 : i.height) || "100%"), w = a.append("path").datum(c).attr("d", h).attr("class", r).classed(`${r}_hidden`, !o.hasMainLineArea).attr("clip-path", `url(#${m})`);
|
|
425
434
|
return {
|
|
426
|
-
className(
|
|
427
|
-
|
|
435
|
+
className(p, v) {
|
|
436
|
+
p === "remove" ? w.classed(`${r}${v}`, !1) : w.classed(`${r}${v}`, !0);
|
|
428
437
|
},
|
|
429
|
-
update({ data:
|
|
430
|
-
|
|
438
|
+
update({ data: p, hidden: v, clip: N }) {
|
|
439
|
+
p !== void 0 && w.datum(p).attr("d", h), v !== void 0 && w.classed(`${r}_hidden`, v), N !== void 0 && y.attr("x", N.x).attr("y", N.y).attr("width", N.width).attr("height", N.height);
|
|
431
440
|
},
|
|
432
441
|
destroy() {
|
|
433
|
-
|
|
442
|
+
w.remove();
|
|
434
443
|
}
|
|
435
444
|
};
|
|
436
445
|
}, S = (e, t) => {
|
|
437
|
-
const { svg: r, data: a, x: n, y: s, chartId: o } = e, { baseClassName:
|
|
446
|
+
const { svg: r, data: a, x: n, y: s, chartId: o } = e, { baseClassName: c, id: d, clip: i } = t, l = r.node(), g = $(l), u = x.line().x((w) => n(w.date)).y((w) => s(w.value)).curve(_(e)), h = `${o}-clip-${c}`, f = g.append("clipPath").attr("id", h).append("rect").attr("x", (i == null ? void 0 : i.x) || 0).attr("y", (i == null ? void 0 : i.y) || 0).attr("width", (i == null ? void 0 : i.width) || "100%").attr("height", (i == null ? void 0 : i.height) || "100%"), y = r.append("path").classed(c, !0).datum(a).attr("d", u).attr("id", d).attr("clip-path", `url(#${h})`);
|
|
438
447
|
return {
|
|
439
|
-
className(
|
|
440
|
-
|
|
448
|
+
className(w, p) {
|
|
449
|
+
w === "remove" ? y.classed(`${c}${p}`, !1) : y.classed(`${c}${p}`, !0);
|
|
441
450
|
},
|
|
442
|
-
update({ data:
|
|
443
|
-
|
|
451
|
+
update({ data: w, clip: p, hidden: v }) {
|
|
452
|
+
w !== void 0 && y.datum(w).attr("d", u), v !== void 0 && y.classed(`${c}_hidden`, v), p !== void 0 && f.attr("x", p.x).attr("y", p.y).attr("width", p.width).attr("height", p.height);
|
|
444
453
|
},
|
|
445
454
|
destroy() {
|
|
446
455
|
y.remove();
|
|
447
456
|
}
|
|
448
457
|
};
|
|
449
458
|
}, ge = (e, t) => {
|
|
450
|
-
const { svg: r, data: a, x: n, y: s, chartId: o, config:
|
|
459
|
+
const { svg: r, data: a, x: n, y: s, chartId: o, config: c } = e, { baseClassName: d, id: i, clip: l } = t, g = r.node(), u = $(g), h = x.line().x((p) => n(p.date)).y((p) => s(p.value)).curve(_(e)), m = `${o}-clip-${d}`, y = u.append("clipPath").attr("id", m).append("rect").attr("x", (l == null ? void 0 : l.x) || 0).attr("y", (l == null ? void 0 : l.y) || 0).attr("width", (l == null ? void 0 : l.width) || "100%").attr("height", (l == null ? void 0 : l.height) || "100%"), w = r.append("path").classed(d, !0).datum(a).attr("d", h).attr("id", i).attr("clip-path", `url(#${m})`);
|
|
451
460
|
return {
|
|
452
|
-
className(
|
|
453
|
-
|
|
461
|
+
className(p, v) {
|
|
462
|
+
p === "remove" ? w.classed(`${d}${v}`, !1) : w.classed(`${d}${v}`, !0);
|
|
454
463
|
},
|
|
455
|
-
update({ data:
|
|
456
|
-
|
|
464
|
+
update({ data: p, clip: v, hidden: N }) {
|
|
465
|
+
p !== void 0 && w.datum(p).attr("d", h), N !== void 0 && w.classed(`${d}_hidden`, N), v !== void 0 && (c.hover.transitionName === "default" ? y.transition().duration(c.hover.transitionDuration).attr("x", v.x).attr("y", v.y).attr("width", v.width).attr("height", v.height).ease(x.easeLinear) : y.attr("x", v.x).attr("y", v.y).attr("width", v.width).attr("height", v.height));
|
|
457
466
|
},
|
|
458
467
|
destroy() {
|
|
459
|
-
|
|
468
|
+
w.remove();
|
|
460
469
|
}
|
|
461
470
|
};
|
|
462
471
|
}, me = (e) => {
|
|
@@ -464,22 +473,22 @@ const ce = (e) => {
|
|
|
464
473
|
let r;
|
|
465
474
|
return t >= 1e9 ? r = (e / 1e9).toFixed(1) + "B" : t >= 1e6 ? r = (e / 1e6).toFixed(1) + "M" : t >= 1e3 ? r = (e / 1e3).toFixed(1) + "K" : r = e.toFixed(1), r;
|
|
466
475
|
}, fe = (e, t) => {
|
|
467
|
-
const { svg: r, data: a, x: n, y: s } = e, { baseClassName: o } = t,
|
|
468
|
-
return ((
|
|
469
|
-
if (!
|
|
470
|
-
const
|
|
471
|
-
d.attr("cx",
|
|
476
|
+
const { svg: r, data: a, x: n, y: s } = e, { baseClassName: o } = t, c = r.append("g").classed(o, !0), d = c.append("circle").attr("r", 5).classed(`${o}-circle`, !0), i = c.append("text").attr("text-anchor", "middle").attr("dy", "-9px").classed(`${o}-label`, !0);
|
|
477
|
+
return ((g) => {
|
|
478
|
+
if (!g || g.length === 0) return;
|
|
479
|
+
const u = g[g.length - 1], h = n(u.date), m = s(u.value);
|
|
480
|
+
d.attr("cx", h).attr("cy", m);
|
|
472
481
|
const f = e.config.extremePointFormatter || me;
|
|
473
|
-
i.attr("x",
|
|
482
|
+
i.attr("x", h).attr("y", m).text(f(u.value));
|
|
474
483
|
})(a), {
|
|
475
|
-
className(
|
|
476
|
-
|
|
484
|
+
className(g, u) {
|
|
485
|
+
g === "remove" ? c.classed(`${o}${u}`, !1) : c.classed(`${o}${u}`, !0);
|
|
477
486
|
},
|
|
478
|
-
update({ hidden:
|
|
479
|
-
|
|
487
|
+
update({ hidden: g }) {
|
|
488
|
+
g !== void 0 && c.classed(`${o}_hidden`, g);
|
|
480
489
|
},
|
|
481
490
|
destroy() {
|
|
482
|
-
|
|
491
|
+
c.remove();
|
|
483
492
|
}
|
|
484
493
|
};
|
|
485
494
|
}, pe = (e) => {
|
|
@@ -502,31 +511,31 @@ const ce = (e) => {
|
|
|
502
511
|
id: `${e.chartId}-sc-charts__below-zero-line`,
|
|
503
512
|
clip: Y(e)
|
|
504
513
|
}));
|
|
505
|
-
const
|
|
514
|
+
const c = I(e.svg, {
|
|
506
515
|
className: "sc-charts__hover-circle",
|
|
507
516
|
hidden: !0
|
|
508
|
-
}), d = j(e.svg), i = j(e.svg),
|
|
517
|
+
}), d = j(e.svg), i = j(e.svg), l = S(e, {
|
|
509
518
|
baseClassName: "sc-charts__range-line",
|
|
510
519
|
id: `${e.chartId}-sc-charts__range-line`,
|
|
511
520
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
512
|
-
}),
|
|
521
|
+
}), g = I(e.svg, {
|
|
513
522
|
className: "sc-charts__range-circle-left",
|
|
514
523
|
hidden: !0
|
|
515
|
-
}),
|
|
524
|
+
}), u = I(e.svg, {
|
|
516
525
|
className: "sc-charts__range-circle-right",
|
|
517
526
|
hidden: !0
|
|
518
|
-
}),
|
|
527
|
+
}), h = se(e), m = le(e), f = ue(e);
|
|
519
528
|
return {
|
|
520
529
|
hoverLine: n,
|
|
521
|
-
hoverCircle:
|
|
530
|
+
hoverCircle: c,
|
|
522
531
|
rangeBorderLeft: d,
|
|
523
532
|
rangeBorderRight: i,
|
|
524
|
-
rangeLine:
|
|
533
|
+
rangeLine: l,
|
|
525
534
|
rangeLineArea: f,
|
|
526
|
-
rangeCircleLeft:
|
|
527
|
-
rangeCircleRight:
|
|
535
|
+
rangeCircleLeft: g,
|
|
536
|
+
rangeCircleRight: u,
|
|
528
537
|
mainLine: t,
|
|
529
|
-
rangeTooltip:
|
|
538
|
+
rangeTooltip: h,
|
|
530
539
|
highlightLine: s,
|
|
531
540
|
hoverTooltip: m,
|
|
532
541
|
mainLineArea: r,
|
|
@@ -542,25 +551,25 @@ const ce = (e) => {
|
|
|
542
551
|
width: "100%",
|
|
543
552
|
height: "100%"
|
|
544
553
|
};
|
|
545
|
-
const [, n, s] = a, o = parseInt(n, 10), [
|
|
546
|
-
let i = new Date(
|
|
554
|
+
const [, n, s] = a, o = parseInt(n, 10), [c, d] = r.domain();
|
|
555
|
+
let i = new Date(c);
|
|
547
556
|
for (; i < d; ) {
|
|
548
|
-
let
|
|
557
|
+
let l = new Date(i);
|
|
549
558
|
switch (s) {
|
|
550
559
|
case "M":
|
|
551
|
-
|
|
560
|
+
l.setMinutes(l.getMinutes() + o);
|
|
552
561
|
break;
|
|
553
562
|
case "h":
|
|
554
|
-
|
|
563
|
+
l.setHours(l.getHours() + o);
|
|
555
564
|
break;
|
|
556
565
|
case "d":
|
|
557
|
-
|
|
566
|
+
l.setDate(l.getDate() + o);
|
|
558
567
|
break;
|
|
559
568
|
case "w":
|
|
560
|
-
|
|
569
|
+
l.setDate(l.getDate() + o * 7);
|
|
561
570
|
break;
|
|
562
571
|
case "m":
|
|
563
|
-
|
|
572
|
+
l = new Date(i.getFullYear(), i.getMonth() + o, 1);
|
|
564
573
|
break;
|
|
565
574
|
default:
|
|
566
575
|
return {
|
|
@@ -570,41 +579,41 @@ const ce = (e) => {
|
|
|
570
579
|
height: "100%"
|
|
571
580
|
};
|
|
572
581
|
}
|
|
573
|
-
if (t >= i && t <
|
|
574
|
-
const
|
|
582
|
+
if (t >= i && t < l) {
|
|
583
|
+
const g = r(i), u = r(l);
|
|
575
584
|
return {
|
|
576
|
-
x:
|
|
585
|
+
x: g,
|
|
577
586
|
y: 0,
|
|
578
|
-
width:
|
|
587
|
+
width: u - g,
|
|
579
588
|
height: "100%"
|
|
580
589
|
};
|
|
581
590
|
}
|
|
582
|
-
i = new Date(
|
|
591
|
+
i = new Date(l);
|
|
583
592
|
}
|
|
584
593
|
if (t.getTime() === d.getTime()) {
|
|
585
|
-
let
|
|
594
|
+
let l = new Date(d);
|
|
586
595
|
switch (s) {
|
|
587
596
|
case "M":
|
|
588
|
-
|
|
597
|
+
l.setMinutes(l.getMinutes() - o);
|
|
589
598
|
break;
|
|
590
599
|
case "h":
|
|
591
|
-
|
|
600
|
+
l.setHours(l.getHours() - o);
|
|
592
601
|
break;
|
|
593
602
|
case "d":
|
|
594
|
-
|
|
603
|
+
l.setDate(l.getDate() - o);
|
|
595
604
|
break;
|
|
596
605
|
case "w":
|
|
597
|
-
|
|
606
|
+
l.setDate(l.getDate() - o * 7);
|
|
598
607
|
break;
|
|
599
608
|
case "m":
|
|
600
|
-
|
|
609
|
+
l = new Date(d.getFullYear(), d.getMonth() - o, 1);
|
|
601
610
|
break;
|
|
602
611
|
}
|
|
603
|
-
const
|
|
612
|
+
const g = r(l), u = r(d);
|
|
604
613
|
return {
|
|
605
|
-
x:
|
|
614
|
+
x: g,
|
|
606
615
|
y: 0,
|
|
607
|
-
width:
|
|
616
|
+
width: u - g,
|
|
608
617
|
height: "100%"
|
|
609
618
|
};
|
|
610
619
|
}
|
|
@@ -637,15 +646,15 @@ const ce = (e) => {
|
|
|
637
646
|
dataItem: t,
|
|
638
647
|
hidden: !1
|
|
639
648
|
});
|
|
640
|
-
const
|
|
649
|
+
const c = ve(e.config.hover.range, t.date, r);
|
|
641
650
|
n.highlightLine.update({
|
|
642
|
-
clip:
|
|
651
|
+
clip: c,
|
|
643
652
|
hidden: !1
|
|
644
653
|
});
|
|
645
654
|
const d = a.range()[0] - a(0) + s.bottom;
|
|
646
655
|
d >= 0 && ((i = n.belowZeroLine) == null || i.update({
|
|
647
656
|
clip: {
|
|
648
|
-
...
|
|
657
|
+
...c,
|
|
649
658
|
y: a(0),
|
|
650
659
|
height: d
|
|
651
660
|
}
|
|
@@ -675,78 +684,78 @@ const ce = (e) => {
|
|
|
675
684
|
y: n,
|
|
676
685
|
config: { margin: s },
|
|
677
686
|
height: o,
|
|
678
|
-
elements:
|
|
679
|
-
} = e, d = a(t.date) < a(r.date) ? t : r, i = a(t.date) >= a(r.date) ? t : r,
|
|
680
|
-
|
|
681
|
-
x1:
|
|
682
|
-
x2:
|
|
687
|
+
elements: c
|
|
688
|
+
} = e, d = a(t.date) < a(r.date) ? t : r, i = a(t.date) >= a(r.date) ? t : r, l = i.value - d.value >= 0, g = a(d.date), u = a(i.date), h = u - g;
|
|
689
|
+
c.rangeBorderLeft.update({
|
|
690
|
+
x1: g,
|
|
691
|
+
x2: g,
|
|
683
692
|
y1: s.top,
|
|
684
693
|
y2: o - s.bottom,
|
|
685
694
|
hidden: !1
|
|
686
|
-
}),
|
|
687
|
-
x1:
|
|
688
|
-
x2:
|
|
695
|
+
}), c.rangeBorderRight.update({
|
|
696
|
+
x1: u,
|
|
697
|
+
x2: u,
|
|
689
698
|
y1: s.top,
|
|
690
699
|
y2: o - s.bottom,
|
|
691
700
|
hidden: !1
|
|
692
|
-
}),
|
|
693
|
-
cx:
|
|
701
|
+
}), c.rangeCircleLeft.update({
|
|
702
|
+
cx: g,
|
|
694
703
|
cy: n(d.value),
|
|
695
704
|
hidden: !1
|
|
696
|
-
}),
|
|
697
|
-
cx:
|
|
705
|
+
}), c.rangeCircleRight.update({
|
|
706
|
+
cx: u,
|
|
698
707
|
cy: n(i.value),
|
|
699
708
|
hidden: !1
|
|
700
|
-
}),
|
|
709
|
+
}), c.rangeLine.update({
|
|
701
710
|
clip: {
|
|
702
|
-
x:
|
|
711
|
+
x: g,
|
|
703
712
|
y: 0,
|
|
704
|
-
width:
|
|
713
|
+
width: h,
|
|
705
714
|
height: n.range()[0]
|
|
706
715
|
},
|
|
707
716
|
hidden: !1
|
|
708
|
-
}),
|
|
717
|
+
}), c.rangeLineArea.update({
|
|
709
718
|
clip: {
|
|
710
|
-
x:
|
|
719
|
+
x: g,
|
|
711
720
|
y: 0,
|
|
712
|
-
width:
|
|
721
|
+
width: h,
|
|
713
722
|
height: n.range()[0]
|
|
714
723
|
},
|
|
715
724
|
hidden: !1
|
|
716
|
-
}),
|
|
725
|
+
}), c.rangeTooltip.update({
|
|
717
726
|
rightPoint: i,
|
|
718
727
|
leftPoint: d,
|
|
719
728
|
closest: r,
|
|
720
|
-
x:
|
|
729
|
+
x: g + h / 2,
|
|
721
730
|
y: 0,
|
|
722
731
|
hidden: !1
|
|
723
|
-
}), (m =
|
|
732
|
+
}), (m = c.belowZeroLine) == null || m.update({
|
|
724
733
|
hidden: !0
|
|
725
|
-
}),
|
|
734
|
+
}), c.mainLineArea.update({ hidden: !0 }), ye(c, l), c.mainLine.className("add", "_selected-muted");
|
|
726
735
|
}, Z = (e) => {
|
|
727
736
|
var r;
|
|
728
737
|
const { elements: t } = e;
|
|
729
738
|
t.rangeLine.update({ hidden: !0 }), t.rangeLineArea.update({ hidden: !0 }), t.rangeBorderLeft.update({ hidden: !0 }), t.rangeBorderRight.update({ hidden: !0 }), t.rangeCircleLeft.update({ hidden: !0 }), t.rangeCircleRight.update({ hidden: !0 }), t.rangeTooltip.update({ hidden: !0 }), t.mainLine.className("remove", "_selected-muted"), t.mainLineArea.update({ hidden: !1 }), (r = t.belowZeroLine) == null || r.update({ hidden: !1 });
|
|
730
739
|
}, xe = (e) => {
|
|
731
|
-
const { svg: t, data: r, x: a, config: n, width: s, height: o } = e, { margin:
|
|
732
|
-
let
|
|
733
|
-
const
|
|
740
|
+
const { svg: t, data: r, x: a, config: n, width: s, height: o } = e, { margin: c, hover: d, selection: i } = n;
|
|
741
|
+
let l = null, g = !1;
|
|
742
|
+
const u = (m) => r.reduce(
|
|
734
743
|
(f, y) => Math.abs(a(f.date) - m) < Math.abs(a(y.date) - m) ? f : y
|
|
735
744
|
);
|
|
736
|
-
t.append("rect").attr("width", s -
|
|
737
|
-
const [f] = x.pointer(m, this), y =
|
|
738
|
-
!
|
|
745
|
+
t.append("rect").attr("width", s - c.left - c.right).attr("height", o - c.top - c.bottom).attr("x", c.left).attr("y", c.top).attr("fill", "transparent").on("mousemove", function(m) {
|
|
746
|
+
const [f] = x.pointer(m, this), y = u(f);
|
|
747
|
+
!g && d.enable ? (e.action = "hover", B(e, y)) : (e.action = g ? "selection" : "none", R(e)), l && i.enable && (e.action = "selection", we(e, l, y));
|
|
739
748
|
}).on("mouseleave", () => {
|
|
740
|
-
e.action = "none",
|
|
749
|
+
e.action = "none", g = !1, l = null, R(e), Z(e);
|
|
741
750
|
}).on("mousedown", function(m) {
|
|
742
751
|
if (i.enable) {
|
|
743
|
-
|
|
752
|
+
g = !0, e.action = "selection";
|
|
744
753
|
const [f] = x.pointer(m, this);
|
|
745
|
-
|
|
754
|
+
l = u(f);
|
|
746
755
|
}
|
|
747
756
|
}).on("mouseup", function(m) {
|
|
748
|
-
const [f] = x.pointer(m, this), y =
|
|
749
|
-
|
|
757
|
+
const [f] = x.pointer(m, this), y = u(f);
|
|
758
|
+
g = !1, l = null, e.action = "hover", i.enable && Z(e), d.enable && B(e, y);
|
|
750
759
|
});
|
|
751
760
|
}, Ne = (e, t, r) => {
|
|
752
761
|
const { margin: a } = t, n = x.scaleTime(), s = x.extent(e, (o) => new Date(o.date));
|
|
@@ -762,38 +771,38 @@ const ce = (e) => {
|
|
|
762
771
|
return console.error(`chartId is required and must be a valid id
|
|
763
772
|
(only letters, numbers or underscores. The first character must be a letter)`), null;
|
|
764
773
|
const a = r.append("div"), n = a.append("svg"), s = r.node();
|
|
765
|
-
let o = s.getBoundingClientRect(),
|
|
766
|
-
const
|
|
767
|
-
o = s.getBoundingClientRect(),
|
|
774
|
+
let o = s.getBoundingClientRect(), c = o.width, d = o.height, i = z({ ...de }, t.config), l = t.data;
|
|
775
|
+
const g = () => {
|
|
776
|
+
o = s.getBoundingClientRect(), c = o.width, d = o.height, u({ data: l, config: i });
|
|
768
777
|
};
|
|
769
|
-
window.addEventListener("resize",
|
|
770
|
-
const
|
|
771
|
-
m &&
|
|
772
|
-
const f =
|
|
773
|
-
a.attr("class", `sc-charts sc-charts__${i.theme}`), n.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${
|
|
774
|
-
const
|
|
778
|
+
window.addEventListener("resize", g);
|
|
779
|
+
const u = (h, m = !1) => {
|
|
780
|
+
m && h.config && (i = z(i, h.config)), m && h.data && (l = h.data);
|
|
781
|
+
const f = l.map((N) => ({ date: new Date(N.date), value: N.value })).sort((N, C) => N.date.getTime() - C.date.getTime()), y = Ne(f, i, c), w = Me(f, i, d);
|
|
782
|
+
a.attr("class", `sc-charts sc-charts__${i.theme}`), n.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${c} ${d}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
|
|
783
|
+
const p = {
|
|
775
784
|
chartId: t.chartId,
|
|
776
785
|
svg: n,
|
|
777
786
|
wrapperNode: a.node(),
|
|
778
787
|
data: f,
|
|
779
788
|
x: y,
|
|
780
|
-
y:
|
|
789
|
+
y: w,
|
|
781
790
|
config: i,
|
|
782
791
|
action: "none",
|
|
783
|
-
width:
|
|
792
|
+
width: c,
|
|
784
793
|
height: d
|
|
785
794
|
};
|
|
786
|
-
ee(
|
|
787
|
-
const
|
|
788
|
-
...
|
|
789
|
-
elements: pe(
|
|
795
|
+
ee(p);
|
|
796
|
+
const v = {
|
|
797
|
+
...p,
|
|
798
|
+
elements: pe(p)
|
|
790
799
|
};
|
|
791
|
-
xe(
|
|
800
|
+
xe(v);
|
|
792
801
|
};
|
|
793
|
-
return
|
|
794
|
-
update: (
|
|
802
|
+
return u(t), {
|
|
803
|
+
update: (h) => u(h, !0),
|
|
795
804
|
destroy: () => {
|
|
796
|
-
window.removeEventListener("resize",
|
|
805
|
+
window.removeEventListener("resize", g), n.remove();
|
|
797
806
|
}
|
|
798
807
|
};
|
|
799
808
|
};
|