@graphysdk/geom-boxplot 0.1.1-beta.1792404455940 → 0.1.1-beta.1792409717036
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 +162 -168
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let s=require("@graphysdk/react"),W=require("react"),f=require("react/jsx-runtime");var x={q1:"boxplotQ1",median:"boxplotMedian",q3:"boxplotQ3",lowerWhisker:"boxplotLowerWhisker",upperWhisker:"boxplotUpperWhisker",count:"boxplotCount",mean:"boxplotMean",notchLower:"boxplotNotchLower",notchUpper:"boxplotNotchUpper",relativeWidth:"boxplotRelativeWidth",outlier:"boxplotOutlier"},_=e=>(e.start+e.end)/2,G=(e,t)=>{const r=t==="x"?(0,s.getXMin)(e):(0,s.getYMin)(e),o=t==="x"?(0,s.getXMax)(e):(0,s.getYMax)(e),n=t==="x"?(0,s.getYMin)(e):(0,s.getXMin)(e),a=t==="x"?(0,s.getYMax)(e):(0,s.getXMax)(e),l=(0,s.getScaledAesthetic)(e,"q1"),u=(0,s.getScaledAesthetic)(e,"median"),c=(0,s.getScaledAesthetic)(e,"q3");if(r===null||o===null||n===null||a===null||u===null||l===null||c===null)return null;const i=T(e,"notchLower"),d=T(e,"notchUpper"),[m,k]=ae(r,o,e);return{observation:e,start:m,end:k,lowerWhisker:n,q1:l,median:u,q3:c,upperWhisker:a,mean:T(e,"mean"),notch:i===null||d===null?null:{lower:i,upper:d}}},F=(e,t)=>{const r=t==="x"?(0,s.getXMin)(e):(0,s.getYMin)(e),o=t==="x"?(0,s.getXMax)(e):(0,s.getYMax)(e),n=(0,s.getScaledAesthetic)(e,"outlier");return r===null||o===null||n===null?null:{observation:e,band:_({start:r,end:o}),value:n}},S=(e,t)=>{const r=[],o=[];for(const n of e){const a=G(n,t);if(a!==null){r.push(a);continue}const l=F(n,t);l!==null&&o.push(l)}return{boxes:r,outliers:o}},T=(e,t)=>(0,s.getScaledAesthetic)(e,t)??null,ae=(e,t,r)=>{const o=r[x.relativeWidth];if(typeof o!="number")return[e,t];const n=(e+t)/2,a=(t-e)*o/2;return[n-a,n+a]},b=1.5,H=e=>e==="min-max"||typeof e=="number"&&Number.isFinite(e)&&e>=0,se=1.58,le=(e,t)=>{if(e.length===0)return null;const r=[...e].sort((m,k)=>m-k),o=B(r,.25),n=B(r,.5),a=B(r,.75),l=t==="min-max"?1/0:t*(a-o),u=o-l,c=a+l,i=r.filter(m=>m>=u&&m<=c),d=se*(a-o)/Math.sqrt(e.length);return{lowerWhisker:Math.min(i[0]??o,o),q1:o,median:n,q3:a,upperWhisker:Math.max(i[i.length-1]??a,a),count:e.length,mean:r.reduce((m,k)=>m+k,0)/r.length,notchLower:n-d,notchUpper:n+d}},B=(e,t)=>{const r=(e.length-1)*t,o=Math.floor(r),n=e[o]??0;return n+((e[o+1]??n)-n)*(r-o)},Y={q1:x.q1,median:x.median,q3:x.q3,lowerWhisker:x.lowerWhisker,upperWhisker:x.upperWhisker,count:x.count,outlier:x.outlier},z=new Set([...Object.keys(Y),"mean","notchLower","notchUpper"]),ie=class extends s.Stat{constructor(...e){super(...e),this.type="boxplot",this.computedVariables=z}computeStat({data:e,mapping:t,params:r}){const o=(0,s.readVariableName)(t.x),n=(0,s.readVariableName)(t.y);if(o===null||n===null||!e.hasVariable(o)||!e.hasVariable(n))return{data:e,mapping:{}};if(e.size()>0&&e.getType(n)!=="numeric"){const l=e.getType(n);throw new s.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'boxplot' stat requires a numeric 'y' (got '${l}' for variable '${n}')`,context:{aesthetic:"y",variableName:n,variableType:l},suggestion:"Map the raw values to 'y', or summarised columns under stat 'identity'."})}const a=r?.extent;return{data:ue({data:e,xVariable:o,yVariable:n,groupVariables:(0,s.getGroupVariables)(e,t).filter(l=>l!==o),extent:H(a)?a:b}),mapping:Y}}},ue=({data:e,xVariable:t,yVariable:r,groupVariables:o,extent:n})=>{const a=ce(e,t,r,o),l=e.getVariableNames(),u=new Map(l.map(p=>[p,e.getValues(p)])),c=new Map(l.map(p=>[p,[]])),i={q1:[],median:[],q3:[],lowerWhisker:[],upperWhisker:[],count:[],mean:[],notchLower:[],notchUpper:[],outlier:[]},d=[];for(const p of a){const v=le(p.values,n);if(v===null)continue;for(const h of l)c.get(h)?.push(he(u.get(h)??[],p.indices));i.q1.push(v.q1),i.median.push(v.median),i.q3.push(v.q3),i.lowerWhisker.push(v.lowerWhisker),i.upperWhisker.push(v.upperWhisker),i.count.push(v.count),i.mean.push(v.mean),i.notchLower.push(v.notchLower),i.notchUpper.push(v.notchUpper),i.outlier.push(null);const w={low:v.lowerWhisker,high:v.upperWhisker};p.indices.forEach((h,y)=>{const M=p.values[y];M!==void 0&&(M<w.low||M>w.high)&&d.push({index:h,value:M})})}for(const{index:p,value:v}of d){for(const w of l)c.get(w)?.push(u.get(w)?.[p]??null);i.q1.push(null),i.median.push(null),i.q3.push(null),i.lowerWhisker.push(null),i.upperWhisker.push(null),i.count.push(null),i.mean.push(null),i.notchLower.push(null),i.notchUpper.push(null),i.outlier.push(v)}const m=e.getValueFormat(r),k=Object.fromEntries(l.map(p=>[p,{type:e.getType(p),values:c.get(p)??[],valueFormat:e.getValueFormat(p)}]));for(const[p,v]of Object.entries(i)){const w=x[p];k[w]=p==="count"?{type:"numeric",values:v}:{type:"numeric",values:v,valueFormat:m}}return new s.Dataset(k)},ce=(e,t,r,o)=>{const n=[t,...o].map(u=>e.getValues(u)),a=e.getValues(r,{type:"numeric"}),l=new Map;return a.forEach((u,c)=>{if(u===null||!Number.isFinite(u))return;const i=n.map(m=>V(m[c]??null)).join("\0"),d=l.get(i)??{indices:[],values:[]};d.indices.push(c),d.values.push(u),l.set(i,d)}),[...l.values()]},he=(e,t)=>{const r=e[t[0]??-1]??null,o=V(r);return t.every(n=>V(e[n]??null)===o)?r:null},V=e=>e===null?"\0null":e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`,Q=.6,de=1.5,pe=.3,me=2,C=1.5,ve=6,ge=1.5,fe=7,ke=1.5,ye=["q1","median","q3"],xe={strokeWidth:"pixels"},q={stroke:"color",alpha:"unitInterval",strokeWidth:"pixels",dashArray:"dashArray"},D={fill:"color",fillAlpha:"unitInterval",stroke:"color",alpha:"unitInterval",size:"pixels",strokeWidth:"pixels"},Z=class extends s.Geom{constructor(...e){super(...e),this.type="boxplot",this.defaultParams={extent:b,outliers:!0,notch:!1,showMean:!1,varwidth:!1},this.defaultStat=new ie,this.derivedVariables=Object.values(x),this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value",aes:"lowerWhisker"},{axis:"y",role:"max",valueKind:"value",aes:"upperWhisker"},{axis:"y",role:"scalar",valueKind:"value",aes:"q1"},{axis:"y",role:"scalar",valueKind:"value",aes:"median"},{axis:"y",role:"scalar",valueKind:"value",aes:"q3"},{axis:"y",role:"scalar",valueKind:"value",aes:"outlier"},{axis:"y",role:"scalar",valueKind:"value",aes:"mean"},{axis:"y",role:"scalar",valueKind:"value",aes:"notchLower"},{axis:"y",role:"scalar",valueKind:"value",aes:"notchUpper"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"data",name:"y"},{kind:"data",name:"count"}],this.defaultPosition="dodge",this.supportedPositions=["identity","dodge"],this.supportedCoordTypes=["cartesian","flip"],this.scaleConstraints={discreteMainAxis:!0},this.legend={suppressWhenSingleItem:!0},this.spatialKind="rects",this.highlightStrategy="observation-rerender",this.tooltip=[{key:"Upper whisker",aes:"upperWhisker",optional:!0},{key:"Q3",aes:"q3",optional:!0},{key:"Median",aes:"median",optional:!0},{key:"Q1",aes:"q1",optional:!0},{key:"Lower whisker",aes:"lowerWhisker",optional:!0},{key:"Count",aes:"count",optional:!0},{key:"Mean",aes:"mean",optional:!0},{key:"Outlier",aes:"outlier",optional:!0}],this.styleTarget=(0,s.defineGeomStyleTarget)({observation:{vocabulary:xe,aesthetics:{fill:"color",stroke:"color"},rest:{fill:(0,s.token)("geom"),fillAlpha:pe,stroke:(0,s.token)("geom"),strokeWidth:de}},parts:{median:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,s.token)("geom"),alpha:1,strokeWidth:me,dashArray:[]}},whisker:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,s.token)("geom"),alpha:1,strokeWidth:C,dashArray:[]}},cap:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,s.token)("geom"),alpha:1,strokeWidth:C,dashArray:[]}},outlier:{vocabulary:D,aesthetics:{fill:"color",stroke:"color"},rest:{fill:(0,s.token)("geom"),fillAlpha:0,stroke:(0,s.token)("geom"),alpha:1,size:ve,strokeWidth:ge}},mean:{vocabulary:D,aesthetics:{fill:"color"},rest:{fill:(0,s.token)("geom"),fillAlpha:1,stroke:(0,s.token)("graphBackground"),alpha:1,size:fe,strokeWidth:ke}}}}),this.resolveBandFraction=t=>R(t),this.resolveValueSource=t=>t.median??{variable:x.median},this.validateMapping=({mapping:t,computedVariables:r})=>r.has("y")?[{code:"CONFLICTING_STAT_MAPPING",message:"boxplot geom draws a summary, not a single 'y'; use the 'boxplot' stat or 'identity'"}]:r.has("median")?[...[...z].filter(o=>t[o]!==void 0).map(o=>({code:"CONFLICTING_STAT_MAPPING",message:`boxplot stat computes '${o}' from 'y'; remove its mapping, or set the layer's stat to 'identity'`})),...t.y===void 0?[{code:"MISSING_AESTHETIC",message:"boxplot stat summarises 'y'; map it to the raw values"}]:[]]:ye.filter(o=>t[o]===void 0).map(o=>({code:"MISSING_AESTHETIC",message:`boxplot geom requires '${o}' when its data is already summarised`,context:{aesthetic:o}})),this.resolveAnchorPosition=(t,{coordSystem:r})=>{const o=(0,s.readMainAxis)(r),n=we(t,o);return n===null?null:o==="x"?{x:n.band,y:n.value}:{x:n.value,y:n.band}}}resolveParams(e){const{extent:t,width:r,...o}=super.resolveParams(e);return{...o,extent:this.resolveExtent(t,e.diagnostics),...this.resolveWidth(r,e.diagnostics)}}compile({data:e,mapping:t,params:r}){const o=P(e,t.lowerWhisker),n=P(e,t.upperWhisker);if(o===null||n===null)return{data:e,mapping:{}};const{outliers:a,notch:l,showMean:u,varwidth:c}=r,i=P(e,t.outlier),d=a===!1&&i!==null?Se(e,i):e,m=P(d,t.count),k=R(r)/2;return{data:d.addVariable(x.relativeWidth,"numeric",c===!0&&m!==null?Me(d,m):We(d)).addVariable(s.POSITION_VARIABLES.yMin,"numeric",K(d,o,i)).addVariable(s.POSITION_VARIABLES.yMax,"numeric",K(d,n,i)).addConstantVariable(s.POSITION_VARIABLES.xMin,"numeric",-k).addConstantVariable(s.POSITION_VARIABLES.xMax,"numeric",k),mapping:{...t.y===void 0&&{y:t.median},...u===!0&&t.mean===void 0&&d.hasVariable(x.mean)&&{mean:x.mean},...l===!0&&t.notchLower===void 0&&d.hasVariable(x.notchLower)&&{notchLower:x.notchLower,notchUpper:x.notchUpper}}}}resolveExtent(e,t){return H(e)?e:(t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Boxplot extent must be a non-negative number or 'min-max', got ${String(e)}; falling back to ${b}.`,context:{geom:this.type,param:"extent",expected:"extent >= 0 or 'min-max'",actual:String(e)},suggestion:"Set params.extent to a number of interquartile ranges, or 'min-max'."}),b)}resolveWidth(e,t){if(e===void 0)return{};const r=typeof e=="number"&&Number.isFinite(e)?e:null;if(r!==null&&r>0&&r<=1)return{width:r};const o=r!==null&&r>1?1:void 0;return t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o??Q}.`,context:{geom:this.type,param:"width",expected:"0 < width <= 1",actual:r??String(e)},suggestion:"Set params.width to a fraction of the category band in (0, 1]."}),o!==void 0?{width:o}:{}}},we=(e,t)=>{const r=G(e,t);if(r!==null)return{band:_(r),value:r.median};const o=F(e,t);return o===null?null:{band:o.band,value:o.value}},R=({width:e})=>e??Q,Me=(e,t)=>{const r=e.getValues(t,{type:"numeric"}),o=Math.max(0,...r.map(n=>n??0));return r.map(n=>n===null||o===0?null:Math.sqrt(n/o))},We=e=>Array.from({length:e.size()},()=>null),K=(e,t,r)=>{const o=r===null?[]:e.getValues(r,{type:"numeric"});return e.getValues(t,{type:"numeric"}).map((n,a)=>n??o[a]??null)},Se=(e,t)=>{const r=e.getValues(t,{type:"numeric"});return e.take(r.flatMap((o,n)=>o===null?[n]:[]))},P=(e,t)=>{const r=(0,s.readVariableName)(t);return r!==null&&e.hasVariable(r)?r:null},Ie=5e-4,Oe=.5,Pe=.5,J=(e,t)=>{const r=(e.q1+e.q3)/2,o=Math.max(Math.abs(e.q3-e.q1),Ie)/2,n=g(t,e.start,r-o),a=g(t,e.end,r+o),[l,u]=j(n.x,a.x),[c,i]=j(n.y,a.y);return{x:l,y:c,width:u-l,height:i-c}},ee=(e,t)=>{if(e.notch===null)return null;const{lower:r,upper:o}=e.notch,[n,a]=re(e);return[g(t,e.start,e.q1),g(t,e.start,r),g(t,n,e.median),g(t,e.start,o),g(t,e.start,e.q3),g(t,e.end,e.q3),g(t,e.end,o),g(t,a,e.median),g(t,e.end,r),g(t,e.end,e.q1)]},be=(e,t)=>{const[r,o]=e.notch===null?[e.start,e.end]:re(e);return{from:g(t,r,e.median),to:g(t,o,e.median)}},te=(e,t)=>e.mean===null?null:g(t,_(e),e.mean),re=e=>{const t=(e.end-e.start)*(1-Pe)/2;return[e.start+t,e.end-t]},oe=(e,t)=>{const r=_(e),o=(e.end-e.start)*Oe/2;return[{side:"lower",quartile:e.q1,reach:e.lowerWhisker},{side:"upper",quartile:e.q3,reach:e.upperWhisker}].filter(({quartile:n,reach:a})=>n!==a).map(({side:n,quartile:a,reach:l})=>({side:n,stem:{from:g(t,r,a),to:g(t,r,l)},cap:{from:g(t,r-o,l),to:g(t,r+o,l)}}))},g=(e,t,r)=>{const o=(0,s.composePoint)(e,{main:t,cross:r});return{x:(0,s.toViewBoxX)(o.x),y:(0,s.toViewBoxY)(o.y)}},j=(e,t)=>e<=t?[e,t]:[t,e],O=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),N=(e,t)=>`${e.map((r,o)=>{const{x:n,y:a}=O(r,t);return`${o===0?"M":"L"}${n},${a}`}).join("")}Z`,_e=(e,t)=>N([{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],t),Ee=(e,t)=>{const r=O(e.from,t),o=O(e.to,t);return`M${r.x},${r.y}L${o.x},${o.y}`},Te=({layer:e,coordSystem:t,panelRect:r,styleReaders:o})=>{const n=(0,s.readMainAxis)(t),{boxes:a,outliers:l}=S(e.data,n),u=a.map(h=>{const y=ee(h,n);return y!==null?{kind:"region",pathData:N(y,r)}:{kind:"region",pathData:_e(J(h,n),r)}}),c=o.part("whisker"),i=o.part("cap"),d=a.flatMap(h=>oe(h,n).flatMap(y=>[{segment:y.stem,readers:c},{segment:y.cap,readers:i}].flatMap(({segment:M,readers:E})=>{const I=E?.get("strokeWidth",h.observation)??0;return I>0?[{kind:"stroke",pathData:Ee(M,r),width:I}]:[]}))),m=o.part("outlier"),k=m===void 0?[]:l.map(h=>({center:O(g(n,h.band,h.value),r),size:U(m,h.observation)})),p=o.part("mean"),v=p===void 0?[]:a.flatMap(h=>{const y=te(h,n);return y===null?[]:[{center:O(y,r),size:U(p,h.observation)}]}),w=(0,s.buildDotsEditOutlineShapes)([...k,...v]);return[...d,...u,...w]},U=(e,t)=>(e.get("size",t)??0)+(e.get("strokeWidth",t)??0),A=e=>{const t=(0,s.createStableKeyGenerator)(e.data,e.mapping,e.id),r=(0,s.readVariableName)(e.mapping.outlier),o=n=>`${t(n.observation)}-outlier-${String(r===null?n.value:n.observation[r])}`;return{readBoxKey:t,readOutlierKeys:n=>{const a=new Map;return n.map(l=>{const u=o(l),c=a.get(u)??0;return a.set(u,c+1),c===0?u:`${u}-${c}`})}}},Be=(e,t,r)=>{const o=e.data.getVariableNames(),n=l=>JSON.stringify(o.map(u=>l.observation[u]??null)),a=new Set(r.map(n));return t.filter(l=>a.has(n(l)))},ne=(e,t,r)=>{const o=new Set(t.map(n=>r(n.observation)));return e.filter(n=>o.has(r(n.observation)))},L=({boxes:e,outliers:t,mainAxis:r,panelSize:o,source:n,styleReaders:a,keys:l,hovered:u,shouldAnimateTransitions:c=!1})=>{const i=u===void 0?void 0:"hovered",d=a.part("whisker"),m=a.part("cap"),k=a.part("median"),p=a.part("mean"),v=a.part("outlier"),w=l.readOutlierKeys(t);return(0,f.jsxs)(f.Fragment,{children:[e.flatMap(h=>oe(h,r).flatMap(y=>[{piece:"stem",testId:"boxplot-whisker",readers:d},{piece:"cap",testId:"boxplot-cap",readers:m}].map(({piece:M,testId:E,readers:I})=>I===void 0?null:(0,f.jsx)($,{testId:E,segment:y[M],observation:h.observation,readers:I,state:i,shouldAnimateTransitions:c},`${l.readBoxKey(h.observation)}-${y.side}-${M}`)))),(0,f.jsx)(s.GeomOverpaint,{styleReaders:a,state:i,children:e.map(h=>(0,f.jsx)(qe,{box:h,mainAxis:r,panelSize:o,source:n,styleReaders:a,state:i,shouldAnimateTransitions:c},l.readBoxKey(h.observation)))}),k&&e.map(h=>(0,f.jsx)($,{testId:"boxplot-median",segment:be(h,r),observation:h.observation,readers:k,state:i,shouldAnimateTransitions:c},l.readBoxKey(h.observation))),p&&e.map(h=>{const y=te(h,r);return y===null?null:(0,f.jsx)(X,{testId:"boxplot-mean",centre:y,observation:h.observation,readers:p,state:i,shouldAnimateTransitions:c},l.readBoxKey(h.observation))}),v&&t.map((h,y)=>(0,f.jsx)(X,{testId:"boxplot-outlier",centre:g(r,h.band,h.value),observation:h.observation,readers:v,state:i,shouldAnimateTransitions:c},w[y]))]})},$=({testId:e,segment:t,observation:r,readers:o,state:n,shouldAnimateTransitions:a})=>{const l=o.get("strokeWidth",r,n)??0,u=o.get("stroke",r,n);return(0,f.jsx)(s.GeomLine,{"data-testid":e,x1:(0,s.toPercent)(t.from.x),y1:(0,s.toPercent)(t.from.y),x2:(0,s.toPercent)(t.to.x),y2:(0,s.toPercent)(t.to.y),stroke:u===void 0?void 0:(0,s.toPaintColor)(u),strokeOpacity:o.get("alpha",r,n),strokeWidth:l,strokeDasharray:(0,s.toStrokeDasharray)(o.get("dashArray",r,n),l),shouldAnimateTransitions:a})},qe=({box:e,mainAxis:t,panelSize:r,source:o,styleReaders:n,state:a,shouldAnimateTransitions:l})=>{const u=n.get("fill",e.observation,a),c=n.get("stroke",e.observation,a),i={fill:u===void 0?void 0:(0,s.toPaintColor)(u),opacity:n.get("alpha",e.observation,a),fillOpacity:n.get("fillAlpha",e.observation,a),stroke:c===void 0?void 0:(0,s.toPaintColor)(c),strokeOpacity:n.get("strokeAlpha",e.observation,a),strokeWidth:n.get("strokeWidth",e.observation,a),effects:(0,s.readGeomEffects)(n,e.observation,a),shouldAnimateTransitions:l},d=ee(e,t);if(d!==null)return(0,f.jsx)(s.GeomPath,{"data-testid":"boxplot-box",d:N(d,r),source:o,...i});const m=J(e,t);return(0,f.jsx)(s.GeomRect,{"data-testid":"boxplot-box",x:(0,s.toPercent)(m.x),y:(0,s.toPercent)(m.y),width:(0,s.toPercent)(m.width),height:(0,s.toPercent)(m.height),...i})},X=({testId:e,centre:t,observation:r,readers:o,state:n,shouldAnimateTransitions:a})=>{const l=o.get("fill",r,n),u=o.get("stroke",r,n);return(0,f.jsx)(s.GeomCircle,{"data-testid":e,cx:(0,s.toPercent)(t.x),cy:(0,s.toPercent)(t.y),r:(o.get("size",r,n)??0)/2,fill:l===void 0?void 0:(0,s.toPaintColor)(l),opacity:o.get("alpha",r,n),fillOpacity:o.get("fillAlpha",r,n),stroke:u===void 0?void 0:(0,s.toPaintColor)(u),strokeWidth:o.get("strokeWidth",r,n),shouldAnimateTransitions:a})},Ve=({layer:e,sourceLayer:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,W.useMemo)(()=>A(t),[t]),l=(0,W.useMemo)(()=>S(t.data,r).outliers,[t.data,r]),{boxes:u,outliers:c}=(0,W.useMemo)(()=>{const i=S(e.data,r),d=new Set(Be(t,l,i.outliers)),m=new Set(ne(l,i.boxes,a.readBoxKey)),k=l.filter(p=>m.has(p)||d.has(p));return{boxes:i.boxes,outliers:k}},[e.data,r,t,l,a]);return(0,f.jsx)(L,{boxes:u,outliers:c,mainAxis:r,panelSize:o,source:t,styleReaders:n,keys:a})},Ne=({layer:e,primary:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,W.useMemo)(()=>S(e.data,r).outliers,[e.data,r]),l=(0,W.useMemo)(()=>A(e),[e]),{boxes:u,outliers:c}=S([t.observation],r);return(0,f.jsx)("g",{"data-testid":"hovered-boxes",children:(0,f.jsx)(L,{boxes:u,outliers:u.length>0?ne(a,u,l.readBoxKey):c,mainAxis:r,panelSize:o,source:e,styleReaders:n,keys:l,hovered:t.observation})})},Ae=({layer:e,mainAxis:t,panelSize:r,styleReaders:o,shouldAnimateTransitions:n,intro:a})=>{const{boxes:l,outliers:u}=(0,W.useMemo)(()=>S(e.data,t),[e.data,t]),c=(0,f.jsx)(L,{boxes:l,outliers:u,mainAxis:t,panelSize:r,source:e,styleReaders:o,keys:(0,W.useMemo)(()=>A(e),[e]),shouldAnimateTransitions:n});return a==null?c:(0,f.jsx)(s.IntroFade,{intro:{type:"fade",layerId:a.layerId,durationSeconds:a.durationSeconds},children:c})},Le=(0,s.defineGeomRenderer)(new Z,{coord:"cartesian",swatchShape:"square",overpaintPlacement:"manual",guideMode:"band",render:({layer:e,coordSystem:t,panelRect:r,styleReaders:o,shouldAnimateTransitions:n,intro:a})=>(0,f.jsx)(Ae,{layer:e,mainAxis:(0,s.readMainAxis)(t),panelSize:r,styleReaders:o,shouldAnimateTransitions:n,intro:a}),renderHighlight:({layer:e,sourceLayer:t,coordSystem:r,panelRect:o,styleReaders:n})=>(0,f.jsx)(Ve,{layer:e,sourceLayer:t,mainAxis:(0,s.readMainAxis)(r),panelSize:o,styleReaders:n}),renderHover:({layer:e,primary:t,coordSystem:r,panelRect:o,styleReaders:n})=>(0,f.jsx)(Ne,{layer:e,primary:t,mainAxis:(0,s.readMainAxis)(r),panelSize:o,styleReaders:n}),renderHoverCompanions:()=>null,getEditOutlineShapes:Te});exports.BOXPLOT_VARIABLES=x;exports.BoxplotGeom=Z;exports.boxplot=Le;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let s=require("@graphysdk/react"),W=require("react"),f=require("react/jsx-runtime");var x={q1:"boxplotQ1",median:"boxplotMedian",q3:"boxplotQ3",lowerWhisker:"boxplotLowerWhisker",upperWhisker:"boxplotUpperWhisker",count:"boxplotCount",mean:"boxplotMean",notchLower:"boxplotNotchLower",notchUpper:"boxplotNotchUpper",relativeWidth:"boxplotRelativeWidth",outlier:"boxplotOutlier"},B=e=>(e.start+e.end)/2,G=(e,t)=>{const r=t==="x"?(0,s.getXMin)(e):(0,s.getYMin)(e),o=t==="x"?(0,s.getXMax)(e):(0,s.getYMax)(e),n=t==="x"?(0,s.getYMin)(e):(0,s.getXMin)(e),a=t==="x"?(0,s.getYMax)(e):(0,s.getXMax)(e),l=(0,s.getScaledAesthetic)(e,"q1"),u=(0,s.getScaledAesthetic)(e,"median"),c=(0,s.getScaledAesthetic)(e,"q3");if(r===null||o===null||n===null||a===null||u===null||l===null||c===null)return null;const i=T(e,"notchLower"),h=T(e,"notchUpper"),[m,k]=ne(r,o,e);return{observation:e,start:m,end:k,lowerWhisker:n,q1:l,median:u,q3:c,upperWhisker:a,mean:T(e,"mean"),notch:i===null||h===null?null:{lower:i,upper:h}}},X=(e,t)=>{const r=t==="x"?(0,s.getXMin)(e):(0,s.getYMin)(e),o=t==="x"?(0,s.getXMax)(e):(0,s.getYMax)(e),n=(0,s.getScaledAesthetic)(e,"outlier");return r===null||o===null||n===null?null:{observation:e,band:B({start:r,end:o}),value:n}},S=(e,t)=>{const r=[],o=[];for(const n of e){const a=G(n,t);if(a!==null){r.push(a);continue}const l=X(n,t);l!==null&&o.push(l)}return{boxes:r,outliers:o}},T=(e,t)=>(0,s.getScaledAesthetic)(e,t)??null,ne=(e,t,r)=>{const o=r[x.relativeWidth];if(typeof o!="number")return[e,t];const n=(e+t)/2,a=(t-e)*o/2;return[n-a,n+a]},b=1.5,F=e=>e==="min-max"||typeof e=="number"&&Number.isFinite(e)&&e>=0,ae=1.58,se=(e,t)=>{if(e.length===0)return null;const r=[...e].sort((m,k)=>m-k),o=_(r,.25),n=_(r,.5),a=_(r,.75),l=t==="min-max"?1/0:t*(a-o),u=o-l,c=a+l,i=r.filter(m=>m>=u&&m<=c),h=ae*(a-o)/Math.sqrt(e.length);return{lowerWhisker:Math.min(i[0]??o,o),q1:o,median:n,q3:a,upperWhisker:Math.max(i[i.length-1]??a,a),count:e.length,mean:r.reduce((m,k)=>m+k,0)/r.length,notchLower:n-h,notchUpper:n+h}},_=(e,t)=>{const r=(e.length-1)*t,o=Math.floor(r),n=e[o]??0;return n+((e[o+1]??n)-n)*(r-o)},H={q1:x.q1,median:x.median,q3:x.q3,lowerWhisker:x.lowerWhisker,upperWhisker:x.upperWhisker,count:x.count,outlier:x.outlier},Y=new Set([...Object.keys(H),"mean","notchLower","notchUpper"]),le=class extends s.Stat{constructor(...e){super(...e),this.type="boxplot",this.computedVariables=Y}computeStat({data:e,mapping:t,params:r}){const o=(0,s.readVariableName)(t.x),n=(0,s.readVariableName)(t.y);if(o===null||n===null||!e.hasVariable(o)||!e.hasVariable(n))return{data:e,mapping:{}};if(e.size()>0&&e.getType(n)!=="numeric"){const l=e.getType(n);throw new s.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'boxplot' stat requires a numeric 'y' (got '${l}' for variable '${n}')`,context:{aesthetic:"y",variableName:n,variableType:l},suggestion:"Map the raw values to 'y', or summarised columns under stat 'identity'."})}const a=r?.extent;return{data:ie({data:e,xVariable:o,yVariable:n,groupVariables:(0,s.getGroupVariables)(e,t).filter(l=>l!==o),extent:F(a)?a:b}),mapping:H}}},ie=({data:e,xVariable:t,yVariable:r,groupVariables:o,extent:n})=>{const a=ue(e,t,r,o),l=e.getVariableNames(),u=new Map(l.map(p=>[p,e.getValues(p)])),c=new Map(l.map(p=>[p,[]])),i={q1:[],median:[],q3:[],lowerWhisker:[],upperWhisker:[],count:[],mean:[],notchLower:[],notchUpper:[],outlier:[]},h=[];for(const p of a){const v=se(p.values,n);if(v===null)continue;for(const d of l)c.get(d)?.push(ce(u.get(d)??[],p.indices));i.q1.push(v.q1),i.median.push(v.median),i.q3.push(v.q3),i.lowerWhisker.push(v.lowerWhisker),i.upperWhisker.push(v.upperWhisker),i.count.push(v.count),i.mean.push(v.mean),i.notchLower.push(v.notchLower),i.notchUpper.push(v.notchUpper),i.outlier.push(null);const w={low:v.lowerWhisker,high:v.upperWhisker};p.indices.forEach((d,y)=>{const M=p.values[y];M!==void 0&&(M<w.low||M>w.high)&&h.push({index:d,value:M})})}for(const{index:p,value:v}of h){for(const w of l)c.get(w)?.push(u.get(w)?.[p]??null);i.q1.push(null),i.median.push(null),i.q3.push(null),i.lowerWhisker.push(null),i.upperWhisker.push(null),i.count.push(null),i.mean.push(null),i.notchLower.push(null),i.notchUpper.push(null),i.outlier.push(v)}const m=e.getValueFormat(r),k=Object.fromEntries(l.map(p=>[p,{type:e.getType(p),values:c.get(p)??[],valueFormat:e.getValueFormat(p)}]));for(const[p,v]of Object.entries(i)){const w=x[p];k[w]=p==="count"?{type:"numeric",values:v}:{type:"numeric",values:v,valueFormat:m}}return new s.Dataset(k)},ue=(e,t,r,o)=>{const n=[t,...o].map(u=>e.getValues(u)),a=e.getValues(r,{type:"numeric"}),l=new Map;return a.forEach((u,c)=>{if(u===null||!Number.isFinite(u))return;const i=n.map(m=>V(m[c]??null)).join("\0"),h=l.get(i)??{indices:[],values:[]};h.indices.push(c),h.values.push(u),l.set(i,h)}),[...l.values()]},ce=(e,t)=>{const r=e[t[0]??-1]??null,o=V(r);return t.every(n=>V(e[n]??null)===o)?r:null},V=e=>e===null?"\0null":e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`,z=.6,de=1,he=2,pe=1.5,me=7,ve=1,ge=7,fe=1.5,ke=["q1","median","q3"],ye={strokeWidth:"pixels"},q={stroke:"color",alpha:"unitInterval",strokeWidth:"pixels",dashArray:"dashArray"},C={fill:"color",fillAlpha:"unitInterval",stroke:"color",alpha:"unitInterval",size:"pixels",strokeWidth:"pixels"},Q=class extends s.Geom{constructor(...e){super(...e),this.type="boxplot",this.defaultParams={extent:b,outliers:!0,notch:!1,showMean:!1,varwidth:!1},this.defaultStat=new le,this.derivedVariables=Object.values(x),this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value",aes:"lowerWhisker"},{axis:"y",role:"max",valueKind:"value",aes:"upperWhisker"},{axis:"y",role:"scalar",valueKind:"value",aes:"q1"},{axis:"y",role:"scalar",valueKind:"value",aes:"median"},{axis:"y",role:"scalar",valueKind:"value",aes:"q3"},{axis:"y",role:"scalar",valueKind:"value",aes:"outlier"},{axis:"y",role:"scalar",valueKind:"value",aes:"mean"},{axis:"y",role:"scalar",valueKind:"value",aes:"notchLower"},{axis:"y",role:"scalar",valueKind:"value",aes:"notchUpper"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"data",name:"y"},{kind:"data",name:"count"}],this.defaultPosition="dodge",this.supportedPositions=["identity","dodge"],this.supportedCoordTypes=["cartesian","flip"],this.scaleConstraints={discreteMainAxis:!0},this.legend={suppressWhenSingleItem:!0},this.spatialKind="rects",this.highlightStrategy="observation-rerender",this.tooltip=[{key:"Upper whisker",aes:"upperWhisker",optional:!0},{key:"Q3",aes:"q3",optional:!0},{key:"Median",aes:"median",optional:!0},{key:"Q1",aes:"q1",optional:!0},{key:"Lower whisker",aes:"lowerWhisker",optional:!0},{key:"Count",aes:"count",optional:!0},{key:"Mean",aes:"mean",optional:!0},{key:"Outlier",aes:"outlier",optional:!0}],this.styleTarget=(0,s.defineGeomStyleTarget)({observation:{vocabulary:ye,aesthetics:{fill:"color"},rest:{fill:(0,s.token)("geom"),fillAlpha:1,stroke:(0,s.token)("geomBorder"),strokeWidth:de}},parts:{median:{vocabulary:q,rest:{stroke:(0,s.token)("graphBackground"),alpha:1,strokeWidth:he,dashArray:[]}},whisker:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,s.token)("geom"),alpha:1,strokeWidth:pe,dashArray:[]}},cap:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,s.token)("geom"),alpha:1,strokeWidth:0,dashArray:[]}},outlier:{vocabulary:C,aesthetics:{fill:"color"},rest:{fill:(0,s.token)("geom"),fillAlpha:1,stroke:(0,s.token)("graphBackground"),alpha:1,size:me,strokeWidth:ve}},mean:{vocabulary:C,aesthetics:{stroke:"color"},rest:{fill:(0,s.token)("graphBackground"),fillAlpha:1,stroke:(0,s.token)("geom"),alpha:1,size:ge,strokeWidth:fe}}}}),this.resolveBandFraction=t=>D(t),this.resolveValueSource=t=>t.median??{variable:x.median},this.validateMapping=({mapping:t,computedVariables:r})=>r.has("y")?[{code:"CONFLICTING_STAT_MAPPING",message:"boxplot geom draws a summary, not a single 'y'; use the 'boxplot' stat or 'identity'"}]:r.has("median")?[...[...Y].filter(o=>t[o]!==void 0).map(o=>({code:"CONFLICTING_STAT_MAPPING",message:`boxplot stat computes '${o}' from 'y'; remove its mapping, or set the layer's stat to 'identity'`})),...t.y===void 0?[{code:"MISSING_AESTHETIC",message:"boxplot stat summarises 'y'; map it to the raw values"}]:[]]:ke.filter(o=>t[o]===void 0).map(o=>({code:"MISSING_AESTHETIC",message:`boxplot geom requires '${o}' when its data is already summarised`,context:{aesthetic:o}})),this.resolveAnchorPosition=(t,{coordSystem:r})=>{const o=(0,s.readMainAxis)(r),n=xe(t,o);return n===null?null:o==="x"?{x:n.band,y:n.value}:{x:n.value,y:n.band}}}resolveParams(e){const{extent:t,width:r,...o}=super.resolveParams(e);return{...o,extent:this.resolveExtent(t,e.diagnostics),...this.resolveWidth(r,e.diagnostics)}}compile({data:e,mapping:t,params:r}){const o=P(e,t.lowerWhisker),n=P(e,t.upperWhisker);if(o===null||n===null)return{data:e,mapping:{}};const{outliers:a,notch:l,showMean:u,varwidth:c}=r,i=P(e,t.outlier),h=a===!1&&i!==null?We(e,i):e,m=P(h,t.count),k=D(r)/2;return{data:h.addVariable(x.relativeWidth,"numeric",c===!0&&m!==null?we(h,m):Me(h)).addVariable(s.POSITION_VARIABLES.yMin,"numeric",R(h,o,i)).addVariable(s.POSITION_VARIABLES.yMax,"numeric",R(h,n,i)).addConstantVariable(s.POSITION_VARIABLES.xMin,"numeric",-k).addConstantVariable(s.POSITION_VARIABLES.xMax,"numeric",k),mapping:{...t.y===void 0&&{y:t.median},...u===!0&&t.mean===void 0&&h.hasVariable(x.mean)&&{mean:x.mean},...l===!0&&t.notchLower===void 0&&h.hasVariable(x.notchLower)&&{notchLower:x.notchLower,notchUpper:x.notchUpper}}}}resolveExtent(e,t){return F(e)?e:(t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Boxplot extent must be a non-negative number or 'min-max', got ${String(e)}; falling back to ${b}.`,context:{geom:this.type,param:"extent",expected:"extent >= 0 or 'min-max'",actual:String(e)},suggestion:"Set params.extent to a number of interquartile ranges, or 'min-max'."}),b)}resolveWidth(e,t){if(e===void 0)return{};const r=typeof e=="number"&&Number.isFinite(e)?e:null;if(r!==null&&r>0&&r<=1)return{width:r};const o=r!==null&&r>1?1:void 0;return t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o??z}.`,context:{geom:this.type,param:"width",expected:"0 < width <= 1",actual:r??String(e)},suggestion:"Set params.width to a fraction of the category band in (0, 1]."}),o!==void 0?{width:o}:{}}},xe=(e,t)=>{const r=G(e,t);if(r!==null)return{band:B(r),value:r.median};const o=X(e,t);return o===null?null:{band:o.band,value:o.value}},D=({width:e})=>e??z,we=(e,t)=>{const r=e.getValues(t,{type:"numeric"}),o=Math.max(0,...r.map(n=>n??0));return r.map(n=>n===null||o===0?null:Math.sqrt(n/o))},Me=e=>Array.from({length:e.size()},()=>null),R=(e,t,r)=>{const o=r===null?[]:e.getValues(r,{type:"numeric"});return e.getValues(t,{type:"numeric"}).map((n,a)=>n??o[a]??null)},We=(e,t)=>{const r=e.getValues(t,{type:"numeric"});return e.take(r.flatMap((o,n)=>o===null?[n]:[]))},P=(e,t)=>{const r=(0,s.readVariableName)(t);return r!==null&&e.hasVariable(r)?r:null},Se=5e-4,Ie=.5,Oe=.5,Z=(e,t)=>{const r=(e.q1+e.q3)/2,o=Math.max(Math.abs(e.q3-e.q1),Se)/2,n=g(t,e.start,r-o),a=g(t,e.end,r+o),[l,u]=K(n.x,a.x),[c,i]=K(n.y,a.y);return{x:l,y:c,width:u-l,height:i-c}},J=(e,t)=>{if(e.notch===null)return null;const{lower:r,upper:o}=e.notch,[n,a]=te(e);return[g(t,e.start,e.q1),g(t,e.start,r),g(t,n,e.median),g(t,e.start,o),g(t,e.start,e.q3),g(t,e.end,e.q3),g(t,e.end,o),g(t,a,e.median),g(t,e.end,r),g(t,e.end,e.q1)]},Pe=(e,t)=>{const[r,o]=e.notch===null?[e.start,e.end]:te(e);return{from:g(t,r,e.median),to:g(t,o,e.median)}},ee=(e,t)=>e.mean===null?null:g(t,B(e),e.mean),te=e=>{const t=(e.end-e.start)*(1-Oe)/2;return[e.start+t,e.end-t]},re=(e,t)=>{const r=B(e),o=(e.end-e.start)*Ie/2;return[{side:"lower",quartile:e.q1,reach:e.lowerWhisker},{side:"upper",quartile:e.q3,reach:e.upperWhisker}].filter(({quartile:n,reach:a})=>n!==a).map(({side:n,quartile:a,reach:l})=>({side:n,stem:{from:g(t,r,a),to:g(t,r,l)},cap:{from:g(t,r-o,l),to:g(t,r+o,l)}}))},g=(e,t,r)=>{const o=(0,s.composePoint)(e,{main:t,cross:r});return{x:(0,s.toViewBoxX)(o.x),y:(0,s.toViewBoxY)(o.y)}},K=(e,t)=>e<=t?[e,t]:[t,e],O=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),N=(e,t)=>`${e.map((r,o)=>{const{x:n,y:a}=O(r,t);return`${o===0?"M":"L"}${n},${a}`}).join("")}Z`,be=(e,t)=>N([{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],t),Be=(e,t)=>{const r=O(e.from,t),o=O(e.to,t);return`M${r.x},${r.y}L${o.x},${o.y}`},Ee=({layer:e,coordSystem:t,panelRect:r,styleReaders:o})=>{const n=(0,s.readMainAxis)(t),{boxes:a,outliers:l}=S(e.data,n),u=a.map(d=>{const y=J(d,n);return y!==null?{kind:"region",pathData:N(y,r)}:{kind:"region",pathData:be(Z(d,n),r)}}),c=o.part("whisker"),i=o.part("cap"),h=a.flatMap(d=>re(d,n).flatMap(y=>[{segment:y.stem,readers:c},{segment:y.cap,readers:i}].flatMap(({segment:M,readers:E})=>{const I=E?.get("strokeWidth",d.observation)??0;return I>0?[{kind:"stroke",pathData:Be(M,r),width:I}]:[]}))),m=o.part("outlier"),k=m===void 0?[]:l.map(d=>({center:O(g(n,d.band,d.value),r),size:j(m,d.observation)})),p=o.part("mean"),v=p===void 0?[]:a.flatMap(d=>{const y=ee(d,n);return y===null?[]:[{center:O(y,r),size:j(p,d.observation)}]}),w=(0,s.buildDotsEditOutlineShapes)([...k,...v]);return[...h,...u,...w]},j=(e,t)=>(e.get("size",t)??0)+(e.get("strokeWidth",t)??0),A=e=>{const t=(0,s.createStableKeyGenerator)(e.data,e.mapping,e.id),r=(0,s.readVariableName)(e.mapping.outlier),o=n=>`${t(n.observation)}-outlier-${String(r===null?n.value:n.observation[r])}`;return{readBoxKey:t,readOutlierKeys:n=>{const a=new Map;return n.map(l=>{const u=o(l),c=a.get(u)??0;return a.set(u,c+1),c===0?u:`${u}-${c}`})}}},Te=(e,t,r)=>{const o=e.data.getVariableNames(),n=l=>JSON.stringify(o.map(u=>l.observation[u]??null)),a=new Set(r.map(n));return t.filter(l=>a.has(n(l)))},oe=(e,t,r)=>{const o=new Set(t.map(n=>r(n.observation)));return e.filter(n=>o.has(r(n.observation)))},L=({boxes:e,outliers:t,mainAxis:r,panelSize:o,source:n,styleReaders:a,keys:l,hovered:u,shouldAnimateTransitions:c=!1})=>{const i=u===void 0?void 0:"hovered",h=a.part("whisker"),m=a.part("cap"),k=a.part("median"),p=a.part("mean"),v=a.part("outlier"),w=l.readOutlierKeys(t);return(0,f.jsxs)(f.Fragment,{children:[e.flatMap(d=>re(d,r).flatMap(y=>[{piece:"stem",testId:"boxplot-whisker",readers:h},{piece:"cap",testId:"boxplot-cap",readers:m}].map(({piece:M,testId:E,readers:I})=>I===void 0?null:(0,f.jsx)(U,{testId:E,segment:y[M],observation:d.observation,readers:I,state:i,shouldAnimateTransitions:c},`${l.readBoxKey(d.observation)}-${y.side}-${M}`)))),(0,f.jsx)(s.GeomOverpaint,{styleReaders:a,state:i,children:e.map(d=>(0,f.jsx)(_e,{box:d,mainAxis:r,panelSize:o,source:n,styleReaders:a,state:i,shouldAnimateTransitions:c},l.readBoxKey(d.observation)))}),k&&e.map(d=>(0,f.jsx)(U,{testId:"boxplot-median",segment:Pe(d,r),observation:d.observation,readers:k,state:i,shouldAnimateTransitions:c},l.readBoxKey(d.observation))),p&&e.map(d=>{const y=ee(d,r);return y===null?null:(0,f.jsx)($,{testId:"boxplot-mean",centre:y,observation:d.observation,readers:p,state:i,shouldAnimateTransitions:c},l.readBoxKey(d.observation))}),v&&t.map((d,y)=>(0,f.jsx)($,{testId:"boxplot-outlier",centre:g(r,d.band,d.value),observation:d.observation,readers:v,state:i,shouldAnimateTransitions:c},w[y]))]})},U=({testId:e,segment:t,observation:r,readers:o,state:n,shouldAnimateTransitions:a})=>{const l=o.get("strokeWidth",r,n)??0,u=o.get("stroke",r,n);return(0,f.jsx)(s.GeomLine,{"data-testid":e,x1:(0,s.toPercent)(t.from.x),y1:(0,s.toPercent)(t.from.y),x2:(0,s.toPercent)(t.to.x),y2:(0,s.toPercent)(t.to.y),stroke:u===void 0?void 0:(0,s.toPaintColor)(u),strokeOpacity:o.get("alpha",r,n),strokeWidth:l,strokeDasharray:(0,s.toStrokeDasharray)(o.get("dashArray",r,n),l),shouldAnimateTransitions:a})},_e=({box:e,mainAxis:t,panelSize:r,source:o,styleReaders:n,state:a,shouldAnimateTransitions:l})=>{const u=n.get("fill",e.observation,a),c=n.get("stroke",e.observation,a),i={fill:u===void 0?void 0:(0,s.toPaintColor)(u),opacity:n.get("alpha",e.observation,a),fillOpacity:n.get("fillAlpha",e.observation,a),stroke:c===void 0?void 0:(0,s.toPaintColor)(c),strokeOpacity:n.get("strokeAlpha",e.observation,a),strokeWidth:n.get("strokeWidth",e.observation,a),effects:(0,s.readGeomEffects)(n,e.observation,a),shouldAnimateTransitions:l},h=J(e,t);if(h!==null)return(0,f.jsx)(s.GeomPath,{"data-testid":"boxplot-box",d:N(h,r),source:o,...i});const m=Z(e,t);return(0,f.jsx)(s.GeomRect,{"data-testid":"boxplot-box",x:(0,s.toPercent)(m.x),y:(0,s.toPercent)(m.y),width:(0,s.toPercent)(m.width),height:(0,s.toPercent)(m.height),cornerRadius:n.get("cornerRadius",e.observation,a),...i})},$=({testId:e,centre:t,observation:r,readers:o,state:n,shouldAnimateTransitions:a})=>{const l=o.get("fill",r,n),u=o.get("stroke",r,n);return(0,f.jsx)(s.GeomCircle,{"data-testid":e,cx:(0,s.toPercent)(t.x),cy:(0,s.toPercent)(t.y),r:(o.get("size",r,n)??0)/2,fill:l===void 0?void 0:(0,s.toPaintColor)(l),opacity:o.get("alpha",r,n),fillOpacity:o.get("fillAlpha",r,n),stroke:u===void 0?void 0:(0,s.toPaintColor)(u),strokeWidth:o.get("strokeWidth",r,n),shouldAnimateTransitions:a})},qe=({layer:e,sourceLayer:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,W.useMemo)(()=>A(t),[t]),l=(0,W.useMemo)(()=>S(t.data,r).outliers,[t.data,r]),{boxes:u,outliers:c}=(0,W.useMemo)(()=>{const i=S(e.data,r),h=new Set(Te(t,l,i.outliers)),m=new Set(oe(l,i.boxes,a.readBoxKey)),k=l.filter(p=>m.has(p)||h.has(p));return{boxes:i.boxes,outliers:k}},[e.data,r,t,l,a]);return(0,f.jsx)(L,{boxes:u,outliers:c,mainAxis:r,panelSize:o,source:t,styleReaders:n,keys:a})},Ve=({layer:e,primary:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,W.useMemo)(()=>S(e.data,r).outliers,[e.data,r]),l=(0,W.useMemo)(()=>A(e),[e]),{boxes:u,outliers:c}=S([t.observation],r);return(0,f.jsx)("g",{"data-testid":"hovered-boxes",children:(0,f.jsx)(L,{boxes:u,outliers:u.length>0?oe(a,u,l.readBoxKey):c,mainAxis:r,panelSize:o,source:e,styleReaders:n,keys:l,hovered:t.observation})})},Ne=({layer:e,mainAxis:t,panelSize:r,styleReaders:o,shouldAnimateTransitions:n,intro:a})=>{const{boxes:l,outliers:u}=(0,W.useMemo)(()=>S(e.data,t),[e.data,t]),c=(0,f.jsx)(L,{boxes:l,outliers:u,mainAxis:t,panelSize:r,source:e,styleReaders:o,keys:(0,W.useMemo)(()=>A(e),[e]),shouldAnimateTransitions:n});return a==null?c:(0,f.jsx)(s.IntroFade,{intro:{type:"fade",layerId:a.layerId,durationSeconds:a.durationSeconds},children:c})},Ae=(0,s.defineGeomRenderer)(new Q,{coord:"cartesian",swatchShape:"square",overpaintPlacement:"manual",guideMode:"band",render:({layer:e,coordSystem:t,panelRect:r,styleReaders:o,shouldAnimateTransitions:n,intro:a})=>(0,f.jsx)(Ne,{layer:e,mainAxis:(0,s.readMainAxis)(t),panelSize:r,styleReaders:o,shouldAnimateTransitions:n,intro:a}),renderHighlight:({layer:e,sourceLayer:t,coordSystem:r,panelRect:o,styleReaders:n})=>(0,f.jsx)(qe,{layer:e,sourceLayer:t,mainAxis:(0,s.readMainAxis)(r),panelSize:o,styleReaders:n}),renderHover:({layer:e,primary:t,coordSystem:r,panelRect:o,styleReaders:n})=>(0,f.jsx)(Ve,{layer:e,primary:t,mainAxis:(0,s.readMainAxis)(r),panelSize:o,styleReaders:n}),renderHoverCompanions:()=>null,getEditOutlineShapes:Ee});exports.BOXPLOT_VARIABLES=x;exports.BoxplotGeom=Q;exports.boxplot=Ae;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Dataset as
|
|
1
|
+
import { Dataset as pe, Geom as me, GeomCircle as ve, GeomLine as ge, GeomOverpaint as fe, GeomPath as ke, GeomRect as ye, IntroFade as we, POSITION_VARIABLES as _, Stat as xe, UserInputError as We, buildDotsEditOutlineShapes as Me, composePoint as Se, createStableKeyGenerator as Ie, defineGeomRenderer as Oe, defineGeomStyleTarget as be, getGroupVariables as Ee, getScaledAesthetic as b, getXMax as R, getXMin as U, getYMax as $, getYMin as A, readGeomEffects as Be, readMainAxis as E, readVariableName as V, toPaintColor as B, toPercent as x, toStrokeDasharray as Te, toViewBoxX as _e, toViewBoxY as qe, token as M } from "@graphysdk/react";
|
|
2
2
|
import { useMemo as S } from "react";
|
|
3
|
-
import { Fragment as
|
|
4
|
-
var
|
|
3
|
+
import { Fragment as Pe, jsx as k, jsxs as Ve } from "react/jsx-runtime";
|
|
4
|
+
var y = {
|
|
5
5
|
q1: "boxplotQ1",
|
|
6
6
|
median: "boxplotMedian",
|
|
7
7
|
q3: "boxplotQ3",
|
|
@@ -13,10 +13,10 @@ var k = {
|
|
|
13
13
|
notchUpper: "boxplotNotchUpper",
|
|
14
14
|
relativeWidth: "boxplotRelativeWidth",
|
|
15
15
|
outlier: "boxplotOutlier"
|
|
16
|
-
}, N = (e) => (e.start + e.end) / 2,
|
|
17
|
-
const r = t === "x" ?
|
|
16
|
+
}, N = (e) => (e.start + e.end) / 2, te = (e, t) => {
|
|
17
|
+
const r = t === "x" ? U(e) : A(e), o = t === "x" ? R(e) : $(e), n = t === "x" ? A(e) : U(e), a = t === "x" ? $(e) : R(e), s = b(e, "q1"), i = b(e, "median"), u = b(e, "q3");
|
|
18
18
|
if (r === null || o === null || n === null || a === null || i === null || s === null || u === null) return null;
|
|
19
|
-
const l =
|
|
19
|
+
const l = L(e, "notchLower"), h = L(e, "notchUpper"), [p, g] = Ne(r, o, e);
|
|
20
20
|
return {
|
|
21
21
|
observation: e,
|
|
22
22
|
start: p,
|
|
@@ -26,14 +26,14 @@ var k = {
|
|
|
26
26
|
median: i,
|
|
27
27
|
q3: u,
|
|
28
28
|
upperWhisker: a,
|
|
29
|
-
mean:
|
|
29
|
+
mean: L(e, "mean"),
|
|
30
30
|
notch: l === null || h === null ? null : {
|
|
31
31
|
lower: l,
|
|
32
32
|
upper: h
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
},
|
|
36
|
-
const r = t === "x" ?
|
|
35
|
+
}, re = (e, t) => {
|
|
36
|
+
const r = t === "x" ? U(e) : A(e), o = t === "x" ? R(e) : $(e), n = b(e, "outlier");
|
|
37
37
|
return r === null || o === null || n === null ? null : {
|
|
38
38
|
observation: e,
|
|
39
39
|
band: N({
|
|
@@ -45,24 +45,24 @@ var k = {
|
|
|
45
45
|
}, I = (e, t) => {
|
|
46
46
|
const r = [], o = [];
|
|
47
47
|
for (const n of e) {
|
|
48
|
-
const a =
|
|
48
|
+
const a = te(n, t);
|
|
49
49
|
if (a !== null) {
|
|
50
50
|
r.push(a);
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
const s =
|
|
53
|
+
const s = re(n, t);
|
|
54
54
|
s !== null && o.push(s);
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
boxes: r,
|
|
58
58
|
outliers: o
|
|
59
59
|
};
|
|
60
|
-
},
|
|
61
|
-
const o = r[
|
|
60
|
+
}, L = (e, t) => b(e, t) ?? null, Ne = (e, t, r) => {
|
|
61
|
+
const o = r[y.relativeWidth];
|
|
62
62
|
if (typeof o != "number") return [e, t];
|
|
63
63
|
const n = (e + t) / 2, a = (t - e) * o / 2;
|
|
64
64
|
return [n - a, n + a];
|
|
65
|
-
}, P = 1.5,
|
|
65
|
+
}, P = 1.5, oe = (e) => e === "min-max" || typeof e == "number" && Number.isFinite(e) && e >= 0, Ce = 1.58, Le = (e, t) => {
|
|
66
66
|
if (e.length === 0) return null;
|
|
67
67
|
const r = [...e].sort((p, g) => p - g), o = D(r, 0.25), n = D(r, 0.5), a = D(r, 0.75), s = t === "min-max" ? 1 / 0 : t * (a - o), i = o - s, u = a + s, l = r.filter((p) => p >= i && p <= u), h = Ce * (a - o) / Math.sqrt(e.length);
|
|
68
68
|
return {
|
|
@@ -79,22 +79,22 @@ var k = {
|
|
|
79
79
|
}, D = (e, t) => {
|
|
80
80
|
const r = (e.length - 1) * t, o = Math.floor(r), n = e[o] ?? 0;
|
|
81
81
|
return n + ((e[o + 1] ?? n) - n) * (r - o);
|
|
82
|
-
},
|
|
83
|
-
q1:
|
|
84
|
-
median:
|
|
85
|
-
q3:
|
|
86
|
-
lowerWhisker:
|
|
87
|
-
upperWhisker:
|
|
88
|
-
count:
|
|
89
|
-
outlier:
|
|
90
|
-
},
|
|
91
|
-
...Object.keys(
|
|
82
|
+
}, ne = {
|
|
83
|
+
q1: y.q1,
|
|
84
|
+
median: y.median,
|
|
85
|
+
q3: y.q3,
|
|
86
|
+
lowerWhisker: y.lowerWhisker,
|
|
87
|
+
upperWhisker: y.upperWhisker,
|
|
88
|
+
count: y.count,
|
|
89
|
+
outlier: y.outlier
|
|
90
|
+
}, ae = /* @__PURE__ */ new Set([
|
|
91
|
+
...Object.keys(ne),
|
|
92
92
|
"mean",
|
|
93
93
|
"notchLower",
|
|
94
94
|
"notchUpper"
|
|
95
|
-
]),
|
|
95
|
+
]), De = class extends xe {
|
|
96
96
|
constructor(...e) {
|
|
97
|
-
super(...e), this.type = "boxplot", this.computedVariables =
|
|
97
|
+
super(...e), this.type = "boxplot", this.computedVariables = ae;
|
|
98
98
|
}
|
|
99
99
|
computeStat({ data: e, mapping: t, params: r }) {
|
|
100
100
|
const o = V(t.x), n = V(t.y);
|
|
@@ -104,7 +104,7 @@ var k = {
|
|
|
104
104
|
};
|
|
105
105
|
if (e.size() > 0 && e.getType(n) !== "numeric") {
|
|
106
106
|
const s = e.getType(n);
|
|
107
|
-
throw new
|
|
107
|
+
throw new We({
|
|
108
108
|
code: "INCOMPATIBLE_TYPE",
|
|
109
109
|
message: `'boxplot' stat requires a numeric 'y' (got '${s}' for variable '${n}')`,
|
|
110
110
|
context: {
|
|
@@ -117,18 +117,18 @@ var k = {
|
|
|
117
117
|
}
|
|
118
118
|
const a = r?.extent;
|
|
119
119
|
return {
|
|
120
|
-
data:
|
|
120
|
+
data: Ke({
|
|
121
121
|
data: e,
|
|
122
122
|
xVariable: o,
|
|
123
123
|
yVariable: n,
|
|
124
|
-
groupVariables:
|
|
125
|
-
extent:
|
|
124
|
+
groupVariables: Ee(e, t).filter((s) => s !== o),
|
|
125
|
+
extent: oe(a) ? a : P
|
|
126
126
|
}),
|
|
127
|
-
mapping:
|
|
127
|
+
mapping: ne
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
},
|
|
131
|
-
const a =
|
|
130
|
+
}, Ke = ({ data: e, xVariable: t, yVariable: r, groupVariables: o, extent: n }) => {
|
|
131
|
+
const a = Re(e, t, r, o), s = e.getVariableNames(), i = new Map(s.map((d) => [d, e.getValues(d)])), u = new Map(s.map((d) => [d, []])), l = {
|
|
132
132
|
q1: [],
|
|
133
133
|
median: [],
|
|
134
134
|
q3: [],
|
|
@@ -141,7 +141,7 @@ var k = {
|
|
|
141
141
|
outlier: []
|
|
142
142
|
}, h = [];
|
|
143
143
|
for (const d of a) {
|
|
144
|
-
const m =
|
|
144
|
+
const m = Le(d.values, n);
|
|
145
145
|
if (m === null) continue;
|
|
146
146
|
for (const c of s) u.get(c)?.push(Ue(i.get(c) ?? [], d.indices));
|
|
147
147
|
l.q1.push(m.q1), l.median.push(m.median), l.q3.push(m.q3), l.lowerWhisker.push(m.lowerWhisker), l.upperWhisker.push(m.upperWhisker), l.count.push(m.count), l.mean.push(m.mean), l.notchLower.push(m.notchLower), l.notchUpper.push(m.notchUpper), l.outlier.push(null);
|
|
@@ -167,7 +167,7 @@ var k = {
|
|
|
167
167
|
valueFormat: e.getValueFormat(d)
|
|
168
168
|
}]));
|
|
169
169
|
for (const [d, m] of Object.entries(l)) {
|
|
170
|
-
const w =
|
|
170
|
+
const w = y[d];
|
|
171
171
|
g[w] = d === "count" ? {
|
|
172
172
|
type: "numeric",
|
|
173
173
|
values: m
|
|
@@ -177,8 +177,8 @@ var k = {
|
|
|
177
177
|
valueFormat: p
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
return new
|
|
181
|
-
},
|
|
180
|
+
return new pe(g);
|
|
181
|
+
}, Re = (e, t, r, o) => {
|
|
182
182
|
const n = [t, ...o].map((i) => e.getValues(i)), a = e.getValues(r, { type: "numeric" }), s = /* @__PURE__ */ new Map();
|
|
183
183
|
return a.forEach((i, u) => {
|
|
184
184
|
if (i === null || !Number.isFinite(i)) return;
|
|
@@ -191,23 +191,23 @@ var k = {
|
|
|
191
191
|
}, Ue = (e, t) => {
|
|
192
192
|
const r = e[t[0] ?? -1] ?? null, o = G(r);
|
|
193
193
|
return t.every((n) => G(e[n] ?? null) === o) ? r : null;
|
|
194
|
-
}, G = (e) => e === null ? "\0null" : e instanceof Date ? `date:${e.getTime()}` : `${typeof e}:${String(e)}`,
|
|
194
|
+
}, G = (e) => e === null ? "\0null" : e instanceof Date ? `date:${e.getTime()}` : `${typeof e}:${String(e)}`, se = 0.6, $e = 1, Ae = 2, Ge = 1.5, Fe = 7, He = 1, Xe = 7, ze = 1.5, Ye = [
|
|
195
195
|
"q1",
|
|
196
196
|
"median",
|
|
197
197
|
"q3"
|
|
198
|
-
],
|
|
198
|
+
], je = { strokeWidth: "pixels" }, K = {
|
|
199
199
|
stroke: "color",
|
|
200
200
|
alpha: "unitInterval",
|
|
201
201
|
strokeWidth: "pixels",
|
|
202
202
|
dashArray: "dashArray"
|
|
203
|
-
},
|
|
203
|
+
}, z = {
|
|
204
204
|
fill: "color",
|
|
205
205
|
fillAlpha: "unitInterval",
|
|
206
206
|
stroke: "color",
|
|
207
207
|
alpha: "unitInterval",
|
|
208
208
|
size: "pixels",
|
|
209
209
|
strokeWidth: "pixels"
|
|
210
|
-
},
|
|
210
|
+
}, Qe = class extends me {
|
|
211
211
|
constructor(...e) {
|
|
212
212
|
super(...e), this.type = "boxplot", this.defaultParams = {
|
|
213
213
|
extent: P,
|
|
@@ -215,7 +215,7 @@ var k = {
|
|
|
215
215
|
notch: !1,
|
|
216
216
|
showMean: !1,
|
|
217
217
|
varwidth: !1
|
|
218
|
-
}, this.defaultStat = new
|
|
218
|
+
}, this.defaultStat = new De(), this.derivedVariables = Object.values(y), this.positionRoles = [
|
|
219
219
|
{
|
|
220
220
|
axis: "x",
|
|
221
221
|
role: "point",
|
|
@@ -329,28 +329,24 @@ var k = {
|
|
|
329
329
|
aes: "outlier",
|
|
330
330
|
optional: !0
|
|
331
331
|
}
|
|
332
|
-
], this.styleTarget =
|
|
332
|
+
], this.styleTarget = be({
|
|
333
333
|
observation: {
|
|
334
|
-
vocabulary:
|
|
335
|
-
aesthetics: {
|
|
336
|
-
fill: "color",
|
|
337
|
-
stroke: "color"
|
|
338
|
-
},
|
|
334
|
+
vocabulary: je,
|
|
335
|
+
aesthetics: { fill: "color" },
|
|
339
336
|
rest: {
|
|
340
337
|
fill: M("geom"),
|
|
341
|
-
fillAlpha:
|
|
342
|
-
stroke: M("
|
|
338
|
+
fillAlpha: 1,
|
|
339
|
+
stroke: M("geomBorder"),
|
|
343
340
|
strokeWidth: $e
|
|
344
341
|
}
|
|
345
342
|
},
|
|
346
343
|
parts: {
|
|
347
344
|
median: {
|
|
348
345
|
vocabulary: K,
|
|
349
|
-
aesthetics: { stroke: "color" },
|
|
350
346
|
rest: {
|
|
351
|
-
stroke: M("
|
|
347
|
+
stroke: M("graphBackground"),
|
|
352
348
|
alpha: 1,
|
|
353
|
-
strokeWidth:
|
|
349
|
+
strokeWidth: Ae,
|
|
354
350
|
dashArray: []
|
|
355
351
|
}
|
|
356
352
|
},
|
|
@@ -360,7 +356,7 @@ var k = {
|
|
|
360
356
|
rest: {
|
|
361
357
|
stroke: M("geom"),
|
|
362
358
|
alpha: 1,
|
|
363
|
-
strokeWidth:
|
|
359
|
+
strokeWidth: Ge,
|
|
364
360
|
dashArray: []
|
|
365
361
|
}
|
|
366
362
|
},
|
|
@@ -370,53 +366,50 @@ var k = {
|
|
|
370
366
|
rest: {
|
|
371
367
|
stroke: M("geom"),
|
|
372
368
|
alpha: 1,
|
|
373
|
-
strokeWidth:
|
|
369
|
+
strokeWidth: 0,
|
|
374
370
|
dashArray: []
|
|
375
371
|
}
|
|
376
372
|
},
|
|
377
373
|
outlier: {
|
|
378
|
-
vocabulary:
|
|
379
|
-
aesthetics: {
|
|
380
|
-
fill: "color",
|
|
381
|
-
stroke: "color"
|
|
382
|
-
},
|
|
374
|
+
vocabulary: z,
|
|
375
|
+
aesthetics: { fill: "color" },
|
|
383
376
|
rest: {
|
|
384
377
|
fill: M("geom"),
|
|
385
|
-
fillAlpha:
|
|
386
|
-
stroke: M("
|
|
378
|
+
fillAlpha: 1,
|
|
379
|
+
stroke: M("graphBackground"),
|
|
387
380
|
alpha: 1,
|
|
388
|
-
size:
|
|
389
|
-
strokeWidth:
|
|
381
|
+
size: Fe,
|
|
382
|
+
strokeWidth: He
|
|
390
383
|
}
|
|
391
384
|
},
|
|
392
385
|
mean: {
|
|
393
|
-
vocabulary:
|
|
394
|
-
aesthetics: {
|
|
386
|
+
vocabulary: z,
|
|
387
|
+
aesthetics: { stroke: "color" },
|
|
395
388
|
rest: {
|
|
396
|
-
fill: M("
|
|
389
|
+
fill: M("graphBackground"),
|
|
397
390
|
fillAlpha: 1,
|
|
398
|
-
stroke: M("
|
|
391
|
+
stroke: M("geom"),
|
|
399
392
|
alpha: 1,
|
|
400
|
-
size:
|
|
401
|
-
strokeWidth:
|
|
393
|
+
size: Xe,
|
|
394
|
+
strokeWidth: ze
|
|
402
395
|
}
|
|
403
396
|
}
|
|
404
397
|
}
|
|
405
|
-
}), this.resolveBandFraction = (t) =>
|
|
398
|
+
}), this.resolveBandFraction = (t) => Y(t), this.resolveValueSource = (t) => t.median ?? { variable: y.median }, this.validateMapping = ({ mapping: t, computedVariables: r }) => r.has("y") ? [{
|
|
406
399
|
code: "CONFLICTING_STAT_MAPPING",
|
|
407
400
|
message: "boxplot geom draws a summary, not a single 'y'; use the 'boxplot' stat or 'identity'"
|
|
408
|
-
}] : r.has("median") ? [...[...
|
|
401
|
+
}] : r.has("median") ? [...[...ae].filter((o) => t[o] !== void 0).map((o) => ({
|
|
409
402
|
code: "CONFLICTING_STAT_MAPPING",
|
|
410
403
|
message: `boxplot stat computes '${o}' from 'y'; remove its mapping, or set the layer's stat to 'identity'`
|
|
411
404
|
})), ...t.y === void 0 ? [{
|
|
412
405
|
code: "MISSING_AESTHETIC",
|
|
413
406
|
message: "boxplot stat summarises 'y'; map it to the raw values"
|
|
414
|
-
}] : []] :
|
|
407
|
+
}] : []] : Ye.filter((o) => t[o] === void 0).map((o) => ({
|
|
415
408
|
code: "MISSING_AESTHETIC",
|
|
416
409
|
message: `boxplot geom requires '${o}' when its data is already summarised`,
|
|
417
410
|
context: { aesthetic: o }
|
|
418
411
|
})), this.resolveAnchorPosition = (t, { coordSystem: r }) => {
|
|
419
|
-
const o = E(r), n =
|
|
412
|
+
const o = E(r), n = Ze(t, o);
|
|
420
413
|
return n === null ? null : o === "x" ? {
|
|
421
414
|
x: n.band,
|
|
422
415
|
y: n.value
|
|
@@ -440,21 +433,21 @@ var k = {
|
|
|
440
433
|
data: e,
|
|
441
434
|
mapping: {}
|
|
442
435
|
};
|
|
443
|
-
const { outliers: a, notch: s, showMean: i, varwidth: u } = r, l = q(e, t.outlier), h = a === !1 && l !== null ?
|
|
436
|
+
const { outliers: a, notch: s, showMean: i, varwidth: u } = r, l = q(e, t.outlier), h = a === !1 && l !== null ? tt(e, l) : e, p = q(h, t.count), g = Y(r) / 2;
|
|
444
437
|
return {
|
|
445
|
-
data: h.addVariable(
|
|
438
|
+
data: h.addVariable(y.relativeWidth, "numeric", u === !0 && p !== null ? Je(h, p) : et(h)).addVariable(_.yMin, "numeric", j(h, o, l)).addVariable(_.yMax, "numeric", j(h, n, l)).addConstantVariable(_.xMin, "numeric", -g).addConstantVariable(_.xMax, "numeric", g),
|
|
446
439
|
mapping: {
|
|
447
440
|
...t.y === void 0 && { y: t.median },
|
|
448
|
-
...i === !0 && t.mean === void 0 && h.hasVariable(
|
|
449
|
-
...s === !0 && t.notchLower === void 0 && h.hasVariable(
|
|
450
|
-
notchLower:
|
|
451
|
-
notchUpper:
|
|
441
|
+
...i === !0 && t.mean === void 0 && h.hasVariable(y.mean) && { mean: y.mean },
|
|
442
|
+
...s === !0 && t.notchLower === void 0 && h.hasVariable(y.notchLower) && {
|
|
443
|
+
notchLower: y.notchLower,
|
|
444
|
+
notchUpper: y.notchUpper
|
|
452
445
|
}
|
|
453
446
|
}
|
|
454
447
|
};
|
|
455
448
|
}
|
|
456
449
|
resolveExtent(e, t) {
|
|
457
|
-
return
|
|
450
|
+
return oe(e) ? e : (t?.addWarning({
|
|
458
451
|
code: "INVALID_GEOM_PARAM",
|
|
459
452
|
message: `Boxplot extent must be a non-negative number or 'min-max', got ${String(e)}; falling back to ${P}.`,
|
|
460
453
|
context: {
|
|
@@ -473,7 +466,7 @@ var k = {
|
|
|
473
466
|
const o = r !== null && r > 1 ? 1 : void 0;
|
|
474
467
|
return t?.addWarning({
|
|
475
468
|
code: "INVALID_GEOM_PARAM",
|
|
476
|
-
message: `Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o ??
|
|
469
|
+
message: `Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o ?? se}.`,
|
|
477
470
|
context: {
|
|
478
471
|
geom: this.type,
|
|
479
472
|
param: "width",
|
|
@@ -483,40 +476,40 @@ var k = {
|
|
|
483
476
|
suggestion: "Set params.width to a fraction of the category band in (0, 1]."
|
|
484
477
|
}), o !== void 0 ? { width: o } : {};
|
|
485
478
|
}
|
|
486
|
-
},
|
|
487
|
-
const r =
|
|
479
|
+
}, Ze = (e, t) => {
|
|
480
|
+
const r = te(e, t);
|
|
488
481
|
if (r !== null) return {
|
|
489
482
|
band: N(r),
|
|
490
483
|
value: r.median
|
|
491
484
|
};
|
|
492
|
-
const o =
|
|
485
|
+
const o = re(e, t);
|
|
493
486
|
return o === null ? null : {
|
|
494
487
|
band: o.band,
|
|
495
488
|
value: o.value
|
|
496
489
|
};
|
|
497
|
-
},
|
|
490
|
+
}, Y = ({ width: e }) => e ?? se, Je = (e, t) => {
|
|
498
491
|
const r = e.getValues(t, { type: "numeric" }), o = Math.max(0, ...r.map((n) => n ?? 0));
|
|
499
492
|
return r.map((n) => n === null || o === 0 ? null : Math.sqrt(n / o));
|
|
500
|
-
},
|
|
493
|
+
}, et = (e) => Array.from({ length: e.size() }, () => null), j = (e, t, r) => {
|
|
501
494
|
const o = r === null ? [] : e.getValues(r, { type: "numeric" });
|
|
502
495
|
return e.getValues(t, { type: "numeric" }).map((n, a) => n ?? o[a] ?? null);
|
|
503
|
-
},
|
|
496
|
+
}, tt = (e, t) => {
|
|
504
497
|
const r = e.getValues(t, { type: "numeric" });
|
|
505
498
|
return e.take(r.flatMap((o, n) => o === null ? [n] : []));
|
|
506
499
|
}, q = (e, t) => {
|
|
507
500
|
const r = V(t);
|
|
508
501
|
return r !== null && e.hasVariable(r) ? r : null;
|
|
509
|
-
},
|
|
510
|
-
const r = (e.q1 + e.q3) / 2, o = Math.max(Math.abs(e.q3 - e.q1),
|
|
502
|
+
}, rt = 5e-4, ot = 0.5, nt = 0.5, le = (e, t) => {
|
|
503
|
+
const r = (e.q1 + e.q3) / 2, o = Math.max(Math.abs(e.q3 - e.q1), rt) / 2, n = v(t, e.start, r - o), a = v(t, e.end, r + o), [s, i] = Q(n.x, a.x), [u, l] = Q(n.y, a.y);
|
|
511
504
|
return {
|
|
512
505
|
x: s,
|
|
513
506
|
y: u,
|
|
514
507
|
width: i - s,
|
|
515
508
|
height: l - u
|
|
516
509
|
};
|
|
517
|
-
},
|
|
510
|
+
}, ie = (e, t) => {
|
|
518
511
|
if (e.notch === null) return null;
|
|
519
|
-
const { lower: r, upper: o } = e.notch, [n, a] =
|
|
512
|
+
const { lower: r, upper: o } = e.notch, [n, a] = ce(e);
|
|
520
513
|
return [
|
|
521
514
|
v(t, e.start, e.q1),
|
|
522
515
|
v(t, e.start, r),
|
|
@@ -529,17 +522,17 @@ var k = {
|
|
|
529
522
|
v(t, e.end, r),
|
|
530
523
|
v(t, e.end, e.q1)
|
|
531
524
|
];
|
|
532
|
-
},
|
|
533
|
-
const [r, o] = e.notch === null ? [e.start, e.end] :
|
|
525
|
+
}, at = (e, t) => {
|
|
526
|
+
const [r, o] = e.notch === null ? [e.start, e.end] : ce(e);
|
|
534
527
|
return {
|
|
535
528
|
from: v(t, r, e.median),
|
|
536
529
|
to: v(t, o, e.median)
|
|
537
530
|
};
|
|
538
|
-
},
|
|
539
|
-
const t = (e.end - e.start) * (1 -
|
|
531
|
+
}, ue = (e, t) => e.mean === null ? null : v(t, N(e), e.mean), ce = (e) => {
|
|
532
|
+
const t = (e.end - e.start) * (1 - nt) / 2;
|
|
540
533
|
return [e.start + t, e.end - t];
|
|
541
|
-
},
|
|
542
|
-
const r = N(e), o = (e.end - e.start) *
|
|
534
|
+
}, he = (e, t) => {
|
|
535
|
+
const r = N(e), o = (e.end - e.start) * ot / 2;
|
|
543
536
|
return [{
|
|
544
537
|
side: "lower",
|
|
545
538
|
quartile: e.q1,
|
|
@@ -560,21 +553,21 @@ var k = {
|
|
|
560
553
|
}
|
|
561
554
|
}));
|
|
562
555
|
}, v = (e, t, r) => {
|
|
563
|
-
const o =
|
|
556
|
+
const o = Se(e, {
|
|
564
557
|
main: t,
|
|
565
558
|
cross: r
|
|
566
559
|
});
|
|
567
560
|
return {
|
|
568
|
-
x:
|
|
569
|
-
y:
|
|
561
|
+
x: _e(o.x),
|
|
562
|
+
y: qe(o.y)
|
|
570
563
|
};
|
|
571
|
-
},
|
|
564
|
+
}, Q = (e, t) => e <= t ? [e, t] : [t, e], T = (e, t) => ({
|
|
572
565
|
x: e.x * t.width,
|
|
573
566
|
y: e.y * t.height
|
|
574
567
|
}), F = (e, t) => `${e.map((r, o) => {
|
|
575
|
-
const { x: n, y: a } =
|
|
568
|
+
const { x: n, y: a } = T(r, t);
|
|
576
569
|
return `${o === 0 ? "M" : "L"}${n},${a}`;
|
|
577
|
-
}).join("")}Z`,
|
|
570
|
+
}).join("")}Z`, st = (e, t) => F([
|
|
578
571
|
{
|
|
579
572
|
x: e.x,
|
|
580
573
|
y: e.y
|
|
@@ -591,49 +584,49 @@ var k = {
|
|
|
591
584
|
x: e.x,
|
|
592
585
|
y: e.y + e.height
|
|
593
586
|
}
|
|
594
|
-
], t),
|
|
595
|
-
const r =
|
|
587
|
+
], t), lt = (e, t) => {
|
|
588
|
+
const r = T(e.from, t), o = T(e.to, t);
|
|
596
589
|
return `M${r.x},${r.y}L${o.x},${o.y}`;
|
|
597
|
-
},
|
|
590
|
+
}, it = ({ layer: e, coordSystem: t, panelRect: r, styleReaders: o }) => {
|
|
598
591
|
const n = E(t), { boxes: a, outliers: s } = I(e.data, n), i = a.map((c) => {
|
|
599
|
-
const f =
|
|
592
|
+
const f = ie(c, n);
|
|
600
593
|
return f !== null ? {
|
|
601
594
|
kind: "region",
|
|
602
595
|
pathData: F(f, r)
|
|
603
596
|
} : {
|
|
604
597
|
kind: "region",
|
|
605
|
-
pathData:
|
|
598
|
+
pathData: st(le(c, n), r)
|
|
606
599
|
};
|
|
607
|
-
}), u = o.part("whisker"), l = o.part("cap"), h = a.flatMap((c) =>
|
|
600
|
+
}), u = o.part("whisker"), l = o.part("cap"), h = a.flatMap((c) => he(c, n).flatMap((f) => [{
|
|
608
601
|
segment: f.stem,
|
|
609
602
|
readers: u
|
|
610
603
|
}, {
|
|
611
604
|
segment: f.cap,
|
|
612
605
|
readers: l
|
|
613
|
-
}].flatMap(({ segment: W, readers:
|
|
614
|
-
const O =
|
|
606
|
+
}].flatMap(({ segment: W, readers: C }) => {
|
|
607
|
+
const O = C?.get("strokeWidth", c.observation) ?? 0;
|
|
615
608
|
return O > 0 ? [{
|
|
616
609
|
kind: "stroke",
|
|
617
|
-
pathData:
|
|
610
|
+
pathData: lt(W, r),
|
|
618
611
|
width: O
|
|
619
612
|
}] : [];
|
|
620
613
|
}))), p = o.part("outlier"), g = p === void 0 ? [] : s.map((c) => ({
|
|
621
|
-
center:
|
|
622
|
-
size:
|
|
614
|
+
center: T(v(n, c.band, c.value), r),
|
|
615
|
+
size: Z(p, c.observation)
|
|
623
616
|
})), d = o.part("mean"), m = d === void 0 ? [] : a.flatMap((c) => {
|
|
624
|
-
const f =
|
|
617
|
+
const f = ue(c, n);
|
|
625
618
|
return f === null ? [] : [{
|
|
626
|
-
center:
|
|
627
|
-
size:
|
|
619
|
+
center: T(f, r),
|
|
620
|
+
size: Z(d, c.observation)
|
|
628
621
|
}];
|
|
629
|
-
}), w =
|
|
622
|
+
}), w = Me([...g, ...m]);
|
|
630
623
|
return [
|
|
631
624
|
...h,
|
|
632
625
|
...i,
|
|
633
626
|
...w
|
|
634
627
|
];
|
|
635
|
-
},
|
|
636
|
-
const t =
|
|
628
|
+
}, Z = (e, t) => (e.get("size", t) ?? 0) + (e.get("strokeWidth", t) ?? 0), H = (e) => {
|
|
629
|
+
const t = Ie(e.data, e.mapping, e.id), r = V(e.mapping.outlier), o = (n) => `${t(n.observation)}-outlier-${String(r === null ? n.value : n.observation[r])}`;
|
|
637
630
|
return {
|
|
638
631
|
readBoxKey: t,
|
|
639
632
|
readOutlierKeys: (n) => {
|
|
@@ -644,16 +637,16 @@ var k = {
|
|
|
644
637
|
});
|
|
645
638
|
}
|
|
646
639
|
};
|
|
647
|
-
},
|
|
640
|
+
}, ut = (e, t, r) => {
|
|
648
641
|
const o = e.data.getVariableNames(), n = (s) => JSON.stringify(o.map((i) => s.observation[i] ?? null)), a = new Set(r.map(n));
|
|
649
642
|
return t.filter((s) => a.has(n(s)));
|
|
650
|
-
},
|
|
643
|
+
}, de = (e, t, r) => {
|
|
651
644
|
const o = new Set(t.map((n) => r(n.observation)));
|
|
652
645
|
return e.filter((n) => o.has(r(n.observation)));
|
|
653
646
|
}, X = ({ boxes: e, outliers: t, mainAxis: r, panelSize: o, source: n, styleReaders: a, keys: s, hovered: i, shouldAnimateTransitions: u = !1 }) => {
|
|
654
647
|
const l = i === void 0 ? void 0 : "hovered", h = a.part("whisker"), p = a.part("cap"), g = a.part("median"), d = a.part("mean"), m = a.part("outlier"), w = s.readOutlierKeys(t);
|
|
655
|
-
return /* @__PURE__ */
|
|
656
|
-
e.flatMap((c) =>
|
|
648
|
+
return /* @__PURE__ */ Ve(Pe, { children: [
|
|
649
|
+
e.flatMap((c) => he(c, r).flatMap((f) => [{
|
|
657
650
|
piece: "stem",
|
|
658
651
|
testId: "boxplot-whisker",
|
|
659
652
|
readers: h
|
|
@@ -661,18 +654,18 @@ var k = {
|
|
|
661
654
|
piece: "cap",
|
|
662
655
|
testId: "boxplot-cap",
|
|
663
656
|
readers: p
|
|
664
|
-
}].map(({ piece: W, testId:
|
|
665
|
-
testId:
|
|
657
|
+
}].map(({ piece: W, testId: C, readers: O }) => O === void 0 ? null : /* @__PURE__ */ k(J, {
|
|
658
|
+
testId: C,
|
|
666
659
|
segment: f[W],
|
|
667
660
|
observation: c.observation,
|
|
668
661
|
readers: O,
|
|
669
662
|
state: l,
|
|
670
663
|
shouldAnimateTransitions: u
|
|
671
664
|
}, `${s.readBoxKey(c.observation)}-${f.side}-${W}`)))),
|
|
672
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ k(fe, {
|
|
673
666
|
styleReaders: a,
|
|
674
667
|
state: l,
|
|
675
|
-
children: e.map((c) => /* @__PURE__ */
|
|
668
|
+
children: e.map((c) => /* @__PURE__ */ k(ct, {
|
|
676
669
|
box: c,
|
|
677
670
|
mainAxis: r,
|
|
678
671
|
panelSize: o,
|
|
@@ -682,17 +675,17 @@ var k = {
|
|
|
682
675
|
shouldAnimateTransitions: u
|
|
683
676
|
}, s.readBoxKey(c.observation)))
|
|
684
677
|
}),
|
|
685
|
-
g && e.map((c) => /* @__PURE__ */
|
|
678
|
+
g && e.map((c) => /* @__PURE__ */ k(J, {
|
|
686
679
|
testId: "boxplot-median",
|
|
687
|
-
segment:
|
|
680
|
+
segment: at(c, r),
|
|
688
681
|
observation: c.observation,
|
|
689
682
|
readers: g,
|
|
690
683
|
state: l,
|
|
691
684
|
shouldAnimateTransitions: u
|
|
692
685
|
}, s.readBoxKey(c.observation))),
|
|
693
686
|
d && e.map((c) => {
|
|
694
|
-
const f =
|
|
695
|
-
return f === null ? null : /* @__PURE__ */
|
|
687
|
+
const f = ue(c, r);
|
|
688
|
+
return f === null ? null : /* @__PURE__ */ k(ee, {
|
|
696
689
|
testId: "boxplot-mean",
|
|
697
690
|
centre: f,
|
|
698
691
|
observation: c.observation,
|
|
@@ -701,7 +694,7 @@ var k = {
|
|
|
701
694
|
shouldAnimateTransitions: u
|
|
702
695
|
}, s.readBoxKey(c.observation));
|
|
703
696
|
}),
|
|
704
|
-
m && t.map((c, f) => /* @__PURE__ */
|
|
697
|
+
m && t.map((c, f) => /* @__PURE__ */ k(ee, {
|
|
705
698
|
testId: "boxplot-outlier",
|
|
706
699
|
centre: v(r, c.band, c.value),
|
|
707
700
|
observation: c.observation,
|
|
@@ -710,63 +703,64 @@ var k = {
|
|
|
710
703
|
shouldAnimateTransitions: u
|
|
711
704
|
}, w[f]))
|
|
712
705
|
] });
|
|
713
|
-
},
|
|
706
|
+
}, J = ({ testId: e, segment: t, observation: r, readers: o, state: n, shouldAnimateTransitions: a }) => {
|
|
714
707
|
const s = o.get("strokeWidth", r, n) ?? 0, i = o.get("stroke", r, n);
|
|
715
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ k(ge, {
|
|
716
709
|
"data-testid": e,
|
|
717
710
|
x1: x(t.from.x),
|
|
718
711
|
y1: x(t.from.y),
|
|
719
712
|
x2: x(t.to.x),
|
|
720
713
|
y2: x(t.to.y),
|
|
721
|
-
stroke: i === void 0 ? void 0 :
|
|
714
|
+
stroke: i === void 0 ? void 0 : B(i),
|
|
722
715
|
strokeOpacity: o.get("alpha", r, n),
|
|
723
716
|
strokeWidth: s,
|
|
724
|
-
strokeDasharray:
|
|
717
|
+
strokeDasharray: Te(o.get("dashArray", r, n), s),
|
|
725
718
|
shouldAnimateTransitions: a
|
|
726
719
|
});
|
|
727
|
-
},
|
|
720
|
+
}, ct = ({ box: e, mainAxis: t, panelSize: r, source: o, styleReaders: n, state: a, shouldAnimateTransitions: s }) => {
|
|
728
721
|
const i = n.get("fill", e.observation, a), u = n.get("stroke", e.observation, a), l = {
|
|
729
|
-
fill: i === void 0 ? void 0 :
|
|
722
|
+
fill: i === void 0 ? void 0 : B(i),
|
|
730
723
|
opacity: n.get("alpha", e.observation, a),
|
|
731
724
|
fillOpacity: n.get("fillAlpha", e.observation, a),
|
|
732
|
-
stroke: u === void 0 ? void 0 :
|
|
725
|
+
stroke: u === void 0 ? void 0 : B(u),
|
|
733
726
|
strokeOpacity: n.get("strokeAlpha", e.observation, a),
|
|
734
727
|
strokeWidth: n.get("strokeWidth", e.observation, a),
|
|
735
|
-
effects:
|
|
728
|
+
effects: Be(n, e.observation, a),
|
|
736
729
|
shouldAnimateTransitions: s
|
|
737
|
-
}, h =
|
|
738
|
-
if (h !== null) return /* @__PURE__ */
|
|
730
|
+
}, h = ie(e, t);
|
|
731
|
+
if (h !== null) return /* @__PURE__ */ k(ke, {
|
|
739
732
|
"data-testid": "boxplot-box",
|
|
740
733
|
d: F(h, r),
|
|
741
734
|
source: o,
|
|
742
735
|
...l
|
|
743
736
|
});
|
|
744
|
-
const p =
|
|
745
|
-
return /* @__PURE__ */
|
|
737
|
+
const p = le(e, t);
|
|
738
|
+
return /* @__PURE__ */ k(ye, {
|
|
746
739
|
"data-testid": "boxplot-box",
|
|
747
740
|
x: x(p.x),
|
|
748
741
|
y: x(p.y),
|
|
749
742
|
width: x(p.width),
|
|
750
743
|
height: x(p.height),
|
|
744
|
+
cornerRadius: n.get("cornerRadius", e.observation, a),
|
|
751
745
|
...l
|
|
752
746
|
});
|
|
753
|
-
},
|
|
747
|
+
}, ee = ({ testId: e, centre: t, observation: r, readers: o, state: n, shouldAnimateTransitions: a }) => {
|
|
754
748
|
const s = o.get("fill", r, n), i = o.get("stroke", r, n);
|
|
755
|
-
return /* @__PURE__ */
|
|
749
|
+
return /* @__PURE__ */ k(ve, {
|
|
756
750
|
"data-testid": e,
|
|
757
751
|
cx: x(t.x),
|
|
758
752
|
cy: x(t.y),
|
|
759
753
|
r: (o.get("size", r, n) ?? 0) / 2,
|
|
760
|
-
fill: s === void 0 ? void 0 :
|
|
754
|
+
fill: s === void 0 ? void 0 : B(s),
|
|
761
755
|
opacity: o.get("alpha", r, n),
|
|
762
756
|
fillOpacity: o.get("fillAlpha", r, n),
|
|
763
|
-
stroke: i === void 0 ? void 0 :
|
|
757
|
+
stroke: i === void 0 ? void 0 : B(i),
|
|
764
758
|
strokeWidth: o.get("strokeWidth", r, n),
|
|
765
759
|
shouldAnimateTransitions: a
|
|
766
760
|
});
|
|
767
|
-
},
|
|
761
|
+
}, ht = ({ layer: e, sourceLayer: t, mainAxis: r, panelSize: o, styleReaders: n }) => {
|
|
768
762
|
const a = S(() => H(t), [t]), s = S(() => I(t.data, r).outliers, [t.data, r]), { boxes: i, outliers: u } = S(() => {
|
|
769
|
-
const l = I(e.data, r), h = new Set(
|
|
763
|
+
const l = I(e.data, r), h = new Set(ut(t, s, l.outliers)), p = new Set(de(s, l.boxes, a.readBoxKey)), g = s.filter((d) => p.has(d) || h.has(d));
|
|
770
764
|
return {
|
|
771
765
|
boxes: l.boxes,
|
|
772
766
|
outliers: g
|
|
@@ -778,7 +772,7 @@ var k = {
|
|
|
778
772
|
s,
|
|
779
773
|
a
|
|
780
774
|
]);
|
|
781
|
-
return /* @__PURE__ */
|
|
775
|
+
return /* @__PURE__ */ k(X, {
|
|
782
776
|
boxes: i,
|
|
783
777
|
outliers: u,
|
|
784
778
|
mainAxis: r,
|
|
@@ -787,13 +781,13 @@ var k = {
|
|
|
787
781
|
styleReaders: n,
|
|
788
782
|
keys: a
|
|
789
783
|
});
|
|
790
|
-
},
|
|
784
|
+
}, dt = ({ layer: e, primary: t, mainAxis: r, panelSize: o, styleReaders: n }) => {
|
|
791
785
|
const a = S(() => I(e.data, r).outliers, [e.data, r]), s = S(() => H(e), [e]), { boxes: i, outliers: u } = I([t.observation], r);
|
|
792
|
-
return /* @__PURE__ */
|
|
786
|
+
return /* @__PURE__ */ k("g", {
|
|
793
787
|
"data-testid": "hovered-boxes",
|
|
794
|
-
children: /* @__PURE__ */
|
|
788
|
+
children: /* @__PURE__ */ k(X, {
|
|
795
789
|
boxes: i,
|
|
796
|
-
outliers: i.length > 0 ?
|
|
790
|
+
outliers: i.length > 0 ? de(a, i, s.readBoxKey) : u,
|
|
797
791
|
mainAxis: r,
|
|
798
792
|
panelSize: o,
|
|
799
793
|
source: e,
|
|
@@ -802,8 +796,8 @@ var k = {
|
|
|
802
796
|
hovered: t.observation
|
|
803
797
|
})
|
|
804
798
|
});
|
|
805
|
-
},
|
|
806
|
-
const { boxes: s, outliers: i } = S(() => I(e.data, t), [e.data, t]), u = /* @__PURE__ */
|
|
799
|
+
}, pt = ({ layer: e, mainAxis: t, panelSize: r, styleReaders: o, shouldAnimateTransitions: n, intro: a }) => {
|
|
800
|
+
const { boxes: s, outliers: i } = S(() => I(e.data, t), [e.data, t]), u = /* @__PURE__ */ k(X, {
|
|
807
801
|
boxes: s,
|
|
808
802
|
outliers: i,
|
|
809
803
|
mainAxis: t,
|
|
@@ -813,7 +807,7 @@ var k = {
|
|
|
813
807
|
keys: S(() => H(e), [e]),
|
|
814
808
|
shouldAnimateTransitions: n
|
|
815
809
|
});
|
|
816
|
-
return a == null ? u : /* @__PURE__ */
|
|
810
|
+
return a == null ? u : /* @__PURE__ */ k(we, {
|
|
817
811
|
intro: {
|
|
818
812
|
type: "fade",
|
|
819
813
|
layerId: a.layerId,
|
|
@@ -821,12 +815,12 @@ var k = {
|
|
|
821
815
|
},
|
|
822
816
|
children: u
|
|
823
817
|
});
|
|
824
|
-
},
|
|
818
|
+
}, ft = Oe(new Qe(), {
|
|
825
819
|
coord: "cartesian",
|
|
826
820
|
swatchShape: "square",
|
|
827
821
|
overpaintPlacement: "manual",
|
|
828
822
|
guideMode: "band",
|
|
829
|
-
render: ({ layer: e, coordSystem: t, panelRect: r, styleReaders: o, shouldAnimateTransitions: n, intro: a }) => /* @__PURE__ */
|
|
823
|
+
render: ({ layer: e, coordSystem: t, panelRect: r, styleReaders: o, shouldAnimateTransitions: n, intro: a }) => /* @__PURE__ */ k(pt, {
|
|
830
824
|
layer: e,
|
|
831
825
|
mainAxis: E(t),
|
|
832
826
|
panelSize: r,
|
|
@@ -834,14 +828,14 @@ var k = {
|
|
|
834
828
|
shouldAnimateTransitions: n,
|
|
835
829
|
intro: a
|
|
836
830
|
}),
|
|
837
|
-
renderHighlight: ({ layer: e, sourceLayer: t, coordSystem: r, panelRect: o, styleReaders: n }) => /* @__PURE__ */
|
|
831
|
+
renderHighlight: ({ layer: e, sourceLayer: t, coordSystem: r, panelRect: o, styleReaders: n }) => /* @__PURE__ */ k(ht, {
|
|
838
832
|
layer: e,
|
|
839
833
|
sourceLayer: t,
|
|
840
834
|
mainAxis: E(r),
|
|
841
835
|
panelSize: o,
|
|
842
836
|
styleReaders: n
|
|
843
837
|
}),
|
|
844
|
-
renderHover: ({ layer: e, primary: t, coordSystem: r, panelRect: o, styleReaders: n }) => /* @__PURE__ */
|
|
838
|
+
renderHover: ({ layer: e, primary: t, coordSystem: r, panelRect: o, styleReaders: n }) => /* @__PURE__ */ k(dt, {
|
|
845
839
|
layer: e,
|
|
846
840
|
primary: t,
|
|
847
841
|
mainAxis: E(r),
|
|
@@ -849,10 +843,10 @@ var k = {
|
|
|
849
843
|
styleReaders: n
|
|
850
844
|
}),
|
|
851
845
|
renderHoverCompanions: () => null,
|
|
852
|
-
getEditOutlineShapes:
|
|
846
|
+
getEditOutlineShapes: it
|
|
853
847
|
});
|
|
854
848
|
export {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
849
|
+
y as BOXPLOT_VARIABLES,
|
|
850
|
+
Qe as BoxplotGeom,
|
|
851
|
+
ft as boxplot
|
|
858
852
|
};
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"boxplot",
|
|
14
14
|
"box-plot"
|
|
15
15
|
],
|
|
16
|
-
"version": "0.1.1-beta.
|
|
16
|
+
"version": "0.1.1-beta.1792409717036",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^19.0.0",
|
|
35
|
-
"@graphysdk/react": "^1.9.0-beta.
|
|
35
|
+
"@graphysdk/react": "^1.9.0-beta.1792409717036"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@testing-library/react": "^16.3.1",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"vite": "^8.1.5",
|
|
45
45
|
"vite-plugin-dts": "^4.5.4",
|
|
46
46
|
"vitest": "^4.1.11",
|
|
47
|
-
"@graphysdk/react": "1.9.0-beta.1792404455940",
|
|
48
47
|
"@graphytools/typescript-config": "0.0.1",
|
|
49
|
-
"@graphytools/eslint-config": "0.0.1",
|
|
50
48
|
"@graphytools/vitest-config": "1.0.0",
|
|
51
|
-
"@graphysdk/viz-engine": "1.9.0-beta.
|
|
49
|
+
"@graphysdk/viz-engine": "1.9.0-beta.1792409717036",
|
|
50
|
+
"@graphysdk/react": "1.9.0-beta.1792409717036",
|
|
51
|
+
"@graphytools/eslint-config": "0.0.1"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|