@graphysdk/node-renderer 2.0.0-beta.1786440210947 → 2.0.0-beta.1787130761469
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 +30 -55
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +460 -415
- package/licenses/PolyForm-Free-Trial-1.0.0.md +93 -0
- package/licenses/PolyForm-NonCommercial-1.0.0.md +131 -0
- package/licenses/PolyForm-Small-Business-1.0.0.md +121 -0
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { existsSync as tt, readFileSync as ot } from "node:fs";
|
|
2
2
|
import { createRequire as Le } from "node:module";
|
|
3
|
-
import
|
|
3
|
+
import H from "node:path";
|
|
4
4
|
import { fileURLToPath as nt } from "node:url";
|
|
5
5
|
import { convertGraphConfig as rt } from "@graphysdk/viz-engine/graph-config";
|
|
6
6
|
import { curveCatmullRom as st, curveLinear as it, area as Re, line as we, arc as at } from "d3-shape";
|
|
7
|
-
import { createStyleResolver as
|
|
8
|
-
import { Buffer as
|
|
9
|
-
let
|
|
10
|
-
const
|
|
7
|
+
import { createStyleResolver as P, GROUP_VARIABLES as Be, getX as v, getY as B, getXMin as lt, getXMax as dt, getYMin as ct, getYMax as ft, getBarRectBounds as ut, buildColumnKey as ht, resolveBarBorderTreatment as ve, resolveBarCornerRadiiPx as $, getBoundingRect as gt, getRuleDashPattern as mt, getRuleLabelTextColor as pt, formatRuleValue as At, buildFontString as R, getAngleExtent as bt, getRadiusExtent as yt, buildSliceGroupKey as Tt, getUnionExtent as St, resolvePolarBarCornerRadiusUnit as Et, createCompiler as Lt, toFontSpec as J, isSafeUrl as Rt, extractPlainText as te, computePanelBorderPaths as wt, resolvePanelBorderStyle as Bt, resolveGridLineStyle as vt, getAestheticFromScaleAestheticKey as U, computeLineBoxHeight as _t, getDifferenceArrowDimensions as Ct, formatLegends as Nt, resolveAxisLabelStyle as fe, resolveTickLabelStyle as ue, resolveTickLineStyle as he, DATA_LABEL_ROLES as It, DATA_LABEL_POSITIONS as Pt, resolveDataLabelStyle as kt, LayoutCompiler as Dt } from "@graphysdk/viz-engine";
|
|
8
|
+
import { Buffer as Ot } from "node:buffer";
|
|
9
|
+
let G, x;
|
|
10
|
+
const Ft = () => G ? Promise.resolve(G) : (x ??= import("@napi-rs/canvas").then((e) => (G = e, e)).catch((e) => {
|
|
11
11
|
throw x = void 0, e;
|
|
12
|
-
}), x),
|
|
13
|
-
if (!
|
|
12
|
+
}), x), z = () => {
|
|
13
|
+
if (!G)
|
|
14
14
|
throw new Error("Canvas runtime is not loaded. Call loadCanvasRuntime() before rendering.");
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
let
|
|
18
|
-
const
|
|
19
|
-
const t =
|
|
20
|
-
oe.has(t) || (
|
|
21
|
-
},
|
|
22
|
-
{ file: "Inter-Regular.ttf", family:
|
|
23
|
-
{ file: "Inter-SemiBold.ttf", family:
|
|
24
|
-
],
|
|
25
|
-
{ file: "inter-latin-400-normal.woff", family:
|
|
26
|
-
{ file: "inter-latin-600-normal.woff", family:
|
|
27
|
-
],
|
|
15
|
+
return G;
|
|
16
|
+
}, E = "Inter", oe = /* @__PURE__ */ new Set();
|
|
17
|
+
let ge = !1, j = !1;
|
|
18
|
+
const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce = (e) => {
|
|
19
|
+
const t = _e(e);
|
|
20
|
+
oe.has(t) || (z().GlobalFonts.register(e.data, e.family), oe.add(t));
|
|
21
|
+
}, Ht = [
|
|
22
|
+
{ file: "Inter-Regular.ttf", family: E, weight: 400 },
|
|
23
|
+
{ file: "Inter-SemiBold.ttf", family: E, weight: 600 }
|
|
24
|
+
], Mt = [
|
|
25
|
+
{ file: "inter-latin-400-normal.woff", family: E, weight: 400 },
|
|
26
|
+
{ file: "inter-latin-600-normal.woff", family: E, weight: 600 }
|
|
27
|
+
], Gt = "@fontsource/inter", Ut = () => {
|
|
28
28
|
try {
|
|
29
|
-
const e = Le(import.meta.url), t =
|
|
30
|
-
return
|
|
29
|
+
const e = Le(import.meta.url), t = H.dirname(e.resolve("@graphysdk/node-renderer/package.json"));
|
|
30
|
+
return H.join(t, "assets");
|
|
31
31
|
} catch {
|
|
32
|
-
return
|
|
32
|
+
return H.resolve(H.dirname(nt(import.meta.url)), "../assets");
|
|
33
33
|
}
|
|
34
|
-
},
|
|
34
|
+
}, Ne = (e, t, o) => {
|
|
35
35
|
try {
|
|
36
|
-
return tt(e) ? (
|
|
36
|
+
return tt(e) ? (Ce({
|
|
37
37
|
family: t,
|
|
38
38
|
data: ot(e),
|
|
39
39
|
weight: o
|
|
@@ -41,20 +41,20 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
|
|
|
41
41
|
} catch {
|
|
42
42
|
return !1;
|
|
43
43
|
}
|
|
44
|
-
},
|
|
45
|
-
const e =
|
|
46
|
-
for (const { file: t, family: o, weight: n } of
|
|
47
|
-
|
|
48
|
-
},
|
|
44
|
+
}, Wt = () => {
|
|
45
|
+
const e = Ut();
|
|
46
|
+
for (const { file: t, family: o, weight: n } of Ht)
|
|
47
|
+
Ne(H.join(e, t), o, n) && (j = !0);
|
|
48
|
+
}, Vt = () => {
|
|
49
49
|
const e = Le(import.meta.url);
|
|
50
|
-
for (const { file: t, family: o, weight: n } of
|
|
51
|
-
if (!oe.has(
|
|
50
|
+
for (const { file: t, family: o, weight: n } of Mt)
|
|
51
|
+
if (!oe.has(_e({ family: o, data: Buffer.alloc(0), weight: n })))
|
|
52
52
|
try {
|
|
53
|
-
const s = e.resolve(`${
|
|
54
|
-
|
|
53
|
+
const s = e.resolve(`${Gt}/files/${t}`);
|
|
54
|
+
Ne(s, o, n) && (j = !0);
|
|
55
55
|
} catch {
|
|
56
56
|
}
|
|
57
|
-
},
|
|
57
|
+
}, Kt = () => (ge || (ge = !0, Wt(), Vt()), j), C = (e, t) => e.x + t * e.width, _ = (e, t) => e.y + (1 - t) * e.height, ne = (e) => e === "catmull-rom" ? st : it, Ie = (e) => {
|
|
58
58
|
switch (e) {
|
|
59
59
|
case "dashed":
|
|
60
60
|
return [8, 4];
|
|
@@ -63,160 +63,160 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
|
|
|
63
63
|
case "solid":
|
|
64
64
|
return [];
|
|
65
65
|
}
|
|
66
|
-
}, F = (e) => e,
|
|
66
|
+
}, F = (e) => e, zt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), Xt = (e, t, o) => {
|
|
67
67
|
const n = ne(t.interpolate), s = Re().curve(n), r = we().curve(n);
|
|
68
68
|
if (e.mainAxis === "y") {
|
|
69
|
-
const i = (
|
|
70
|
-
s.y(i).x0(
|
|
69
|
+
const i = (a) => _(o, B(a) ?? 0), l = (a) => C(o, lt(a) ?? 0), d = (a) => C(o, dt(a) ?? v(a) ?? 0);
|
|
70
|
+
s.y(i).x0(l).x1(d), r.y(i).x(d);
|
|
71
71
|
} else {
|
|
72
|
-
const i = (
|
|
73
|
-
s.x(i).y0(
|
|
72
|
+
const i = (a) => C(o, v(a) ?? 0), l = (a) => _(o, ct(a) ?? 0), d = (a) => _(o, ft(a) ?? B(a) ?? 0);
|
|
73
|
+
s.x(i).y0(l).y1(d), r.x(i).y(d);
|
|
74
74
|
}
|
|
75
75
|
if (t.missingValues === "gap") {
|
|
76
|
-
const i = (
|
|
76
|
+
const i = (l) => v(l) !== null && B(l) !== null;
|
|
77
77
|
s.defined(i), r.defined(i);
|
|
78
78
|
}
|
|
79
79
|
return { areaGenerator: s, lineGenerator: r };
|
|
80
|
-
},
|
|
80
|
+
}, Yt = F({
|
|
81
81
|
geom: "area",
|
|
82
82
|
coord: "cartesian",
|
|
83
83
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
84
|
-
const r =
|
|
85
|
-
t.data.groupBy(
|
|
86
|
-
const c =
|
|
87
|
-
if (!
|
|
88
|
-
const
|
|
89
|
-
e.save(), e.globalAlpha = h, e.fillStyle =
|
|
84
|
+
const r = P({ colorScheme: s }).geomReaders(t), { areaGenerator: i, lineGenerator: l } = Xt(o, t.params, n), d = e;
|
|
85
|
+
t.data.groupBy(Be.group).forEach((a) => {
|
|
86
|
+
const c = zt([...a], t.params.missingValues), u = c[0];
|
|
87
|
+
if (!u) return;
|
|
88
|
+
const f = r.get("color", u), h = r.get("alpha", u), g = r.get("strokeWidth", u), A = Ie(r.get("lineType", u));
|
|
89
|
+
e.save(), e.globalAlpha = h, e.fillStyle = f, e.beginPath(), i.context(d)(c), e.fill(), e.restore(), e.save(), e.globalAlpha = r.get("strokeAlpha", u), e.strokeStyle = f, e.lineWidth = g, e.setLineDash(A), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), l.context(d)(c), e.stroke(), e.restore();
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
}),
|
|
93
|
-
const i = Math.max(0, Math.min(r.rx ?? r.ry ?? 0, n / 2)),
|
|
94
|
-
e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.ellipse(t + n - i, o +
|
|
95
|
-
},
|
|
92
|
+
}), me = (e, t, o, n, s, r) => {
|
|
93
|
+
const i = Math.max(0, Math.min(r.rx ?? r.ry ?? 0, n / 2)), l = Math.max(0, Math.min(r.ry ?? r.rx ?? 0, s / 2)), d = Math.PI / 2;
|
|
94
|
+
e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.ellipse(t + n - i, o + l, i, l, 0, -d, 0), e.lineTo(t + n, o + s - l), e.ellipse(t + n - i, o + s - l, i, l, 0, 0, d), e.lineTo(t + i, o + s), e.ellipse(t + i, o + s - l, i, l, 0, d, Math.PI), e.lineTo(t, o + l), e.ellipse(t + i, o + l, i, l, 0, Math.PI, Math.PI * 1.5), e.closePath();
|
|
95
|
+
}, qt = F({
|
|
96
96
|
geom: "bar",
|
|
97
97
|
coord: "cartesian",
|
|
98
98
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
99
|
-
const { Path2D: r } =
|
|
100
|
-
for (const
|
|
101
|
-
const c = ut(
|
|
99
|
+
const { Path2D: r } = z(), i = P({ colorScheme: s }).geomReaders(t), l = o.mainAxis, d = /* @__PURE__ */ new Map();
|
|
100
|
+
for (const a of t.data) {
|
|
101
|
+
const c = ut(l, a);
|
|
102
102
|
if (!c) continue;
|
|
103
|
-
const
|
|
104
|
-
x:
|
|
105
|
-
y:
|
|
103
|
+
const u = C(n, c.x), f = n.y + c.y * n.height, h = {
|
|
104
|
+
x: u,
|
|
105
|
+
y: f,
|
|
106
106
|
width: c.width * n.width,
|
|
107
107
|
height: c.height * n.height,
|
|
108
|
-
fill: i.get("color",
|
|
109
|
-
opacity: i.get("alpha",
|
|
110
|
-
}, g = ht(
|
|
108
|
+
fill: i.get("color", a),
|
|
109
|
+
opacity: i.get("alpha", a)
|
|
110
|
+
}, g = ht(l, c), A = d.get(g);
|
|
111
111
|
A ? A.bars.push(h) : d.set(g, {
|
|
112
112
|
bars: [h],
|
|
113
113
|
style: {
|
|
114
|
-
borderColor: i.get("borderColor",
|
|
115
|
-
borderWidth: i.get("borderWidth",
|
|
116
|
-
borderRadius: i.get("borderRadius",
|
|
117
|
-
borderAlpha: i.get("alpha",
|
|
114
|
+
borderColor: i.get("borderColor", a),
|
|
115
|
+
borderWidth: i.get("borderWidth", a),
|
|
116
|
+
borderRadius: i.get("borderRadius", a),
|
|
117
|
+
borderAlpha: i.get("alpha", a)
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
for (const { bars:
|
|
122
|
-
const { borderColor:
|
|
123
|
-
if (!(
|
|
124
|
-
const [m] =
|
|
121
|
+
for (const { bars: a, style: c } of d.values()) {
|
|
122
|
+
const { borderColor: u, borderRadius: f, borderWidth: h, borderAlpha: g } = c, A = ve(h), p = f === "full" ? void 0 : $({ borderRadius: f, mainAxis: l });
|
|
123
|
+
if (!(a.length > 1)) {
|
|
124
|
+
const [m] = a;
|
|
125
125
|
if (!m) continue;
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const w = p ?? $({ borderRadius: f, mainAxis: l, bounds: { width: m.width, height: m.height } }), L = new r();
|
|
127
|
+
me(L, m.x, m.y, m.width, m.height, w), e.save(), e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fill(L), u !== void 0 && (e.clip(L), e.strokeStyle = u, e.lineWidth = A.outlineWidth, e.stroke(L)), e.restore();
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
for (const m of
|
|
133
|
-
e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fillRect(m.x, m.y, m.width, m.height),
|
|
134
|
-
|
|
130
|
+
const y = gt(a), S = p ?? $({ borderRadius: f, mainAxis: l, bounds: { width: y.width, height: y.height } }), T = new r();
|
|
131
|
+
me(T, y.x, y.y, y.width, y.height, S), e.save(), e.clip(T);
|
|
132
|
+
for (const m of a)
|
|
133
|
+
e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fillRect(m.x, m.y, m.width, m.height), u !== void 0 && (e.strokeStyle = u, e.lineWidth = A.separatorWidth, e.strokeRect(m.x, m.y, m.width, m.height));
|
|
134
|
+
u !== void 0 && (e.globalAlpha = g, e.strokeStyle = u, e.lineWidth = A.outlineWidth, e.stroke(T)), e.restore();
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
}),
|
|
137
|
+
}), pe = (e, t) => {
|
|
138
138
|
const o = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());
|
|
139
139
|
if (o?.[1] !== void 0) {
|
|
140
|
-
const s = o[1], r = s.length === 3 ? [...s].map((
|
|
141
|
-
return `rgba(${i}, ${
|
|
140
|
+
const s = o[1], r = s.length === 3 ? [...s].map((a) => a + a).join("") : s.slice(0, 6), i = Number.parseInt(r.slice(0, 2), 16), l = Number.parseInt(r.slice(2, 4), 16), d = Number.parseInt(r.slice(4, 6), 16);
|
|
141
|
+
return `rgba(${i}, ${l}, ${d}, ${t})`;
|
|
142
142
|
}
|
|
143
143
|
const n = /^rgba?\(([^)]+)\)$/i.exec(e.trim());
|
|
144
144
|
if (n?.[1] !== void 0) {
|
|
145
|
-
const s = n[1].split(",").map((d) => d.trim()), [r, i,
|
|
146
|
-
if (r !== void 0 && i !== void 0 &&
|
|
147
|
-
return `rgba(${r}, ${i}, ${
|
|
145
|
+
const s = n[1].split(",").map((d) => d.trim()), [r, i, l] = s;
|
|
146
|
+
if (r !== void 0 && i !== void 0 && l !== void 0)
|
|
147
|
+
return `rgba(${r}, ${i}, ${l}, ${t})`;
|
|
148
148
|
}
|
|
149
149
|
return t === 0 ? "rgba(0, 0, 0, 0)" : e;
|
|
150
|
-
},
|
|
151
|
-
const { seriesObservations: o, fillGenerator: n, panel: s, color: r, fillAlpha: i } = t,
|
|
152
|
-
if (
|
|
153
|
-
const d = e.createLinearGradient(0, Math.min(...
|
|
154
|
-
d.addColorStop(0, r), d.addColorStop(0.7,
|
|
155
|
-
},
|
|
150
|
+
}, jt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), Qt = (e, t) => {
|
|
151
|
+
const { seriesObservations: o, fillGenerator: n, panel: s, color: r, fillAlpha: i } = t, l = o.map((a) => B(a)).filter((a) => a !== null).map((a) => _(s, a));
|
|
152
|
+
if (l.length === 0) return;
|
|
153
|
+
const d = e.createLinearGradient(0, Math.min(...l), 0, s.y + s.height);
|
|
154
|
+
d.addColorStop(0, r), d.addColorStop(0.7, pe(r, 0)), d.addColorStop(1, pe(r, 0)), e.save(), e.globalAlpha = i, e.fillStyle = d, e.beginPath(), n.context(e)(o), e.fill(), e.restore();
|
|
155
|
+
}, Zt = F({
|
|
156
156
|
geom: "line",
|
|
157
157
|
coord: "cartesian",
|
|
158
158
|
draw: (e, { layer: t, panel: o, colorScheme: n }) => {
|
|
159
|
-
const s =
|
|
159
|
+
const s = P({ colorScheme: n }).geomReaders(t), r = we().x((l) => C(o, v(l) ?? 0)).y((l) => _(o, B(l) ?? 0)).curve(ne(t.params.interpolate)), i = Re().x((l) => C(o, v(l) ?? 0)).y0(o.y + o.height).y1((l) => _(o, B(l) ?? 0)).curve(ne(t.params.interpolate));
|
|
160
160
|
if (t.params.missingValues === "gap") {
|
|
161
|
-
const
|
|
162
|
-
r.defined(
|
|
161
|
+
const l = (d) => v(d) !== null && B(d) !== null;
|
|
162
|
+
r.defined(l), i.defined(l);
|
|
163
163
|
}
|
|
164
|
-
t.data.groupBy(
|
|
165
|
-
const d =
|
|
166
|
-
if (!
|
|
167
|
-
const c = s.get("strokeWidth",
|
|
168
|
-
h !== void 0 &&
|
|
164
|
+
t.data.groupBy(Be.group).forEach((l) => {
|
|
165
|
+
const d = jt([...l], t.params.missingValues), a = d[0];
|
|
166
|
+
if (!a) return;
|
|
167
|
+
const c = s.get("strokeWidth", a), u = Ie(s.get("lineType", a)), f = s.get("color", a), h = s.get("fillAlpha", a);
|
|
168
|
+
h !== void 0 && Qt(e, { seriesObservations: d, fillGenerator: i, panel: o, color: f, fillAlpha: h }), e.save(), e.globalAlpha = s.get("alpha", a), e.strokeStyle = f, e.lineWidth = c, e.setLineDash(u), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), r.context(e)(d), e.stroke(), e.restore();
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
}),
|
|
171
|
+
}), Jt = F({
|
|
172
172
|
geom: "point",
|
|
173
173
|
coord: "cartesian",
|
|
174
174
|
draw: (e, { layer: t, panel: o, colorScheme: n }) => {
|
|
175
|
-
const s =
|
|
175
|
+
const s = P({ colorScheme: n }).geomReaders(t);
|
|
176
176
|
for (const r of t.data) {
|
|
177
|
-
const i =
|
|
178
|
-
if (i === null ||
|
|
179
|
-
const d =
|
|
180
|
-
e.save(), e.globalAlpha = s.get("alpha", r), e.fillStyle = s.get("color", r), e.strokeStyle = s.get("borderColor", r), e.lineWidth =
|
|
177
|
+
const i = v(r), l = B(r);
|
|
178
|
+
if (i === null || l === null) continue;
|
|
179
|
+
const d = C(o, i), a = _(o, l), c = s.get("size", r) / 2, u = s.get("borderWidth", r);
|
|
180
|
+
e.save(), e.globalAlpha = s.get("alpha", r), e.fillStyle = s.get("color", r), e.strokeStyle = s.get("borderColor", r), e.lineWidth = u, e.beginPath(), e.arc(d, a, c, 0, Math.PI * 2), e.fill(), u > 0 && e.stroke(), e.restore();
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
}),
|
|
183
|
+
}), le = 11, $t = "sans-serif", xt = 500, D = 5, Pe = 5, re = 13, ke = 6, X = 12, Ae = 21.6, eo = (e, t) => {
|
|
184
184
|
const o = e.mapping.y !== void 0, n = t.mainAxis === "y";
|
|
185
185
|
return o !== n;
|
|
186
|
-
},
|
|
186
|
+
}, to = (e, t, o) => {
|
|
187
187
|
const n = mt(t, o);
|
|
188
188
|
e.setLineDash(n), n.length > 0 && (e.lineCap = "round");
|
|
189
|
-
},
|
|
189
|
+
}, oo = (e, t) => Y(e) && Y(t) ? `${e}: ${t}` : Y(e) ? e : Y(t) ? t : null, Y = (e) => e != null && e.trim() !== "", no = (e) => {
|
|
190
190
|
e.beginPath(), e.moveTo(2.48935, 16.9323), e.lineTo(9.07098, 9.82964), e.bezierCurveTo(9.51595, 9.34944, 9.51504, 8.60728, 9.0689, 8.12818), e.lineTo(2.48866, 1.06172), e.bezierCurveTo(1.85811, 0.384586, 0.974477, 0, 0.049217, 0), e.lineTo(0, 0), e.lineTo(0, 18), e.lineTo(0.0443689, 18), e.bezierCurveTo(0.972463, 18, 1.85854, 17.6131, 2.48935, 16.9323), e.closePath();
|
|
191
191
|
}, De = (e, t, o, n, s, r) => {
|
|
192
192
|
const i = Math.min(r, n / 2, s / 2);
|
|
193
193
|
e.beginPath(), e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.arcTo(t + n, o, t + n, o + i, i), e.lineTo(t + n, o + s - i), e.arcTo(t + n, o + s, t + n - i, o + s, i), e.lineTo(t + i, o + s), e.arcTo(t, o + s, t, o + s - i, i), e.lineTo(t, o + i), e.arcTo(t, o, t + i, o, i), e.closePath(), e.fill();
|
|
194
|
-
},
|
|
195
|
-
const d = o +
|
|
196
|
-
e.save(), e.translate(
|
|
197
|
-
},
|
|
198
|
-
const d = o +
|
|
199
|
-
e.save(), e.translate(
|
|
200
|
-
},
|
|
194
|
+
}, ro = (e, t, o, n, s, r, i, l) => {
|
|
195
|
+
const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = c ? r.x : r.x + r.width, f = _(r, s), h = c ? -re : -(d - re), g = c ? h + d - D : h + D - X;
|
|
196
|
+
e.save(), e.translate(u, f), e.translate(0, -a / 2), e.fillStyle = i, De(e, h, 0, d, a, ke), e.save(), c || (e.translate(g + X / 2, a / 2), e.rotate(Math.PI), e.translate(-(g + X / 2), -a / 2)), e.translate(g, (a - Ae) / 2), e.scale(X / 10, Ae / 18), e.fillStyle = i, no(e), e.fill(), e.restore(), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, h + D, a / 2), e.restore();
|
|
197
|
+
}, so = (e, t, o, n, s, r, i, l) => {
|
|
198
|
+
const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = C(r, s), f = c ? r.y + r.height : r.y, h = c ? -re : -8;
|
|
199
|
+
e.save(), e.translate(u, f), e.translate(-d / 2, 0), e.fillStyle = i, De(e, 0, h, d, a, ke), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, D, h + a / 2), e.restore();
|
|
200
|
+
}, io = F({
|
|
201
201
|
geom: "rule",
|
|
202
202
|
coord: "cartesian",
|
|
203
|
-
draw: (e, { layer: t, coordSystem: o, panel: n, compiled: s, textMeasurer: r, formattingLocale: i, colorScheme:
|
|
203
|
+
draw: (e, { layer: t, coordSystem: o, panel: n, compiled: s, textMeasurer: r, formattingLocale: i, colorScheme: l }) => {
|
|
204
204
|
const d = t.data.getFirst();
|
|
205
205
|
if (!d) return;
|
|
206
|
-
const
|
|
206
|
+
const a = eo(t, o), c = a ? B(d) : v(d);
|
|
207
207
|
if (c === null) return;
|
|
208
|
-
const
|
|
209
|
-
if (e.save(), e.strokeStyle =
|
|
210
|
-
const
|
|
211
|
-
e.moveTo(n.x,
|
|
208
|
+
const u = P({ colorScheme: l }).geomReaders(t), f = u.get("color", d), h = pt(f), g = u.get("strokeWidth", d);
|
|
209
|
+
if (e.save(), e.strokeStyle = f, e.lineWidth = g, to(e, u.get("lineType", d), g), e.beginPath(), a) {
|
|
210
|
+
const T = _(n, c);
|
|
211
|
+
e.moveTo(n.x, T), e.lineTo(n.x + n.width, T);
|
|
212
212
|
} else {
|
|
213
|
-
const
|
|
214
|
-
e.moveTo(
|
|
213
|
+
const T = C(n, c);
|
|
214
|
+
e.moveTo(T, n.y), e.lineTo(T, n.y + n.height);
|
|
215
215
|
}
|
|
216
216
|
e.stroke(), e.restore();
|
|
217
|
-
const A =
|
|
217
|
+
const A = oo(
|
|
218
218
|
t.params.label,
|
|
219
|
-
|
|
219
|
+
At({
|
|
220
220
|
guides: s.guides,
|
|
221
221
|
numberFormat: s.config.numberFormat,
|
|
222
222
|
layer: t,
|
|
@@ -224,71 +224,71 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
|
|
|
224
224
|
})
|
|
225
225
|
);
|
|
226
226
|
if (A === null) return;
|
|
227
|
-
const
|
|
228
|
-
family:
|
|
229
|
-
size:
|
|
230
|
-
weight:
|
|
227
|
+
const p = s.config.appearance.textScale, b = {
|
|
228
|
+
family: $t,
|
|
229
|
+
size: le * p,
|
|
230
|
+
weight: xt
|
|
231
231
|
};
|
|
232
|
-
e.font =
|
|
233
|
-
const
|
|
234
|
-
(
|
|
232
|
+
e.font = R(b);
|
|
233
|
+
const y = r.measureText(A, b).width;
|
|
234
|
+
(a ? ro : so)(e, A, y, t.params.labelPosition, c, n, f, h);
|
|
235
235
|
}
|
|
236
|
-
}),
|
|
237
|
-
|
|
238
|
-
const
|
|
236
|
+
}), M = at();
|
|
237
|
+
M.digits(8);
|
|
238
|
+
const ao = F({
|
|
239
239
|
geom: "bar",
|
|
240
240
|
coord: "polar",
|
|
241
241
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
242
|
-
const r = n.x + n.width / 2, i = n.y + n.height / 2,
|
|
243
|
-
e.save(), e.translate(r, i), e.scale(
|
|
244
|
-
const c = e,
|
|
245
|
-
for (const
|
|
246
|
-
const { startAngle: h, endAngle: g } =
|
|
247
|
-
if (h === null || g === null || A === null ||
|
|
248
|
-
const
|
|
242
|
+
const r = n.x + n.width / 2, i = n.y + n.height / 2, l = Math.min(n.width, n.height) / 2, { Path2D: d } = z(), a = P({ colorScheme: s }).geomReaders(t);
|
|
243
|
+
e.save(), e.translate(r, i), e.scale(l, l);
|
|
244
|
+
const c = e, u = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const f of t.data) {
|
|
246
|
+
const { startAngle: h, endAngle: g } = bt(f), { innerRadius: A, outerRadius: p } = yt(f);
|
|
247
|
+
if (h === null || g === null || A === null || p === null) continue;
|
|
248
|
+
const b = {
|
|
249
249
|
startAngle: h,
|
|
250
250
|
endAngle: g,
|
|
251
251
|
innerRadius: A,
|
|
252
|
-
outerRadius:
|
|
253
|
-
fill:
|
|
254
|
-
opacity:
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
items: [
|
|
252
|
+
outerRadius: p,
|
|
253
|
+
fill: a.get("color", f),
|
|
254
|
+
opacity: a.get("alpha", f)
|
|
255
|
+
}, y = Tt(o.bandAxis, b), S = u.get(y);
|
|
256
|
+
S ? S.items.push(b) : u.set(y, {
|
|
257
|
+
items: [b],
|
|
258
258
|
style: {
|
|
259
|
-
borderColor:
|
|
260
|
-
borderWidth:
|
|
261
|
-
borderRadius:
|
|
262
|
-
borderAlpha:
|
|
259
|
+
borderColor: a.get("borderColor", f),
|
|
260
|
+
borderWidth: a.get("borderWidth", f),
|
|
261
|
+
borderRadius: a.get("borderRadius", f),
|
|
262
|
+
borderAlpha: a.get("alpha", f)
|
|
263
263
|
}
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
-
for (const { items:
|
|
267
|
-
const { borderColor: g, borderRadius: A, borderWidth:
|
|
266
|
+
for (const { items: f, style: h } of u.values()) {
|
|
267
|
+
const { borderColor: g, borderRadius: A, borderWidth: p, borderAlpha: b } = h, y = ve(p), S = g !== void 0 && l > 0, T = St(f), m = Et(A, T.outerRadius - T.innerRadius), w = l > 0 && (S || m > 0);
|
|
268
268
|
e.save();
|
|
269
269
|
let L;
|
|
270
|
-
|
|
271
|
-
for (const
|
|
272
|
-
e.globalAlpha =
|
|
273
|
-
|
|
270
|
+
w && (L = new d(), M.cornerRadius(m), M.context(L)(T), e.clip(L)), M.cornerRadius(0);
|
|
271
|
+
for (const k of f)
|
|
272
|
+
e.globalAlpha = k.opacity, e.fillStyle = k.fill, e.beginPath(), M.context(c)(k), e.fill(), S && (e.strokeStyle = g, e.lineWidth = y.separatorWidth / l, e.stroke());
|
|
273
|
+
S && L && (e.globalAlpha = b, e.strokeStyle = g, e.lineWidth = y.outlineWidth / l, e.stroke(L)), e.restore();
|
|
274
274
|
}
|
|
275
275
|
e.restore();
|
|
276
276
|
}
|
|
277
|
-
}),
|
|
278
|
-
bar: { cartesian:
|
|
279
|
-
line: { cartesian:
|
|
280
|
-
area: { cartesian:
|
|
281
|
-
point: { cartesian:
|
|
282
|
-
rule: { cartesian:
|
|
283
|
-
},
|
|
277
|
+
}), lo = {
|
|
278
|
+
bar: { cartesian: qt, polar: ao },
|
|
279
|
+
line: { cartesian: Zt },
|
|
280
|
+
area: { cartesian: Yt },
|
|
281
|
+
point: { cartesian: Jt },
|
|
282
|
+
rule: { cartesian: io }
|
|
283
|
+
}, Oe = (e, t) => (
|
|
284
284
|
// `CompiledLayer.geom` is a plain string (a custom geom carries a name outside `GeomName`); the
|
|
285
285
|
// node renderer ships only built-ins, so an unregistered name simply resolves to `null`.
|
|
286
|
-
|
|
287
|
-
),
|
|
286
|
+
lo[e.geom]?.[t.type] ?? null
|
|
287
|
+
), co = (e, t, o) => {
|
|
288
288
|
e.draw(t, o);
|
|
289
289
|
};
|
|
290
|
-
let
|
|
291
|
-
const
|
|
290
|
+
let be;
|
|
291
|
+
const Fe = () => (be ??= Lt(), be), He = [
|
|
292
292
|
"line",
|
|
293
293
|
"areaStacked",
|
|
294
294
|
"bar",
|
|
@@ -302,139 +302,151 @@ const Oe = () => (Ae ??= Lt(), Ae), He = [
|
|
|
302
302
|
"donut",
|
|
303
303
|
"scatter",
|
|
304
304
|
"bubble"
|
|
305
|
-
],
|
|
305
|
+
], fo = [
|
|
306
306
|
"funnel",
|
|
307
307
|
"heatmap",
|
|
308
308
|
"waterfall",
|
|
309
309
|
"mekko",
|
|
310
310
|
"table"
|
|
311
|
-
],
|
|
311
|
+
], uo = new Set(He), Dn = {
|
|
312
312
|
supportedGraphTypes: [...He],
|
|
313
|
-
unsupportedGraphTypes: [...
|
|
313
|
+
unsupportedGraphTypes: [...fo],
|
|
314
314
|
supportedGeoms: {
|
|
315
315
|
cartesian: ["bar", "line", "area", "point", "rule"],
|
|
316
316
|
polar: ["bar"]
|
|
317
317
|
}
|
|
318
|
-
},
|
|
319
|
-
if (!
|
|
318
|
+
}, I = (e) => ({ ok: !1, reason: e }), Q = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ho = (e) => {
|
|
319
|
+
if (!Q(e)) return !1;
|
|
320
320
|
const { columns: t, rows: o } = e;
|
|
321
|
-
return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) =>
|
|
322
|
-
},
|
|
321
|
+
return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) => Q(n) && typeof n.key == "string");
|
|
322
|
+
}, go = (e) => {
|
|
323
323
|
if ("_unstable_mapping" in e && e._unstable_mapping !== void 0) return !0;
|
|
324
324
|
const t = e.referenceLines;
|
|
325
|
-
return
|
|
326
|
-
},
|
|
327
|
-
if (!
|
|
328
|
-
return
|
|
329
|
-
if (!
|
|
330
|
-
return
|
|
325
|
+
return Q(t) ? t.trendline !== void 0 || t.averageLine !== void 0 : !1;
|
|
326
|
+
}, mo = (e) => {
|
|
327
|
+
if (!Q(e))
|
|
328
|
+
return I("Chart config must be a plain object.");
|
|
329
|
+
if (!ho(e.data))
|
|
330
|
+
return I("Chart config is missing a valid `data` object (columns + rows).");
|
|
331
331
|
const { data: t, ...o } = e;
|
|
332
332
|
return { ok: !0, input: o, data: t };
|
|
333
|
-
},
|
|
334
|
-
const t =
|
|
333
|
+
}, po = (e) => {
|
|
334
|
+
const t = mo(e);
|
|
335
335
|
if (!t.ok) return t;
|
|
336
|
-
if (
|
|
337
|
-
return
|
|
336
|
+
if (go(e))
|
|
337
|
+
return I(
|
|
338
338
|
"Canvas renderer does not support `_unstable_mapping`, `referenceLines.trendline`, or `referenceLines.averageLine`."
|
|
339
339
|
);
|
|
340
340
|
const o = t.input.type ?? "column";
|
|
341
|
-
if (!
|
|
342
|
-
return
|
|
341
|
+
if (!uo.has(o))
|
|
342
|
+
return I(`Unsupported chart type for canvas rendering: ${o}.`);
|
|
343
343
|
try {
|
|
344
|
-
const n =
|
|
344
|
+
const n = Fe(), s = rt(t.input, t.data), r = n.compile({ input: s, data: t.data });
|
|
345
345
|
if (!r.ok)
|
|
346
|
-
return
|
|
346
|
+
return I(
|
|
347
347
|
`Chart config failed to compile: ${r.errors.map((i) => i.message).join("; ")}`
|
|
348
348
|
);
|
|
349
349
|
for (const i of r.compiled.layers)
|
|
350
|
-
if (
|
|
351
|
-
return
|
|
350
|
+
if (Oe(i, r.compiled.coordSystem) === null)
|
|
351
|
+
return I(`No canvas geom renderer for ${i.geom} (${r.compiled.coordSystem.type} coord).`);
|
|
352
352
|
return { ok: !0, compiled: r.compiled };
|
|
353
353
|
} catch (n) {
|
|
354
354
|
const s = n instanceof Error ? n.message : String(n);
|
|
355
|
-
return
|
|
355
|
+
return I(`Chart config failed to compile: ${s}`);
|
|
356
356
|
}
|
|
357
|
-
},
|
|
357
|
+
}, Me = E, W = 12, de = 1.3, V = 10, K = 12, O = 6, Ge = 16, Ao = 24, Ue = 6, We = 3, se = 4, bo = 8, yo = "#9ca3af", Ve = 16, To = 1.3, Ke = 13, So = 1.4, ze = 12, Eo = 1.4, Z = 8, ce = 12, Lo = 1.3, Ro = 200, wo = 120, Bo = 80, Xe = 22, vo = 9, _o = 11, Co = 10, q = 9, ye = 12, No = '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif', Io = 11.5, Po = 550, ko = { light: 0.55, mid: 0.75, dark: 0.08 }, Do = { light: 0.62, mid: 0.8, dark: 0.85 }, Oo = 0.22, Fo = 0.65, Ho = { family: Me, size: W }, Mo = [2, 3], Go = [1, 3], ie = (e) => {
|
|
358
|
+
switch (e) {
|
|
359
|
+
case "dashed":
|
|
360
|
+
return Mo;
|
|
361
|
+
case "dotted":
|
|
362
|
+
return Go;
|
|
363
|
+
case "solid":
|
|
364
|
+
return [];
|
|
365
|
+
}
|
|
366
|
+
}, Uo = (e, t, o, n, s, r) => {
|
|
358
367
|
if (!t.isVisible || t.ticks.length === 0) return;
|
|
359
|
-
const
|
|
360
|
-
e.save(), e.font =
|
|
361
|
-
for (const
|
|
362
|
-
const d =
|
|
363
|
-
t.ticksVisible &&
|
|
368
|
+
const i = t.position === "bottom" || t.position === "top";
|
|
369
|
+
e.save(), e.font = R(J(s, E)), e.fillStyle = s.textColor, e.strokeStyle = r.color, e.lineWidth = r.strokeWidth, e.setLineDash(ie(r.lineType));
|
|
370
|
+
for (const l of t.ticks) {
|
|
371
|
+
const d = i ? l.position : 1 - l.position;
|
|
372
|
+
t.ticksVisible && Vo(e, t.position, d, o, n, r.length), zo(
|
|
364
373
|
e,
|
|
365
374
|
t.position,
|
|
366
375
|
d,
|
|
367
376
|
o,
|
|
368
377
|
n,
|
|
369
|
-
|
|
378
|
+
l.formattedLabel,
|
|
370
379
|
t.labelRotation,
|
|
371
|
-
|
|
380
|
+
s.offset
|
|
372
381
|
);
|
|
373
382
|
}
|
|
374
383
|
e.restore();
|
|
375
|
-
},
|
|
384
|
+
}, Wo = (e, t, o, n, s) => {
|
|
376
385
|
if (e === "bottom" || e === "top") {
|
|
377
|
-
const
|
|
378
|
-
return { x1:
|
|
379
|
-
}
|
|
380
|
-
const
|
|
381
|
-
return { x1:
|
|
386
|
+
const d = n.x + t * n.width, a = e === "top" ? o.y + o.height : o.y, c = e === "top" ? -s : s;
|
|
387
|
+
return { x1: d, y1: a, x2: d, y2: a + c };
|
|
388
|
+
}
|
|
389
|
+
const r = n.y + t * n.height, i = e === "right" ? o.x : o.x + o.width, l = e === "right" ? s : -s;
|
|
390
|
+
return { x1: i, y1: r, x2: i + l, y2: r };
|
|
391
|
+
}, Vo = (e, t, o, n, s, r) => {
|
|
392
|
+
const { x1: i, y1: l, x2: d, y2: a } = Wo(t, o, n, s, r);
|
|
393
|
+
e.beginPath(), e.moveTo(i, l), e.lineTo(d, a), e.stroke();
|
|
382
394
|
}, Ko = (e, t, o, n, s) => {
|
|
383
|
-
const { x1: r, y1: i, x2: a, y2: d } = Vo(t, o, n, s);
|
|
384
|
-
e.beginPath(), e.moveTo(r, i), e.lineTo(a, d), e.stroke();
|
|
385
|
-
}, Xo = (e, t, o, n, s) => {
|
|
386
395
|
if (e === "bottom" || e === "top") {
|
|
387
396
|
const i = n.x + t * n.width;
|
|
388
397
|
return e === "bottom" ? { x: i, y: o.y + s, textAlign: "center", textBaseline: "top" } : { x: i, y: o.y + o.height - s, textAlign: "center", textBaseline: "alphabetic" };
|
|
389
398
|
}
|
|
390
399
|
const r = n.y + t * n.height;
|
|
391
400
|
return e === "left" ? { x: o.x + o.width - s, y: r, textAlign: "right", textBaseline: "middle" } : { x: o.x + s, y: r, textAlign: "left", textBaseline: "middle" };
|
|
392
|
-
}, zo = (e, t, o, n, s, r, i,
|
|
393
|
-
const d = q * a;
|
|
401
|
+
}, zo = (e, t, o, n, s, r, i, l) => {
|
|
394
402
|
if (i !== 0 && (t === "top" || t === "bottom")) {
|
|
395
|
-
const
|
|
396
|
-
e.save(), e.translate(
|
|
403
|
+
const a = s.x + o * s.width, c = t === "top";
|
|
404
|
+
e.save(), e.translate(a, c ? n.y + n.height - l : n.y + l), e.rotate(i * Math.PI / 180), e.textAlign = c ? "left" : "right", e.textBaseline = "middle", e.fillText(r, 0, 0), e.restore();
|
|
397
405
|
return;
|
|
398
406
|
}
|
|
399
|
-
const
|
|
400
|
-
e.textAlign =
|
|
401
|
-
},
|
|
407
|
+
const d = Ko(t, o, n, s, l);
|
|
408
|
+
e.textAlign = d.textAlign, e.textBaseline = d.textBaseline, e.fillText(r, d.x, d.y);
|
|
409
|
+
}, Xo = (e, t, o, n) => {
|
|
402
410
|
if (!t.isVisible || !t.label) return;
|
|
403
|
-
e.save(), e.font =
|
|
404
|
-
|
|
411
|
+
e.save(), e.font = R({
|
|
412
|
+
family: n.fontFamily ?? E,
|
|
413
|
+
size: n.fontSize,
|
|
414
|
+
weight: n.fontWeight
|
|
415
|
+
}), e.fillStyle = n.textColor, e.textBaseline = "middle";
|
|
416
|
+
const { x: s, y: r, alignment: i } = Yo(t.position, o);
|
|
405
417
|
e.textAlign = i, e.fillText(t.label, s, r), e.restore();
|
|
406
|
-
},
|
|
418
|
+
}, Yo = (e, t) => {
|
|
407
419
|
const o = t.y + t.height / 2;
|
|
408
420
|
return e === "left" ? { x: t.x, y: o, alignment: "start" } : e === "right" ? { x: t.x + t.width, y: o, alignment: "end" } : { x: t.x + t.width / 2, y: o, alignment: "center" };
|
|
409
|
-
},
|
|
421
|
+
}, qo = "data:image/png;base64,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", N = Xe;
|
|
410
422
|
let ee;
|
|
411
423
|
const jo = () => {
|
|
412
424
|
if (ee) return ee;
|
|
413
|
-
const { Image: e } =
|
|
414
|
-
return t.src =
|
|
415
|
-
}, Ye = (e, t, o = "full") => !e || t.width <
|
|
416
|
-
const t =
|
|
425
|
+
const { Image: e } = z(), t = new e(), o = qo.replace(/^data:image\/png;base64,/, "");
|
|
426
|
+
return t.src = Ot.from(o, "base64"), ee = t, t;
|
|
427
|
+
}, Ye = (e, t, o = "full") => !e || t.width < wo || t.height < Bo ? "hidden" : t.width < Ro || o === "mini" ? "mini" : "full", Qo = (e) => {
|
|
428
|
+
const t = Zo(e);
|
|
417
429
|
if (t === null) return "light";
|
|
418
|
-
const o =
|
|
419
|
-
return o <=
|
|
420
|
-
},
|
|
430
|
+
const o = Jo(t);
|
|
431
|
+
return o <= Oo ? "dark" : o <= Fo ? "mid" : "light";
|
|
432
|
+
}, ae = (e, t, o) => e.placement !== o || Ye(e.enabled, t, e.variant) === "hidden" ? 0 : Xe, qe = (e, t, o, n, s, r) => {
|
|
421
433
|
if (t.placement !== r) return;
|
|
422
434
|
const i = Ye(t.enabled, s, t.variant);
|
|
423
435
|
if (i === "hidden") return;
|
|
424
|
-
const
|
|
425
|
-
let
|
|
426
|
-
i === "full" && (e.font =
|
|
427
|
-
const
|
|
428
|
-
e.save(), e.globalAlpha =
|
|
429
|
-
const
|
|
430
|
-
if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(jo(),
|
|
431
|
-
const m =
|
|
432
|
-
e.fillStyle =
|
|
436
|
+
const l = Qo(n.background), d = l === "dark", a = { family: No, size: Io, weight: 400 }, c = { ...a, weight: Po };
|
|
437
|
+
let u = 0;
|
|
438
|
+
i === "full" && (e.font = R(a), u = e.measureText("Made with ").width, e.font = R(c), u += e.measureText("Graphy").width);
|
|
439
|
+
const f = i === "mini" ? 0 : vo, h = i === "mini" ? 0 : _o, g = i === "mini" ? 0 : Co, A = i === "mini" ? N : f + q + g + u + h, p = o.x + o.width - A, b = o.y + Math.max(0, (o.height || N) / 2 - N / 2);
|
|
440
|
+
e.save(), e.globalAlpha = Do[l], e.textBaseline = "middle", e.textAlign = "left", d || (e.shadowColor = "rgba(0, 0, 0, 0.09)", e.shadowBlur = 4, e.shadowOffsetY = 1), e.beginPath(), e.roundRect(p, b, A, N, N / 2), e.fillStyle = `rgba(255, 255, 255, ${ko[l]})`, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetY = 0;
|
|
441
|
+
const y = d ? "#FFFFFF" : "#2A2A28", S = i === "mini" ? p + (A - q) / 2 : p + f, T = b + (N - ye) / 2;
|
|
442
|
+
if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(jo(), S, T, q, ye), e.restore(), i === "full") {
|
|
443
|
+
const m = p + f + q + g, w = b + N / 2;
|
|
444
|
+
e.fillStyle = y, e.font = R(a), e.fillText("Made with ", m, w);
|
|
433
445
|
const L = e.measureText("Made with ").width;
|
|
434
|
-
e.font =
|
|
446
|
+
e.font = R(c), e.fillText("Graphy", m + L, w);
|
|
435
447
|
}
|
|
436
448
|
e.restore();
|
|
437
|
-
},
|
|
449
|
+
}, Zo = (e) => {
|
|
438
450
|
const t = e.trim();
|
|
439
451
|
if (!t.startsWith("#")) return null;
|
|
440
452
|
const o = t.slice(1);
|
|
@@ -451,13 +463,13 @@ const jo = () => {
|
|
|
451
463
|
green: Number.parseInt(o.slice(2, 4), 16),
|
|
452
464
|
blue: Number.parseInt(o.slice(4, 6), 16)
|
|
453
465
|
} : null;
|
|
454
|
-
},
|
|
466
|
+
}, Jo = ({ red: e, green: t, blue: o }) => {
|
|
455
467
|
const n = (s) => {
|
|
456
468
|
const r = s / 255;
|
|
457
469
|
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
458
470
|
};
|
|
459
471
|
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
460
|
-
},
|
|
472
|
+
}, $o = { family: E, size: Ve, weight: 600 }, xo = { family: E, size: Ke }, en = { family: E, size: ze }, tn = { family: E, size: ce, weight: 500 }, on = { family: E, size: ce }, je = Ve * To, nn = Ke * So, Qe = ze * Eo, Ze = ce * Lo, Je = (e) => {
|
|
461
473
|
if (e === null) return null;
|
|
462
474
|
if (e.label !== void 0 && e.label !== "") return e.label;
|
|
463
475
|
if (e.url !== void 0 && e.url !== "" && Rt(e.url))
|
|
@@ -467,70 +479,61 @@ const jo = () => {
|
|
|
467
479
|
return e.url;
|
|
468
480
|
}
|
|
469
481
|
return null;
|
|
470
|
-
},
|
|
482
|
+
}, rn = (e, t) => {
|
|
471
483
|
let o = 0;
|
|
472
484
|
const n = e.isTitleVisible && e.title !== null, s = e.isSubtitleVisible && e.subtitle !== null;
|
|
473
|
-
n && (o +=
|
|
474
|
-
const r =
|
|
485
|
+
n && (o += je), s && (o > 0 && (o += Z), o += nn);
|
|
486
|
+
const r = ae(e.brandMark, t, "header");
|
|
475
487
|
!n && !s && r > 0 && (o = r);
|
|
476
|
-
const i = e.isCaptionVisible && e.caption !== null,
|
|
477
|
-
let
|
|
478
|
-
return i && (
|
|
479
|
-
},
|
|
488
|
+
const i = e.isCaptionVisible && e.caption !== null, l = e.isSourceVisible && Je(e.source) !== null, d = ae(e.brandMark, t, "footer");
|
|
489
|
+
let a = 0;
|
|
490
|
+
return i && (a += Qe), (l || d > 0) && (a > 0 && (a += Z), a += Math.max(Ze, d)), { headerHeight: o, footerHeight: a };
|
|
491
|
+
}, sn = (e, t, o, n, s) => {
|
|
480
492
|
if (o.height === 0) return;
|
|
481
493
|
e.save(), e.textBaseline = "top", e.textAlign = "left";
|
|
482
494
|
let r = o.y;
|
|
483
|
-
t.isTitleVisible && t.title !== null && (e.font =
|
|
484
|
-
},
|
|
495
|
+
t.isTitleVisible && t.title !== null && (e.font = R($o), e.fillStyle = n.textPrimary, e.fillText(te(t.title), o.x, r), r += je + Z), t.isSubtitleVisible && t.subtitle !== null && (e.font = R(xo), e.fillStyle = n.textSecondary, e.fillText(te(t.subtitle), o.x, r)), e.restore(), qe(e, t.brandMark, o, n, s, "header");
|
|
496
|
+
}, an = (e, t, o, n, s) => {
|
|
485
497
|
if (o.height === 0) return;
|
|
486
|
-
const r = t.isCaptionVisible ? t.caption : null, i = t.isSourceVisible ? Je(t.source) : null,
|
|
487
|
-
if (r === null && i === null &&
|
|
498
|
+
const r = t.isCaptionVisible ? t.caption : null, i = t.isSourceVisible ? Je(t.source) : null, l = ae(t.brandMark, s, "footer");
|
|
499
|
+
if (r === null && i === null && l === 0) return;
|
|
488
500
|
e.save(), e.textBaseline = "top", e.textAlign = "left";
|
|
489
501
|
let d = o.y;
|
|
490
|
-
if (r !== null && (e.font =
|
|
491
|
-
let
|
|
492
|
-
|
|
502
|
+
if (r !== null && (e.font = R(en), e.fillStyle = n.textSecondary, e.fillText(te(r), o.x, d), d += Qe + Z), i !== null) {
|
|
503
|
+
let a = o.x;
|
|
504
|
+
a = Te(e, "Source: ", tn, n.textSecondary, a, d), Te(e, i, on, n.textSecondary, a, d);
|
|
493
505
|
}
|
|
494
506
|
e.restore(), qe(
|
|
495
507
|
e,
|
|
496
508
|
t.brandMark,
|
|
497
|
-
{ x: o.x, y: d, width: o.width, height: Math.max(
|
|
509
|
+
{ x: o.x, y: d, width: o.width, height: Math.max(Ze, l) },
|
|
498
510
|
n,
|
|
499
511
|
s,
|
|
500
512
|
"footer"
|
|
501
513
|
);
|
|
502
|
-
},
|
|
503
|
-
e.save(), e.lineCap = "round"
|
|
504
|
-
for (const
|
|
505
|
-
e.
|
|
506
|
-
for (const
|
|
507
|
-
if (!
|
|
508
|
-
const
|
|
509
|
-
e.
|
|
510
|
-
for (const
|
|
511
|
-
if (
|
|
512
|
-
const d =
|
|
513
|
-
if (e.beginPath(),
|
|
514
|
-
const
|
|
515
|
-
e.moveTo(
|
|
514
|
+
}, Te = (e, t, o, n, s, r) => (e.font = R(o), e.fillStyle = n, e.fillText(t, s, r), s + e.measureText(t).width), ln = (e, t, o, n) => {
|
|
515
|
+
e.save(), e.lineCap = "round";
|
|
516
|
+
for (const s of wt(Bt(o), n))
|
|
517
|
+
e.strokeStyle = s.color, e.lineWidth = s.strokeWidth, e.setLineDash(ie(s.lineType)), dn(e, s.segments), e.stroke();
|
|
518
|
+
for (const s of t) {
|
|
519
|
+
if (!s.gridVisible) continue;
|
|
520
|
+
const r = s.position === "top" || s.position === "bottom", i = vt(o, U(s.scaleAestheticKey));
|
|
521
|
+
e.strokeStyle = i.color, e.lineWidth = i.strokeWidth, e.setLineDash(ie(i.lineType));
|
|
522
|
+
for (const l of s.ticks) {
|
|
523
|
+
if (l.position <= 0 || l.position >= 1) continue;
|
|
524
|
+
const d = r ? l.position : 1 - l.position;
|
|
525
|
+
if (e.beginPath(), r) {
|
|
526
|
+
const a = n.x + d * n.width;
|
|
527
|
+
e.moveTo(a, n.y), e.lineTo(a, n.y + n.height);
|
|
516
528
|
} else {
|
|
517
|
-
const
|
|
518
|
-
e.moveTo(n.x,
|
|
529
|
+
const a = n.y + d * n.height;
|
|
530
|
+
e.moveTo(n.x, a), e.lineTo(n.x + n.width, a);
|
|
519
531
|
}
|
|
520
532
|
e.stroke();
|
|
521
533
|
}
|
|
522
534
|
}
|
|
523
535
|
e.restore();
|
|
524
|
-
},
|
|
525
|
-
switch (e) {
|
|
526
|
-
case "dashed":
|
|
527
|
-
return Go;
|
|
528
|
-
case "dotted":
|
|
529
|
-
return Uo;
|
|
530
|
-
case "solid":
|
|
531
|
-
return [];
|
|
532
|
-
}
|
|
533
|
-
}, cn = (e, t) => {
|
|
536
|
+
}, dn = (e, t) => {
|
|
534
537
|
e.beginPath();
|
|
535
538
|
for (const o of t)
|
|
536
539
|
switch (o.type) {
|
|
@@ -547,10 +550,10 @@ const jo = () => {
|
|
|
547
550
|
e.closePath();
|
|
548
551
|
break;
|
|
549
552
|
}
|
|
550
|
-
},
|
|
551
|
-
e.save(), e.font =
|
|
553
|
+
}, cn = (e, t, o, n) => {
|
|
554
|
+
e.save(), e.font = R(Ho), e.textBaseline = "middle";
|
|
552
555
|
for (const r of t)
|
|
553
|
-
r.display === "direct" &&
|
|
556
|
+
r.display === "direct" && fn(e, r, o, n);
|
|
554
557
|
const s = /* @__PURE__ */ new Map();
|
|
555
558
|
for (const r of t) {
|
|
556
559
|
if (r.display !== "pill" || r.items.length === 0) continue;
|
|
@@ -558,135 +561,136 @@ const jo = () => {
|
|
|
558
561
|
i ? i.push(r) : s.set(r.position, [r]);
|
|
559
562
|
}
|
|
560
563
|
for (const [r, i] of s) {
|
|
561
|
-
const
|
|
562
|
-
|
|
564
|
+
const l = o[r];
|
|
565
|
+
l && (r === "top" || r === "bottom" ? un(e, i, l, n) : hn(e, i, l, n));
|
|
563
566
|
}
|
|
564
567
|
e.restore();
|
|
565
|
-
},
|
|
568
|
+
}, fn = (e, t, o, n) => {
|
|
566
569
|
const s = o[t.position];
|
|
567
570
|
if (s) {
|
|
568
571
|
e.textAlign = "left";
|
|
569
572
|
for (const r of t.items)
|
|
570
|
-
r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x +
|
|
573
|
+
r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x + bo, _(s, r.normalizedY)));
|
|
571
574
|
}
|
|
572
|
-
},
|
|
575
|
+
}, un = (e, t, o, n) => {
|
|
573
576
|
const s = $e(t), r = s.reduce(
|
|
574
|
-
(
|
|
577
|
+
(a, c, u) => a + mn(c) + e.measureText(c.label).width + (u === 0 ? 0 : Se(c)),
|
|
575
578
|
0
|
|
576
|
-
), i =
|
|
577
|
-
let
|
|
578
|
-
const d = o.y + Ue + Math.max(i,
|
|
579
|
-
for (let
|
|
580
|
-
const c = s[
|
|
581
|
-
c && (
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
const s = $e(t), r = Math.max(
|
|
585
|
-
let d = o.y + Math.max(0, (o.height -
|
|
586
|
-
for (const
|
|
587
|
-
xe(e,
|
|
579
|
+
), i = W * de;
|
|
580
|
+
let l = o.x + Math.max(0, (o.width - r) / 2);
|
|
581
|
+
const d = o.y + Ue + Math.max(i, K) / 2;
|
|
582
|
+
for (let a = 0; a < s.length; a++) {
|
|
583
|
+
const c = s[a];
|
|
584
|
+
c && (a > 0 && (l += Se(c)), l = xe(e, c, l, d, n));
|
|
585
|
+
}
|
|
586
|
+
}, hn = (e, t, o, n) => {
|
|
587
|
+
const s = $e(t), r = Math.max(W * de, K), i = 4, l = s.length * r + Math.max(0, s.length - 1) * i;
|
|
588
|
+
let d = o.y + Math.max(0, (o.height - l) / 2) + r / 2;
|
|
589
|
+
for (const a of s)
|
|
590
|
+
xe(e, a, o.x, d, n), d += r + i;
|
|
588
591
|
}, $e = (e) => {
|
|
589
592
|
const t = [];
|
|
590
593
|
for (const o of e) {
|
|
591
594
|
const n = o.aesthetics.includes("size");
|
|
592
595
|
o.items.forEach((s, r) => {
|
|
593
|
-
const i = s.visual.size,
|
|
596
|
+
const i = s.visual.size, l = n && typeof i == "number" && Number.isFinite(i) && i > 0 ? i : void 0;
|
|
594
597
|
t.push({
|
|
595
598
|
label: s.formattedLabel,
|
|
596
|
-
colors:
|
|
597
|
-
bubbleSize:
|
|
599
|
+
colors: gn(s.visual.color),
|
|
600
|
+
bubbleSize: l,
|
|
598
601
|
isFirstInGroup: r === 0
|
|
599
602
|
});
|
|
600
603
|
});
|
|
601
604
|
}
|
|
602
605
|
return t;
|
|
603
|
-
},
|
|
604
|
-
if (e.bubbleSize !== void 0) return e.bubbleSize +
|
|
606
|
+
}, gn = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e.filter((t) => typeof t == "string") : [], Se = (e) => e.isFirstInGroup ? Ao : Ge, mn = (e) => {
|
|
607
|
+
if (e.bubbleSize !== void 0) return e.bubbleSize + O;
|
|
605
608
|
const t = e.colors.length;
|
|
606
609
|
if (t === 0) return 0;
|
|
607
|
-
if (t === 1) return
|
|
610
|
+
if (t === 1) return V + O;
|
|
608
611
|
const o = Math.min(t, We);
|
|
609
|
-
return
|
|
612
|
+
return V + (o - 1) * se + O;
|
|
610
613
|
}, xe = (e, t, o, n, s) => {
|
|
611
614
|
let r = o;
|
|
612
615
|
if (t.bubbleSize !== void 0) {
|
|
613
616
|
const i = t.bubbleSize / 2;
|
|
614
|
-
e.fillStyle = t.colors[0] ??
|
|
617
|
+
e.fillStyle = t.colors[0] ?? yo, e.beginPath(), e.arc(r + i, n, i, 0, Math.PI * 2), e.fill(), r += t.bubbleSize + O;
|
|
615
618
|
} else if (t.colors.length > 0) {
|
|
616
619
|
const i = t.colors.slice(0, We);
|
|
617
|
-
for (let
|
|
618
|
-
const d = i[
|
|
620
|
+
for (let l = 0; l < i.length; l++) {
|
|
621
|
+
const d = i[l];
|
|
619
622
|
d && (e.fillStyle = d, e.fillRect(
|
|
620
|
-
r +
|
|
621
|
-
n -
|
|
622
|
-
|
|
623
|
-
|
|
623
|
+
r + l * se,
|
|
624
|
+
n - K / 2,
|
|
625
|
+
V,
|
|
626
|
+
K
|
|
624
627
|
));
|
|
625
628
|
}
|
|
626
|
-
r +=
|
|
629
|
+
r += V + (i.length - 1) * se + O;
|
|
627
630
|
}
|
|
628
631
|
return e.fillStyle = s.textPrimary, e.textAlign = "left", e.fillText(t.label, r, n), r + e.measureText(t.label).width;
|
|
629
|
-
},
|
|
630
|
-
if (!
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
), s = t.labelMaxWidthPx ?? Number.POSITIVE_INFINITY;
|
|
637
|
-
if (o) {
|
|
638
|
-
if (t.labelRotation !== 0) {
|
|
639
|
-
const i = n.map((a) => a.width);
|
|
640
|
-
return Se(i, s) + 2 * q;
|
|
632
|
+
}, Ee = (e, t) => Math.min(Math.max(...e), t), pn = (e, t, o) => (n) => {
|
|
633
|
+
if (!n.isVisible || n.ticks.length === 0) return 0;
|
|
634
|
+
const s = n.position === "top" || n.position === "bottom", r = U(n.scaleAestheticKey), { offset: i, ...l } = t[r], d = n.ticksVisible ? Math.max(i, o[r].length) : i, a = J(l, E), c = n.ticks.map((h) => e.measureText(h.formattedLabel, a)), u = n.labelMaxWidthPx ?? Number.POSITIVE_INFINITY;
|
|
635
|
+
if (s) {
|
|
636
|
+
if (n.labelRotation !== 0) {
|
|
637
|
+
const h = c.map((g) => g.width);
|
|
638
|
+
return Ee(h, u) + 2 * d;
|
|
641
639
|
}
|
|
642
|
-
return Math.max(...
|
|
640
|
+
return Math.max(...c.map((h) => h.height)) + d;
|
|
643
641
|
}
|
|
644
|
-
const
|
|
645
|
-
return
|
|
646
|
-
},
|
|
642
|
+
const f = c.map((h) => h.width);
|
|
643
|
+
return Ee(f, u) + d;
|
|
644
|
+
}, An = (e) => (t) => {
|
|
647
645
|
if (t.items.length === 0) return 0;
|
|
648
|
-
const o = { family: Me, size:
|
|
646
|
+
const o = { family: Me, size: W };
|
|
649
647
|
if (t.position === "top" || t.position === "bottom") {
|
|
650
|
-
const r =
|
|
651
|
-
return Math.max(r,
|
|
648
|
+
const r = W * de;
|
|
649
|
+
return Math.max(r, K) + Ue * 2;
|
|
652
650
|
}
|
|
653
651
|
const s = t.items.map((r) => {
|
|
654
652
|
const i = e.measureText(r.formattedLabel, o).width;
|
|
655
|
-
return
|
|
653
|
+
return V + O + i;
|
|
656
654
|
});
|
|
657
655
|
return Math.max(...s) + Ge;
|
|
658
|
-
},
|
|
659
|
-
const { labelLineHeight: n, labelFontWeight: s } =
|
|
656
|
+
}, bn = (e) => (t, o) => {
|
|
657
|
+
const { labelLineHeight: n, labelFontWeight: s } = Ct(o, 1);
|
|
660
658
|
return e.measureText(t, {
|
|
661
|
-
family:
|
|
659
|
+
family: E,
|
|
662
660
|
size: n,
|
|
663
661
|
weight: s
|
|
664
662
|
});
|
|
665
|
-
},
|
|
666
|
-
const
|
|
667
|
-
return
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
},
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
663
|
+
}, yn = (e, t) => (o, n, s) => {
|
|
664
|
+
const r = t[o][n], i = e.measureText(s, J(r, E));
|
|
665
|
+
return {
|
|
666
|
+
...i,
|
|
667
|
+
width: i.width + r.paddingInline * 2,
|
|
668
|
+
height: i.height + r.paddingBlock * 2
|
|
669
|
+
};
|
|
670
|
+
}, Tn = ({
|
|
671
|
+
textMeasurer: e,
|
|
672
|
+
axisLabelStyles: t,
|
|
673
|
+
dataLabelStyles: o,
|
|
674
|
+
tickLabelStyles: n,
|
|
675
|
+
tickLineStyles: s
|
|
676
|
+
}) => ({
|
|
677
|
+
measureAxis: pn(e, n, s),
|
|
678
|
+
measureAxisLabel: (r) => _t(t[U(r.scaleAestheticKey)]),
|
|
679
|
+
measureLegend: An(e),
|
|
680
|
+
measureTickLabel: (r, i) => e.measureText(r, J(n[i], E)),
|
|
681
|
+
measureDifferenceArrowLabel: bn(e),
|
|
682
|
+
measureDataLabel: yn(e, o),
|
|
679
683
|
measureHeadline: () => ({ width: 0, height: 0 }),
|
|
680
684
|
measureHeadlineItemWidths: () => []
|
|
681
685
|
});
|
|
682
686
|
class Sn {
|
|
683
687
|
constructor() {
|
|
684
688
|
this.currentFont = "";
|
|
685
|
-
const t =
|
|
689
|
+
const t = z().createCanvas(1, 1);
|
|
686
690
|
this.ctx = t.getContext("2d");
|
|
687
691
|
}
|
|
688
692
|
measureText(t, o) {
|
|
689
|
-
const n =
|
|
693
|
+
const n = R(o);
|
|
690
694
|
this.currentFont !== n && (this.ctx.font = n, this.currentFont = n);
|
|
691
695
|
const s = this.ctx.measureText(t);
|
|
692
696
|
return {
|
|
@@ -697,116 +701,157 @@ class Sn {
|
|
|
697
701
|
};
|
|
698
702
|
}
|
|
699
703
|
}
|
|
700
|
-
const
|
|
704
|
+
const En = {
|
|
701
705
|
background: "#ffffff",
|
|
702
706
|
textPrimary: "#111827",
|
|
703
707
|
textSecondary: "#6b7280",
|
|
704
708
|
gridLine: "#e5e7eb",
|
|
705
|
-
panelBorder: "#d1d5db",
|
|
706
709
|
legendPillBackground: "rgba(0, 0, 0, 0.04)",
|
|
707
710
|
legendPillBorder: "rgba(0, 0, 0, 0.08)"
|
|
708
|
-
},
|
|
711
|
+
}, Ln = {
|
|
709
712
|
background: "#0b0f17",
|
|
710
713
|
textPrimary: "#e5e7eb",
|
|
711
714
|
textSecondary: "#9ca3af",
|
|
712
715
|
gridLine: "#1f2937",
|
|
713
|
-
panelBorder: "#374151",
|
|
714
716
|
legendPillBackground: "rgba(255, 255, 255, 0.06)",
|
|
715
717
|
legendPillBorder: "rgba(255, 255, 255, 0.12)"
|
|
716
718
|
}, On = async ({ input: e, data: t }, o) => {
|
|
717
|
-
const s =
|
|
719
|
+
const s = Fe().compile({ input: e, data: t });
|
|
718
720
|
if (!s.ok)
|
|
719
721
|
throw new Error(
|
|
720
722
|
`Failed to compile graph spec: ${s.errors.map((r) => r.message).join("; ")}`
|
|
721
723
|
);
|
|
722
724
|
return et(s.compiled, o);
|
|
723
725
|
}, et = async (e, t) => {
|
|
724
|
-
const { Canvas: o } = await
|
|
725
|
-
if (
|
|
726
|
-
for (const
|
|
727
|
-
const n =
|
|
726
|
+
const { Canvas: o } = await Ft();
|
|
727
|
+
if (Kt(), t.fonts)
|
|
728
|
+
for (const w of t.fonts) Ce(w);
|
|
729
|
+
const n = Nt({
|
|
728
730
|
legends: e.guides.legends.drawn,
|
|
729
731
|
numberFormat: e.config.numberFormat,
|
|
730
732
|
parsingLocale: e.config.parsingLocale,
|
|
731
733
|
formattingLocale: t.formattingLocale
|
|
732
|
-
}), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } =
|
|
734
|
+
}), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } = rn(e.config.content, s), l = {
|
|
733
735
|
headerSize: { width: t.width, height: r },
|
|
734
736
|
footerSize: { width: t.width, height: i }
|
|
735
|
-
}, d =
|
|
737
|
+
}, d = t.colorScheme ?? "light", a = P({ colorScheme: d }).chromeReaders(e.chrome), c = e.config.appearance.textScale, u = {
|
|
738
|
+
x: fe(a, "x", c),
|
|
739
|
+
y: fe(a, "y", c)
|
|
740
|
+
}, f = {
|
|
741
|
+
x: ue(a, "x", c),
|
|
742
|
+
y: ue(a, "y", c)
|
|
743
|
+
}, h = {
|
|
744
|
+
x: he(a, "x"),
|
|
745
|
+
y: he(a, "y")
|
|
746
|
+
}, g = {};
|
|
747
|
+
for (const w of It) {
|
|
748
|
+
const L = {};
|
|
749
|
+
for (const k of Pt)
|
|
750
|
+
L[k] = kt(a, w, k, c);
|
|
751
|
+
g[w] = L;
|
|
752
|
+
}
|
|
753
|
+
const A = new Sn(), p = Tn({
|
|
754
|
+
textMeasurer: A,
|
|
755
|
+
axisLabelStyles: u,
|
|
756
|
+
dataLabelStyles: g,
|
|
757
|
+
tickLabelStyles: f,
|
|
758
|
+
tickLineStyles: h
|
|
759
|
+
}), { layout: b, formattedAxes: y } = new Dt(p).compile({
|
|
736
760
|
axes: e.guides.axes,
|
|
737
761
|
numberFormat: e.config.numberFormat,
|
|
738
762
|
parsingLocale: e.config.parsingLocale,
|
|
739
763
|
formattedLegends: n,
|
|
740
764
|
containerSize: { width: t.width, height: t.height },
|
|
741
|
-
externalMeasurements:
|
|
765
|
+
externalMeasurements: l,
|
|
742
766
|
formattingLocale: t.formattingLocale,
|
|
743
767
|
layout: e.config.layout
|
|
744
|
-
}),
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
768
|
+
}), S = t.pixelRatio ?? 2, T = new o(t.width * S, t.height * S), m = T.getContext("2d");
|
|
769
|
+
return m.scale(S, S), Rn({
|
|
770
|
+
ctx: m,
|
|
771
|
+
theme: d === "dark" ? Ln : En,
|
|
772
|
+
colorScheme: d,
|
|
773
|
+
chromeReaders: a,
|
|
774
|
+
axisLabelStyles: u,
|
|
775
|
+
tickLabelStyles: f,
|
|
776
|
+
tickLineStyles: h,
|
|
777
|
+
width: t.width,
|
|
778
|
+
height: t.height,
|
|
779
|
+
compiled: e,
|
|
780
|
+
formattedAxes: y,
|
|
781
|
+
formattedLegends: n,
|
|
782
|
+
layout: b,
|
|
783
|
+
textMeasurer: A,
|
|
784
|
+
...t.formattingLocale === void 0 ? {} : { formattingLocale: t.formattingLocale }
|
|
785
|
+
}), T.encode("png");
|
|
786
|
+
}, Rn = ({
|
|
787
|
+
ctx: e,
|
|
788
|
+
theme: t,
|
|
789
|
+
colorScheme: o,
|
|
790
|
+
chromeReaders: n,
|
|
791
|
+
axisLabelStyles: s,
|
|
792
|
+
tickLabelStyles: r,
|
|
793
|
+
tickLineStyles: i,
|
|
794
|
+
width: l,
|
|
795
|
+
height: d,
|
|
796
|
+
compiled: a,
|
|
797
|
+
formattedAxes: c,
|
|
798
|
+
formattedLegends: u,
|
|
799
|
+
layout: f,
|
|
800
|
+
textMeasurer: h,
|
|
801
|
+
formattingLocale: g
|
|
802
|
+
}) => {
|
|
803
|
+
e.fillStyle = t.background, e.fillRect(0, 0, l, d), ln(e, c, n, f.panel), e.save(), e.beginPath(), e.rect(f.panel.x, f.panel.y, f.panel.width, f.panel.height), e.clip();
|
|
804
|
+
const A = {
|
|
805
|
+
coordSystem: a.coordSystem,
|
|
806
|
+
panel: f.panel,
|
|
807
|
+
compiled: a,
|
|
766
808
|
theme: t,
|
|
767
809
|
colorScheme: o,
|
|
768
|
-
textMeasurer:
|
|
769
|
-
formattingLocale:
|
|
810
|
+
textMeasurer: h,
|
|
811
|
+
formattingLocale: g
|
|
770
812
|
};
|
|
771
|
-
for (const
|
|
772
|
-
const
|
|
773
|
-
|
|
813
|
+
for (const p of a.layers) {
|
|
814
|
+
const b = Oe(p, a.coordSystem);
|
|
815
|
+
b && co(b, e, { ...A, layer: p });
|
|
774
816
|
}
|
|
775
817
|
e.restore();
|
|
776
|
-
for (const
|
|
777
|
-
const
|
|
778
|
-
|
|
818
|
+
for (const p of c) {
|
|
819
|
+
const b = f.axes[p.position];
|
|
820
|
+
if (b) {
|
|
821
|
+
const y = U(p.scaleAestheticKey);
|
|
822
|
+
Uo(e, p, b, f.panel, r[y], i[y]);
|
|
823
|
+
}
|
|
779
824
|
}
|
|
780
|
-
for (const
|
|
781
|
-
const
|
|
782
|
-
|
|
825
|
+
for (const p of a.guides.axes) {
|
|
826
|
+
const b = f.axisLabels[p.position];
|
|
827
|
+
b && Xo(e, p, b, s[U(p.scaleAestheticKey)]);
|
|
783
828
|
}
|
|
784
|
-
|
|
829
|
+
cn(e, u, f.legends, t), sn(e, a.config.content, f.header, t, { width: l, height: d }), an(e, a.config.content, f.footer, t, { width: l, height: d });
|
|
785
830
|
};
|
|
786
|
-
class
|
|
831
|
+
class wn extends Error {
|
|
787
832
|
constructor(t) {
|
|
788
833
|
super(t), this.name = "ChartConfigRenderError";
|
|
789
834
|
}
|
|
790
835
|
}
|
|
791
|
-
const
|
|
792
|
-
const o =
|
|
836
|
+
const Fn = async (e, t) => {
|
|
837
|
+
const o = po(e);
|
|
793
838
|
if (!o.ok)
|
|
794
|
-
throw new
|
|
839
|
+
throw new wn(o.reason);
|
|
795
840
|
return et(o.compiled, t);
|
|
796
841
|
};
|
|
797
842
|
export {
|
|
798
|
-
|
|
843
|
+
Dn as CANVAS_CAPABILITY_MATRIX,
|
|
799
844
|
He as CANVAS_SUPPORTED_GRAPH_TYPES,
|
|
800
|
-
|
|
801
|
-
|
|
845
|
+
fo as CANVAS_UNSUPPORTED_GRAPH_TYPES,
|
|
846
|
+
wn as ChartConfigRenderError,
|
|
802
847
|
Sn as NodeCanvasTextMeasurer,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
848
|
+
po as canRenderConfigWithCanvas,
|
|
849
|
+
Ln as darkTheme,
|
|
850
|
+
Kt as ensureDefaultFonts,
|
|
851
|
+
En as lightTheme,
|
|
852
|
+
Ft as loadCanvasRuntime,
|
|
853
|
+
mo as parseChartConfig,
|
|
854
|
+
Ce as registerFont,
|
|
855
|
+
Fn as renderChartConfigToPng,
|
|
811
856
|
On as renderGraphToPng
|
|
812
857
|
};
|