minerva-design 1.17.0 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/charts/engine/backing-store.cjs +2 -0
- package/dist/charts/engine/backing-store.cjs.map +1 -0
- package/dist/charts/engine/backing-store.d.cts +11 -0
- package/dist/charts/engine/backing-store.d.ts +11 -0
- package/dist/charts/engine/backing-store.js +27 -0
- package/dist/charts/engine/backing-store.js.map +1 -0
- package/dist/charts/engine/canvas.cjs +1 -1
- package/dist/charts/engine/canvas.cjs.map +1 -1
- package/dist/charts/engine/canvas.js +89 -86
- package/dist/charts/engine/canvas.js.map +1 -1
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +5 -0
- package/dist/charts/engine/model.d.ts +5 -0
- package/dist/charts/engine/model.js +1 -0
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +6 -0
- package/dist/charts/engine/overlay.d.ts +6 -0
- package/dist/charts/engine/overlay.js +68 -6
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +1 -1
- package/dist/charts/engine/presets.cjs.map +1 -1
- package/dist/charts/engine/presets.js +4 -0
- package/dist/charts/engine/presets.js.map +1 -1
- package/dist/charts/engine/scene.cjs +1 -1
- package/dist/charts/engine/scene.cjs.map +1 -1
- package/dist/charts/engine/scene.d.cts +11 -0
- package/dist/charts/engine/scene.d.ts +11 -0
- package/dist/charts/engine/scene.js +107 -90
- package/dist/charts/engine/scene.js.map +1 -1
- package/dist/charts/engine/shapes/canvas.cjs +1 -1
- package/dist/charts/engine/shapes/canvas.cjs.map +1 -1
- package/dist/charts/engine/shapes/canvas.js +97 -94
- package/dist/charts/engine/shapes/canvas.js.map +1 -1
- package/dist/charts/engine/types.d.cts +10 -0
- package/dist/charts/engine/types.d.ts +10 -0
- package/dist/native/charts/src/engine/backing-store.cjs +2 -0
- package/dist/native/charts/src/engine/backing-store.cjs.map +1 -0
- package/dist/native/charts/src/engine/backing-store.js +27 -0
- package/dist/native/charts/src/engine/backing-store.js.map +1 -0
- package/dist/native/charts/src/engine/model.cjs +1 -1
- package/dist/native/charts/src/engine/model.cjs.map +1 -1
- package/dist/native/charts/src/engine/model.js +1 -0
- package/dist/native/charts/src/engine/model.js.map +1 -1
- package/dist/native/charts/src/engine/overlay.cjs +1 -1
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
- package/dist/native/charts/src/engine/overlay.js +64 -2
- package/dist/native/charts/src/engine/overlay.js.map +1 -1
- package/dist/native/charts/src/engine/presets.cjs +1 -1
- package/dist/native/charts/src/engine/presets.cjs.map +1 -1
- package/dist/native/charts/src/engine/presets.js +4 -0
- package/dist/native/charts/src/engine/presets.js.map +1 -1
- package/dist/native/charts/src/engine/scene.cjs +1 -1
- package/dist/native/charts/src/engine/scene.cjs.map +1 -1
- package/dist/native/charts/src/engine/scene.js +107 -90
- package/dist/native/charts/src/engine/scene.js.map +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.cjs +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.cjs.map +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.js +107 -104
- package/dist/native/charts/src/engine/shapes/canvas.js.map +1 -1
- package/dist/taro/chart-pixel-ratio.d.ts +10 -0
- package/dist/taro/{components-DoBebZ28.js → components-R1m1BIE0.js} +1 -1
- package/dist/taro/icons.js +1 -1
- package/dist/taro/index.js +1757 -1663
- package/dist/taro/monaco.js +1 -1
- package/dist/taro/style.css +102 -2
- package/dist/uni/QuadrantTaskBoard.vue +4 -14
- package/dist/uni/style.css +90 -0
- package/dist/weapp/charts/canvas.js +201 -18
- package/dist/weapp/controls.js +1 -1
- package/dist/weapp/controls.wxss +90 -0
- package/dist/weapp/quadrant-task-board/index.wxml +1 -1
- package/package.json +1 -1
|
@@ -5,11 +5,12 @@ import { liftedBarRect as s } from "./scene.js";
|
|
|
5
5
|
import { buildItems as c, cellStyleKey as l } from "./items.js";
|
|
6
6
|
import { createCanvas2dPainter as u } from "./renderers/canvas2d.js";
|
|
7
7
|
import { itemsSignature as d } from "./signature.js";
|
|
8
|
-
import {
|
|
8
|
+
import { watchBackingStore as f } from "./backing-store.js";
|
|
9
|
+
import { createChartController as p, scenePrimitives as m } from "./controller.js";
|
|
9
10
|
//#region src/engine/canvas.ts
|
|
10
|
-
var
|
|
11
|
+
var h = (e) => (e[0] + e[1]) / 2, g = (e, t, n, r, i, a) => {
|
|
11
12
|
e.beginPath(), e.moveTo(t + a, n), e.lineTo(t + r - a, n), e.arcTo(t + r, n, t + r, n + a, a), e.lineTo(t + r, n + i - a), e.arcTo(t + r, n + i, t + r - a, n + i, a), e.lineTo(t + a, n + i), e.arcTo(t, n + i, t, n + i - a, a), e.lineTo(t, n + a), e.arcTo(t, n, t + a, n, a), e.closePath();
|
|
12
|
-
},
|
|
13
|
+
}, _ = (e, t, n) => {
|
|
13
14
|
e.save(), e.beginPath(), e.rect(n.x, n.y, n.width, n.height), e.clip(), e.lineJoin = "round", e.lineCap = "round";
|
|
14
15
|
for (let n of t) if (n.kind === "area") e.globalAlpha = n.opacity, e.fillStyle = n.color, n.segments.forEach((t, r) => {
|
|
15
16
|
let i = n.bottoms?.[r], a = t.length / 2;
|
|
@@ -39,7 +40,7 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
39
40
|
];
|
|
40
41
|
e.fillStyle = n.colors?.[r / 4] ?? n.color;
|
|
41
42
|
let c = Math.min(t, o / 2, s / 2);
|
|
42
|
-
c > .5 ? (
|
|
43
|
+
c > .5 ? (g(e, i, a, o, s, c), e.fill()) : e.fillRect(i, a, o, s);
|
|
43
44
|
}
|
|
44
45
|
e.globalAlpha = 1;
|
|
45
46
|
} else {
|
|
@@ -51,11 +52,11 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
51
52
|
e.globalAlpha = 1;
|
|
52
53
|
}
|
|
53
54
|
e.restore();
|
|
54
|
-
},
|
|
55
|
+
}, v = (e, n, r) => {
|
|
55
56
|
let { theme: i } = r, { bar: a, stops: s } = n, c = s.length;
|
|
56
57
|
if (typeof e.createLinearGradient == "function") {
|
|
57
58
|
let t = e.createLinearGradient(a.x, 0, a.x + a.width, 0);
|
|
58
|
-
s.forEach((e, n) => t.addColorStop(n / Math.max(1, c - 1), e)), e.fillStyle = t,
|
|
59
|
+
s.forEach((e, n) => t.addColorStop(n / Math.max(1, c - 1), e)), e.fillStyle = t, g(e, a.x, a.y, a.width, a.height, a.height / 2), e.fill();
|
|
59
60
|
} else {
|
|
60
61
|
let t = a.width / c;
|
|
61
62
|
s.forEach((n, r) => {
|
|
@@ -66,14 +67,14 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
66
67
|
for (let t of n.ticks) e.fillRect(Math.round(t), a.y - 2, 1, a.height + 4);
|
|
67
68
|
e.font = o(i, 11), e.textBaseline = "middle", e.fillStyle = t(i.textMuted);
|
|
68
69
|
for (let t of n.labels) e.textAlign = t.align, e.fillText(t.text, t.x, t.y);
|
|
69
|
-
n.caret !== null && (
|
|
70
|
-
},
|
|
70
|
+
n.caret !== null && (g(e, n.caret - 2, a.y - 3, 4, a.height + 6, 2), e.fillStyle = t(i.text), e.fill(), e.lineWidth = 1.5, e.strokeStyle = t(i.background), e.stroke());
|
|
71
|
+
}, y = 1.16, b = (e, t, n, r) => {
|
|
71
72
|
let i = Math.max(0, t.width + r * 2), a = Math.max(0, t.height + r * 2);
|
|
72
|
-
|
|
73
|
-
},
|
|
73
|
+
g(e, t.x - r, t.y - r, i, a, Math.max(0, Math.min(n + r, i / 2, a / 2)));
|
|
74
|
+
}, x = (e, n, r, i, a, o, s, c, l) => {
|
|
74
75
|
let u = t(l.background);
|
|
75
|
-
o ? (e.save(), e.shadowColor = "rgba(15, 23, 42, 0.4)", e.shadowBlur = 14, e.shadowOffsetY = 5,
|
|
76
|
-
},
|
|
76
|
+
o ? (e.save(), e.shadowColor = "rgba(15, 23, 42, 0.4)", e.shadowBlur = 14, e.shadowOffsetY = 5, b(e, n, r, s + (c?.width ?? 0)), e.fillStyle = c ? c.color : u, e.fill(), e.restore(), c && (b(e, n, r, s), e.fillStyle = u, e.fill())) : a && (b(e, n, r, 0), e.fillStyle = u, e.fill()), b(e, n, r, 0), e.fillStyle = i, e.fill(), o && o.width > 0 && (b(e, n, r, -o.width / 2), e.lineWidth = o.width, e.strokeStyle = o.color, e.stroke());
|
|
77
|
+
}, S = (e, n, r, i) => {
|
|
77
78
|
for (let a of n) if (a.kind === "bar") {
|
|
78
79
|
let t = s(a);
|
|
79
80
|
e.save(), e.beginPath(), e.rect(r.x, r.y, r.width, r.height), e.clip();
|
|
@@ -81,15 +82,15 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
81
82
|
color: a.ring,
|
|
82
83
|
width: Math.min(a.backdrop ? 2 : 1.5, Math.max(0, (Math.min(t.width, t.height) - 2) / 4))
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
x(e, t, a.radius, a.color, a.backdrop, n, 1.5, null, i), e.restore();
|
|
85
86
|
} else if (a.kind === "cell") {
|
|
86
|
-
let n = a.width *
|
|
87
|
-
|
|
87
|
+
let n = a.width * y, r = a.height * y;
|
|
88
|
+
x(e, {
|
|
88
89
|
x: a.x + (a.width - n) / 2,
|
|
89
90
|
y: a.y + (a.height - r) / 2,
|
|
90
91
|
width: n,
|
|
91
92
|
height: r
|
|
92
|
-
}, Math.max(2, a.radius) *
|
|
93
|
+
}, Math.max(2, a.radius) * y, a.color, !1, {
|
|
93
94
|
color: a.ring,
|
|
94
95
|
width: Math.min(2, Math.min(n, r) / 5)
|
|
95
96
|
}, 2, {
|
|
@@ -97,25 +98,25 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
97
98
|
width: 1.5
|
|
98
99
|
}, i);
|
|
99
100
|
}
|
|
100
|
-
},
|
|
101
|
+
}, C = (n, r) => {
|
|
101
102
|
let i = e(n);
|
|
102
103
|
return i ? t(i, i[3] * r) : n;
|
|
103
|
-
},
|
|
104
|
+
}, w = (e, n, r, i) => {
|
|
104
105
|
if (e.save(), n.origin) {
|
|
105
106
|
let r = (n.size - 2) / 2;
|
|
106
107
|
e.beginPath(), e.arc(n.origin.x, n.origin.y, r, 0, Math.PI * 2), e.fillStyle = t(i.background, .62), e.fill(), e.setLineDash([3, 3]), e.lineWidth = 1.5, e.strokeStyle = n.color, e.stroke(), e.setLineDash([]);
|
|
107
108
|
}
|
|
108
|
-
if (e.beginPath(), e.arc(n.x, n.y + 3, n.size / 2 + 2, 0, Math.PI * 2), e.fillStyle = "rgba(15, 23, 42, 0.18)", e.shadowColor = "rgba(15, 23, 42, 0.35)", e.shadowBlur = 10, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.beginPath(), e.arc(n.x, n.y, n.size / 2 + 5, 0, Math.PI * 2), e.fillStyle =
|
|
109
|
+
if (e.beginPath(), e.arc(n.x, n.y + 3, n.size / 2 + 2, 0, Math.PI * 2), e.fillStyle = "rgba(15, 23, 42, 0.18)", e.shadowColor = "rgba(15, 23, 42, 0.35)", e.shadowBlur = 10, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.beginPath(), e.arc(n.x, n.y, n.size / 2 + 5, 0, Math.PI * 2), e.fillStyle = C(n.color, .24), e.fill(), e.beginPath(), e.arc(n.x, n.y, n.size / 2 - 1, 0, Math.PI * 2), e.fillStyle = n.color, e.fill(), e.lineWidth = 2, e.strokeStyle = t(i.background), e.stroke(), n.label) {
|
|
109
110
|
e.font = o(i, 12, 600);
|
|
110
111
|
let a = e.measureText(n.label).width + 18, s = n.size / 2 + 8, c = n.x + s + a <= r.x + r.width || n.x - s - a < r.x ? n.x + s : n.x - s - a, l = n.y - 11;
|
|
111
|
-
e.shadowColor = "rgba(15, 23, 42, 0.2)", e.shadowBlur = 10, e.shadowOffsetY = 3,
|
|
112
|
+
e.shadowColor = "rgba(15, 23, 42, 0.2)", e.shadowBlur = 10, e.shadowOffsetY = 3, g(e, c, l, a, 22, 11), e.fillStyle = t(i.background), e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetY = 0, e.lineWidth = 1, e.strokeStyle = t(i.axis, .7), e.stroke(), e.fillStyle = t(i.text), e.textAlign = "left", e.textBaseline = "middle", e.fillText(n.label, c + 9, n.y);
|
|
112
113
|
}
|
|
113
114
|
e.restore();
|
|
114
|
-
},
|
|
115
|
-
let { width:
|
|
116
|
-
e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, Math.ceil(
|
|
117
|
-
width:
|
|
118
|
-
height:
|
|
115
|
+
}, T = (e, s, c, l, d, f = u(e)) => {
|
|
116
|
+
let { width: p, height: h, theme: y, model: b, view: x, layout: T } = s, { plot: E, scales: D } = T, O = d;
|
|
117
|
+
e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, Math.ceil(p * O), Math.ceil(h * O)), e.setTransform(O, 0, 0, O, 0, 0), i(e, {
|
|
118
|
+
width: p,
|
|
119
|
+
height: h,
|
|
119
120
|
scales: D,
|
|
120
121
|
x: b.x,
|
|
121
122
|
y: b.y,
|
|
@@ -127,7 +128,7 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
127
128
|
annotations: s.annotations
|
|
128
129
|
});
|
|
129
130
|
let k = s.legend?.colors;
|
|
130
|
-
if (k &&
|
|
131
|
+
if (k && v(e, k, s), s.legend) {
|
|
131
132
|
e.font = o(y, 12), e.textBaseline = "middle", e.textAlign = "left";
|
|
132
133
|
for (let n of s.legend.entries) {
|
|
133
134
|
let r = n.box.y + n.box.height / 2;
|
|
@@ -139,16 +140,16 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
139
140
|
e.globalAlpha = 1;
|
|
140
141
|
}
|
|
141
142
|
let A = s.hover?.marks.some((e) => e.kind === "bar") ?? !1;
|
|
142
|
-
for (let n of s.hover?.marks ?? []) n.kind === "band" && (
|
|
143
|
+
for (let n of s.hover?.marks ?? []) n.kind === "band" && (g(e, n.x, n.y, n.width, n.height, 6), e.fillStyle = t(y.text, A ? .04 : .06), e.fill());
|
|
143
144
|
let j = b.series.some((e) => !e.hidden && (e.type === "line" || e.type === "area"));
|
|
144
|
-
A && j && s.hover &&
|
|
145
|
+
A && j && s.hover && S(e, s.hover.marks, E, y);
|
|
145
146
|
let M = s.dragging?.target;
|
|
146
|
-
M && (e.save(), e.fillStyle =
|
|
147
|
+
M && (e.save(), e.fillStyle = C(M.color, .12), e.fillRect(M.x, M.y, M.width, M.height), e.strokeStyle = C(M.color, .7), e.lineWidth = 2, g(e, M.x + 1, M.y + 1, M.width - 2, M.height - 2, 4), e.stroke(), e.restore()), D.horizontal ? _(e, m(s), E) : N();
|
|
147
148
|
function N() {
|
|
148
149
|
let e = (e, t, n) => {
|
|
149
150
|
let r = 2 / (e[1] - e[0]), i = (t - e[0]) * r - 1;
|
|
150
151
|
return n ? [-r, -i] : [r, i];
|
|
151
|
-
}, [t, n] = e(
|
|
152
|
+
}, [t, n] = e(x.x, l.x, b.x.reverse), [r, i] = e(x.y, l.y, b.y.reverse);
|
|
152
153
|
f.paint(c, {
|
|
153
154
|
transform: {
|
|
154
155
|
xScale: t,
|
|
@@ -163,9 +164,9 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
163
164
|
}
|
|
164
165
|
e.setTransform(O, 0, 0, O, 0, 0);
|
|
165
166
|
for (let n of s.hover?.marks ?? []) n.kind === "guide" && (e.fillStyle = t(y.text, .06), e.fillRect(n.x, n.y, n.width, n.height));
|
|
166
|
-
if (A && !j && (e.fillStyle = t(y.background, .42), e.fillRect(E.x, E.y, E.width, E.height)), s.hover && !(A && j) &&
|
|
167
|
-
width:
|
|
168
|
-
height:
|
|
167
|
+
if (A && !j && (e.fillStyle = t(y.background, .42), e.fillRect(E.x, E.y, E.width, E.height)), s.hover && !(A && j) && S(e, s.hover.marks, E, y), a(e, {
|
|
168
|
+
width: p,
|
|
169
|
+
height: h,
|
|
169
170
|
scales: D,
|
|
170
171
|
theme: y,
|
|
171
172
|
annotations: s.annotations,
|
|
@@ -199,11 +200,11 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
199
200
|
}
|
|
200
201
|
for (let n of P.marks) n.kind !== "band" && n.kind !== "guide" && n.kind !== "bar" && n.kind !== "cell" && (e.beginPath(), e.arc(n.x, n.y, n.size / 2 + 8, 0, Math.PI * 2), e.fillStyle = n.halo, e.globalAlpha = .45, e.fill(), e.globalAlpha = 1, e.beginPath(), e.arc(n.x, n.y, n.size / 2 + 4, 0, Math.PI * 2), e.fillStyle = n.halo, e.fill(), e.beginPath(), e.arc(n.x, n.y, n.size / 2 - 1, 0, Math.PI * 2), e.fillStyle = n.color, e.fill(), e.lineWidth = 2, e.strokeStyle = t(y.background), e.stroke());
|
|
201
202
|
}
|
|
202
|
-
s.dragging &&
|
|
203
|
+
s.dragging && w(e, s.dragging, E, y);
|
|
203
204
|
let F = P?.tooltip;
|
|
204
205
|
if (F) {
|
|
205
206
|
let { box: i, lineHeight: a, padding: s } = F, c = r(y, n);
|
|
206
|
-
e.save(), e.shadowColor = "rgba(15, 23, 42, 0.18)", e.shadowBlur = 16, e.shadowOffsetY = 6,
|
|
207
|
+
e.save(), e.shadowColor = "rgba(15, 23, 42, 0.18)", e.shadowBlur = 16, e.shadowOffsetY = 6, g(e, i.x, i.y, i.width, i.height, 8), e.fillStyle = c.background, e.fill(), e.restore(), g(e, i.x + .5, i.y + .5, i.width - 1, i.height - 1, 8), e.strokeStyle = c.border, e.lineWidth = 1, e.stroke(), e.textBaseline = "middle";
|
|
207
208
|
let l = i.y + s + a / 2, u = i.x + s + 2, d = i.x + i.width - s - 2;
|
|
208
209
|
if (F.text) {
|
|
209
210
|
e.font = o(y, 12), e.fillStyle = t(y.text), e.textAlign = "left";
|
|
@@ -214,87 +215,89 @@ var m = (e) => (e[0] + e[1]) / 2, h = (e, t, n, r, i, a) => {
|
|
|
214
215
|
for (let i of n.rows) r = u, i.color && (e.fillStyle = i.color, e.beginPath(), e.arc(r + 4, l, 4, 0, Math.PI * 2), e.fill()), r += F.swatchWidth, e.font = o(y, 12), e.textAlign = "left", e.fillStyle = t(y.textMuted), e.fillText(i.name, r, l), e.font = o(y, 12, 600), e.textAlign = "right", e.fillStyle = t(y.text), e.fillText(i.value, d, l), l += a;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
},
|
|
218
|
-
let { canvas: t } = e, n = t.getContext("2d"), r = e.width, i = e.height, a = e.pixelRatio ?? 1, o = !1, s = null,
|
|
219
|
-
let t =
|
|
220
|
-
return t === void 0 &&
|
|
221
|
-
},
|
|
218
|
+
}, E = (e) => {
|
|
219
|
+
let { canvas: t } = e, n = t.getContext("2d"), r = e.width, i = e.height, a = e.pixelRatio ?? 1, o = !1, s = null, m = [], g = null, _ = "", v = "", y = e.options, b = /* @__PURE__ */ new WeakMap(), x = 0, S = (e) => {
|
|
220
|
+
let t = b.get(e);
|
|
221
|
+
return t === void 0 && b.set(e, t = ++x), t;
|
|
222
|
+
}, C = {
|
|
222
223
|
x: 0,
|
|
223
224
|
y: 0
|
|
224
|
-
},
|
|
225
|
-
if (s = null, o || !n || !
|
|
226
|
-
let e =
|
|
225
|
+
}, w = 0, E = "", D = (e, t) => n ? (t !== E && (n.font = t, E = t), n.measureText(e).width) : e.length * 6.5, O = n ? u(n) : null, k = globalThis, A = () => {
|
|
226
|
+
if (s = null, o || !n || !O) return;
|
|
227
|
+
let e = F.getScene();
|
|
227
228
|
if (!e) return;
|
|
228
229
|
let u = Math.max(1, Math.round(r * a)), f = Math.max(1, Math.round(i * a));
|
|
229
|
-
t.width !== u && (t.width = u), t.height !== f && (t.height = f),
|
|
230
|
-
let
|
|
231
|
-
x: 1 / Math.abs(
|
|
232
|
-
y: 1 / Math.abs(
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
x:
|
|
236
|
-
y:
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
o || s !== null || (s = t.requestAnimationFrame ? t.requestAnimationFrame(
|
|
240
|
-
},
|
|
230
|
+
t.width !== u && (P.own(), t.width = u), t.height !== f && (P.own(), t.height = f), E = "", g !== e.model && (g = e.model, _ = d(e.model, S(e.theme), (e) => y.series[e]?.stack));
|
|
231
|
+
let p = e.layout.scales, b = {
|
|
232
|
+
x: 1 / Math.abs(p.xPerPx),
|
|
233
|
+
y: 1 / Math.abs(p.yPerPx)
|
|
234
|
+
}, x = `${_}|${l(e.model, b)}`;
|
|
235
|
+
x !== v && (v = x, C = {
|
|
236
|
+
x: h(e.model.base.x),
|
|
237
|
+
y: h(e.model.base.y)
|
|
238
|
+
}, m = c(e.model, C, ++w, b)), T(n, e, m, C, a, O), E = "";
|
|
239
|
+
}, j = () => {
|
|
240
|
+
o || s !== null || (s = t.requestAnimationFrame ? t.requestAnimationFrame(A) : k.requestAnimationFrame ? k.requestAnimationFrame(A) : setTimeout(A, 16));
|
|
241
|
+
}, M = () => {
|
|
242
|
+
s !== null && (t.cancelAnimationFrame ? t.cancelAnimationFrame(s) : k.cancelAnimationFrame ? k.cancelAnimationFrame(s) : clearTimeout(s), s = null);
|
|
243
|
+
}, N = () => {
|
|
244
|
+
M(), A();
|
|
245
|
+
}, P = f(t, () => t.width !== Math.max(1, Math.round(r * a)) || t.height !== Math.max(1, Math.round(i * a)), N), F = p({
|
|
241
246
|
options: e.options,
|
|
242
247
|
theme: e.theme,
|
|
243
|
-
measureText:
|
|
244
|
-
onInvalidate:
|
|
248
|
+
measureText: D,
|
|
249
|
+
onInvalidate: j
|
|
245
250
|
});
|
|
246
|
-
|
|
247
|
-
let
|
|
251
|
+
F.setSize(r, i);
|
|
252
|
+
let I = (e, t) => ({
|
|
248
253
|
id: e.identifier ?? t,
|
|
249
254
|
touch: !0
|
|
250
255
|
});
|
|
251
256
|
return {
|
|
252
257
|
setOptions: (e) => {
|
|
253
|
-
|
|
258
|
+
y = e, F.setOptions(e);
|
|
254
259
|
},
|
|
255
|
-
setTheme: (e) =>
|
|
260
|
+
setTheme: (e) => F.setTheme(e),
|
|
256
261
|
resize(e, t, n) {
|
|
257
|
-
r = e, i = t, n && (a = n),
|
|
258
|
-
},
|
|
259
|
-
render() {
|
|
260
|
-
s !== null && (t.cancelAnimationFrame ? t.cancelAnimationFrame(s) : O.cancelAnimationFrame ? O.cancelAnimationFrame(s) : clearTimeout(s)), k();
|
|
262
|
+
r = e, i = t, n && (a = n), F.setSize(e, t), j();
|
|
261
263
|
},
|
|
264
|
+
render: N,
|
|
262
265
|
touchStart(e) {
|
|
263
|
-
e.forEach((e, t) =>
|
|
266
|
+
e.forEach((e, t) => F.pointerDown(e.x, e.y, I(e, t)));
|
|
264
267
|
},
|
|
265
268
|
touchMove(e) {
|
|
266
|
-
e.forEach((e, t) =>
|
|
269
|
+
e.forEach((e, t) => F.pointerMove(e.x, e.y, I(e, t)));
|
|
267
270
|
},
|
|
268
271
|
touchEnd(e) {
|
|
269
|
-
e.forEach((e, t) =>
|
|
272
|
+
e.forEach((e, t) => F.pointerUp(e.x, e.y, I(e, t)));
|
|
270
273
|
},
|
|
271
274
|
touchCancel(e = [{
|
|
272
275
|
x: 0,
|
|
273
276
|
y: 0
|
|
274
277
|
}]) {
|
|
275
|
-
e.forEach((e, t) =>
|
|
278
|
+
e.forEach((e, t) => F.pointerCancel(I(e, t)));
|
|
276
279
|
},
|
|
277
|
-
pointerDown: (e, t, n) =>
|
|
278
|
-
pointerMove: (e, t, n) =>
|
|
279
|
-
pointerUp: (e, t, n) =>
|
|
280
|
-
pointerLeave: () =>
|
|
281
|
-
zoomAt: (e, t, n) =>
|
|
282
|
-
resetZoom: () =>
|
|
283
|
-
getView: () =>
|
|
284
|
-
setView: (e) =>
|
|
285
|
-
toggleSeries: (e) =>
|
|
286
|
-
clearHover: () =>
|
|
287
|
-
getPlotRect: () =>
|
|
288
|
-
toPixel: (e, t) =>
|
|
289
|
-
fromPixel: (e, t) =>
|
|
290
|
-
getController: () =>
|
|
291
|
-
on: (e, t) =>
|
|
280
|
+
pointerDown: (e, t, n) => F.pointerDown(e, t, n),
|
|
281
|
+
pointerMove: (e, t, n) => F.pointerMove(e, t, n),
|
|
282
|
+
pointerUp: (e, t, n) => F.pointerUp(e, t, n),
|
|
283
|
+
pointerLeave: () => F.pointerLeave(),
|
|
284
|
+
zoomAt: (e, t, n) => F.zoomAt(e, t, n),
|
|
285
|
+
resetZoom: () => F.resetZoom(),
|
|
286
|
+
getView: () => F.getView(),
|
|
287
|
+
setView: (e) => F.setView(e),
|
|
288
|
+
toggleSeries: (e) => F.toggleSeries(e),
|
|
289
|
+
clearHover: () => F.clearHover(),
|
|
290
|
+
getPlotRect: () => F.getPlotRect(),
|
|
291
|
+
toPixel: (e, t) => F.toPixel(e, t),
|
|
292
|
+
fromPixel: (e, t) => F.fromPixel(e, t),
|
|
293
|
+
getController: () => F,
|
|
294
|
+
on: (e, t) => F.on(e, t),
|
|
292
295
|
destroy() {
|
|
293
|
-
o || (o = !0,
|
|
296
|
+
o || (o = !0, M(), P.disconnect(), O?.destroy(), F.destroy());
|
|
294
297
|
}
|
|
295
298
|
};
|
|
296
299
|
};
|
|
297
300
|
//#endregion
|
|
298
|
-
export {
|
|
301
|
+
export { E as createCanvasChart, w as drawDragPreview, _ as drawPrimitives, T as drawScene };
|
|
299
302
|
|
|
300
303
|
//# sourceMappingURL=canvas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.js","names":["mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","toCss","theme","font","l","CELL_LIFT","grownRect","d","drawLifted","background","ring","halo","accent","backdrop","fill","drawLiftedMarks","mark","marks","liftedBarRect","withAlpha","rgba","parseColor","alpha","drawDragPreview","gap","drawScene","createCanvas2dPainter","layout","dpr","pixelRatio","width","height","drawBackground","model","e","cy","lifted","m","mixed","s","target","scales","scenePrimitives","paintData","scale","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","items","drawForeground","box","label","hover","cx","tip","colors","tooltipColors","CANVAS_TOOLTIP_ALPHA","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","painter","g","render","controller","pw","ph","itemsSignature","index","sc","density","key","cellStyleKey","buildItems","schedule","createChartController","touchOptions","t","ratio","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { parseColor, toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport type { DragPreview } from \"./drag-preview\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport type { Rect } from \"./layout\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { liftedBarRect, type HoverMark } from \"./scene\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartTheme, ChartThemeInput } from \"./theme\";\nimport { CANVAS_TOOLTIP_ALPHA, tooltipColors } from \"./tooltip\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Scale of a hovered heatmap cell (like the DOM host) */\nconst CELL_LIFT = 1.16;\n\n/** A rounded rectangle grown by `d` on every side (shrunk when negative) */\nconst grownRect = (\n ctx: CanvasRenderingContext2D,\n r: { x: number; y: number; width: number; height: number },\n radius: number,\n d: number,\n) => {\n const w = Math.max(0, r.width + d * 2);\n const h = Math.max(0, r.height + d * 2);\n roundedRect(\n ctx,\n r.x - d,\n r.y - d,\n w,\n h,\n Math.max(0, Math.min(radius + d, w / 2, h / 2)),\n );\n};\n\n/**\n * A lifted shape: the lift shadow under a halo of the background, an\n * optional accent line around the halo, the fill, a ring inside the edge\n */\nconst drawLifted = (\n ctx: CanvasRenderingContext2D,\n r: { x: number; y: number; width: number; height: number },\n radius: number,\n fill: string,\n backdrop: boolean,\n ring: { color: string; width: number } | null,\n halo: number,\n accent: { color: string; width: number } | null,\n theme: ChartScene[\"theme\"],\n) => {\n const background = toCss(theme.background);\n if (ring) {\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 5;\n grownRect(ctx, r, radius, halo + (accent?.width ?? 0));\n ctx.fillStyle = accent ? accent.color : background;\n ctx.fill();\n ctx.restore();\n if (accent) {\n grownRect(ctx, r, radius, halo);\n ctx.fillStyle = background;\n ctx.fill();\n }\n } else if (backdrop) {\n grownRect(ctx, r, radius, 0);\n ctx.fillStyle = background;\n ctx.fill();\n }\n grownRect(ctx, r, radius, 0);\n ctx.fillStyle = fill;\n ctx.fill();\n if (ring && ring.width > 0) {\n grownRect(ctx, r, radius, -ring.width / 2);\n ctx.lineWidth = ring.width;\n ctx.strokeStyle = ring.color;\n ctx.stroke();\n }\n};\n\n/** Hovered bars (thicker, clipped to the plot) and heatmap cells, lifted */\nconst drawLiftedMarks = (\n ctx: CanvasRenderingContext2D,\n marks: readonly HoverMark[],\n plot: { x: number; y: number; width: number; height: number },\n theme: ChartScene[\"theme\"],\n) => {\n for (const mark of marks) {\n if (mark.kind === \"bar\") {\n const r = liftedBarRect(mark);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n const ring =\n mark.ring === null\n ? null\n : {\n color: mark.ring,\n width: Math.min(\n mark.backdrop ? 2 : 1.5,\n Math.max(0, (Math.min(r.width, r.height) - 2) / 4),\n ),\n };\n drawLifted(\n ctx,\n r,\n mark.radius,\n mark.color,\n mark.backdrop,\n ring,\n 1.5,\n null,\n theme,\n );\n ctx.restore();\n } else if (mark.kind === \"cell\") {\n const w = mark.width * CELL_LIFT;\n const h = mark.height * CELL_LIFT;\n const r = {\n x: mark.x + (mark.width - w) / 2,\n y: mark.y + (mark.height - h) / 2,\n width: w,\n height: h,\n };\n drawLifted(\n ctx,\n r,\n Math.max(2, mark.radius) * CELL_LIFT,\n mark.color,\n false,\n { color: mark.ring, width: Math.min(2, Math.min(w, h) / 5) },\n 2,\n { color: toCss(theme.primary, 0.6), width: 1.5 },\n theme,\n );\n }\n }\n};\n\n/** A CSS color with its alpha multiplied (canvas: no color-mix) */\nconst withAlpha = (color: string, alpha: number) => {\n const rgba = parseColor(color);\n return rgba ? toCss(rgba, rgba[3] * alpha) : color;\n};\n\n/**\n * A dragged point: a dashed placeholder where it was, the dot lifted under\n * the pointer with a shadow, and its label in a pill beside it\n */\nexport const drawDragPreview = (\n ctx: CanvasRenderingContext2D,\n d: DragPreview,\n plot: Rect,\n theme: ChartTheme,\n) => {\n ctx.save();\n if (d.origin) {\n const r = (d.size - 2) / 2;\n ctx.beginPath();\n ctx.arc(d.origin.x, d.origin.y, r, 0, Math.PI * 2);\n ctx.fillStyle = toCss(theme.background, 0.62);\n ctx.fill();\n ctx.setLineDash([3, 3]);\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = d.color;\n ctx.stroke();\n ctx.setLineDash([]);\n }\n // shadow, then the halo and the dot ringed in the background color\n ctx.beginPath();\n ctx.arc(d.x, d.y + 3, d.size / 2 + 2, 0, Math.PI * 2);\n ctx.fillStyle = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowColor = \"rgba(15, 23, 42, 0.35)\";\n ctx.shadowBlur = 10;\n ctx.fill();\n ctx.shadowColor = \"transparent\";\n ctx.shadowBlur = 0;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2 + 5, 0, Math.PI * 2);\n ctx.fillStyle = withAlpha(d.color, 0.24);\n ctx.fill();\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n if (d.label) {\n ctx.font = font(theme, 12, 600);\n const w = ctx.measureText(d.label).width + 18;\n const h = 22;\n const gap = d.size / 2 + 8;\n const right =\n d.x + gap + w <= plot.x + plot.width || d.x - gap - w < plot.x;\n const x = right ? d.x + gap : d.x - gap - w;\n const y = d.y - h / 2;\n ctx.shadowColor = \"rgba(15, 23, 42, 0.2)\";\n ctx.shadowBlur = 10;\n ctx.shadowOffsetY = 3;\n roundedRect(ctx, x, y, w, h, h / 2);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.shadowColor = \"transparent\";\n ctx.shadowBlur = 0;\n ctx.shadowOffsetY = 0;\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.axis, 0.7);\n ctx.stroke();\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.fillText(d.label, x + 9, d.y);\n }\n ctx.restore();\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data (lighter behind lifted bars)\n const lifted = scene.hover?.marks.some((m) => m.kind === \"bar\") ?? false;\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, lifted ? 0.04 : 0.06);\n ctx.fill();\n }\n // combo charts: the lifted bar goes below the data, so the lines (and\n // their markers) stay above it, without a veil\n const mixed = model.series.some(\n (s) => !s.hidden && (s.type === \"line\" || s.type === \"area\"),\n );\n if (lifted && mixed && scene.hover)\n drawLiftedMarks(ctx, scene.hover.marks, plot, theme);\n // the area a dragged point would land in, below the data\n const target = scene.dragging?.target;\n if (target) {\n ctx.save();\n ctx.fillStyle = withAlpha(target.color, 0.12);\n ctx.fillRect(target.x, target.y, target.width, target.height);\n ctx.strokeStyle = withAlpha(target.color, 0.7);\n ctx.lineWidth = 2;\n roundedRect(\n ctx,\n target.x + 1,\n target.y + 1,\n target.width - 2,\n target.height - 2,\n 4,\n );\n ctx.stroke();\n ctx.restore();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n // lifted bars and cells, below the value labels; the plot behind lifted\n // bars is veiled so the hovered one stands out\n if (lifted && !mixed) {\n ctx.fillStyle = toCss(theme.background, 0.42);\n ctx.fillRect(plot.x, plot.y, plot.width, plot.height);\n }\n if (scene.hover && !(lifted && mixed))\n drawLiftedMarks(ctx, scene.hover.marks, plot, theme);\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n arrows: scene.arrows,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n const y = box.y + box.height / 2;\n if (label.color) {\n // inside a solid bar: its contrasting color, no halo\n ctx.save();\n ctx.fillStyle = label.color;\n ctx.fillText(label.text, box.x, y);\n ctx.restore();\n continue;\n }\n ctx.strokeText(label.text, box.x, y);\n ctx.fillText(label.text, box.x, y);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (\n mark.kind === \"band\" ||\n mark.kind === \"guide\" ||\n mark.kind === \"bar\" ||\n mark.kind === \"cell\"\n )\n continue;\n // a soft glow, the tinted halo, the dot ringed in the background color\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 8, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.globalAlpha = 0.45;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) drawDragPreview(ctx, scene.dragging, plot, theme);\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n const colors = tooltipColors(theme, CANVAS_TOOLTIP_ALPHA);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = colors.background;\n ctx.fill();\n ctx.restore();\n roundedRect(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = colors.border;\n ctx.lineWidth = 1;\n ctx.stroke();\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.fillText(content.title, x, y);\n y += lineHeight;\n if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) canvas.width = pw;\n if (canvas.height !== ph) canvas.height = ph;\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render() {\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n render();\n },\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n if (frameId !== null) {\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n }\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":";;;;;;;;;AAmGA,IAAMA,KAAO,OAAyBC,EAAE,KAAKA,EAAE,MAAM,GAE/CC,KACJ,GACA,GACA,GACA,GACA,GACA,MACG;CAWH,AAVAC,EAAI,UAAU,GACdA,EAAI,OAAOC,IAAIH,GAAGI,CAAC,GACnBF,EAAI,OAAOC,IAAIE,IAAIL,GAAGI,CAAC,GACvBF,EAAI,MAAMC,IAAIE,GAAGD,GAAGD,IAAIE,GAAGD,IAAIJ,GAAGA,CAAC,GACnCE,EAAI,OAAOC,IAAIE,GAAGD,IAAIE,IAAIN,CAAC,GAC3BE,EAAI,MAAMC,IAAIE,GAAGD,IAAIE,GAAGH,IAAIE,IAAIL,GAAGI,IAAIE,GAAGN,CAAC,GAC3CE,EAAI,OAAOC,IAAIH,GAAGI,IAAIE,CAAC,GACvBJ,EAAI,MAAMC,GAAGC,IAAIE,GAAGH,GAAGC,IAAIE,IAAIN,GAAGA,CAAC,GACnCE,EAAI,OAAOC,GAAGC,IAAIJ,CAAC,GACnBE,EAAI,MAAMC,GAAGC,GAAGD,IAAIH,GAAGI,GAAGJ,CAAC,GAC3BE,EAAI,UAAU;AAChB,GAMaK,KACX,GACA,GACA,MACG;CAMH,AALAL,EAAI,KAAK,GACTA,EAAI,UAAU,GACdA,EAAI,KAAKM,EAAK,GAAGA,EAAK,GAAGA,EAAK,OAAOA,EAAK,MAAM,GAChDN,EAAI,KAAK,GACT,EAAI,WAA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ACpD,UAAU;GACR,AAAInC,MACJ,IAAY,IACRC,MAAY,SACVF,EAAO,uBAAsBA,EAAO,qBAAqBE,CAAO,IAC3De,EAAE,uBAAsBA,EAAE,qBAAqBf,CAAO,IAC1D,aAAaA,CAAO,IAE3Bc,GAAS,QAAQ,GACjBG,EAAW,QAAQ;EACrB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"canvas.js","names":["mid","r","roundedRect","ctx","x","y","w","h","drawPrimitives","plot","p","primitives","bottoms","k","n","run","i","b","radius","stroke","color","drawColorLegend","scene","ramp","stops","gradient","bar","c","toCss","theme","font","l","CELL_LIFT","grownRect","d","drawLifted","background","ring","halo","accent","backdrop","fill","drawLiftedMarks","mark","marks","liftedBarRect","withAlpha","rgba","parseColor","alpha","drawDragPreview","gap","drawScene","createCanvas2dPainter","layout","dpr","pixelRatio","width","height","drawBackground","model","e","cy","lifted","m","mixed","s","target","scales","scenePrimitives","paintData","scale","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","items","drawForeground","box","label","hover","cx","tip","colors","tooltipColors","CANVAS_TOOLTIP_ALPHA","padding","lineHeight","left","right","line","content","row","createCanvasChart","config","canvas","destroyed","frameId","itemsModel","itemsKey0","itemsKey","options","themeIds","themeCount","themeId","id","version","fontSet","measureText","f","text","painter","g","render","controller","pw","ph","backing","itemsSignature","index","sc","density","key","cellStyleKey","buildItems","schedule","cancelFrame","renderNow","watchBackingStore","createChartController","touchOptions","t","ratio","v","type","listener"],"sources":["../../../../charts/src/engine/canvas.ts"],"sourcesContent":["// createCanvasChart: a whole chart drawn on one 2D canvas without any DOM:\n// WeChat / Alipay / ByteDance mini-programs (`<canvas type=\"2d\">`), Taro,\n// uni-app, OffscreenCanvas, or a plain browser canvas. The host forwards\n// touches / pointer events; everything else is handled here.\n\nimport { watchBackingStore } from \"./backing-store\";\nimport { parseColor, toCss } from \"./color\";\nimport {\n createChartController,\n scenePrimitives,\n type ChartController,\n type ChartControllerEventMap,\n type ChartPointerOptions,\n type ChartPrimitive,\n type ChartScene,\n} from \"./controller\";\nimport type { DragPreview } from \"./drag-preview\";\nimport { buildItems, cellStyleKey, type Origin } from \"./items\";\nimport type { Rect } from \"./layout\";\nimport { drawBackground, drawForeground, font } from \"./overlay\";\nimport { createCanvas2dPainter } from \"./renderers/canvas2d\";\nimport type { RenderItem } from \"./renderers/types\";\nimport { liftedBarRect, type HoverMark } from \"./scene\";\nimport { itemsSignature } from \"./signature\";\nimport type { ChartTheme, ChartThemeInput } from \"./theme\";\nimport { CANVAS_TOOLTIP_ALPHA, tooltipColors } from \"./tooltip\";\nimport type { ChartOptions, ChartRect, ChartView } from \"./types\";\n\n/**\n * The canvas a chart draws on: a browser `HTMLCanvasElement`, an\n * `OffscreenCanvas` or the node of a mini-program `<canvas type=\"2d\">`\n * (`SelectorQuery.fields({ node: true })`)\n */\nexport interface ChartCanvas {\n width: number;\n height: number;\n getContext(type: \"2d\"): unknown;\n /** Mini-program canvases schedule their frames themselves */\n requestAnimationFrame?: (callback: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n}\n\n/** A touch point relative to the canvas (`x` / `y`) with its identifier */\nexport interface ChartTouch {\n x: number;\n y: number;\n identifier?: number;\n}\n\nexport interface CanvasChartConfig {\n canvas: ChartCanvas;\n /** Size of the canvas in CSS pixels (rpx converted by the host) */\n width: number;\n height: number;\n /**\n * Device pixel ratio (`wx.getWindowInfo().pixelRatio` in mini-programs)\n * @default 1\n */\n pixelRatio?: number;\n options: ChartOptions;\n /** Colors and fonts: values of the Minerva CSS variables */\n theme?: ChartThemeInput;\n}\n\nexport interface CanvasChartInstance {\n setOptions(options: ChartOptions): void;\n setTheme(theme: ChartThemeInput | undefined): void;\n /** New CSS size (and pixel ratio) of the canvas */\n resize(width: number, height: number, pixelRatio?: number): void;\n /** Draws now (frames are otherwise scheduled automatically) */\n render(): void;\n /** Touch handlers: pass the `touches` / `changedTouches` of the event */\n touchStart(touches: readonly ChartTouch[]): void;\n touchMove(touches: readonly ChartTouch[]): void;\n touchEnd(changedTouches: readonly ChartTouch[]): void;\n touchCancel(changedTouches?: readonly ChartTouch[]): void;\n /** Mouse / pen handlers (H5, desktop mini-programs) */\n pointerDown(x: number, y: number, options?: ChartPointerOptions): void;\n pointerMove(x: number, y: number, options?: ChartPointerOptions): void;\n pointerUp(x: number, y: number, options?: ChartPointerOptions): void;\n pointerLeave(): void;\n /** Zooms around a pixel (factor < 1 zooms in) */\n zoomAt(x: number, y: number, factor: number): void;\n resetZoom(): void;\n getView(): ChartView;\n setView(view: Partial<ChartView>): void;\n toggleSeries(id: string): void;\n clearHover(): void;\n getPlotRect(): ChartRect | null;\n toPixel(x: number, y: number): { x: number; y: number } | null;\n fromPixel(x: number, y: number): { x: number; y: number } | null;\n /** The platform-free controller (scene, gestures) */\n getController(): ChartController;\n on<K extends keyof ChartControllerEventMap>(\n type: K,\n listener: (event: ChartControllerEventMap[K]) => void,\n ): () => void;\n destroy(): void;\n}\n\nconst mid = (r: [number, number]) => (r[0] + r[1]) / 2;\n\nconst roundedRect = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\n/**\n * Draws the shapes of `scenePrimitives` (CSS pixels of the chart) clipped to\n * the plot: the data of horizontal charts\n */\nexport const drawPrimitives = (\n ctx: CanvasRenderingContext2D,\n primitives: readonly ChartPrimitive[],\n plot: { x: number; y: number; width: number; height: number },\n) => {\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n for (const p of primitives) {\n if (p.kind === \"area\") {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = p.color;\n p.segments.forEach((run, k) => {\n const bottoms = p.bottoms?.[k];\n const n = run.length / 2;\n if (n < 2) return;\n ctx.beginPath();\n for (let i = 0; i < n; i++) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i * 2], run[i * 2 + 1]);\n }\n // back along the bottom edge (or the baseline)\n for (let i = n - 1; i >= 0; i--) {\n const b = bottoms ? bottoms[i] : p.baseline;\n if (p.horizontal) ctx.lineTo(b, run[i * 2 + 1]);\n else ctx.lineTo(run[i * 2], b);\n }\n ctx.closePath();\n ctx.fill();\n });\n ctx.globalAlpha = 1;\n } else if (p.kind === \"line\") {\n ctx.strokeStyle = p.color;\n ctx.lineWidth = p.width;\n ctx.beginPath();\n for (const run of p.segments) {\n for (let i = 0; i < run.length; i += 2) {\n if (i === 0) ctx.moveTo(run[0], run[1]);\n else ctx.lineTo(run[i], run[i + 1]);\n }\n }\n ctx.stroke();\n } else if (p.kind === \"bars\") {\n ctx.globalAlpha = p.opacity ?? 1;\n const r = p.radius ?? 0;\n for (let k = 0; k < p.rects.length; k += 4) {\n const [x, y, w, h] = [\n p.rects[k],\n p.rects[k + 1],\n p.rects[k + 2],\n p.rects[k + 3],\n ];\n ctx.fillStyle = p.colors?.[k / 4] ?? p.color;\n const radius = Math.min(r, w / 2, h / 2);\n if (radius > 0.5) {\n roundedRect(ctx, x, y, w, h, radius);\n ctx.fill();\n } else {\n ctx.fillRect(x, y, w, h);\n }\n }\n ctx.globalAlpha = 1;\n } else {\n const stroke = p.stroke ?? 0;\n for (let k = 0; k < p.dots.length; k += 3) {\n const color = p.colors[k / 3] ?? \"#888\";\n const r = p.dots[k + 2] / 2;\n ctx.beginPath();\n ctx.arc(\n p.dots[k],\n p.dots[k + 1],\n Math.max(0, r - stroke / 2),\n 0,\n Math.PI * 2,\n );\n if (p.opacity > 0) {\n ctx.globalAlpha = p.opacity;\n ctx.fillStyle = color;\n ctx.fill();\n }\n if (stroke > 0) {\n // rings stay opaque (hollow box plot outliers)\n ctx.globalAlpha = 1;\n ctx.lineWidth = stroke;\n ctx.strokeStyle = color;\n ctx.stroke();\n }\n }\n ctx.globalAlpha = 1;\n }\n }\n ctx.restore();\n};\n\n/** The visual map of a heatmap: gradient bar, value labels, hover caret */\nconst drawColorLegend = (\n ctx: CanvasRenderingContext2D,\n ramp: NonNullable<NonNullable<ChartScene[\"legend\"]>[\"colors\"]>,\n scene: ChartScene,\n) => {\n const { theme } = scene;\n const { bar, stops } = ramp;\n const n = stops.length;\n if (typeof ctx.createLinearGradient === \"function\") {\n const gradient = ctx.createLinearGradient(bar.x, 0, bar.x + bar.width, 0);\n stops.forEach((c, k) => gradient.addColorStop(k / Math.max(1, n - 1), c));\n ctx.fillStyle = gradient;\n roundedRect(ctx, bar.x, bar.y, bar.width, bar.height, bar.height / 2);\n ctx.fill();\n } else {\n // contexts without gradients: even steps\n const w = bar.width / n;\n stops.forEach((c, k) => {\n ctx.fillStyle = c;\n ctx.fillRect(bar.x + k * w, bar.y, w + 0.5, bar.height);\n });\n }\n ctx.fillStyle = toCss(theme.text, 0.35);\n for (const t of ramp.ticks)\n ctx.fillRect(Math.round(t), bar.y - 2, 1, bar.height + 4);\n ctx.font = font(theme, 11);\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = toCss(theme.textMuted);\n for (const l of ramp.labels) {\n ctx.textAlign = l.align;\n ctx.fillText(l.text, l.x, l.y);\n }\n if (ramp.caret !== null) {\n roundedRect(ctx, ramp.caret - 2, bar.y - 3, 4, bar.height + 6, 2);\n ctx.fillStyle = toCss(theme.text);\n ctx.fill();\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n};\n\n/** Scale of a hovered heatmap cell (like the DOM host) */\nconst CELL_LIFT = 1.16;\n\n/** A rounded rectangle grown by `d` on every side (shrunk when negative) */\nconst grownRect = (\n ctx: CanvasRenderingContext2D,\n r: { x: number; y: number; width: number; height: number },\n radius: number,\n d: number,\n) => {\n const w = Math.max(0, r.width + d * 2);\n const h = Math.max(0, r.height + d * 2);\n roundedRect(\n ctx,\n r.x - d,\n r.y - d,\n w,\n h,\n Math.max(0, Math.min(radius + d, w / 2, h / 2)),\n );\n};\n\n/**\n * A lifted shape: the lift shadow under a halo of the background, an\n * optional accent line around the halo, the fill, a ring inside the edge\n */\nconst drawLifted = (\n ctx: CanvasRenderingContext2D,\n r: { x: number; y: number; width: number; height: number },\n radius: number,\n fill: string,\n backdrop: boolean,\n ring: { color: string; width: number } | null,\n halo: number,\n accent: { color: string; width: number } | null,\n theme: ChartScene[\"theme\"],\n) => {\n const background = toCss(theme.background);\n if (ring) {\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.4)\";\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 5;\n grownRect(ctx, r, radius, halo + (accent?.width ?? 0));\n ctx.fillStyle = accent ? accent.color : background;\n ctx.fill();\n ctx.restore();\n if (accent) {\n grownRect(ctx, r, radius, halo);\n ctx.fillStyle = background;\n ctx.fill();\n }\n } else if (backdrop) {\n grownRect(ctx, r, radius, 0);\n ctx.fillStyle = background;\n ctx.fill();\n }\n grownRect(ctx, r, radius, 0);\n ctx.fillStyle = fill;\n ctx.fill();\n if (ring && ring.width > 0) {\n grownRect(ctx, r, radius, -ring.width / 2);\n ctx.lineWidth = ring.width;\n ctx.strokeStyle = ring.color;\n ctx.stroke();\n }\n};\n\n/** Hovered bars (thicker, clipped to the plot) and heatmap cells, lifted */\nconst drawLiftedMarks = (\n ctx: CanvasRenderingContext2D,\n marks: readonly HoverMark[],\n plot: { x: number; y: number; width: number; height: number },\n theme: ChartScene[\"theme\"],\n) => {\n for (const mark of marks) {\n if (mark.kind === \"bar\") {\n const r = liftedBarRect(mark);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n const ring =\n mark.ring === null\n ? null\n : {\n color: mark.ring,\n width: Math.min(\n mark.backdrop ? 2 : 1.5,\n Math.max(0, (Math.min(r.width, r.height) - 2) / 4),\n ),\n };\n drawLifted(\n ctx,\n r,\n mark.radius,\n mark.color,\n mark.backdrop,\n ring,\n 1.5,\n null,\n theme,\n );\n ctx.restore();\n } else if (mark.kind === \"cell\") {\n const w = mark.width * CELL_LIFT;\n const h = mark.height * CELL_LIFT;\n const r = {\n x: mark.x + (mark.width - w) / 2,\n y: mark.y + (mark.height - h) / 2,\n width: w,\n height: h,\n };\n drawLifted(\n ctx,\n r,\n Math.max(2, mark.radius) * CELL_LIFT,\n mark.color,\n false,\n { color: mark.ring, width: Math.min(2, Math.min(w, h) / 5) },\n 2,\n { color: toCss(theme.primary, 0.6), width: 1.5 },\n theme,\n );\n }\n }\n};\n\n/** A CSS color with its alpha multiplied (canvas: no color-mix) */\nconst withAlpha = (color: string, alpha: number) => {\n const rgba = parseColor(color);\n return rgba ? toCss(rgba, rgba[3] * alpha) : color;\n};\n\n/**\n * A dragged point: a dashed placeholder where it was, the dot lifted under\n * the pointer with a shadow, and its label in a pill beside it\n */\nexport const drawDragPreview = (\n ctx: CanvasRenderingContext2D,\n d: DragPreview,\n plot: Rect,\n theme: ChartTheme,\n) => {\n ctx.save();\n if (d.origin) {\n const r = (d.size - 2) / 2;\n ctx.beginPath();\n ctx.arc(d.origin.x, d.origin.y, r, 0, Math.PI * 2);\n ctx.fillStyle = toCss(theme.background, 0.62);\n ctx.fill();\n ctx.setLineDash([3, 3]);\n ctx.lineWidth = 1.5;\n ctx.strokeStyle = d.color;\n ctx.stroke();\n ctx.setLineDash([]);\n }\n // shadow, then the halo and the dot ringed in the background color\n ctx.beginPath();\n ctx.arc(d.x, d.y + 3, d.size / 2 + 2, 0, Math.PI * 2);\n ctx.fillStyle = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowColor = \"rgba(15, 23, 42, 0.35)\";\n ctx.shadowBlur = 10;\n ctx.fill();\n ctx.shadowColor = \"transparent\";\n ctx.shadowBlur = 0;\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2 + 5, 0, Math.PI * 2);\n ctx.fillStyle = withAlpha(d.color, 0.24);\n ctx.fill();\n ctx.beginPath();\n ctx.arc(d.x, d.y, d.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = d.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n if (d.label) {\n ctx.font = font(theme, 12, 600);\n const w = ctx.measureText(d.label).width + 18;\n const h = 22;\n const gap = d.size / 2 + 8;\n const right =\n d.x + gap + w <= plot.x + plot.width || d.x - gap - w < plot.x;\n const x = right ? d.x + gap : d.x - gap - w;\n const y = d.y - h / 2;\n ctx.shadowColor = \"rgba(15, 23, 42, 0.2)\";\n ctx.shadowBlur = 10;\n ctx.shadowOffsetY = 3;\n roundedRect(ctx, x, y, w, h, h / 2);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.shadowColor = \"transparent\";\n ctx.shadowBlur = 0;\n ctx.shadowOffsetY = 0;\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.axis, 0.7);\n ctx.stroke();\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.fillText(d.label, x + 9, d.y);\n }\n ctx.restore();\n};\n\n/** Draws a scene (legend, axes, data, labels, hover) on a 2D context */\nexport const drawScene = (\n ctx: CanvasRenderingContext2D,\n scene: ChartScene,\n items: readonly RenderItem[],\n origin: Origin,\n pixelRatio: number,\n painter = createCanvas2dPainter(ctx),\n) => {\n const { width, height, theme, model, view, layout } = scene;\n const { plot, scales } = layout;\n const dpr = pixelRatio;\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, Math.ceil(width * dpr), Math.ceil(height * dpr));\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n drawBackground(ctx, {\n width,\n height,\n scales,\n x: model.x,\n y: model.y,\n xTicks: layout.xTicks,\n yTicks: layout.yTicks,\n y2: model.y2,\n y2Ticks: layout.y2Ticks,\n theme,\n annotations: scene.annotations,\n });\n\n // color legend of heatmaps\n const ramp = scene.legend?.colors;\n if (ramp) drawColorLegend(ctx, ramp, scene);\n // legend\n if (scene.legend) {\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const e of scene.legend.entries) {\n const cy = e.box.y + e.box.height / 2;\n ctx.globalAlpha = e.hidden ? 0.45 : 1;\n ctx.fillStyle = e.color;\n if (e.shape === \"dot\") {\n ctx.beginPath();\n ctx.arc(e.box.x + 5, cy, 4, 0, Math.PI * 2);\n ctx.fill();\n } else if (e.shape === \"line\") {\n ctx.fillRect(e.box.x, cy - 1, 10, 2);\n } else {\n ctx.fillRect(e.box.x + 1, cy - 4, 8, 8);\n }\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(e.name, e.box.x + 14, cy);\n if (e.hidden) {\n const w = e.box.width - 22;\n ctx.fillRect(e.box.x + 14, cy, w, 1);\n }\n }\n ctx.globalAlpha = 1;\n }\n\n // hover band of bars, below the data (lighter behind lifted bars)\n const lifted = scene.hover?.marks.some((m) => m.kind === \"bar\") ?? false;\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"band\") continue;\n roundedRect(ctx, mark.x, mark.y, mark.width, mark.height, 6);\n ctx.fillStyle = toCss(theme.text, lifted ? 0.04 : 0.06);\n ctx.fill();\n }\n // combo charts: the lifted bar goes below the data, so the lines (and\n // their markers) stay above it, without a veil\n const mixed = model.series.some(\n (s) => !s.hidden && (s.type === \"line\" || s.type === \"area\"),\n );\n if (lifted && mixed && scene.hover)\n drawLiftedMarks(ctx, scene.hover.marks, plot, theme);\n // the area a dragged point would land in, below the data\n const target = scene.dragging?.target;\n if (target) {\n ctx.save();\n ctx.fillStyle = withAlpha(target.color, 0.12);\n ctx.fillRect(target.x, target.y, target.width, target.height);\n ctx.strokeStyle = withAlpha(target.color, 0.7);\n ctx.lineWidth = 2;\n roundedRect(\n ctx,\n target.x + 1,\n target.y + 1,\n target.width - 2,\n target.height - 2,\n 4,\n );\n ctx.stroke();\n ctx.restore();\n }\n\n // data (horizontal charts: as shapes, the painter draws vertical charts)\n if (scales.horizontal) {\n drawPrimitives(ctx, scenePrimitives(scene), plot);\n } else {\n paintData();\n }\n function paintData() {\n const scale = (range: [number, number], o: number, reverse: boolean) => {\n const s = 2 / (range[1] - range[0]);\n const offset = (o - range[0]) * s - 1;\n return reverse ? [-s, -offset] : [s, offset];\n };\n const [xScale, xOffset] = scale(view.x, origin.x, model.x.reverse);\n const [yScale, yOffset] = scale(view.y, origin.y, model.y.reverse);\n painter.paint(\n items,\n {\n transform: { xScale, xOffset, yScale, yOffset },\n width: Math.max(1, Math.round(plot.width * dpr)),\n height: Math.max(1, Math.round(plot.height * dpr)),\n dpr,\n },\n Math.round(plot.x * dpr),\n Math.round(plot.y * dpr),\n );\n }\n\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n // soft row / column of a hovered heatmap cell, over the data\n for (const mark of scene.hover?.marks ?? []) {\n if (mark.kind !== \"guide\") continue;\n ctx.fillStyle = toCss(theme.text, 0.06);\n ctx.fillRect(mark.x, mark.y, mark.width, mark.height);\n }\n // lifted bars and cells, below the value labels; the plot behind lifted\n // bars is veiled so the hovered one stands out\n if (lifted && !mixed) {\n ctx.fillStyle = toCss(theme.background, 0.42);\n ctx.fillRect(plot.x, plot.y, plot.width, plot.height);\n }\n if (scene.hover && !(lifted && mixed))\n drawLiftedMarks(ctx, scene.hover.marks, plot, theme);\n drawForeground(ctx, {\n width,\n height,\n scales,\n theme,\n annotations: scene.annotations,\n pointLabels: [],\n clear: false,\n connectors: scene.connectors,\n arrows: scene.arrows,\n });\n // dot labels placed by the scene\n if (scene.pointLabels.length) {\n ctx.save();\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = toCss(theme.background, 0.9);\n ctx.fillStyle = toCss(theme.text, 0.85);\n for (const { label, box } of scene.pointLabels) {\n const y = box.y + box.height / 2;\n if (label.color) {\n // inside a solid bar: its contrasting color, no halo\n ctx.save();\n ctx.fillStyle = label.color;\n ctx.fillText(label.text, box.x, y);\n ctx.restore();\n continue;\n }\n ctx.strokeText(label.text, box.x, y);\n ctx.fillText(label.text, box.x, y);\n }\n ctx.restore();\n }\n\n // hover\n const hover = scene.hover;\n if (hover) {\n if (hover.crosshairX !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cx = Math.round(hover.crosshairX) + 0.5;\n ctx.moveTo(cx, plot.y);\n ctx.lineTo(cx, plot.y + plot.height);\n ctx.stroke();\n ctx.restore();\n }\n if (hover.crosshairY !== null) {\n ctx.save();\n ctx.strokeStyle = toCss(theme.textMuted, 0.55);\n ctx.lineWidth = 1;\n ctx.setLineDash([3, 3]);\n ctx.beginPath();\n const cy = Math.round(hover.crosshairY) + 0.5;\n ctx.moveTo(plot.x, cy);\n ctx.lineTo(plot.x + plot.width, cy);\n ctx.stroke();\n ctx.restore();\n }\n for (const mark of hover.marks) {\n if (\n mark.kind === \"band\" ||\n mark.kind === \"guide\" ||\n mark.kind === \"bar\" ||\n mark.kind === \"cell\"\n )\n continue;\n // a soft glow, the tinted halo, the dot ringed in the background color\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 8, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.globalAlpha = 0.45;\n ctx.fill();\n ctx.globalAlpha = 1;\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 + 4, 0, Math.PI * 2);\n ctx.fillStyle = mark.halo;\n ctx.fill();\n ctx.beginPath();\n ctx.arc(mark.x, mark.y, mark.size / 2 - 1, 0, Math.PI * 2);\n ctx.fillStyle = mark.color;\n ctx.fill();\n ctx.lineWidth = 2;\n ctx.strokeStyle = toCss(theme.background);\n ctx.stroke();\n }\n }\n if (scene.dragging) drawDragPreview(ctx, scene.dragging, plot, theme);\n const tip = hover?.tooltip;\n if (tip) {\n const { box, lineHeight, padding } = tip;\n const colors = tooltipColors(theme, CANVAS_TOOLTIP_ALPHA);\n ctx.save();\n ctx.shadowColor = \"rgba(15, 23, 42, 0.18)\";\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundedRect(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = colors.background;\n ctx.fill();\n ctx.restore();\n roundedRect(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = colors.border;\n ctx.lineWidth = 1;\n ctx.stroke();\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (tip.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of tip.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else {\n const { content } = tip;\n let x = left;\n if (content.titleColor) {\n ctx.fillStyle = content.titleColor;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n ctx.fillText(content.title, x, y);\n y += lineHeight;\n if (content.subtitle) {\n ctx.font = font(theme, 11);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(content.subtitle, x, y - 2);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n ctx.beginPath();\n ctx.arc(x + 4, y, 4, 0, Math.PI * 2);\n ctx.fill();\n }\n // names in one column, values right-aligned in another\n x += tip.swatchWidth;\n ctx.font = font(theme, 12);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n }\n};\n\n/**\n * Creates a chart drawn on a 2D canvas: line, area, bar and scatter series,\n * annotations, legend and tooltip, tap / drag / pinch gestures. Works\n * without a DOM (mini-programs); see `createChart` for the GPU version of\n * the web.\n */\nexport const createCanvasChart = (\n config: CanvasChartConfig,\n): CanvasChartInstance => {\n const { canvas } = config;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D | null;\n let width = config.width;\n let height = config.height;\n let dpr = config.pixelRatio ?? 1;\n let destroyed = false;\n let frameId: number | null = null;\n let items: RenderItem[] = [];\n let itemsModel: unknown = null;\n let itemsKey0 = \"\";\n let itemsKey = \"\";\n let options = config.options;\n /** Ids of the themes seen (the controller replaces its theme on changes) */\n const themeIds = new WeakMap<object, number>();\n let themeCount = 0;\n const themeId = (theme: object) => {\n let id = themeIds.get(theme);\n if (id === undefined) themeIds.set(theme, (id = ++themeCount));\n return id;\n };\n let origin: Origin = { x: 0, y: 0 };\n let version = 0;\n let fontSet = \"\";\n\n const measureText = (text: string, f: string) => {\n if (!ctx) return text.length * 6.5;\n if (f !== fontSet) {\n ctx.font = f;\n fontSet = f;\n }\n return ctx.measureText(text).width;\n };\n\n const painter = ctx ? createCanvas2dPainter(ctx) : null;\n\n const g = globalThis as {\n requestAnimationFrame?: (cb: () => void) => number;\n cancelAnimationFrame?: (id: number) => void;\n };\n\n const render = () => {\n frameId = null;\n if (destroyed || !ctx || !painter) return;\n const scene = controller.getScene();\n if (!scene) return;\n const pw = Math.max(1, Math.round(width * dpr));\n const ph = Math.max(1, Math.round(height * dpr));\n if (canvas.width !== pw) {\n backing.own();\n canvas.width = pw;\n }\n if (canvas.height !== ph) {\n backing.own();\n canvas.height = ph;\n }\n fontSet = \"\";\n if (itemsModel !== scene.model) {\n itemsModel = scene.model;\n // a new model (any setOptions) keeps the items when nothing they\n // depend on changed\n itemsKey0 = itemsSignature(\n scene.model,\n themeId(scene.theme),\n (index) => options.series[index]?.stack,\n );\n }\n // heatmap cells: their gaps and corners follow their size on screen\n const sc = scene.layout.scales;\n const density = { x: 1 / Math.abs(sc.xPerPx), y: 1 / Math.abs(sc.yPerPx) };\n const key = `${itemsKey0}|${cellStyleKey(scene.model, density)}`;\n if (key !== itemsKey) {\n itemsKey = key;\n origin = { x: mid(scene.model.base.x), y: mid(scene.model.base.y) };\n items = buildItems(scene.model, origin, ++version, density);\n }\n drawScene(ctx, scene, items, origin, dpr, painter);\n fontSet = \"\";\n };\n\n const schedule = () => {\n if (destroyed || frameId !== null) return;\n if (canvas.requestAnimationFrame)\n frameId = canvas.requestAnimationFrame(render);\n else if (g.requestAnimationFrame) frameId = g.requestAnimationFrame(render);\n else frameId = setTimeout(render, 16) as unknown as number;\n };\n\n const cancelFrame = () => {\n if (frameId === null) return;\n if (canvas.cancelAnimationFrame) canvas.cancelAnimationFrame(frameId);\n else if (g.cancelAnimationFrame) g.cancelAnimationFrame(frameId);\n else clearTimeout(frameId);\n frameId = null;\n };\n\n const renderNow = () => {\n cancelFrame();\n render();\n };\n\n // H5 hosts reset the canvas size (and clear it) on renders of their own:\n // draw again at once, at the device pixel ratio\n const backing = watchBackingStore(\n canvas,\n () =>\n canvas.width !== Math.max(1, Math.round(width * dpr)) ||\n canvas.height !== Math.max(1, Math.round(height * dpr)),\n renderNow,\n );\n\n const controller = createChartController({\n options: config.options,\n theme: config.theme,\n measureText,\n onInvalidate: schedule,\n });\n controller.setSize(width, height);\n\n const touchOptions = (t: ChartTouch, i: number): ChartPointerOptions => ({\n id: t.identifier ?? i,\n touch: true,\n });\n\n return {\n setOptions: (o) => {\n options = o;\n controller.setOptions(o);\n },\n setTheme: (t) => controller.setTheme(t),\n resize(w, h, ratio) {\n width = w;\n height = h;\n if (ratio) dpr = ratio;\n controller.setSize(w, h);\n schedule();\n },\n render: renderNow,\n touchStart(touches) {\n touches.forEach((t, i) =>\n controller.pointerDown(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchMove(touches) {\n touches.forEach((t, i) =>\n controller.pointerMove(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchEnd(touches) {\n touches.forEach((t, i) =>\n controller.pointerUp(t.x, t.y, touchOptions(t, i)),\n );\n },\n touchCancel(touches = [{ x: 0, y: 0 }]) {\n touches.forEach((t, i) => controller.pointerCancel(touchOptions(t, i)));\n },\n pointerDown: (x, y, o) => controller.pointerDown(x, y, o),\n pointerMove: (x, y, o) => controller.pointerMove(x, y, o),\n pointerUp: (x, y, o) => controller.pointerUp(x, y, o),\n pointerLeave: () => controller.pointerLeave(),\n zoomAt: (x, y, f) => controller.zoomAt(x, y, f),\n resetZoom: () => controller.resetZoom(),\n getView: () => controller.getView(),\n setView: (v) => controller.setView(v),\n toggleSeries: (id) => controller.toggleSeries(id),\n clearHover: () => controller.clearHover(),\n getPlotRect: () => controller.getPlotRect(),\n toPixel: (x, y) => controller.toPixel(x, y),\n fromPixel: (x, y) => controller.fromPixel(x, y),\n getController: () => controller,\n on: (type, listener) => controller.on(type, listener),\n destroy() {\n if (destroyed) return;\n destroyed = true;\n cancelFrame();\n backing.disconnect();\n painter?.destroy();\n controller.destroy();\n },\n };\n};\n"],"mappings":";;;;;;;;;;AAoGA,IAAMA,KAAO,OAAyBC,EAAE,KAAKA,EAAE,MAAM,GAE/CC,KACJ,GACA,GACA,GACA,GACA,GACA,MACG;CAWH,AAVAC,EAAI,UAAU,GACdA,EAAI,OAAOC,IAAIH,GAAGI,CAAC,GACnBF,EAAI,OAAOC,IAAIE,IAAIL,GAAGI,CAAC,GACvBF,EAAI,MAAMC,IAAIE,GAAGD,GAAGD,IAAIE,GAAGD,IAAIJ,GAAGA,CAAC,GACnCE,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