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