@svgrid/grid-wc 3.0.1 → 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.
Files changed (92) hide show
  1. package/README.md +20 -0
  2. package/dist/GridMenus-B1mC1aPp.js +1077 -0
  3. package/dist/SvChartMenu-CBMKm7Xb.js +413 -0
  4. package/dist/SvDateRangeInput-BrYTQEMM.js +197 -0
  5. package/dist/SvDateTimePicker-CnLlqNDQ.js +766 -0
  6. package/dist/SvField-Bmzp3ObZ.js +147 -0
  7. package/dist/SvGridCellEditor-B005dmV1.js +560 -0
  8. package/dist/SvGridChart-4TcL9Rj2.js +3702 -0
  9. package/dist/SvGridChartBuilder-C4OL4XYx.js +1165 -0
  10. package/dist/SvGridChartPanel-CfHA8Ioq.js +1743 -0
  11. package/dist/SvGridChartView-Ci-9_EJ0.js +45 -0
  12. package/dist/SvGridDropdown-BlA6iw9m.js +257 -0
  13. package/dist/angular/fesm2022/svgrid-grid-wc-angular.mjs +178 -7
  14. package/dist/angular/fesm2022/svgrid-grid-wc-angular.mjs.map +1 -1
  15. package/dist/angular/types/svgrid-grid-wc-angular.d.ts +77 -2
  16. package/dist/chart/SvChartMenu-C-sbGNk8.js +586 -0
  17. package/dist/chart/chart-export-BHGuh_kZ.js +127 -0
  18. package/dist/chart/chart-export-pdf-BjkkIEkE.js +104 -0
  19. package/dist/chart/chart-summary-B86RFA3M.js +137 -0
  20. package/dist/chart/chart-trend-DP6DSsBa.js +56 -0
  21. package/dist/chart/chart-validate-CD6ptiwg.js +180 -0
  22. package/dist/chart/client-BuB0wIgc.js +2757 -0
  23. package/dist/chart/sv-chart-element.d.ts +98 -0
  24. package/dist/chart/sv-chart-element.js +7282 -0
  25. package/dist/chart-DoqdUoGg.js +4398 -0
  26. package/dist/chart-export-pdf-BirUdchl.js +104 -0
  27. package/dist/chart-summary-BP9i-v8M.js +137 -0
  28. package/dist/chart-validate-CD6ptiwg.js +180 -0
  29. package/dist/{shadow/client-DjwUji8D.js → client-DEF0GRjE.js} +1 -1
  30. package/dist/{column-resize-DvCRUrN3.js → column-resize-DUPgynvc.js} +3 -3
  31. package/dist/date-format-DMTwV8NC.js +1128 -0
  32. package/dist/focus-trap-DvlOlOGM.js +65 -0
  33. package/dist/list-option-DrRyivWp.js +82 -0
  34. package/dist/react/chart.d.ts +99 -0
  35. package/dist/react/chart.js +49 -0
  36. package/dist/react/index.d.ts +28 -0
  37. package/dist/react/index.js +4 -1
  38. package/dist/{row-resize-D-8s3cqT.js → row-resize-Cf8qPLbi.js} +44 -36
  39. package/dist/shadow/GridMenus-B1mC1aPp.js +1077 -0
  40. package/dist/shadow/SvChartMenu-CBMKm7Xb.js +413 -0
  41. package/dist/shadow/SvDateRangeInput-BrYTQEMM.js +197 -0
  42. package/dist/shadow/SvDateTimePicker-CnLlqNDQ.js +766 -0
  43. package/dist/shadow/SvField-Bmzp3ObZ.js +147 -0
  44. package/dist/shadow/SvGridCellEditor-B005dmV1.js +560 -0
  45. package/dist/shadow/SvGridChart-4TcL9Rj2.js +3702 -0
  46. package/dist/shadow/SvGridChartBuilder-C4OL4XYx.js +1165 -0
  47. package/dist/shadow/SvGridChartPanel-CfHA8Ioq.js +1743 -0
  48. package/dist/shadow/SvGridChartView-Ci-9_EJ0.js +45 -0
  49. package/dist/shadow/SvGridDropdown-BlA6iw9m.js +257 -0
  50. package/dist/shadow/chart-DoqdUoGg.js +4398 -0
  51. package/dist/shadow/chart-export-pdf-BirUdchl.js +104 -0
  52. package/dist/shadow/chart-summary-BP9i-v8M.js +137 -0
  53. package/dist/shadow/chart-validate-CD6ptiwg.js +180 -0
  54. package/dist/{client-DjwUji8D.js → shadow/client-DEF0GRjE.js} +1 -1
  55. package/dist/shadow/{column-resize-DvCRUrN3.js → column-resize-DUPgynvc.js} +3 -3
  56. package/dist/shadow/date-format-DMTwV8NC.js +1128 -0
  57. package/dist/shadow/focus-trap-DvlOlOGM.js +65 -0
  58. package/dist/shadow/list-option-DrRyivWp.js +82 -0
  59. package/dist/shadow/{row-resize-D-8s3cqT.js → row-resize-Cf8qPLbi.js} +44 -36
  60. package/dist/shadow/sv-grid-shadow-element.d.ts +15 -0
  61. package/dist/shadow/sv-grid-shadow-element.js +4688 -3621
  62. package/dist/shadow/{svelte-virtualizer.svelte-DZ9UcyfT.js → svelte-virtualizer.svelte-CnGhFGDc.js} +37 -34
  63. package/dist/sv-grid-element.d.ts +15 -0
  64. package/dist/sv-grid-element.js +4646 -3609
  65. package/dist/{svelte-virtualizer.svelte-DZ9UcyfT.js → svelte-virtualizer.svelte-CnGhFGDc.js} +37 -34
  66. package/dist/vue/chart.d.ts +64 -0
  67. package/dist/vue/chart.js +41 -0
  68. package/dist/vue/index.d.ts +11 -2
  69. package/dist/vue/index.js +4 -1
  70. package/package.json +18 -5
  71. package/dist/GridMenus-YwTw9Upd.js +0 -1123
  72. package/dist/SvDateRangeInput-CrxeppBV.js +0 -196
  73. package/dist/SvDateTimePicker-xAO-Pb4S.js +0 -765
  74. package/dist/SvField-CE345DyF.js +0 -146
  75. package/dist/SvGridCellEditor-D7SyHtff.js +0 -550
  76. package/dist/SvGridChart-CMaVmlso.js +0 -1477
  77. package/dist/SvGridChartPanel-Pc_IW0eA.js +0 -833
  78. package/dist/SvGridChartView-DLhhzmFy.js +0 -52
  79. package/dist/SvGridDropdown-DUncHqM-.js +0 -256
  80. package/dist/chart-GRBAgN1M.js +0 -1658
  81. package/dist/date-format-D_oQ5Yw0.js +0 -1127
  82. package/dist/shadow/GridMenus-YwTw9Upd.js +0 -1123
  83. package/dist/shadow/SvDateRangeInput-CrxeppBV.js +0 -196
  84. package/dist/shadow/SvDateTimePicker-xAO-Pb4S.js +0 -765
  85. package/dist/shadow/SvField-CE345DyF.js +0 -146
  86. package/dist/shadow/SvGridCellEditor-D7SyHtff.js +0 -550
  87. package/dist/shadow/SvGridChart-CMaVmlso.js +0 -1477
  88. package/dist/shadow/SvGridChartPanel-Pc_IW0eA.js +0 -833
  89. package/dist/shadow/SvGridChartView-DLhhzmFy.js +0 -52
  90. package/dist/shadow/SvGridDropdown-DUncHqM-.js +0 -256
  91. package/dist/shadow/chart-GRBAgN1M.js +0 -1658
  92. package/dist/shadow/date-format-D_oQ5Yw0.js +0 -1127
@@ -0,0 +1,104 @@
1
+ import { i as e, r as t } from "./SvGridChart-4TcL9Rj2.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(e, n = {}) {
78
+ let r = e instanceof SVGSVGElement ? e : e.querySelector("svg.sv-grid-chart-svg") ?? e.querySelector("svg"), i = n.background ?? (r && getComputedStyle(r).getPropertyValue("--sg-bg").trim() || "#ffffff"), a = s(await o(await t(e, {
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(t, n = {}) {
90
+ let r = e(t, n), i = window.open("", "_blank", "width=900,height=700");
91
+ if (!i) return !1;
92
+ let a = (e) => e.replace(/[&<>]/g, (e) => ({
93
+ "&": "&amp;",
94
+ "<": "&lt;",
95
+ ">": "&gt;"
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 { A as e, j as t, k as n } from "./chart-DoqdUoGg.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 ?? ((e) => t(e, 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 t = d.flatMap((e) => e.points ?? []).filter((e) => r(e.x) && r(e.y));
71
+ if (!t.length) return "No data.";
72
+ let n = e(t.map((e) => e.x), t.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 `${t.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 t = d.filter((e) => e.values.some(r) || e.ohlc);
129
+ if (!t.length) return "No data.";
130
+ let i = t.slice(0, l), p = i.map((e) => s(e, u, a)), m = t.length > i.length ? ` And ${t.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,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 };
@@ -2957,4 +2957,4 @@ function ma(e, t, n, r, i, a) {
2957
2957
  }), a && (o = a(o)), e.element = o, o;
2958
2958
  }
2959
2959
  //#endregion
2960
- export { Nt as $, Er as A, En as B, ii as C, Kr as D, qr as E, gr as F, $t as G, Sn as H, hr as I, sn as J, an as K, mr as L, wr as M, Or as N, Rr as O, Tr as P, qt as Q, Q as R, pi as S, Jr as T, fn as U, kn as V, pn as W, F as X, Xt as Y, P as Z, Oi as _, ra as a, yi as b, ji as c, Bi as d, qe as et, Wi as f, ki as g, Vi as h, sa as i, g as it, Sr as j, Dr as k, Mi as l, Gi as m, ca as n, ze as nt, ta as o, Hi as p, on as q, aa as r, Re as rt, Zi as s, ma as t, Ke as tt, qi as u, Di as v, Qr as w, hi as x, Ti as y, sr as z };
2960
+ export { qt as $, Er as A, sr as B, ii as C, Kr as D, qr as E, gr as F, pn as G, kn as H, hr as I, on as J, $t as K, mr as L, wr as M, Or as N, Rr as O, Tr as P, P as Q, Q as R, pi as S, Jr as T, Sn as U, En as V, fn as W, Xt as X, sn as Y, F as Z, Oi as _, ra as a, g as at, yi as b, ji as c, Bi as d, Nt as et, Wi as f, ki as g, Vi as h, sa as i, Re as it, Sr as j, Dr as k, Mi as l, Gi as m, ca as n, Ke as nt, ta as o, Hi as p, an as q, aa as r, ze as rt, Zi as s, ma as t, qe as tt, qi as u, Di as v, Qr as w, hi as x, Ti as y, ir as z };
@@ -15,7 +15,7 @@ function t(t, n) {
15
15
  }
16
16
  function d(e) {
17
17
  if (i) {
18
- a !== null && (cancelAnimationFrame(a), a = null), o = Math.max(s(), i.startWidth + (e.clientX - i.startX)), l(), i.handle.classList.remove("is-resizing"), m(i.handle, i.columnId);
18
+ a !== null && (cancelAnimationFrame(a), a = null), o = Math.max(s(), i.startWidth + (e.clientX - i.startX)), l(), r.onResizeEnd?.(i.columnId, o, i.startWidth), i.handle.classList.remove("is-resizing"), m(i.handle, i.columnId);
19
19
  try {
20
20
  i.handle.releasePointerCapture(e.pointerId);
21
21
  } catch {}
@@ -51,8 +51,8 @@ function t(t, n) {
51
51
  let o = c(n);
52
52
  if (!o || r.canResize?.(o) === !1) return;
53
53
  t.preventDefault(), t.stopPropagation();
54
- let l = Math.max(s(), Math.round(r.getWidth(o) + a));
55
- r.onResize(o, l), m(n, o);
54
+ let l = r.getWidth(o), u = Math.max(s(), Math.round(l + a));
55
+ r.onResize(o, u), r.onResizeEnd?.(o, u, l), m(n, o);
56
56
  }
57
57
  function m(e, t) {
58
58
  let n = Math.round(r.getWidth(t));