@graphysdk/geom-boxplot 0.1.1-beta.1793788324987 → 0.1.1-beta.1793803805689
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let s=require("@graphysdk/react"),S=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"),d=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||d===null?null:{lower:i,upper:d}}},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}},W=(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]},P=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),d=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-d,notchUpper:n+d}},_=(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.computedAesthetics=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:P}),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:[]},d=[];for(const p of a){const v=se(p.values,n);if(v===null)continue;for(const h of l)c.get(h)?.push(ce(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)},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"),d=l.get(i)??{indices:[],values:[]};d.indices.push(c),d.values.push(u),l.set(i,d)}),[...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,he=1,de=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",symbol:"pointSymbol"},Q=class extends s.Geom{constructor(...e){super(...e),this.type="boxplot",this.defaultParams={extent:P,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",aesthetic:"lowerWhisker"},{axis:"y",role:"max",valueKind:"value",aesthetic:"upperWhisker"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"q1"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"median"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"q3"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"outlier"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"mean"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"notchLower"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"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={requireMainAxisBands:!0},this.legend={suppressWhenSingleItem:!0},this.spatialKind="rects",this.highlightStrategy="observationRerender",this.tooltip=[{key:"Upper whisker",aesthetic:"upperWhisker",optional:!0},{key:"Q3",aesthetic:"q3",optional:!0},{key:"Median",aesthetic:"median",optional:!0},{key:"Q1",aesthetic:"q1",optional:!0},{key:"Lower whisker",aesthetic:"lowerWhisker",optional:!0},{key:"Count",aesthetic:"count",optional:!0},{key:"Mean",aesthetic:"mean",optional:!0},{key:"Outlier",aesthetic:"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:he}},parts:{median:{vocabulary:q,rest:{stroke:(0,s.token)("graphBackground"),alpha:1,strokeWidth:de,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=>R(t),this.resolveValueSource=t=>t.median??{variable:x.median},this.validateMapping=({mapping:t,computedAesthetics: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=b(e,t.lowerWhisker),n=b(e,t.upperWhisker);if(o===null||n===null)return{data:e,mapping:{}};const{outliers:a,notch:l,showMean:u,varwidth:c}=r,i=b(e,t.outlier),d=a===!1&&i!==null?Se(e,i):e,m=b(d,t.count),k=R(r)/2;return{data:d.addVariable(x.relativeWidth,"numeric",c===!0&&m!==null?we(d,m):Me(d)).addVariable(s.POSITION_VARIABLES.yMin,"numeric",D(d,o,i)).addVariable(s.POSITION_VARIABLES.yMax,"numeric",D(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 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 ${P}.`,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'."}),P)}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}},R=({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),D=(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]:[]))},b=(e,t)=>{const r=(0,s.readVariableName)(t);return r!==null&&e.hasVariable(r)?r:null},We=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),We)/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)]},be=(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`,Pe=(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}=W(e.data,n),u=a.map(h=>{const y=J(h,n);return y!==null?{kind:"region",pathData:N(y,r)}:{kind:"region",pathData:Pe(Z(h,n),r)}}),c=o.part("whisker"),i=o.part("cap"),d=a.flatMap(h=>re(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:Be(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:j(m,h.observation)})),p=o.part("mean"),v=p===void 0?[]:a.flatMap(h=>{const y=ee(h,n);return y===null?[]:[{center:O(y,r),size:j(p,h.observation)}]}),w=(0,s.buildDotsEditOutlineShapes)([...k,...v]);return[...d,...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,animateTransitions: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=>re(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)(U,{testId:E,segment:y[M],observation:h.observation,readers:I,state:i,animateTransitions:c},`${l.readBoxKey(h.observation)}-${y.side}-${M}`)))),(0,f.jsx)(s.GeomOverpaint,{styleReaders:a,state:i,children:e.map(h=>(0,f.jsx)(_e,{box:h,mainAxis:r,panelSize:o,source:n,styleReaders:a,state:i,animateTransitions:c},l.readBoxKey(h.observation)))}),k&&e.map(h=>(0,f.jsx)(U,{testId:"boxplot-median",segment:be(h,r),observation:h.observation,readers:k,state:i,animateTransitions:c},l.readBoxKey(h.observation))),p&&e.map(h=>{const y=ee(h,r);return y===null?null:(0,f.jsx)($,{testId:"boxplot-mean",centre:y,observation:h.observation,readers:p,state:i,animateTransitions:c},l.readBoxKey(h.observation))}),v&&t.map((h,y)=>(0,f.jsx)($,{testId:"boxplot-outlier",centre:g(r,h.band,h.value),observation:h.observation,readers:v,state:i,animateTransitions:c},w[y]))]})},U=({testId:e,segment:t,observation:r,readers:o,state:n,animateTransitions: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),animateTransitions:a})},_e=({box:e,mainAxis:t,panelSize:r,source:o,styleReaders:n,state:a,animateTransitions: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),animateTransitions:l},d=J(e,t);if(d!==null)return(0,f.jsx)(s.GeomPath,{"data-testid":"boxplot-box",d:N(d,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,animateTransitions: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),symbol:o.get("symbol",r,n),animateTransitions:a})},qe=({layer:e,sourceLayer:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,S.useMemo)(()=>A(t),[t]),l=(0,S.useMemo)(()=>W(t.data,r).outliers,[t.data,r]),{boxes:u,outliers:c}=(0,S.useMemo)(()=>{const i=W(e.data,r),d=new Set(Te(t,l,i.outliers)),m=new Set(oe(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})},Ve=({layer:e,primary:t,mainAxis:r,panelSize:o,styleReaders:n})=>{const a=(0,S.useMemo)(()=>W(e.data,r).outliers,[e.data,r]),l=(0,S.useMemo)(()=>A(e),[e]),{boxes:u,outliers:c}=W([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,animateTransitions:n,intro:a})=>{const{boxes:l,outliers:u}=(0,S.useMemo)(()=>W(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,S.useMemo)(()=>A(e),[e]),animateTransitions: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,animateTransitions:n,intro:a})=>(0,f.jsx)(Ne,{layer:e,mainAxis:(0,s.readMainAxis)(t),panelSize:r,styleReaders:o,animateTransitions: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;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let a=require("@graphysdk/react"),S=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,a.getXMin)(e):(0,a.getYMin)(e),o=t==="x"?(0,a.getXMax)(e):(0,a.getYMax)(e),n=t==="x"?(0,a.getYMin)(e):(0,a.getXMin)(e),s=t==="x"?(0,a.getYMax)(e):(0,a.getXMax)(e),l=(0,a.getScaledAesthetic)(e,"q1"),u=(0,a.getScaledAesthetic)(e,"median"),c=(0,a.getScaledAesthetic)(e,"q3");if(r===null||o===null||n===null||s===null||u===null||l===null||c===null)return null;const i=T(e,"notchLower"),d=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:s,mean:T(e,"mean"),notch:i===null||d===null?null:{lower:i,upper:d}}},X=(e,t)=>{const r=t==="x"?(0,a.getXMin)(e):(0,a.getYMin)(e),o=t==="x"?(0,a.getXMax)(e):(0,a.getYMax)(e),n=(0,a.getScaledAesthetic)(e,"outlier");return r===null||o===null||n===null?null:{observation:e,band:B({start:r,end:o}),value:n}},W=(e,t)=>{const r=[],o=[];for(const n of e){const s=G(n,t);if(s!==null){r.push(s);continue}const l=X(n,t);l!==null&&o.push(l)}return{boxes:r,outliers:o}},T=(e,t)=>(0,a.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,s=(t-e)*o/2;return[n-s,n+s]},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),s=_(r,.75),l=t==="min-max"?1/0:t*(s-o),u=o-l,c=s+l,i=r.filter(m=>m>=u&&m<=c),d=ae*(s-o)/Math.sqrt(e.length);return{lowerWhisker:Math.min(i[0]??o,o),q1:o,median:n,q3:s,upperWhisker:Math.max(i[i.length-1]??s,s),count:e.length,mean:r.reduce((m,k)=>m+k,0)/r.length,notchLower:n-d,notchUpper:n+d}},_=(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},z=new Set([...Object.keys(H),"mean","notchLower","notchUpper"]),le=class extends a.Stat{constructor(...e){super(...e),this.type="boxplot",this.computedAesthetics=z}computeStat({data:e,mapping:t,params:r}){const o=(0,a.readVariableName)(t.x),n=(0,a.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 a.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 s=r?.extent;return{data:ie({data:e,xVariable:o,yVariable:n,groupVariables:(0,a.getGroupVariables)(e,t).filter(l=>l!==o),extent:F(s)?s:b}),mapping:H}}},ie=({data:e,xVariable:t,yVariable:r,groupVariables:o,extent:n})=>{const s=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:[]},d=[];for(const p of s){const v=se(p.values,n);if(v===null)continue;for(const h of l)c.get(h)?.push(ce(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 a.Dataset(k)},ue=(e,t,r,o)=>{const n=[t,...o].map(u=>e.getValues(u)),s=e.getValues(r,{type:"numeric"}),l=new Map;return s.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()]},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)}`,Y=.6,he=1,de=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",symbol:"pointSymbol"},Q=class extends a.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",aesthetic:"lowerWhisker"},{axis:"y",role:"max",valueKind:"value",aesthetic:"upperWhisker"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"q1"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"median"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"q3"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"outlier"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"mean"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"notchLower"},{axis:"y",role:"scalar",valueKind:"value",aesthetic:"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={requireMainAxisBands:!0},this.legend={suppressWhenSingleItem:!0},this.spatialKind="rects",this.highlightStrategy="observationRerender",this.tooltip=[{key:"Upper whisker",aesthetic:"upperWhisker",optional:!0},{key:"Q3",aesthetic:"q3",optional:!0},{key:"Median",aesthetic:"median",optional:!0},{key:"Q1",aesthetic:"q1",optional:!0},{key:"Lower whisker",aesthetic:"lowerWhisker",optional:!0},{key:"Count",aesthetic:"count",optional:!0},{key:"Mean",aesthetic:"mean",optional:!0},{key:"Outlier",aesthetic:"outlier",optional:!0}],this.styleTarget=(0,a.defineGeomStyleTarget)({observation:{vocabulary:ye,aesthetics:{fill:"color"},rest:{fill:(0,a.token)("geom"),fillAlpha:1,stroke:(0,a.token)("geomBorder"),strokeWidth:he}},parts:{median:{vocabulary:q,rest:{stroke:(0,a.token)("graphBackground"),alpha:1,strokeWidth:de,dashArray:[]}},whisker:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,a.token)("geom"),alpha:1,strokeWidth:pe,dashArray:[]}},cap:{vocabulary:q,aesthetics:{stroke:"color"},rest:{stroke:(0,a.token)("geom"),alpha:1,strokeWidth:0,dashArray:[]}},outlier:{vocabulary:C,aesthetics:{fill:"color"},rest:{fill:(0,a.token)("geom"),fillAlpha:1,stroke:(0,a.token)("graphBackground"),alpha:1,size:me,strokeWidth:ve}},mean:{vocabulary:C,aesthetics:{stroke:"color"},rest:{fill:(0,a.token)("graphBackground"),fillAlpha:1,stroke:(0,a.token)("geom"),alpha:1,size:ge,strokeWidth:fe}}}}),this.resolveBandFraction=t=>R(t),this.resolveValueSource=t=>t.median??{variable:x.median},this.validateMapping=({mapping:t,computedAesthetics: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"}]:[]]: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,a.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:s,notch:l,showMean:u,varwidth:c}=r,i=P(e,t.outlier),d=s===!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?we(d,m):Me(d)).addVariable(a.POSITION_VARIABLES.yMin,"numeric",D(d,o,i)).addVariable(a.POSITION_VARIABLES.yMax,"numeric",D(d,n,i)).addConstantVariable(a.POSITION_VARIABLES.xMin,"numeric",-k).addConstantVariable(a.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 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??Y}.`,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}},R=({width:e})=>e??Y,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),D=(e,t,r)=>{const o=r===null?[]:e.getValues(r,{type:"numeric"});return e.getValues(t,{type:"numeric"}).map((n,s)=>n??o[s]??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,a.readVariableName)(t);return r!==null&&e.hasVariable(r)?r:null},We=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),We)/2,n=g(t,e.start,r-o),s=g(t,e.end,r+o),[l,u]=K(n.x,s.x),[c,i]=K(n.y,s.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,s]=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,s,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:s})=>n!==s).map(({side:n,quartile:s,reach:l})=>({side:n,stem:{from:g(t,r,s),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,a.composePoint)(e,{main:t,cross:r});return{x:(0,a.toViewBoxX)(o.x),y:(0,a.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:s}=O(r,t);return`${o===0?"M":"L"}${n},${s}`}).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,a.readMainAxis)(t),{boxes:s,outliers:l}=W(e.data,n),u=s.map(h=>{const y=J(h,n);return y!==null?{kind:"region",pathData:N(y,r)}:{kind:"region",pathData:be(Z(h,n),r)}}),c=o.part("whisker"),i=o.part("cap"),d=s.flatMap(h=>re(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:Be(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:j(m,h.observation)})),p=o.part("mean"),v=p===void 0?[]:s.flatMap(h=>{const y=ee(h,n);return y===null?[]:[{center:O(y,r),size:j(p,h.observation)}]}),w=(0,a.buildDotsEditOutlineShapes)([...k,...v]);return[...d,...u,...w]},j=(e,t)=>(e.get("size",t)??0)+(e.get("strokeWidth",t)??0),A=e=>{const t=(0,a.createStableKeyGenerator)(e.data,e.mapping,e.id),r=(0,a.readVariableName)(e.mapping.outlier),o=n=>`${t(n.observation)}-outlier-${String(r===null?n.value:n.observation[r])}`;return{readBoxKey:t,readOutlierKeys:n=>{const s=new Map;return n.map(l=>{const u=o(l),c=s.get(u)??0;return s.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)),s=new Set(r.map(n));return t.filter(l=>s.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:s,keys:l,hovered:u,animateTransitions:c=!1})=>{const i=u===void 0?void 0:"hovered",d=s.part("whisker"),m=s.part("cap"),k=s.part("median"),p=s.part("mean"),v=s.part("outlier"),w=l.readOutlierKeys(t);return(0,f.jsxs)(f.Fragment,{children:[e.flatMap(h=>re(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)(U,{testId:E,segment:y[M],observation:h.observation,readers:I,state:i,animateTransitions:c},`${l.readBoxKey(h.observation)}-${y.side}-${M}`)))),(0,f.jsx)(a.GeomOverpaint,{styleReaders:s,state:i,children:e.map(h=>(0,f.jsx)(_e,{box:h,mainAxis:r,panelSize:o,source:n,styleReaders:s,state:i,animateTransitions:c},l.readBoxKey(h.observation)))}),k&&e.map(h=>(0,f.jsx)(U,{testId:"boxplot-median",segment:Pe(h,r),observation:h.observation,readers:k,state:i,animateTransitions:c},l.readBoxKey(h.observation))),p&&e.map(h=>{const y=ee(h,r);return y===null?null:(0,f.jsx)($,{testId:"boxplot-mean",centre:y,observation:h.observation,readers:p,state:i,animateTransitions:c},l.readBoxKey(h.observation))}),v&&t.map((h,y)=>(0,f.jsx)($,{testId:"boxplot-outlier",centre:g(r,h.band,h.value),observation:h.observation,readers:v,state:i,animateTransitions:c},w[y]))]})},U=({testId:e,segment:t,observation:r,readers:o,state:n,animateTransitions:s})=>{const l=o.get("strokeWidth",r,n)??0,u=o.get("stroke",r,n);return(0,f.jsx)(a.GeomLine,{"data-testid":e,x1:(0,a.toPercent)(t.from.x),y1:(0,a.toPercent)(t.from.y),x2:(0,a.toPercent)(t.to.x),y2:(0,a.toPercent)(t.to.y),stroke:u===void 0?void 0:(0,a.toPaintColor)(u),strokeOpacity:o.get("alpha",r,n),strokeWidth:l,strokeDasharray:(0,a.toStrokeDasharray)(o.get("dashArray",r,n),l),animateTransitions:s})},_e=({box:e,mainAxis:t,panelSize:r,source:o,styleReaders:n,state:s,animateTransitions:l})=>{const u=n.get("fill",e.observation,s),c=n.get("stroke",e.observation,s),i={fill:u===void 0?void 0:(0,a.toPaintColor)(u),opacity:n.get("alpha",e.observation,s),fillOpacity:n.get("fillAlpha",e.observation,s),stroke:c===void 0?void 0:(0,a.toPaintColor)(c),strokeOpacity:n.get("strokeAlpha",e.observation,s),strokeWidth:n.get("strokeWidth",e.observation,s),effects:(0,a.readGeomEffects)(n,e.observation,s),animateTransitions:l},d=J(e,t);if(d!==null)return(0,f.jsx)(a.GeomPath,{"data-testid":"boxplot-box",d:N(d,r),source:o,...i});const m=Z(e,t);return(0,f.jsx)(a.GeomRect,{"data-testid":"boxplot-box",x:(0,a.toPercent)(m.x),y:(0,a.toPercent)(m.y),width:(0,a.toPercent)(m.width),height:(0,a.toPercent)(m.height),cornerRadius:n.get("cornerRadius",e.observation,s),...i})},$=({testId:e,centre:t,observation:r,readers:o,state:n,animateTransitions:s})=>{const l=o.get("fill",r,n),u=o.get("stroke",r,n);return(0,f.jsx)(a.GeomCircle,{"data-testid":e,cx:(0,a.toPercent)(t.x),cy:(0,a.toPercent)(t.y),r:(o.get("size",r,n)??0)/2,fill:l===void 0?void 0:(0,a.toPaintColor)(l),opacity:o.get("alpha",r,n),fillOpacity:o.get("fillAlpha",r,n),stroke:u===void 0?void 0:(0,a.toPaintColor)(u),strokeWidth:o.get("strokeWidth",r,n),symbol:o.get("symbol",r,n),animateTransitions:s})},qe=({layer:e,sourceLayer:t,mainAxis:r,styleReaders:o})=>{const n=(0,a.useGeomPanelSize)(),s=(0,S.useMemo)(()=>A(t),[t]),l=(0,S.useMemo)(()=>W(t.data,r).outliers,[t.data,r]),{boxes:u,outliers:c}=(0,S.useMemo)(()=>{const i=W(e.data,r),d=new Set(Te(t,l,i.outliers)),m=new Set(oe(l,i.boxes,s.readBoxKey)),k=l.filter(p=>m.has(p)||d.has(p));return{boxes:i.boxes,outliers:k}},[e.data,r,t,l,s]);return(0,f.jsx)(L,{boxes:u,outliers:c,mainAxis:r,panelSize:n,source:t,styleReaders:o,keys:s})},Ve=({layer:e,primary:t,mainAxis:r,styleReaders:o})=>{const n=(0,a.useGeomPanelSize)(),s=(0,S.useMemo)(()=>W(e.data,r).outliers,[e.data,r]),l=(0,S.useMemo)(()=>A(e),[e]),{boxes:u,outliers:c}=W([t.observation],r);return(0,f.jsx)("g",{"data-testid":"hovered-boxes",children:(0,f.jsx)(L,{boxes:u,outliers:u.length>0?oe(s,u,l.readBoxKey):c,mainAxis:r,panelSize:n,source:e,styleReaders:o,keys:l,hovered:t.observation})})},Ne=({layer:e,mainAxis:t,styleReaders:r,animateTransitions:o,intro:n})=>{const s=(0,a.useGeomPanelSize)(),{boxes:l,outliers:u}=(0,S.useMemo)(()=>W(e.data,t),[e.data,t]),c=(0,f.jsx)(L,{boxes:l,outliers:u,mainAxis:t,panelSize:s,source:e,styleReaders:r,keys:(0,S.useMemo)(()=>A(e),[e]),animateTransitions:o});return n==null?c:(0,f.jsx)(a.IntroFade,{intro:{type:"fade",layerId:n.layerId,durationSeconds:n.durationSeconds},children:c})},Ae=(0,a.defineGeomRenderer)(new Q,{coord:"cartesian",swatchShape:"square",overpaintPlacement:"manual",guideMode:"band",render:({layer:e,coordSystem:t,styleReaders:r,animateTransitions:o,intro:n})=>(0,f.jsx)(Ne,{layer:e,mainAxis:(0,a.readMainAxis)(t),styleReaders:r,animateTransitions:o,intro:n}),renderHighlight:({layer:e,sourceLayer:t,coordSystem:r,styleReaders:o})=>(0,f.jsx)(qe,{layer:e,sourceLayer:t,mainAxis:(0,a.readMainAxis)(r),styleReaders:o}),renderHover:({layer:e,primary:t,coordSystem:r,styleReaders:o})=>(0,f.jsx)(Ve,{layer:e,primary:t,mainAxis:(0,a.readMainAxis)(r),styleReaders:o}),getEditOutlineShapes:Ee});exports.BOXPLOT_VARIABLES=x;exports.BoxplotGeom=Q;exports.boxplot=Ae;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dataset as
|
|
1
|
+
import { Dataset as me, Geom as ve, GeomCircle as ge, GeomLine as fe, GeomOverpaint as ye, GeomPath as ke, GeomRect as we, IntroFade as xe, POSITION_VARIABLES as _, Stat as We, UserInputError as Me, buildDotsEditOutlineShapes as Se, composePoint as Ie, createStableKeyGenerator as Oe, defineGeomRenderer as be, defineGeomStyleTarget as Ee, getGroupVariables as Be, getScaledAesthetic as b, getXMax as A, getXMin as K, getYMax as U, getYMin as $, readGeomEffects as Te, readMainAxis as E, readVariableName as V, toPaintColor as B, toPercent as x, toStrokeDasharray as _e, toViewBoxX as qe, toViewBoxY as Pe, token as M, useGeomPanelSize as F } from "@graphysdk/react";
|
|
2
2
|
import { useMemo as S } from "react";
|
|
3
|
-
import { Fragment as
|
|
3
|
+
import { Fragment as Ve, jsx as y, jsxs as Ne } from "react/jsx-runtime";
|
|
4
4
|
var k = {
|
|
5
5
|
q1: "boxplotQ1",
|
|
6
6
|
median: "boxplotMedian",
|
|
@@ -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,
|
|
16
|
+
}, N = (e) => (e.start + e.end) / 2, re = (e, t) => {
|
|
17
17
|
const r = t === "x" ? K(e) : $(e), o = t === "x" ? A(e) : U(e), n = t === "x" ? $(e) : K(e), a = t === "x" ? U(e) : A(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 = C(e, "notchLower"), h = C(e, "notchUpper"), [p, g] = Le(r, o, e);
|
|
20
20
|
return {
|
|
21
21
|
observation: e,
|
|
22
22
|
start: p,
|
|
@@ -26,13 +26,13 @@ var k = {
|
|
|
26
26
|
median: i,
|
|
27
27
|
q3: u,
|
|
28
28
|
upperWhisker: a,
|
|
29
|
-
mean:
|
|
29
|
+
mean: C(e, "mean"),
|
|
30
30
|
notch: l === null || h === null ? null : {
|
|
31
31
|
lower: l,
|
|
32
32
|
upper: h
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, oe = (e, t) => {
|
|
36
36
|
const r = t === "x" ? K(e) : $(e), o = t === "x" ? A(e) : U(e), n = b(e, "outlier");
|
|
37
37
|
return r === null || o === null || n === null ? null : {
|
|
38
38
|
observation: e,
|
|
@@ -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 = re(n, t);
|
|
49
49
|
if (a !== null) {
|
|
50
50
|
r.push(a);
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
const s =
|
|
53
|
+
const s = oe(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
|
-
},
|
|
60
|
+
}, C = (e, t) => b(e, t) ?? null, Le = (e, t, r) => {
|
|
61
61
|
const o = r[k.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, ne = (e) => e === "min-max" || typeof e == "number" && Number.isFinite(e) && e >= 0, Ce = 1.58, De = (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,7 +79,7 @@ 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
|
-
},
|
|
82
|
+
}, ae = {
|
|
83
83
|
q1: k.q1,
|
|
84
84
|
median: k.median,
|
|
85
85
|
q3: k.q3,
|
|
@@ -87,14 +87,14 @@ var k = {
|
|
|
87
87
|
upperWhisker: k.upperWhisker,
|
|
88
88
|
count: k.count,
|
|
89
89
|
outlier: k.outlier
|
|
90
|
-
},
|
|
91
|
-
...Object.keys(
|
|
90
|
+
}, se = /* @__PURE__ */ new Set([
|
|
91
|
+
...Object.keys(ae),
|
|
92
92
|
"mean",
|
|
93
93
|
"notchLower",
|
|
94
94
|
"notchUpper"
|
|
95
|
-
]),
|
|
95
|
+
]), Re = class extends We {
|
|
96
96
|
constructor(...e) {
|
|
97
|
-
super(...e), this.type = "boxplot", this.computedAesthetics =
|
|
97
|
+
super(...e), this.type = "boxplot", this.computedAesthetics = se;
|
|
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 Me({
|
|
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: Ae({
|
|
121
121
|
data: e,
|
|
122
122
|
xVariable: o,
|
|
123
123
|
yVariable: n,
|
|
124
|
-
groupVariables:
|
|
125
|
-
extent:
|
|
124
|
+
groupVariables: Be(e, t).filter((s) => s !== o),
|
|
125
|
+
extent: ne(a) ? a : P
|
|
126
126
|
}),
|
|
127
|
-
mapping:
|
|
127
|
+
mapping: ae
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
},
|
|
131
|
-
const a =
|
|
130
|
+
}, Ae = ({ data: e, xVariable: t, yVariable: r, groupVariables: o, extent: n }) => {
|
|
131
|
+
const a = Ke(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,9 +141,9 @@ var k = {
|
|
|
141
141
|
outlier: []
|
|
142
142
|
}, h = [];
|
|
143
143
|
for (const d of a) {
|
|
144
|
-
const m =
|
|
144
|
+
const m = De(d.values, n);
|
|
145
145
|
if (m === null) continue;
|
|
146
|
-
for (const c of s) u.get(c)?.push(
|
|
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);
|
|
148
148
|
const w = {
|
|
149
149
|
low: m.lowerWhisker,
|
|
@@ -177,8 +177,8 @@ var k = {
|
|
|
177
177
|
valueFormat: p
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
return new
|
|
181
|
-
},
|
|
180
|
+
return new me(g);
|
|
181
|
+
}, Ke = (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;
|
|
@@ -188,19 +188,19 @@ var k = {
|
|
|
188
188
|
};
|
|
189
189
|
h.indices.push(u), h.values.push(i), s.set(l, h);
|
|
190
190
|
}), [...s.values()];
|
|
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)}`, le = 0.6, $e = 1, Ge = 2, Fe = 1.5, He = 7, Xe = 1, ze = 7, Ye = 1.5, je = [
|
|
195
195
|
"q1",
|
|
196
196
|
"median",
|
|
197
197
|
"q3"
|
|
198
|
-
],
|
|
198
|
+
], Qe = { strokeWidth: "pixels" }, R = {
|
|
199
199
|
stroke: "color",
|
|
200
200
|
alpha: "unitInterval",
|
|
201
201
|
strokeWidth: "pixels",
|
|
202
202
|
dashArray: "dashArray"
|
|
203
|
-
},
|
|
203
|
+
}, Y = {
|
|
204
204
|
fill: "color",
|
|
205
205
|
fillAlpha: "unitInterval",
|
|
206
206
|
stroke: "color",
|
|
@@ -208,7 +208,7 @@ var k = {
|
|
|
208
208
|
size: "pixels",
|
|
209
209
|
strokeWidth: "pixels",
|
|
210
210
|
symbol: "pointSymbol"
|
|
211
|
-
},
|
|
211
|
+
}, Ze = class extends ve {
|
|
212
212
|
constructor(...e) {
|
|
213
213
|
super(...e), this.type = "boxplot", this.defaultParams = {
|
|
214
214
|
extent: P,
|
|
@@ -216,7 +216,7 @@ var k = {
|
|
|
216
216
|
notch: !1,
|
|
217
217
|
showMean: !1,
|
|
218
218
|
varwidth: !1
|
|
219
|
-
}, this.defaultStat = new
|
|
219
|
+
}, this.defaultStat = new Re(), this.derivedVariables = Object.values(k), this.positionRoles = [
|
|
220
220
|
{
|
|
221
221
|
axis: "x",
|
|
222
222
|
role: "point",
|
|
@@ -330,15 +330,15 @@ var k = {
|
|
|
330
330
|
aesthetic: "outlier",
|
|
331
331
|
optional: !0
|
|
332
332
|
}
|
|
333
|
-
], this.styleTarget =
|
|
333
|
+
], this.styleTarget = Ee({
|
|
334
334
|
observation: {
|
|
335
|
-
vocabulary:
|
|
335
|
+
vocabulary: Qe,
|
|
336
336
|
aesthetics: { fill: "color" },
|
|
337
337
|
rest: {
|
|
338
338
|
fill: M("geom"),
|
|
339
339
|
fillAlpha: 1,
|
|
340
340
|
stroke: M("geomBorder"),
|
|
341
|
-
strokeWidth:
|
|
341
|
+
strokeWidth: $e
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
344
|
parts: {
|
|
@@ -347,7 +347,7 @@ var k = {
|
|
|
347
347
|
rest: {
|
|
348
348
|
stroke: M("graphBackground"),
|
|
349
349
|
alpha: 1,
|
|
350
|
-
strokeWidth:
|
|
350
|
+
strokeWidth: Ge,
|
|
351
351
|
dashArray: []
|
|
352
352
|
}
|
|
353
353
|
},
|
|
@@ -357,7 +357,7 @@ var k = {
|
|
|
357
357
|
rest: {
|
|
358
358
|
stroke: M("geom"),
|
|
359
359
|
alpha: 1,
|
|
360
|
-
strokeWidth:
|
|
360
|
+
strokeWidth: Fe,
|
|
361
361
|
dashArray: []
|
|
362
362
|
}
|
|
363
363
|
},
|
|
@@ -372,45 +372,45 @@ var k = {
|
|
|
372
372
|
}
|
|
373
373
|
},
|
|
374
374
|
outlier: {
|
|
375
|
-
vocabulary:
|
|
375
|
+
vocabulary: Y,
|
|
376
376
|
aesthetics: { fill: "color" },
|
|
377
377
|
rest: {
|
|
378
378
|
fill: M("geom"),
|
|
379
379
|
fillAlpha: 1,
|
|
380
380
|
stroke: M("graphBackground"),
|
|
381
381
|
alpha: 1,
|
|
382
|
-
size:
|
|
383
|
-
strokeWidth:
|
|
382
|
+
size: He,
|
|
383
|
+
strokeWidth: Xe
|
|
384
384
|
}
|
|
385
385
|
},
|
|
386
386
|
mean: {
|
|
387
|
-
vocabulary:
|
|
387
|
+
vocabulary: Y,
|
|
388
388
|
aesthetics: { stroke: "color" },
|
|
389
389
|
rest: {
|
|
390
390
|
fill: M("graphBackground"),
|
|
391
391
|
fillAlpha: 1,
|
|
392
392
|
stroke: M("geom"),
|
|
393
393
|
alpha: 1,
|
|
394
|
-
size:
|
|
395
|
-
strokeWidth:
|
|
394
|
+
size: ze,
|
|
395
|
+
strokeWidth: Ye
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
}), this.resolveBandFraction = (t) =>
|
|
399
|
+
}), this.resolveBandFraction = (t) => j(t), this.resolveValueSource = (t) => t.median ?? { variable: k.median }, this.validateMapping = ({ mapping: t, computedAesthetics: r }) => r.has("y") ? [{
|
|
400
400
|
code: "CONFLICTING_STAT_MAPPING",
|
|
401
401
|
message: "boxplot geom draws a summary, not a single 'y'; use the 'boxplot' stat or 'identity'"
|
|
402
|
-
}] : r.has("median") ? [...[...
|
|
402
|
+
}] : r.has("median") ? [...[...se].filter((o) => t[o] !== void 0).map((o) => ({
|
|
403
403
|
code: "CONFLICTING_STAT_MAPPING",
|
|
404
404
|
message: `boxplot stat computes '${o}' from 'y'; remove its mapping, or set the layer's stat to 'identity'`
|
|
405
405
|
})), ...t.y === void 0 ? [{
|
|
406
406
|
code: "MISSING_AESTHETIC",
|
|
407
407
|
message: "boxplot stat summarises 'y'; map it to the raw values"
|
|
408
|
-
}] : []] :
|
|
408
|
+
}] : []] : je.filter((o) => t[o] === void 0).map((o) => ({
|
|
409
409
|
code: "MISSING_AESTHETIC",
|
|
410
410
|
message: `boxplot geom requires '${o}' when its data is already summarised`,
|
|
411
411
|
context: { aesthetic: o }
|
|
412
412
|
})), this.resolveAnchorPosition = (t, { coordSystem: r }) => {
|
|
413
|
-
const o = E(r), n =
|
|
413
|
+
const o = E(r), n = Je(t, o);
|
|
414
414
|
return n === null ? null : o === "x" ? {
|
|
415
415
|
x: n.band,
|
|
416
416
|
y: n.value
|
|
@@ -434,9 +434,9 @@ var k = {
|
|
|
434
434
|
data: e,
|
|
435
435
|
mapping: {}
|
|
436
436
|
};
|
|
437
|
-
const { outliers: a, notch: s, showMean: i, varwidth: u } = r, l = q(e, t.outlier), h = a === !1 && l !== null ?
|
|
437
|
+
const { outliers: a, notch: s, showMean: i, varwidth: u } = r, l = q(e, t.outlier), h = a === !1 && l !== null ? rt(e, l) : e, p = q(h, t.count), g = j(r) / 2;
|
|
438
438
|
return {
|
|
439
|
-
data: h.addVariable(k.relativeWidth, "numeric", u === !0 && p !== null ?
|
|
439
|
+
data: h.addVariable(k.relativeWidth, "numeric", u === !0 && p !== null ? et(h, p) : tt(h)).addVariable(_.yMin, "numeric", Q(h, o, l)).addVariable(_.yMax, "numeric", Q(h, n, l)).addConstantVariable(_.xMin, "numeric", -g).addConstantVariable(_.xMax, "numeric", g),
|
|
440
440
|
mapping: {
|
|
441
441
|
...t.y === void 0 && { y: t.median },
|
|
442
442
|
...i === !0 && t.mean === void 0 && h.hasVariable(k.mean) && { mean: k.mean },
|
|
@@ -448,7 +448,7 @@ var k = {
|
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
450
|
resolveExtent(e, t) {
|
|
451
|
-
return
|
|
451
|
+
return ne(e) ? e : (t?.addWarning({
|
|
452
452
|
code: "INVALID_GEOM_PARAM",
|
|
453
453
|
message: `Boxplot extent must be a non-negative number or 'min-max', got ${String(e)}; falling back to ${P}.`,
|
|
454
454
|
context: {
|
|
@@ -467,7 +467,7 @@ var k = {
|
|
|
467
467
|
const o = r !== null && r > 1 ? 1 : void 0;
|
|
468
468
|
return t?.addWarning({
|
|
469
469
|
code: "INVALID_GEOM_PARAM",
|
|
470
|
-
message: `Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o ??
|
|
470
|
+
message: `Boxplot width must be a fraction in (0, 1], got ${String(e)}; falling back to ${o ?? le}.`,
|
|
471
471
|
context: {
|
|
472
472
|
geom: this.type,
|
|
473
473
|
param: "width",
|
|
@@ -477,40 +477,40 @@ var k = {
|
|
|
477
477
|
suggestion: "Set params.width to a fraction of the category band in (0, 1]."
|
|
478
478
|
}), o !== void 0 ? { width: o } : {};
|
|
479
479
|
}
|
|
480
|
-
},
|
|
481
|
-
const r =
|
|
480
|
+
}, Je = (e, t) => {
|
|
481
|
+
const r = re(e, t);
|
|
482
482
|
if (r !== null) return {
|
|
483
483
|
band: N(r),
|
|
484
484
|
value: r.median
|
|
485
485
|
};
|
|
486
|
-
const o =
|
|
486
|
+
const o = oe(e, t);
|
|
487
487
|
return o === null ? null : {
|
|
488
488
|
band: o.band,
|
|
489
489
|
value: o.value
|
|
490
490
|
};
|
|
491
|
-
},
|
|
491
|
+
}, j = ({ width: e }) => e ?? le, et = (e, t) => {
|
|
492
492
|
const r = e.getValues(t, { type: "numeric" }), o = Math.max(0, ...r.map((n) => n ?? 0));
|
|
493
493
|
return r.map((n) => n === null || o === 0 ? null : Math.sqrt(n / o));
|
|
494
|
-
},
|
|
494
|
+
}, tt = (e) => Array.from({ length: e.size() }, () => null), Q = (e, t, r) => {
|
|
495
495
|
const o = r === null ? [] : e.getValues(r, { type: "numeric" });
|
|
496
496
|
return e.getValues(t, { type: "numeric" }).map((n, a) => n ?? o[a] ?? null);
|
|
497
|
-
},
|
|
497
|
+
}, rt = (e, t) => {
|
|
498
498
|
const r = e.getValues(t, { type: "numeric" });
|
|
499
499
|
return e.take(r.flatMap((o, n) => o === null ? [n] : []));
|
|
500
500
|
}, q = (e, t) => {
|
|
501
501
|
const r = V(t);
|
|
502
502
|
return r !== null && e.hasVariable(r) ? r : null;
|
|
503
|
-
},
|
|
504
|
-
const r = (e.q1 + e.q3) / 2, o = Math.max(Math.abs(e.q3 - e.q1),
|
|
503
|
+
}, ot = 5e-4, nt = 0.5, at = 0.5, ie = (e, t) => {
|
|
504
|
+
const r = (e.q1 + e.q3) / 2, o = Math.max(Math.abs(e.q3 - e.q1), ot) / 2, n = v(t, e.start, r - o), a = v(t, e.end, r + o), [s, i] = Z(n.x, a.x), [u, l] = Z(n.y, a.y);
|
|
505
505
|
return {
|
|
506
506
|
x: s,
|
|
507
507
|
y: u,
|
|
508
508
|
width: i - s,
|
|
509
509
|
height: l - u
|
|
510
510
|
};
|
|
511
|
-
},
|
|
511
|
+
}, ue = (e, t) => {
|
|
512
512
|
if (e.notch === null) return null;
|
|
513
|
-
const { lower: r, upper: o } = e.notch, [n, a] =
|
|
513
|
+
const { lower: r, upper: o } = e.notch, [n, a] = he(e);
|
|
514
514
|
return [
|
|
515
515
|
v(t, e.start, e.q1),
|
|
516
516
|
v(t, e.start, r),
|
|
@@ -523,17 +523,17 @@ var k = {
|
|
|
523
523
|
v(t, e.end, r),
|
|
524
524
|
v(t, e.end, e.q1)
|
|
525
525
|
];
|
|
526
|
-
},
|
|
527
|
-
const [r, o] = e.notch === null ? [e.start, e.end] :
|
|
526
|
+
}, st = (e, t) => {
|
|
527
|
+
const [r, o] = e.notch === null ? [e.start, e.end] : he(e);
|
|
528
528
|
return {
|
|
529
529
|
from: v(t, r, e.median),
|
|
530
530
|
to: v(t, o, e.median)
|
|
531
531
|
};
|
|
532
|
-
},
|
|
533
|
-
const t = (e.end - e.start) * (1 -
|
|
532
|
+
}, ce = (e, t) => e.mean === null ? null : v(t, N(e), e.mean), he = (e) => {
|
|
533
|
+
const t = (e.end - e.start) * (1 - at) / 2;
|
|
534
534
|
return [e.start + t, e.end - t];
|
|
535
|
-
},
|
|
536
|
-
const r = N(e), o = (e.end - e.start) *
|
|
535
|
+
}, de = (e, t) => {
|
|
536
|
+
const r = N(e), o = (e.end - e.start) * nt / 2;
|
|
537
537
|
return [{
|
|
538
538
|
side: "lower",
|
|
539
539
|
quartile: e.q1,
|
|
@@ -554,21 +554,21 @@ var k = {
|
|
|
554
554
|
}
|
|
555
555
|
}));
|
|
556
556
|
}, v = (e, t, r) => {
|
|
557
|
-
const o =
|
|
557
|
+
const o = Ie(e, {
|
|
558
558
|
main: t,
|
|
559
559
|
cross: r
|
|
560
560
|
});
|
|
561
561
|
return {
|
|
562
|
-
x:
|
|
563
|
-
y:
|
|
562
|
+
x: qe(o.x),
|
|
563
|
+
y: Pe(o.y)
|
|
564
564
|
};
|
|
565
|
-
},
|
|
565
|
+
}, Z = (e, t) => e <= t ? [e, t] : [t, e], T = (e, t) => ({
|
|
566
566
|
x: e.x * t.width,
|
|
567
567
|
y: e.y * t.height
|
|
568
|
-
}),
|
|
568
|
+
}), H = (e, t) => `${e.map((r, o) => {
|
|
569
569
|
const { x: n, y: a } = T(r, t);
|
|
570
570
|
return `${o === 0 ? "M" : "L"}${n},${a}`;
|
|
571
|
-
}).join("")}Z`,
|
|
571
|
+
}).join("")}Z`, lt = (e, t) => H([
|
|
572
572
|
{
|
|
573
573
|
x: e.x,
|
|
574
574
|
y: e.y
|
|
@@ -585,49 +585,49 @@ var k = {
|
|
|
585
585
|
x: e.x,
|
|
586
586
|
y: e.y + e.height
|
|
587
587
|
}
|
|
588
|
-
], t),
|
|
588
|
+
], t), it = (e, t) => {
|
|
589
589
|
const r = T(e.from, t), o = T(e.to, t);
|
|
590
590
|
return `M${r.x},${r.y}L${o.x},${o.y}`;
|
|
591
|
-
},
|
|
591
|
+
}, ut = ({ layer: e, coordSystem: t, panelRect: r, styleReaders: o }) => {
|
|
592
592
|
const n = E(t), { boxes: a, outliers: s } = I(e.data, n), i = a.map((c) => {
|
|
593
|
-
const f =
|
|
593
|
+
const f = ue(c, n);
|
|
594
594
|
return f !== null ? {
|
|
595
595
|
kind: "region",
|
|
596
|
-
pathData:
|
|
596
|
+
pathData: H(f, r)
|
|
597
597
|
} : {
|
|
598
598
|
kind: "region",
|
|
599
|
-
pathData:
|
|
599
|
+
pathData: lt(ie(c, n), r)
|
|
600
600
|
};
|
|
601
|
-
}), u = o.part("whisker"), l = o.part("cap"), h = a.flatMap((c) =>
|
|
601
|
+
}), u = o.part("whisker"), l = o.part("cap"), h = a.flatMap((c) => de(c, n).flatMap((f) => [{
|
|
602
602
|
segment: f.stem,
|
|
603
603
|
readers: u
|
|
604
604
|
}, {
|
|
605
605
|
segment: f.cap,
|
|
606
606
|
readers: l
|
|
607
|
-
}].flatMap(({ segment: W, readers:
|
|
608
|
-
const O =
|
|
607
|
+
}].flatMap(({ segment: W, readers: L }) => {
|
|
608
|
+
const O = L?.get("strokeWidth", c.observation) ?? 0;
|
|
609
609
|
return O > 0 ? [{
|
|
610
610
|
kind: "stroke",
|
|
611
|
-
pathData:
|
|
611
|
+
pathData: it(W, r),
|
|
612
612
|
width: O
|
|
613
613
|
}] : [];
|
|
614
614
|
}))), p = o.part("outlier"), g = p === void 0 ? [] : s.map((c) => ({
|
|
615
615
|
center: T(v(n, c.band, c.value), r),
|
|
616
|
-
size:
|
|
616
|
+
size: J(p, c.observation)
|
|
617
617
|
})), d = o.part("mean"), m = d === void 0 ? [] : a.flatMap((c) => {
|
|
618
|
-
const f =
|
|
618
|
+
const f = ce(c, n);
|
|
619
619
|
return f === null ? [] : [{
|
|
620
620
|
center: T(f, r),
|
|
621
|
-
size:
|
|
621
|
+
size: J(d, c.observation)
|
|
622
622
|
}];
|
|
623
|
-
}), w =
|
|
623
|
+
}), w = Se([...g, ...m]);
|
|
624
624
|
return [
|
|
625
625
|
...h,
|
|
626
626
|
...i,
|
|
627
627
|
...w
|
|
628
628
|
];
|
|
629
|
-
},
|
|
630
|
-
const t =
|
|
629
|
+
}, J = (e, t) => (e.get("size", t) ?? 0) + (e.get("strokeWidth", t) ?? 0), X = (e) => {
|
|
630
|
+
const t = Oe(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])}`;
|
|
631
631
|
return {
|
|
632
632
|
readBoxKey: t,
|
|
633
633
|
readOutlierKeys: (n) => {
|
|
@@ -638,16 +638,16 @@ var k = {
|
|
|
638
638
|
});
|
|
639
639
|
}
|
|
640
640
|
};
|
|
641
|
-
},
|
|
641
|
+
}, ct = (e, t, r) => {
|
|
642
642
|
const o = e.data.getVariableNames(), n = (s) => JSON.stringify(o.map((i) => s.observation[i] ?? null)), a = new Set(r.map(n));
|
|
643
643
|
return t.filter((s) => a.has(n(s)));
|
|
644
|
-
},
|
|
644
|
+
}, pe = (e, t, r) => {
|
|
645
645
|
const o = new Set(t.map((n) => r(n.observation)));
|
|
646
646
|
return e.filter((n) => o.has(r(n.observation)));
|
|
647
|
-
},
|
|
647
|
+
}, z = ({ boxes: e, outliers: t, mainAxis: r, panelSize: o, source: n, styleReaders: a, keys: s, hovered: i, animateTransitions: u = !1 }) => {
|
|
648
648
|
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);
|
|
649
|
-
return /* @__PURE__ */ Ve
|
|
650
|
-
e.flatMap((c) =>
|
|
649
|
+
return /* @__PURE__ */ Ne(Ve, { children: [
|
|
650
|
+
e.flatMap((c) => de(c, r).flatMap((f) => [{
|
|
651
651
|
piece: "stem",
|
|
652
652
|
testId: "boxplot-whisker",
|
|
653
653
|
readers: h
|
|
@@ -655,18 +655,18 @@ var k = {
|
|
|
655
655
|
piece: "cap",
|
|
656
656
|
testId: "boxplot-cap",
|
|
657
657
|
readers: p
|
|
658
|
-
}].map(({ piece: W, testId:
|
|
659
|
-
testId:
|
|
658
|
+
}].map(({ piece: W, testId: L, readers: O }) => O === void 0 ? null : /* @__PURE__ */ y(ee, {
|
|
659
|
+
testId: L,
|
|
660
660
|
segment: f[W],
|
|
661
661
|
observation: c.observation,
|
|
662
662
|
readers: O,
|
|
663
663
|
state: l,
|
|
664
664
|
animateTransitions: u
|
|
665
665
|
}, `${s.readBoxKey(c.observation)}-${f.side}-${W}`)))),
|
|
666
|
-
/* @__PURE__ */ y(
|
|
666
|
+
/* @__PURE__ */ y(ye, {
|
|
667
667
|
styleReaders: a,
|
|
668
668
|
state: l,
|
|
669
|
-
children: e.map((c) => /* @__PURE__ */ y(
|
|
669
|
+
children: e.map((c) => /* @__PURE__ */ y(ht, {
|
|
670
670
|
box: c,
|
|
671
671
|
mainAxis: r,
|
|
672
672
|
panelSize: o,
|
|
@@ -676,17 +676,17 @@ var k = {
|
|
|
676
676
|
animateTransitions: u
|
|
677
677
|
}, s.readBoxKey(c.observation)))
|
|
678
678
|
}),
|
|
679
|
-
g && e.map((c) => /* @__PURE__ */ y(
|
|
679
|
+
g && e.map((c) => /* @__PURE__ */ y(ee, {
|
|
680
680
|
testId: "boxplot-median",
|
|
681
|
-
segment:
|
|
681
|
+
segment: st(c, r),
|
|
682
682
|
observation: c.observation,
|
|
683
683
|
readers: g,
|
|
684
684
|
state: l,
|
|
685
685
|
animateTransitions: u
|
|
686
686
|
}, s.readBoxKey(c.observation))),
|
|
687
687
|
d && e.map((c) => {
|
|
688
|
-
const f =
|
|
689
|
-
return f === null ? null : /* @__PURE__ */ y(
|
|
688
|
+
const f = ce(c, r);
|
|
689
|
+
return f === null ? null : /* @__PURE__ */ y(te, {
|
|
690
690
|
testId: "boxplot-mean",
|
|
691
691
|
centre: f,
|
|
692
692
|
observation: c.observation,
|
|
@@ -695,7 +695,7 @@ var k = {
|
|
|
695
695
|
animateTransitions: u
|
|
696
696
|
}, s.readBoxKey(c.observation));
|
|
697
697
|
}),
|
|
698
|
-
m && t.map((c, f) => /* @__PURE__ */ y(
|
|
698
|
+
m && t.map((c, f) => /* @__PURE__ */ y(te, {
|
|
699
699
|
testId: "boxplot-outlier",
|
|
700
700
|
centre: v(r, c.band, c.value),
|
|
701
701
|
observation: c.observation,
|
|
@@ -704,9 +704,9 @@ var k = {
|
|
|
704
704
|
animateTransitions: u
|
|
705
705
|
}, w[f]))
|
|
706
706
|
] });
|
|
707
|
-
},
|
|
707
|
+
}, ee = ({ testId: e, segment: t, observation: r, readers: o, state: n, animateTransitions: a }) => {
|
|
708
708
|
const s = o.get("strokeWidth", r, n) ?? 0, i = o.get("stroke", r, n);
|
|
709
|
-
return /* @__PURE__ */ y(
|
|
709
|
+
return /* @__PURE__ */ y(fe, {
|
|
710
710
|
"data-testid": e,
|
|
711
711
|
x1: x(t.from.x),
|
|
712
712
|
y1: x(t.from.y),
|
|
@@ -715,10 +715,10 @@ var k = {
|
|
|
715
715
|
stroke: i === void 0 ? void 0 : B(i),
|
|
716
716
|
strokeOpacity: o.get("alpha", r, n),
|
|
717
717
|
strokeWidth: s,
|
|
718
|
-
strokeDasharray:
|
|
718
|
+
strokeDasharray: _e(o.get("dashArray", r, n), s),
|
|
719
719
|
animateTransitions: a
|
|
720
720
|
});
|
|
721
|
-
},
|
|
721
|
+
}, ht = ({ box: e, mainAxis: t, panelSize: r, source: o, styleReaders: n, state: a, animateTransitions: s }) => {
|
|
722
722
|
const i = n.get("fill", e.observation, a), u = n.get("stroke", e.observation, a), l = {
|
|
723
723
|
fill: i === void 0 ? void 0 : B(i),
|
|
724
724
|
opacity: n.get("alpha", e.observation, a),
|
|
@@ -726,17 +726,17 @@ var k = {
|
|
|
726
726
|
stroke: u === void 0 ? void 0 : B(u),
|
|
727
727
|
strokeOpacity: n.get("strokeAlpha", e.observation, a),
|
|
728
728
|
strokeWidth: n.get("strokeWidth", e.observation, a),
|
|
729
|
-
effects:
|
|
729
|
+
effects: Te(n, e.observation, a),
|
|
730
730
|
animateTransitions: s
|
|
731
|
-
}, h =
|
|
732
|
-
if (h !== null) return /* @__PURE__ */ y(
|
|
731
|
+
}, h = ue(e, t);
|
|
732
|
+
if (h !== null) return /* @__PURE__ */ y(ke, {
|
|
733
733
|
"data-testid": "boxplot-box",
|
|
734
|
-
d:
|
|
734
|
+
d: H(h, r),
|
|
735
735
|
source: o,
|
|
736
736
|
...l
|
|
737
737
|
});
|
|
738
|
-
const p =
|
|
739
|
-
return /* @__PURE__ */ y(
|
|
738
|
+
const p = ie(e, t);
|
|
739
|
+
return /* @__PURE__ */ y(we, {
|
|
740
740
|
"data-testid": "boxplot-box",
|
|
741
741
|
x: x(p.x),
|
|
742
742
|
y: x(p.y),
|
|
@@ -745,9 +745,9 @@ var k = {
|
|
|
745
745
|
cornerRadius: n.get("cornerRadius", e.observation, a),
|
|
746
746
|
...l
|
|
747
747
|
});
|
|
748
|
-
},
|
|
748
|
+
}, te = ({ testId: e, centre: t, observation: r, readers: o, state: n, animateTransitions: a }) => {
|
|
749
749
|
const s = o.get("fill", r, n), i = o.get("stroke", r, n);
|
|
750
|
-
return /* @__PURE__ */ y(
|
|
750
|
+
return /* @__PURE__ */ y(ge, {
|
|
751
751
|
"data-testid": e,
|
|
752
752
|
cx: x(t.x),
|
|
753
753
|
cy: x(t.y),
|
|
@@ -760,9 +760,9 @@ var k = {
|
|
|
760
760
|
symbol: o.get("symbol", r, n),
|
|
761
761
|
animateTransitions: a
|
|
762
762
|
});
|
|
763
|
-
},
|
|
764
|
-
const a = S(() =>
|
|
765
|
-
const l = I(e.data, r), h = new Set(
|
|
763
|
+
}, dt = ({ layer: e, sourceLayer: t, mainAxis: r, styleReaders: o }) => {
|
|
764
|
+
const n = F(), a = S(() => X(t), [t]), s = S(() => I(t.data, r).outliers, [t.data, r]), { boxes: i, outliers: u } = S(() => {
|
|
765
|
+
const l = I(e.data, r), h = new Set(ct(t, s, l.outliers)), p = new Set(pe(s, l.boxes, a.readBoxKey)), g = s.filter((d) => p.has(d) || h.has(d));
|
|
766
766
|
return {
|
|
767
767
|
boxes: l.boxes,
|
|
768
768
|
outliers: g
|
|
@@ -774,81 +774,77 @@ var k = {
|
|
|
774
774
|
s,
|
|
775
775
|
a
|
|
776
776
|
]);
|
|
777
|
-
return /* @__PURE__ */ y(
|
|
777
|
+
return /* @__PURE__ */ y(z, {
|
|
778
778
|
boxes: i,
|
|
779
779
|
outliers: u,
|
|
780
780
|
mainAxis: r,
|
|
781
|
-
panelSize:
|
|
781
|
+
panelSize: n,
|
|
782
782
|
source: t,
|
|
783
|
-
styleReaders:
|
|
783
|
+
styleReaders: o,
|
|
784
784
|
keys: a
|
|
785
785
|
});
|
|
786
|
-
},
|
|
787
|
-
const a = S(() => I(e.data, r).outliers, [e.data, r]), s = S(() =>
|
|
786
|
+
}, pt = ({ layer: e, primary: t, mainAxis: r, styleReaders: o }) => {
|
|
787
|
+
const n = F(), a = S(() => I(e.data, r).outliers, [e.data, r]), s = S(() => X(e), [e]), { boxes: i, outliers: u } = I([t.observation], r);
|
|
788
788
|
return /* @__PURE__ */ y("g", {
|
|
789
789
|
"data-testid": "hovered-boxes",
|
|
790
|
-
children: /* @__PURE__ */ y(
|
|
790
|
+
children: /* @__PURE__ */ y(z, {
|
|
791
791
|
boxes: i,
|
|
792
|
-
outliers: i.length > 0 ?
|
|
792
|
+
outliers: i.length > 0 ? pe(a, i, s.readBoxKey) : u,
|
|
793
793
|
mainAxis: r,
|
|
794
|
-
panelSize:
|
|
794
|
+
panelSize: n,
|
|
795
795
|
source: e,
|
|
796
|
-
styleReaders:
|
|
796
|
+
styleReaders: o,
|
|
797
797
|
keys: s,
|
|
798
798
|
hovered: t.observation
|
|
799
799
|
})
|
|
800
800
|
});
|
|
801
|
-
},
|
|
802
|
-
const { boxes: s, outliers: i } = S(() => I(e.data, t), [e.data, t]), u = /* @__PURE__ */ y(
|
|
801
|
+
}, mt = ({ layer: e, mainAxis: t, styleReaders: r, animateTransitions: o, intro: n }) => {
|
|
802
|
+
const a = F(), { boxes: s, outliers: i } = S(() => I(e.data, t), [e.data, t]), u = /* @__PURE__ */ y(z, {
|
|
803
803
|
boxes: s,
|
|
804
804
|
outliers: i,
|
|
805
805
|
mainAxis: t,
|
|
806
|
-
panelSize:
|
|
806
|
+
panelSize: a,
|
|
807
807
|
source: e,
|
|
808
|
-
styleReaders:
|
|
809
|
-
keys: S(() =>
|
|
810
|
-
animateTransitions:
|
|
808
|
+
styleReaders: r,
|
|
809
|
+
keys: S(() => X(e), [e]),
|
|
810
|
+
animateTransitions: o
|
|
811
811
|
});
|
|
812
|
-
return
|
|
812
|
+
return n == null ? u : /* @__PURE__ */ y(xe, {
|
|
813
813
|
intro: {
|
|
814
814
|
type: "fade",
|
|
815
|
-
layerId:
|
|
816
|
-
durationSeconds:
|
|
815
|
+
layerId: n.layerId,
|
|
816
|
+
durationSeconds: n.durationSeconds
|
|
817
817
|
},
|
|
818
818
|
children: u
|
|
819
819
|
});
|
|
820
|
-
},
|
|
820
|
+
}, yt = be(new Ze(), {
|
|
821
821
|
coord: "cartesian",
|
|
822
822
|
swatchShape: "square",
|
|
823
823
|
overpaintPlacement: "manual",
|
|
824
824
|
guideMode: "band",
|
|
825
|
-
render: ({ layer: e, coordSystem: t,
|
|
825
|
+
render: ({ layer: e, coordSystem: t, styleReaders: r, animateTransitions: o, intro: n }) => /* @__PURE__ */ y(mt, {
|
|
826
826
|
layer: e,
|
|
827
827
|
mainAxis: E(t),
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
intro: a
|
|
828
|
+
styleReaders: r,
|
|
829
|
+
animateTransitions: o,
|
|
830
|
+
intro: n
|
|
832
831
|
}),
|
|
833
|
-
renderHighlight: ({ layer: e, sourceLayer: t, coordSystem: r,
|
|
832
|
+
renderHighlight: ({ layer: e, sourceLayer: t, coordSystem: r, styleReaders: o }) => /* @__PURE__ */ y(dt, {
|
|
834
833
|
layer: e,
|
|
835
834
|
sourceLayer: t,
|
|
836
835
|
mainAxis: E(r),
|
|
837
|
-
|
|
838
|
-
styleReaders: n
|
|
836
|
+
styleReaders: o
|
|
839
837
|
}),
|
|
840
|
-
renderHover: ({ layer: e, primary: t, coordSystem: r,
|
|
838
|
+
renderHover: ({ layer: e, primary: t, coordSystem: r, styleReaders: o }) => /* @__PURE__ */ y(pt, {
|
|
841
839
|
layer: e,
|
|
842
840
|
primary: t,
|
|
843
841
|
mainAxis: E(r),
|
|
844
|
-
|
|
845
|
-
styleReaders: n
|
|
842
|
+
styleReaders: o
|
|
846
843
|
}),
|
|
847
|
-
|
|
848
|
-
getEditOutlineShapes: it
|
|
844
|
+
getEditOutlineShapes: ut
|
|
849
845
|
});
|
|
850
846
|
export {
|
|
851
847
|
k as BOXPLOT_VARIABLES,
|
|
852
|
-
|
|
853
|
-
|
|
848
|
+
Ze as BoxplotGeom,
|
|
849
|
+
yt as boxplot
|
|
854
850
|
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { GeomStyleReaders, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
-
import { PanelSize } from './utils/panel-path';
|
|
3
2
|
interface HighlightedBoxesProps {
|
|
4
3
|
layer: SceneLayer;
|
|
5
4
|
/** The whole layer the matched observations were taken from. */
|
|
6
5
|
sourceLayer: SceneLayer;
|
|
7
6
|
mainAxis: MainAxis;
|
|
8
|
-
panelSize: PanelSize;
|
|
9
7
|
styleReaders: GeomStyleReaders;
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
10
|
* Repaints the matched boxes and outliers above the dimmed layer. A matched box raises its outliers with it,
|
|
13
11
|
* so a highlight on a summary column (`boxplotQ3`, which an outlier does not carry) still shows the box whole.
|
|
14
12
|
*/
|
|
15
|
-
export declare const HighlightedBoxes: ({ layer, sourceLayer, mainAxis,
|
|
13
|
+
export declare const HighlightedBoxes: ({ layer, sourceLayer, mainAxis, styleReaders }: HighlightedBoxesProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
14
|
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { GeomStyleReaders, HoverHit, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
-
import { PanelSize } from './utils/panel-path';
|
|
3
2
|
interface HoveredBoxesProps {
|
|
4
3
|
layer: SceneLayer;
|
|
5
4
|
primary: HoverHit;
|
|
6
5
|
mainAxis: MainAxis;
|
|
7
|
-
panelSize: PanelSize;
|
|
8
6
|
styleReaders: GeomStyleReaders;
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
@@ -12,5 +10,5 @@ interface HoveredBoxesProps {
|
|
|
12
10
|
* dimmed layer. The engine groups a dodged box with the rest of its band, as it does a grouped bar, but the
|
|
13
11
|
* tooltip reads the one box's summary, or the one outlier's value, so only that is raised.
|
|
14
12
|
*/
|
|
15
|
-
export declare const HoveredBoxes: ({ layer, primary, mainAxis,
|
|
13
|
+
export declare const HoveredBoxes: ({ layer, primary, mainAxis, styleReaders }: HoveredBoxesProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
14
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { GeomStyleReaders, LayerIntroPlan, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
-
import { PanelSize } from './utils/panel-path';
|
|
3
2
|
interface BoxplotLayerProps {
|
|
4
3
|
layer: SceneLayer;
|
|
5
4
|
mainAxis: MainAxis;
|
|
6
|
-
panelSize: PanelSize;
|
|
7
5
|
styleReaders: GeomStyleReaders;
|
|
8
6
|
animateTransitions: boolean;
|
|
9
7
|
intro: LayerIntroPlan | null | undefined;
|
|
@@ -14,5 +12,5 @@ interface BoxplotLayerProps {
|
|
|
14
12
|
* the plan's clock instead. The fade is independent of `animateTransitions`: it rides the group rather
|
|
15
13
|
* than moving the marks, so it plays even when data changes snap.
|
|
16
14
|
*/
|
|
17
|
-
export declare const BoxplotLayer: ({ layer, mainAxis,
|
|
15
|
+
export declare const BoxplotLayer: ({ layer, mainAxis, styleReaders, animateTransitions, intro }: BoxplotLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
16
|
export {};
|
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.1793803805689",
|
|
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.1793803805689"
|
|
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.1793803805689",
|
|
47
48
|
"@graphytools/typescript-config": "0.0.1",
|
|
49
|
+
"@graphysdk/viz-engine": "1.9.0-beta.1793803805689",
|
|
48
50
|
"@graphytools/vitest-config": "1.0.0",
|
|
49
|
-
"@
|
|
50
|
-
"@graphytools/eslint-config": "0.0.1",
|
|
51
|
-
"@graphysdk/react": "1.9.0-beta.1793788324987"
|
|
51
|
+
"@graphytools/eslint-config": "0.0.1"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|