@graphysdk/theme-typewriter 0.1.1-beta.1792407460425 → 0.1.1-beta.1792410301640
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/dist/index.cjs +1 -1
- package/dist/index.mjs +511 -434
- package/dist/renderer/area.d.ts +8 -0
- package/dist/renderer/bar.d.ts +23 -0
- package/dist/renderer/shapes.d.ts +3 -0
- package/dist/styles.d.ts +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let R=require("react"),o=require("@graphysdk/react"),h=require("react/jsx-runtime");var p={paper:"#EBD9A9",card:"#F8F0D8",text:"#1F1B16",secondary:"#4A443A",grid:"rgba(31, 27, 22, 0.4)",edge:"#C4AE74"},se="'Special Elite', 'Courier New', ui-monospace, monospace",m={black:"#1F1B16",red:"#B3271E",carbonBlue:"#2F4F8F",pencilGrey:"#6E6A62",stampGreen:"#2E6B4B",duplicatorViolet:"#7B5A9C"},le=[m.black,m.red,m.carbonBlue,m.pencilGrey,m.stampGreen,m.duplicatorViolet],de=["#D6C18B",m.black],he=[m.carbonBlue,"#DECEA4",m.red],k={fontWeight:400,textColor:p.text},P={...k,fontSize:13,fill:p.paper,stroke:"transparent",strokeWidth:0,cornerRadius:0,paddingInline:3,paddingBlock:1,shadow:"none"},v={fontWeight:400,textColor:p.secondary},C={fill:p.card,stroke:p.text,strokeWidth:1,cornerRadius:0,shadow:"none"},ce={tokens:{graphBackground:p.paper,graphBorder:p.edge,geomBorder:p.text,textPrimary:p.text,textSecondary:p.secondary,ruleLine:p.text,gridLine:p.grid,hoverAffordance:p.paper,hoverGuideFill:"rgba(31, 27, 22, 0.07)",hoverGuideLine:p.secondary,tooltipBackground:p.card,tooltipBorder:p.text,tooltipPrimaryRow:"rgba(31, 27, 22, 0.08)",annotationShape:m.red,annotationArrow:p.text,differenceLabelBackground:p.card},defaults:[o.style.graph({strokeWidth:1,cornerRadius:0,fontFamily:se,fontWeight:400,padding:24}),o.style.geom({shadow:"none"}),o.style.geom({shadow:"none"},{state:"hovered"}),o.style.geom.bar({stroke:p.text,strokeWidth:1,cornerRadius:"none"}),o.style.geom.line({strokeWidth:2,dashArray:[],lineCap:"butt",lineJoin:"miter"}),o.style.geom.area({fillAlpha:.6,strokeWidth:1.5,dashArray:[],lineCap:"butt",lineJoin:"miter"}),o.style.geom.point({size:9,stroke:p.paper,strokeWidth:1.5}),o.style.geom.tile({cornerRadius:0,stroke:p.paper,strokeWidth:2}),o.style.geom.rule({stroke:m.red,strokeWidth:1.5,dashArray:[5,4]}),o.style.geom.rule.label({...k,fontSize:13}),o.style.gridLine({dashArray:[5,4]}),o.style.panelBorder({strokeWidth:0,cornerRadius:0}),o.style.panelBorder.left({stroke:p.text,strokeWidth:1,dashArray:[]}),o.style.panelBorder.bottom({stroke:p.text,strokeWidth:1,dashArray:[]}),o.style.tickLine({strokeWidth:0}),o.style.tickLabel({...v,fontSize:13,lineHeight:1}),o.style.axisLabel({...v,fontSize:12,lineHeight:1,letterSpacing:1,textTransform:"uppercase"}),o.style.axisLabel.top({margin:{bottom:14}}),o.style.heading({...k}),o.style.heading.h1({fontSize:19,lineHeight:1.15,letterSpacing:1.5,textTransform:"uppercase",textDecoration:"underline"}),o.style.heading.h2({...v,fontSize:15,lineHeight:1.2}),o.style.header({margin:{bottom:18}}),o.style.caption({...v,fontSize:12.5}),o.style.source({...v,fontSize:12.5}),o.style.source.link({...v,fontSize:12.5}),o.style.dataLabel({...k,fontSize:13,fill:"transparent",cornerRadius:0}),o.style.legendItem({...v,fontSize:13,fill:"transparent",stroke:"transparent"}),o.style.legend.popover({...C}),o.style.directLabel({fontWeight:400,fontSize:13}),o.style.headlineItem.number({...k}),o.style.headlineItem.caption({...v}),o.style.headlineItem.label({...v}),o.style.headlineItem.trend({fontWeight:400}),o.style.tooltip({...C,paddingInline:12,paddingBlock:9}),o.style.tooltip.heading({...k,fontSize:13,lineHeight:1.3,letterSpacing:1,textTransform:"uppercase"}),o.style.tooltip.label({...v,fontSize:13,lineHeight:1.4}),o.style.tooltip.value({...k,fontSize:13,lineHeight:1.4}),o.style.annotation.text({...P,paddingInline:4,paddingBlock:2,lineHeight:1.3}),o.style.annotation.pinnedNumber({fill:m.red,stroke:p.paper,shadow:"none"}),o.style.annotation.pinnedNumber.label({...P}),o.style.annotation.comment({fill:m.red,stroke:p.paper,shadow:"none"}),o.style.annotation.comment.label({...P}),o.style.annotation.differenceArrow({stroke:p.text,strokeWidth:1.5}),o.style.annotation.differenceArrow.label({...P}),o.style.annotation.arrow({stroke:p.text,strokeWidth:1.5,dashArray:[]}),o.style.annotation.shape({fill:p.text,fillAlpha:.06,stroke:p.secondary,strokeWidth:.75}),o.style.geom.area({fillAlpha:.45},{coord:"polar"}),o.style.panelBorder.left({strokeWidth:0},{coord:"polar"}),o.style.panelBorder.bottom({strokeWidth:0},{coord:"polar"}),o.style.tickLabel({textColor:p.text,fontSize:14,fontWeight:700,textOutlineColor:p.paper,textOutlineWidth:8},{coord:"polar"})]},ue=/[a-df-zA-DF-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/gu,pe=/^[a-zA-Z]$/u,ge=(e,t)=>e==="H"?"x":e==="V"?"y":t%2===0?"x":"y",H=(e,t)=>{let r="",n=0;return(e.match(ue)??[]).map(a=>{if(pe.test(a))return r=a.toUpperCase(),n=0,a;const i=ge(r,n);return n+=1,String(Number(a)*(i==="x"?t.width:t.height))}).join(" ")},j=(e,t)=>{const r=(0,o.getX)(e),n=(0,o.getY)(e)??(0,o.getYMax)(e);return r===null||n===null?null:{x:(0,o.toViewBoxX)(r)*t.width,y:(0,o.toViewBoxY)(n)*t.height}},w=(e,t)=>{const r=(0,o.getX)(e),n=(0,o.getY)(e)??(0,o.getRadiusExtent)(e).outerRadius;if(r===null||n===null)return null;const a=(0,o.polarToUnit)(r,n),i=Math.min(t.width,t.height)/2;return{x:t.width/2+a.x*i,y:t.height/2-a.y*i}},fe=e=>`${e.map((t,r)=>`${r===0?"M":"L"}${t.x},${t.y}`).join(" ")} Z`,E=e=>{const t=(0,o.useGeomStyleReader)(e);return(r,n)=>({color:(0,o.toPaintColor)(t.get("fill",r,n)),opacity:t.get("alpha",r,n),fillOpacity:t.get("fillAlpha",r,n),edge:t.get("stroke",r,n),edgeWidth:t.get("strokeWidth",r,n)})},Z=e=>{const t=(0,o.useGeomStyleReader)(e);return(r,n)=>{const a=t.get("strokeWidth",r,n);return{color:t.get("stroke",r,n),opacity:t.get("alpha",r,n)*t.get("strokeAlpha",r,n),width:a,dashArray:(0,o.toStrokeDasharray)(t.get("dashArray",r,n),a)}}},ye=1.3,M=[.72,.87,1],B=.35,xe=.7,D=100,z=.7,me=4,ve=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0},L=(e,t,r,n)=>{let a=Math.imul(e^Math.imul(t,374761393)^Math.imul(r,668265263)^n,1274126177);return a=Math.imul(a^a>>>13,1103515245),((a^a>>>16)>>>0)/4294967296},x=e=>Math.round(e*D)/D,q=(e,t,r,n,a)=>{const i=x(t-n/2),l=x(t+n/2),d=x(r-a/2),s=x(r+a/2),c=`M${i},${d}L${l},${s}M${l},${d}L${i},${s}`;if(e==="x"||e==="X"&&n<me)return c;if(e==="X"){const f=(y,T)=>`M${x(y-z)},${T}L${x(y+z)},${T}`;return`${c}${f(i,d)}${f(l,d)}${f(i,s)}${f(l,s)}`}if(e==="/")return`M${i},${s}L${l},${d}`;if(e==="_")return`M${i},${x(r)}L${l},${x(r)}`;if(e==="|")return`M${x(t)},${d}L${x(t)},${s}`;const g=x(n/2),u=x(a/2);return`M${i},${x(r)}a${g},${u} 0 1,0 ${x(n)},0a${g},${u} 0 1,0 ${-x(n)},0`},b=e=>{const t=ve(e);return(r,n,a,i,l,d,s)=>{const c=(L(t,d,s,1)*2-1)*B,g=(L(t,d,s,2)*2-1)*B,u=Math.floor(L(t,d,s,3)*M.length);return{path:q(r,n+c,a+g,i,l),weight:u}}},S=(e,t,r,n,a)=>({path:q(e,t,r,n,a),weight:M.length-1}),W=e=>`${e}-${(0,R.useId)().replace(/[^a-zA-Z0-9]/gu,"")}`,A=({strikes:e,color:t,opacity:r=1,width:n=ye,isOverstruck:a=!1})=>e.length===0?null:(0,h.jsxs)("g",{fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",opacity:r,children:[M.map((i,l)=>e.filter(d=>d.weight===l).map(d=>d.path).join("")).map((i,l)=>i===""?null:(0,h.jsx)("path",{d:i,strokeOpacity:M[l]},M[l])),a&&(0,h.jsx)("path",{d:e.map(i=>i.path).join(""),transform:`translate(${xe},0)`})]}),N=6,Ae=14,ke=1.5,X=10,Re=1.8,I=(e,t,r,n)=>{const a=(0,o.createStableKeyGenerator)(e.data,e.mapping,e.id),i=[];return e.data.groupBy(o.GROUP_VARIABLES.group).forEach(l=>{const d=[...l],[s]=d,c=t(d);if(s===void 0||c===null)return;const g=d.flatMap(u=>r(u,n)??[]);i.push({key:a(s),observation:s,path:c,readings:g})}),i},J=(e,t)=>{const r=e.flatMap(n=>{const a=(0,o.getX)(n),i=w(n,t);return a===null||i===null?[]:[{angle:a,point:i}]}).sort((n,a)=>n.angle-a.angle).map(({point:n})=>n);return r.length===0?null:fe(r)},Se=e=>e.every((t,r)=>{const n=e[r+1];return n===void 0||Math.hypot(n.x-t.x,n.y-t.y)>=Ae}),we=({readings:e,color:t,opacity:r})=>Se(e)?(0,h.jsx)(A,{strikes:e.map(({x:n,y:a})=>S("x",n,a,N,N)),color:t,opacity:r,width:ke}):null,Q=({geom:e,observation:t,panel:r,project:n,color:a,opacity:i})=>{const l=n(t,r);return l===null?null:(0,h.jsx)("g",{"data-geom":e,children:(0,h.jsx)(A,{strikes:[S("X",l.x,l.y,X,X)],color:a,opacity:i,width:Re,isOverstruck:!0})})},Ee=.55,Me=1.5,je=(e,t)=>{const r=b(t),n=[],a=Math.ceil(e.height/12),i=Math.ceil(e.width/8);for(let l=0;l<a;l+=1){const d=e.height-(l+.5)*12;for(let s=0;s<i;s+=1)n.push(r("/",(s+.5)*8,d,5,8,s,l))}return n},ee=({layer:e,coordSystem:t,panel:r})=>{const n=E(e),a=W("typewriter-area"),i=(0,R.useMemo)(()=>{if(t===void 0)return I(e,c=>J(c,r),w,r).map(c=>({...c,fill:c.path,edge:c.path}));const{areaGenerator:l,lineGenerator:d}=(0,o.createAreaPathGenerators)(t,e.params),s=new Map;return I(e,c=>{const g=(0,o.prepareAreaObservations)(c,e.params.missingValues),u=l(g),f=d(g);if(!u)return null;const y=H(u,r);return f&&s.set(y,H(f,r)),y},j,r).map(c=>({...c,fill:c.path,edge:s.get(c.path)??""}))},[e,t,r]);return r.width<=0||r.height<=0?null:(0,h.jsx)("g",{"data-geom":"area",children:i.map(({key:l,observation:d,fill:s,edge:c},g)=>{const u=n(d);return(0,h.jsxs)("g",{opacity:u.opacity,children:[(0,h.jsx)("clipPath",{id:`${a}-${g}`,children:(0,h.jsx)("path",{d:s})}),(0,h.jsx)("path",{d:s,fill:p.paper}),(0,h.jsx)("path",{d:s,fill:u.color,fillOpacity:u.fillOpacity*Ee}),(0,h.jsx)("g",{clipPath:`url(#${a}-${g})`,children:(0,h.jsx)(A,{strikes:je(r,l),color:u.color,opacity:u.fillOpacity})}),(0,h.jsx)("path",{d:c,fill:"none",stroke:u.color,strokeWidth:Me,strokeLinejoin:"round",strokeLinecap:"round"})]},l)})})},te=({layer:e,observation:t,panel:r,project:n})=>{const a=E(e)(t,"hovered");return(0,h.jsx)(Q,{geom:"area",observation:t,panel:r,project:n,color:a.color,opacity:a.opacity})},Te=(0,o.defineGeomRenderer)("area",{coord:"cartesian",guideMode:"crosshair",swatchShape:"area",render:({layer:e,coordSystem:t,panelRect:r})=>t.type!=="cartesian"?null:(0,h.jsx)(ee,{layer:e,coordSystem:t,panel:r}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,h.jsx)(te,{layer:e,observation:t.observation,panel:r,project:j}),renderHoverCompanions:()=>null}),Pe=(0,o.defineGeomRenderer)("area",{coord:"polar",guideMode:"crosshair",swatchShape:"area",render:({layer:e,panelRect:t})=>(0,h.jsx)(ee,{layer:e,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,h.jsx)(te,{layer:e,observation:t.observation,panel:r,project:w}),renderHoverCompanions:()=>null}),_e=2,re=1.8,$e=1,Ie=3.3,be={solo:{base:!0,value:!0},floor:{base:!0,value:!1},ceiling:{base:!1,value:!0},middle:{base:!1,value:!1}},We={top:"bottom",bottom:"top",left:"right",right:"left"},Le=(e,t)=>t==="x"?((0,o.getYMax)(e)??(0,o.getY)(e)??0)>=((0,o.getYMin)(e)??0)?"top":"bottom":((0,o.getXMax)(e)??0)>=((0,o.getXMin)(e)??0)?"right":"left",He=(e,t,r)=>{const n=Math.max(0,e.width-r),a=Math.max(0,e.height-r);return t==="top"?{...e,y:e.y+e.height-a,height:a}:t==="bottom"?{...e,height:a}:t==="left"?{...e,x:e.x+e.width-n,width:n}:{...e,width:n}},O=(e,t)=>{const r=Math.max(1,Math.round(e/t));return{count:r,size:e/r}},K=(e,t,r)=>{const n=[];for(let a=Ie+r/2;a-r/2<e;a+=t)n.push(a);return n},Oe=(e,t,r)=>{const n=b(r),a=t==="top"||t==="bottom",i=a?O(e.width,8):O(e.height,12),l=a?Math.min(5,i.size-2):5,d=a?8:Math.max(1,Math.min(8,i.size-4));return(a?K(e.height,12,8):K(e.width,8,5)).flatMap((s,c)=>Array.from({length:i.count},(g,u)=>{const f=(u+.5)*i.size;if(t==="top")return n("X",e.x+f,e.y+s,l,d,u,c);if(t==="bottom")return n("X",e.x+f,e.y+e.height-s,l,d,u,c);const y=t==="right"?e.x+e.width-s:e.x+s;return n("X",y,e.y+f,l,d,c,u)}))},Ge=(e,t)=>{const r=t==="top"||t==="bottom",n=O(r?e.width:e.height,r?8:12),a=Math.max(1,n.size-$e),i=re/2;return Array.from({length:n.count},(l,d)=>{const s=(d+.5)*n.size;return t==="top"?S("_",e.x+s,e.y+i,a,0):t==="bottom"?S("_",e.x+s,e.y+e.height-i,a,0):S("|",t==="right"?e.x+e.width-i:e.x+i,e.y+s,0,a)})},Ce=({layer:e,observation:t,seed:r,mainAxis:n,panel:a,clipId:i,state:l})=>{const d=E(e),s=(0,o.getBarRectBounds)(n,t);if(!s||s.width<=0||s.height<=0)return null;const c=d(t,l),g=be[(0,o.getStackRole)(t)],u=Le(t,n),f={x:s.x*a.width,y:s.y*a.height,width:s.width*a.width,height:s.height*a.height},y=[g.value?[]:[u],g.base?[]:[We[u]]].flat().reduce((oe,ie)=>He(oe,ie,_e/2),f);if(y.width<=0||y.height<=0)return null;const T=Oe(y,u,r),G=l==="hovered";return(0,h.jsxs)("g",{opacity:c.opacity,children:[(0,h.jsx)("clipPath",{id:i,children:(0,h.jsx)("rect",{...y})}),(0,h.jsx)("rect",{...y,fill:p.paper}),(0,h.jsx)("g",{clipPath:`url(#${i})`,children:(0,h.jsx)(A,{strikes:T,color:c.color,opacity:c.fillOpacity,isOverstruck:G})}),(0,h.jsx)(A,{strikes:Ge(y,u),color:c.color,width:re,isOverstruck:G})]})},Y=({layer:e,observations:t,mainAxis:r,panel:n,state:a})=>{const i=W("typewriter-bar"),l=(0,R.useMemo)(()=>(0,o.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return n.width<=0||n.height<=0?null:(0,h.jsx)("g",{"data-geom":"bar",children:Array.from(t,(d,s)=>{const c=l(d);return(0,h.jsx)(Ce,{layer:e,observation:d,seed:c,mainAxis:r,panel:n,clipId:`${i}-${s}`,state:a},c)})})},Be=(0,o.defineGeomRenderer)("bar",{coord:"cartesian",guideMode:"band",swatchShape:"square",render:({layer:e,coordSystem:t,panelRect:r})=>(0,h.jsx)(Y,{layer:e,observations:e.data,mainAxis:(0,o.readMainAxis)(t),panel:r}),renderHover:({layer:e,coordSystem:t,primary:r,panelRect:n})=>(0,h.jsx)(Y,{layer:e,observations:[r.observation],mainAxis:(0,o.readMainAxis)(t),panel:n,state:"hovered"}),renderHoverCompanions:()=>null}),De=({layer:e,panel:t,coord:r})=>{const n=Z(e),a=(0,R.useMemo)(()=>{if(r==="polar")return I(e,l=>J(l,t),w,t);const i=(0,o.createLinePathGenerator)(e.params);return I(e,l=>{const d=i((0,o.prepareLineObservations)(l,e.params.missingValues));return d?H(d,t):null},j,t)},[e,t,r]);return t.width<=0||t.height<=0?null:(0,h.jsx)("g",{"data-geom":"line",children:a.map(({key:i,path:l,observation:d,readings:s})=>{const c=n(d);return(0,h.jsxs)("g",{children:[(0,h.jsx)("path",{d:l,fill:"none",stroke:c.color,strokeOpacity:c.opacity,strokeWidth:c.width,strokeDasharray:c.dashArray,strokeLinejoin:"round",strokeLinecap:"round"}),(0,h.jsx)(we,{readings:s,color:c.color,opacity:c.opacity})]},i)})})},ze=({layer:e,observation:t,panel:r,project:n})=>{const a=Z(e)(t,"hovered");return(0,h.jsx)(Q,{geom:"line",observation:t,panel:r,project:n,color:a.color,opacity:a.opacity})},ne=(e,t)=>(0,o.defineGeomRenderer)("line",{coord:e,guideMode:"crosshair",swatchShape:"line",render:({layer:r,panelRect:n})=>(0,h.jsx)(De,{layer:r,panel:n,coord:e}),renderHover:({layer:r,primary:n,panelRect:a})=>(0,h.jsx)(ze,{layer:r,observation:n.observation,panel:a,project:t}),renderHoverCompanions:()=>null,getOverlayAnchor:({observation:r})=>{const n=(0,o.getX)(r),a=(0,o.getY)(r);return n===null||a===null?null:{x:n,y:a}}}),Ne=ne("cartesian",j),Xe=ne("polar",w),Ke=.85,Ye=1.6,Fe=4,F=({layer:e,observations:t,panel:r,project:n,state:a})=>{const i=(0,o.useGeomStyleReader)(e),l=E(e),d=(0,R.useMemo)(()=>(0,o.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]),s=a==="hovered",c=s?Fe:0;return(0,h.jsx)("g",{"data-geom":"point",children:Array.from(t,g=>{const u=n(g,r);if(u===null)return null;const f=l(g,a),y=i.get("size",g,a)+c;return(0,h.jsx)(A,{strikes:[S("o",u.x,u.y,y*Ke,y)],color:f.color,opacity:f.opacity,width:Ye,isOverstruck:s},d(g))})})},ae=(e,t)=>(0,o.defineGeomRenderer)("point",{coord:e,swatchShape:"circle",render:({layer:r,panelRect:n})=>(0,h.jsx)(F,{layer:r,observations:r.data,panel:n,project:t}),renderHover:({layer:r,primary:n,panelRect:a})=>(0,h.jsx)(F,{layer:r,observations:[n.observation],panel:a,project:t,state:"hovered"}),renderHoverCompanions:()=>null}),Ve=ae("cartesian",j),Ue=ae("polar",w),Ze=4,qe=1.2,Je=3,$=Math.PI*2,Qe=.3,et=(e,t)=>{const{startAngle:r,endAngle:n}=(0,o.getAngleExtent)(e),{innerRadius:a,outerRadius:i}=(0,o.getRadiusExtent)(e);if(r===null||n===null||a===null||i===null)return null;const l=Math.min(t.width,t.height)/2;if(l<=0||i<=0)return null;const d=Math.max(0,n-r),s=Ze/2/(i*l),c=d>=$-1e-6?0:Math.min(s,d/4),g=r+c,u=n-c,f=(0,o.buildPolarBarArcPath)({startAngle:g,endAngle:u,innerRadius:a,outerRadius:i},{centerX:t.width/2,centerY:t.height/2,radius:l,digits:Je});return f===void 0?null:{path:f,startAngle:g,endAngle:u,inner:a*l,outer:i*l}},tt=(e,t,r,n)=>{const a=Math.hypot(t,r);if(a>e.outer-n||a<e.inner+n)return!1;const i=((Math.atan2(t,-r)-e.startAngle)%$+$)%$,l=n/Math.max(a,1);return i>=l&&i<=e.endAngle-e.startAngle-l},rt=(e,t,r)=>{const n=b(r),a=Math.ceil(e.outer/8)+1,i=Math.ceil(e.outer/12)+1,l=-Math.hypot(8,12)/2,d=[];for(let s=-i;s<=i;s+=1)for(let c=-a;c<=a;c+=1){const g=c*8,u=s*12;tt(e,g,u,l)&&d.push(n("/",t.width/2+g,t.height/2+u,5,8,c,s))}return d},V=({layer:e,observations:t,panel:r,state:n})=>{const a=E(e),i=W("slice-shading"),l=(0,R.useMemo)(()=>(0,o.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return r.width<=0||r.height<=0?null:(0,h.jsx)("g",{"data-geom":"bar",children:Array.from(t,d=>{const s=et(d,r);if(s===null)return null;const c=l(d),g=a(d,n),u=`${i}-${c.replace(/[^a-zA-Z0-9]/gu,"")}`;return(0,h.jsxs)("g",{opacity:g.opacity,children:[(0,h.jsx)("path",{d:s.path,fill:p.paper}),(0,h.jsxs)("g",{children:[(0,h.jsx)("clipPath",{id:u,children:(0,h.jsx)("path",{d:s.path})}),(0,h.jsx)("path",{d:s.path,fill:g.color,fillOpacity:g.fillOpacity*Qe}),(0,h.jsx)("g",{clipPath:`url(#${u})`,children:(0,h.jsx)(A,{strikes:rt(s,r,c),color:g.color,opacity:g.fillOpacity,isOverstruck:n==="hovered"})})]}),(0,h.jsx)("path",{d:s.path,fill:"none",stroke:g.color,strokeWidth:qe,strokeLinejoin:"round"})]},c)})})},nt=(0,o.defineGeomRenderer)("bar",{coord:"polar",guideMode:"band",swatchShape:"slice",render:({layer:e,panelRect:t})=>(0,h.jsx)(V,{layer:e,observations:e.data,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,h.jsx)(V,{layer:e,observations:[t.observation],panel:r,state:"hovered"}),renderHoverCompanions:()=>null}),_=2,at=.2,ot=(e,t)=>{const r=b(t),n=[],a=Math.floor(e.y/12),i=Math.floor(e.x/8);for(let l=a;l*12<e.y+e.height;l+=1)for(let d=i;d*8<e.x+e.width;d+=1){const s=(d+.5)*8,c=(l+.5)*12;n.push(r("X",s,c,5,8,d,l))}return n},it=({layer:e,observation:t,seed:r,panel:n,clipId:a,state:i})=>{const l=E(e),d=(0,o.getPaintedTileRect)(t);if(d===null)return null;const s=l(t,i),c={x:d.x*n.width+_/2,y:d.y*n.height+_/2,width:Math.max(0,d.width*n.width-_),height:Math.max(0,d.height*n.height-_)};return c.width<=0||c.height<=0?null:(0,h.jsxs)("g",{opacity:s.opacity,children:[(0,h.jsx)("clipPath",{id:a,children:(0,h.jsx)("rect",{...c})}),(0,h.jsx)("rect",{...c,fill:s.color,fillOpacity:s.fillOpacity}),(0,h.jsx)("g",{clipPath:`url(#${a})`,children:(0,h.jsx)(A,{strikes:ot(c,r),color:p.paper,opacity:at,isOverstruck:i==="hovered"})}),i==="hovered"&&(0,h.jsx)("rect",{...c,fill:"none",stroke:p.text,strokeWidth:s.edgeWidth})]})},U=({layer:e,observations:t,panel:r,state:n})=>{const a=W("typewriter-tile"),i=(0,R.useMemo)(()=>(0,o.createStableCellKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return r.width<=0||r.height<=0?null:(0,h.jsx)("g",{"data-geom":"tile",children:Array.from(t,(l,d)=>{const s=i(l);return(0,h.jsx)(it,{layer:e,observation:l,seed:s,panel:r,clipId:`${a}-${d}`,state:n},s)})})},st=(0,o.defineGeomRenderer)("tile",{coord:"cartesian",guideMode:null,swatchShape:"square",render:({layer:e,panelRect:t})=>(0,h.jsx)(U,{layer:e,observations:e.data,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,h.jsx)(U,{layer:e,observations:[t.observation],panel:r,state:"hovered"}),renderHoverCompanions:()=>null}),lt=[Be,nt,st,Ne,Xe,Te,Pe,Ve,Ue],dt={name:"typewriter",styles:ce,palettes:{categorical:le,sequential:de,diverging:he},config:{axes:{y:{position:"left"}}},colorScheme:"light",plugins:lt};exports.typewriter=dt;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let k=require("react"),i=require("@graphysdk/react"),s=require("react/jsx-runtime");var p={paper:"#EBD9A9",card:"#F8F0D8",text:"#1F1B16",secondary:"#4A443A",grid:"rgba(31, 27, 22, 0.4)",edge:"#C4AE74"},le="'Special Elite', 'Courier New', ui-monospace, monospace",y={black:"#1F1B16",red:"#B3271E",carbonBlue:"#2F4F8F",pencilGrey:"#6E6A62",stampGreen:"#2E6B4B",duplicatorViolet:"#7B5A9C"},de=[y.black,y.red,y.carbonBlue,y.pencilGrey,y.stampGreen,y.duplicatorViolet],he=["#D6C18B",y.black],ce=[y.carbonBlue,"#DECEA4",y.red],R={fontWeight:400,textColor:p.text},_={...R,fontSize:13,fill:p.paper,stroke:"transparent",strokeWidth:0,cornerRadius:0,paddingInline:3,paddingBlock:1,shadow:"none"},v={fontWeight:400,textColor:p.secondary},H={fill:p.card,stroke:p.text,strokeWidth:1,cornerRadius:0,shadow:"none"},ue={tokens:{graphBackground:p.paper,graphBorder:p.edge,geomBorder:p.text,textPrimary:p.text,textSecondary:p.secondary,ruleLine:p.text,gridLine:p.grid,hoverAffordance:p.paper,hoverGuideFill:"rgba(31, 27, 22, 0.07)",hoverGuideLine:p.secondary,tooltipBackground:p.card,tooltipBorder:p.text,tooltipPrimaryRow:"rgba(31, 27, 22, 0.08)",annotationShape:y.red,annotationArrow:p.text,differenceLabelBackground:p.card,trendPositive:y.black,trendNegative:y.red,trendNeutral:y.pencilGrey},defaults:[i.style.graph({strokeWidth:1,cornerRadius:0,fontFamily:le,fontWeight:400,padding:24}),i.style.geom({shadow:"none"}),i.style.geom({shadow:"none"},{state:"hovered"}),i.style.geom.bar({stroke:p.text,strokeWidth:1,cornerRadius:"none"}),i.style.geom.line({strokeWidth:2,dashArray:[],lineCap:"butt",lineJoin:"miter"}),i.style.geom.area({fillAlpha:.6,strokeWidth:1.5,dashArray:[],lineCap:"butt",lineJoin:"miter"}),i.style.geom.point({size:9,stroke:p.paper,strokeWidth:1.5}),i.style.geom.tile({cornerRadius:0,stroke:p.paper,strokeWidth:2}),i.style.geom.rule({stroke:y.red,strokeWidth:1.5,dashArray:[5,4]}),i.style.geom.rule.label({...R,fontSize:13}),i.style.gridLine({dashArray:[5,4]}),i.style.panelBorder({strokeWidth:0,cornerRadius:0}),i.style.panelBorder.left({stroke:p.text,strokeWidth:1,dashArray:[]}),i.style.panelBorder.bottom({stroke:p.text,strokeWidth:1,dashArray:[]}),i.style.tickLine({strokeWidth:0}),i.style.tickLabel({...v,fontSize:13,lineHeight:1}),i.style.axisLabel({...v,fontSize:12,lineHeight:1,letterSpacing:1,textTransform:"uppercase"}),i.style.axisLabel.top({margin:{bottom:14}}),i.style.heading({...R}),i.style.heading.h1({fontSize:19,lineHeight:1.15,letterSpacing:1.5,textTransform:"uppercase",textDecoration:"underline"}),i.style.heading.h2({...v,fontSize:15,lineHeight:1.2}),i.style.header({margin:{bottom:18}}),i.style.caption({...v,fontSize:12.5}),i.style.source({...v,fontSize:12.5}),i.style.source.link({...v,fontSize:12.5}),i.style.dataLabel({...R,fontSize:13,fill:"transparent",cornerRadius:0}),i.style.legendItem({...v,fontSize:13,fill:"transparent",stroke:"transparent"}),i.style.legend.popover({...H}),i.style.directLabel({fontWeight:400,fontSize:13}),i.style.headlineItem.number({...R}),i.style.headlineItem.caption({...v}),i.style.headlineItem.label({...v}),i.style.headlineItem.trend({fontWeight:400}),i.style.tooltip({...H,paddingInline:12,paddingBlock:9}),i.style.tooltip.heading({...R,fontSize:13,lineHeight:1.3,letterSpacing:1,textTransform:"uppercase"}),i.style.tooltip.label({...v,fontSize:13,lineHeight:1.4}),i.style.tooltip.value({...R,fontSize:13,lineHeight:1.4}),i.style.annotation.text({..._,paddingInline:4,paddingBlock:2,lineHeight:1.3}),i.style.annotation.pinnedNumber({fill:y.red,stroke:p.paper,shadow:"none"}),i.style.annotation.pinnedNumber.label({..._}),i.style.annotation.comment({fill:y.red,stroke:p.paper,shadow:"none"}),i.style.annotation.comment.label({..._}),i.style.annotation.differenceArrow({stroke:p.text,strokeWidth:1.5}),i.style.annotation.differenceArrow.label({..._}),i.style.annotation.arrow({stroke:p.text,strokeWidth:1.5,dashArray:[]}),i.style.annotation.shape({fill:p.text,fillAlpha:.06,stroke:p.secondary,strokeWidth:.75}),i.style.geom.area({fillAlpha:.45},{coord:"polar"}),i.style.panelBorder.left({strokeWidth:0},{coord:"polar"}),i.style.panelBorder.bottom({strokeWidth:0},{coord:"polar"}),i.style.tickLabel({textColor:p.text,fontSize:14,fontWeight:700,textOutlineColor:p.paper,textOutlineWidth:8},{coord:"polar"})]},pe=/[a-df-zA-DF-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/gu,ge=/^[a-zA-Z]$/u,fe=(e,t)=>e==="H"?"x":e==="V"?"y":t%2===0?"x":"y",G=(e,t)=>{let r="",n=0;return(e.match(pe)??[]).map(a=>{if(ge.test(a))return r=a.toUpperCase(),n=0,a;const o=fe(r,n);return n+=1,String(Number(a)*(o==="x"?t.width:t.height))}).join(" ")},T=(e,t)=>{const r=(0,i.getX)(e),n=(0,i.getY)(e)??(0,i.getYMax)(e);return r===null||n===null?null:{x:(0,i.toViewBoxX)(r)*t.width,y:(0,i.toViewBoxY)(n)*t.height}},j=(e,t)=>{const r=(0,i.getX)(e),n=(0,i.getY)(e)??(0,i.getRadiusExtent)(e).outerRadius;if(r===null||n===null)return null;const a=(0,i.polarToUnit)(r,n),o=Math.min(t.width,t.height)/2;return{x:t.width/2+a.x*o,y:t.height/2-a.y*o}},ye=e=>`${e.map((t,r)=>`${r===0?"M":"L"}${t.x},${t.y}`).join(" ")} Z`,w=e=>{const t=(0,i.useGeomStyleReader)(e);return(r,n)=>({color:(0,i.toPaintColor)(t.get("fill",r,n)),opacity:t.get("alpha",r,n),fillOpacity:t.get("fillAlpha",r,n),edge:t.get("stroke",r,n),edgeWidth:t.get("strokeWidth",r,n)})},U=e=>{const t=(0,i.useGeomStyleReader)(e);return(r,n)=>{const a=t.get("strokeWidth",r,n);return{color:t.get("stroke",r,n),opacity:t.get("alpha",r,n)*t.get("strokeAlpha",r,n),width:a,dashArray:(0,i.toStrokeDasharray)(t.get("dashArray",r,n),a)}}},xe=1.3,E=[.72,.87,1],C=.35,me=.7,B=100,D=.7,ve=4,Ae=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0},L=(e,t,r,n)=>{let a=Math.imul(e^Math.imul(t,374761393)^Math.imul(r,668265263)^n,1274126177);return a=Math.imul(a^a>>>13,1103515245),((a^a>>>16)>>>0)/4294967296},x=e=>Math.round(e*B)/B,Z=(e,t,r,n,a)=>{const o=x(t-n/2),d=x(t+n/2),l=x(r-a/2),h=x(r+a/2),c=`M${o},${l}L${d},${h}M${d},${l}L${o},${h}`;if(e==="x"||e==="X"&&n<ve)return c;if(e==="X"){const f=(m,P)=>`M${x(m-D)},${P}L${x(m+D)},${P}`;return`${c}${f(o,l)}${f(d,l)}${f(o,h)}${f(d,h)}`}if(e==="/")return`M${o},${h}L${d},${l}`;if(e==="_")return`M${o},${x(r)}L${d},${x(r)}`;if(e==="|")return`M${x(t)},${l}L${x(t)},${h}`;const g=x(n/2),u=x(a/2);return`M${o},${x(r)}a${g},${u} 0 1,0 ${x(n)},0a${g},${u} 0 1,0 ${-x(n)},0`},W=e=>{const t=Ae(e);return(r,n,a,o,d,l,h)=>{const c=(L(t,l,h,1)*2-1)*C,g=(L(t,l,h,2)*2-1)*C,u=Math.floor(L(t,l,h,3)*E.length);return{path:Z(r,n+c,a+g,o,d),weight:u}}},M=(e,t,r,n,a)=>({path:Z(e,t,r,n,a),weight:E.length-1}),S=e=>`${e}-${(0,k.useId)().replace(/[^a-zA-Z0-9]/gu,"")}`,A=({strikes:e,color:t,opacity:r=1,width:n=xe,isOverstruck:a=!1})=>e.length===0?null:(0,s.jsxs)("g",{fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",opacity:r,children:[E.map((o,d)=>e.filter(l=>l.weight===d).map(l=>l.path).join("")).map((o,d)=>o===""?null:(0,s.jsx)("path",{d:o,strokeOpacity:E[d]},E[d])),a&&(0,s.jsx)("path",{d:e.map(o=>o.path).join(""),transform:`translate(${me},0)`})]}),z=6,ke=14,Re=1.5,N=10,Me=1.8,b=(e,t,r,n)=>{const a=(0,i.createStableKeyGenerator)(e.data,e.mapping,e.id),o=[];return e.data.groupBy(i.GROUP_VARIABLES.group).forEach(d=>{const l=[...d],[h]=l,c=t(l);if(h===void 0||c===null)return;const g=l.flatMap(u=>r(u,n)??[]);o.push({key:a(h),observation:h,path:c,readings:g})}),o},q=(e,t)=>{const r=e.flatMap(n=>{const a=(0,i.getX)(n),o=j(n,t);return a===null||o===null?[]:[{angle:a,point:o}]}).sort((n,a)=>n.angle-a.angle).map(({point:n})=>n);return r.length===0?null:ye(r)},je=e=>e.every((t,r)=>{const n=e[r+1];return n===void 0||Math.hypot(n.x-t.x,n.y-t.y)>=ke}),we=({readings:e,color:t,opacity:r})=>je(e)?(0,s.jsx)(A,{strikes:e.map(({x:n,y:a})=>M("x",n,a,z,z)),color:t,opacity:r,width:Re}):null,J=({geom:e,observation:t,panel:r,project:n,color:a,opacity:o})=>{const d=n(t,r);return d===null?null:(0,s.jsx)("g",{"data-geom":e,children:(0,s.jsx)(A,{strikes:[M("X",d.x,d.y,N,N)],color:a,opacity:o,width:Me,isOverstruck:!0})})},Q=.55,Se=1.5,ee=(e,t,r={x:0,y:0,...e})=>{const n=W(t),a=[],o=Math.max(0,Math.floor((e.height-r.y-r.height)/12-.5)),d=Math.min(Math.ceil(e.height/12),Math.ceil((e.height-r.y)/12)),l=Math.max(0,Math.floor(r.x/8)),h=Math.min(Math.ceil(e.width/8),Math.ceil((r.x+r.width)/8));for(let c=o;c<d;c+=1){const g=e.height-(c+.5)*12;for(let u=l;u<h;u+=1)a.push(n("/",(u+.5)*8,g,5,8,u,c))}return a},te=({layer:e,coordSystem:t,panel:r})=>{const n=w(e),a=S("typewriter-area"),o=(0,k.useMemo)(()=>{if(t===void 0)return b(e,c=>q(c,r),j,r).map(c=>({...c,fill:c.path,edge:c.path}));const{areaGenerator:d,lineGenerator:l}=(0,i.createAreaPathGenerators)(t,e.params),h=new Map;return b(e,c=>{const g=(0,i.prepareAreaObservations)(c,e.params.missingValues),u=d(g),f=l(g);if(!u)return null;const m=G(u,r);return f&&h.set(m,G(f,r)),m},T,r).map(c=>({...c,fill:c.path,edge:h.get(c.path)??""}))},[e,t,r]);return r.width<=0||r.height<=0?null:(0,s.jsx)("g",{"data-geom":"area",children:o.map(({key:d,observation:l,fill:h,edge:c},g)=>{const u=n(l);return(0,s.jsxs)("g",{opacity:u.opacity,children:[(0,s.jsx)("clipPath",{id:`${a}-${g}`,children:(0,s.jsx)("path",{d:h})}),(0,s.jsx)("path",{d:h,fill:p.paper}),(0,s.jsx)("path",{d:h,fill:u.color,fillOpacity:u.fillOpacity*Q}),(0,s.jsx)("g",{clipPath:`url(#${a}-${g})`,children:(0,s.jsx)(A,{strikes:ee(r,d),color:u.color,opacity:u.fillOpacity})}),(0,s.jsx)("path",{d:c,fill:"none",stroke:u.color,strokeWidth:Se,strokeLinejoin:"round",strokeLinecap:"round"})]},d)})})},re=({layer:e,observation:t,panel:r,project:n})=>{const a=w(e)(t,"hovered");return(0,s.jsx)(J,{geom:"area",observation:t,panel:r,project:n,color:a.color,opacity:a.opacity})},Ee=(0,i.defineGeomRenderer)("area",{coord:"cartesian",guideMode:"crosshair",swatchShape:"area",render:({layer:e,coordSystem:t,panelRect:r})=>t.type!=="cartesian"?null:(0,s.jsx)(te,{layer:e,coordSystem:t,panel:r}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,s.jsx)(re,{layer:e,observation:t.observation,panel:r,project:T}),renderHoverCompanions:()=>null}),Te=(0,i.defineGeomRenderer)("area",{coord:"polar",guideMode:"crosshair",swatchShape:"area",render:({layer:e,panelRect:t})=>(0,s.jsx)(te,{layer:e,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,s.jsx)(re,{layer:e,observation:t.observation,panel:r,project:j}),renderHoverCompanions:()=>null}),Pe=2,ne=1.8,_e=1,$e=3.3,Ie={solo:{base:!0,value:!0},floor:{base:!0,value:!1},ceiling:{base:!1,value:!0},middle:{base:!1,value:!1}},be={top:"bottom",bottom:"top",left:"right",right:"left"},We=(e,t)=>t==="x"?((0,i.getYMax)(e)??(0,i.getY)(e)??0)>=((0,i.getYMin)(e)??0)?"top":"bottom":((0,i.getXMax)(e)??0)>=((0,i.getXMin)(e)??0)?"right":"left",Le=(e,t,r)=>{const n=Math.max(0,e.width-r),a=Math.max(0,e.height-r);return t==="top"?{...e,y:e.y+e.height-a,height:a}:t==="bottom"?{...e,height:a}:t==="left"?{...e,x:e.x+e.width-n,width:n}:{...e,width:n}},O=(e,t)=>{const r=Math.max(1,Math.round(e/t));return{count:r,size:e/r}},X=(e,t,r)=>{const n=[];for(let a=$e+r/2;a-r/2<e;a+=t)n.push(a);return n},Ge=(e,t,r)=>{const n=W(r),a=t==="top"||t==="bottom",o=a?O(e.width,8):O(e.height,12),d=a?Math.min(5,o.size-2):5,l=a?8:Math.max(1,Math.min(8,o.size-4));return(a?X(e.height,12,8):X(e.width,8,5)).flatMap((h,c)=>Array.from({length:o.count},(g,u)=>{const f=(u+.5)*o.size;if(t==="top")return n("X",e.x+f,e.y+h,d,l,u,c);if(t==="bottom")return n("X",e.x+f,e.y+e.height-h,d,l,u,c);const m=t==="right"?e.x+e.width-h:e.x+h;return n("X",m,e.y+f,d,l,c,u)}))},Oe=(e,t)=>{const r=t==="top"||t==="bottom",n=O(r?e.width:e.height,r?8:12),a=Math.max(1,n.size-_e),o=ne/2;return Array.from({length:n.count},(d,l)=>{const h=(l+.5)*n.size;return t==="top"?M("_",e.x+h,e.y+o,a,0):t==="bottom"?M("_",e.x+h,e.y+e.height-o,a,0):M("|",t==="right"?e.x+e.width-o:e.x+o,e.y+h,0,a)})},He=({layer:e,observation:t,seed:r,mainAxis:n,panel:a,clipId:o,state:d})=>{const l=w(e),h=(0,i.getBarRectBounds)(n,t);if(!h||h.width<=0||h.height<=0)return null;const c=l(t,d),g=Ie[(0,i.getStackRole)(t)],u=We(t,n),f={x:h.x*a.width,y:h.y*a.height,width:h.width*a.width,height:h.height*a.height},m=[g.value?[]:[u],g.base?[]:[be[u]]].flat().reduce((P,se)=>Le(P,se,Pe/2),f);return m.width<=0||m.height<=0?null:(0,s.jsx)(ae,{rect:m,edge:u,seed:r,clipId:o,color:c.color,opacity:c.opacity,pressure:c.fillOpacity,isOverstruck:d==="hovered"})},ae=({rect:e,edge:t,seed:r,clipId:n,color:a,opacity:o,pressure:d,isOverstruck:l})=>(0,s.jsxs)("g",{opacity:o,children:[(0,s.jsx)("clipPath",{id:n,children:(0,s.jsx)("rect",{...e})}),(0,s.jsx)("rect",{...e,fill:p.paper}),(0,s.jsx)("g",{clipPath:`url(#${n})`,children:(0,s.jsx)(A,{strikes:Ge(e,t,r),color:a,opacity:d,isOverstruck:l})}),(0,s.jsx)(A,{strikes:Oe(e,t),color:a,width:ne,isOverstruck:l})]}),K=({layer:e,observations:t,mainAxis:r,panel:n,state:a})=>{const o=S("typewriter-bar"),d=(0,k.useMemo)(()=>(0,i.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return n.width<=0||n.height<=0?null:(0,s.jsx)("g",{"data-geom":"bar",children:Array.from(t,(l,h)=>{const c=d(l);return(0,s.jsx)(He,{layer:e,observation:l,seed:c,mainAxis:r,panel:n,clipId:`${o}-${h}`,state:a},c)})})},Ce=(0,i.defineGeomRenderer)("bar",{coord:"cartesian",guideMode:"band",swatchShape:"square",render:({layer:e,coordSystem:t,panelRect:r})=>(0,s.jsx)(K,{layer:e,observations:e.data,mainAxis:(0,i.readMainAxis)(t),panel:r}),renderHover:({layer:e,coordSystem:t,primary:r,panelRect:n})=>(0,s.jsx)(K,{layer:e,observations:[r.observation],mainAxis:(0,i.readMainAxis)(t),panel:n,state:"hovered"}),renderHoverCompanions:()=>null}),Be=({layer:e,panel:t,coord:r})=>{const n=U(e),a=(0,k.useMemo)(()=>{if(r==="polar")return b(e,d=>q(d,t),j,t);const o=(0,i.createLinePathGenerator)(e.params);return b(e,d=>{const l=o((0,i.prepareLineObservations)(d,e.params.missingValues));return l?G(l,t):null},T,t)},[e,t,r]);return t.width<=0||t.height<=0?null:(0,s.jsx)("g",{"data-geom":"line",children:a.map(({key:o,path:d,observation:l,readings:h})=>{const c=n(l);return(0,s.jsxs)("g",{children:[(0,s.jsx)("path",{d,fill:"none",stroke:c.color,strokeOpacity:c.opacity,strokeWidth:c.width,strokeDasharray:c.dashArray,strokeLinejoin:"round",strokeLinecap:"round"}),(0,s.jsx)(we,{readings:h,color:c.color,opacity:c.opacity})]},o)})})},De=({layer:e,observation:t,panel:r,project:n})=>{const a=U(e)(t,"hovered");return(0,s.jsx)(J,{geom:"line",observation:t,panel:r,project:n,color:a.color,opacity:a.opacity})},ie=(e,t)=>(0,i.defineGeomRenderer)("line",{coord:e,guideMode:"crosshair",swatchShape:"line",render:({layer:r,panelRect:n})=>(0,s.jsx)(Be,{layer:r,panel:n,coord:e}),renderHover:({layer:r,primary:n,panelRect:a})=>(0,s.jsx)(De,{layer:r,observation:n.observation,panel:a,project:t}),renderHoverCompanions:()=>null,getOverlayAnchor:({observation:r})=>{const n=(0,i.getX)(r),a=(0,i.getY)(r);return n===null||a===null?null:{x:n,y:a}}}),ze=ie("cartesian",T),Ne=ie("polar",j),Xe=.85,Ke=1.6,Ye=4,Y=({layer:e,observations:t,panel:r,project:n,state:a})=>{const o=(0,i.useGeomStyleReader)(e),d=w(e),l=(0,k.useMemo)(()=>(0,i.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]),h=a==="hovered",c=h?Ye:0;return(0,s.jsx)("g",{"data-geom":"point",children:Array.from(t,g=>{const u=n(g,r);if(u===null)return null;const f=d(g,a),m=o.get("size",g,a)+c;return(0,s.jsx)(A,{strikes:[M("o",u.x,u.y,m*Xe,m)],color:f.color,opacity:f.opacity,width:Ke,isOverstruck:h},l(g))})})},oe=(e,t)=>(0,i.defineGeomRenderer)("point",{coord:e,swatchShape:"circle",render:({layer:r,panelRect:n})=>(0,s.jsx)(Y,{layer:r,observations:r.data,panel:n,project:t}),renderHover:({layer:r,primary:n,panelRect:a})=>(0,s.jsx)(Y,{layer:r,observations:[n.observation],panel:a,project:t,state:"hovered"}),renderHoverCompanions:()=>null}),Fe=oe("cartesian",T),Ve=oe("polar",j),Ue=4,Ze=1.2,qe=3,I=Math.PI*2,Je=.3,Qe=(e,t)=>{const{startAngle:r,endAngle:n}=(0,i.getAngleExtent)(e),{innerRadius:a,outerRadius:o}=(0,i.getRadiusExtent)(e);if(r===null||n===null||a===null||o===null)return null;const d=Math.min(t.width,t.height)/2;if(d<=0||o<=0)return null;const l=Math.max(0,n-r),h=Ue/2/(o*d),c=l>=I-1e-6?0:Math.min(h,l/4),g=r+c,u=n-c,f=(0,i.buildPolarBarArcPath)({startAngle:g,endAngle:u,innerRadius:a,outerRadius:o},{centerX:t.width/2,centerY:t.height/2,radius:d,digits:qe});return f===void 0?null:{path:f,startAngle:g,endAngle:u,inner:a*d,outer:o*d}},et=(e,t,r,n)=>{const a=Math.hypot(t,r);if(a>e.outer-n||a<e.inner+n)return!1;const o=((Math.atan2(t,-r)-e.startAngle)%I+I)%I,d=n/Math.max(a,1);return o>=d&&o<=e.endAngle-e.startAngle-d},tt=(e,t,r)=>{const n=W(r),a=Math.ceil(e.outer/8)+1,o=Math.ceil(e.outer/12)+1,d=-Math.hypot(8,12)/2,l=[];for(let h=-o;h<=o;h+=1)for(let c=-a;c<=a;c+=1){const g=c*8,u=h*12;et(e,g,u,d)&&l.push(n("/",t.width/2+g,t.height/2+u,5,8,c,h))}return l},F=({layer:e,observations:t,panel:r,state:n})=>{const a=w(e),o=S("slice-shading"),d=(0,k.useMemo)(()=>(0,i.createStableKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return r.width<=0||r.height<=0?null:(0,s.jsx)("g",{"data-geom":"bar",children:Array.from(t,l=>{const h=Qe(l,r);if(h===null)return null;const c=d(l),g=a(l,n),u=`${o}-${c.replace(/[^a-zA-Z0-9]/gu,"")}`;return(0,s.jsxs)("g",{opacity:g.opacity,children:[(0,s.jsx)("path",{d:h.path,fill:p.paper}),(0,s.jsxs)("g",{children:[(0,s.jsx)("clipPath",{id:u,children:(0,s.jsx)("path",{d:h.path})}),(0,s.jsx)("path",{d:h.path,fill:g.color,fillOpacity:g.fillOpacity*Je}),(0,s.jsx)("g",{clipPath:`url(#${u})`,children:(0,s.jsx)(A,{strikes:tt(h,r,c),color:g.color,opacity:g.fillOpacity,isOverstruck:n==="hovered"})})]}),(0,s.jsx)("path",{d:h.path,fill:"none",stroke:g.color,strokeWidth:Ze,strokeLinejoin:"round"})]},c)})})},rt=(0,i.defineGeomRenderer)("bar",{coord:"polar",guideMode:"band",swatchShape:"slice",render:({layer:e,panelRect:t})=>(0,s.jsx)(F,{layer:e,observations:e.data,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,s.jsx)(F,{layer:e,observations:[t.observation],panel:r,state:"hovered"}),renderHoverCompanions:()=>null}),$=2,nt=.2,at=(e,t)=>{const r=W(t),n=[],a=Math.floor(e.y/12),o=Math.floor(e.x/8);for(let d=a;d*12<e.y+e.height;d+=1)for(let l=o;l*8<e.x+e.width;l+=1){const h=(l+.5)*8,c=(d+.5)*12;n.push(r("X",h,c,5,8,l,d))}return n},it=({layer:e,observation:t,seed:r,panel:n,clipId:a,state:o})=>{const d=w(e),l=(0,i.getPaintedTileRect)(t);if(l===null)return null;const h=d(t,o),c={x:l.x*n.width+$/2,y:l.y*n.height+$/2,width:Math.max(0,l.width*n.width-$),height:Math.max(0,l.height*n.height-$)};return c.width<=0||c.height<=0?null:(0,s.jsxs)("g",{opacity:h.opacity,children:[(0,s.jsx)("clipPath",{id:a,children:(0,s.jsx)("rect",{...c})}),(0,s.jsx)("rect",{...c,fill:h.color,fillOpacity:h.fillOpacity}),(0,s.jsx)("g",{clipPath:`url(#${a})`,children:(0,s.jsx)(A,{strikes:at(c,r),color:p.paper,opacity:nt,isOverstruck:o==="hovered"})}),o==="hovered"&&(0,s.jsx)("rect",{...c,fill:"none",stroke:p.text,strokeWidth:h.edgeWidth})]})},V=({layer:e,observations:t,panel:r,state:n})=>{const a=S("typewriter-tile"),o=(0,k.useMemo)(()=>(0,i.createStableCellKeyGenerator)(e.data,e.mapping,e.id),[e.data,e.mapping,e.id]);return r.width<=0||r.height<=0?null:(0,s.jsx)("g",{"data-geom":"tile",children:Array.from(t,(d,l)=>{const h=o(d);return(0,s.jsx)(it,{layer:e,observation:d,seed:h,panel:r,clipId:`${a}-${l}`,state:n},h)})})},ot=(0,i.defineGeomRenderer)("tile",{coord:"cartesian",guideMode:null,swatchShape:"square",render:({layer:e,panelRect:t})=>(0,s.jsx)(V,{layer:e,observations:e.data,panel:t}),renderHover:({layer:e,primary:t,panelRect:r})=>(0,s.jsx)(V,{layer:e,observations:[t.observation],panel:r,state:"hovered"}),renderHoverCompanions:()=>null}),st=[Ce,rt,ot,ze,Ne,Ee,Te,Fe,Ve],lt=e=>{const t=S("typewriter-rect"),r=(0,i.useGeomPanelSize)(),n=r===null?null:(0,i.readRectPixels)(e,r);return n===null||e.fill===void 0?(0,s.jsx)(i.DefaultGeomRect,{...e}):n.width<=0||n.height<=0?null:(0,s.jsx)("g",{"data-testid":e["data-testid"],children:(0,s.jsx)(ae,{rect:n,edge:"top",seed:`${n.x},${n.y}`,clipId:t,color:e.fill,opacity:e.opacity??1,pressure:e.fillOpacity??1,isOverstruck:!1})})},dt=e=>{const t=(e.match(/-?\d*\.?\d+(?:e-?\d+)?/giu)??[]).map(Number),r=t.filter((d,l)=>l%2===0),n=t.filter((d,l)=>l%2===1);if(r.length===0||n.length===0)return null;const a=Math.min(...r),o=Math.min(...n);return{x:a,y:o,width:Math.max(...r)-a,height:Math.max(...n)-o}},ht=e=>{const t=S("typewriter-path"),r=(0,i.useGeomPanelSize)(),n=(0,k.useMemo)(()=>{const o=dt(e.d);return r===null||o===null?null:ee(r,e.d,o)},[r,e.d]);if(n===null||e.fill===void 0||e.fill.startsWith("url("))return(0,s.jsx)(i.DefaultGeomPath,{...e});const a=e.fillOpacity??1;return(0,s.jsxs)("g",{"data-testid":e["data-testid"],opacity:e.opacity??1,children:[(0,s.jsx)("clipPath",{id:t,children:(0,s.jsx)("path",{d:e.d})}),(0,s.jsx)("path",{d:e.d,fill:p.paper}),(0,s.jsx)("path",{d:e.d,fill:e.fill,fillOpacity:a*Q}),(0,s.jsx)("g",{clipPath:`url(#${t})`,children:(0,s.jsx)(A,{strikes:n,color:e.fill,opacity:a})})]})},ct={Rect:lt,Path:ht},ut={name:"typewriter",styles:ue,palettes:{categorical:de,sequential:he,diverging:ce},config:{axes:{y:{position:"left"}}},colorScheme:"light",plugins:st,shapes:ct};exports.typewriter=ut;
|