@svgrid/grid-wc 3.0.0 → 3.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/README.md +130 -110
- package/dist/GridMenus-B1mC1aPp.js +1077 -0
- package/dist/SvChartMenu-CBMKm7Xb.js +413 -0
- package/dist/SvDateRangeInput-BrYTQEMM.js +197 -0
- package/dist/SvDateTimePicker-CnLlqNDQ.js +766 -0
- package/dist/SvField-Bmzp3ObZ.js +147 -0
- package/dist/SvGridCellEditor-B005dmV1.js +560 -0
- package/dist/SvGridChart-4TcL9Rj2.js +3702 -0
- package/dist/SvGridChartBuilder-C4OL4XYx.js +1165 -0
- package/dist/SvGridChartPanel-CfHA8Ioq.js +1743 -0
- package/dist/SvGridChartView-Ci-9_EJ0.js +45 -0
- package/dist/SvGridDropdown-BlA6iw9m.js +257 -0
- package/dist/angular/fesm2022/svgrid-grid-wc-angular.mjs +178 -7
- package/dist/angular/fesm2022/svgrid-grid-wc-angular.mjs.map +1 -1
- package/dist/angular/types/svgrid-grid-wc-angular.d.ts +77 -2
- package/dist/{shadow/cell-formatting-C0OsDmi_.js → cell-formatting-Eypm-id0.js} +1 -1
- package/dist/chart/SvChartMenu-C-sbGNk8.js +586 -0
- package/dist/chart/chart-export-BHGuh_kZ.js +127 -0
- package/dist/chart/chart-export-pdf-BjkkIEkE.js +104 -0
- package/dist/chart/chart-summary-B86RFA3M.js +137 -0
- package/dist/chart/chart-trend-DP6DSsBa.js +56 -0
- package/dist/chart/chart-validate-CD6ptiwg.js +180 -0
- package/dist/chart/client-BuB0wIgc.js +2757 -0
- package/dist/chart/sv-chart-element.d.ts +98 -0
- package/dist/chart/sv-chart-element.js +7282 -0
- package/dist/chart-DoqdUoGg.js +4398 -0
- package/dist/chart-export-pdf-BirUdchl.js +104 -0
- package/dist/chart-summary-BP9i-v8M.js +137 -0
- package/dist/chart-validate-CD6ptiwg.js +180 -0
- package/dist/{shadow/client-DjwUji8D.js → client-DEF0GRjE.js} +1 -1
- package/dist/{shadow/column-resize-DvCRUrN3.js → column-resize-DUPgynvc.js} +3 -3
- package/dist/date-format-DMTwV8NC.js +1128 -0
- package/dist/{export-format-B6FUgOll.js → export-format-uGayRKWM.js} +3 -3
- package/dist/focus-trap-DvlOlOGM.js +65 -0
- package/dist/list-option-DrRyivWp.js +82 -0
- package/dist/react/chart.d.ts +99 -0
- package/dist/react/chart.js +49 -0
- package/dist/react/index.d.ts +28 -0
- package/dist/react/index.js +4 -1
- package/dist/{row-resize-D-8s3cqT.js → row-resize-Cf8qPLbi.js} +44 -36
- package/dist/shadow/GridMenus-B1mC1aPp.js +1077 -0
- package/dist/shadow/SvChartMenu-CBMKm7Xb.js +413 -0
- package/dist/shadow/SvDateRangeInput-BrYTQEMM.js +197 -0
- package/dist/shadow/SvDateTimePicker-CnLlqNDQ.js +766 -0
- package/dist/shadow/SvField-Bmzp3ObZ.js +147 -0
- package/dist/shadow/SvGridCellEditor-B005dmV1.js +560 -0
- package/dist/shadow/SvGridChart-4TcL9Rj2.js +3702 -0
- package/dist/shadow/SvGridChartBuilder-C4OL4XYx.js +1165 -0
- package/dist/shadow/SvGridChartPanel-CfHA8Ioq.js +1743 -0
- package/dist/shadow/SvGridChartView-Ci-9_EJ0.js +45 -0
- package/dist/shadow/SvGridDropdown-BlA6iw9m.js +257 -0
- package/dist/{cell-formatting-C0OsDmi_.js → shadow/cell-formatting-Eypm-id0.js} +1 -1
- package/dist/shadow/chart-DoqdUoGg.js +4398 -0
- package/dist/shadow/chart-export-pdf-BirUdchl.js +104 -0
- package/dist/shadow/chart-summary-BP9i-v8M.js +137 -0
- package/dist/shadow/chart-validate-CD6ptiwg.js +180 -0
- package/dist/{client-DjwUji8D.js → shadow/client-DEF0GRjE.js} +1 -1
- package/dist/{column-resize-DvCRUrN3.js → shadow/column-resize-DUPgynvc.js} +3 -3
- package/dist/shadow/date-format-DMTwV8NC.js +1128 -0
- package/dist/shadow/{export-format-C8kZGZfz.js → export-format-DhdZREP1.js} +3 -3
- package/dist/shadow/focus-trap-DvlOlOGM.js +65 -0
- package/dist/shadow/list-option-DrRyivWp.js +82 -0
- package/dist/shadow/{row-resize-D-8s3cqT.js → row-resize-Cf8qPLbi.js} +44 -36
- package/dist/shadow/sv-grid-shadow-element.d.ts +15 -0
- package/dist/shadow/sv-grid-shadow-element.js +4853 -3626
- package/dist/shadow/{svelte-virtualizer.svelte-DZ9UcyfT.js → svelte-virtualizer.svelte-CnGhFGDc.js} +37 -34
- package/dist/sv-grid-element.d.ts +15 -0
- package/dist/sv-grid-element.js +4809 -3612
- package/dist/{svelte-virtualizer.svelte-DZ9UcyfT.js → svelte-virtualizer.svelte-CnGhFGDc.js} +37 -34
- package/dist/vue/chart.d.ts +64 -0
- package/dist/vue/chart.js +41 -0
- package/dist/vue/index.d.ts +11 -2
- package/dist/vue/index.js +4 -1
- package/package.json +18 -5
- package/dist/GridMenus-DpmS1pzo.js +0 -1121
- package/dist/SvDateRangeInput-u4ibte8S.js +0 -196
- package/dist/SvDateTimePicker-DVFiDxUq.js +0 -765
- package/dist/SvField-ChCI-O2O.js +0 -146
- package/dist/SvGridCellEditor-DvsQyE9a.js +0 -550
- package/dist/SvGridChart-yK5Zv85y.js +0 -1199
- package/dist/SvGridChartPanel-B38_VjXM.js +0 -584
- package/dist/SvGridChartView-ScXTF6t-.js +0 -50
- package/dist/SvGridDropdown-DnAESFDu.js +0 -256
- package/dist/chart-uvs3sFJA.js +0 -1220
- package/dist/date-format-CPHqTHN6.js +0 -1127
- package/dist/shadow/GridMenus-DpmS1pzo.js +0 -1121
- package/dist/shadow/SvDateRangeInput-u4ibte8S.js +0 -196
- package/dist/shadow/SvDateTimePicker-DVFiDxUq.js +0 -765
- package/dist/shadow/SvField-ChCI-O2O.js +0 -146
- package/dist/shadow/SvGridCellEditor-DvsQyE9a.js +0 -550
- package/dist/shadow/SvGridChart-yK5Zv85y.js +0 -1199
- package/dist/shadow/SvGridChartPanel-B38_VjXM.js +0 -584
- package/dist/shadow/SvGridChartView-ScXTF6t-.js +0 -50
- package/dist/shadow/SvGridDropdown-DnAESFDu.js +0 -256
- package/dist/shadow/chart-uvs3sFJA.js +0 -1220
- package/dist/shadow/date-format-CPHqTHN6.js +0 -1127
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region ../grid/dist/chart-export.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e instanceof SVGSVGElement ? e : e.querySelector("svg.sv-grid-chart-svg") ?? e.querySelector("svg");
|
|
4
|
+
}
|
|
5
|
+
function t(e, t, n) {
|
|
6
|
+
return getComputedStyle(e).getPropertyValue(t).trim() || n;
|
|
7
|
+
}
|
|
8
|
+
function n(n, r = {}) {
|
|
9
|
+
let i = e(n);
|
|
10
|
+
if (!i) throw Error("chartToSvgString: no <svg> found");
|
|
11
|
+
let a = t(i, "--sg-fg", "#0f172a"), o = t(i, "--sg-muted", "#64748b"), s = t(i, "--sg-border", "#e2e8f0"), c = r.background ?? t(i, "--sg-bg", "#ffffff"), l = i.viewBox.baseVal, u = l && l.width ? l.width : i.clientWidth || 520, d = l && l.height ? l.height : i.clientHeight || 300, f = i.cloneNode(!0);
|
|
12
|
+
f.setAttribute("width", String(u)), f.setAttribute("height", String(d)), f.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
13
|
+
let p = [
|
|
14
|
+
"fill",
|
|
15
|
+
"fill-opacity",
|
|
16
|
+
"stroke",
|
|
17
|
+
"stroke-width",
|
|
18
|
+
"stroke-opacity",
|
|
19
|
+
"stroke-dasharray",
|
|
20
|
+
"stroke-linecap",
|
|
21
|
+
"stroke-linejoin",
|
|
22
|
+
"opacity",
|
|
23
|
+
"font-size",
|
|
24
|
+
"font-family",
|
|
25
|
+
"font-weight",
|
|
26
|
+
"text-anchor"
|
|
27
|
+
], m = i.querySelectorAll("*"), h = f.querySelectorAll("*");
|
|
28
|
+
for (let e = 0; e < m.length; e += 1) {
|
|
29
|
+
let t = h[e];
|
|
30
|
+
if (!t || !t.style) continue;
|
|
31
|
+
let n = getComputedStyle(m[e]);
|
|
32
|
+
for (let e of p) {
|
|
33
|
+
let r = n.getPropertyValue(e);
|
|
34
|
+
r && r !== "normal" && t.style.setProperty(e, r);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
f.querySelectorAll(".sv-grid-chart-hit").forEach((e) => e.remove());
|
|
38
|
+
let g = document.createElementNS("http://www.w3.org/2000/svg", "style");
|
|
39
|
+
g.textContent = `
|
|
40
|
+
.sv-grid-chart-axis { fill: ${o}; font-size: 10px; font-family: sans-serif; }
|
|
41
|
+
.sv-grid-chart-gridline { stroke: ${s}; stroke-width: 1; opacity: 0.6; }
|
|
42
|
+
.sv-grid-chart-gridline.is-zero { stroke: ${o}; opacity: 0.9; }
|
|
43
|
+
.sv-grid-chart-datalabel { fill: ${a}; font-size: 9.5px; font-weight: 600; font-family: sans-serif; }
|
|
44
|
+
.sv-grid-chart-datalabel.on-bar { fill: #fff; }
|
|
45
|
+
.sv-grid-chart-donut-total { fill: ${a}; font-size: 16px; font-weight: 800; font-family: sans-serif; }
|
|
46
|
+
.sv-grid-chart-donut-label { fill: ${o}; font-size: 10px; font-family: sans-serif; }
|
|
47
|
+
`, f.insertBefore(g, f.firstChild);
|
|
48
|
+
let _ = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
49
|
+
return _.setAttribute("x", "0"), _.setAttribute("y", "0"), _.setAttribute("width", String(u)), _.setAttribute("height", String(d)), _.setAttribute("fill", c), f.insertBefore(_, g.nextSibling), new XMLSerializer().serializeToString(f);
|
|
50
|
+
}
|
|
51
|
+
function r(e, t) {
|
|
52
|
+
let n = document.createElement("a");
|
|
53
|
+
n.href = e, n.download = t, document.body.appendChild(n), n.click(), n.remove();
|
|
54
|
+
}
|
|
55
|
+
function i(t, r = {}) {
|
|
56
|
+
let i = n(t, r), a = r.scale ?? 2, o = e(t), s = o.viewBox.baseVal, c = (s && s.width ? s.width : o.clientWidth || 520) * a, l = (s && s.height ? s.height : o.clientHeight || 300) * a;
|
|
57
|
+
return new Promise((e, t) => {
|
|
58
|
+
let n = URL.createObjectURL(new Blob([i], { type: "image/svg+xml" })), r = new Image();
|
|
59
|
+
r.onload = () => {
|
|
60
|
+
let i = document.createElement("canvas");
|
|
61
|
+
i.width = Math.round(c), i.height = Math.round(l);
|
|
62
|
+
let a = i.getContext("2d");
|
|
63
|
+
if (!a) {
|
|
64
|
+
URL.revokeObjectURL(n), t(/* @__PURE__ */ Error("canvas 2d context unavailable"));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
a.drawImage(r, 0, 0, i.width, i.height), URL.revokeObjectURL(n), i.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("toBlob failed")), "image/png");
|
|
68
|
+
}, r.onerror = () => {
|
|
69
|
+
URL.revokeObjectURL(n), t(/* @__PURE__ */ Error("failed to rasterize chart SVG"));
|
|
70
|
+
}, r.src = n;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
var a = (e) => {
|
|
74
|
+
let t = e == null || typeof e == "number" && !Number.isFinite(e) ? "" : String(e);
|
|
75
|
+
return /[",\n]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
76
|
+
};
|
|
77
|
+
function o(e) {
|
|
78
|
+
let t = e.series ?? [];
|
|
79
|
+
if (t.some((e) => e.points?.length)) {
|
|
80
|
+
let e = [
|
|
81
|
+
"Series",
|
|
82
|
+
"X",
|
|
83
|
+
"Y",
|
|
84
|
+
"Size",
|
|
85
|
+
"Label"
|
|
86
|
+
].map(a).join(","), n = [];
|
|
87
|
+
for (let e of t) for (let t of e.points ?? []) n.push([
|
|
88
|
+
e.label,
|
|
89
|
+
t.x,
|
|
90
|
+
t.y,
|
|
91
|
+
t.r ?? "",
|
|
92
|
+
t.label ?? ""
|
|
93
|
+
].map(a).join(","));
|
|
94
|
+
return n.length ? [e, ...n].join("\n") : "";
|
|
95
|
+
}
|
|
96
|
+
let n = e.categories ?? [];
|
|
97
|
+
if (!n.length || !t.length) return "";
|
|
98
|
+
let r = ["Category"];
|
|
99
|
+
for (let e of t) e.ohlc ? r.push(`${e.label} Open`, `${e.label} High`, `${e.label} Low`, `${e.label} Close`, ...e.volumes ? [`${e.label} Volume`] : []) : e.boxes ? r.push(`${e.label} Min`, `${e.label} Q1`, `${e.label} Median`, `${e.label} Q3`, `${e.label} Max`, `${e.label} Outliers`) : e.errors ? r.push(e.label, `${e.label} Low`, `${e.label} High`) : e.lowValues ? r.push(`${e.label} low`, `${e.label} high`) : e.targets ? r.push(e.label, `${e.label} target`) : r.push(e.label);
|
|
100
|
+
let i = n.map((e, n) => {
|
|
101
|
+
let r = [e];
|
|
102
|
+
for (let e of t) if (e.ohlc) {
|
|
103
|
+
let t = e.ohlc[n];
|
|
104
|
+
r.push(t?.o ?? "", t?.h ?? "", t?.l ?? "", t?.c ?? ""), e.volumes && r.push(e.volumes[n] ?? "");
|
|
105
|
+
} else if (e.boxes) {
|
|
106
|
+
let t = e.boxes[n];
|
|
107
|
+
r.push(t?.min ?? "", t?.q1 ?? "", t?.median ?? "", t?.q3 ?? "", t?.max ?? "", t?.outliers?.join(" ") ?? "");
|
|
108
|
+
} else if (e.errors) {
|
|
109
|
+
let t = e.values[n], i = e.errors[n], a = i == null ? "" : typeof i == "number" ? (t ?? 0) - Math.abs(i) : Math.min(i.lo, i.hi), o = i == null ? "" : typeof i == "number" ? (t ?? 0) + Math.abs(i) : Math.max(i.lo, i.hi);
|
|
110
|
+
r.push(t ?? "", a, o);
|
|
111
|
+
} else e.lowValues ? r.push(e.lowValues[n] ?? "", e.values[n] ?? "") : e.targets ? r.push(e.values[n] ?? "", e.targets[n] ?? "") : r.push(e.values[n] ?? "");
|
|
112
|
+
return r.map(a).join(",");
|
|
113
|
+
});
|
|
114
|
+
return [r.map(a).join(","), ...i].join("\n");
|
|
115
|
+
}
|
|
116
|
+
function s(e) {
|
|
117
|
+
let t = e.series ?? [];
|
|
118
|
+
return t.some((e) => e.points?.length) ? !0 : !!(e.categories?.length && t.length);
|
|
119
|
+
}
|
|
120
|
+
function c(e, t = "chart.csv") {
|
|
121
|
+
let n = o(e);
|
|
122
|
+
if (!n) return !1;
|
|
123
|
+
let i = URL.createObjectURL(new Blob([n], { type: "text/csv;charset=utf-8" }));
|
|
124
|
+
return r(i, t), setTimeout(() => URL.revokeObjectURL(i), 1e3), !0;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { c as i, i as n, n as r, s as t };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { n as e, r as t } from "./chart-export-BHGuh_kZ.js";
|
|
2
|
+
//#region ../grid/dist/chart-export-pdf.js
|
|
3
|
+
var n = {
|
|
4
|
+
A4: [595.28, 841.89],
|
|
5
|
+
Letter: [612, 792]
|
|
6
|
+
};
|
|
7
|
+
function r(e) {
|
|
8
|
+
let t = new Uint8Array(e.length);
|
|
9
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
10
|
+
let r = e.charCodeAt(n);
|
|
11
|
+
t[n] = r < 256 ? r : 63;
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
function i(e) {
|
|
16
|
+
return "(" + e.replace(/[\\()]/g, (e) => "\\" + e).replace(/[\r\n]+/g, " ") + ")";
|
|
17
|
+
}
|
|
18
|
+
function a(e, t) {
|
|
19
|
+
return e.length * t * .5;
|
|
20
|
+
}
|
|
21
|
+
function o(e, t, n) {
|
|
22
|
+
return new Promise((r, i) => {
|
|
23
|
+
let a = URL.createObjectURL(e), o = new Image();
|
|
24
|
+
o.onload = () => {
|
|
25
|
+
let e = document.createElement("canvas");
|
|
26
|
+
e.width = o.naturalWidth || o.width, e.height = o.naturalHeight || o.height;
|
|
27
|
+
let s = e.getContext("2d");
|
|
28
|
+
if (!s) {
|
|
29
|
+
URL.revokeObjectURL(a), i(/* @__PURE__ */ Error("canvas 2d context unavailable"));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
s.fillStyle = t, s.fillRect(0, 0, e.width, e.height), s.drawImage(o, 0, 0), URL.revokeObjectURL(a), e.toBlob((t) => {
|
|
33
|
+
if (!t) {
|
|
34
|
+
i(/* @__PURE__ */ Error("toBlob failed"));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
t.arrayBuffer().then((t) => r({
|
|
38
|
+
bytes: new Uint8Array(t),
|
|
39
|
+
width: e.width,
|
|
40
|
+
height: e.height
|
|
41
|
+
}), i);
|
|
42
|
+
}, "image/jpeg", n);
|
|
43
|
+
}, o.onerror = () => {
|
|
44
|
+
URL.revokeObjectURL(a), i(/* @__PURE__ */ Error("failed to decode chart PNG"));
|
|
45
|
+
}, o.src = a;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function s(e, t = {}) {
|
|
49
|
+
let [o, s] = n[t.page ?? "A4"], c = t.orientation ? t.orientation === "landscape" : e.width / e.height > o / s, l = c ? s : o, u = c ? o : s, d = (t.title ?? "").trim(), f = (t.subtitle ?? "").trim(), p = (t.caption ?? "").trim(), m = u - 40, h = [], g = (e, t, n) => {
|
|
50
|
+
m -= t + 4, h.push(`BT /F1 ${t} Tf ${n} g 40 ${m.toFixed(2)} Td ${i(e)} Tj ET`);
|
|
51
|
+
};
|
|
52
|
+
d && g(d, 16, 0), f && g(f, 11, .4), (d || f) && (m -= 8);
|
|
53
|
+
let _ = p ? 20 : 0, v = l - 80, y = m - 40 - _, b = Math.min(v / e.width, y / e.height), x = e.width * b, S = e.height * b, C = 40 + (v - x) / 2, w = m - S;
|
|
54
|
+
if (h.push(`q ${x.toFixed(2)} 0 0 ${S.toFixed(2)} ${C.toFixed(2)} ${w.toFixed(2)} cm /Im1 Do Q`), p) {
|
|
55
|
+
let e = a(p, 9) > v ? p.slice(0, Math.floor(v / 4.5) - 3) + "..." : p;
|
|
56
|
+
h.push(`BT /F1 9 Tf 0.4 g 40 ${36 .toFixed(2)} Td ${i(e)} Tj ET`);
|
|
57
|
+
}
|
|
58
|
+
let T = h.join("\n"), E = [], D = [], O = 0, k = (e) => {
|
|
59
|
+
E.push(e), O += e.length;
|
|
60
|
+
};
|
|
61
|
+
k("%PDF-1.4\n%âãÏÓ\n");
|
|
62
|
+
let A = (e, t, n) => {
|
|
63
|
+
D[e] = O, k(`${e} 0 obj\n${t}\n`), n && (k("stream\n"), k(n), k("\nendstream\n")), k("endobj\n");
|
|
64
|
+
};
|
|
65
|
+
A(1, "<< /Type /Catalog /Pages 2 0 R >>"), A(2, "<< /Type /Pages /Kids [3 0 R] /Count 1 >>"), A(3, `<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${l.toFixed(2)} ${u.toFixed(2)}] /Resources << /XObject << /Im1 4 0 R >> /Font << /F1 5 0 R >> >> /Contents 6 0 R >>`), A(4, `<< /Type /XObject /Subtype /Image /Width ${e.width} /Height ${e.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${e.bytes.length} >>`, e.bytes), A(5, "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>"), A(6, `<< /Length ${T.length} >>`, r(T));
|
|
66
|
+
let j = O;
|
|
67
|
+
k("xref\n0 7\n0000000000 65535 f \n");
|
|
68
|
+
for (let e = 1; e <= 6; e += 1) k(`${String(D[e]).padStart(10, "0")} 00000 n \n`);
|
|
69
|
+
k(`trailer\n<< /Size 7 /Root 1 0 R >>\nstartxref\n${j}\n%%EOF\n`);
|
|
70
|
+
let M = new Uint8Array(new ArrayBuffer(O)), N = 0;
|
|
71
|
+
for (let e of E) {
|
|
72
|
+
let t = typeof e == "string" ? r(e) : e;
|
|
73
|
+
M.set(t, N), N += t.length;
|
|
74
|
+
}
|
|
75
|
+
return M;
|
|
76
|
+
}
|
|
77
|
+
async function c(t, n = {}) {
|
|
78
|
+
let r = t instanceof SVGSVGElement ? t : t.querySelector("svg.sv-grid-chart-svg") ?? t.querySelector("svg"), i = n.background ?? (r && getComputedStyle(r).getPropertyValue("--sg-bg").trim() || "#ffffff"), a = s(await o(await e(t, {
|
|
79
|
+
...n,
|
|
80
|
+
background: i,
|
|
81
|
+
scale: n.scale ?? 2
|
|
82
|
+
}), i, n.quality ?? .92), n);
|
|
83
|
+
return new Blob([a.buffer], { type: "application/pdf" });
|
|
84
|
+
}
|
|
85
|
+
async function l(e, t = "chart.pdf", n = {}) {
|
|
86
|
+
let r = await c(e, n), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
87
|
+
a.href = i, a.download = t, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(i), 1e3);
|
|
88
|
+
}
|
|
89
|
+
function u(e, n = {}) {
|
|
90
|
+
let r = t(e, n), i = window.open("", "_blank", "width=900,height=700");
|
|
91
|
+
if (!i) return !1;
|
|
92
|
+
let a = (e) => e.replace(/[&<>]/g, (e) => ({
|
|
93
|
+
"&": "&",
|
|
94
|
+
"<": "<",
|
|
95
|
+
">": ">"
|
|
96
|
+
})[e]);
|
|
97
|
+
i.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>${a(n.title ?? "Chart")}</title><style>body{margin:24px;font-family:system-ui,sans-serif}h1{font-size:16px;margin:0 0 12px}svg{max-width:100%;height:auto}@page{margin:12mm}</style></head><body>` + (n.title ? `<h1>${a(n.title)}</h1>` : "") + r + "</body></html>"), i.document.close();
|
|
98
|
+
let o = () => {
|
|
99
|
+
i.focus(), i.print();
|
|
100
|
+
};
|
|
101
|
+
return i.document.readyState === "complete" ? setTimeout(o, 50) : i.addEventListener("load", () => setTimeout(o, 50)), !0;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { l as downloadChartPdf, u as printChart };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { i as e, n as t, t as n } from "./chart-trend-DP6DSsBa.js";
|
|
2
|
+
//#region ../grid/dist/chart-summary.js
|
|
3
|
+
var r = (e) => typeof e == "number" && Number.isFinite(e);
|
|
4
|
+
function i(e) {
|
|
5
|
+
let t = -1, n = -1;
|
|
6
|
+
for (let i = 0; i < e.length; i += 1) r(e[i]) && (t < 0 && (t = i), n = i);
|
|
7
|
+
return t < 0 ? null : {
|
|
8
|
+
i0: t,
|
|
9
|
+
v0: e[t],
|
|
10
|
+
i1: n,
|
|
11
|
+
v1: e[n]
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function a(e) {
|
|
15
|
+
let t = -Infinity, n = Infinity, i = -1, a = -1;
|
|
16
|
+
return e.forEach((e, o) => {
|
|
17
|
+
r(e) && (e > t && (t = e, i = o), e < n && (n = e, a = o));
|
|
18
|
+
}), i < 0 ? null : {
|
|
19
|
+
max: t,
|
|
20
|
+
iMax: i,
|
|
21
|
+
min: n,
|
|
22
|
+
iMin: a
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var o = (e, t) => {
|
|
26
|
+
if (e === 0) return "";
|
|
27
|
+
let n = Math.abs((t - e) / Math.abs(e) * 100);
|
|
28
|
+
return `${n >= 10 ? Math.round(n) : Math.round(n * 10) / 10}%`;
|
|
29
|
+
};
|
|
30
|
+
function s(e, t, r) {
|
|
31
|
+
let s = e.ohlc ? e.ohlc.map((e) => e ? e.c : NaN) : e.values, c = i(s);
|
|
32
|
+
if (!c) return `${e.label} has no values.`;
|
|
33
|
+
let l = (e) => t[e] ?? `#${e + 1}`;
|
|
34
|
+
if (c.i0 === c.i1) return `${e.label} is ${r(c.v0)} at ${l(c.i0)}.`;
|
|
35
|
+
let u = n(s), d = u[u.length - 1] - u[0], f = Math.abs(c.v1 - c.v0), p = Math.max(Math.abs(c.v0), Math.abs(c.v1), 1e-9), m = f / p < .02 && Math.abs(d) / p < .05, h = m ? "holds at about" : c.v1 > c.v0 ? "rises" : "falls", g = o(c.v0, c.v1), _ = m ? `${e.label} holds at about ${r(c.v1)} from ${l(c.i0)} to ${l(c.i1)}` : `${e.label} ${h}${g ? ` ${g}` : ""} from ${r(c.v0)} at ${l(c.i0)} to ${r(c.v1)} at ${l(c.i1)}`, v = a(s);
|
|
36
|
+
if (v && !m) {
|
|
37
|
+
let e = v.iMax !== c.i0 && v.iMax !== c.i1, t = v.iMin !== c.i0 && v.iMin !== c.i1;
|
|
38
|
+
e && (_ += `, peaking at ${r(v.max)} at ${l(v.iMax)}`), t && (_ += `, lowest at ${r(v.min)} at ${l(v.iMin)}`);
|
|
39
|
+
}
|
|
40
|
+
return _ + ".";
|
|
41
|
+
}
|
|
42
|
+
function c(e, t, n, i) {
|
|
43
|
+
let a = t.reduce((e, t) => e + (r(t) ? Math.abs(t) : 0), 0);
|
|
44
|
+
if (!a) return `No ${i} has a value.`;
|
|
45
|
+
let o = e.map((e, n) => ({
|
|
46
|
+
l: e,
|
|
47
|
+
v: r(t[n]) ? Math.abs(t[n]) : 0
|
|
48
|
+
})).sort((e, t) => t.v - e.v), s = o.slice(0, 3).map((e) => `${e.l} ${Math.round(e.v / a * 100)}%`), c = o.length > 3 ? `, ${o.length - 3} more share the rest` : "";
|
|
49
|
+
return `${e.length} ${i}s totalling ${n(a)}: ${s.join(", ")}${c}.`;
|
|
50
|
+
}
|
|
51
|
+
function l(n, i = {}) {
|
|
52
|
+
let a = i.formatValue ?? ((t) => e(t, n.valueFormat, n)), l = i.maxSeries ?? 4, u = n.categories ?? [], d = (n.series ?? []).filter((e) => e.visible !== !1), f = n.type;
|
|
53
|
+
try {
|
|
54
|
+
if (f === "pie" || f === "radial-bar" || f === "nightingale") {
|
|
55
|
+
let e = d[0];
|
|
56
|
+
return !e || !e.values.some(r) ? "No data." : c(u, e.values, a, "slice");
|
|
57
|
+
}
|
|
58
|
+
if (f === "treemap" || f === "sunburst") {
|
|
59
|
+
let e = (n.treemap ?? n.tree)?.children ?? [];
|
|
60
|
+
if (!e.length) return "No data.";
|
|
61
|
+
let t = (e) => e.value ?? (e.children ?? []).reduce((e, n) => e + t(n), 0);
|
|
62
|
+
return c(e.map((e) => e.name), e.map((e) => t(e)), a, "node");
|
|
63
|
+
}
|
|
64
|
+
if (f === "gauge") {
|
|
65
|
+
if (!r(n.gaugeValue)) return "No data.";
|
|
66
|
+
let e = n.gaugeMin ?? 0, t = n.gaugeMax ?? 100, i = t > e ? Math.round((n.gaugeValue - e) / (t - e) * 100) : 0, o = r(n.gaugeTarget) ? `, ${n.gaugeValue >= n.gaugeTarget ? "above" : "below"} the target of ${a(n.gaugeTarget)}` : "";
|
|
67
|
+
return `${a(n.gaugeValue)}${n.gaugeUnit ? " " + n.gaugeUnit : ""}, ${i}% of the way from ${a(e)} to ${a(t)}${o}.`;
|
|
68
|
+
}
|
|
69
|
+
if (f === "scatter") {
|
|
70
|
+
let e = d.flatMap((e) => e.points ?? []).filter((e) => r(e.x) && r(e.y));
|
|
71
|
+
if (!e.length) return "No data.";
|
|
72
|
+
let n = t(e.map((e) => e.x), e.map((e) => e.y)), i = Math.abs(n) >= .7 ? "strong" : Math.abs(n) >= .4 ? "moderate" : Math.abs(n) >= .2 ? "weak" : "no", a = i === "no" ? "no clear correlation" : `a ${i} ${n > 0 ? "positive" : "negative"} correlation (r ${n.toFixed(2)})`;
|
|
73
|
+
return `${e.length} points in ${d.length} series with ${a} between x and y.`;
|
|
74
|
+
}
|
|
75
|
+
if (f === "candlestick" || f === "ohlc") {
|
|
76
|
+
let e = d.find((e) => e.ohlc) ?? d[0], t = (e?.ohlc ?? []).filter((e) => !!e);
|
|
77
|
+
if (!e || !t.length) return "No data.";
|
|
78
|
+
let n = t[t.length - 1], r = t.length > 1 ? t[t.length - 2] : null, i = Math.max(...t.map((e) => e.h)), s = Math.min(...t.map((e) => e.l)), c = r ? `, ${n.c >= r.c ? "up" : "down"} ${o(r.c, n.c)} on the session` : "";
|
|
79
|
+
return `${e.label}: last close ${a(n.c)}${c}, ranging ${a(s)} to ${a(i)} over ${t.length} bars.`;
|
|
80
|
+
}
|
|
81
|
+
if (f === "heatmap") {
|
|
82
|
+
let e = null;
|
|
83
|
+
for (let t of d) t.values.forEach((n, i) => {
|
|
84
|
+
r(n) && (!e || n > e.v) && (e = {
|
|
85
|
+
v: n,
|
|
86
|
+
row: t.label,
|
|
87
|
+
col: u[i] ?? String(i)
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
if (!e) return "No data.";
|
|
91
|
+
let t = e;
|
|
92
|
+
return `${d.length} rows by ${u.length} columns; the highest cell is ${a(t.v)} at ${t.row} and ${t.col}.`;
|
|
93
|
+
}
|
|
94
|
+
if (f === "calendar") {
|
|
95
|
+
let e = (n.calendarValues ?? []).filter((e) => r(e.value));
|
|
96
|
+
if (!e.length) return "No data.";
|
|
97
|
+
let t = e.reduce((e, t) => t.value > e.value ? t : e, e[0]), i = e.reduce((e, t) => e + t.value, 0);
|
|
98
|
+
return `${e.length} days totalling ${a(i)}; the busiest is ${t.date} at ${a(t.value)}.`;
|
|
99
|
+
}
|
|
100
|
+
if (f === "funnel") {
|
|
101
|
+
let e = d[0], t = (e?.values ?? []).filter(r);
|
|
102
|
+
if (!e || t.length < 2) return e && t.length === 1 ? `${u[0] ?? e.label}: ${a(t[0])}.` : "No data.";
|
|
103
|
+
let n = t[0], i = t[t.length - 1], o = n ? Math.round(i / n * 100) : 0, s = 0, c = "";
|
|
104
|
+
for (let e = 1; e < t.length; e += 1) {
|
|
105
|
+
let n = t[e - 1] ? 1 - t[e] / t[e - 1] : 0;
|
|
106
|
+
n > s && (s = n, c = u[e] ?? `step ${e + 1}`);
|
|
107
|
+
}
|
|
108
|
+
return `${o}% of ${a(n)} at ${u[0] ?? "the top"} reach ${u[t.length - 1] ?? "the bottom"}${c ? `; the biggest drop is into ${c} (${Math.round(s * 100)}% lost)` : ""}.`;
|
|
109
|
+
}
|
|
110
|
+
if (f === "boxplot") {
|
|
111
|
+
let e = null;
|
|
112
|
+
for (let t of d) for (let n of t.boxes ?? []) {
|
|
113
|
+
if (!n) continue;
|
|
114
|
+
let r = n.q3 - n.q1;
|
|
115
|
+
(!e || r > e.spread) && (e = {
|
|
116
|
+
label: t.label,
|
|
117
|
+
spread: r
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return e ? `${d.length} distributions over ${u.length} categories; ${e.label} has the widest interquartile range at ${a(e.spread)}.` : "No data.";
|
|
121
|
+
}
|
|
122
|
+
if (f === "sankey" || f === "chord") {
|
|
123
|
+
let e = n.sankeyLinks ?? [];
|
|
124
|
+
if (!e.length) return "No data.";
|
|
125
|
+
let t = e.reduce((e, t) => e + (r(t.value) ? t.value : 0), 0), i = [...e].sort((e, t) => t.value - e.value)[0];
|
|
126
|
+
return `${e.length} flows totalling ${a(t)}; the largest is ${i.source} to ${i.target} at ${a(i.value)}.`;
|
|
127
|
+
}
|
|
128
|
+
let e = d.filter((e) => e.values.some(r) || e.ohlc);
|
|
129
|
+
if (!e.length) return "No data.";
|
|
130
|
+
let i = e.slice(0, l), p = i.map((e) => s(e, u, a)), m = e.length > i.length ? ` And ${e.length - i.length} more series.` : "";
|
|
131
|
+
return `${p.join(" ")}${m}`;
|
|
132
|
+
} catch {
|
|
133
|
+
return "No data.";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { l as chartSummary };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region ../grid/dist/cell-formatting.js
|
|
2
|
+
var e = /* @__PURE__ */ new Map();
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = (Array.isArray(t) ? t.join(",") : t ?? "") + "|" + (n.style ?? "") + "|" + (n.currency ?? "") + "|" + (n.minimumFractionDigits ?? "") + "|" + (n.maximumFractionDigits ?? "") + "|" + (n.useGrouping ?? "") + "|" + (n.currencyDisplay ?? "") + "|" + (n.notation ?? ""), i = e.get(r);
|
|
5
|
+
return i || (i = new Intl.NumberFormat(t, n), e.set(r, i)), i;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../grid/dist/chart-format.js
|
|
9
|
+
function n(e) {
|
|
10
|
+
let t = Math.abs(e);
|
|
11
|
+
return t >= 1e6 ? `${(e / 1e6).toFixed(t % 1e6 ? 1 : 0)}M` : t >= 1e3 ? `${(e / 1e3).toFixed(t % 1e3 ? 1 : 0)}k` : String(Math.round(e * 100) / 100);
|
|
12
|
+
}
|
|
13
|
+
function r(e, r, i) {
|
|
14
|
+
if (!Number.isFinite(e)) return "";
|
|
15
|
+
if (i && (i.locale || i.currency)) {
|
|
16
|
+
let n = r === "currency" ? "currency" : r === "percent" ? "percent" : "decimal", a = {
|
|
17
|
+
notation: "compact",
|
|
18
|
+
maximumFractionDigits: 1
|
|
19
|
+
};
|
|
20
|
+
return n === "currency" ? (a.style = "currency", a.currency = i.currency || "USD") : n === "percent" && (a.style = "percent"), t(i.locale, a).format(e);
|
|
21
|
+
}
|
|
22
|
+
if (r === "currency") return `${e < 0 ? "-" : ""}$${n(Math.abs(e))}`;
|
|
23
|
+
if (r === "percent") {
|
|
24
|
+
let t = e * 100;
|
|
25
|
+
return `${Math.round(t * 10) / 10}%`;
|
|
26
|
+
}
|
|
27
|
+
return n(e);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ../grid/dist/chart-trend.js
|
|
31
|
+
function i(e) {
|
|
32
|
+
let t = 0, n = 0, r = 0, i = 0, a = 0;
|
|
33
|
+
for (let o = 0; o < e.length; o += 1) {
|
|
34
|
+
let s = e[o];
|
|
35
|
+
Number.isFinite(s) && (t += 1, n += o, r += s, i += o * o, a += o * s);
|
|
36
|
+
}
|
|
37
|
+
if (t < 2) return e.map(() => NaN);
|
|
38
|
+
let o = t * i - n * n;
|
|
39
|
+
if (o === 0) return e.map(() => r / t);
|
|
40
|
+
let s = (t * a - n * r) / o, c = (r - s * n) / t;
|
|
41
|
+
return e.map((e, t) => s * t + c);
|
|
42
|
+
}
|
|
43
|
+
function a(e, t) {
|
|
44
|
+
let n = 0, r = 0, i = 0, a = Math.min(e.length, t.length);
|
|
45
|
+
for (let o = 0; o < a; o += 1) Number.isFinite(e[o]) && Number.isFinite(t[o]) && (n += 1, r += e[o], i += t[o]);
|
|
46
|
+
if (n < 2) return 0;
|
|
47
|
+
let o = r / n, s = i / n, c = 0, l = 0, u = 0;
|
|
48
|
+
for (let n = 0; n < a; n += 1) {
|
|
49
|
+
if (!Number.isFinite(e[n]) || !Number.isFinite(t[n])) continue;
|
|
50
|
+
let r = e[n] - o, i = t[n] - s;
|
|
51
|
+
c += r * i, l += r * r, u += i * i;
|
|
52
|
+
}
|
|
53
|
+
return l === 0 || u === 0 ? 0 : c / Math.sqrt(l * u);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { r as i, a as n, n as r, i as t };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
//#region ../grid/dist/chart-validate.js
|
|
2
|
+
var e = /* @__PURE__ */ "bar.line.area.pie.scatter.heatmap.waterfall.funnel.radar.calendar.gauge.treemap.sankey.candlestick.ohlc.boxplot.histogram.range-bar.range-area.lollipop.dumbbell.pareto.stream.sunburst.radial-bar.radial-column.nightingale.chord.bullet".split("."), t = /* @__PURE__ */ "type.categories.series.width.height.palette.categoryColors.valueFormat.locale.currency.categoryGroups.stacked.stacked100.orientation.innerRadius.referenceLines.xType.yAxisTitle.y2AxisTitle.xAxisTitle.yScale.y2Scale.xAxis.yAxis.y2Axis.title.subtitle.caption.referenceBands.nullAs.decimate.dataLabels.annotations.seriesLabels.responsive.style.drawings.lastPriceLine.patternFallback.calendarValues.calendarStart.calendarEnd.gaugeValue.gaugeMin.gaugeMax.gaugeTarget.gaugeRanges.gaugeUnit.treemap.sankeyNodes.sankeyLinks.waterfallTotals.waterfallColors.candleColors.candleStyle.funnelShape.stackOffset.binEdges.tree.bulletRanges.colorScale".split("."), n = /* @__PURE__ */ "label.values.color.type.ohlc.volumes.boxes.errors.axis.points.rowIds.overlay.overlayColor.pattern.smooth.upperValues.lowerValues.marker.markers.colors.stack.strokeWidth.dash.opacity.visible.gradient.step.connectNulls.nullAs.lowValues.targets".split("."), r = /* @__PURE__ */ new Set([
|
|
3
|
+
"bar",
|
|
4
|
+
"line",
|
|
5
|
+
"area",
|
|
6
|
+
"scatter",
|
|
7
|
+
"candlestick",
|
|
8
|
+
"ohlc",
|
|
9
|
+
"boxplot",
|
|
10
|
+
"range-bar",
|
|
11
|
+
"range-area",
|
|
12
|
+
"lollipop",
|
|
13
|
+
"dumbbell"
|
|
14
|
+
]), i = [
|
|
15
|
+
"values",
|
|
16
|
+
"rowIds",
|
|
17
|
+
"upperValues",
|
|
18
|
+
"lowerValues",
|
|
19
|
+
"ohlc",
|
|
20
|
+
"boxes",
|
|
21
|
+
"errors",
|
|
22
|
+
"markers",
|
|
23
|
+
"colors",
|
|
24
|
+
"lowValues",
|
|
25
|
+
"targets",
|
|
26
|
+
"volumes"
|
|
27
|
+
], a = /* @__PURE__ */ new Set([
|
|
28
|
+
"scatter",
|
|
29
|
+
"gauge",
|
|
30
|
+
"treemap",
|
|
31
|
+
"sankey",
|
|
32
|
+
"calendar",
|
|
33
|
+
"sunburst",
|
|
34
|
+
"chord",
|
|
35
|
+
"histogram"
|
|
36
|
+
]), o = /^(linear|exp|log|power|vwap|sma:\d+|ema:\d+|wma:\d+|bb:\d+:\d+(?:\.\d+)?|poly:\d+)$/;
|
|
37
|
+
function s(e, t) {
|
|
38
|
+
let n = Array.from({ length: t.length + 1 }, (e, t) => t);
|
|
39
|
+
for (let r = 1; r <= e.length; r += 1) {
|
|
40
|
+
let i = n[0];
|
|
41
|
+
n[0] = r;
|
|
42
|
+
for (let a = 1; a <= t.length; a += 1) {
|
|
43
|
+
let o = n[a];
|
|
44
|
+
n[a] = Math.min(n[a] + 1, n[a - 1] + 1, i + (e[r - 1] === t[a - 1] ? 0 : 1)), i = o;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return n[t.length];
|
|
48
|
+
}
|
|
49
|
+
function c(e, t) {
|
|
50
|
+
let n = null, r = Infinity;
|
|
51
|
+
for (let i of t) {
|
|
52
|
+
let t = s(e.toLowerCase(), i.toLowerCase());
|
|
53
|
+
t < r && (r = t, n = i);
|
|
54
|
+
}
|
|
55
|
+
return n !== null && r <= Math.max(1, Math.floor(e.length / 3)) ? n : null;
|
|
56
|
+
}
|
|
57
|
+
var l = (e) => typeof e == "object" && !!e && !Array.isArray(e), u = (e) => typeof e == "number", d = /* @__PURE__ */ new WeakSet();
|
|
58
|
+
function f(e, t = (e) => console.warn(e)) {
|
|
59
|
+
if (typeof e != "object" || !e || d.has(e)) return [];
|
|
60
|
+
d.add(e);
|
|
61
|
+
let n = p(e);
|
|
62
|
+
for (let e of n) t(`[SvChart] ${e.path ? e.path + ": " : ""}${e.message}`);
|
|
63
|
+
return n;
|
|
64
|
+
}
|
|
65
|
+
function p(s) {
|
|
66
|
+
let d = [], f = (e, t, n) => d.push({
|
|
67
|
+
code: `chart/${e}`,
|
|
68
|
+
path: t,
|
|
69
|
+
message: n,
|
|
70
|
+
severity: "error"
|
|
71
|
+
}), p = (e, t, n) => d.push({
|
|
72
|
+
code: `chart/${e}`,
|
|
73
|
+
path: t,
|
|
74
|
+
message: n,
|
|
75
|
+
severity: "warning"
|
|
76
|
+
});
|
|
77
|
+
if (!l(s)) return f("not-an-object", "", "a ChartSpec is an object with type, categories and series"), d;
|
|
78
|
+
let m = s;
|
|
79
|
+
for (let e of Object.keys(m)) {
|
|
80
|
+
if (t.includes(e)) continue;
|
|
81
|
+
let n = c(e, t);
|
|
82
|
+
p("unknown-key", e, n ? `unknown field "${e}"; did you mean "${n}"?` : `unknown field "${e}" is ignored`);
|
|
83
|
+
}
|
|
84
|
+
let h = m.type;
|
|
85
|
+
if (typeof h != "string" || !e.includes(h)) {
|
|
86
|
+
let t = typeof h == "string" ? c(h, e) : null;
|
|
87
|
+
f("unknown-type", "type", t ? `unknown chart type "${String(h)}"; did you mean "${t}"?` : `unknown chart type "${String(h)}"`);
|
|
88
|
+
}
|
|
89
|
+
let g = Array.isArray(m.categories) ? m.categories : null;
|
|
90
|
+
g || f("categories", "categories", "categories must be an array of labels");
|
|
91
|
+
let _ = g?.length ?? 0, v = Array.isArray(m.series) ? m.series : null;
|
|
92
|
+
v || f("series", "series", "series must be an array");
|
|
93
|
+
let y = typeof h == "string" && !a.has(h);
|
|
94
|
+
v?.forEach((e, t) => {
|
|
95
|
+
let a = `series[${t}]`;
|
|
96
|
+
if (!l(e)) {
|
|
97
|
+
f("series-shape", a, "a series is an object with label and values");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (let t of Object.keys(e)) {
|
|
101
|
+
if (n.includes(t)) continue;
|
|
102
|
+
let e = c(t, n);
|
|
103
|
+
p("unknown-series-key", `${a}.${t}`, e ? `unknown series field "${t}"; did you mean "${e}"?` : `unknown series field "${t}" is ignored`);
|
|
104
|
+
}
|
|
105
|
+
if (typeof e.label != "string" && p("series-label", `${a}.label`, "a series wants a string label; the legend and tooltip name it"), !Array.isArray(e.values)) {
|
|
106
|
+
f("series-values", `${a}.values`, "values must be an array of numbers");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
let s = e.values;
|
|
110
|
+
y && g && s.length !== _ && !(e.points && s.length === 0) && f("series-length", `${a}.values`, `${s.length} values for ${_} categories; they run in parallel`);
|
|
111
|
+
for (let t of i) {
|
|
112
|
+
if (t === "values") continue;
|
|
113
|
+
let n = e[t];
|
|
114
|
+
if (n !== void 0) {
|
|
115
|
+
if (!Array.isArray(n)) {
|
|
116
|
+
f("series-array", `${a}.${t}`, `${t} must be an array parallel to values`);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
y && n.length !== s.length && f("series-length", `${a}.${t}`, `${t} has ${n.length} entries for ${s.length} values; they run in parallel`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (e.type !== void 0 && (typeof e.type != "string" || !r.has(e.type)) && f("series-type", `${a}.type`, `unknown series type "${String(e.type)}"`), e.axis !== void 0 && e.axis !== "left" && e.axis !== "right" && f("series-axis", `${a}.axis`, `axis is 'left' or 'right', not "${String(e.axis)}"`), e.stack !== void 0) {
|
|
123
|
+
let t = e.type ?? h;
|
|
124
|
+
t !== "bar" && t !== "area" && p("stack-kind", `${a}.stack`, "stack groups apply to bar and area series; ignored here");
|
|
125
|
+
}
|
|
126
|
+
e.overlay !== void 0 && (typeof e.overlay != "string" || !o.test(e.overlay)) && f("overlay", `${a}.overlay`, `unknown overlay "${String(e.overlay)}"; expected linear, poly:N, exp, log, power, sma:N, ema:N, wma:N, bb:N:K or vwap`), Array.isArray(e.ohlc) && e.ohlc.forEach((e, t) => {
|
|
127
|
+
e != null && (!l(e) || !u(e.o) || !u(e.h) || !u(e.l) || !u(e.c) ? f("ohlc-shape", `${a}.ohlc[${t}]`, "an OHLC bar is { o, h, l, c } or null") : e.l > e.h && f("ohlc-range", `${a}.ohlc[${t}]`, `low ${e.l} is above high ${e.h}`));
|
|
128
|
+
}), Array.isArray(e.boxes) && e.boxes.forEach((e, t) => {
|
|
129
|
+
e != null && (!l(e) || !u(e.min) || !u(e.q1) || !u(e.median) || !u(e.q3) || !u(e.max) ? f("box-shape", `${a}.boxes[${t}]`, "a box is { min, q1, median, q3, max } or null") : (e.q1 > e.median || e.median > e.q3) && f("box-order", `${a}.boxes[${t}]`, "a box wants q1 <= median <= q3"));
|
|
130
|
+
}), Array.isArray(e.points) && e.points.forEach((e, t) => {
|
|
131
|
+
(!l(e) || !u(e.x) || !u(e.y)) && f("point-shape", `${a}.points[${t}]`, "a scatter point is { x, y, r?, label? }");
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
for (let e of [
|
|
135
|
+
"xAxis",
|
|
136
|
+
"yAxis",
|
|
137
|
+
"y2Axis"
|
|
138
|
+
]) {
|
|
139
|
+
let t = m[e];
|
|
140
|
+
if (t !== void 0) {
|
|
141
|
+
if (!l(t)) {
|
|
142
|
+
f("axis-shape", e, `${e} must be an object`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
u(t.min) && u(t.max) && t.min >= t.max && f("axis-range", `${e}.min`, `min ${t.min} is not below max ${t.max}`), t.scale === "log" && u(t.min) && t.min <= 0 && f("axis-log-min", `${e}.min`, "a log axis cannot start at or below zero"), t.scale === "log" && e === "xAxis" && t.type !== void 0 && t.type !== "number" && p("axis-log-x", `${e}.scale`, "a log x axis needs type: 'number'"), t.tickCount !== void 0 && (!u(t.tickCount) || t.tickCount <= 0) && f("axis-ticks", `${e}.tickCount`, "tickCount must be a positive number"), t.labelRotation !== void 0 && t.labelRotation !== "auto" && !u(t.labelRotation) && f("axis-rotation", `${e}.labelRotation`, "labelRotation is a number of degrees or 'auto'"), t.scale !== void 0 && t.scale !== "linear" && t.scale !== "log" && f("axis-scale", `${e}.scale`, `scale is 'linear' or 'log', not "${String(t.scale)}"`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (m.stacked100 && typeof h == "string" && h !== "bar" && h !== "area" && p("stacked100-kind", "stacked100", "stacked100 applies to bar and area charts; ignored here"), m.innerRadius !== void 0 && (!u(m.innerRadius) || m.innerRadius < 0 || m.innerRadius > 1) && f("inner-radius", "innerRadius", "innerRadius is a fraction 0..1 of the pie radius"), Array.isArray(m.categoryGroups) && g) {
|
|
149
|
+
let e = m.categoryGroups.reduce((e, t) => e + (l(t) && u(t.span) ? t.span : 0), 0);
|
|
150
|
+
e !== _ && f("category-groups", "categoryGroups", `the group spans add up to ${e}, not the ${_} categories`);
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(m.binEdges) && g && m.binEdges.length !== _ + 1 && f("bin-edges", "binEdges", `binEdges wants ${_ + 1} edges for ${_} bins`), Array.isArray(m.waterfallTotals) && g && m.waterfallTotals.length !== _ && f("waterfall-totals", "waterfallTotals", `waterfallTotals has ${m.waterfallTotals.length} flags for ${_} categories`), Array.isArray(m.responsive) && m.responsive.forEach((e, t) => {
|
|
153
|
+
let n = `responsive[${t}]`;
|
|
154
|
+
if (!l(e)) {
|
|
155
|
+
f("responsive-shape", n, "a rule is { maxWidth?, minWidth?, maxHeight?, spec?, legend? }");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!u(e.maxWidth) && !u(e.minWidth) && !u(e.maxHeight) && p("responsive-size", n, "a rule with no maxWidth, minWidth or maxHeight always applies"), l(e.spec)) for (let t of [
|
|
159
|
+
"width",
|
|
160
|
+
"height",
|
|
161
|
+
"responsive"
|
|
162
|
+
]) t in e.spec && p("responsive-size-key", `${n}.spec.${t}`, `${t} in a responsive rule is ignored; a rule cannot change the size`);
|
|
163
|
+
}), g && typeof h == "string" && !a.has(h)) {
|
|
164
|
+
let e = new Set(g.map(String)), t = m.xType ?? (l(m.xAxis) ? m.xAxis.type : void 0), n = t === "time" || t === "number", r = (t, r, i) => {
|
|
165
|
+
!Array.isArray(t) || n || t.forEach((t, n) => {
|
|
166
|
+
if (!l(t)) return;
|
|
167
|
+
let a = i(t);
|
|
168
|
+
typeof a == "string" && !e.has(a) && p("unknown-category", `${r}[${n}]`, `"${a}" is not one of the categories, so it has no place on the axis`);
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
r(m.annotations, "annotations", (e) => l(e.at) ? e.at.category : void 0), r(Array.isArray(m.referenceLines) ? m.referenceLines.filter((e) => l(e) && e.axis === "x") : [], "referenceLines", (e) => e.value), Array.isArray(m.drawings) && !n && m.drawings.forEach((t, n) => {
|
|
172
|
+
!l(t) || !Array.isArray(t.points) || t.points.forEach((t, r) => {
|
|
173
|
+
l(t) && typeof t.x == "string" && !e.has(t.x) && p("unknown-category", `drawings[${n}].points[${r}].x`, `"${t.x}" is not one of the categories`);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return d;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { f as warnChartSpec };
|