@graphysdk/node-renderer 2.0.0-beta.1787305269287 → 2.0.0-beta.1788422115078
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +170 -177
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Render a Graphy chart to a PNG in Node.js.
|
|
4
4
|
|
|
5
|
+
Learn more at [graphy.dev](https://graphy.dev).
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -64,10 +66,16 @@ traceDeps: ['@graphysdk/node-renderer', '@napi-rs/canvas', '@fontsource/inter'];
|
|
|
64
66
|
|
|
65
67
|
Serves preset chart PNGs at `http://localhost:4310` (see `src/dev/server.ts`).
|
|
66
68
|
|
|
69
|
+
## Agent skills
|
|
70
|
+
|
|
71
|
+
Install the Graphy agent skills from [github.com/graphysdk/skills](https://github.com/graphysdk/skills) to set up the SDK and author charts from Cursor, Claude Code, and other coding agents.
|
|
72
|
+
|
|
67
73
|
## Licence
|
|
68
74
|
|
|
69
75
|
This package is available under PolyForm Noncommercial, Small Business, or a 32-day Free Trial. Free Trial is local or internal evaluation only — it does not cover a public page. See [what you can do under the trial](https://docs.graphy.dev/licence/evaluation).
|
|
70
76
|
|
|
77
|
+
For a commercial licence, [talk to us](https://graphy.dev/license).
|
|
78
|
+
|
|
71
79
|
## Support
|
|
72
80
|
|
|
73
81
|
Questions and community help: [Discord](https://discord.gg/yGmYCjkSr).
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var et=Object.create;var le=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var st=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ot(t))!rt.call(e,r)&&r!==o&&le(e,r,{get:()=>t[r],enumerable:!(n=tt(t,r))||n.enumerable});return e};var it=(e,t,o)=>(o=e!=null?et(nt(e)):{},st(t||!e||!e.__esModule?le(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("node:fs"),ye=require("node:module"),O=require("node:path"),at=require("node:url"),lt=require("@graphysdk/viz-engine/graph-config"),I=require("d3-shape"),d=require("@graphysdk/viz-engine"),ct=require("node:buffer");var _=typeof document<"u"?document.currentScript:null;let H,Q;const Se=()=>H?Promise.resolve(H):(Q??=import("@napi-rs/canvas").then(e=>(H=e,e)).catch(e=>{throw Q=void 0,e}),Q),V=()=>{if(!H)throw new Error("Canvas runtime is not loaded. Call loadCanvasRuntime() before rendering.");return H},E="Inter",J=new Set;let de=!1,z=!1;const Te=e=>`${e.family}|${e.weight??400}|${e.style??"normal"}`,ne=e=>{const t=Te(e);J.has(t)||(V().GlobalFonts.register(e.data,e.family),J.add(t))},dt=[{file:"Inter-Regular.ttf",family:E,weight:400},{file:"Inter-SemiBold.ttf",family:E,weight:600}],ut=[{file:"inter-latin-400-normal.woff",family:E,weight:400},{file:"inter-latin-600-normal.woff",family:E,weight:600}],ft="@fontsource/inter",ht=()=>{try{const e=ye.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href),t=O.dirname(e.resolve("@graphysdk/node-renderer/package.json"));return O.join(t,"assets")}catch{return O.resolve(O.dirname(at.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href)),"../assets")}},Re=(e,t,o)=>{try{return ce.existsSync(e)?(ne({family:t,data:ce.readFileSync(e),weight:o}),!0):!1}catch{return!1}},gt=()=>{const e=ht();for(const{file:t,family:o,weight:n}of dt)Re(O.join(e,t),o,n)&&(z=!0)},mt=()=>{const e=ye.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href);for(const{file:t,family:o,weight:n}of ut)if(!J.has(Te({family:o,data:Buffer.alloc(0),weight:n})))try{const r=e.resolve(`${ft}/files/${t}`);Re(r,o,n)&&(z=!0)}catch{}},Ee=()=>(de||(de=!0,gt(),mt()),z),C=(e,t)=>e.x+t*e.width,v=(e,t)=>e.y+(1-t)*e.height,$=e=>e==="catmull-rom"?I.curveCatmullRom:I.curveLinear,Le=e=>{switch(e){case"dashed":return[8,4];case"dotted":return[2,2];case"solid":return[]}},D=e=>e,At=(e,t)=>t!=="connect"?e:e.filter(o=>d.getX(o)!==null&&d.getY(o)!==null),bt=(e,t,o)=>{const n=$(t.interpolate),r=I.area().curve(n),s=I.line().curve(n);if(e.mainAxis==="y"){const i=a=>v(o,d.getY(a)??0),l=a=>C(o,d.getXMin(a)??0),c=a=>C(o,d.getXMax(a)??d.getX(a)??0);r.y(i).x0(l).x1(c),s.y(i).x(c)}else{const i=a=>C(o,d.getX(a)??0),l=a=>v(o,d.getYMin(a)??0),c=a=>v(o,d.getYMax(a)??d.getY(a)??0);r.x(i).y0(l).y1(c),s.x(i).y(c)}if(t.missingValues==="gap"){const i=l=>d.getX(l)!==null&&d.getY(l)!==null;r.defined(i),s.defined(i)}return{areaGenerator:r,lineGenerator:s}},pt=D({geom:"area",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const s=d.createStyleResolver({colorScheme:r}).geomReaders(t),{areaGenerator:i,lineGenerator:l}=bt(o,t.params,n),c=e;t.data.groupBy(d.GROUP_VARIABLES.group).forEach(a=>{const u=At([...a],t.params.missingValues),h=u[0];if(!h)return;const f=s.get("color",h),g=s.get("alpha",h),m=s.get("strokeWidth",h),p=Le(s.get("lineType",h));e.save(),e.globalAlpha=g,e.fillStyle=f,e.beginPath(),i.context(c)(u),e.fill(),e.restore(),e.save(),e.globalAlpha=s.get("strokeAlpha",h),e.strokeStyle=f,e.lineWidth=m,e.setLineDash(p),e.lineJoin="round",e.lineCap="round",e.beginPath(),l.context(c)(u),e.stroke(),e.restore()})}}),ue=(e,t,o,n,r,s)=>{const i=Math.max(0,Math.min(s.rx??s.ry??0,n/2)),l=Math.max(0,Math.min(s.ry??s.rx??0,r/2)),c=Math.PI/2;e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.ellipse(t+n-i,o+l,i,l,0,-c,0),e.lineTo(t+n,o+r-l),e.ellipse(t+n-i,o+r-l,i,l,0,0,c),e.lineTo(t+i,o+r),e.ellipse(t+i,o+r-l,i,l,0,c,Math.PI),e.lineTo(t,o+l),e.ellipse(t+i,o+l,i,l,0,Math.PI,Math.PI*1.5),e.closePath()},yt=D({geom:"bar",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const{Path2D:s}=V(),i=d.createStyleResolver({colorScheme:r}).geomReaders(t),l=o.mainAxis,c=new Map;for(const a of t.data){const u=d.getBarRectBounds(l,a);if(!u)continue;const h=C(n,u.x),f=n.y+u.y*n.height,g={x:h,y:f,width:u.width*n.width,height:u.height*n.height,fill:i.get("color",a),opacity:i.get("alpha",a)},m=d.buildColumnKey(l,u),p=c.get(m);p?p.bars.push(g):c.set(m,{bars:[g],style:{borderColor:i.get("borderColor",a),borderWidth:i.get("borderWidth",a),borderRadius:i.get("borderRadius",a),borderAlpha:i.get("alpha",a)}})}for(const{bars:a,style:u}of c.values()){const{borderColor:h,borderRadius:f,borderWidth:g,borderAlpha:m}=u,p=d.resolveBarBorderTreatment(g),b=f==="full"?void 0:d.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l});if(!(a.length>1)){const[A]=a;if(!A)continue;const w=b??d.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l,bounds:{width:A.width,height:A.height}}),L=new s;ue(L,A.x,A.y,A.width,A.height,w),e.save(),e.globalAlpha=A.opacity,e.fillStyle=A.fill,e.fill(L),h!==void 0&&(e.clip(L),e.strokeStyle=h,e.lineWidth=p.outlineWidth,e.stroke(L)),e.restore();continue}const S=d.getBoundingRect(a),R=b??d.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l,bounds:{width:S.width,height:S.height}}),T=new s;ue(T,S.x,S.y,S.width,S.height,R),e.save(),e.clip(T);for(const A of a)e.globalAlpha=A.opacity,e.fillStyle=A.fill,e.fillRect(A.x,A.y,A.width,A.height),h!==void 0&&(e.strokeStyle=h,e.lineWidth=p.separatorWidth,e.strokeRect(A.x,A.y,A.width,A.height));h!==void 0&&(e.globalAlpha=m,e.strokeStyle=h,e.lineWidth=p.outlineWidth,e.stroke(T)),e.restore()}}}),fe=(e,t)=>{const o=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());if(o?.[1]!==void 0){const r=o[1],s=r.length===3?[...r].map(a=>a+a).join(""):r.slice(0,6),i=Number.parseInt(s.slice(0,2),16),l=Number.parseInt(s.slice(2,4),16),c=Number.parseInt(s.slice(4,6),16);return`rgba(${i}, ${l}, ${c}, ${t})`}const n=/^rgba?\(([^)]+)\)$/i.exec(e.trim());if(n?.[1]!==void 0){const r=n[1].split(",").map(c=>c.trim()),[s,i,l]=r;if(s!==void 0&&i!==void 0&&l!==void 0)return`rgba(${s}, ${i}, ${l}, ${t})`}return t===0?"rgba(0, 0, 0, 0)":e},St=(e,t)=>t!=="connect"?e:e.filter(o=>d.getX(o)!==null&&d.getY(o)!==null),Tt=(e,t)=>{const{seriesObservations:o,fillGenerator:n,panel:r,color:s,fillAlpha:i}=t,l=o.map(a=>d.getY(a)).filter(a=>a!==null).map(a=>v(r,a));if(l.length===0)return;const c=e.createLinearGradient(0,Math.min(...l),0,r.y+r.height);c.addColorStop(0,s),c.addColorStop(.7,fe(s,0)),c.addColorStop(1,fe(s,0)),e.save(),e.globalAlpha=i,e.fillStyle=c,e.beginPath(),n.context(e)(o),e.fill(),e.restore()},Rt=D({geom:"line",coord:"cartesian",draw:(e,{layer:t,panel:o,colorScheme:n})=>{const r=d.createStyleResolver({colorScheme:n}).geomReaders(t),s=I.line().x(l=>C(o,d.getX(l)??0)).y(l=>v(o,d.getY(l)??0)).curve($(t.params.interpolate)),i=I.area().x(l=>C(o,d.getX(l)??0)).y0(o.y+o.height).y1(l=>v(o,d.getY(l)??0)).curve($(t.params.interpolate));if(t.params.missingValues==="gap"){const l=c=>d.getX(c)!==null&&d.getY(c)!==null;s.defined(l),i.defined(l)}t.data.groupBy(d.GROUP_VARIABLES.group).forEach(l=>{const c=St([...l],t.params.missingValues),a=c[0];if(!a)return;const u=r.get("strokeWidth",a),h=Le(r.get("lineType",a)),f=r.get("color",a),g=r.get("fillAlpha",a);g!==void 0&&Tt(e,{seriesObservations:c,fillGenerator:i,panel:o,color:f,fillAlpha:g}),e.save(),e.globalAlpha=r.get("alpha",a),e.strokeStyle=f,e.lineWidth=u,e.setLineDash(h),e.lineJoin="round",e.lineCap="round",e.beginPath(),s.context(e)(c),e.stroke(),e.restore()})}}),Et=D({geom:"point",coord:"cartesian",draw:(e,{layer:t,panel:o,colorScheme:n})=>{const r=d.createStyleResolver({colorScheme:n}).geomReaders(t);for(const s of t.data){const i=d.getX(s),l=d.getY(s);if(i===null||l===null)continue;const c=C(o,i),a=v(o,l),u=r.get("size",s)/2,h=r.get("borderWidth",s);e.save(),e.globalAlpha=r.get("alpha",s),e.fillStyle=r.get("color",s),e.strokeStyle=r.get("borderColor",s),e.lineWidth=h,e.beginPath(),e.arc(c,a,u,0,Math.PI*2),e.fill(),h>0&&e.stroke(),e.restore()}}}),re=11,Lt="sans-serif",wt=500,k=5,we=5,x=13,ve=6,K=12,he=21.6,vt=(e,t)=>{const o=e.mapping.y!==void 0,n=t.mainAxis==="y";return o!==n},_t=(e,t,o)=>{const n=d.getRuleDashPattern(t,o);e.setLineDash(n),n.length>0&&(e.lineCap="round")},Ct=(e,t)=>X(e)&&X(t)?`${e}: ${t}`:X(e)?e:X(t)?t:null,X=e=>e!=null&&e.trim()!=="",Bt=e=>{e.beginPath(),e.moveTo(2.48935,16.9323),e.lineTo(9.07098,9.82964),e.bezierCurveTo(9.51595,9.34944,9.51504,8.60728,9.0689,8.12818),e.lineTo(2.48866,1.06172),e.bezierCurveTo(1.85811,.384586,.974477,0,.049217,0),e.lineTo(0,0),e.lineTo(0,18),e.lineTo(.0443689,18),e.bezierCurveTo(.972463,18,1.85854,17.6131,2.48935,16.9323),e.closePath()},_e=(e,t,o,n,r,s)=>{const i=Math.min(s,n/2,r/2);e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.arcTo(t+n,o,t+n,o+i,i),e.lineTo(t+n,o+r-i),e.arcTo(t+n,o+r,t+n-i,o+r,i),e.lineTo(t+i,o+r),e.arcTo(t,o+r,t,o+r-i,i),e.lineTo(t,o+i),e.arcTo(t,o,t+i,o,i),e.closePath(),e.fill()},Pt=(e,t,o,n,r,s,i,l)=>{const c=o+k*2,a=re+we*2,u=n==="start",h=u?s.x:s.x+s.width,f=v(s,r),g=u?-x:-(c-x),m=u?g+c-k:g+k-K;e.save(),e.translate(h,f),e.translate(0,-a/2),e.fillStyle=i,_e(e,g,0,c,a,ve),e.save(),u||(e.translate(m+K/2,a/2),e.rotate(Math.PI),e.translate(-(m+K/2),-a/2)),e.translate(m,(a-he)/2),e.scale(K/10,he/18),e.fillStyle=i,Bt(e),e.fill(),e.restore(),e.fillStyle=l,e.textAlign="left",e.textBaseline="middle",e.fillText(t,g+k,a/2),e.restore()},It=(e,t,o,n,r,s,i,l)=>{const c=o+k*2,a=re+we*2,u=n==="start",h=C(s,r),f=u?s.y+s.height:s.y,g=u?-x:-8;e.save(),e.translate(h,f),e.translate(-c/2,0),e.fillStyle=i,_e(e,0,g,c,a,ve),e.fillStyle=l,e.textAlign="left",e.textBaseline="middle",e.fillText(t,k,g+a/2),e.restore()},Nt=D({geom:"rule",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,compiled:r,textMeasurer:s,formattingLocale:i,colorScheme:l})=>{const c=t.data.getFirst();if(!c)return;const a=vt(t,o),u=a?d.getY(c):d.getX(c);if(u===null)return;const h=d.createStyleResolver({colorScheme:l}).geomReaders(t),f=h.get("color",c),g=d.pickReadableTextColor(f),m=h.get("strokeWidth",c);if(e.save(),e.strokeStyle=f,e.lineWidth=m,_t(e,h.get("lineType",c),m),e.beginPath(),a){const T=v(n,u);e.moveTo(n.x,T),e.lineTo(n.x+n.width,T)}else{const T=C(n,u);e.moveTo(T,n.y),e.lineTo(T,n.y+n.height)}e.stroke(),e.restore();const p=Ct(t.params.label,d.formatRuleValue({guides:r.guides,numberFormat:r.config.numberFormat,layer:t,locale:i??r.config.parsingLocale}));if(p===null)return;const b=r.config.appearance.textScale,y={family:Lt,size:re*b,weight:wt};e.font=d.buildFontString(y);const S=s.measureText(p,y).width;(a?Pt:It)(e,p,S,t.params.labelPosition,u,n,f,g)}}),U=I.arc();U.digits(8);const kt=D({geom:"bar",coord:"polar",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const s=n.x+n.width/2,i=n.y+n.height/2,l=Math.min(n.width,n.height)/2,{Path2D:c}=V(),a=d.createStyleResolver({colorScheme:r}).geomReaders(t);e.save(),e.translate(s,i),e.scale(l,l);const u=e,h=new Map;for(const f of t.data){const{startAngle:g,endAngle:m}=d.getAngleExtent(f),{innerRadius:p,outerRadius:b}=d.getRadiusExtent(f);if(g===null||m===null||p===null||b===null)continue;const y={startAngle:g,endAngle:m,innerRadius:p,outerRadius:b,fill:a.get("color",f),opacity:a.get("alpha",f)},S=d.buildSliceGroupKey(o.bandAxis,y),R=h.get(S);R?R.items.push(y):h.set(S,{items:[y],style:{borderColor:a.get("borderColor",f),borderWidth:a.get("borderWidth",f),borderRadius:a.get("borderRadius",f),borderAlpha:a.get("alpha",f)}})}for(const{items:f,style:g}of h.values()){const{borderColor:m,borderRadius:p,borderWidth:b,borderAlpha:y}=g,S=d.resolveBarBorderTreatment(b),R=m!==void 0&&l>0,T=d.getUnionExtent(f),A=d.resolvePolarBarCornerRadiusUnit(p,T.outerRadius-T.innerRadius),w=l>0&&(R||A>0);e.save();let L;w&&(L=new c,U.cornerRadius(A),U.context(L)(T),e.clip(L)),U.cornerRadius(0);for(const N of f)e.globalAlpha=N.opacity,e.fillStyle=N.fill,e.beginPath(),U.context(u)(N),e.fill(),R&&(e.strokeStyle=m,e.lineWidth=S.separatorWidth/l,e.stroke());R&&L&&(e.globalAlpha=y,e.strokeStyle=m,e.lineWidth=S.outlineWidth/l,e.stroke(L)),e.restore()}e.restore()}}),Ft={bar:{cartesian:yt,polar:kt},line:{cartesian:Rt},area:{cartesian:pt},point:{cartesian:Et},rule:{cartesian:Nt}},Ce=(e,t)=>Ft[e.geom]?.[t.type]??null,Dt=(e,t,o)=>{e.draw(t,o)};let ge;const Be=()=>(ge??=d.createCompiler(),ge),se=["line","areaStacked","bar","barStacked","barStackedFill","column","columnStacked","columnStackedFill","combo","pie","donut","scatter","bubble"],Pe=["funnel","heatmap","waterfall","mekko","table"],Ot=new Set(se),Ut={supportedGraphTypes:[...se],unsupportedGraphTypes:[...Pe],supportedGeoms:{cartesian:["bar","line","area","point","rule"],polar:["bar"]}},P=e=>({ok:!1,reason:e}),q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ht=e=>{if(!q(e))return!1;const{columns:t,rows:o}=e;return!Array.isArray(t)||!Array.isArray(o)?!1:t.every(n=>q(n)&&typeof n.key=="string")},Mt=e=>{if("_unstable_mapping"in e&&e._unstable_mapping!==void 0)return!0;const t=e.referenceLines;return q(t)?t.trendline!==void 0||t.averageLine!==void 0:!1},Ie=e=>{if(!q(e))return P("Chart config must be a plain object.");if(!Ht(e.data))return P("Chart config is missing a valid `data` object (columns + rows).");const{data:t,...o}=e;return{ok:!0,input:o,data:t}},Ne=e=>{const t=Ie(e);if(!t.ok)return t;if(Mt(e))return P("Canvas renderer does not support `_unstable_mapping`, `referenceLines.trendline`, or `referenceLines.averageLine`.");const o=t.input.type??"column";if(!Ot.has(o))return P(`Unsupported chart type for canvas rendering: ${o}.`);try{const n=Be(),r=lt.convertGraphConfig(t.input,t.data),s=n.compile({input:r,data:t.data});if(!s.ok)return P(`Chart config failed to compile: ${s.errors.map(i=>i.message).join("; ")}`);for(const i of s.compiled.layers)if(Ce(i,s.compiled.coordSystem)===null)return P(`No canvas geom renderer for ${i.geom} (${s.compiled.coordSystem.type} coord).`);return{ok:!0,compiled:s.compiled}}catch(n){const r=n instanceof Error?n.message:String(n);return P(`Chart config failed to compile: ${r}`)}},ke=E,M=12,ie=1.3,G=10,W=12,F=6,Fe=16,Gt=24,De=6,Oe=3,ee=4,Wt=8,Vt="#9ca3af",Ue=16,Kt=1.3,He=13,Xt=1.4,Me=12,Yt=1.4,j=8,ae=12,zt=1.3,qt=200,jt=120,Qt=80,Ge=22,Zt=9,Jt=11,$t=10,Y=9,me=12,xt='-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif',eo=11.5,to=550,oo={light:.55,mid:.75,dark:.08},no={light:.62,mid:.8,dark:.85},ro=.22,so=.65,io={family:ke,size:M},ao=[2,3],lo=[1,3],te=e=>{switch(e){case"dashed":return ao;case"dotted":return lo;case"solid":return[]}},co=(e,t,o,n,r,s)=>{if(!t.isVisible||t.ticks.length===0)return;const i=t.position==="bottom"||t.position==="top";e.save(),e.font=d.buildFontString(d.toFontSpec(r,E)),e.fillStyle=r.textColor,e.strokeStyle=s.color,e.lineWidth=s.strokeWidth,e.setLineDash(te(s.lineType));for(const l of t.ticks){const c=i?l.position:1-l.position;t.ticksVisible&&fo(e,t.position,c,o,n,s.length),go(e,t.position,c,o,n,l.formattedLabel,t.labelRotation,r.offset)}e.restore()},uo=(e,t,o,n,r)=>{if(e==="bottom"||e==="top"){const c=n.x+t*n.width,a=e==="top"?o.y+o.height:o.y,u=e==="top"?-r:r;return{x1:c,y1:a,x2:c,y2:a+u}}const s=n.y+t*n.height,i=e==="right"?o.x:o.x+o.width,l=e==="right"?r:-r;return{x1:i,y1:s,x2:i+l,y2:s}},fo=(e,t,o,n,r,s)=>{const{x1:i,y1:l,x2:c,y2:a}=uo(t,o,n,r,s);e.beginPath(),e.moveTo(i,l),e.lineTo(c,a),e.stroke()},ho=(e,t,o,n,r)=>{if(e==="bottom"||e==="top"){const i=n.x+t*n.width;return e==="bottom"?{x:i,y:o.y+r,textAlign:"center",textBaseline:"top"}:{x:i,y:o.y+o.height-r,textAlign:"center",textBaseline:"alphabetic"}}const s=n.y+t*n.height;return e==="left"?{x:o.x+o.width-r,y:s,textAlign:"right",textBaseline:"middle"}:{x:o.x+r,y:s,textAlign:"left",textBaseline:"middle"}},go=(e,t,o,n,r,s,i,l)=>{if(i!==0&&(t==="top"||t==="bottom")){const a=r.x+o*r.width,u=t==="top";e.save(),e.translate(a,u?n.y+n.height-l:n.y+l),e.rotate(i*Math.PI/180),e.textAlign=u?"left":"right",e.textBaseline="middle",e.fillText(s,0,0),e.restore();return}const c=ho(t,o,n,r,l);e.textAlign=c.textAlign,e.textBaseline=c.textBaseline,e.fillText(s,c.x,c.y)},mo=(e,t,o,n)=>{if(!t.isVisible||!t.label)return;e.save(),e.font=d.buildFontString({family:n.fontFamily??E,size:n.fontSize,weight:n.fontWeight}),e.fillStyle=n.textColor,e.textBaseline="middle";const{x:r,y:s,alignment:i}=Ao(t.position,o);e.textAlign=i,e.fillText(t.label,r,s),e.restore()},Ao=(e,t)=>{const o=t.y+t.height/2;return e==="left"?{x:t.x,y:o,alignment:"start"}:e==="right"?{x:t.x+t.width,y:o,alignment:"end"}:{x:t.x+t.width/2,y:o,alignment:"center"}},bo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABgCAYAAAC65+QhAAAKo0lEQVR42u2de4wdVR3HPzN32+oSUQSsikEoosR3iko08oovEkwMpmiIr/KHIomgUYyPiBofkRjjE+MjEk3RQNIYTdUotKkoaql0Wyympbtl2XbLtrW71n3v3ntnrn+c38n98cvc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UBFCkvN4XgDO6lazdphrvVJUFD5j1jmV5+QdMOFExzD3jGdKOGLcud1Gv0P/rGVyH29B6MiWcmBbARiVAHBNg9srvsqQdV3cDIXuz9ut88Tpp4cSi5I77RSWLGdKOGxUoBXq0Z8cW2C7D8X+n0XFXUtz9nJRhz1lt3xJkFxdvUMV7b7/K5tuAdEStpWgr8MpeVbNGVoHPwG20n6lBs21DhiGVLK9agOrZrwtxq7ePGm48X5PfgeuJWdvN381CG7+pIlBbfryEXCJpxlqRtBG10oHa6NXVx/8Ba+cluUx5B18AAAAASUVORK5CYII=",B=Ge;let Z;const po=()=>{if(Z)return Z;const{Image:e}=V(),t=new e,o=bo.replace(/^data:image\/png;base64,/,"");return t.src=ct.Buffer.from(o,"base64"),Z=t,t},We=(e,t,o="full")=>!e||t.width<jt||t.height<Qt?"hidden":t.width<qt||o==="mini"?"mini":"full",yo=e=>{const t=So(e);if(t===null)return"light";const o=To(t);return o<=ro?"dark":o<=so?"mid":"light"},oe=(e,t,o)=>e.placement!==o||We(e.enabled,t,e.variant)==="hidden"?0:Ge,Ve=(e,t,o,n,r,s)=>{if(t.placement!==s)return;const i=We(t.enabled,r,t.variant);if(i==="hidden")return;const l=yo(n.background),c=l==="dark",a={family:xt,size:eo,weight:400},u={...a,weight:to};let h=0;i==="full"&&(e.font=d.buildFontString(a),h=e.measureText("Made with ").width,e.font=d.buildFontString(u),h+=e.measureText("Graphy").width);const f=i==="mini"?0:Zt,g=i==="mini"?0:Jt,m=i==="mini"?0:$t,p=i==="mini"?B:f+Y+m+h+g,b=o.x+o.width-p,y=o.y+Math.max(0,(o.height||B)/2-B/2);e.save(),e.globalAlpha=no[l],e.textBaseline="middle",e.textAlign="left",c||(e.shadowColor="rgba(0, 0, 0, 0.09)",e.shadowBlur=4,e.shadowOffsetY=1),e.beginPath(),e.roundRect(b,y,p,B,B/2),e.fillStyle=`rgba(255, 255, 255, ${oo[l]})`,e.fill(),e.shadowColor="transparent",e.shadowBlur=0,e.shadowOffsetY=0;const S=c?"#FFFFFF":"#2A2A28",R=i==="mini"?b+(p-Y)/2:b+f,T=y+(B-me)/2;if(e.save(),c&&(e.filter="invert(1)"),e.drawImage(po(),R,T,Y,me),e.restore(),i==="full"){const A=b+f+Y+m,w=y+B/2;e.fillStyle=S,e.font=d.buildFontString(a),e.fillText("Made with ",A,w);const L=e.measureText("Made with ").width;e.font=d.buildFontString(u),e.fillText("Graphy",A+L,w)}e.restore()},So=e=>{const t=e.trim();if(!t.startsWith("#"))return null;const o=t.slice(1);if(o.length===3){const n=o[0],r=o[1],s=o[2];return n===void 0||r===void 0||s===void 0?null:{red:Number.parseInt(n+n,16),green:Number.parseInt(r+r,16),blue:Number.parseInt(s+s,16)}}return o.length>=6?{red:Number.parseInt(o.slice(0,2),16),green:Number.parseInt(o.slice(2,4),16),blue:Number.parseInt(o.slice(4,6),16)}:null},To=({red:e,green:t,blue:o})=>{const n=r=>{const s=r/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*n(e)+.7152*n(t)+.0722*n(o)},Ro={family:E,size:Ue,weight:600},Eo={family:E,size:He},Lo={family:E,size:Me},wo={family:E,size:ae,weight:500},vo={family:E,size:ae},Ke=Ue*Kt,_o=He*Xt,Xe=Me*Yt,Ye=ae*zt,ze=e=>{if(e===null)return null;if(e.label!==void 0&&e.label!=="")return e.label;if(e.url!==void 0&&e.url!==""&&d.isSafeUrl(e.url))try{return new URL(e.url).hostname}catch{return e.url}return null},Co=(e,t)=>{let o=0;const n=e.isTitleVisible&&e.title!==null,r=e.isSubtitleVisible&&e.subtitle!==null;n&&(o+=Ke),r&&(o>0&&(o+=j),o+=_o);const s=oe(e.brandMark,t,"header");!n&&!r&&s>0&&(o=s);const i=e.isCaptionVisible&&e.caption!==null,l=e.isSourceVisible&&ze(e.source)!==null,c=oe(e.brandMark,t,"footer");let a=0;return i&&(a+=Xe),(l||c>0)&&(a>0&&(a+=j),a+=Math.max(Ye,c)),{headerHeight:o,footerHeight:a}},Bo=(e,t,o,n,r)=>{if(o.height===0)return;e.save(),e.textBaseline="top",e.textAlign="left";let s=o.y;t.isTitleVisible&&t.title!==null&&(e.font=d.buildFontString(Ro),e.fillStyle=n.textPrimary,e.fillText(d.extractPlainText(t.title),o.x,s),s+=Ke+j),t.isSubtitleVisible&&t.subtitle!==null&&(e.font=d.buildFontString(Eo),e.fillStyle=n.textSecondary,e.fillText(d.extractPlainText(t.subtitle),o.x,s)),e.restore(),Ve(e,t.brandMark,o,n,r,"header")},Po=(e,t,o,n,r)=>{if(o.height===0)return;const s=t.isCaptionVisible?t.caption:null,i=t.isSourceVisible?ze(t.source):null,l=oe(t.brandMark,r,"footer");if(s===null&&i===null&&l===0)return;e.save(),e.textBaseline="top",e.textAlign="left";let c=o.y;if(s!==null&&(e.font=d.buildFontString(Lo),e.fillStyle=n.textSecondary,e.fillText(d.extractPlainText(s),o.x,c),c+=Xe+j),i!==null){let a=o.x;a=Ae(e,"Source: ",wo,n.textSecondary,a,c),Ae(e,i,vo,n.textSecondary,a,c)}e.restore(),Ve(e,t.brandMark,{x:o.x,y:c,width:o.width,height:Math.max(Ye,l)},n,r,"footer")},Ae=(e,t,o,n,r,s)=>(e.font=d.buildFontString(o),e.fillStyle=n,e.fillText(t,r,s),r+e.measureText(t).width),Io=(e,t,o,n)=>{e.save(),e.lineCap="round";for(const r of d.computePanelBorderPaths(d.resolvePanelBorderStyle(o),n))e.strokeStyle=r.color,e.lineWidth=r.strokeWidth,e.setLineDash(te(r.lineType)),No(e,r.segments),e.stroke();for(const r of t){if(!r.gridVisible)continue;const s=r.position==="top"||r.position==="bottom",i=d.resolveGridLineStyle(o,d.getAestheticFromScaleAestheticKey(r.scaleAestheticKey));e.strokeStyle=i.color,e.lineWidth=i.strokeWidth,e.setLineDash(te(i.lineType));for(const l of r.ticks){if(l.position<=0||l.position>=1)continue;const c=s?l.position:1-l.position;if(e.beginPath(),s){const a=n.x+c*n.width;e.moveTo(a,n.y),e.lineTo(a,n.y+n.height)}else{const a=n.y+c*n.height;e.moveTo(n.x,a),e.lineTo(n.x+n.width,a)}e.stroke()}}e.restore()},No=(e,t)=>{e.beginPath();for(const o of t)switch(o.type){case"move":e.moveTo(o.x,o.y);break;case"line":e.lineTo(o.x,o.y);break;case"arc":e.arc(o.cx,o.cy,o.radius,o.startAngle,o.endAngle);break;case"close":e.closePath();break}},ko=(e,t,o,n)=>{e.save(),e.font=d.buildFontString(io),e.textBaseline="middle";for(const s of t)s.display==="direct"&&Fo(e,s,o,n);const r=new Map;for(const s of t){if(s.display!=="pill"||s.items.length===0)continue;const i=r.get(s.position);i?i.push(s):r.set(s.position,[s])}for(const[s,i]of r){const l=o[s];l&&(s==="top"||s==="bottom"?Do(e,i,l,n):Oo(e,i,l,n))}e.restore()},Fo=(e,t,o,n)=>{const r=o[t.position];if(r){e.textAlign="left";for(const s of t.items)s.normalizedY!==null&&(e.fillStyle=typeof s.visual.color=="string"?s.visual.color:n.textPrimary,e.fillText(s.formattedLabel,r.x+Wt,v(r,s.normalizedY)))}},Do=(e,t,o,n)=>{const r=qe(t),s=r.reduce((a,u,h)=>a+Ho(u)+e.measureText(u.label).width+(h===0?0:be(u)),0),i=M*ie;let l=o.x+Math.max(0,(o.width-s)/2);const c=o.y+De+Math.max(i,W)/2;for(let a=0;a<r.length;a++){const u=r[a];u&&(a>0&&(l+=be(u)),l=je(e,u,l,c,n))}},Oo=(e,t,o,n)=>{const r=qe(t),s=Math.max(M*ie,W),i=4,l=r.length*s+Math.max(0,r.length-1)*i;let c=o.y+Math.max(0,(o.height-l)/2)+s/2;for(const a of r)je(e,a,o.x,c,n),c+=s+i},qe=e=>{const t=[];for(const o of e){const n=o.aesthetics.includes("size");o.items.forEach((r,s)=>{const i=r.visual.size,l=n&&typeof i=="number"&&Number.isFinite(i)&&i>0?i:void 0;t.push({label:r.formattedLabel,colors:Uo(r.visual.color),bubbleSize:l,isFirstInGroup:s===0})})}return t},Uo=e=>typeof e=="string"?[e]:Array.isArray(e)?e.filter(t=>typeof t=="string"):[],be=e=>e.isFirstInGroup?Gt:Fe,Ho=e=>{if(e.bubbleSize!==void 0)return e.bubbleSize+F;const t=e.colors.length;if(t===0)return 0;if(t===1)return G+F;const o=Math.min(t,Oe);return G+(o-1)*ee+F},je=(e,t,o,n,r)=>{let s=o;if(t.bubbleSize!==void 0){const i=t.bubbleSize/2;e.fillStyle=t.colors[0]??Vt,e.beginPath(),e.arc(s+i,n,i,0,Math.PI*2),e.fill(),s+=t.bubbleSize+F}else if(t.colors.length>0){const i=t.colors.slice(0,Oe);for(let l=0;l<i.length;l++){const c=i[l];c&&(e.fillStyle=c,e.fillRect(s+l*ee,n-W/2,G,W))}s+=G+(i.length-1)*ee+F}return e.fillStyle=r.textPrimary,e.textAlign="left",e.fillText(t.label,s,n),s+e.measureText(t.label).width},pe=(e,t)=>Math.min(Math.max(...e),t),Mo=(e,t,o)=>n=>{if(!n.isVisible||n.ticks.length===0)return 0;const r=n.position==="top"||n.position==="bottom",s=d.getAestheticFromScaleAestheticKey(n.scaleAestheticKey),{offset:i,...l}=t[s],c=n.ticksVisible?Math.max(i,o[s].length):i,a=d.toFontSpec(l,E),u=n.ticks.map(g=>e.measureText(g.formattedLabel,a)),h=n.labelMaxWidthPx??Number.POSITIVE_INFINITY;if(r){if(n.labelRotation!==0){const g=u.map(m=>m.width);return pe(g,h)+2*c}return Math.max(...u.map(g=>g.height))+c}const f=u.map(g=>g.width);return pe(f,h)+c},Go=e=>t=>{if(t.items.length===0)return 0;const o={family:ke,size:M};if(t.position==="top"||t.position==="bottom"){const s=M*ie;return Math.max(s,W)+De*2}const r=t.items.map(s=>{const i=e.measureText(s.formattedLabel,o).width;return G+F+i});return Math.max(...r)+Fe},Wo=e=>(t,o)=>{const{labelLineHeight:n,labelFontWeight:r}=d.getDifferenceArrowDimensions(o,1);return e.measureText(t,{family:E,size:n,weight:r})},Vo=(e,t)=>(o,n,r)=>{const s=t[o][n],i=e.measureText(r,d.toFontSpec(s,E));return{...i,width:i.width+s.paddingInline*2,height:i.height+s.paddingBlock*2}},Ko=({textMeasurer:e,axisLabelStyles:t,dataLabelStyles:o,tickLabelStyles:n,tickLineStyles:r})=>({measureAxis:Mo(e,n,r),measureAxisLabel:s=>d.computeLineBoxHeight(t[d.getAestheticFromScaleAestheticKey(s.scaleAestheticKey)]),measureLegend:Go(e),measureTickLabel:(s,i)=>e.measureText(s,d.toFontSpec(n[i],E)),measureDifferenceArrowLabel:Wo(e),measureDataLabel:Vo(e,o),measureHeadline:()=>({width:0,height:0}),measureHeadlineItemWidths:()=>[]});class Qe{constructor(){this.currentFont="";const t=V().createCanvas(1,1);this.ctx=t.getContext("2d")}measureText(t,o){const n=d.buildFontString(o);this.currentFont!==n&&(this.ctx.font=n,this.currentFont=n);const r=this.ctx.measureText(t);return{width:r.width,height:r.fontBoundingBoxAscent+r.fontBoundingBoxDescent,ascent:r.fontBoundingBoxAscent,descent:r.fontBoundingBoxDescent}}}const Ze={background:"#ffffff",textPrimary:"#111827",textSecondary:"#6b7280",gridLine:"#e5e7eb",legendPillBackground:"rgba(0, 0, 0, 0.04)",legendPillBorder:"rgba(0, 0, 0, 0.08)"},Je={background:"#0b0f17",textPrimary:"#e5e7eb",textSecondary:"#9ca3af",gridLine:"#1f2937",legendPillBackground:"rgba(255, 255, 255, 0.06)",legendPillBorder:"rgba(255, 255, 255, 0.12)"},Xo=async({input:e,data:t},o)=>{const r=Be().compile({input:e,data:t});if(!r.ok)throw new Error(`Failed to compile graph spec: ${r.errors.map(s=>s.message).join("; ")}`);return $e(r.compiled,o)},$e=async(e,t)=>{const{Canvas:o}=await Se();if(Ee(),t.fonts)for(const w of t.fonts)ne(w);const n=d.formatLegends({legends:e.guides.legends.drawn,numberFormat:e.config.numberFormat,parsingLocale:e.config.parsingLocale,formattingLocale:t.formattingLocale}),r={width:t.width,height:t.height},{headerHeight:s,footerHeight:i}=Co(e.config.content,r),l={headerSize:{width:t.width,height:s},footerSize:{width:t.width,height:i}},c=t.colorScheme??"light",a=d.createStyleResolver({colorScheme:c}).chromeReaders(e.chrome),u=e.config.appearance.textScale,h={x:d.resolveAxisLabelStyle(a,"x",u),y:d.resolveAxisLabelStyle(a,"y",u)},f={x:d.resolveTickLabelStyle(a,"x",u),y:d.resolveTickLabelStyle(a,"y",u)},g={x:d.resolveTickLineStyle(a,"x"),y:d.resolveTickLineStyle(a,"y")},m={};for(const w of d.DATA_LABEL_ROLES){const L={};for(const N of d.DATA_LABEL_POSITIONS)L[N]=d.resolveDataLabelStyle(a,w,N,u);m[w]=L}const p=new Qe,b=Ko({textMeasurer:p,axisLabelStyles:h,dataLabelStyles:m,tickLabelStyles:f,tickLineStyles:g}),{layout:y,formattedAxes:S}=new d.LayoutCompiler(b).compile({axes:e.guides.axes,numberFormat:e.config.numberFormat,parsingLocale:e.config.parsingLocale,formattedLegends:n,containerSize:{width:t.width,height:t.height},externalMeasurements:l,formattingLocale:t.formattingLocale,layout:e.config.layout}),R=t.pixelRatio??2,T=new o(t.width*R,t.height*R),A=T.getContext("2d");return A.scale(R,R),Yo({ctx:A,theme:c==="dark"?Je:Ze,colorScheme:c,chromeReaders:a,axisLabelStyles:h,tickLabelStyles:f,tickLineStyles:g,width:t.width,height:t.height,compiled:e,formattedAxes:S,formattedLegends:n,layout:y,textMeasurer:p,...t.formattingLocale===void 0?{}:{formattingLocale:t.formattingLocale}}),T.encode("png")},Yo=({ctx:e,theme:t,colorScheme:o,chromeReaders:n,axisLabelStyles:r,tickLabelStyles:s,tickLineStyles:i,width:l,height:c,compiled:a,formattedAxes:u,formattedLegends:h,layout:f,textMeasurer:g,formattingLocale:m})=>{e.fillStyle=t.background,e.fillRect(0,0,l,c),Io(e,u,n,f.panel),e.save(),e.beginPath(),e.rect(f.panel.x,f.panel.y,f.panel.width,f.panel.height),e.clip();const p={coordSystem:a.coordSystem,panel:f.panel,compiled:a,theme:t,colorScheme:o,textMeasurer:g,formattingLocale:m};for(const b of a.layers){const y=Ce(b,a.coordSystem);y&&Dt(y,e,{...p,layer:b})}e.restore();for(const b of u){const y=f.axes[b.position];if(y){const S=d.getAestheticFromScaleAestheticKey(b.scaleAestheticKey);co(e,b,y,f.panel,s[S],i[S])}}for(const b of a.guides.axes){const y=f.axisLabels[b.position];y&&mo(e,b,y,r[d.getAestheticFromScaleAestheticKey(b.scaleAestheticKey)])}ko(e,h,f.legends,t),Bo(e,a.config.content,f.header,t,{width:l,height:c}),Po(e,a.config.content,f.footer,t,{width:l,height:c})};class xe extends Error{constructor(t){super(t),this.name="ChartConfigRenderError"}}const zo=async(e,t)=>{const o=Ne(e);if(!o.ok)throw new xe(o.reason);return $e(o.compiled,t)};exports.CANVAS_CAPABILITY_MATRIX=Ut;exports.CANVAS_SUPPORTED_GRAPH_TYPES=se;exports.CANVAS_UNSUPPORTED_GRAPH_TYPES=Pe;exports.ChartConfigRenderError=xe;exports.NodeCanvasTextMeasurer=Qe;exports.canRenderConfigWithCanvas=Ne;exports.darkTheme=Je;exports.ensureDefaultFonts=Ee;exports.lightTheme=Ze;exports.loadCanvasRuntime=Se;exports.parseChartConfig=Ie;exports.registerFont=ne;exports.renderChartConfigToPng=zo;exports.renderGraphToPng=Xo;
|
|
1
|
+
"use strict";var et=Object.create;var le=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var st=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ot(t))!rt.call(e,r)&&r!==o&&le(e,r,{get:()=>t[r],enumerable:!(n=tt(t,r))||n.enumerable});return e};var it=(e,t,o)=>(o=e!=null?et(nt(e)):{},st(t||!e||!e.__esModule?le(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("node:fs"),ye=require("node:module"),O=require("node:path"),at=require("node:url"),lt=require("@graphysdk/viz-engine/graph-config"),I=require("d3-shape"),c=require("@graphysdk/viz-engine"),dt=require("node:buffer");var _=typeof document<"u"?document.currentScript:null;let H,Q;const Se=()=>H?Promise.resolve(H):(Q??=import("@napi-rs/canvas").then(e=>(H=e,e)).catch(e=>{throw Q=void 0,e}),Q),V=()=>{if(!H)throw new Error("Canvas runtime is not loaded. Call loadCanvasRuntime() before rendering.");return H},E="Inter",J=new Set;let ce=!1,z=!1;const Te=e=>`${e.family}|${e.weight??400}|${e.style??"normal"}`,ne=e=>{const t=Te(e);J.has(t)||(V().GlobalFonts.register(e.data,e.family),J.add(t))},ct=[{file:"Inter-Regular.ttf",family:E,weight:400},{file:"Inter-SemiBold.ttf",family:E,weight:600}],ut=[{file:"inter-latin-400-normal.woff",family:E,weight:400},{file:"inter-latin-600-normal.woff",family:E,weight:600}],ft="@fontsource/inter",ht=()=>{try{const e=ye.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href),t=O.dirname(e.resolve("@graphysdk/node-renderer/package.json"));return O.join(t,"assets")}catch{return O.resolve(O.dirname(at.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href)),"../assets")}},Re=(e,t,o)=>{try{return de.existsSync(e)?(ne({family:t,data:de.readFileSync(e),weight:o}),!0):!1}catch{return!1}},gt=()=>{const e=ht();for(const{file:t,family:o,weight:n}of ct)Re(O.join(e,t),o,n)&&(z=!0)},mt=()=>{const e=ye.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index.cjs",document.baseURI).href);for(const{file:t,family:o,weight:n}of ut)if(!J.has(Te({family:o,data:Buffer.alloc(0),weight:n})))try{const r=e.resolve(`${ft}/files/${t}`);Re(r,o,n)&&(z=!0)}catch{}},Ee=()=>(ce||(ce=!0,gt(),mt()),z),C=(e,t)=>e.x+t*e.width,v=(e,t)=>e.y+(1-t)*e.height,$=e=>e==="catmull-rom"?I.curveCatmullRom:I.curveLinear,Le=e=>{switch(e){case"dashed":return[8,4];case"dotted":return[2,2];case"solid":return[]}},D=e=>e,At=(e,t)=>t!=="connect"?e:e.filter(o=>c.getX(o)!==null&&c.getY(o)!==null),bt=(e,t,o)=>{const n=$(t.interpolate),r=I.area().curve(n),s=I.line().curve(n);if(e.mainAxis==="y"){const i=a=>v(o,c.getY(a)??0),l=a=>C(o,c.getXMin(a)??0),d=a=>C(o,c.getXMax(a)??c.getX(a)??0);r.y(i).x0(l).x1(d),s.y(i).x(d)}else{const i=a=>C(o,c.getX(a)??0),l=a=>v(o,c.getYMin(a)??0),d=a=>v(o,c.getYMax(a)??c.getY(a)??0);r.x(i).y0(l).y1(d),s.x(i).y(d)}if(t.missingValues==="gap"){const i=l=>c.getX(l)!==null&&c.getY(l)!==null;r.defined(i),s.defined(i)}return{areaGenerator:r,lineGenerator:s}},pt=D({geom:"area",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const s=c.createStyleResolver({colorScheme:r}).geomReaders(t),{areaGenerator:i,lineGenerator:l}=bt(o,t.params,n),d=e;t.data.groupBy(c.GROUP_VARIABLES.group).forEach(a=>{const u=At([...a],t.params.missingValues),h=u[0];if(!h)return;const f=s.get("color",h),g=s.get("alpha",h),m=s.get("strokeWidth",h),p=Le(s.get("lineType",h));e.save(),e.globalAlpha=g,e.fillStyle=f,e.beginPath(),i.context(d)(u),e.fill(),e.restore(),e.save(),e.globalAlpha=s.get("strokeAlpha",h),e.strokeStyle=f,e.lineWidth=m,e.setLineDash(p),e.lineJoin="round",e.lineCap="round",e.beginPath(),l.context(d)(u),e.stroke(),e.restore()})}}),ue=(e,t,o,n,r,s)=>{const i=Math.max(0,Math.min(s.rx??s.ry??0,n/2)),l=Math.max(0,Math.min(s.ry??s.rx??0,r/2)),d=Math.PI/2;e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.ellipse(t+n-i,o+l,i,l,0,-d,0),e.lineTo(t+n,o+r-l),e.ellipse(t+n-i,o+r-l,i,l,0,0,d),e.lineTo(t+i,o+r),e.ellipse(t+i,o+r-l,i,l,0,d,Math.PI),e.lineTo(t,o+l),e.ellipse(t+i,o+l,i,l,0,Math.PI,Math.PI*1.5),e.closePath()},yt=D({geom:"bar",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const{Path2D:s}=V(),i=c.createStyleResolver({colorScheme:r}).geomReaders(t),l=o.mainAxis,d=new Map;for(const a of t.data){const u=c.getBarRectBounds(l,a);if(!u)continue;const h=C(n,u.x),f=n.y+u.y*n.height,g={x:h,y:f,width:u.width*n.width,height:u.height*n.height,fill:i.get("color",a),opacity:i.get("alpha",a)},m=c.buildColumnKey(l,u),p=d.get(m);p?p.bars.push(g):d.set(m,{bars:[g],style:{borderColor:i.get("borderColor",a),borderWidth:i.get("borderWidth",a),borderRadius:i.get("borderRadius",a),borderAlpha:i.get("alpha",a)}})}for(const{bars:a,style:u}of d.values()){const{borderColor:h,borderRadius:f,borderWidth:g,borderAlpha:m}=u,p=c.resolveBarBorderTreatment(g),b=f==="full"?void 0:c.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l});if(!(a.length>1)){const[A]=a;if(!A)continue;const w=b??c.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l,bounds:{width:A.width,height:A.height}}),L=new s;ue(L,A.x,A.y,A.width,A.height,w),e.save(),e.globalAlpha=A.opacity,e.fillStyle=A.fill,e.fill(L),h!==void 0&&(e.clip(L),e.strokeStyle=h,e.lineWidth=p.outlineWidth,e.stroke(L)),e.restore();continue}const S=c.getBoundingRect(a),R=b??c.resolveBarCornerRadiiPx({borderRadius:f,mainAxis:l,bounds:{width:S.width,height:S.height}}),T=new s;ue(T,S.x,S.y,S.width,S.height,R),e.save(),e.clip(T);for(const A of a)e.globalAlpha=A.opacity,e.fillStyle=A.fill,e.fillRect(A.x,A.y,A.width,A.height),h!==void 0&&(e.strokeStyle=h,e.lineWidth=p.separatorWidth,e.strokeRect(A.x,A.y,A.width,A.height));h!==void 0&&(e.globalAlpha=m,e.strokeStyle=h,e.lineWidth=p.outlineWidth,e.stroke(T)),e.restore()}}}),fe=(e,t)=>{const o=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());if(o?.[1]!==void 0){const r=o[1],s=r.length===3?[...r].map(a=>a+a).join(""):r.slice(0,6),i=Number.parseInt(s.slice(0,2),16),l=Number.parseInt(s.slice(2,4),16),d=Number.parseInt(s.slice(4,6),16);return`rgba(${i}, ${l}, ${d}, ${t})`}const n=/^rgba?\(([^)]+)\)$/i.exec(e.trim());if(n?.[1]!==void 0){const r=n[1].split(",").map(d=>d.trim()),[s,i,l]=r;if(s!==void 0&&i!==void 0&&l!==void 0)return`rgba(${s}, ${i}, ${l}, ${t})`}return t===0?"rgba(0, 0, 0, 0)":e},St=(e,t)=>t!=="connect"?e:e.filter(o=>c.getX(o)!==null&&c.getY(o)!==null),Tt=(e,t)=>{const{seriesObservations:o,fillGenerator:n,panel:r,color:s,fillAlpha:i}=t,l=o.map(a=>c.getY(a)).filter(a=>a!==null).map(a=>v(r,a));if(l.length===0)return;const d=e.createLinearGradient(0,Math.min(...l),0,r.y+r.height);d.addColorStop(0,s),d.addColorStop(.7,fe(s,0)),d.addColorStop(1,fe(s,0)),e.save(),e.globalAlpha=i,e.fillStyle=d,e.beginPath(),n.context(e)(o),e.fill(),e.restore()},Rt=D({geom:"line",coord:"cartesian",draw:(e,{layer:t,panel:o,colorScheme:n})=>{const r=c.createStyleResolver({colorScheme:n}).geomReaders(t),s=I.line().x(l=>C(o,c.getX(l)??0)).y(l=>v(o,c.getY(l)??0)).curve($(t.params.interpolate)),i=I.area().x(l=>C(o,c.getX(l)??0)).y0(o.y+o.height).y1(l=>v(o,c.getY(l)??0)).curve($(t.params.interpolate));if(t.params.missingValues==="gap"){const l=d=>c.getX(d)!==null&&c.getY(d)!==null;s.defined(l),i.defined(l)}t.data.groupBy(c.GROUP_VARIABLES.group).forEach(l=>{const d=St([...l],t.params.missingValues),a=d[0];if(!a)return;const u=r.get("strokeWidth",a),h=Le(r.get("lineType",a)),f=r.get("color",a),g=r.get("fillAlpha",a);g!==void 0&&Tt(e,{seriesObservations:d,fillGenerator:i,panel:o,color:f,fillAlpha:g}),e.save(),e.globalAlpha=r.get("alpha",a),e.strokeStyle=f,e.lineWidth=u,e.setLineDash(h),e.lineJoin="round",e.lineCap="round",e.beginPath(),s.context(e)(d),e.stroke(),e.restore()})}}),Et=D({geom:"point",coord:"cartesian",draw:(e,{layer:t,panel:o,colorScheme:n})=>{const r=c.createStyleResolver({colorScheme:n}).geomReaders(t);for(const s of t.data){const i=c.getX(s),l=c.getY(s);if(i===null||l===null)continue;const d=C(o,i),a=v(o,l),u=r.get("size",s)/2,h=r.get("borderWidth",s);e.save(),e.globalAlpha=r.get("alpha",s),e.fillStyle=r.get("color",s),e.strokeStyle=r.get("borderColor",s),e.lineWidth=h,e.beginPath(),e.arc(d,a,u,0,Math.PI*2),e.fill(),h>0&&e.stroke(),e.restore()}}}),re=11,Lt="sans-serif",wt=500,k=5,we=5,x=13,ve=6,K=12,he=21.6,vt=(e,t)=>{const o=e.mapping.y!==void 0,n=t.mainAxis==="y";return o!==n},_t=(e,t,o)=>{const n=c.getRuleDashPattern(t,o);e.setLineDash(n),n.length>0&&(e.lineCap="round")},Ct=(e,t)=>X(e)&&X(t)?`${e}: ${t}`:X(e)?e:X(t)?t:null,X=e=>e!=null&&e.trim()!=="",Bt=e=>{e.beginPath(),e.moveTo(2.48935,16.9323),e.lineTo(9.07098,9.82964),e.bezierCurveTo(9.51595,9.34944,9.51504,8.60728,9.0689,8.12818),e.lineTo(2.48866,1.06172),e.bezierCurveTo(1.85811,.384586,.974477,0,.049217,0),e.lineTo(0,0),e.lineTo(0,18),e.lineTo(.0443689,18),e.bezierCurveTo(.972463,18,1.85854,17.6131,2.48935,16.9323),e.closePath()},_e=(e,t,o,n,r,s)=>{const i=Math.min(s,n/2,r/2);e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.arcTo(t+n,o,t+n,o+i,i),e.lineTo(t+n,o+r-i),e.arcTo(t+n,o+r,t+n-i,o+r,i),e.lineTo(t+i,o+r),e.arcTo(t,o+r,t,o+r-i,i),e.lineTo(t,o+i),e.arcTo(t,o,t+i,o,i),e.closePath(),e.fill()},Pt=(e,t,o,n,r,s,i,l)=>{const d=o+k*2,a=re+we*2,u=n==="start",h=u?s.x:s.x+s.width,f=v(s,r),g=u?-x:-(d-x),m=u?g+d-k:g+k-K;e.save(),e.translate(h,f),e.translate(0,-a/2),e.fillStyle=i,_e(e,g,0,d,a,ve),e.save(),u||(e.translate(m+K/2,a/2),e.rotate(Math.PI),e.translate(-(m+K/2),-a/2)),e.translate(m,(a-he)/2),e.scale(K/10,he/18),e.fillStyle=i,Bt(e),e.fill(),e.restore(),e.fillStyle=l,e.textAlign="left",e.textBaseline="middle",e.fillText(t,g+k,a/2),e.restore()},It=(e,t,o,n,r,s,i,l)=>{const d=o+k*2,a=re+we*2,u=n==="start",h=C(s,r),f=u?s.y+s.height:s.y,g=u?-x:-8;e.save(),e.translate(h,f),e.translate(-d/2,0),e.fillStyle=i,_e(e,0,g,d,a,ve),e.fillStyle=l,e.textAlign="left",e.textBaseline="middle",e.fillText(t,k,g+a/2),e.restore()},Nt=D({geom:"rule",coord:"cartesian",draw:(e,{layer:t,coordSystem:o,panel:n,compiled:r,textMeasurer:s,formattingLocale:i,colorScheme:l})=>{const d=t.data.getFirst();if(!d)return;const a=vt(t,o),u=a?c.getY(d):c.getX(d);if(u===null)return;const h=c.createStyleResolver({colorScheme:l}).geomReaders(t),f=h.get("color",d),g=c.pickReadableTextColor(f),m=h.get("strokeWidth",d);if(e.save(),e.strokeStyle=f,e.lineWidth=m,_t(e,h.get("lineType",d),m),e.beginPath(),a){const T=v(n,u);e.moveTo(n.x,T),e.lineTo(n.x+n.width,T)}else{const T=C(n,u);e.moveTo(T,n.y),e.lineTo(T,n.y+n.height)}e.stroke(),e.restore();const p=Ct(t.params.label,c.formatRuleValue({guides:r.guides,numberFormat:r.config.numberFormat,layer:t,locale:i??r.config.parsingLocale}));if(p===null)return;const b=r.config.appearance.textScale,y={family:Lt,size:re*b,weight:wt};e.font=c.buildFontString(y);const S=s.measureText(p,y).width;(a?Pt:It)(e,p,S,t.params.labelPosition,u,n,f,g)}}),U=I.arc();U.digits(8);const kt=D({geom:"bar",coord:"polar",draw:(e,{layer:t,coordSystem:o,panel:n,colorScheme:r})=>{const s=n.x+n.width/2,i=n.y+n.height/2,l=Math.min(n.width,n.height)/2,{Path2D:d}=V(),a=c.createStyleResolver({colorScheme:r}).geomReaders(t);e.save(),e.translate(s,i),e.scale(l,l);const u=e,h=new Map;for(const f of t.data){const{startAngle:g,endAngle:m}=c.getAngleExtent(f),{innerRadius:p,outerRadius:b}=c.getRadiusExtent(f);if(g===null||m===null||p===null||b===null)continue;const y={startAngle:g,endAngle:m,innerRadius:p,outerRadius:b,fill:a.get("color",f),opacity:a.get("alpha",f)},S=c.buildSliceGroupKey(o.bandAxis,y),R=h.get(S);R?R.items.push(y):h.set(S,{items:[y],style:{borderColor:a.get("borderColor",f),borderWidth:a.get("borderWidth",f),borderRadius:a.get("borderRadius",f),borderAlpha:a.get("alpha",f)}})}for(const{items:f,style:g}of h.values()){const{borderColor:m,borderRadius:p,borderWidth:b,borderAlpha:y}=g,S=c.resolveBarBorderTreatment(b),R=m!==void 0&&l>0,T=c.getUnionExtent(f),A=c.resolvePolarBarCornerRadiusUnit(p,T.outerRadius-T.innerRadius),w=l>0&&(R||A>0);e.save();let L;w&&(L=new d,U.cornerRadius(A),U.context(L)(T),e.clip(L)),U.cornerRadius(0);for(const N of f)e.globalAlpha=N.opacity,e.fillStyle=N.fill,e.beginPath(),U.context(u)(N),e.fill(),R&&(e.strokeStyle=m,e.lineWidth=S.separatorWidth/l,e.stroke());R&&L&&(e.globalAlpha=y,e.strokeStyle=m,e.lineWidth=S.outlineWidth/l,e.stroke(L)),e.restore()}e.restore()}}),Ft={bar:{cartesian:yt,polar:kt},line:{cartesian:Rt},area:{cartesian:pt},point:{cartesian:Et},rule:{cartesian:Nt}},Ce=(e,t)=>Ft[e.geom]?.[t.type]??null,Dt=(e,t,o)=>{e.draw(t,o)};let ge;const Be=()=>(ge??=c.createCompiler(),ge),se=["line","areaStacked","bar","barStacked","barStackedFill","column","columnStacked","columnStackedFill","combo","pie","donut","scatter","bubble"],Pe=["funnel","heatmap","waterfall","mekko","table"],Ot=new Set(se),Ut={supportedGraphTypes:[...se],unsupportedGraphTypes:[...Pe],supportedGeoms:{cartesian:["bar","line","area","point","rule"],polar:["bar"]}},P=e=>({ok:!1,reason:e}),q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ht=e=>{if(!q(e))return!1;const{columns:t,rows:o}=e;return!Array.isArray(t)||!Array.isArray(o)?!1:t.every(n=>q(n)&&typeof n.key=="string")},Mt=e=>{if("_unstable_mapping"in e&&e._unstable_mapping!==void 0)return!0;const t=e.referenceLines;return q(t)?t.trendline!==void 0||t.averageLine!==void 0:!1},Ie=e=>{if(!q(e))return P("Chart config must be a plain object.");if(!Ht(e.data))return P("Chart config is missing a valid `data` object (columns + rows).");const{data:t,...o}=e;return{ok:!0,input:o,data:t}},Ne=e=>{const t=Ie(e);if(!t.ok)return t;if(Mt(e))return P("Canvas renderer does not support `_unstable_mapping`, `referenceLines.trendline`, or `referenceLines.averageLine`.");const o=t.input.type??"column";if(!Ot.has(o))return P(`Unsupported chart type for canvas rendering: ${o}.`);try{const n=Be(),r=lt.convertGraphConfig(t.input,t.data),s=n.compile({input:r,data:t.data});if(!s.ok)return P(`Chart config failed to compile: ${s.errors.map(i=>i.message).join("; ")}`);for(const i of s.compiled.layers)if(Ce(i,s.compiled.coordSystem)===null)return P(`No canvas geom renderer for ${i.geom} (${s.compiled.coordSystem.type} coord).`);return{ok:!0,compiled:s.compiled}}catch(n){const r=n instanceof Error?n.message:String(n);return P(`Chart config failed to compile: ${r}`)}},ke=E,M=12,ie=1.3,G=10,W=12,F=6,Fe=16,Gt=24,De=6,Oe=3,ee=4,Wt=8,Vt="#9ca3af",Ue=16,Kt=1.3,He=13,Xt=1.4,Me=12,Yt=1.4,j=8,ae=12,zt=1.3,qt=200,jt=120,Qt=80,Ge=22,Zt=9,Jt=11,$t=10,Y=9,me=12,xt='-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif',eo=11.5,to=550,oo={light:.55,mid:.75,dark:.08},no={light:.62,mid:.8,dark:.85},ro=.22,so=.65,io={family:ke,size:M},ao=[2,3],lo=[1,3],te=e=>{switch(e){case"dashed":return ao;case"dotted":return lo;case"solid":return[]}},co=(e,t,o,n,r,s)=>{if(!t.isVisible||t.ticks.length===0)return;const i=t.position==="bottom"||t.position==="top";e.save(),e.font=c.buildFontString(c.toFontSpec(r,E)),e.fillStyle=r.textColor,e.strokeStyle=s.color,e.lineWidth=s.strokeWidth,e.setLineDash(te(s.lineType));for(const l of t.ticks){const d=i?l.position:1-l.position;t.ticksVisible&&fo(e,t.position,d,o,n,s.length),go(e,t.position,d,o,n,l.formattedLabel,t.labelRotation,r.offset)}e.restore()},uo=(e,t,o,n,r)=>{if(e==="bottom"||e==="top"){const d=n.x+t*n.width,a=e==="top"?o.y+o.height:o.y,u=e==="top"?-r:r;return{x1:d,y1:a,x2:d,y2:a+u}}const s=n.y+t*n.height,i=e==="right"?o.x:o.x+o.width,l=e==="right"?r:-r;return{x1:i,y1:s,x2:i+l,y2:s}},fo=(e,t,o,n,r,s)=>{const{x1:i,y1:l,x2:d,y2:a}=uo(t,o,n,r,s);e.beginPath(),e.moveTo(i,l),e.lineTo(d,a),e.stroke()},ho=(e,t,o,n,r)=>{if(e==="bottom"||e==="top"){const i=n.x+t*n.width;return e==="bottom"?{x:i,y:o.y+r,textAlign:"center",textBaseline:"top"}:{x:i,y:o.y+o.height-r,textAlign:"center",textBaseline:"alphabetic"}}const s=n.y+t*n.height;return e==="left"?{x:o.x+o.width-r,y:s,textAlign:"right",textBaseline:"middle"}:{x:o.x+r,y:s,textAlign:"left",textBaseline:"middle"}},go=(e,t,o,n,r,s,i,l)=>{if(i!==0&&(t==="top"||t==="bottom")){const a=r.x+o*r.width,u=t==="top";e.save(),e.translate(a,u?n.y+n.height-l:n.y+l),e.rotate(i*Math.PI/180),e.textAlign=u?"left":"right",e.textBaseline="middle",e.fillText(s,0,0),e.restore();return}const d=ho(t,o,n,r,l);e.textAlign=d.textAlign,e.textBaseline=d.textBaseline,e.fillText(s,d.x,d.y)},mo=(e,t,o,n)=>{if(!t.isVisible||!t.label)return;e.save(),e.font=c.buildFontString({family:n.fontFamily??E,size:n.fontSize,weight:n.fontWeight}),e.fillStyle=n.textColor,e.textBaseline="middle";const{x:r,y:s,alignment:i}=Ao(t.position,o);e.textAlign=i,e.fillText(t.label,r,s),e.restore()},Ao=(e,t)=>{const o=t.y+t.height/2;return e==="left"?{x:t.x,y:o,alignment:"start"}:e==="right"?{x:t.x+t.width,y:o,alignment:"end"}:{x:t.x+t.width/2,y:o,alignment:"center"}},bo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABgCAYAAAC65+QhAAAKo0lEQVR42u2de4wdVR3HPzN32+oSUQSsikEoosR3iko08oovEkwMpmiIr/KHIomgUYyPiBofkRjjE+MjEk3RQNIYTdUotKkoaql0Wyympbtl2XbLtrW71n3v3ntnrn+c38n98cvcOzP3tfcud5LJ5u7Ozpz5nt/7nN/3QncfAVBQn18LfBd4GJgFYvm5B/iW/N0fBfn/VX9ogF4K3A0sAhV1xubzIrBFrk+6z6oDyEvCmcBXgTkFRgkoA5E6y/J7f80s8GXg2Uoyw9UCUGhm/wPAYQNQJFJkJUmDpgEbkfusCnW0dujNwM4aAEVGak4aaYvVdRqwHcAbexkwDdCLgZ8mqJgFaBo4BowD/wQOAbuBCSNhsVHJGPgJ8KJesl+hshnPBD4LTKqXLCUANAPsF0CKRvWm5W+Pi6RZw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luUx5B18AAAAASUVORK5CYII=",B=Ge;let Z;const po=()=>{if(Z)return Z;const{Image:e}=V(),t=new e,o=bo.replace(/^data:image\/png;base64,/,"");return t.src=dt.Buffer.from(o,"base64"),Z=t,t},We=(e,t,o="full")=>!e||t.width<jt||t.height<Qt?"hidden":t.width<qt||o==="mini"?"mini":"full",yo=e=>{const t=So(e);if(t===null)return"light";const o=To(t);return o<=ro?"dark":o<=so?"mid":"light"},oe=(e,t,o)=>e.placement!==o||We(e.enabled,t,e.variant)==="hidden"?0:Ge,Ve=(e,t,o,n,r,s)=>{if(t.placement!==s)return;const i=We(t.enabled,r,t.variant);if(i==="hidden")return;const l=yo(n.background),d=l==="dark",a={family:xt,size:eo,weight:400},u={...a,weight:to};let h=0;i==="full"&&(e.font=c.buildFontString(a),h=e.measureText("Made with ").width,e.font=c.buildFontString(u),h+=e.measureText("Graphy").width);const f=i==="mini"?0:Zt,g=i==="mini"?0:Jt,m=i==="mini"?0:$t,p=i==="mini"?B:f+Y+m+h+g,b=o.x+o.width-p,y=o.y+Math.max(0,(o.height||B)/2-B/2);e.save(),e.globalAlpha=no[l],e.textBaseline="middle",e.textAlign="left",d||(e.shadowColor="rgba(0, 0, 0, 0.09)",e.shadowBlur=4,e.shadowOffsetY=1),e.beginPath(),e.roundRect(b,y,p,B,B/2),e.fillStyle=`rgba(255, 255, 255, ${oo[l]})`,e.fill(),e.shadowColor="transparent",e.shadowBlur=0,e.shadowOffsetY=0;const S=d?"#FFFFFF":"#2A2A28",R=i==="mini"?b+(p-Y)/2:b+f,T=y+(B-me)/2;if(e.save(),d&&(e.filter="invert(1)"),e.drawImage(po(),R,T,Y,me),e.restore(),i==="full"){const A=b+f+Y+m,w=y+B/2;e.fillStyle=S,e.font=c.buildFontString(a),e.fillText("Made with ",A,w);const L=e.measureText("Made with ").width;e.font=c.buildFontString(u),e.fillText("Graphy",A+L,w)}e.restore()},So=e=>{const t=e.trim();if(!t.startsWith("#"))return null;const o=t.slice(1);if(o.length===3){const n=o[0],r=o[1],s=o[2];return n===void 0||r===void 0||s===void 0?null:{red:Number.parseInt(n+n,16),green:Number.parseInt(r+r,16),blue:Number.parseInt(s+s,16)}}return o.length>=6?{red:Number.parseInt(o.slice(0,2),16),green:Number.parseInt(o.slice(2,4),16),blue:Number.parseInt(o.slice(4,6),16)}:null},To=({red:e,green:t,blue:o})=>{const n=r=>{const s=r/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*n(e)+.7152*n(t)+.0722*n(o)},Ro={family:E,size:Ue,weight:600},Eo={family:E,size:He},Lo={family:E,size:Me},wo={family:E,size:ae,weight:500},vo={family:E,size:ae},Ke=Ue*Kt,_o=He*Xt,Xe=Me*Yt,Ye=ae*zt,ze=e=>{if(e===null)return null;if(e.label!==void 0&&e.label!=="")return e.label;if(e.url!==void 0&&e.url!==""&&c.isSafeUrl(e.url))try{return new URL(e.url).hostname}catch{return e.url}return null},Co=(e,t)=>{let o=0;const n=e.isTitleVisible&&e.title!==null,r=e.isSubtitleVisible&&e.subtitle!==null;n&&(o+=Ke),r&&(o>0&&(o+=j),o+=_o);const s=oe(e.brandMark,t,"header");!n&&!r&&s>0&&(o=s);const i=e.isCaptionVisible&&e.caption!==null,l=e.isSourceVisible&&ze(e.source)!==null,d=oe(e.brandMark,t,"footer");let a=0;return i&&(a+=Xe),(l||d>0)&&(a>0&&(a+=j),a+=Math.max(Ye,d)),{headerHeight:o,footerHeight:a}},Bo=(e,t,o,n,r)=>{if(o.height===0)return;e.save(),e.textBaseline="top",e.textAlign="left";let s=o.y;t.isTitleVisible&&t.title!==null&&(e.font=c.buildFontString(Ro),e.fillStyle=n.textPrimary,e.fillText(c.extractPlainText(t.title),o.x,s),s+=Ke+j),t.isSubtitleVisible&&t.subtitle!==null&&(e.font=c.buildFontString(Eo),e.fillStyle=n.textSecondary,e.fillText(c.extractPlainText(t.subtitle),o.x,s)),e.restore(),Ve(e,t.brandMark,o,n,r,"header")},Po=(e,t,o,n,r)=>{if(o.height===0)return;const s=t.isCaptionVisible?t.caption:null,i=t.isSourceVisible?ze(t.source):null,l=oe(t.brandMark,r,"footer");if(s===null&&i===null&&l===0)return;e.save(),e.textBaseline="top",e.textAlign="left";let d=o.y;if(s!==null&&(e.font=c.buildFontString(Lo),e.fillStyle=n.textSecondary,e.fillText(c.extractPlainText(s),o.x,d),d+=Xe+j),i!==null){let a=o.x;a=Ae(e,"Source: ",wo,n.textSecondary,a,d),Ae(e,i,vo,n.textSecondary,a,d)}e.restore(),Ve(e,t.brandMark,{x:o.x,y:d,width:o.width,height:Math.max(Ye,l)},n,r,"footer")},Ae=(e,t,o,n,r,s)=>(e.font=c.buildFontString(o),e.fillStyle=n,e.fillText(t,r,s),r+e.measureText(t).width),Io=(e,t,o,n)=>{e.save(),e.lineCap="round";for(const r of c.computePanelBorderPaths(c.resolvePanelBorderStyle(o),n))e.strokeStyle=r.color,e.lineWidth=r.strokeWidth,e.setLineDash(te(r.lineType)),No(e,r.segments),e.stroke();for(const r of t){if(!r.gridVisible)continue;const s=r.position==="top"||r.position==="bottom",i=c.resolveGridLineStyle(o,c.getAestheticFromScaleAestheticKey(r.scaleAestheticKey));e.strokeStyle=i.color,e.lineWidth=i.strokeWidth,e.setLineDash(te(i.lineType));for(const l of r.ticks){if(l.position<=0||l.position>=1)continue;const d=s?l.position:1-l.position;if(e.beginPath(),s){const a=n.x+d*n.width;e.moveTo(a,n.y),e.lineTo(a,n.y+n.height)}else{const a=n.y+d*n.height;e.moveTo(n.x,a),e.lineTo(n.x+n.width,a)}e.stroke()}}e.restore()},No=(e,t)=>{e.beginPath();for(const o of t)switch(o.type){case"move":e.moveTo(o.x,o.y);break;case"line":e.lineTo(o.x,o.y);break;case"arc":e.arc(o.cx,o.cy,o.radius,o.startAngle,o.endAngle);break;case"close":e.closePath();break}},ko=(e,t,o,n)=>{e.save(),e.font=c.buildFontString(io),e.textBaseline="middle";for(const s of t)s.display==="direct"&&Fo(e,s,o,n);const r=new Map;for(const s of t){if(s.display!=="pill"||s.items.length===0)continue;const i=r.get(s.position);i?i.push(s):r.set(s.position,[s])}for(const[s,i]of r){const l=o[s];l&&(s==="top"||s==="bottom"?Do(e,i,l,n):Oo(e,i,l,n))}e.restore()},Fo=(e,t,o,n)=>{const r=o[t.position];if(r){e.textAlign="left";for(const s of t.items)s.normalizedY!==null&&(e.fillStyle=typeof s.visual.color=="string"?s.visual.color:n.textPrimary,e.fillText(s.formattedLabel,r.x+Wt,v(r,s.normalizedY)))}},Do=(e,t,o,n)=>{const r=qe(t),s=r.reduce((a,u,h)=>a+Ho(u)+e.measureText(u.label).width+(h===0?0:be(u)),0),i=M*ie;let l=o.x+Math.max(0,(o.width-s)/2);const d=o.y+De+Math.max(i,W)/2;for(let a=0;a<r.length;a++){const u=r[a];u&&(a>0&&(l+=be(u)),l=je(e,u,l,d,n))}},Oo=(e,t,o,n)=>{const r=qe(t),s=Math.max(M*ie,W),i=4,l=r.length*s+Math.max(0,r.length-1)*i;let d=o.y+Math.max(0,(o.height-l)/2)+s/2;for(const a of r)je(e,a,o.x,d,n),d+=s+i},qe=e=>{const t=[];for(const o of e){const n=o.aesthetics.includes("size");o.items.forEach((r,s)=>{const i=r.visual.size,l=n&&typeof i=="number"&&Number.isFinite(i)&&i>0?i:void 0;t.push({label:r.formattedLabel,colors:Uo(r.visual.color),bubbleSize:l,isFirstInGroup:s===0})})}return t},Uo=e=>typeof e=="string"?[e]:Array.isArray(e)?e.filter(t=>typeof t=="string"):[],be=e=>e.isFirstInGroup?Gt:Fe,Ho=e=>{if(e.bubbleSize!==void 0)return e.bubbleSize+F;const t=e.colors.length;if(t===0)return 0;if(t===1)return G+F;const o=Math.min(t,Oe);return G+(o-1)*ee+F},je=(e,t,o,n,r)=>{let s=o;if(t.bubbleSize!==void 0){const i=t.bubbleSize/2;e.fillStyle=t.colors[0]??Vt,e.beginPath(),e.arc(s+i,n,i,0,Math.PI*2),e.fill(),s+=t.bubbleSize+F}else if(t.colors.length>0){const i=t.colors.slice(0,Oe);for(let l=0;l<i.length;l++){const d=i[l];d&&(e.fillStyle=d,e.fillRect(s+l*ee,n-W/2,G,W))}s+=G+(i.length-1)*ee+F}return e.fillStyle=r.textPrimary,e.textAlign="left",e.fillText(t.label,s,n),s+e.measureText(t.label).width},pe=(e,t)=>Math.min(Math.max(...e),t),Mo=(e,t,o)=>n=>{if(!n.isVisible||n.ticks.length===0)return 0;const r=n.position==="top"||n.position==="bottom",s=c.getAestheticFromScaleAestheticKey(n.scaleAestheticKey),{offset:i,...l}=t[s],d=n.ticksVisible?Math.max(i,o[s].length):i,a=c.toFontSpec(l,E),u=n.ticks.map(g=>e.measureText(g.formattedLabel,a)),h=n.labelMaxWidthPx??Number.POSITIVE_INFINITY;if(r){if(n.labelRotation!==0){const g=u.map(m=>m.width);return pe(g,h)+2*d}return Math.max(...u.map(g=>g.height))+d}const f=u.map(g=>g.width);return pe(f,h)+d},Go=e=>t=>{if(t.items.length===0)return 0;const o={family:ke,size:M};if(t.position==="top"||t.position==="bottom"){const s=M*ie;return Math.max(s,W)+De*2}const r=t.items.map(s=>{const i=e.measureText(s.formattedLabel,o).width;return G+F+i});return Math.max(...r)+Fe},Wo=e=>(t,o)=>e.measureText(t,c.toFontSpec(o,E)),Vo=(e,t)=>(o,n,r)=>{const s=t[o][n],i=e.measureText(r,c.toFontSpec(s,E));return{...i,width:i.width+s.paddingInline*2,height:i.height+s.paddingBlock*2}},Ko=({textMeasurer:e,axisLabelStyles:t,dataLabelStyles:o,tickLabelStyles:n,tickLineStyles:r})=>({measureAxis:Mo(e,n,r),measureAxisLabel:s=>c.computeLineBoxHeight(t[c.getAestheticFromScaleAestheticKey(s.scaleAestheticKey)]),measureLegend:Go(e),measureTickLabel:(s,i)=>e.measureText(s,c.toFontSpec(n[i],E)),measureDifferenceArrowLabel:Wo(e),measureDataLabel:Vo(e,o),measureHeadline:()=>({width:0,height:0}),measureHeadlineItemWidths:()=>[]});class Qe{constructor(){this.currentFont="";const t=V().createCanvas(1,1);this.ctx=t.getContext("2d")}measureText(t,o){const n=c.buildFontString(o);this.currentFont!==n&&(this.ctx.font=n,this.currentFont=n);const r=this.ctx.measureText(t);return{width:r.width,height:r.fontBoundingBoxAscent+r.fontBoundingBoxDescent,ascent:r.fontBoundingBoxAscent,descent:r.fontBoundingBoxDescent}}}const Ze={background:"#ffffff",textPrimary:"#111827",textSecondary:"#6b7280",gridLine:"#e5e7eb",legendPillBackground:"rgba(0, 0, 0, 0.04)",legendPillBorder:"rgba(0, 0, 0, 0.08)"},Je={background:"#0b0f17",textPrimary:"#e5e7eb",textSecondary:"#9ca3af",gridLine:"#1f2937",legendPillBackground:"rgba(255, 255, 255, 0.06)",legendPillBorder:"rgba(255, 255, 255, 0.12)"},Xo=async({input:e,data:t},o)=>{const r=Be().compile({input:e,data:t});if(!r.ok)throw new Error(`Failed to compile graph spec: ${r.errors.map(s=>s.message).join("; ")}`);return $e(r.compiled,o)},$e=async(e,t)=>{const{Canvas:o}=await Se();if(Ee(),t.fonts)for(const w of t.fonts)ne(w);const n=c.formatLegends({legends:e.guides.legends.drawn,numberFormat:e.config.numberFormat,parsingLocale:e.config.parsingLocale,formattingLocale:t.formattingLocale}),r={width:t.width,height:t.height},{headerHeight:s,footerHeight:i}=Co(e.config.content,r),l={headerSize:{width:t.width,height:s},footerSize:{width:t.width,height:i}},d=t.colorScheme??"light",a=c.createStyleResolver({colorScheme:d}).chromeReaders(e.chrome),u=e.config.appearance.textScale,h={x:c.resolveAxisLabelStyle(a,"x",u),y:c.resolveAxisLabelStyle(a,"y",u)},f={x:c.resolveTickLabelStyle(a,"x",u),y:c.resolveTickLabelStyle(a,"y",u)},g={x:c.resolveTickLineStyle(a,"x"),y:c.resolveTickLineStyle(a,"y")},m={};for(const w of c.DATA_LABEL_ROLES){const L={};for(const N of c.DATA_LABEL_POSITIONS)L[N]=c.resolveDataLabelStyle(a,w,N,u);m[w]=L}const p=new Qe,b=Ko({textMeasurer:p,axisLabelStyles:h,dataLabelStyles:m,tickLabelStyles:f,tickLineStyles:g}),{layout:y,formattedAxes:S}=new c.LayoutCompiler(b).compile({axes:e.guides.axes,numberFormat:e.config.numberFormat,parsingLocale:e.config.parsingLocale,formattedLegends:n,containerSize:{width:t.width,height:t.height},externalMeasurements:l,formattingLocale:t.formattingLocale,layout:e.config.layout}),R=t.pixelRatio??2,T=new o(t.width*R,t.height*R),A=T.getContext("2d");return A.scale(R,R),Yo({ctx:A,theme:d==="dark"?Je:Ze,colorScheme:d,chromeReaders:a,axisLabelStyles:h,tickLabelStyles:f,tickLineStyles:g,width:t.width,height:t.height,compiled:e,formattedAxes:S,formattedLegends:n,layout:y,textMeasurer:p,...t.formattingLocale===void 0?{}:{formattingLocale:t.formattingLocale}}),T.encode("png")},Yo=({ctx:e,theme:t,colorScheme:o,chromeReaders:n,axisLabelStyles:r,tickLabelStyles:s,tickLineStyles:i,width:l,height:d,compiled:a,formattedAxes:u,formattedLegends:h,layout:f,textMeasurer:g,formattingLocale:m})=>{e.fillStyle=t.background,e.fillRect(0,0,l,d),Io(e,u,n,f.panel),e.save(),e.beginPath(),e.rect(f.panel.x,f.panel.y,f.panel.width,f.panel.height),e.clip();const p={coordSystem:a.coordSystem,panel:f.panel,compiled:a,theme:t,colorScheme:o,textMeasurer:g,formattingLocale:m};for(const b of a.layers){const y=Ce(b,a.coordSystem);y&&Dt(y,e,{...p,layer:b})}e.restore();for(const b of u){const y=f.axes[b.position];if(y){const S=c.getAestheticFromScaleAestheticKey(b.scaleAestheticKey);co(e,b,y,f.panel,s[S],i[S])}}for(const b of a.guides.axes){const y=f.axisLabels[b.position];y&&mo(e,b,y,r[c.getAestheticFromScaleAestheticKey(b.scaleAestheticKey)])}ko(e,h,f.legends,t),Bo(e,a.config.content,f.header,t,{width:l,height:d}),Po(e,a.config.content,f.footer,t,{width:l,height:d})};class xe extends Error{constructor(t){super(t),this.name="ChartConfigRenderError"}}const zo=async(e,t)=>{const o=Ne(e);if(!o.ok)throw new xe(o.reason);return $e(o.compiled,t)};exports.CANVAS_CAPABILITY_MATRIX=Ut;exports.CANVAS_SUPPORTED_GRAPH_TYPES=se;exports.CANVAS_UNSUPPORTED_GRAPH_TYPES=Pe;exports.ChartConfigRenderError=xe;exports.NodeCanvasTextMeasurer=Qe;exports.canRenderConfigWithCanvas=Ne;exports.darkTheme=Je;exports.ensureDefaultFonts=Ee;exports.lightTheme=Ze;exports.loadCanvasRuntime=Se;exports.parseChartConfig=Ie;exports.registerFont=ne;exports.renderChartConfigToPng=zo;exports.renderGraphToPng=Xo;
|
package/dist/index.mjs
CHANGED
|
@@ -4,27 +4,27 @@ import H from "node:path";
|
|
|
4
4
|
import { fileURLToPath as nt } from "node:url";
|
|
5
5
|
import { convertGraphConfig as rt } from "@graphysdk/viz-engine/graph-config";
|
|
6
6
|
import { curveCatmullRom as st, curveLinear as it, area as Re, line as we, arc as at } from "d3-shape";
|
|
7
|
-
import { createStyleResolver as P, GROUP_VARIABLES as Be, getX as v, getY as B, getXMin as lt, getXMax as dt, getYMin as ct, getYMax as ft, getBarRectBounds as ut, buildColumnKey as ht, resolveBarBorderTreatment as ve, resolveBarCornerRadiiPx as $, getBoundingRect as gt, getRuleDashPattern as mt, pickReadableTextColor as pt, formatRuleValue as At, buildFontString as R, getAngleExtent as bt, getRadiusExtent as yt, buildSliceGroupKey as Tt, getUnionExtent as St, resolvePolarBarCornerRadiusUnit as Et, createCompiler as Lt, toFontSpec as
|
|
8
|
-
import { Buffer as
|
|
7
|
+
import { createStyleResolver as P, GROUP_VARIABLES as Be, getX as v, getY as B, getXMin as lt, getXMax as dt, getYMin as ct, getYMax as ft, getBarRectBounds as ut, buildColumnKey as ht, resolveBarBorderTreatment as ve, resolveBarCornerRadiiPx as $, getBoundingRect as gt, getRuleDashPattern as mt, pickReadableTextColor as pt, formatRuleValue as At, buildFontString as R, getAngleExtent as bt, getRadiusExtent as yt, buildSliceGroupKey as Tt, getUnionExtent as St, resolvePolarBarCornerRadiusUnit as Et, createCompiler as Lt, toFontSpec as z, isSafeUrl as Rt, extractPlainText as te, computePanelBorderPaths as wt, resolvePanelBorderStyle as Bt, resolveGridLineStyle as vt, getAestheticFromScaleAestheticKey as U, computeLineBoxHeight as _t, formatLegends as Ct, resolveAxisLabelStyle as fe, resolveTickLabelStyle as ue, resolveTickLineStyle as he, DATA_LABEL_ROLES as Nt, DATA_LABEL_POSITIONS as It, resolveDataLabelStyle as Pt, LayoutCompiler as kt } from "@graphysdk/viz-engine";
|
|
8
|
+
import { Buffer as Dt } from "node:buffer";
|
|
9
9
|
let G, x;
|
|
10
|
-
const
|
|
10
|
+
const Ot = () => G ? Promise.resolve(G) : (x ??= import("@napi-rs/canvas").then((e) => (G = e, e)).catch((e) => {
|
|
11
11
|
throw x = void 0, e;
|
|
12
|
-
}), x),
|
|
12
|
+
}), x), X = () => {
|
|
13
13
|
if (!G)
|
|
14
14
|
throw new Error("Canvas runtime is not loaded. Call loadCanvasRuntime() before rendering.");
|
|
15
15
|
return G;
|
|
16
16
|
}, E = "Inter", oe = /* @__PURE__ */ new Set();
|
|
17
|
-
let ge = !1,
|
|
17
|
+
let ge = !1, Q = !1;
|
|
18
18
|
const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce = (e) => {
|
|
19
19
|
const t = _e(e);
|
|
20
|
-
oe.has(t) || (
|
|
21
|
-
},
|
|
20
|
+
oe.has(t) || (X().GlobalFonts.register(e.data, e.family), oe.add(t));
|
|
21
|
+
}, Ft = [
|
|
22
22
|
{ file: "Inter-Regular.ttf", family: E, weight: 400 },
|
|
23
23
|
{ file: "Inter-SemiBold.ttf", family: E, weight: 600 }
|
|
24
|
-
],
|
|
24
|
+
], Ht = [
|
|
25
25
|
{ file: "inter-latin-400-normal.woff", family: E, weight: 400 },
|
|
26
26
|
{ file: "inter-latin-600-normal.woff", family: E, weight: 600 }
|
|
27
|
-
],
|
|
27
|
+
], Mt = "@fontsource/inter", Gt = () => {
|
|
28
28
|
try {
|
|
29
29
|
const e = Le(import.meta.url), t = H.dirname(e.resolve("@graphysdk/node-renderer/package.json"));
|
|
30
30
|
return H.join(t, "assets");
|
|
@@ -41,20 +41,20 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
41
41
|
} catch {
|
|
42
42
|
return !1;
|
|
43
43
|
}
|
|
44
|
+
}, Ut = () => {
|
|
45
|
+
const e = Gt();
|
|
46
|
+
for (const { file: t, family: o, weight: n } of Ft)
|
|
47
|
+
Ne(H.join(e, t), o, n) && (Q = !0);
|
|
44
48
|
}, Wt = () => {
|
|
45
|
-
const e = Ut();
|
|
46
|
-
for (const { file: t, family: o, weight: n } of Ht)
|
|
47
|
-
Ne(H.join(e, t), o, n) && (j = !0);
|
|
48
|
-
}, Vt = () => {
|
|
49
49
|
const e = Le(import.meta.url);
|
|
50
|
-
for (const { file: t, family: o, weight: n } of
|
|
50
|
+
for (const { file: t, family: o, weight: n } of Ht)
|
|
51
51
|
if (!oe.has(_e({ family: o, data: Buffer.alloc(0), weight: n })))
|
|
52
52
|
try {
|
|
53
|
-
const s = e.resolve(`${
|
|
54
|
-
Ne(s, o, n) && (
|
|
53
|
+
const s = e.resolve(`${Mt}/files/${t}`);
|
|
54
|
+
Ne(s, o, n) && (Q = !0);
|
|
55
55
|
} catch {
|
|
56
56
|
}
|
|
57
|
-
},
|
|
57
|
+
}, Vt = () => (ge || (ge = !0, Ut(), Wt()), Q), C = (e, t) => e.x + t * e.width, _ = (e, t) => e.y + (1 - t) * e.height, ne = (e) => e === "catmull-rom" ? st : it, Ie = (e) => {
|
|
58
58
|
switch (e) {
|
|
59
59
|
case "dashed":
|
|
60
60
|
return [8, 4];
|
|
@@ -63,7 +63,7 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
63
63
|
case "solid":
|
|
64
64
|
return [];
|
|
65
65
|
}
|
|
66
|
-
}, F = (e) => e,
|
|
66
|
+
}, F = (e) => e, Kt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), zt = (e, t, o) => {
|
|
67
67
|
const n = ne(t.interpolate), s = Re().curve(n), r = we().curve(n);
|
|
68
68
|
if (e.mainAxis === "y") {
|
|
69
69
|
const i = (a) => _(o, B(a) ?? 0), l = (a) => C(o, lt(a) ?? 0), d = (a) => C(o, dt(a) ?? v(a) ?? 0);
|
|
@@ -77,13 +77,13 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
77
77
|
s.defined(i), r.defined(i);
|
|
78
78
|
}
|
|
79
79
|
return { areaGenerator: s, lineGenerator: r };
|
|
80
|
-
},
|
|
80
|
+
}, Xt = F({
|
|
81
81
|
geom: "area",
|
|
82
82
|
coord: "cartesian",
|
|
83
83
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
84
|
-
const r = P({ colorScheme: s }).geomReaders(t), { areaGenerator: i, lineGenerator: l } =
|
|
84
|
+
const r = P({ colorScheme: s }).geomReaders(t), { areaGenerator: i, lineGenerator: l } = zt(o, t.params, n), d = e;
|
|
85
85
|
t.data.groupBy(Be.group).forEach((a) => {
|
|
86
|
-
const c =
|
|
86
|
+
const c = Kt([...a], t.params.missingValues), u = c[0];
|
|
87
87
|
if (!u) return;
|
|
88
88
|
const f = r.get("color", u), h = r.get("alpha", u), g = r.get("strokeWidth", u), A = Ie(r.get("lineType", u));
|
|
89
89
|
e.save(), e.globalAlpha = h, e.fillStyle = f, e.beginPath(), i.context(d)(c), e.fill(), e.restore(), e.save(), e.globalAlpha = r.get("strokeAlpha", u), e.strokeStyle = f, e.lineWidth = g, e.setLineDash(A), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), l.context(d)(c), e.stroke(), e.restore();
|
|
@@ -92,11 +92,11 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
92
92
|
}), me = (e, t, o, n, s, r) => {
|
|
93
93
|
const i = Math.max(0, Math.min(r.rx ?? r.ry ?? 0, n / 2)), l = Math.max(0, Math.min(r.ry ?? r.rx ?? 0, s / 2)), d = Math.PI / 2;
|
|
94
94
|
e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.ellipse(t + n - i, o + l, i, l, 0, -d, 0), e.lineTo(t + n, o + s - l), e.ellipse(t + n - i, o + s - l, i, l, 0, 0, d), e.lineTo(t + i, o + s), e.ellipse(t + i, o + s - l, i, l, 0, d, Math.PI), e.lineTo(t, o + l), e.ellipse(t + i, o + l, i, l, 0, Math.PI, Math.PI * 1.5), e.closePath();
|
|
95
|
-
},
|
|
95
|
+
}, Yt = F({
|
|
96
96
|
geom: "bar",
|
|
97
97
|
coord: "cartesian",
|
|
98
98
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
99
|
-
const { Path2D: r } =
|
|
99
|
+
const { Path2D: r } = X(), i = P({ colorScheme: s }).geomReaders(t), l = o.mainAxis, d = /* @__PURE__ */ new Map();
|
|
100
100
|
for (const a of t.data) {
|
|
101
101
|
const c = ut(l, a);
|
|
102
102
|
if (!c) continue;
|
|
@@ -147,12 +147,12 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
147
147
|
return `rgba(${r}, ${i}, ${l}, ${t})`;
|
|
148
148
|
}
|
|
149
149
|
return t === 0 ? "rgba(0, 0, 0, 0)" : e;
|
|
150
|
-
},
|
|
150
|
+
}, qt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), jt = (e, t) => {
|
|
151
151
|
const { seriesObservations: o, fillGenerator: n, panel: s, color: r, fillAlpha: i } = t, l = o.map((a) => B(a)).filter((a) => a !== null).map((a) => _(s, a));
|
|
152
152
|
if (l.length === 0) return;
|
|
153
153
|
const d = e.createLinearGradient(0, Math.min(...l), 0, s.y + s.height);
|
|
154
154
|
d.addColorStop(0, r), d.addColorStop(0.7, pe(r, 0)), d.addColorStop(1, pe(r, 0)), e.save(), e.globalAlpha = i, e.fillStyle = d, e.beginPath(), n.context(e)(o), e.fill(), e.restore();
|
|
155
|
-
},
|
|
155
|
+
}, Qt = F({
|
|
156
156
|
geom: "line",
|
|
157
157
|
coord: "cartesian",
|
|
158
158
|
draw: (e, { layer: t, panel: o, colorScheme: n }) => {
|
|
@@ -162,13 +162,13 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
162
162
|
r.defined(l), i.defined(l);
|
|
163
163
|
}
|
|
164
164
|
t.data.groupBy(Be.group).forEach((l) => {
|
|
165
|
-
const d =
|
|
165
|
+
const d = qt([...l], t.params.missingValues), a = d[0];
|
|
166
166
|
if (!a) return;
|
|
167
167
|
const c = s.get("strokeWidth", a), u = Ie(s.get("lineType", a)), f = s.get("color", a), h = s.get("fillAlpha", a);
|
|
168
|
-
h !== void 0 &&
|
|
168
|
+
h !== void 0 && jt(e, { seriesObservations: d, fillGenerator: i, panel: o, color: f, fillAlpha: h }), e.save(), e.globalAlpha = s.get("alpha", a), e.strokeStyle = f, e.lineWidth = c, e.setLineDash(u), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), r.context(e)(d), e.stroke(), e.restore();
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
}),
|
|
171
|
+
}), Zt = F({
|
|
172
172
|
geom: "point",
|
|
173
173
|
coord: "cartesian",
|
|
174
174
|
draw: (e, { layer: t, panel: o, colorScheme: n }) => {
|
|
@@ -180,33 +180,33 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
180
180
|
e.save(), e.globalAlpha = s.get("alpha", r), e.fillStyle = s.get("color", r), e.strokeStyle = s.get("borderColor", r), e.lineWidth = u, e.beginPath(), e.arc(d, a, c, 0, Math.PI * 2), e.fill(), u > 0 && e.stroke(), e.restore();
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
}), le = 11,
|
|
183
|
+
}), le = 11, Jt = "sans-serif", $t = 500, D = 5, Pe = 5, re = 13, ke = 6, Y = 12, Ae = 21.6, xt = (e, t) => {
|
|
184
184
|
const o = e.mapping.y !== void 0, n = t.mainAxis === "y";
|
|
185
185
|
return o !== n;
|
|
186
|
-
},
|
|
186
|
+
}, eo = (e, t, o) => {
|
|
187
187
|
const n = mt(t, o);
|
|
188
188
|
e.setLineDash(n), n.length > 0 && (e.lineCap = "round");
|
|
189
|
-
},
|
|
189
|
+
}, to = (e, t) => q(e) && q(t) ? `${e}: ${t}` : q(e) ? e : q(t) ? t : null, q = (e) => e != null && e.trim() !== "", oo = (e) => {
|
|
190
190
|
e.beginPath(), e.moveTo(2.48935, 16.9323), e.lineTo(9.07098, 9.82964), e.bezierCurveTo(9.51595, 9.34944, 9.51504, 8.60728, 9.0689, 8.12818), e.lineTo(2.48866, 1.06172), e.bezierCurveTo(1.85811, 0.384586, 0.974477, 0, 0.049217, 0), e.lineTo(0, 0), e.lineTo(0, 18), e.lineTo(0.0443689, 18), e.bezierCurveTo(0.972463, 18, 1.85854, 17.6131, 2.48935, 16.9323), e.closePath();
|
|
191
191
|
}, De = (e, t, o, n, s, r) => {
|
|
192
192
|
const i = Math.min(r, n / 2, s / 2);
|
|
193
193
|
e.beginPath(), e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.arcTo(t + n, o, t + n, o + i, i), e.lineTo(t + n, o + s - i), e.arcTo(t + n, o + s, t + n - i, o + s, i), e.lineTo(t + i, o + s), e.arcTo(t, o + s, t, o + s - i, i), e.lineTo(t, o + i), e.arcTo(t, o, t + i, o, i), e.closePath(), e.fill();
|
|
194
|
+
}, no = (e, t, o, n, s, r, i, l) => {
|
|
195
|
+
const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = c ? r.x : r.x + r.width, f = _(r, s), h = c ? -re : -(d - re), g = c ? h + d - D : h + D - Y;
|
|
196
|
+
e.save(), e.translate(u, f), e.translate(0, -a / 2), e.fillStyle = i, De(e, h, 0, d, a, ke), e.save(), c || (e.translate(g + Y / 2, a / 2), e.rotate(Math.PI), e.translate(-(g + Y / 2), -a / 2)), e.translate(g, (a - Ae) / 2), e.scale(Y / 10, Ae / 18), e.fillStyle = i, oo(e), e.fill(), e.restore(), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, h + D, a / 2), e.restore();
|
|
194
197
|
}, ro = (e, t, o, n, s, r, i, l) => {
|
|
195
|
-
const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = c ? r.x : r.x + r.width, f = _(r, s), h = c ? -re : -(d - re), g = c ? h + d - D : h + D - X;
|
|
196
|
-
e.save(), e.translate(u, f), e.translate(0, -a / 2), e.fillStyle = i, De(e, h, 0, d, a, ke), e.save(), c || (e.translate(g + X / 2, a / 2), e.rotate(Math.PI), e.translate(-(g + X / 2), -a / 2)), e.translate(g, (a - Ae) / 2), e.scale(X / 10, Ae / 18), e.fillStyle = i, no(e), e.fill(), e.restore(), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, h + D, a / 2), e.restore();
|
|
197
|
-
}, so = (e, t, o, n, s, r, i, l) => {
|
|
198
198
|
const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = C(r, s), f = c ? r.y + r.height : r.y, h = c ? -re : -8;
|
|
199
199
|
e.save(), e.translate(u, f), e.translate(-d / 2, 0), e.fillStyle = i, De(e, 0, h, d, a, ke), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, D, h + a / 2), e.restore();
|
|
200
|
-
},
|
|
200
|
+
}, so = F({
|
|
201
201
|
geom: "rule",
|
|
202
202
|
coord: "cartesian",
|
|
203
203
|
draw: (e, { layer: t, coordSystem: o, panel: n, compiled: s, textMeasurer: r, formattingLocale: i, colorScheme: l }) => {
|
|
204
204
|
const d = t.data.getFirst();
|
|
205
205
|
if (!d) return;
|
|
206
|
-
const a =
|
|
206
|
+
const a = xt(t, o), c = a ? B(d) : v(d);
|
|
207
207
|
if (c === null) return;
|
|
208
208
|
const u = P({ colorScheme: l }).geomReaders(t), f = u.get("color", d), h = pt(f), g = u.get("strokeWidth", d);
|
|
209
|
-
if (e.save(), e.strokeStyle = f, e.lineWidth = g,
|
|
209
|
+
if (e.save(), e.strokeStyle = f, e.lineWidth = g, eo(e, u.get("lineType", d), g), e.beginPath(), a) {
|
|
210
210
|
const T = _(n, c);
|
|
211
211
|
e.moveTo(n.x, T), e.lineTo(n.x + n.width, T);
|
|
212
212
|
} else {
|
|
@@ -214,7 +214,7 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
214
214
|
e.moveTo(T, n.y), e.lineTo(T, n.y + n.height);
|
|
215
215
|
}
|
|
216
216
|
e.stroke(), e.restore();
|
|
217
|
-
const A =
|
|
217
|
+
const A = to(
|
|
218
218
|
t.params.label,
|
|
219
219
|
At({
|
|
220
220
|
guides: s.guides,
|
|
@@ -225,21 +225,21 @@ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce =
|
|
|
225
225
|
);
|
|
226
226
|
if (A === null) return;
|
|
227
227
|
const p = s.config.appearance.textScale, b = {
|
|
228
|
-
family:
|
|
228
|
+
family: Jt,
|
|
229
229
|
size: le * p,
|
|
230
|
-
weight:
|
|
230
|
+
weight: $t
|
|
231
231
|
};
|
|
232
232
|
e.font = R(b);
|
|
233
233
|
const y = r.measureText(A, b).width;
|
|
234
|
-
(a ?
|
|
234
|
+
(a ? no : ro)(e, A, y, t.params.labelPosition, c, n, f, h);
|
|
235
235
|
}
|
|
236
236
|
}), M = at();
|
|
237
237
|
M.digits(8);
|
|
238
|
-
const
|
|
238
|
+
const io = F({
|
|
239
239
|
geom: "bar",
|
|
240
240
|
coord: "polar",
|
|
241
241
|
draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
|
|
242
|
-
const r = n.x + n.width / 2, i = n.y + n.height / 2, l = Math.min(n.width, n.height) / 2, { Path2D: d } =
|
|
242
|
+
const r = n.x + n.width / 2, i = n.y + n.height / 2, l = Math.min(n.width, n.height) / 2, { Path2D: d } = X(), a = P({ colorScheme: s }).geomReaders(t);
|
|
243
243
|
e.save(), e.translate(r, i), e.scale(l, l);
|
|
244
244
|
const c = e, u = /* @__PURE__ */ new Map();
|
|
245
245
|
for (const f of t.data) {
|
|
@@ -274,17 +274,17 @@ const ao = F({
|
|
|
274
274
|
}
|
|
275
275
|
e.restore();
|
|
276
276
|
}
|
|
277
|
-
}),
|
|
278
|
-
bar: { cartesian:
|
|
279
|
-
line: { cartesian:
|
|
280
|
-
area: { cartesian:
|
|
281
|
-
point: { cartesian:
|
|
282
|
-
rule: { cartesian:
|
|
277
|
+
}), ao = {
|
|
278
|
+
bar: { cartesian: Yt, polar: io },
|
|
279
|
+
line: { cartesian: Qt },
|
|
280
|
+
area: { cartesian: Xt },
|
|
281
|
+
point: { cartesian: Zt },
|
|
282
|
+
rule: { cartesian: so }
|
|
283
283
|
}, Oe = (e, t) => (
|
|
284
284
|
// `CompiledLayer.geom` is a plain string (a custom geom carries a name outside `GeomName`); the
|
|
285
285
|
// node renderer ships only built-ins, so an unregistered name simply resolves to `null`.
|
|
286
|
-
|
|
287
|
-
),
|
|
286
|
+
ao[e.geom]?.[t.type] ?? null
|
|
287
|
+
), lo = (e, t, o) => {
|
|
288
288
|
e.draw(t, o);
|
|
289
289
|
};
|
|
290
290
|
let be;
|
|
@@ -302,43 +302,43 @@ const Fe = () => (be ??= Lt(), be), He = [
|
|
|
302
302
|
"donut",
|
|
303
303
|
"scatter",
|
|
304
304
|
"bubble"
|
|
305
|
-
],
|
|
305
|
+
], co = [
|
|
306
306
|
"funnel",
|
|
307
307
|
"heatmap",
|
|
308
308
|
"waterfall",
|
|
309
309
|
"mekko",
|
|
310
310
|
"table"
|
|
311
|
-
],
|
|
311
|
+
], fo = new Set(He), kn = {
|
|
312
312
|
supportedGraphTypes: [...He],
|
|
313
|
-
unsupportedGraphTypes: [...
|
|
313
|
+
unsupportedGraphTypes: [...co],
|
|
314
314
|
supportedGeoms: {
|
|
315
315
|
cartesian: ["bar", "line", "area", "point", "rule"],
|
|
316
316
|
polar: ["bar"]
|
|
317
317
|
}
|
|
318
|
-
}, I = (e) => ({ ok: !1, reason: e }),
|
|
319
|
-
if (!
|
|
318
|
+
}, I = (e) => ({ ok: !1, reason: e }), Z = (e) => typeof e == "object" && e !== null && !Array.isArray(e), uo = (e) => {
|
|
319
|
+
if (!Z(e)) return !1;
|
|
320
320
|
const { columns: t, rows: o } = e;
|
|
321
|
-
return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) =>
|
|
322
|
-
},
|
|
321
|
+
return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) => Z(n) && typeof n.key == "string");
|
|
322
|
+
}, ho = (e) => {
|
|
323
323
|
if ("_unstable_mapping" in e && e._unstable_mapping !== void 0) return !0;
|
|
324
324
|
const t = e.referenceLines;
|
|
325
|
-
return
|
|
326
|
-
},
|
|
327
|
-
if (!
|
|
325
|
+
return Z(t) ? t.trendline !== void 0 || t.averageLine !== void 0 : !1;
|
|
326
|
+
}, go = (e) => {
|
|
327
|
+
if (!Z(e))
|
|
328
328
|
return I("Chart config must be a plain object.");
|
|
329
|
-
if (!
|
|
329
|
+
if (!uo(e.data))
|
|
330
330
|
return I("Chart config is missing a valid `data` object (columns + rows).");
|
|
331
331
|
const { data: t, ...o } = e;
|
|
332
332
|
return { ok: !0, input: o, data: t };
|
|
333
|
-
},
|
|
334
|
-
const t =
|
|
333
|
+
}, mo = (e) => {
|
|
334
|
+
const t = go(e);
|
|
335
335
|
if (!t.ok) return t;
|
|
336
|
-
if (
|
|
336
|
+
if (ho(e))
|
|
337
337
|
return I(
|
|
338
338
|
"Canvas renderer does not support `_unstable_mapping`, `referenceLines.trendline`, or `referenceLines.averageLine`."
|
|
339
339
|
);
|
|
340
340
|
const o = t.input.type ?? "column";
|
|
341
|
-
if (!
|
|
341
|
+
if (!fo.has(o))
|
|
342
342
|
return I(`Unsupported chart type for canvas rendering: ${o}.`);
|
|
343
343
|
try {
|
|
344
344
|
const n = Fe(), s = rt(t.input, t.data), r = n.compile({ input: s, data: t.data });
|
|
@@ -354,22 +354,22 @@ const Fe = () => (be ??= Lt(), be), He = [
|
|
|
354
354
|
const s = n instanceof Error ? n.message : String(n);
|
|
355
355
|
return I(`Chart config failed to compile: ${s}`);
|
|
356
356
|
}
|
|
357
|
-
}, Me = E, W = 12, de = 1.3, V = 10, K = 12, O = 6, Ge = 16,
|
|
357
|
+
}, Me = E, W = 12, de = 1.3, V = 10, K = 12, O = 6, Ge = 16, po = 24, Ue = 6, We = 3, se = 4, Ao = 8, bo = "#9ca3af", Ve = 16, yo = 1.3, Ke = 13, To = 1.4, ze = 12, So = 1.4, J = 8, ce = 12, Eo = 1.3, Lo = 200, Ro = 120, wo = 80, Xe = 22, Bo = 9, vo = 11, _o = 10, j = 9, ye = 12, Co = '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif', No = 11.5, Io = 550, Po = { light: 0.55, mid: 0.75, dark: 0.08 }, ko = { light: 0.62, mid: 0.8, dark: 0.85 }, Do = 0.22, Oo = 0.65, Fo = { family: Me, size: W }, Ho = [2, 3], Mo = [1, 3], ie = (e) => {
|
|
358
358
|
switch (e) {
|
|
359
359
|
case "dashed":
|
|
360
|
-
return
|
|
360
|
+
return Ho;
|
|
361
361
|
case "dotted":
|
|
362
|
-
return
|
|
362
|
+
return Mo;
|
|
363
363
|
case "solid":
|
|
364
364
|
return [];
|
|
365
365
|
}
|
|
366
|
-
},
|
|
366
|
+
}, Go = (e, t, o, n, s, r) => {
|
|
367
367
|
if (!t.isVisible || t.ticks.length === 0) return;
|
|
368
368
|
const i = t.position === "bottom" || t.position === "top";
|
|
369
|
-
e.save(), e.font = R(
|
|
369
|
+
e.save(), e.font = R(z(s, E)), e.fillStyle = s.textColor, e.strokeStyle = r.color, e.lineWidth = r.strokeWidth, e.setLineDash(ie(r.lineType));
|
|
370
370
|
for (const l of t.ticks) {
|
|
371
371
|
const d = i ? l.position : 1 - l.position;
|
|
372
|
-
t.ticksVisible &&
|
|
372
|
+
t.ticksVisible && Wo(e, t.position, d, o, n, r.length), Ko(
|
|
373
373
|
e,
|
|
374
374
|
t.position,
|
|
375
375
|
d,
|
|
@@ -381,72 +381,72 @@ const Fe = () => (be ??= Lt(), be), He = [
|
|
|
381
381
|
);
|
|
382
382
|
}
|
|
383
383
|
e.restore();
|
|
384
|
-
},
|
|
384
|
+
}, Uo = (e, t, o, n, s) => {
|
|
385
385
|
if (e === "bottom" || e === "top") {
|
|
386
386
|
const d = n.x + t * n.width, a = e === "top" ? o.y + o.height : o.y, c = e === "top" ? -s : s;
|
|
387
387
|
return { x1: d, y1: a, x2: d, y2: a + c };
|
|
388
388
|
}
|
|
389
389
|
const r = n.y + t * n.height, i = e === "right" ? o.x : o.x + o.width, l = e === "right" ? s : -s;
|
|
390
390
|
return { x1: i, y1: r, x2: i + l, y2: r };
|
|
391
|
-
},
|
|
392
|
-
const { x1: i, y1: l, x2: d, y2: a } =
|
|
391
|
+
}, Wo = (e, t, o, n, s, r) => {
|
|
392
|
+
const { x1: i, y1: l, x2: d, y2: a } = Uo(t, o, n, s, r);
|
|
393
393
|
e.beginPath(), e.moveTo(i, l), e.lineTo(d, a), e.stroke();
|
|
394
|
-
},
|
|
394
|
+
}, Vo = (e, t, o, n, s) => {
|
|
395
395
|
if (e === "bottom" || e === "top") {
|
|
396
396
|
const i = n.x + t * n.width;
|
|
397
397
|
return e === "bottom" ? { x: i, y: o.y + s, textAlign: "center", textBaseline: "top" } : { x: i, y: o.y + o.height - s, textAlign: "center", textBaseline: "alphabetic" };
|
|
398
398
|
}
|
|
399
399
|
const r = n.y + t * n.height;
|
|
400
400
|
return e === "left" ? { x: o.x + o.width - s, y: r, textAlign: "right", textBaseline: "middle" } : { x: o.x + s, y: r, textAlign: "left", textBaseline: "middle" };
|
|
401
|
-
},
|
|
401
|
+
}, Ko = (e, t, o, n, s, r, i, l) => {
|
|
402
402
|
if (i !== 0 && (t === "top" || t === "bottom")) {
|
|
403
403
|
const a = s.x + o * s.width, c = t === "top";
|
|
404
404
|
e.save(), e.translate(a, c ? n.y + n.height - l : n.y + l), e.rotate(i * Math.PI / 180), e.textAlign = c ? "left" : "right", e.textBaseline = "middle", e.fillText(r, 0, 0), e.restore();
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
const d =
|
|
407
|
+
const d = Vo(t, o, n, s, l);
|
|
408
408
|
e.textAlign = d.textAlign, e.textBaseline = d.textBaseline, e.fillText(r, d.x, d.y);
|
|
409
|
-
},
|
|
409
|
+
}, zo = (e, t, o, n) => {
|
|
410
410
|
if (!t.isVisible || !t.label) return;
|
|
411
411
|
e.save(), e.font = R({
|
|
412
412
|
family: n.fontFamily ?? E,
|
|
413
413
|
size: n.fontSize,
|
|
414
414
|
weight: n.fontWeight
|
|
415
415
|
}), e.fillStyle = n.textColor, e.textBaseline = "middle";
|
|
416
|
-
const { x: s, y: r, alignment: i } =
|
|
416
|
+
const { x: s, y: r, alignment: i } = Xo(t.position, o);
|
|
417
417
|
e.textAlign = i, e.fillText(t.label, s, r), e.restore();
|
|
418
|
-
},
|
|
418
|
+
}, Xo = (e, t) => {
|
|
419
419
|
const o = t.y + t.height / 2;
|
|
420
420
|
return e === "left" ? { x: t.x, y: o, alignment: "start" } : e === "right" ? { x: t.x + t.width, y: o, alignment: "end" } : { x: t.x + t.width / 2, y: o, alignment: "center" };
|
|
421
|
-
},
|
|
421
|
+
}, Yo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABgCAYAAAC65+QhAAAKo0lEQVR42u2de4wdVR3HPzN32+oSUQSsikEoosR3iko08oovEkwMpmiIr/KHIomgUYyPiBofkRjjE+MjEk3RQNIYTdUotKkoaql0Wyympbtl2XbLtrW71n3v3ntnrn+c38n98cvcOzP3tfcud5LJ5u7Ozpz5nt/7nN/3QncfAVBQn18LfBd4GJgFYvm5B/iW/N0fBfn/VX9ogF4K3A0sAhV1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g9srvsqQdV3cDIXuz9ut88Tpp4cSi5I77RSWLGdKOGxUoBXq0Z8cW2C7D8X+n0XFXUtz9nJRhz1lt3xJkFxdvUMV7b7/K5tuAdEStpWgr8MpeVbNGVoHPwG20n6lBs21DhiGVLK9agOrZrwtxq7ePGm48X5PfgeuJWdvN381CG7+pIlBbfryEXCJpxlqRtBG10oHa6NXVx/8Ba+cluUx5B18AAAAASUVORK5CYII=", N = Xe;
|
|
422
422
|
let ee;
|
|
423
|
-
const
|
|
423
|
+
const qo = () => {
|
|
424
424
|
if (ee) return ee;
|
|
425
|
-
const { Image: e } =
|
|
426
|
-
return t.src =
|
|
427
|
-
}, Ye = (e, t, o = "full") => !e || t.width <
|
|
428
|
-
const t =
|
|
425
|
+
const { Image: e } = X(), t = new e(), o = Yo.replace(/^data:image\/png;base64,/, "");
|
|
426
|
+
return t.src = Dt.from(o, "base64"), ee = t, t;
|
|
427
|
+
}, Ye = (e, t, o = "full") => !e || t.width < Ro || t.height < wo ? "hidden" : t.width < Lo || o === "mini" ? "mini" : "full", jo = (e) => {
|
|
428
|
+
const t = Qo(e);
|
|
429
429
|
if (t === null) return "light";
|
|
430
|
-
const o =
|
|
431
|
-
return o <=
|
|
430
|
+
const o = Zo(t);
|
|
431
|
+
return o <= Do ? "dark" : o <= Oo ? "mid" : "light";
|
|
432
432
|
}, ae = (e, t, o) => e.placement !== o || Ye(e.enabled, t, e.variant) === "hidden" ? 0 : Xe, qe = (e, t, o, n, s, r) => {
|
|
433
433
|
if (t.placement !== r) return;
|
|
434
434
|
const i = Ye(t.enabled, s, t.variant);
|
|
435
435
|
if (i === "hidden") return;
|
|
436
|
-
const l =
|
|
436
|
+
const l = jo(n.background), d = l === "dark", a = { family: Co, size: No, weight: 400 }, c = { ...a, weight: Io };
|
|
437
437
|
let u = 0;
|
|
438
438
|
i === "full" && (e.font = R(a), u = e.measureText("Made with ").width, e.font = R(c), u += e.measureText("Graphy").width);
|
|
439
|
-
const f = i === "mini" ? 0 :
|
|
440
|
-
e.save(), e.globalAlpha =
|
|
441
|
-
const y = d ? "#FFFFFF" : "#2A2A28", S = i === "mini" ? p + (A -
|
|
442
|
-
if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(
|
|
443
|
-
const m = p + f +
|
|
439
|
+
const f = i === "mini" ? 0 : Bo, h = i === "mini" ? 0 : vo, g = i === "mini" ? 0 : _o, A = i === "mini" ? N : f + j + g + u + h, p = o.x + o.width - A, b = o.y + Math.max(0, (o.height || N) / 2 - N / 2);
|
|
440
|
+
e.save(), e.globalAlpha = ko[l], e.textBaseline = "middle", e.textAlign = "left", d || (e.shadowColor = "rgba(0, 0, 0, 0.09)", e.shadowBlur = 4, e.shadowOffsetY = 1), e.beginPath(), e.roundRect(p, b, A, N, N / 2), e.fillStyle = `rgba(255, 255, 255, ${Po[l]})`, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetY = 0;
|
|
441
|
+
const y = d ? "#FFFFFF" : "#2A2A28", S = i === "mini" ? p + (A - j) / 2 : p + f, T = b + (N - ye) / 2;
|
|
442
|
+
if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(qo(), S, T, j, ye), e.restore(), i === "full") {
|
|
443
|
+
const m = p + f + j + g, w = b + N / 2;
|
|
444
444
|
e.fillStyle = y, e.font = R(a), e.fillText("Made with ", m, w);
|
|
445
445
|
const L = e.measureText("Made with ").width;
|
|
446
446
|
e.font = R(c), e.fillText("Graphy", m + L, w);
|
|
447
447
|
}
|
|
448
448
|
e.restore();
|
|
449
|
-
},
|
|
449
|
+
}, Qo = (e) => {
|
|
450
450
|
const t = e.trim();
|
|
451
451
|
if (!t.startsWith("#")) return null;
|
|
452
452
|
const o = t.slice(1);
|
|
@@ -463,13 +463,13 @@ const jo = () => {
|
|
|
463
463
|
green: Number.parseInt(o.slice(2, 4), 16),
|
|
464
464
|
blue: Number.parseInt(o.slice(4, 6), 16)
|
|
465
465
|
} : null;
|
|
466
|
-
},
|
|
466
|
+
}, Zo = ({ red: e, green: t, blue: o }) => {
|
|
467
467
|
const n = (s) => {
|
|
468
468
|
const r = s / 255;
|
|
469
469
|
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
470
470
|
};
|
|
471
471
|
return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
|
|
472
|
-
},
|
|
472
|
+
}, Jo = { family: E, size: Ve, weight: 600 }, $o = { family: E, size: Ke }, xo = { family: E, size: ze }, en = { family: E, size: ce, weight: 500 }, tn = { family: E, size: ce }, je = Ve * yo, on = Ke * To, Qe = ze * So, Ze = ce * Eo, Je = (e) => {
|
|
473
473
|
if (e === null) return null;
|
|
474
474
|
if (e.label !== void 0 && e.label !== "") return e.label;
|
|
475
475
|
if (e.url !== void 0 && e.url !== "" && Rt(e.url))
|
|
@@ -479,29 +479,29 @@ const jo = () => {
|
|
|
479
479
|
return e.url;
|
|
480
480
|
}
|
|
481
481
|
return null;
|
|
482
|
-
},
|
|
482
|
+
}, nn = (e, t) => {
|
|
483
483
|
let o = 0;
|
|
484
484
|
const n = e.isTitleVisible && e.title !== null, s = e.isSubtitleVisible && e.subtitle !== null;
|
|
485
|
-
n && (o += je), s && (o > 0 && (o +=
|
|
485
|
+
n && (o += je), s && (o > 0 && (o += J), o += on);
|
|
486
486
|
const r = ae(e.brandMark, t, "header");
|
|
487
487
|
!n && !s && r > 0 && (o = r);
|
|
488
488
|
const i = e.isCaptionVisible && e.caption !== null, l = e.isSourceVisible && Je(e.source) !== null, d = ae(e.brandMark, t, "footer");
|
|
489
489
|
let a = 0;
|
|
490
|
-
return i && (a += Qe), (l || d > 0) && (a > 0 && (a +=
|
|
491
|
-
},
|
|
490
|
+
return i && (a += Qe), (l || d > 0) && (a > 0 && (a += J), a += Math.max(Ze, d)), { headerHeight: o, footerHeight: a };
|
|
491
|
+
}, rn = (e, t, o, n, s) => {
|
|
492
492
|
if (o.height === 0) return;
|
|
493
493
|
e.save(), e.textBaseline = "top", e.textAlign = "left";
|
|
494
494
|
let r = o.y;
|
|
495
|
-
t.isTitleVisible && t.title !== null && (e.font = R(
|
|
496
|
-
},
|
|
495
|
+
t.isTitleVisible && t.title !== null && (e.font = R(Jo), e.fillStyle = n.textPrimary, e.fillText(te(t.title), o.x, r), r += je + J), t.isSubtitleVisible && t.subtitle !== null && (e.font = R($o), e.fillStyle = n.textSecondary, e.fillText(te(t.subtitle), o.x, r)), e.restore(), qe(e, t.brandMark, o, n, s, "header");
|
|
496
|
+
}, sn = (e, t, o, n, s) => {
|
|
497
497
|
if (o.height === 0) return;
|
|
498
498
|
const r = t.isCaptionVisible ? t.caption : null, i = t.isSourceVisible ? Je(t.source) : null, l = ae(t.brandMark, s, "footer");
|
|
499
499
|
if (r === null && i === null && l === 0) return;
|
|
500
500
|
e.save(), e.textBaseline = "top", e.textAlign = "left";
|
|
501
501
|
let d = o.y;
|
|
502
|
-
if (r !== null && (e.font = R(
|
|
502
|
+
if (r !== null && (e.font = R(xo), e.fillStyle = n.textSecondary, e.fillText(te(r), o.x, d), d += Qe + J), i !== null) {
|
|
503
503
|
let a = o.x;
|
|
504
|
-
a = Te(e, "Source: ",
|
|
504
|
+
a = Te(e, "Source: ", en, n.textSecondary, a, d), Te(e, i, tn, n.textSecondary, a, d);
|
|
505
505
|
}
|
|
506
506
|
e.restore(), qe(
|
|
507
507
|
e,
|
|
@@ -511,10 +511,10 @@ const jo = () => {
|
|
|
511
511
|
s,
|
|
512
512
|
"footer"
|
|
513
513
|
);
|
|
514
|
-
}, Te = (e, t, o, n, s, r) => (e.font = R(o), e.fillStyle = n, e.fillText(t, s, r), s + e.measureText(t).width),
|
|
514
|
+
}, Te = (e, t, o, n, s, r) => (e.font = R(o), e.fillStyle = n, e.fillText(t, s, r), s + e.measureText(t).width), an = (e, t, o, n) => {
|
|
515
515
|
e.save(), e.lineCap = "round";
|
|
516
516
|
for (const s of wt(Bt(o), n))
|
|
517
|
-
e.strokeStyle = s.color, e.lineWidth = s.strokeWidth, e.setLineDash(ie(s.lineType)),
|
|
517
|
+
e.strokeStyle = s.color, e.lineWidth = s.strokeWidth, e.setLineDash(ie(s.lineType)), ln(e, s.segments), e.stroke();
|
|
518
518
|
for (const s of t) {
|
|
519
519
|
if (!s.gridVisible) continue;
|
|
520
520
|
const r = s.position === "top" || s.position === "bottom", i = vt(o, U(s.scaleAestheticKey));
|
|
@@ -533,7 +533,7 @@ const jo = () => {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
e.restore();
|
|
536
|
-
},
|
|
536
|
+
}, ln = (e, t) => {
|
|
537
537
|
e.beginPath();
|
|
538
538
|
for (const o of t)
|
|
539
539
|
switch (o.type) {
|
|
@@ -550,10 +550,10 @@ const jo = () => {
|
|
|
550
550
|
e.closePath();
|
|
551
551
|
break;
|
|
552
552
|
}
|
|
553
|
-
},
|
|
554
|
-
e.save(), e.font = R(
|
|
553
|
+
}, dn = (e, t, o, n) => {
|
|
554
|
+
e.save(), e.font = R(Fo), e.textBaseline = "middle";
|
|
555
555
|
for (const r of t)
|
|
556
|
-
r.display === "direct" &&
|
|
556
|
+
r.display === "direct" && cn(e, r, o, n);
|
|
557
557
|
const s = /* @__PURE__ */ new Map();
|
|
558
558
|
for (const r of t) {
|
|
559
559
|
if (r.display !== "pill" || r.items.length === 0) continue;
|
|
@@ -562,19 +562,19 @@ const jo = () => {
|
|
|
562
562
|
}
|
|
563
563
|
for (const [r, i] of s) {
|
|
564
564
|
const l = o[r];
|
|
565
|
-
l && (r === "top" || r === "bottom" ?
|
|
565
|
+
l && (r === "top" || r === "bottom" ? fn(e, i, l, n) : un(e, i, l, n));
|
|
566
566
|
}
|
|
567
567
|
e.restore();
|
|
568
|
-
},
|
|
568
|
+
}, cn = (e, t, o, n) => {
|
|
569
569
|
const s = o[t.position];
|
|
570
570
|
if (s) {
|
|
571
571
|
e.textAlign = "left";
|
|
572
572
|
for (const r of t.items)
|
|
573
|
-
r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x +
|
|
573
|
+
r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x + Ao, _(s, r.normalizedY)));
|
|
574
574
|
}
|
|
575
|
-
},
|
|
575
|
+
}, fn = (e, t, o, n) => {
|
|
576
576
|
const s = $e(t), r = s.reduce(
|
|
577
|
-
(a, c, u) => a +
|
|
577
|
+
(a, c, u) => a + gn(c) + e.measureText(c.label).width + (u === 0 ? 0 : Se(c)),
|
|
578
578
|
0
|
|
579
579
|
), i = W * de;
|
|
580
580
|
let l = o.x + Math.max(0, (o.width - r) / 2);
|
|
@@ -583,7 +583,7 @@ const jo = () => {
|
|
|
583
583
|
const c = s[a];
|
|
584
584
|
c && (a > 0 && (l += Se(c)), l = xe(e, c, l, d, n));
|
|
585
585
|
}
|
|
586
|
-
},
|
|
586
|
+
}, un = (e, t, o, n) => {
|
|
587
587
|
const s = $e(t), r = Math.max(W * de, K), i = 4, l = s.length * r + Math.max(0, s.length - 1) * i;
|
|
588
588
|
let d = o.y + Math.max(0, (o.height - l) / 2) + r / 2;
|
|
589
589
|
for (const a of s)
|
|
@@ -596,14 +596,14 @@ const jo = () => {
|
|
|
596
596
|
const i = s.visual.size, l = n && typeof i == "number" && Number.isFinite(i) && i > 0 ? i : void 0;
|
|
597
597
|
t.push({
|
|
598
598
|
label: s.formattedLabel,
|
|
599
|
-
colors:
|
|
599
|
+
colors: hn(s.visual.color),
|
|
600
600
|
bubbleSize: l,
|
|
601
601
|
isFirstInGroup: r === 0
|
|
602
602
|
});
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
return t;
|
|
606
|
-
},
|
|
606
|
+
}, hn = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e.filter((t) => typeof t == "string") : [], Se = (e) => e.isFirstInGroup ? po : Ge, gn = (e) => {
|
|
607
607
|
if (e.bubbleSize !== void 0) return e.bubbleSize + O;
|
|
608
608
|
const t = e.colors.length;
|
|
609
609
|
if (t === 0) return 0;
|
|
@@ -614,7 +614,7 @@ const jo = () => {
|
|
|
614
614
|
let r = o;
|
|
615
615
|
if (t.bubbleSize !== void 0) {
|
|
616
616
|
const i = t.bubbleSize / 2;
|
|
617
|
-
e.fillStyle = t.colors[0] ??
|
|
617
|
+
e.fillStyle = t.colors[0] ?? bo, e.beginPath(), e.arc(r + i, n, i, 0, Math.PI * 2), e.fill(), r += t.bubbleSize + O;
|
|
618
618
|
} else if (t.colors.length > 0) {
|
|
619
619
|
const i = t.colors.slice(0, We);
|
|
620
620
|
for (let l = 0; l < i.length; l++) {
|
|
@@ -629,9 +629,9 @@ const jo = () => {
|
|
|
629
629
|
r += V + (i.length - 1) * se + O;
|
|
630
630
|
}
|
|
631
631
|
return e.fillStyle = s.textPrimary, e.textAlign = "left", e.fillText(t.label, r, n), r + e.measureText(t.label).width;
|
|
632
|
-
}, Ee = (e, t) => Math.min(Math.max(...e), t),
|
|
632
|
+
}, Ee = (e, t) => Math.min(Math.max(...e), t), mn = (e, t, o) => (n) => {
|
|
633
633
|
if (!n.isVisible || n.ticks.length === 0) return 0;
|
|
634
|
-
const s = n.position === "top" || n.position === "bottom", r = U(n.scaleAestheticKey), { offset: i, ...l } = t[r], d = n.ticksVisible ? Math.max(i, o[r].length) : i, a =
|
|
634
|
+
const s = n.position === "top" || n.position === "bottom", r = U(n.scaleAestheticKey), { offset: i, ...l } = t[r], d = n.ticksVisible ? Math.max(i, o[r].length) : i, a = z(l, E), c = n.ticks.map((h) => e.measureText(h.formattedLabel, a)), u = n.labelMaxWidthPx ?? Number.POSITIVE_INFINITY;
|
|
635
635
|
if (s) {
|
|
636
636
|
if (n.labelRotation !== 0) {
|
|
637
637
|
const h = c.map((g) => g.width);
|
|
@@ -641,7 +641,7 @@ const jo = () => {
|
|
|
641
641
|
}
|
|
642
642
|
const f = c.map((h) => h.width);
|
|
643
643
|
return Ee(f, u) + d;
|
|
644
|
-
},
|
|
644
|
+
}, pn = (e) => (t) => {
|
|
645
645
|
if (t.items.length === 0) return 0;
|
|
646
646
|
const o = { family: Me, size: W };
|
|
647
647
|
if (t.position === "top" || t.position === "bottom") {
|
|
@@ -653,40 +653,33 @@ const jo = () => {
|
|
|
653
653
|
return V + O + i;
|
|
654
654
|
});
|
|
655
655
|
return Math.max(...s) + Ge;
|
|
656
|
-
},
|
|
657
|
-
const
|
|
658
|
-
return e.measureText(t, {
|
|
659
|
-
family: E,
|
|
660
|
-
size: n,
|
|
661
|
-
weight: s
|
|
662
|
-
});
|
|
663
|
-
}, yn = (e, t) => (o, n, s) => {
|
|
664
|
-
const r = t[o][n], i = e.measureText(s, J(r, E));
|
|
656
|
+
}, An = (e) => (t, o) => e.measureText(t, z(o, E)), bn = (e, t) => (o, n, s) => {
|
|
657
|
+
const r = t[o][n], i = e.measureText(s, z(r, E));
|
|
665
658
|
return {
|
|
666
659
|
...i,
|
|
667
660
|
width: i.width + r.paddingInline * 2,
|
|
668
661
|
height: i.height + r.paddingBlock * 2
|
|
669
662
|
};
|
|
670
|
-
},
|
|
663
|
+
}, yn = ({
|
|
671
664
|
textMeasurer: e,
|
|
672
665
|
axisLabelStyles: t,
|
|
673
666
|
dataLabelStyles: o,
|
|
674
667
|
tickLabelStyles: n,
|
|
675
668
|
tickLineStyles: s
|
|
676
669
|
}) => ({
|
|
677
|
-
measureAxis:
|
|
670
|
+
measureAxis: mn(e, n, s),
|
|
678
671
|
measureAxisLabel: (r) => _t(t[U(r.scaleAestheticKey)]),
|
|
679
|
-
measureLegend:
|
|
680
|
-
measureTickLabel: (r, i) => e.measureText(r,
|
|
681
|
-
measureDifferenceArrowLabel:
|
|
682
|
-
measureDataLabel:
|
|
672
|
+
measureLegend: pn(e),
|
|
673
|
+
measureTickLabel: (r, i) => e.measureText(r, z(n[i], E)),
|
|
674
|
+
measureDifferenceArrowLabel: An(e),
|
|
675
|
+
measureDataLabel: bn(e, o),
|
|
683
676
|
measureHeadline: () => ({ width: 0, height: 0 }),
|
|
684
677
|
measureHeadlineItemWidths: () => []
|
|
685
678
|
});
|
|
686
|
-
class
|
|
679
|
+
class Tn {
|
|
687
680
|
constructor() {
|
|
688
681
|
this.currentFont = "";
|
|
689
|
-
const t =
|
|
682
|
+
const t = X().createCanvas(1, 1);
|
|
690
683
|
this.ctx = t.getContext("2d");
|
|
691
684
|
}
|
|
692
685
|
measureText(t, o) {
|
|
@@ -701,21 +694,21 @@ class Sn {
|
|
|
701
694
|
};
|
|
702
695
|
}
|
|
703
696
|
}
|
|
704
|
-
const
|
|
697
|
+
const Sn = {
|
|
705
698
|
background: "#ffffff",
|
|
706
699
|
textPrimary: "#111827",
|
|
707
700
|
textSecondary: "#6b7280",
|
|
708
701
|
gridLine: "#e5e7eb",
|
|
709
702
|
legendPillBackground: "rgba(0, 0, 0, 0.04)",
|
|
710
703
|
legendPillBorder: "rgba(0, 0, 0, 0.08)"
|
|
711
|
-
},
|
|
704
|
+
}, En = {
|
|
712
705
|
background: "#0b0f17",
|
|
713
706
|
textPrimary: "#e5e7eb",
|
|
714
707
|
textSecondary: "#9ca3af",
|
|
715
708
|
gridLine: "#1f2937",
|
|
716
709
|
legendPillBackground: "rgba(255, 255, 255, 0.06)",
|
|
717
710
|
legendPillBorder: "rgba(255, 255, 255, 0.12)"
|
|
718
|
-
},
|
|
711
|
+
}, Dn = async ({ input: e, data: t }, o) => {
|
|
719
712
|
const s = Fe().compile({ input: e, data: t });
|
|
720
713
|
if (!s.ok)
|
|
721
714
|
throw new Error(
|
|
@@ -723,15 +716,15 @@ const En = {
|
|
|
723
716
|
);
|
|
724
717
|
return et(s.compiled, o);
|
|
725
718
|
}, et = async (e, t) => {
|
|
726
|
-
const { Canvas: o } = await
|
|
727
|
-
if (
|
|
719
|
+
const { Canvas: o } = await Ot();
|
|
720
|
+
if (Vt(), t.fonts)
|
|
728
721
|
for (const w of t.fonts) Ce(w);
|
|
729
|
-
const n =
|
|
722
|
+
const n = Ct({
|
|
730
723
|
legends: e.guides.legends.drawn,
|
|
731
724
|
numberFormat: e.config.numberFormat,
|
|
732
725
|
parsingLocale: e.config.parsingLocale,
|
|
733
726
|
formattingLocale: t.formattingLocale
|
|
734
|
-
}), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } =
|
|
727
|
+
}), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } = nn(e.config.content, s), l = {
|
|
735
728
|
headerSize: { width: t.width, height: r },
|
|
736
729
|
footerSize: { width: t.width, height: i }
|
|
737
730
|
}, d = t.colorScheme ?? "light", a = P({ colorScheme: d }).chromeReaders(e.chrome), c = e.config.appearance.textScale, u = {
|
|
@@ -744,19 +737,19 @@ const En = {
|
|
|
744
737
|
x: he(a, "x"),
|
|
745
738
|
y: he(a, "y")
|
|
746
739
|
}, g = {};
|
|
747
|
-
for (const w of
|
|
740
|
+
for (const w of Nt) {
|
|
748
741
|
const L = {};
|
|
749
|
-
for (const k of
|
|
750
|
-
L[k] =
|
|
742
|
+
for (const k of It)
|
|
743
|
+
L[k] = Pt(a, w, k, c);
|
|
751
744
|
g[w] = L;
|
|
752
745
|
}
|
|
753
|
-
const A = new
|
|
746
|
+
const A = new Tn(), p = yn({
|
|
754
747
|
textMeasurer: A,
|
|
755
748
|
axisLabelStyles: u,
|
|
756
749
|
dataLabelStyles: g,
|
|
757
750
|
tickLabelStyles: f,
|
|
758
751
|
tickLineStyles: h
|
|
759
|
-
}), { layout: b, formattedAxes: y } = new
|
|
752
|
+
}), { layout: b, formattedAxes: y } = new kt(p).compile({
|
|
760
753
|
axes: e.guides.axes,
|
|
761
754
|
numberFormat: e.config.numberFormat,
|
|
762
755
|
parsingLocale: e.config.parsingLocale,
|
|
@@ -766,9 +759,9 @@ const En = {
|
|
|
766
759
|
formattingLocale: t.formattingLocale,
|
|
767
760
|
layout: e.config.layout
|
|
768
761
|
}), S = t.pixelRatio ?? 2, T = new o(t.width * S, t.height * S), m = T.getContext("2d");
|
|
769
|
-
return m.scale(S, S),
|
|
762
|
+
return m.scale(S, S), Ln({
|
|
770
763
|
ctx: m,
|
|
771
|
-
theme: d === "dark" ?
|
|
764
|
+
theme: d === "dark" ? En : Sn,
|
|
772
765
|
colorScheme: d,
|
|
773
766
|
chromeReaders: a,
|
|
774
767
|
axisLabelStyles: u,
|
|
@@ -783,7 +776,7 @@ const En = {
|
|
|
783
776
|
textMeasurer: A,
|
|
784
777
|
...t.formattingLocale === void 0 ? {} : { formattingLocale: t.formattingLocale }
|
|
785
778
|
}), T.encode("png");
|
|
786
|
-
},
|
|
779
|
+
}, Ln = ({
|
|
787
780
|
ctx: e,
|
|
788
781
|
theme: t,
|
|
789
782
|
colorScheme: o,
|
|
@@ -800,7 +793,7 @@ const En = {
|
|
|
800
793
|
textMeasurer: h,
|
|
801
794
|
formattingLocale: g
|
|
802
795
|
}) => {
|
|
803
|
-
e.fillStyle = t.background, e.fillRect(0, 0, l, d),
|
|
796
|
+
e.fillStyle = t.background, e.fillRect(0, 0, l, d), an(e, c, n, f.panel), e.save(), e.beginPath(), e.rect(f.panel.x, f.panel.y, f.panel.width, f.panel.height), e.clip();
|
|
804
797
|
const A = {
|
|
805
798
|
coordSystem: a.coordSystem,
|
|
806
799
|
panel: f.panel,
|
|
@@ -812,46 +805,46 @@ const En = {
|
|
|
812
805
|
};
|
|
813
806
|
for (const p of a.layers) {
|
|
814
807
|
const b = Oe(p, a.coordSystem);
|
|
815
|
-
b &&
|
|
808
|
+
b && lo(b, e, { ...A, layer: p });
|
|
816
809
|
}
|
|
817
810
|
e.restore();
|
|
818
811
|
for (const p of c) {
|
|
819
812
|
const b = f.axes[p.position];
|
|
820
813
|
if (b) {
|
|
821
814
|
const y = U(p.scaleAestheticKey);
|
|
822
|
-
|
|
815
|
+
Go(e, p, b, f.panel, r[y], i[y]);
|
|
823
816
|
}
|
|
824
817
|
}
|
|
825
818
|
for (const p of a.guides.axes) {
|
|
826
819
|
const b = f.axisLabels[p.position];
|
|
827
|
-
b &&
|
|
820
|
+
b && zo(e, p, b, s[U(p.scaleAestheticKey)]);
|
|
828
821
|
}
|
|
829
|
-
|
|
822
|
+
dn(e, u, f.legends, t), rn(e, a.config.content, f.header, t, { width: l, height: d }), sn(e, a.config.content, f.footer, t, { width: l, height: d });
|
|
830
823
|
};
|
|
831
|
-
class
|
|
824
|
+
class Rn extends Error {
|
|
832
825
|
constructor(t) {
|
|
833
826
|
super(t), this.name = "ChartConfigRenderError";
|
|
834
827
|
}
|
|
835
828
|
}
|
|
836
|
-
const
|
|
837
|
-
const o =
|
|
829
|
+
const On = async (e, t) => {
|
|
830
|
+
const o = mo(e);
|
|
838
831
|
if (!o.ok)
|
|
839
|
-
throw new
|
|
832
|
+
throw new Rn(o.reason);
|
|
840
833
|
return et(o.compiled, t);
|
|
841
834
|
};
|
|
842
835
|
export {
|
|
843
|
-
|
|
836
|
+
kn as CANVAS_CAPABILITY_MATRIX,
|
|
844
837
|
He as CANVAS_SUPPORTED_GRAPH_TYPES,
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
838
|
+
co as CANVAS_UNSUPPORTED_GRAPH_TYPES,
|
|
839
|
+
Rn as ChartConfigRenderError,
|
|
840
|
+
Tn as NodeCanvasTextMeasurer,
|
|
841
|
+
mo as canRenderConfigWithCanvas,
|
|
842
|
+
En as darkTheme,
|
|
843
|
+
Vt as ensureDefaultFonts,
|
|
844
|
+
Sn as lightTheme,
|
|
845
|
+
Ot as loadCanvasRuntime,
|
|
846
|
+
go as parseChartConfig,
|
|
854
847
|
Ce as registerFont,
|
|
855
|
-
|
|
856
|
-
|
|
848
|
+
On as renderChartConfigToPng,
|
|
849
|
+
Dn as renderGraphToPng
|
|
857
850
|
};
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"headless",
|
|
13
13
|
"renderer"
|
|
14
14
|
],
|
|
15
|
-
"version": "2.0.0-beta.
|
|
15
|
+
"version": "2.0.0-beta.1788422115078",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"sideEffects": [
|
|
18
18
|
"**/version.ts"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@fontsource/inter": "5.2.8",
|
|
41
41
|
"@napi-rs/canvas": "^0.1.76",
|
|
42
42
|
"d3-shape": "^3.2.0",
|
|
43
|
-
"@graphysdk/viz-engine": "2.0.0-beta.
|
|
43
|
+
"@graphysdk/viz-engine": "2.0.0-beta.1788422115078"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-replace": "^6.0.3",
|