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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# minerva-design
|
|
2
2
|
|
|
3
|
+
## 1.17.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a411866: Sharper and tidier quadrant boards and charts on mini programs, and quadrant point labels that stay in their quadrant.
|
|
8
|
+
|
|
9
|
+
- **QuadrantTaskBoard** (Taro, uni-app, WeChat): the quadrant headers are compact single-line pills in a 2 x 2 grid, like the web board: the badge and the task count are small chips, a long quadrant title is cut with an ellipsis instead of wrapping, and the + button sits at the end. The headers are styled by the shared stylesheet (no inline layout) and can be themed with `--quadrant-task-board-header-background`, `--quadrant-task-board-header-color`, `--quadrant-task-board-count-background` and `--quadrant-task-board-count-color`.
|
|
10
|
+
- **Charts on Taro H5** were blurry on high-density screens: the canvas was drawn at 1x because Taro's H5 runtime has no pixel ratio API on its default export. Charts now use the page's `devicePixelRatio` there. Canvas charts (Taro and uni-app H5 included) also draw again right away when the host component resets the size of the canvas behind them, instead of staying blank or blurry until the next update.
|
|
11
|
+
- **Taro Input**: small and large inputs no longer pad their text twice, so their text lines up like in medium inputs. This also fixes the name field of the QuadrantTaskBoard panel.
|
|
12
|
+
- **Quadrant charts** (every renderer): a point label stays inside the quadrant of its dot. It goes on the side of the dot with more room in the quadrant, and is cut with "…" when it still does not fit (a label that would keep only a few letters is left out; the tooltip still names the point), so it no longer crosses the center dividers or runs into the dots of the next quadrant. Overlapping labels are still skipped. The behavior comes from a new scatter series option, `labelCells: { x, y }`, which keeps labels inside the cells of a plot cut at those values.
|
|
13
|
+
|
|
14
|
+
## 1.17.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 601ff03: Taro: the parts of a component no longer carry the class of its root. `CardHeader`, `CardTitle`, `CardDescription`, `CardContent` and `CardFooter` (and the parts of the other Taro components) used to get `mn-card` too, so each drew its own card border, background and shadow inside the card; they now only have their `mn-<name>__<part>` class. `CardDescription` no longer adds side padding inside `CardHeader`.
|
|
19
|
+
|
|
3
20
|
## 1.17.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,n){let r=globalThis.MutationObserver;if(typeof r!=`function`||typeof e?.nodeType!=`number`)return{own(){},disconnect(){}};let i=0,a=new r(e=>{let r=e.length>i;i=0,(r||t())&&n()});return a.observe(e,{attributes:!0,attributeFilter:[`width`,`height`]}),{own(e=1){i+=e},disconnect(){a.disconnect(),i=0}}}exports.watchBackingStore=e;
|
|
2
|
+
//# sourceMappingURL=backing-store.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backing-store.cjs","names":["watchBackingStore","Observer","canvas","pending","observer","foreign","records","stale","redraw","count"],"sources":["../../../../charts/src/engine/backing-store.ts"],"sourcesContent":["// A canvas host can resize or clear the backing store of the canvas behind\n// the chart's back: Taro H5's <taro-canvas-core> writes its cached CSS size\n// to the width / height of its inner <canvas> on every render of its own,\n// and uni-app H5's <canvas> resizes it to the CSS size (x1). Both clear the\n// pixels and drop the device pixel ratio, so the chart turns blank or blurry\n// until its next frame. On a DOM canvas the writes reflect into the `width`\n// and `height` attributes: watch them and draw again.\n\ntype Watched = { nodeType?: unknown };\n\n/** The part of the DOM MutationObserver used (no DOM types: React Native) */\ntype AttributeObserver = {\n observe(\n target: unknown,\n options: { attributes: boolean; attributeFilter: string[] },\n ): void;\n disconnect(): void;\n};\ntype AttributeObserverClass = new (\n callback: (records: readonly unknown[]) => void,\n) => AttributeObserver;\n\n/**\n * Calls `redraw` when something other than the chart wrote the `width` /\n * `height` of a DOM canvas (or left them at another size than `stale` expects).\n * The chart reports its own writes with the returned `own(count)`, so they do\n * not trigger a redraw. No-op (and free) on mini-program canvases and\n * OffscreenCanvas, which are not DOM nodes.\n */\nexport function watchBackingStore(\n canvas: unknown,\n stale: () => boolean,\n redraw: () => void,\n): { own(count?: number): void; disconnect(): void } {\n const Observer = (globalThis as { MutationObserver?: AttributeObserverClass })\n .MutationObserver;\n if (\n typeof Observer !== \"function\" ||\n typeof (canvas as Watched | null)?.nodeType !== \"number\"\n )\n return { own() {}, disconnect() {} };\n // writes of the chart itself not delivered to the observer yet\n let pending = 0;\n const observer = new Observer((records) => {\n const foreign = records.length > pending;\n pending = 0;\n if (foreign || stale()) redraw();\n });\n observer.observe(canvas, {\n attributes: true,\n attributeFilter: [\"width\", \"height\"],\n });\n return {\n own(count = 1) {\n pending += count;\n },\n disconnect() {\n observer.disconnect();\n pending = 0;\n },\n };\n}\n"],"mappings":"AA6BA,SAAgBA,EACd,EACA,EACA,EACmD,CACnD,IAAMC,EAAY,WACf,iBACH,GACE,OAAOA,GAAa,YACpB,OAAQC,GAA2B,UAAa,SAEhD,MAAO,CAAE,KAAM,CAAC,EAAG,YAAa,CAAC,CAAE,EAErC,IAAIC,EAAU,EACRC,EAAW,IAAIH,EAAU,GAAY,CACzC,IAAMI,EAAUC,EAAQ,OAASH,EACjC,EAAU,GACNE,GAAWE,EAAM,IAAGC,EAAO,CACjC,CAAC,EAKD,OAJAJ,EAAS,QAAQF,EAAQ,CACvB,WAAY,GACZ,gBAAiB,CAAC,QAAS,QAAQ,CACrC,CAAC,EACM,CACL,IAAI,EAAQ,EAAG,CACb,GAAWO,CACb,EACA,YAAa,CACXL,EAAS,WAAW,EACpB,EAAU,CACZ,CACF,CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `redraw` when something other than the chart wrote the `width` /
|
|
3
|
+
* `height` of a DOM canvas (or left them at another size than `stale` expects).
|
|
4
|
+
* The chart reports its own writes with the returned `own(count)`, so they do
|
|
5
|
+
* not trigger a redraw. No-op (and free) on mini-program canvases and
|
|
6
|
+
* OffscreenCanvas, which are not DOM nodes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function watchBackingStore(canvas: unknown, stale: () => boolean, redraw: () => void): {
|
|
9
|
+
own(count?: number): void;
|
|
10
|
+
disconnect(): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `redraw` when something other than the chart wrote the `width` /
|
|
3
|
+
* `height` of a DOM canvas (or left them at another size than `stale` expects).
|
|
4
|
+
* The chart reports its own writes with the returned `own(count)`, so they do
|
|
5
|
+
* not trigger a redraw. No-op (and free) on mini-program canvases and
|
|
6
|
+
* OffscreenCanvas, which are not DOM nodes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function watchBackingStore(canvas: unknown, stale: () => boolean, redraw: () => void): {
|
|
9
|
+
own(count?: number): void;
|
|
10
|
+
disconnect(): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/engine/backing-store.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = globalThis.MutationObserver;
|
|
4
|
+
if (typeof r != "function" || typeof e?.nodeType != "number") return {
|
|
5
|
+
own() {},
|
|
6
|
+
disconnect() {}
|
|
7
|
+
};
|
|
8
|
+
let i = 0, a = new r((e) => {
|
|
9
|
+
let r = e.length > i;
|
|
10
|
+
i = 0, (r || t()) && n();
|
|
11
|
+
});
|
|
12
|
+
return a.observe(e, {
|
|
13
|
+
attributes: !0,
|
|
14
|
+
attributeFilter: ["width", "height"]
|
|
15
|
+
}), {
|
|
16
|
+
own(e = 1) {
|
|
17
|
+
i += e;
|
|
18
|
+
},
|
|
19
|
+
disconnect() {
|
|
20
|
+
a.disconnect(), i = 0;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as watchBackingStore };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=backing-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backing-store.js","names":["watchBackingStore","Observer","canvas","pending","observer","foreign","records","stale","redraw","count"],"sources":["../../../../charts/src/engine/backing-store.ts"],"sourcesContent":["// A canvas host can resize or clear the backing store of the canvas behind\n// the chart's back: Taro H5's <taro-canvas-core> writes its cached CSS size\n// to the width / height of its inner <canvas> on every render of its own,\n// and uni-app H5's <canvas> resizes it to the CSS size (x1). Both clear the\n// pixels and drop the device pixel ratio, so the chart turns blank or blurry\n// until its next frame. On a DOM canvas the writes reflect into the `width`\n// and `height` attributes: watch them and draw again.\n\ntype Watched = { nodeType?: unknown };\n\n/** The part of the DOM MutationObserver used (no DOM types: React Native) */\ntype AttributeObserver = {\n observe(\n target: unknown,\n options: { attributes: boolean; attributeFilter: string[] },\n ): void;\n disconnect(): void;\n};\ntype AttributeObserverClass = new (\n callback: (records: readonly unknown[]) => void,\n) => AttributeObserver;\n\n/**\n * Calls `redraw` when something other than the chart wrote the `width` /\n * `height` of a DOM canvas (or left them at another size than `stale` expects).\n * The chart reports its own writes with the returned `own(count)`, so they do\n * not trigger a redraw. No-op (and free) on mini-program canvases and\n * OffscreenCanvas, which are not DOM nodes.\n */\nexport function watchBackingStore(\n canvas: unknown,\n stale: () => boolean,\n redraw: () => void,\n): { own(count?: number): void; disconnect(): void } {\n const Observer = (globalThis as { MutationObserver?: AttributeObserverClass })\n .MutationObserver;\n if (\n typeof Observer !== \"function\" ||\n typeof (canvas as Watched | null)?.nodeType !== \"number\"\n )\n return { own() {}, disconnect() {} };\n // writes of the chart itself not delivered to the observer yet\n let pending = 0;\n const observer = new Observer((records) => {\n const foreign = records.length > pending;\n pending = 0;\n if (foreign || stale()) redraw();\n });\n observer.observe(canvas, {\n attributes: true,\n attributeFilter: [\"width\", \"height\"],\n });\n return {\n own(count = 1) {\n pending += count;\n },\n disconnect() {\n observer.disconnect();\n pending = 0;\n },\n };\n}\n"],"mappings":";AA6BA,SAAgBA,EACd,GACA,GACA,GACmD;CACnD,IAAMC,IAAY,WACf;CACH,IACE,OAAOA,KAAa,cACpB,OAAQC,GAA2B,YAAa,UAEhD,OAAO;EAAE,MAAM,CAAC;EAAG,aAAa,CAAC;CAAE;CAErC,IAAIC,IAAU,GACRC,IAAW,IAAIH,GAAU,MAAY;EACzC,IAAMI,IAAUC,EAAQ,SAASH;EAEjC,AADA,IAAU,IACNE,KAAWE,EAAM,MAAGC,EAAO;CACjC,CAAC;CAKD,OAJAJ,EAAS,QAAQF,GAAQ;EACvB,YAAY;EACZ,iBAAiB,CAAC,SAAS,QAAQ;CACrC,CAAC,GACM;EACL,IAAI,IAAQ,GAAG;GACb,KAAWO;EACb;EACA,aAAa;GAEX,AADAL,EAAS,WAAW,GACpB,IAAU;EACZ;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./color.cjs"),t=require("./tooltip.cjs"),n=require("./overlay.cjs"),r=require("./scene.cjs"),i=require("./items.cjs"),a=require("./renderers/canvas2d.cjs"),o=require("./signature.cjs"),s=require("./controller.cjs");var c=e=>(e[0]+e[1])/2,l=(e,t,n,r,i,a)=>{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()},u=(e,t,n)=>{e.save(),e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip(),e.lineJoin=`round`,e.lineCap=`round`;for(let n of t)if(n.kind===`area`)e.globalAlpha=n.opacity,e.fillStyle=n.color,n.segments.forEach((t,r)=>{let i=n.bottoms?.[r],a=t.length/2;if(!(a<2)){e.beginPath();for(let n=0;n<a;n++)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n*2],t[n*2+1]);for(let r=a-1;r>=0;r--){let a=i?i[r]:n.baseline;n.horizontal?e.lineTo(a,t[r*2+1]):e.lineTo(t[r*2],a)}e.closePath(),e.fill()}}),e.globalAlpha=1;else if(n.kind===`line`){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath();for(let t of n.segments)for(let n=0;n<t.length;n+=2)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n],t[n+1]);e.stroke()}else if(n.kind===`bars`){e.globalAlpha=n.opacity??1;let t=n.radius??0;for(let r=0;r<n.rects.length;r+=4){let[i,a,o,s]=[n.rects[r],n.rects[r+1],n.rects[r+2],n.rects[r+3]];e.fillStyle=n.colors?.[r/4]??n.color;let c=Math.min(t,o/2,s/2);c>.5?(l(e,i,a,o,s,c),e.fill()):e.fillRect(i,a,o,s)}e.globalAlpha=1}else{let t=n.stroke??0;for(let r=0;r<n.dots.length;r+=3){let i=n.colors[r/3]??`#888`,a=n.dots[r+2]/2;e.beginPath(),e.arc(n.dots[r],n.dots[r+1],Math.max(0,a-t/2),0,Math.PI*2),n.opacity>0&&(e.globalAlpha=n.opacity,e.fillStyle=i,e.fill()),t>0&&(e.globalAlpha=1,e.lineWidth=t,e.strokeStyle=i,e.stroke())}e.globalAlpha=1}e.restore()},d=(t,r,i)=>{let{theme:a}=i,{bar:o,stops:s}=r,c=s.length;if(typeof t.createLinearGradient==`function`){let e=t.createLinearGradient(o.x,0,o.x+o.width,0);s.forEach((t,n)=>e.addColorStop(n/Math.max(1,c-1),t)),t.fillStyle=e,l(t,o.x,o.y,o.width,o.height,o.height/2),t.fill()}else{let e=o.width/c;s.forEach((n,r)=>{t.fillStyle=n,t.fillRect(o.x+r*e,o.y,e+.5,o.height)})}t.fillStyle=e.toCss(a.text,.35);for(let e of r.ticks)t.fillRect(Math.round(e),o.y-2,1,o.height+4);t.font=n.font(a,11),t.textBaseline=`middle`,t.fillStyle=e.toCss(a.textMuted);for(let e of r.labels)t.textAlign=e.align,t.fillText(e.text,e.x,e.y);r.caret!==null&&(l(t,r.caret-2,o.y-3,4,o.height+6,2),t.fillStyle=e.toCss(a.text),t.fill(),t.lineWidth=1.5,t.strokeStyle=e.toCss(a.background),t.stroke())},f=1.16,p=(e,t,n,r)=>{let i=Math.max(0,t.width+r*2),a=Math.max(0,t.height+r*2);l(e,t.x-r,t.y-r,i,a,Math.max(0,Math.min(n+r,i/2,a/2)))},m=(t,n,r,i,a,o,s,c,l)=>{let u=e.toCss(l.background);o?(t.save(),t.shadowColor=`rgba(15, 23, 42, 0.4)`,t.shadowBlur=14,t.shadowOffsetY=5,p(t,n,r,s+(c?.width??0)),t.fillStyle=c?c.color:u,t.fill(),t.restore(),c&&(p(t,n,r,s),t.fillStyle=u,t.fill())):a&&(p(t,n,r,0),t.fillStyle=u,t.fill()),p(t,n,r,0),t.fillStyle=i,t.fill(),o&&o.width>0&&(p(t,n,r,-o.width/2),t.lineWidth=o.width,t.strokeStyle=o.color,t.stroke())},h=(t,n,i,a)=>{for(let o of n)if(o.kind===`bar`){let e=r.liftedBarRect(o);t.save(),t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.clip();let n=o.ring===null?null:{color:o.ring,width:Math.min(o.backdrop?2:1.5,Math.max(0,(Math.min(e.width,e.height)-2)/4))};m(t,e,o.radius,o.color,o.backdrop,n,1.5,null,a),t.restore()}else if(o.kind===`cell`){let n=o.width*f,r=o.height*f;m(t,{x:o.x+(o.width-n)/2,y:o.y+(o.height-r)/2,width:n,height:r},Math.max(2,o.radius)*f,o.color,!1,{color:o.ring,width:Math.min(2,Math.min(n,r)/5)},2,{color:e.toCss(a.primary,.6),width:1.5},a)}},g=(t,n)=>{let r=e.parseColor(t);return r?e.toCss(r,r[3]*n):t},_=(t,r,i,a)=>{if(t.save(),r.origin){let n=(r.size-2)/2;t.beginPath(),t.arc(r.origin.x,r.origin.y,n,0,Math.PI*2),t.fillStyle=e.toCss(a.background,.62),t.fill(),t.setLineDash([3,3]),t.lineWidth=1.5,t.strokeStyle=r.color,t.stroke(),t.setLineDash([])}if(t.beginPath(),t.arc(r.x,r.y+3,r.size/2+2,0,Math.PI*2),t.fillStyle=`rgba(15, 23, 42, 0.18)`,t.shadowColor=`rgba(15, 23, 42, 0.35)`,t.shadowBlur=10,t.fill(),t.shadowColor=`transparent`,t.shadowBlur=0,t.beginPath(),t.arc(r.x,r.y,r.size/2+5,0,Math.PI*2),t.fillStyle=g(r.color,.24),t.fill(),t.beginPath(),t.arc(r.x,r.y,r.size/2-1,0,Math.PI*2),t.fillStyle=r.color,t.fill(),t.lineWidth=2,t.strokeStyle=e.toCss(a.background),t.stroke(),r.label){t.font=n.font(a,12,600);let o=t.measureText(r.label).width+18,s=r.size/2+8,c=r.x+s+o<=i.x+i.width||r.x-s-o<i.x?r.x+s:r.x-s-o,u=r.y-11;t.shadowColor=`rgba(15, 23, 42, 0.2)`,t.shadowBlur=10,t.shadowOffsetY=3,l(t,c,u,o,22,11),t.fillStyle=e.toCss(a.background),t.fill(),t.shadowColor=`transparent`,t.shadowBlur=0,t.shadowOffsetY=0,t.lineWidth=1,t.strokeStyle=e.toCss(a.axis,.7),t.stroke(),t.fillStyle=e.toCss(a.text),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(r.label,c+9,r.y)}t.restore()},v=(r,i,o,c,f,p=a.createCanvas2dPainter(r))=>{let{width:m,height:v,theme:y,model:b,view:x,layout:S}=i,{plot:C,scales:w}=S,T=f;r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,Math.ceil(m*T),Math.ceil(v*T)),r.setTransform(T,0,0,T,0,0),n.drawBackground(r,{width:m,height:v,scales:w,x:b.x,y:b.y,xTicks:S.xTicks,yTicks:S.yTicks,y2:b.y2,y2Ticks:S.y2Ticks,theme:y,annotations:i.annotations});let E=i.legend?.colors;if(E&&d(r,E,i),i.legend){r.font=n.font(y,12),r.textBaseline=`middle`,r.textAlign=`left`;for(let t of i.legend.entries){let n=t.box.y+t.box.height/2;if(r.globalAlpha=t.hidden?.45:1,r.fillStyle=t.color,t.shape===`dot`?(r.beginPath(),r.arc(t.box.x+5,n,4,0,Math.PI*2),r.fill()):t.shape===`line`?r.fillRect(t.box.x,n-1,10,2):r.fillRect(t.box.x+1,n-4,8,8),r.fillStyle=e.toCss(y.textMuted),r.fillText(t.name,t.box.x+14,n),t.hidden){let e=t.box.width-22;r.fillRect(t.box.x+14,n,e,1)}}r.globalAlpha=1}let D=i.hover?.marks.some(e=>e.kind===`bar`)??!1;for(let t of i.hover?.marks??[])t.kind===`band`&&(l(r,t.x,t.y,t.width,t.height,6),r.fillStyle=e.toCss(y.text,D?.04:.06),r.fill());let O=b.series.some(e=>!e.hidden&&(e.type===`line`||e.type===`area`));D&&O&&i.hover&&h(r,i.hover.marks,C,y);let k=i.dragging?.target;k&&(r.save(),r.fillStyle=g(k.color,.12),r.fillRect(k.x,k.y,k.width,k.height),r.strokeStyle=g(k.color,.7),r.lineWidth=2,l(r,k.x+1,k.y+1,k.width-2,k.height-2,4),r.stroke(),r.restore()),w.horizontal?u(r,s.scenePrimitives(i),C):A();function A(){let e=(e,t,n)=>{let r=2/(e[1]-e[0]),i=(t-e[0])*r-1;return n?[-r,-i]:[r,i]},[t,n]=e(x.x,c.x,b.x.reverse),[r,i]=e(x.y,c.y,b.y.reverse);p.paint(o,{transform:{xScale:t,xOffset:n,yScale:r,yOffset:i},width:Math.max(1,Math.round(C.width*T)),height:Math.max(1,Math.round(C.height*T)),dpr:T},Math.round(C.x*T),Math.round(C.y*T))}r.setTransform(T,0,0,T,0,0);for(let t of i.hover?.marks??[])t.kind===`guide`&&(r.fillStyle=e.toCss(y.text,.06),r.fillRect(t.x,t.y,t.width,t.height));if(D&&!O&&(r.fillStyle=e.toCss(y.background,.42),r.fillRect(C.x,C.y,C.width,C.height)),i.hover&&!(D&&O)&&h(r,i.hover.marks,C,y),n.drawForeground(r,{width:m,height:v,scales:w,theme:y,annotations:i.annotations,pointLabels:[],clear:!1,connectors:i.connectors,arrows:i.arrows}),i.pointLabels.length){r.save(),r.font=n.font(y),r.textAlign=`left`,r.textBaseline=`middle`,r.lineWidth=3,r.lineJoin=`round`,r.strokeStyle=e.toCss(y.background,.9),r.fillStyle=e.toCss(y.text,.85);for(let{label:e,box:t}of i.pointLabels){let n=t.y+t.height/2;if(e.color){r.save(),r.fillStyle=e.color,r.fillText(e.text,t.x,n),r.restore();continue}r.strokeText(e.text,t.x,n),r.fillText(e.text,t.x,n)}r.restore()}let j=i.hover;if(j){if(j.crosshairX!==null){r.save(),r.strokeStyle=e.toCss(y.textMuted,.55),r.lineWidth=1,r.setLineDash([3,3]),r.beginPath();let t=Math.round(j.crosshairX)+.5;r.moveTo(t,C.y),r.lineTo(t,C.y+C.height),r.stroke(),r.restore()}if(j.crosshairY!==null){r.save(),r.strokeStyle=e.toCss(y.textMuted,.55),r.lineWidth=1,r.setLineDash([3,3]),r.beginPath();let t=Math.round(j.crosshairY)+.5;r.moveTo(C.x,t),r.lineTo(C.x+C.width,t),r.stroke(),r.restore()}for(let t of j.marks)t.kind!==`band`&&t.kind!==`guide`&&t.kind!==`bar`&&t.kind!==`cell`&&(r.beginPath(),r.arc(t.x,t.y,t.size/2+8,0,Math.PI*2),r.fillStyle=t.halo,r.globalAlpha=.45,r.fill(),r.globalAlpha=1,r.beginPath(),r.arc(t.x,t.y,t.size/2+4,0,Math.PI*2),r.fillStyle=t.halo,r.fill(),r.beginPath(),r.arc(t.x,t.y,t.size/2-1,0,Math.PI*2),r.fillStyle=t.color,r.fill(),r.lineWidth=2,r.strokeStyle=e.toCss(y.background),r.stroke())}i.dragging&&_(r,i.dragging,C,y);let M=j?.tooltip;if(M){let{box:i,lineHeight:a,padding:o}=M,s=t.tooltipColors(y,t.CANVAS_TOOLTIP_ALPHA);r.save(),r.shadowColor=`rgba(15, 23, 42, 0.18)`,r.shadowBlur=16,r.shadowOffsetY=6,l(r,i.x,i.y,i.width,i.height,8),r.fillStyle=s.background,r.fill(),r.restore(),l(r,i.x+.5,i.y+.5,i.width-1,i.height-1,8),r.strokeStyle=s.border,r.lineWidth=1,r.stroke(),r.textBaseline=`middle`;let c=i.y+o+a/2,u=i.x+o+2,d=i.x+i.width-o-2;if(M.text){r.font=n.font(y,12),r.fillStyle=e.toCss(y.text),r.textAlign=`left`;for(let e of M.text)r.fillText(e,u,c),c+=a}else{let{content:t}=M,i=u;t.titleColor&&(r.fillStyle=t.titleColor,r.beginPath(),r.arc(i+4,c,4,0,Math.PI*2),r.fill(),i+=14),r.font=n.font(y,12,600),r.fillStyle=e.toCss(y.text),r.textAlign=`left`,r.fillText(t.title,i,c),c+=a,t.subtitle&&(r.font=n.font(y,11),r.fillStyle=e.toCss(y.textMuted),r.fillText(t.subtitle,i,c-2),c+=a);for(let o of t.rows)i=u,o.color&&(r.fillStyle=o.color,r.beginPath(),r.arc(i+4,c,4,0,Math.PI*2),r.fill()),i+=M.swatchWidth,r.font=n.font(y,12),r.textAlign=`left`,r.fillStyle=e.toCss(y.textMuted),r.fillText(o.name,i,c),r.font=n.font(y,12,600),r.textAlign=`right`,r.fillStyle=e.toCss(y.text),r.fillText(o.value,d,c),c+=a}}},y=e=>{let{canvas:t}=e,n=t.getContext(`2d`),r=e.width,l=e.height,u=e.pixelRatio??1,d=!1,f=null,p=[],m=null,h=``,g=``,_=e.options,y=new WeakMap,b=0,x=e=>{let t=y.get(e);return t===void 0&&y.set(e,t=++b),t},S={x:0,y:0},C=0,w=``,T=(e,t)=>n?(t!==w&&(n.font=t,w=t),n.measureText(e).width):e.length*6.5,E=n?a.createCanvas2dPainter(n):null,D=globalThis,O=()=>{if(f=null,d||!n||!E)return;let e=A.getScene();if(!e)return;let a=Math.max(1,Math.round(r*u)),s=Math.max(1,Math.round(l*u));t.width!==a&&(t.width=a),t.height!==s&&(t.height=s),w=``,m!==e.model&&(m=e.model,h=o.itemsSignature(e.model,x(e.theme),e=>_.series[e]?.stack));let y=e.layout.scales,b={x:1/Math.abs(y.xPerPx),y:1/Math.abs(y.yPerPx)},T=`${h}|${i.cellStyleKey(e.model,b)}`;T!==g&&(g=T,S={x:c(e.model.base.x),y:c(e.model.base.y)},p=i.buildItems(e.model,S,++C,b)),v(n,e,p,S,u,E),w=``},k=()=>{d||f!==null||(f=t.requestAnimationFrame?t.requestAnimationFrame(O):D.requestAnimationFrame?D.requestAnimationFrame(O):setTimeout(O,16))},A=s.createChartController({options:e.options,theme:e.theme,measureText:T,onInvalidate:k});A.setSize(r,l);let j=(e,t)=>({id:e.identifier??t,touch:!0});return{setOptions:e=>{_=e,A.setOptions(e)},setTheme:e=>A.setTheme(e),resize(e,t,n){r=e,l=t,n&&(u=n),A.setSize(e,t),k()},render(){f!==null&&(t.cancelAnimationFrame?t.cancelAnimationFrame(f):D.cancelAnimationFrame?D.cancelAnimationFrame(f):clearTimeout(f)),O()},touchStart(e){e.forEach((e,t)=>A.pointerDown(e.x,e.y,j(e,t)))},touchMove(e){e.forEach((e,t)=>A.pointerMove(e.x,e.y,j(e,t)))},touchEnd(e){e.forEach((e,t)=>A.pointerUp(e.x,e.y,j(e,t)))},touchCancel(e=[{x:0,y:0}]){e.forEach((e,t)=>A.pointerCancel(j(e,t)))},pointerDown:(e,t,n)=>A.pointerDown(e,t,n),pointerMove:(e,t,n)=>A.pointerMove(e,t,n),pointerUp:(e,t,n)=>A.pointerUp(e,t,n),pointerLeave:()=>A.pointerLeave(),zoomAt:(e,t,n)=>A.zoomAt(e,t,n),resetZoom:()=>A.resetZoom(),getView:()=>A.getView(),setView:e=>A.setView(e),toggleSeries:e=>A.toggleSeries(e),clearHover:()=>A.clearHover(),getPlotRect:()=>A.getPlotRect(),toPixel:(e,t)=>A.toPixel(e,t),fromPixel:(e,t)=>A.fromPixel(e,t),getController:()=>A,on:(e,t)=>A.on(e,t),destroy(){d||(d=!0,f!==null&&(t.cancelAnimationFrame?t.cancelAnimationFrame(f):D.cancelAnimationFrame?D.cancelAnimationFrame(f):clearTimeout(f)),E?.destroy(),A.destroy())}}};exports.createCanvasChart=y,exports.drawDragPreview=_,exports.drawPrimitives=u,exports.drawScene=v;
|
|
1
|
+
const e=require("./color.cjs"),t=require("./tooltip.cjs"),n=require("./overlay.cjs"),r=require("./scene.cjs"),i=require("./items.cjs"),a=require("./renderers/canvas2d.cjs"),o=require("./signature.cjs"),s=require("./backing-store.cjs"),c=require("./controller.cjs");var l=e=>(e[0]+e[1])/2,u=(e,t,n,r,i,a)=>{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()},d=(e,t,n)=>{e.save(),e.beginPath(),e.rect(n.x,n.y,n.width,n.height),e.clip(),e.lineJoin=`round`,e.lineCap=`round`;for(let n of t)if(n.kind===`area`)e.globalAlpha=n.opacity,e.fillStyle=n.color,n.segments.forEach((t,r)=>{let i=n.bottoms?.[r],a=t.length/2;if(!(a<2)){e.beginPath();for(let n=0;n<a;n++)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n*2],t[n*2+1]);for(let r=a-1;r>=0;r--){let a=i?i[r]:n.baseline;n.horizontal?e.lineTo(a,t[r*2+1]):e.lineTo(t[r*2],a)}e.closePath(),e.fill()}}),e.globalAlpha=1;else if(n.kind===`line`){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath();for(let t of n.segments)for(let n=0;n<t.length;n+=2)n===0?e.moveTo(t[0],t[1]):e.lineTo(t[n],t[n+1]);e.stroke()}else if(n.kind===`bars`){e.globalAlpha=n.opacity??1;let t=n.radius??0;for(let r=0;r<n.rects.length;r+=4){let[i,a,o,s]=[n.rects[r],n.rects[r+1],n.rects[r+2],n.rects[r+3]];e.fillStyle=n.colors?.[r/4]??n.color;let c=Math.min(t,o/2,s/2);c>.5?(u(e,i,a,o,s,c),e.fill()):e.fillRect(i,a,o,s)}e.globalAlpha=1}else{let t=n.stroke??0;for(let r=0;r<n.dots.length;r+=3){let i=n.colors[r/3]??`#888`,a=n.dots[r+2]/2;e.beginPath(),e.arc(n.dots[r],n.dots[r+1],Math.max(0,a-t/2),0,Math.PI*2),n.opacity>0&&(e.globalAlpha=n.opacity,e.fillStyle=i,e.fill()),t>0&&(e.globalAlpha=1,e.lineWidth=t,e.strokeStyle=i,e.stroke())}e.globalAlpha=1}e.restore()},f=(t,r,i)=>{let{theme:a}=i,{bar:o,stops:s}=r,c=s.length;if(typeof t.createLinearGradient==`function`){let e=t.createLinearGradient(o.x,0,o.x+o.width,0);s.forEach((t,n)=>e.addColorStop(n/Math.max(1,c-1),t)),t.fillStyle=e,u(t,o.x,o.y,o.width,o.height,o.height/2),t.fill()}else{let e=o.width/c;s.forEach((n,r)=>{t.fillStyle=n,t.fillRect(o.x+r*e,o.y,e+.5,o.height)})}t.fillStyle=e.toCss(a.text,.35);for(let e of r.ticks)t.fillRect(Math.round(e),o.y-2,1,o.height+4);t.font=n.font(a,11),t.textBaseline=`middle`,t.fillStyle=e.toCss(a.textMuted);for(let e of r.labels)t.textAlign=e.align,t.fillText(e.text,e.x,e.y);r.caret!==null&&(u(t,r.caret-2,o.y-3,4,o.height+6,2),t.fillStyle=e.toCss(a.text),t.fill(),t.lineWidth=1.5,t.strokeStyle=e.toCss(a.background),t.stroke())},p=1.16,m=(e,t,n,r)=>{let i=Math.max(0,t.width+r*2),a=Math.max(0,t.height+r*2);u(e,t.x-r,t.y-r,i,a,Math.max(0,Math.min(n+r,i/2,a/2)))},h=(t,n,r,i,a,o,s,c,l)=>{let u=e.toCss(l.background);o?(t.save(),t.shadowColor=`rgba(15, 23, 42, 0.4)`,t.shadowBlur=14,t.shadowOffsetY=5,m(t,n,r,s+(c?.width??0)),t.fillStyle=c?c.color:u,t.fill(),t.restore(),c&&(m(t,n,r,s),t.fillStyle=u,t.fill())):a&&(m(t,n,r,0),t.fillStyle=u,t.fill()),m(t,n,r,0),t.fillStyle=i,t.fill(),o&&o.width>0&&(m(t,n,r,-o.width/2),t.lineWidth=o.width,t.strokeStyle=o.color,t.stroke())},g=(t,n,i,a)=>{for(let o of n)if(o.kind===`bar`){let e=r.liftedBarRect(o);t.save(),t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.clip();let n=o.ring===null?null:{color:o.ring,width:Math.min(o.backdrop?2:1.5,Math.max(0,(Math.min(e.width,e.height)-2)/4))};h(t,e,o.radius,o.color,o.backdrop,n,1.5,null,a),t.restore()}else if(o.kind===`cell`){let n=o.width*p,r=o.height*p;h(t,{x:o.x+(o.width-n)/2,y:o.y+(o.height-r)/2,width:n,height:r},Math.max(2,o.radius)*p,o.color,!1,{color:o.ring,width:Math.min(2,Math.min(n,r)/5)},2,{color:e.toCss(a.primary,.6),width:1.5},a)}},_=(t,n)=>{let r=e.parseColor(t);return r?e.toCss(r,r[3]*n):t},v=(t,r,i,a)=>{if(t.save(),r.origin){let n=(r.size-2)/2;t.beginPath(),t.arc(r.origin.x,r.origin.y,n,0,Math.PI*2),t.fillStyle=e.toCss(a.background,.62),t.fill(),t.setLineDash([3,3]),t.lineWidth=1.5,t.strokeStyle=r.color,t.stroke(),t.setLineDash([])}if(t.beginPath(),t.arc(r.x,r.y+3,r.size/2+2,0,Math.PI*2),t.fillStyle=`rgba(15, 23, 42, 0.18)`,t.shadowColor=`rgba(15, 23, 42, 0.35)`,t.shadowBlur=10,t.fill(),t.shadowColor=`transparent`,t.shadowBlur=0,t.beginPath(),t.arc(r.x,r.y,r.size/2+5,0,Math.PI*2),t.fillStyle=_(r.color,.24),t.fill(),t.beginPath(),t.arc(r.x,r.y,r.size/2-1,0,Math.PI*2),t.fillStyle=r.color,t.fill(),t.lineWidth=2,t.strokeStyle=e.toCss(a.background),t.stroke(),r.label){t.font=n.font(a,12,600);let o=t.measureText(r.label).width+18,s=r.size/2+8,c=r.x+s+o<=i.x+i.width||r.x-s-o<i.x?r.x+s:r.x-s-o,l=r.y-11;t.shadowColor=`rgba(15, 23, 42, 0.2)`,t.shadowBlur=10,t.shadowOffsetY=3,u(t,c,l,o,22,11),t.fillStyle=e.toCss(a.background),t.fill(),t.shadowColor=`transparent`,t.shadowBlur=0,t.shadowOffsetY=0,t.lineWidth=1,t.strokeStyle=e.toCss(a.axis,.7),t.stroke(),t.fillStyle=e.toCss(a.text),t.textAlign=`left`,t.textBaseline=`middle`,t.fillText(r.label,c+9,r.y)}t.restore()},y=(r,i,o,s,l,p=a.createCanvas2dPainter(r))=>{let{width:m,height:h,theme:y,model:b,view:x,layout:S}=i,{plot:C,scales:w}=S,T=l;r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,Math.ceil(m*T),Math.ceil(h*T)),r.setTransform(T,0,0,T,0,0),n.drawBackground(r,{width:m,height:h,scales:w,x:b.x,y:b.y,xTicks:S.xTicks,yTicks:S.yTicks,y2:b.y2,y2Ticks:S.y2Ticks,theme:y,annotations:i.annotations});let E=i.legend?.colors;if(E&&f(r,E,i),i.legend){r.font=n.font(y,12),r.textBaseline=`middle`,r.textAlign=`left`;for(let t of i.legend.entries){let n=t.box.y+t.box.height/2;if(r.globalAlpha=t.hidden?.45:1,r.fillStyle=t.color,t.shape===`dot`?(r.beginPath(),r.arc(t.box.x+5,n,4,0,Math.PI*2),r.fill()):t.shape===`line`?r.fillRect(t.box.x,n-1,10,2):r.fillRect(t.box.x+1,n-4,8,8),r.fillStyle=e.toCss(y.textMuted),r.fillText(t.name,t.box.x+14,n),t.hidden){let e=t.box.width-22;r.fillRect(t.box.x+14,n,e,1)}}r.globalAlpha=1}let D=i.hover?.marks.some(e=>e.kind===`bar`)??!1;for(let t of i.hover?.marks??[])t.kind===`band`&&(u(r,t.x,t.y,t.width,t.height,6),r.fillStyle=e.toCss(y.text,D?.04:.06),r.fill());let O=b.series.some(e=>!e.hidden&&(e.type===`line`||e.type===`area`));D&&O&&i.hover&&g(r,i.hover.marks,C,y);let k=i.dragging?.target;k&&(r.save(),r.fillStyle=_(k.color,.12),r.fillRect(k.x,k.y,k.width,k.height),r.strokeStyle=_(k.color,.7),r.lineWidth=2,u(r,k.x+1,k.y+1,k.width-2,k.height-2,4),r.stroke(),r.restore()),w.horizontal?d(r,c.scenePrimitives(i),C):A();function A(){let e=(e,t,n)=>{let r=2/(e[1]-e[0]),i=(t-e[0])*r-1;return n?[-r,-i]:[r,i]},[t,n]=e(x.x,s.x,b.x.reverse),[r,i]=e(x.y,s.y,b.y.reverse);p.paint(o,{transform:{xScale:t,xOffset:n,yScale:r,yOffset:i},width:Math.max(1,Math.round(C.width*T)),height:Math.max(1,Math.round(C.height*T)),dpr:T},Math.round(C.x*T),Math.round(C.y*T))}r.setTransform(T,0,0,T,0,0);for(let t of i.hover?.marks??[])t.kind===`guide`&&(r.fillStyle=e.toCss(y.text,.06),r.fillRect(t.x,t.y,t.width,t.height));if(D&&!O&&(r.fillStyle=e.toCss(y.background,.42),r.fillRect(C.x,C.y,C.width,C.height)),i.hover&&!(D&&O)&&g(r,i.hover.marks,C,y),n.drawForeground(r,{width:m,height:h,scales:w,theme:y,annotations:i.annotations,pointLabels:[],clear:!1,connectors:i.connectors,arrows:i.arrows}),i.pointLabels.length){r.save(),r.font=n.font(y),r.textAlign=`left`,r.textBaseline=`middle`,r.lineWidth=3,r.lineJoin=`round`,r.strokeStyle=e.toCss(y.background,.9),r.fillStyle=e.toCss(y.text,.85);for(let{label:e,box:t}of i.pointLabels){let n=t.y+t.height/2;if(e.color){r.save(),r.fillStyle=e.color,r.fillText(e.text,t.x,n),r.restore();continue}r.strokeText(e.text,t.x,n),r.fillText(e.text,t.x,n)}r.restore()}let j=i.hover;if(j){if(j.crosshairX!==null){r.save(),r.strokeStyle=e.toCss(y.textMuted,.55),r.lineWidth=1,r.setLineDash([3,3]),r.beginPath();let t=Math.round(j.crosshairX)+.5;r.moveTo(t,C.y),r.lineTo(t,C.y+C.height),r.stroke(),r.restore()}if(j.crosshairY!==null){r.save(),r.strokeStyle=e.toCss(y.textMuted,.55),r.lineWidth=1,r.setLineDash([3,3]),r.beginPath();let t=Math.round(j.crosshairY)+.5;r.moveTo(C.x,t),r.lineTo(C.x+C.width,t),r.stroke(),r.restore()}for(let t of j.marks)t.kind!==`band`&&t.kind!==`guide`&&t.kind!==`bar`&&t.kind!==`cell`&&(r.beginPath(),r.arc(t.x,t.y,t.size/2+8,0,Math.PI*2),r.fillStyle=t.halo,r.globalAlpha=.45,r.fill(),r.globalAlpha=1,r.beginPath(),r.arc(t.x,t.y,t.size/2+4,0,Math.PI*2),r.fillStyle=t.halo,r.fill(),r.beginPath(),r.arc(t.x,t.y,t.size/2-1,0,Math.PI*2),r.fillStyle=t.color,r.fill(),r.lineWidth=2,r.strokeStyle=e.toCss(y.background),r.stroke())}i.dragging&&v(r,i.dragging,C,y);let M=j?.tooltip;if(M){let{box:i,lineHeight:a,padding:o}=M,s=t.tooltipColors(y,t.CANVAS_TOOLTIP_ALPHA);r.save(),r.shadowColor=`rgba(15, 23, 42, 0.18)`,r.shadowBlur=16,r.shadowOffsetY=6,u(r,i.x,i.y,i.width,i.height,8),r.fillStyle=s.background,r.fill(),r.restore(),u(r,i.x+.5,i.y+.5,i.width-1,i.height-1,8),r.strokeStyle=s.border,r.lineWidth=1,r.stroke(),r.textBaseline=`middle`;let c=i.y+o+a/2,l=i.x+o+2,d=i.x+i.width-o-2;if(M.text){r.font=n.font(y,12),r.fillStyle=e.toCss(y.text),r.textAlign=`left`;for(let e of M.text)r.fillText(e,l,c),c+=a}else{let{content:t}=M,i=l;t.titleColor&&(r.fillStyle=t.titleColor,r.beginPath(),r.arc(i+4,c,4,0,Math.PI*2),r.fill(),i+=14),r.font=n.font(y,12,600),r.fillStyle=e.toCss(y.text),r.textAlign=`left`,r.fillText(t.title,i,c),c+=a,t.subtitle&&(r.font=n.font(y,11),r.fillStyle=e.toCss(y.textMuted),r.fillText(t.subtitle,i,c-2),c+=a);for(let o of t.rows)i=l,o.color&&(r.fillStyle=o.color,r.beginPath(),r.arc(i+4,c,4,0,Math.PI*2),r.fill()),i+=M.swatchWidth,r.font=n.font(y,12),r.textAlign=`left`,r.fillStyle=e.toCss(y.textMuted),r.fillText(o.name,i,c),r.font=n.font(y,12,600),r.textAlign=`right`,r.fillStyle=e.toCss(y.text),r.fillText(o.value,d,c),c+=a}}},b=e=>{let{canvas:t}=e,n=t.getContext(`2d`),r=e.width,u=e.height,d=e.pixelRatio??1,f=!1,p=null,m=[],h=null,g=``,_=``,v=e.options,b=new WeakMap,x=0,S=e=>{let t=b.get(e);return t===void 0&&b.set(e,t=++x),t},C={x:0,y:0},w=0,T=``,E=(e,t)=>n?(t!==T&&(n.font=t,T=t),n.measureText(e).width):e.length*6.5,D=n?a.createCanvas2dPainter(n):null,O=globalThis,k=()=>{if(p=null,f||!n||!D)return;let e=P.getScene();if(!e)return;let a=Math.max(1,Math.round(r*d)),s=Math.max(1,Math.round(u*d));t.width!==a&&(N.own(),t.width=a),t.height!==s&&(N.own(),t.height=s),T=``,h!==e.model&&(h=e.model,g=o.itemsSignature(e.model,S(e.theme),e=>v.series[e]?.stack));let c=e.layout.scales,b={x:1/Math.abs(c.xPerPx),y:1/Math.abs(c.yPerPx)},x=`${g}|${i.cellStyleKey(e.model,b)}`;x!==_&&(_=x,C={x:l(e.model.base.x),y:l(e.model.base.y)},m=i.buildItems(e.model,C,++w,b)),y(n,e,m,C,d,D),T=``},A=()=>{f||p!==null||(p=t.requestAnimationFrame?t.requestAnimationFrame(k):O.requestAnimationFrame?O.requestAnimationFrame(k):setTimeout(k,16))},j=()=>{p!==null&&(t.cancelAnimationFrame?t.cancelAnimationFrame(p):O.cancelAnimationFrame?O.cancelAnimationFrame(p):clearTimeout(p),p=null)},M=()=>{j(),k()},N=s.watchBackingStore(t,()=>t.width!==Math.max(1,Math.round(r*d))||t.height!==Math.max(1,Math.round(u*d)),M),P=c.createChartController({options:e.options,theme:e.theme,measureText:E,onInvalidate:A});P.setSize(r,u);let F=(e,t)=>({id:e.identifier??t,touch:!0});return{setOptions:e=>{v=e,P.setOptions(e)},setTheme:e=>P.setTheme(e),resize(e,t,n){r=e,u=t,n&&(d=n),P.setSize(e,t),A()},render:M,touchStart(e){e.forEach((e,t)=>P.pointerDown(e.x,e.y,F(e,t)))},touchMove(e){e.forEach((e,t)=>P.pointerMove(e.x,e.y,F(e,t)))},touchEnd(e){e.forEach((e,t)=>P.pointerUp(e.x,e.y,F(e,t)))},touchCancel(e=[{x:0,y:0}]){e.forEach((e,t)=>P.pointerCancel(F(e,t)))},pointerDown:(e,t,n)=>P.pointerDown(e,t,n),pointerMove:(e,t,n)=>P.pointerMove(e,t,n),pointerUp:(e,t,n)=>P.pointerUp(e,t,n),pointerLeave:()=>P.pointerLeave(),zoomAt:(e,t,n)=>P.zoomAt(e,t,n),resetZoom:()=>P.resetZoom(),getView:()=>P.getView(),setView:e=>P.setView(e),toggleSeries:e=>P.toggleSeries(e),clearHover:()=>P.clearHover(),getPlotRect:()=>P.getPlotRect(),toPixel:(e,t)=>P.toPixel(e,t),fromPixel:(e,t)=>P.fromPixel(e,t),getController:()=>P,on:(e,t)=>P.on(e,t),destroy(){f||(f=!0,j(),N.disconnect(),D?.destroy(),P.destroy())}}};exports.createCanvasChart=b,exports.drawDragPreview=v,exports.drawPrimitives=d,exports.drawScene=y;
|
|
2
2
|
//# sourceMappingURL=canvas.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.cjs","names":["toCss","font","liftedBarRect","parseColor","createCanvas2dPainter","scenePrimitives","tooltipColors","CANVAS_TOOLTIP_ALPHA","itemsSignature","cellStyleKey","buildItems","createChartController","require_color","require_tooltip","require_overlay","require_scene","require_items","require_canvas2d","require_signature","require_controller","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","theme","t","l","CELL_LIFT","grownRect","d","drawLifted","background","ring","halo","accent","backdrop","fill","drawLiftedMarks","mark","marks","withAlpha","rgba","alpha","drawDragPreview","gap","drawScene","layout","dpr","pixelRatio","width","height","model","e","cy","lifted","m","mixed","s","target","scales","paintData","scale","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","painter","items","box","label","hover","cx","tip","colors","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","g","render","controller","pw","ph","index","sc","density","key","schedule","touchOptions","ratio","touches","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":"wOAmGA,IAAMoB,EAAO,IAAyBC,EAAE,GAAKA,EAA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enePrimitives","tooltipColors","CANVAS_TOOLTIP_ALPHA","itemsSignature","cellStyleKey","buildItems","watchBackingStore","createChartController","require_color","require_tooltip","require_overlay","require_scene","require_items","require_canvas2d","require_signature","require_backing_store","require_controller","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","theme","t","l","CELL_LIFT","grownRect","d","drawLifted","background","ring","halo","accent","backdrop","fill","drawLiftedMarks","mark","marks","withAlpha","rgba","alpha","drawDragPreview","gap","drawScene","layout","dpr","pixelRatio","width","height","model","e","cy","lifted","m","mixed","s","target","scales","paintData","scale","range","offset","o","reverse","xScale","xOffset","view","origin","yScale","yOffset","painter","items","box","label","hover","cx","tip","colors","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","g","render","controller","pw","ph","backing","index","sc","density","key","schedule","cancelFrame","renderNow","touchOptions","ratio","touches","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":"yQAoGA,IAAMsB,EAAO,IAAyBC,EAAE,GAAKA,EAAE,IAAM,EAE/CC,GACJ,EACA,EACA,EACA,EACA,EACA,IACG,CACHC,EAAI,UAAU,EACdA,EAAI,OAAOC,EAAIH,EAAGI,CAAC,EACnBF,EAAI,OAAOC,EAAIE,EAAIL,EAAGI,CAAC,EACvBF,EAAI,MAAMC,EAAIE,EAAGD,EAAGD,EAAIE,EAAGD,EAAIJ,EAAGA,CAAC,EACnCE,EAAI,OAAOC,EAAIE,EAAGD,EAAIE,EAAIN,CAAC,EAC3BE,EAAI,MAAMC,EAAIE,EAAGD,EAAIE,EAAGH,EAAIE,EAAIL,EAAGI,EAAIE,EAAGN,CAAC,EAC3CE,EAAI,OAAOC,EAAIH,EAAGI,EAAIE,CAAC,EACvBJ,EAAI,MAAMC,EAAGC,EAAIE,EAAGH,EAAGC,EAAIE,EAAIN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