charts-core 1.0.0 → 1.0.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 +278 -261
- 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,73 +1,73 @@
|
|
|
1
1
|
import * as y from "d3";
|
|
2
|
-
const
|
|
3
|
-
const { svg: t, config: a, y:
|
|
2
|
+
const G = (e) => {
|
|
3
|
+
const { svg: t, config: a, y: r } = e, { width: d, margin: n, yAxis: s } = a, { customTicks: l, tickFormat: i, tickValues: o, ticks: c, isShow: u } = s;
|
|
4
4
|
if (!u) return null;
|
|
5
|
-
t.append("g").attr("transform", `translate(${
|
|
6
|
-
let g = y.axisRight(
|
|
7
|
-
|
|
8
|
-
const x = Number(m),
|
|
9
|
-
return `${
|
|
5
|
+
t.append("g").attr("transform", `translate(${d - n.right},0)`).call((h) => {
|
|
6
|
+
let g = y.axisRight(r);
|
|
7
|
+
l ? (i && (g = g.tickFormat(i)), c && (g = Array.isArray(c) ? g.ticks(...c) : g.ticks(c)), o && (g = g.tickValues(o))) : g = g.tickFormat((m) => {
|
|
8
|
+
const x = Number(m), v = x < 0 ? "-" : "", p = y.format(".0s")(Math.abs(x));
|
|
9
|
+
return `${v}${p}`;
|
|
10
10
|
}), h.call(g);
|
|
11
11
|
}).call((h) => {
|
|
12
12
|
let g = [];
|
|
13
13
|
h.selectAll(".tick").each((m) => g.push(m)), e.yTicks = g;
|
|
14
14
|
}).call((h) => h.select(".domain").remove()).call((h) => h.selectAll(".tick line").remove()).call((h) => h.selectAll(".tick text").classed("sc-charts__y-axis-tick", !0)).attr("font-family", "inherit");
|
|
15
|
-
},
|
|
16
|
-
const { svg: t, config: a, x:
|
|
17
|
-
if (!
|
|
18
|
-
t.append("g").attr("transform", `translate(0,${
|
|
19
|
-
let g = y.axisBottom(
|
|
20
|
-
|
|
15
|
+
}, V = (e) => {
|
|
16
|
+
const { svg: t, config: a, x: r } = e, { height: d, margin: n, xAxis: s } = a, { isShow: l, tickValues: i, tickFormat: o, customTicks: c, ticks: u } = s;
|
|
17
|
+
if (!l) return null;
|
|
18
|
+
t.append("g").attr("transform", `translate(0,${d - n.bottom})`).call((h) => {
|
|
19
|
+
let g = y.axisBottom(r);
|
|
20
|
+
c ? (o && (g = g.tickFormat(o)), u && (g = Array.isArray(u) ? g.ticks(...u) : g.ticks(u)), i && (g = g.tickValues(i))) : g.ticks(5), h.call(g);
|
|
21
21
|
}).call((h) => h.select(".domain").remove()).call((h) => {
|
|
22
22
|
let g = [];
|
|
23
23
|
h.selectAll(".tick").each((m) => g.push(m)), e.xTicks = g;
|
|
24
24
|
}).call((h) => h.selectAll(".tick line").remove()).call((h) => h.selectAll(".tick text").classed("sc-charts__x-axis-tick", !0)).attr("font-family", "inherit");
|
|
25
|
-
},
|
|
26
|
-
const { svg: t, config: a, y:
|
|
27
|
-
width:
|
|
28
|
-
margin:
|
|
29
|
-
grid: { horizontalStyle:
|
|
25
|
+
}, Z = (e) => {
|
|
26
|
+
const { svg: t, config: a, y: r } = e, {
|
|
27
|
+
width: d,
|
|
28
|
+
margin: n,
|
|
29
|
+
grid: { horizontalStyle: s }
|
|
30
30
|
} = a;
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
if (s !== "none") {
|
|
32
|
+
if (s.startsWith("zero-line")) {
|
|
33
|
+
const l = t.append("line").attr("x1", 0 + n.left).attr("x2", d - n.right).attr("y1", r(0)).attr("y2", r(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
34
|
+
s === "zero-line-dashed" && l.attr("stroke-dasharray", "4 4");
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
s.startsWith("every-line") && (e.yTicks || r.ticks()).forEach((i) => {
|
|
37
|
+
const o = t.append("line").attr("x1", 0 + n.left).attr("x2", d - n.right).attr("y1", r(i)).attr("y2", r(i)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
38
|
+
s === "every-line-dashed" && o.attr("stroke-dasharray", "4 4");
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
},
|
|
42
|
-
const { svg: t, config: a, x:
|
|
43
|
-
height:
|
|
44
|
-
margin:
|
|
45
|
-
grid: { verticalStyle:
|
|
41
|
+
}, H = (e) => {
|
|
42
|
+
const { svg: t, config: a, x: r } = e, {
|
|
43
|
+
height: d,
|
|
44
|
+
margin: n,
|
|
45
|
+
grid: { verticalStyle: s }
|
|
46
46
|
} = a;
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
47
|
+
s !== "none" && s.startsWith("every-line") && (e.xTicks || r.ticks()).forEach((i) => {
|
|
48
|
+
const o = t.append("line").attr("x1", r(i)).attr("x2", r(i)).attr("y1", n.top).attr("y2", d - n.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
|
|
49
|
+
s === "every-line-dashed" && o.attr("stroke-dasharray", "4 4");
|
|
50
50
|
});
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
const { svg: t, config: a } = e, { width:
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
let
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
51
|
+
}, X = (e) => {
|
|
52
|
+
Z(e), H(e);
|
|
53
|
+
}, P = (e) => {
|
|
54
|
+
const { svg: t, config: a } = e, { width: r, height: d, margin: n, logo: s } = a;
|
|
55
|
+
V(e), G(e), s && t.append("image").attr("xlink:href", a.theme === "dark" ? s.picDarkTheme : s.picLightTheme).attr("width", s.width).attr("height", s.height).attr("x", s.x ?? (r - n.left - n.right) / 2 - s.width / 2 + n.left).attr("y", s.y ?? (d - n.top - n.bottom) / 2 - s.height / 2 + n.top), X(e);
|
|
56
|
+
}, _ = (e, t, a) => {
|
|
57
|
+
let r = e.select(`#${t}`);
|
|
58
|
+
return r.empty() && (r = e.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", t)), r.attr("x1", a.x1).attr("y1", a.x2).attr("x2", a.y1).attr("y2", a.y2), a.stops.forEach(({ offset: d, stopColor: n }) => {
|
|
59
|
+
r.append("stop").attr("offset", d).attr("stop-color", n);
|
|
60
|
+
}), r;
|
|
61
|
+
}, L = (e) => {
|
|
62
62
|
const t = y.select(e).select("defs");
|
|
63
63
|
return t.empty() ? y.select(e).append("defs") : t;
|
|
64
|
-
},
|
|
64
|
+
}, z = (e) => {
|
|
65
65
|
const {
|
|
66
66
|
y: t,
|
|
67
67
|
config: { margin: a }
|
|
68
|
-
} = e,
|
|
69
|
-
return { x: 0, y: t.range()[0] -
|
|
70
|
-
},
|
|
68
|
+
} = e, r = t.range()[0] - t(0);
|
|
69
|
+
return { x: 0, y: t.range()[0] - r, width: "100%", height: r + a.bottom };
|
|
70
|
+
}, M = (e, t) => ({
|
|
71
71
|
...e,
|
|
72
72
|
...t,
|
|
73
73
|
margin: {
|
|
@@ -102,121 +102,139 @@ const z = (e) => {
|
|
|
102
102
|
...e.selection,
|
|
103
103
|
...t == null ? void 0 : t.selection
|
|
104
104
|
}
|
|
105
|
-
}),
|
|
106
|
-
const a = e.node(),
|
|
105
|
+
}), R = (e, t = {}) => {
|
|
106
|
+
const a = e.node(), r = L(a), d = (l, i) => _(r, l, {
|
|
107
107
|
x1: "0%",
|
|
108
108
|
y1: "0%",
|
|
109
109
|
x2: "0%",
|
|
110
110
|
y2: "100%",
|
|
111
111
|
stops: [
|
|
112
112
|
{ offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
|
|
113
|
-
{ offset: "20%", stopColor:
|
|
114
|
-
{ offset: "60%", stopColor:
|
|
113
|
+
{ offset: "20%", stopColor: i },
|
|
114
|
+
{ offset: "60%", stopColor: i },
|
|
115
115
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
116
116
|
]
|
|
117
117
|
});
|
|
118
|
-
|
|
119
|
-
const
|
|
118
|
+
d("gradient-range-borders-up", "var(--sc-color-selection-up)"), d("gradient-range-borders-down", "var(--sc-color-selection-down)");
|
|
119
|
+
const n = "sc-charts__border-range-line", s = e.append("line").classed(n, !0).style("display", t.hidden ? "none" : "block");
|
|
120
120
|
return {
|
|
121
|
-
className(
|
|
122
|
-
|
|
121
|
+
className(l, i) {
|
|
122
|
+
l === "remove" ? s.classed(`${n}${i}`, !1) : s.classed(`${n}${i}`, !0);
|
|
123
123
|
},
|
|
124
|
-
update({ x1:
|
|
125
|
-
|
|
124
|
+
update({ x1: l, x2: i, y1: o, y2: c, hidden: u }) {
|
|
125
|
+
l !== void 0 && s.attr("x1", l), i !== void 0 && s.attr("x2", i), o !== void 0 && s.attr("y1", o), c !== void 0 && s.attr("y2", c), u !== void 0 && s.style("display", u ? "none" : "block");
|
|
126
126
|
},
|
|
127
127
|
destroy() {
|
|
128
|
-
|
|
128
|
+
s.remove();
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
|
-
},
|
|
132
|
-
const a = e.append("circle").attr("r", t.radius || 4).style("display", t.hidden ? "none" : "block"),
|
|
133
|
-
return
|
|
134
|
-
className(
|
|
135
|
-
|
|
131
|
+
}, A = (e, t = {}) => {
|
|
132
|
+
const a = e.append("circle").attr("r", t.radius || 4).style("display", t.hidden ? "none" : "block"), r = t.className || "";
|
|
133
|
+
return r && a.classed(r, !0), {
|
|
134
|
+
className(d, n) {
|
|
135
|
+
d === "remove" ? a.classed(`${r}${n}`, !1) : a.classed(`${r}${n}`, !0);
|
|
136
136
|
},
|
|
137
|
-
update({ cx:
|
|
138
|
-
|
|
137
|
+
update({ cx: d, cy: n, hidden: s, fill: l }) {
|
|
138
|
+
d !== void 0 && a.attr("cx", d), n !== void 0 && a.attr("cy", n), l !== void 0 && a.attr("fill", l), s !== void 0 && a.style("display", s ? "none" : "block");
|
|
139
139
|
},
|
|
140
140
|
destroy() {
|
|
141
141
|
a.remove();
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
},
|
|
145
|
-
const a = "sc-charts__hover-line",
|
|
146
|
-
return ((
|
|
144
|
+
}, W = (e, t = {}) => {
|
|
145
|
+
const a = "sc-charts__hover-line", r = e.append("line").style("display", t.hidden ? "none" : "block").classed(a, !0), d = e.node(), n = L(d);
|
|
146
|
+
return ((l, i) => _(n, l, {
|
|
147
147
|
x1: "0%",
|
|
148
148
|
y1: "0%",
|
|
149
149
|
x2: "0%",
|
|
150
150
|
y2: "100%",
|
|
151
151
|
stops: [
|
|
152
152
|
{ offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
|
|
153
|
-
{ offset: "15%", stopColor:
|
|
154
|
-
{ offset: "75%", stopColor:
|
|
153
|
+
{ offset: "15%", stopColor: i },
|
|
154
|
+
{ offset: "75%", stopColor: i },
|
|
155
155
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
156
156
|
]
|
|
157
157
|
}))("hover-line-gradient", "var(--sc-color-hover-line)"), {
|
|
158
|
-
className(
|
|
159
|
-
|
|
158
|
+
className(l, i) {
|
|
159
|
+
l === "remove" ? r.classed(`${a}${i}`, !1) : r.classed(`${a}${i}`, !0);
|
|
160
160
|
},
|
|
161
|
-
update({ x1:
|
|
162
|
-
|
|
161
|
+
update({ x1: l, x2: i, y1: o, y2: c, hidden: u }) {
|
|
162
|
+
l !== void 0 && r.attr("x1", l), i !== void 0 && r.attr("x2", i), o !== void 0 && r.attr("y1", o), c !== void 0 && r.attr("y2", c), u !== void 0 && r.style("display", u ? "none" : "block");
|
|
163
163
|
},
|
|
164
164
|
destroy() {
|
|
165
|
-
|
|
165
|
+
r.remove();
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
},
|
|
169
|
-
const t =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
}, k = "sc-charts__range-tooltip", B = y.timeFormat("%b %e, %I:%M %p"), Y = (e) => {
|
|
169
|
+
const t = y.format(",.2f");
|
|
170
|
+
return `${e < 0 ? "-" : ""}$${t(Math.abs(e))}`;
|
|
171
|
+
};
|
|
172
|
+
function q(e) {
|
|
173
|
+
const t = e.append("foreignObject").classed(k, !0).style("display", "none"), a = t.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${k}-container`), r = a.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${k}-sum`), d = a.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${k}-time`);
|
|
174
|
+
return r.text("").append("xhtml:div").html(O).attr("class", `${k}-sum-icon`), { wrapper: t, parent: a, sumNode: r, timeNode: d };
|
|
175
|
+
}
|
|
176
|
+
const j = (e) => {
|
|
177
|
+
const { wrapper: t, parent: a, sumNode: r, timeNode: d } = q(e.svg);
|
|
173
178
|
return {
|
|
174
|
-
className(n,
|
|
175
|
-
n === "remove" ?
|
|
179
|
+
className(n, s) {
|
|
180
|
+
n === "remove" ? t.classed(`${k}${s}`, !1) : t.classed(`${k}${s}`, !0);
|
|
176
181
|
},
|
|
177
|
-
update({ leftPoint: n, rightPoint:
|
|
178
|
-
if (l !== void 0 &&
|
|
179
|
-
const { comparisonValue:
|
|
180
|
-
let
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
182
|
+
update({ leftPoint: n, rightPoint: s, x: l, y: i, hidden: o, closest: c }) {
|
|
183
|
+
if (l !== void 0 && t.attr("x", l), i !== void 0 && t.attr("y", i), n && s && c && l !== void 0) {
|
|
184
|
+
const { comparisonValue: u, hidePercent: h } = e.config.selection, g = s.value - n.value, m = (e.x(s.date) + e.x(n.date)) / 2, x = e.x(c.date) < m ? n.value : s.value;
|
|
185
|
+
let v = null;
|
|
186
|
+
h || (u && u !== 0 && x !== 0 ? v = (x / u * 100).toFixed(2) : n.value && (v = (g / Math.abs(n.value) * 100).toFixed(2)));
|
|
187
|
+
const p = v === null ? "" : `(${v}%)`, f = `${Y(g)}${p}`, w = `${B(n.date)} to ${B(s.date)}`;
|
|
188
|
+
r.text(f), d.text(w);
|
|
189
|
+
const $ = e.x(e.data[e.data.length - 1].date), I = e.x(e.data[0].date);
|
|
190
|
+
requestAnimationFrame(() => {
|
|
191
|
+
const b = a.node().getBoundingClientRect();
|
|
192
|
+
b.x < I && t.attr("x", I + b.width / 2), b.x > $ - b.width && t.attr("x", $ - b.width / 2);
|
|
193
|
+
});
|
|
186
194
|
}
|
|
187
|
-
|
|
195
|
+
o !== void 0 && t.style("display", o ? "none" : "block");
|
|
188
196
|
},
|
|
189
197
|
destroy() {
|
|
190
|
-
|
|
198
|
+
t.remove();
|
|
191
199
|
}
|
|
192
200
|
};
|
|
193
|
-
},
|
|
201
|
+
}, O = `
|
|
194
202
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
195
203
|
<path d="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"
|
|
196
204
|
fill="currentColor"/>
|
|
197
205
|
</svg>
|
|
198
|
-
`,
|
|
199
|
-
const t =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
`, C = "sc-charts__hover-tooltip", T = 16, U = y.timeFormat("%a, %b %d, %-I:%M %p"), J = (e) => {
|
|
207
|
+
const t = y.format(",.2f");
|
|
208
|
+
return `${e < 0 ? "-" : ""}$${t(Math.abs(e))}`;
|
|
209
|
+
};
|
|
210
|
+
function K(e) {
|
|
211
|
+
const t = e.append("foreignObject").classed(C, !0).style("display", "none"), a = t.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${C}-container`), r = a.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${C}-sum`), d = a.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${C}-time`);
|
|
212
|
+
return { wrapper: t, parent: a, sumNode: r, timeNode: d };
|
|
213
|
+
}
|
|
214
|
+
function Q(e, t, a) {
|
|
215
|
+
return e ? t + T + e.width < a ? t + T : t - T - e.width : null;
|
|
216
|
+
}
|
|
217
|
+
const ee = (e) => {
|
|
218
|
+
const { wrapper: t, parent: a, sumNode: r, timeNode: d } = K(e.svg);
|
|
203
219
|
return {
|
|
204
|
-
className(n,
|
|
205
|
-
|
|
220
|
+
className(n, s) {
|
|
221
|
+
t.classed(`${C}${s}`, n !== "remove");
|
|
206
222
|
},
|
|
207
|
-
update({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
223
|
+
update({ hidden: n, dataItem: s }) {
|
|
224
|
+
s && (r.text(J(s.value)), d.text(U(s.date)), requestAnimationFrame(() => {
|
|
225
|
+
const l = a.node().getBoundingClientRect(), i = Q(
|
|
226
|
+
l,
|
|
227
|
+
e.x(s.date),
|
|
228
|
+
e.config.width - e.config.margin.right
|
|
229
|
+
);
|
|
230
|
+
i && t.attr("x", i);
|
|
231
|
+
})), n !== void 0 && t.style("display", n ? "none" : "block");
|
|
214
232
|
},
|
|
215
233
|
destroy() {
|
|
216
|
-
|
|
234
|
+
t.remove();
|
|
217
235
|
}
|
|
218
236
|
};
|
|
219
|
-
},
|
|
237
|
+
}, te = {
|
|
220
238
|
margin: { top: 10, right: 30, bottom: 20, left: 10 },
|
|
221
239
|
theme: "light",
|
|
222
240
|
logo: {
|
|
@@ -236,7 +254,8 @@ const z = (e) => {
|
|
|
236
254
|
},
|
|
237
255
|
selection: {
|
|
238
256
|
enable: !0,
|
|
239
|
-
comparisonValue: null
|
|
257
|
+
comparisonValue: null,
|
|
258
|
+
hidePercent: !1
|
|
240
259
|
},
|
|
241
260
|
xAxis: {
|
|
242
261
|
customTicks: !1,
|
|
@@ -258,9 +277,9 @@ const z = (e) => {
|
|
|
258
277
|
},
|
|
259
278
|
enableBelowZeroLine: !1,
|
|
260
279
|
curveTension: 1
|
|
261
|
-
},
|
|
262
|
-
const { svg: t, data: a, x:
|
|
263
|
-
|
|
280
|
+
}, N = (e) => y.curveCardinal.tension(e.config.curveTension), ae = (e) => {
|
|
281
|
+
const { svg: t, data: a, x: r, y: d, config: n } = e, s = t.node(), l = L(s);
|
|
282
|
+
_(l, "main-line-area-gradient", {
|
|
264
283
|
x1: "0%",
|
|
265
284
|
y1: "0%",
|
|
266
285
|
x2: "0%",
|
|
@@ -270,24 +289,24 @@ const z = (e) => {
|
|
|
270
289
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
271
290
|
]
|
|
272
291
|
});
|
|
273
|
-
const
|
|
292
|
+
const o = y.area().x((h) => r(h.date)).y0(d.range()[0]).y1((h) => d(h.value)).curve(N(e)), c = "sc-charts__main-line-area", u = t.append("path").datum(a).attr("d", o).attr("class", c).classed(`${c}_hidden`, !n.hasMainLineArea);
|
|
274
293
|
return {
|
|
275
294
|
className(h, g) {
|
|
276
|
-
h === "remove" ? u.classed(`${
|
|
295
|
+
h === "remove" ? u.classed(`${c}${g}`, !1) : u.classed(`${c}${g}`, !0);
|
|
277
296
|
},
|
|
278
297
|
update({ data: h, hidden: g }) {
|
|
279
|
-
if (h !== void 0 && u.datum(h).attr("d",
|
|
280
|
-
if (!
|
|
281
|
-
u.classed(`${
|
|
298
|
+
if (h !== void 0 && u.datum(h).attr("d", o), g !== void 0) {
|
|
299
|
+
if (!n.hasMainLineArea) return null;
|
|
300
|
+
u.classed(`${c}_hidden`, g);
|
|
282
301
|
}
|
|
283
302
|
},
|
|
284
303
|
destroy() {
|
|
285
304
|
u.remove();
|
|
286
305
|
}
|
|
287
306
|
};
|
|
288
|
-
},
|
|
289
|
-
const a = "sc-charts__range-line-area", { svg:
|
|
290
|
-
|
|
307
|
+
}, re = (e, t = {}) => {
|
|
308
|
+
const a = "sc-charts__range-line-area", { svg: r, x: d, y: n, config: s, data: l, chartId: i } = e, { clip: o } = t, c = r.node(), u = L(c), h = "range-line-area-gradient";
|
|
309
|
+
_(u, h + "_up", {
|
|
291
310
|
x1: "0%",
|
|
292
311
|
y1: "0%",
|
|
293
312
|
x2: "0%",
|
|
@@ -296,7 +315,7 @@ const z = (e) => {
|
|
|
296
315
|
{ offset: "0%", stopColor: "var(--sc-color-selection-up)" },
|
|
297
316
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
298
317
|
]
|
|
299
|
-
}),
|
|
318
|
+
}), _(u, h + "_down", {
|
|
300
319
|
x1: "0%",
|
|
301
320
|
y1: "0%",
|
|
302
321
|
x2: "0%",
|
|
@@ -306,116 +325,116 @@ const z = (e) => {
|
|
|
306
325
|
{ offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
|
|
307
326
|
]
|
|
308
327
|
});
|
|
309
|
-
const g = y.area().x((f) =>
|
|
328
|
+
const g = y.area().x((f) => d(f.date)).y0(n.range()[0]).y1((f) => n(f.value)).curve(N(e)), m = `${i}-clip-${a}`, v = u.append("clipPath").attr("id", m).append("rect").attr("x", (o == null ? void 0 : o.x) || 0).attr("y", (o == null ? void 0 : o.y) || 0).attr("width", (o == null ? void 0 : o.width) || "100%").attr("height", (o == null ? void 0 : o.height) || "100%"), p = r.append("path").datum(l).attr("d", g).attr("class", a).classed(`${a}_hidden`, !s.hasMainLineArea).attr("clip-path", `url(#${m})`);
|
|
310
329
|
return {
|
|
311
330
|
className(f, w) {
|
|
312
|
-
f === "remove" ?
|
|
331
|
+
f === "remove" ? p.classed(`${a}${w}`, !1) : p.classed(`${a}${w}`, !0);
|
|
313
332
|
},
|
|
314
333
|
update({ data: f, hidden: w, clip: $ }) {
|
|
315
|
-
f !== void 0 &&
|
|
334
|
+
f !== void 0 && p.datum(f).attr("d", g), w !== void 0 && p.classed(`${a}_hidden`, w), $ !== void 0 && v.attr("x", $.x).attr("y", $.y).attr("width", $.width).attr("height", $.height);
|
|
316
335
|
},
|
|
317
336
|
destroy() {
|
|
318
|
-
|
|
337
|
+
p.remove();
|
|
319
338
|
}
|
|
320
339
|
};
|
|
321
|
-
},
|
|
322
|
-
const { svg: a, data:
|
|
340
|
+
}, S = (e, t) => {
|
|
341
|
+
const { svg: a, data: r, x: d, y: n, chartId: s } = e, { baseClassName: l, id: i, clip: o } = t, c = a.node(), u = L(c), h = y.line().x((p) => d(p.date)).y((p) => n(p.value)).curve(N(e)), g = `${s}-clip-${l}`, x = u.append("clipPath").attr("id", g).append("rect").attr("x", (o == null ? void 0 : o.x) || 0).attr("y", (o == null ? void 0 : o.y) || 0).attr("width", (o == null ? void 0 : o.width) || "100%").attr("height", (o == null ? void 0 : o.height) || "100%"), v = a.append("path").classed(l, !0).datum(r).attr("d", h).attr("id", i).attr("clip-path", `url(#${g})`);
|
|
323
342
|
return {
|
|
324
|
-
className(
|
|
325
|
-
|
|
343
|
+
className(p, f) {
|
|
344
|
+
p === "remove" ? v.classed(`${l}${f}`, !1) : v.classed(`${l}${f}`, !0);
|
|
326
345
|
},
|
|
327
|
-
update({ data:
|
|
328
|
-
|
|
346
|
+
update({ data: p, clip: f, hidden: w }) {
|
|
347
|
+
p !== void 0 && v.datum(p).attr("d", h), w !== void 0 && v.classed(`${l}_hidden`, w), f !== void 0 && x.attr("x", f.x).attr("y", f.y).attr("width", f.width).attr("height", f.height);
|
|
329
348
|
},
|
|
330
349
|
destroy() {
|
|
331
|
-
|
|
350
|
+
v.remove();
|
|
332
351
|
}
|
|
333
352
|
};
|
|
334
|
-
},
|
|
335
|
-
const { svg: a, data:
|
|
353
|
+
}, se = (e, t) => {
|
|
354
|
+
const { svg: a, data: r, x: d, y: n, chartId: s, config: l } = e, { baseClassName: i, id: o, clip: c } = t, u = a.node(), h = L(u), g = y.line().x((f) => d(f.date)).y((f) => n(f.value)).curve(N(e)), m = `${s}-clip-${i}`, v = h.append("clipPath").attr("id", m).append("rect").attr("x", (c == null ? void 0 : c.x) || 0).attr("y", (c == null ? void 0 : c.y) || 0).attr("width", (c == null ? void 0 : c.width) || "100%").attr("height", (c == null ? void 0 : c.height) || "100%"), p = a.append("path").classed(i, !0).datum(r).attr("d", g).attr("id", o).attr("clip-path", `url(#${m})`);
|
|
336
355
|
return {
|
|
337
356
|
className(f, w) {
|
|
338
|
-
f === "remove" ?
|
|
357
|
+
f === "remove" ? p.classed(`${i}${w}`, !1) : p.classed(`${i}${w}`, !0);
|
|
339
358
|
},
|
|
340
359
|
update({ data: f, clip: w, hidden: $ }) {
|
|
341
|
-
f !== void 0 &&
|
|
360
|
+
f !== void 0 && p.datum(f).attr("d", g), $ !== void 0 && p.classed(`${i}_hidden`, $), w !== void 0 && (l.hover.transitionName === "default" ? v.transition().duration(l.hover.transitionDuration).attr("x", w.x).attr("y", w.y).attr("width", w.width).attr("height", w.height).ease(y.easeLinear) : v.attr("x", w.x).attr("y", w.y).attr("width", w.width).attr("height", w.height));
|
|
342
361
|
},
|
|
343
362
|
destroy() {
|
|
344
|
-
|
|
363
|
+
p.remove();
|
|
345
364
|
}
|
|
346
365
|
};
|
|
347
|
-
},
|
|
348
|
-
const t =
|
|
366
|
+
}, ne = (e) => {
|
|
367
|
+
const t = S(e, {
|
|
349
368
|
baseClassName: "sc-charts__main-line",
|
|
350
369
|
id: `${e.chartId}-sc-charts__main-line`
|
|
351
|
-
}), a =
|
|
370
|
+
}), a = ae(e), r = W(e.svg), d = se(e, {
|
|
352
371
|
baseClassName: "sc-charts__highlight-line",
|
|
353
372
|
id: `${e.chartId}-sc-charts__highlight-line`,
|
|
354
373
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
355
374
|
});
|
|
356
|
-
let
|
|
357
|
-
e.config.enableBelowZeroLine && (
|
|
375
|
+
let n = null;
|
|
376
|
+
e.config.enableBelowZeroLine && (n = S(e, {
|
|
358
377
|
baseClassName: "sc-charts__below-zero-line",
|
|
359
378
|
id: `${e.chartId}-sc-charts__below-zero-line`,
|
|
360
|
-
clip:
|
|
379
|
+
clip: z(e)
|
|
361
380
|
}));
|
|
362
|
-
const
|
|
381
|
+
const s = A(e.svg, {
|
|
363
382
|
className: "sc-charts__hover-circle",
|
|
364
383
|
hidden: !0
|
|
365
|
-
}),
|
|
384
|
+
}), l = R(e.svg), i = R(e.svg), o = S(e, {
|
|
366
385
|
baseClassName: "sc-charts__range-line",
|
|
367
386
|
id: `${e.chartId}-sc-charts__range-line`,
|
|
368
387
|
clip: { x: 0, y: 0, width: "0", height: "0" }
|
|
369
|
-
}),
|
|
388
|
+
}), c = A(e.svg, {
|
|
370
389
|
className: "sc-charts__range-circle-left",
|
|
371
390
|
hidden: !0
|
|
372
|
-
}), u =
|
|
391
|
+
}), u = A(e.svg, {
|
|
373
392
|
className: "sc-charts__range-circle-right",
|
|
374
393
|
hidden: !0
|
|
375
|
-
}), h = j(e), g =
|
|
394
|
+
}), h = j(e), g = ee(e), m = re(e);
|
|
376
395
|
return {
|
|
377
|
-
hoverLine:
|
|
378
|
-
hoverCircle:
|
|
379
|
-
rangeBorderLeft:
|
|
380
|
-
rangeBorderRight:
|
|
381
|
-
rangeLine:
|
|
396
|
+
hoverLine: r,
|
|
397
|
+
hoverCircle: s,
|
|
398
|
+
rangeBorderLeft: l,
|
|
399
|
+
rangeBorderRight: i,
|
|
400
|
+
rangeLine: o,
|
|
382
401
|
rangeLineArea: m,
|
|
383
|
-
rangeCircleLeft:
|
|
402
|
+
rangeCircleLeft: c,
|
|
384
403
|
rangeCircleRight: u,
|
|
385
404
|
mainLine: t,
|
|
386
405
|
rangeTooltip: h,
|
|
387
|
-
highlightLine:
|
|
406
|
+
highlightLine: d,
|
|
388
407
|
hoverTooltip: g,
|
|
389
408
|
mainLineArea: a,
|
|
390
|
-
belowZeroLine:
|
|
409
|
+
belowZeroLine: n
|
|
391
410
|
};
|
|
392
|
-
},
|
|
393
|
-
const
|
|
394
|
-
if (!
|
|
411
|
+
}, oe = (e, t, a) => {
|
|
412
|
+
const r = e.match(/^(\d+)([dMhmw])$/);
|
|
413
|
+
if (!r)
|
|
395
414
|
return console.warn("Invalid hoverRange:", e), {
|
|
396
415
|
x: 0,
|
|
397
416
|
y: 0,
|
|
398
417
|
width: "100%",
|
|
399
418
|
height: "100%"
|
|
400
419
|
};
|
|
401
|
-
const [,
|
|
402
|
-
let
|
|
403
|
-
for (;
|
|
404
|
-
switch (
|
|
420
|
+
const [, d, n] = r, s = parseInt(d, 10), [l, i] = a.domain();
|
|
421
|
+
let o = new Date(l), c = new Date(o);
|
|
422
|
+
for (; c < i; ) {
|
|
423
|
+
switch (n) {
|
|
405
424
|
case "M":
|
|
406
|
-
|
|
425
|
+
c.setMinutes(o.getMinutes() + s);
|
|
407
426
|
break;
|
|
408
427
|
case "h":
|
|
409
|
-
|
|
428
|
+
c.setHours(o.getHours() + s);
|
|
410
429
|
break;
|
|
411
430
|
case "d":
|
|
412
|
-
|
|
431
|
+
c.setDate(o.getDate() + s);
|
|
413
432
|
break;
|
|
414
433
|
case "w":
|
|
415
|
-
|
|
434
|
+
c.setDate(o.getDate() + s * 7);
|
|
416
435
|
break;
|
|
417
436
|
case "m":
|
|
418
|
-
|
|
437
|
+
c = new Date(o.getFullYear(), o.getMonth() + s, 1);
|
|
419
438
|
break;
|
|
420
439
|
default:
|
|
421
440
|
return {
|
|
@@ -425,8 +444,8 @@ const z = (e) => {
|
|
|
425
444
|
height: "100%"
|
|
426
445
|
};
|
|
427
446
|
}
|
|
428
|
-
if (t >=
|
|
429
|
-
const u = a(
|
|
447
|
+
if (t >= o && t < c) {
|
|
448
|
+
const u = a(o), h = a(c);
|
|
430
449
|
return {
|
|
431
450
|
x: u,
|
|
432
451
|
y: 0,
|
|
@@ -434,7 +453,7 @@ const z = (e) => {
|
|
|
434
453
|
height: "100%"
|
|
435
454
|
};
|
|
436
455
|
}
|
|
437
|
-
|
|
456
|
+
o = new Date(c);
|
|
438
457
|
}
|
|
439
458
|
return {
|
|
440
459
|
x: 0,
|
|
@@ -442,48 +461,46 @@ const z = (e) => {
|
|
|
442
461
|
width: "100%",
|
|
443
462
|
height: "100%"
|
|
444
463
|
};
|
|
445
|
-
},
|
|
446
|
-
var
|
|
464
|
+
}, F = (e, t) => {
|
|
465
|
+
var o;
|
|
447
466
|
const {
|
|
448
467
|
x: a,
|
|
449
|
-
y:
|
|
450
|
-
elements:
|
|
451
|
-
config: { margin:
|
|
468
|
+
y: r,
|
|
469
|
+
elements: d,
|
|
470
|
+
config: { margin: n, height: s, hover: l }
|
|
452
471
|
} = e;
|
|
453
|
-
|
|
472
|
+
d.hoverLine.update({
|
|
454
473
|
x1: a(t.date),
|
|
455
474
|
x2: a(t.date),
|
|
456
|
-
y1:
|
|
457
|
-
y2:
|
|
475
|
+
y1: n.top,
|
|
476
|
+
y2: s - n.bottom,
|
|
458
477
|
hidden: !1
|
|
459
|
-
}),
|
|
478
|
+
}), d.hoverCircle.update({
|
|
460
479
|
cx: a(t.date),
|
|
461
|
-
cy:
|
|
480
|
+
cy: r(t.value),
|
|
462
481
|
hidden: !1
|
|
463
|
-
}),
|
|
482
|
+
}), d.hoverTooltip.update({
|
|
464
483
|
dataItem: t,
|
|
465
|
-
x: a(t.date),
|
|
466
|
-
y: 0,
|
|
467
484
|
hidden: !1
|
|
468
485
|
});
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
clip:
|
|
486
|
+
const i = oe(l.range, t.date, a);
|
|
487
|
+
d.highlightLine.update({
|
|
488
|
+
clip: i,
|
|
472
489
|
hidden: !1
|
|
473
|
-
}), (
|
|
490
|
+
}), (o = d.belowZeroLine) == null || o.update({
|
|
474
491
|
clip: {
|
|
475
|
-
...
|
|
476
|
-
y:
|
|
477
|
-
height:
|
|
492
|
+
...i,
|
|
493
|
+
y: r(0),
|
|
494
|
+
height: r.range()[0] - r(0) + n.bottom
|
|
478
495
|
}
|
|
479
|
-
}),
|
|
480
|
-
},
|
|
496
|
+
}), d.mainLine.className("add", "_muted");
|
|
497
|
+
}, D = (e) => {
|
|
481
498
|
var a;
|
|
482
499
|
const { elements: t } = e;
|
|
483
500
|
t.hoverLine.update({ hidden: !0 }), t.hoverCircle.update({ hidden: !0 }), t.highlightLine.update({ hidden: !0 }), t.mainLine.className("remove", "_muted"), t.hoverTooltip.update({ hidden: !0 }), e.action !== "selection" && ((a = t.belowZeroLine) == null || a.update({
|
|
484
|
-
clip:
|
|
501
|
+
clip: z(e)
|
|
485
502
|
}));
|
|
486
|
-
},
|
|
503
|
+
}, ie = (e, t) => {
|
|
487
504
|
[
|
|
488
505
|
"rangeBorderLeft",
|
|
489
506
|
"rangeBorderRight",
|
|
@@ -492,129 +509,129 @@ const z = (e) => {
|
|
|
492
509
|
"rangeLine",
|
|
493
510
|
"rangeLineArea",
|
|
494
511
|
"rangeTooltip"
|
|
495
|
-
].forEach((
|
|
496
|
-
t ? (e[
|
|
512
|
+
].forEach((r) => {
|
|
513
|
+
t ? (e[r].className("remove", "_down"), e[r].className("add", "_up")) : (e[r].className("remove", "_up"), e[r].className("add", "_down"));
|
|
497
514
|
});
|
|
498
|
-
},
|
|
515
|
+
}, le = (e, t, a) => {
|
|
499
516
|
var m;
|
|
500
517
|
const {
|
|
501
|
-
x:
|
|
502
|
-
y:
|
|
503
|
-
config: { margin:
|
|
504
|
-
elements:
|
|
505
|
-
} = e,
|
|
506
|
-
|
|
518
|
+
x: r,
|
|
519
|
+
y: d,
|
|
520
|
+
config: { margin: n, height: s },
|
|
521
|
+
elements: l
|
|
522
|
+
} = e, i = r(t.date) < r(a.date) ? t : a, o = r(t.date) >= r(a.date) ? t : a, c = o.value - i.value >= 0, u = r(i.date), h = r(o.date), g = h - u;
|
|
523
|
+
l.rangeBorderLeft.update({
|
|
507
524
|
x1: u,
|
|
508
525
|
x2: u,
|
|
509
|
-
y1:
|
|
510
|
-
y2:
|
|
526
|
+
y1: n.top,
|
|
527
|
+
y2: s - n.bottom,
|
|
511
528
|
hidden: !1
|
|
512
|
-
}),
|
|
529
|
+
}), l.rangeBorderRight.update({
|
|
513
530
|
x1: h,
|
|
514
531
|
x2: h,
|
|
515
|
-
y1:
|
|
516
|
-
y2:
|
|
532
|
+
y1: n.top,
|
|
533
|
+
y2: s - n.bottom,
|
|
517
534
|
hidden: !1
|
|
518
|
-
}),
|
|
535
|
+
}), l.rangeCircleLeft.update({
|
|
519
536
|
cx: u,
|
|
520
|
-
cy:
|
|
537
|
+
cy: d(i.value),
|
|
521
538
|
hidden: !1
|
|
522
|
-
}),
|
|
539
|
+
}), l.rangeCircleRight.update({
|
|
523
540
|
cx: h,
|
|
524
|
-
cy:
|
|
541
|
+
cy: d(o.value),
|
|
525
542
|
hidden: !1
|
|
526
|
-
}),
|
|
543
|
+
}), l.rangeLine.update({
|
|
527
544
|
clip: {
|
|
528
545
|
x: u,
|
|
529
546
|
y: 0,
|
|
530
547
|
width: g,
|
|
531
|
-
height:
|
|
548
|
+
height: d.range()[0]
|
|
532
549
|
},
|
|
533
550
|
hidden: !1
|
|
534
|
-
}),
|
|
551
|
+
}), l.rangeLineArea.update({
|
|
535
552
|
clip: {
|
|
536
553
|
x: u,
|
|
537
554
|
y: 0,
|
|
538
555
|
width: g,
|
|
539
|
-
height:
|
|
556
|
+
height: d.range()[0]
|
|
540
557
|
},
|
|
541
558
|
hidden: !1
|
|
542
|
-
}),
|
|
543
|
-
rightPoint:
|
|
544
|
-
leftPoint:
|
|
559
|
+
}), l.rangeTooltip.update({
|
|
560
|
+
rightPoint: o,
|
|
561
|
+
leftPoint: i,
|
|
545
562
|
closest: a,
|
|
546
563
|
x: u + g / 2,
|
|
547
564
|
y: 0,
|
|
548
565
|
hidden: !1
|
|
549
|
-
}), (m =
|
|
566
|
+
}), (m = l.belowZeroLine) == null || m.update({
|
|
550
567
|
hidden: !0
|
|
551
|
-
}),
|
|
552
|
-
},
|
|
568
|
+
}), l.mainLineArea.update({ hidden: !0 }), ie(l, c), l.mainLine.className("add", "_selected-muted");
|
|
569
|
+
}, E = (e) => {
|
|
553
570
|
var a;
|
|
554
571
|
const { elements: t } = e;
|
|
555
572
|
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 }), (a = t.belowZeroLine) == null || a.update({ hidden: !1 });
|
|
556
|
-
},
|
|
557
|
-
const { svg: t, data: a, x:
|
|
558
|
-
let
|
|
573
|
+
}, de = (e) => {
|
|
574
|
+
const { svg: t, data: a, x: r, config: d } = e, { height: n, margin: s, width: l, hover: i, selection: o } = d;
|
|
575
|
+
let c = null, u = !1;
|
|
559
576
|
const h = (m) => a.reduce(
|
|
560
|
-
(x,
|
|
577
|
+
(x, v) => Math.abs(r(x.date) - m) < Math.abs(r(v.date) - m) ? x : v
|
|
561
578
|
);
|
|
562
|
-
t.append("rect").attr("width",
|
|
563
|
-
const [x] = y.pointer(m, this),
|
|
564
|
-
!u &&
|
|
579
|
+
t.append("rect").attr("width", l - s.left - s.right).attr("height", n - s.top - s.bottom).attr("x", s.left).attr("y", s.top).attr("fill", "transparent").on("mousemove", function(m) {
|
|
580
|
+
const [x] = y.pointer(m, this), v = h(x);
|
|
581
|
+
!u && i.enable ? (e.action = "hover", F(e, v)) : (e.action = u ? "selection" : "none", D(e)), c && o.enable && (e.action = "selection", le(e, c, v));
|
|
565
582
|
}).on("mouseleave", () => {
|
|
566
|
-
e.action = "none", u = !1,
|
|
583
|
+
e.action = "none", u = !1, c = null, D(e), E(e);
|
|
567
584
|
}).on("mousedown", function(m) {
|
|
568
|
-
if (
|
|
585
|
+
if (o.enable) {
|
|
569
586
|
u = !0, e.action = "selection";
|
|
570
587
|
const [x] = y.pointer(m, this);
|
|
571
|
-
|
|
588
|
+
c = h(x);
|
|
572
589
|
}
|
|
573
590
|
}).on("mouseup", function(m) {
|
|
574
|
-
const [x] = y.pointer(m, this),
|
|
575
|
-
u = !1,
|
|
591
|
+
const [x] = y.pointer(m, this), v = h(x);
|
|
592
|
+
u = !1, c = null, e.action = "hover", o.enable && E(e), i.enable && F(e, v);
|
|
576
593
|
});
|
|
577
|
-
},
|
|
578
|
-
const { width: a, margin:
|
|
579
|
-
return
|
|
580
|
-
},
|
|
581
|
-
const { height: a, margin:
|
|
582
|
-
return y.scaleLinear().domain([
|
|
583
|
-
},
|
|
594
|
+
}, ce = (e, t) => {
|
|
595
|
+
const { width: a, margin: r } = t, d = y.scaleTime(), n = y.extent(e, (s) => new Date(s.date));
|
|
596
|
+
return n[0] == null || n[1] == null ? d : d.domain([n[0], n[1]]).range([r.left, a - r.right]);
|
|
597
|
+
}, he = (e, t) => {
|
|
598
|
+
const { height: a, margin: r } = t, d = y.max(e, (s) => s.value) ?? 0, n = y.min(e, (s) => s.value) ?? 0;
|
|
599
|
+
return y.scaleLinear().domain([n, d]).range([a - r.bottom, r.top]);
|
|
600
|
+
}, ge = (e, t) => {
|
|
584
601
|
const a = y.select(e);
|
|
585
602
|
if (a.empty())
|
|
586
603
|
return console.error(`Element with selector ${e} not found!`), null;
|
|
587
604
|
if (!t.chartId || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t.chartId))
|
|
588
605
|
return console.error(`chartId is required and must be a valid id
|
|
589
606
|
(only letters, numbers or underscores. The first character must be a letter)`), null;
|
|
590
|
-
const
|
|
591
|
-
let
|
|
592
|
-
const
|
|
593
|
-
u &&
|
|
594
|
-
const h =
|
|
595
|
-
|
|
607
|
+
const r = a.append("svg"), n = a.node().getBoundingClientRect(), s = n.width, l = n.height;
|
|
608
|
+
let i = M({ ...te, width: s, height: l }, t.config);
|
|
609
|
+
const o = (c, u = !1) => {
|
|
610
|
+
u && c.config && (i = M(i, c.config));
|
|
611
|
+
const h = c.data.map((p) => ({ date: new Date(p.date), value: p.value })).sort((p, f) => p.date.getTime() - f.date.getTime()), g = ce(h, i), m = he(h, i);
|
|
612
|
+
r.attr("class", `sc-charts sc-charts__${i.theme}`).attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${s} ${l}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
|
|
596
613
|
const x = {
|
|
597
614
|
chartId: t.chartId,
|
|
598
|
-
svg:
|
|
615
|
+
svg: r,
|
|
599
616
|
data: h,
|
|
600
617
|
x: g,
|
|
601
618
|
y: m,
|
|
602
|
-
config:
|
|
619
|
+
config: i,
|
|
603
620
|
action: "none"
|
|
604
621
|
};
|
|
605
|
-
|
|
606
|
-
const
|
|
622
|
+
P(x);
|
|
623
|
+
const v = {
|
|
607
624
|
...x,
|
|
608
|
-
elements:
|
|
625
|
+
elements: ne(x)
|
|
609
626
|
};
|
|
610
|
-
|
|
627
|
+
de(v);
|
|
611
628
|
};
|
|
612
|
-
return
|
|
613
|
-
update: (
|
|
614
|
-
destroy: () =>
|
|
629
|
+
return o(t), {
|
|
630
|
+
update: (c) => o(c, !0),
|
|
631
|
+
destroy: () => r.remove()
|
|
615
632
|
};
|
|
616
633
|
};
|
|
617
634
|
export {
|
|
618
|
-
|
|
635
|
+
ge as createLineChart
|
|
619
636
|
};
|
|
620
637
|
//# sourceMappingURL=charts-core.js.map
|