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.
@@ -1,73 +1,73 @@
1
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;
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(${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}`;
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
- }, 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);
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
- }, V = (e) => {
26
- const { svg: t, config: a, y: s } = e, {
27
- width: c,
28
- margin: i,
29
- grid: { horizontalStyle: o }
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 (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");
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
- 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");
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
- }, Z = (e) => {
42
- const { svg: t, config: a, x: s } = e, {
43
- height: c,
44
- margin: i,
45
- grid: { verticalStyle: o }
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
- 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");
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
- }, 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
- 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: c, stopColor: i }) => {
59
- s.append("stop").attr("offset", c).attr("stop-color", i);
60
- }), s;
61
- }, k = (e) => {
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
- }, B = (e) => {
64
+ }, z = (e) => {
65
65
  const {
66
66
  y: t,
67
67
  config: { margin: a }
68
- } = e, s = t.range()[0] - t(0);
69
- return { x: 0, y: t.range()[0] - s, width: "100%", height: s + a.bottom };
70
- }, I = (e, t) => ({
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
- }), M = (e, t = {}) => {
106
- const a = e.node(), s = k(a), c = (d, n) => C(s, d, {
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: n },
114
- { offset: "60%", stopColor: n },
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
- 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");
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(d, n) {
122
- d === "remove" ? o.classed(`${i}${n}`, !1) : o.classed(`${i}${n}`, !0);
121
+ className(l, i) {
122
+ l === "remove" ? s.classed(`${n}${i}`, !1) : s.classed(`${n}${i}`, !0);
123
123
  },
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");
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
- o.remove();
128
+ s.remove();
129
129
  }
130
130
  };
131
- }, _ = (e, t = {}) => {
132
- const a = e.append("circle").attr("r", t.radius || 4).style("display", t.hidden ? "none" : "block"), s = t.className || "";
133
- return s && a.classed(s, !0), {
134
- className(c, i) {
135
- c === "remove" ? a.classed(`${s}${i}`, !1) : a.classed(`${s}${i}`, !0);
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: 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");
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
- }, 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, {
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: n },
154
- { offset: "75%", stopColor: n },
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(d, n) {
159
- d === "remove" ? s.classed(`${a}${n}`, !1) : s.classed(`${a}${n}`, !0);
158
+ className(l, i) {
159
+ l === "remove" ? r.classed(`${a}${i}`, !1) : r.classed(`${a}${i}`, !0);
160
160
  },
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");
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
- s.remove();
165
+ r.remove();
166
166
  }
167
167
  };
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
- };
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, r) {
175
- n === "remove" ? a.classed(`${t}${r}`, !1) : a.classed(`${t}${r}`, !0);
179
+ className(n, s) {
180
+ n === "remove" ? t.classed(`${k}${s}`, !1) : t.classed(`${k}${s}`, !0);
176
181
  },
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);
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
- h !== void 0 && a.style("display", h ? "none" : "block");
195
+ o !== void 0 && t.style("display", o ? "none" : "block");
188
196
  },
189
197
  destroy() {
190
- a.remove();
198
+ t.remove();
191
199
  }
192
200
  };
193
- }, W = `
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
- `, 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
- };
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, r) {
205
- n === "remove" ? a.classed(`${t}${r}`, !1) : a.classed(`${t}${r}`, !0);
220
+ className(n, s) {
221
+ t.classed(`${C}${s}`, n !== "remove");
206
222
  },
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;
211
- a.attr("x", m);
212
- }
213
- l !== void 0 && a.style("display", l ? "none" : "block");
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
- a.remove();
234
+ t.remove();
217
235
  }
218
236
  };
219
- }, O = {
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
- }, 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", {
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 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);
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(`${l}${g}`, !1) : u.classed(`${l}${g}`, !0);
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", r), g !== void 0) {
280
- if (!i.hasMainLineArea) return null;
281
- u.classed(`${l}_hidden`, g);
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
- }, 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", {
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
- }), C(u, h + "_down", {
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) => 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})`);
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" ? v.classed(`${a}${w}`, !1) : v.classed(`${a}${w}`, !0);
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 && 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);
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
- v.remove();
337
+ p.remove();
319
338
  }
320
339
  };
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})`);
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(v, f) {
325
- v === "remove" ? p.classed(`${d}${f}`, !1) : p.classed(`${d}${f}`, !0);
343
+ className(p, f) {
344
+ p === "remove" ? v.classed(`${l}${f}`, !1) : v.classed(`${l}${f}`, !0);
326
345
  },
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);
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
- p.remove();
350
+ v.remove();
332
351
  }
333
352
  };
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})`);
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" ? v.classed(`${n}${w}`, !1) : v.classed(`${n}${w}`, !0);
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 && 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));
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
- v.remove();
363
+ p.remove();
345
364
  }
346
365
  };
347
- }, K = (e) => {
348
- const t = N(e, {
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 = U(e), s = X(e.svg), c = J(e, {
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 i = null;
357
- e.config.enableBelowZeroLine && (i = N(e, {
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: B(e)
379
+ clip: z(e)
361
380
  }));
362
- const o = _(e.svg, {
381
+ const s = A(e.svg, {
363
382
  className: "sc-charts__hover-circle",
364
383
  hidden: !0
365
- }), d = M(e.svg), n = M(e.svg), r = N(e, {
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
- }), l = _(e.svg, {
388
+ }), c = A(e.svg, {
370
389
  className: "sc-charts__range-circle-left",
371
390
  hidden: !0
372
- }), u = _(e.svg, {
391
+ }), u = A(e.svg, {
373
392
  className: "sc-charts__range-circle-right",
374
393
  hidden: !0
375
- }), h = j(e), g = Y(e), m = q(e);
394
+ }), h = j(e), g = ee(e), m = re(e);
376
395
  return {
377
- hoverLine: s,
378
- hoverCircle: o,
379
- rangeBorderLeft: d,
380
- rangeBorderRight: n,
381
- rangeLine: r,
396
+ hoverLine: r,
397
+ hoverCircle: s,
398
+ rangeBorderLeft: l,
399
+ rangeBorderRight: i,
400
+ rangeLine: o,
382
401
  rangeLineArea: m,
383
- rangeCircleLeft: l,
402
+ rangeCircleLeft: c,
384
403
  rangeCircleRight: u,
385
404
  mainLine: t,
386
405
  rangeTooltip: h,
387
- highlightLine: c,
406
+ highlightLine: d,
388
407
  hoverTooltip: g,
389
408
  mainLineArea: a,
390
- belowZeroLine: i
409
+ belowZeroLine: n
391
410
  };
392
- }, P = (e, t, a) => {
393
- const s = e.match(/^(\d+)([dMhmw])$/);
394
- if (!s)
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 [, 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) {
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
- l.setMinutes(r.getMinutes() + o);
425
+ c.setMinutes(o.getMinutes() + s);
407
426
  break;
408
427
  case "h":
409
- l.setHours(r.getHours() + o);
428
+ c.setHours(o.getHours() + s);
410
429
  break;
411
430
  case "d":
412
- l.setDate(r.getDate() + o);
431
+ c.setDate(o.getDate() + s);
413
432
  break;
414
433
  case "w":
415
- l.setDate(r.getDate() + o * 7);
434
+ c.setDate(o.getDate() + s * 7);
416
435
  break;
417
436
  case "m":
418
- l = new Date(r.getFullYear(), r.getMonth() + o, 1);
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 >= r && t < l) {
429
- const u = a(r), h = a(l);
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
- r = new Date(l);
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
- }, D = (e, t) => {
446
- var r;
464
+ }, F = (e, t) => {
465
+ var o;
447
466
  const {
448
467
  x: a,
449
- y: s,
450
- elements: c,
451
- config: { margin: i, height: o, hover: d }
468
+ y: r,
469
+ elements: d,
470
+ config: { margin: n, height: s, hover: l }
452
471
  } = e;
453
- c.hoverLine.update({
472
+ d.hoverLine.update({
454
473
  x1: a(t.date),
455
474
  x2: a(t.date),
456
- y1: i.top,
457
- y2: o - i.bottom,
475
+ y1: n.top,
476
+ y2: s - n.bottom,
458
477
  hidden: !1
459
- }), c.hoverCircle.update({
478
+ }), d.hoverCircle.update({
460
479
  cx: a(t.date),
461
- cy: s(t.value),
480
+ cy: r(t.value),
462
481
  hidden: !1
463
- }), c.hoverTooltip.update({
482
+ }), d.hoverTooltip.update({
464
483
  dataItem: t,
465
- x: a(t.date),
466
- y: 0,
467
484
  hidden: !1
468
485
  });
469
- const n = P(d.range, t.date, a);
470
- c.highlightLine.update({
471
- clip: n,
486
+ const i = oe(l.range, t.date, a);
487
+ d.highlightLine.update({
488
+ clip: i,
472
489
  hidden: !1
473
- }), (r = c.belowZeroLine) == null || r.update({
490
+ }), (o = d.belowZeroLine) == null || o.update({
474
491
  clip: {
475
- ...n,
476
- y: s(0),
477
- height: s.range()[0] - s(0) + i.bottom
492
+ ...i,
493
+ y: r(0),
494
+ height: r.range()[0] - r(0) + n.bottom
478
495
  }
479
- }), c.mainLine.className("add", "_muted");
480
- }, R = (e) => {
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: B(e)
501
+ clip: z(e)
485
502
  }));
486
- }, Q = (e, t) => {
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((s) => {
496
- t ? (e[s].className("remove", "_down"), e[s].className("add", "_up")) : (e[s].className("remove", "_up"), e[s].className("add", "_down"));
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
- }, ee = (e, t, a) => {
515
+ }, le = (e, t, a) => {
499
516
  var m;
500
517
  const {
501
- x: s,
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({
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: i.top,
510
- y2: o - i.bottom,
526
+ y1: n.top,
527
+ y2: s - n.bottom,
511
528
  hidden: !1
512
- }), d.rangeBorderRight.update({
529
+ }), l.rangeBorderRight.update({
513
530
  x1: h,
514
531
  x2: h,
515
- y1: i.top,
516
- y2: o - i.bottom,
532
+ y1: n.top,
533
+ y2: s - n.bottom,
517
534
  hidden: !1
518
- }), d.rangeCircleLeft.update({
535
+ }), l.rangeCircleLeft.update({
519
536
  cx: u,
520
- cy: c(n.value),
537
+ cy: d(i.value),
521
538
  hidden: !1
522
- }), d.rangeCircleRight.update({
539
+ }), l.rangeCircleRight.update({
523
540
  cx: h,
524
- cy: c(r.value),
541
+ cy: d(o.value),
525
542
  hidden: !1
526
- }), d.rangeLine.update({
543
+ }), l.rangeLine.update({
527
544
  clip: {
528
545
  x: u,
529
546
  y: 0,
530
547
  width: g,
531
- height: c.range()[0]
548
+ height: d.range()[0]
532
549
  },
533
550
  hidden: !1
534
- }), d.rangeLineArea.update({
551
+ }), l.rangeLineArea.update({
535
552
  clip: {
536
553
  x: u,
537
554
  y: 0,
538
555
  width: g,
539
- height: c.range()[0]
556
+ height: d.range()[0]
540
557
  },
541
558
  hidden: !1
542
- }), d.rangeTooltip.update({
543
- rightPoint: r,
544
- leftPoint: n,
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 = d.belowZeroLine) == null || m.update({
566
+ }), (m = l.belowZeroLine) == null || m.update({
550
567
  hidden: !0
551
- }), d.mainLineArea.update({ hidden: !0 }), Q(d, l), d.mainLine.className("add", "_selected-muted");
552
- }, S = (e) => {
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
- }, 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;
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, p) => Math.abs(s(x.date) - m) < Math.abs(s(p.date) - m) ? x : p
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", 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));
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, l = null, R(e), S(e);
583
+ e.action = "none", u = !1, c = null, D(e), E(e);
567
584
  }).on("mousedown", function(m) {
568
- if (r.enable) {
585
+ if (o.enable) {
569
586
  u = !0, e.action = "selection";
570
587
  const [x] = y.pointer(m, this);
571
- l = h(x);
588
+ c = h(x);
572
589
  }
573
590
  }).on("mouseup", function(m) {
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);
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
- }, 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) => {
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 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();
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: s,
615
+ svg: r,
599
616
  data: h,
600
617
  x: g,
601
618
  y: m,
602
- config: n,
619
+ config: i,
603
620
  action: "none"
604
621
  };
605
- H(x);
606
- const p = {
622
+ P(x);
623
+ const v = {
607
624
  ...x,
608
- elements: K(x)
625
+ elements: ne(x)
609
626
  };
610
- te(p);
627
+ de(v);
611
628
  };
612
- return r(t), {
613
- update: (l) => r(l, !0),
614
- destroy: () => s.remove()
629
+ return o(t), {
630
+ update: (c) => o(c, !0),
631
+ destroy: () => r.remove()
615
632
  };
616
633
  };
617
634
  export {
618
- se as createLineChart
635
+ ge as createLineChart
619
636
  };
620
637
  //# sourceMappingURL=charts-core.js.map