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