@wafertools/wafermap 0.35.1 → 0.37.0
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/AGENTS.md +13 -10
- package/CHANGELOG.md +474 -0
- package/README.md +7 -7
- package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
- package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
- package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
- package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
- package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
- package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
- package/dist/packages/canvas-adapter/charts/index.js +1 -1
- package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
- package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
- package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
- package/dist/packages/canvas-adapter/dieList.js +2 -2
- package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
- package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
- package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
- package/dist/packages/canvas-adapter/filterButton.js +1 -0
- package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
- package/dist/packages/canvas-adapter/filterEditor.js +1 -0
- package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
- package/dist/packages/canvas-adapter/guideWindow.js +1 -1
- package/dist/packages/canvas-adapter/icons.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +1 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +57 -2
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
- package/dist/packages/canvas-adapter/pageFilter.js +2 -0
- package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
- package/dist/packages/canvas-adapter/patMaps.js +1 -0
- package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
- package/dist/packages/canvas-adapter/plotCard.js +1 -0
- package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
- package/dist/packages/canvas-adapter/plotEditor.js +1 -1
- package/dist/packages/canvas-adapter/plotModal.js +1 -1
- package/dist/packages/canvas-adapter/plotStore.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +71 -37
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +22 -9
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
- package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
- package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +12 -6
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +607 -117
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/aggregates.d.ts +10 -0
- package/dist/packages/core/aggregates.js +1 -1
- package/dist/packages/core/classify.d.ts +11 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +5 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/dies.d.ts +2 -0
- package/dist/packages/core/dies.js +1 -1
- package/dist/packages/core/wafer.d.ts +10 -1
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +5 -0
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +21 -4
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/deprecate.d.ts +2 -8
- package/dist/packages/renderer/deprecate.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +10 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +1 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/renderer/testLabel.d.ts +0 -11
- package/dist/packages/renderer/testLabel.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +1 -1
- package/dist/packages/renderer/valueFilter.js +1 -1
- package/dist/packages/stats/analyzeWaferLot.d.ts +22 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +26 -1
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/binPareto.d.ts +2 -54
- package/dist/packages/stats/binPareto.js +1 -1
- package/dist/packages/stats/binRows.js +1 -1
- package/dist/packages/stats/capability.d.ts +10 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/cardSpec.d.ts +53 -0
- package/dist/packages/stats/cardSpec.js +1 -0
- package/dist/packages/stats/chartCatalogue.d.ts +37 -0
- package/dist/packages/stats/chartCatalogue.js +1 -0
- package/dist/packages/stats/clusterDetection.d.ts +9 -0
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/commonality.d.ts +62 -0
- package/dist/packages/stats/commonality.js +1 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/control.d.ts +21 -0
- package/dist/packages/stats/control.js +1 -0
- package/dist/packages/stats/correlation.d.ts +42 -4
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/dieRegions.d.ts +4 -1
- package/dist/packages/stats/dieRegions.js +1 -1
- package/dist/packages/stats/differenceMap.d.ts +22 -0
- package/dist/packages/stats/differenceMap.js +1 -0
- package/dist/packages/stats/examplePicks.d.ts +22 -0
- package/dist/packages/stats/examplePicks.js +1 -0
- package/dist/packages/stats/filterFile.d.ts +41 -0
- package/dist/packages/stats/filterFile.js +2 -0
- package/dist/packages/stats/filterFindings.d.ts +21 -6
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/findingText.d.ts +8 -0
- package/dist/packages/stats/findingText.js +2 -2
- package/dist/packages/stats/groupCompare.d.ts +87 -0
- package/dist/packages/stats/groupCompare.js +1 -0
- package/dist/packages/stats/guideSections.d.ts +55 -0
- package/dist/packages/stats/guideSections.js +1 -0
- package/dist/packages/stats/index.d.ts +5 -2
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotDrift.js +1 -1
- package/dist/packages/stats/math.d.ts +29 -4
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/mergeTestDefs.js +1 -1
- package/dist/packages/stats/metadataColumns.d.ts +3 -0
- package/dist/packages/stats/metadataColumns.js +1 -1
- package/dist/packages/stats/pat.d.ts +58 -0
- package/dist/packages/stats/pat.js +1 -0
- package/dist/packages/stats/patSummary.d.ts +45 -0
- package/dist/packages/stats/patSummary.js +1 -0
- package/dist/packages/stats/patternClassification.d.ts +3 -3
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +294 -17
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotId.d.ts +2 -0
- package/dist/packages/stats/plotId.js +1 -1
- package/dist/packages/stats/plotReferences.d.ts +17 -0
- package/dist/packages/stats/plotReferences.js +1 -0
- package/dist/packages/stats/plotSpec.d.ts +239 -3
- package/dist/packages/stats/plotSpec.js +4 -4
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +5 -12
- package/dist/packages/stats/reportHtml.js +98 -40
- package/dist/packages/stats/synthesis.d.ts +48 -16
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/testPassRate.d.ts +7 -0
- package/dist/packages/stats/testPassRate.js +1 -1
- package/dist/packages/stats/testValueBudget.d.ts +15 -0
- package/dist/packages/stats/testValueBudget.js +1 -0
- package/dist/packages/stats/types.d.ts +90 -30
- package/dist/packages/stats/yield.d.ts +3 -11
- package/dist/packages/stats/yield.js +1 -1
- package/llms.txt +1 -1
- package/package.json +2 -1
- package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
- package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
- package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
- package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
- package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
- package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
- package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
- package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
- package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
- package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
- package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
- package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
- package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
- package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
- package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
- package/dist/packages/canvas-adapter/charts/trend.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCapabilityData as
|
|
1
|
+
import{buildCapabilityData as De}from"../../stats/capability.js";import{capabilityColor as Z}from"./palette.js";import{LEADING as Ae,SPACE as C,fontPx as ie,FONT as se,CLR as F}from"../toolbar.js";import{cardShell as We,guideCite as Ne,isExpandedCard as Ie,chartFillHeight as Be,applyCanvasFlow as Oe,observeResize as Re,makeTooltip as He,positionChartTooltip as _e,renderEmptyState as je,resolveChartCanvasColors as Xe,chartSwatchCss as ze,prepareCanvas as Fe,chartDpr as Ue}from"./chartShell.js";import{GUIDE_SECTIONS as Ge}from"../../stats/guideSections.js";import{fmt as Ye}from"../../renderer/fmt.js";import{limitSetName as he}from"../../renderer/valueFilter.js";import{escHtml as ee}from"../../core/utils.js";import{DERIVED_MARK as ae,DERIVED_KEY as ue}from"../../renderer/testLabel.js";import{cardAbout as Ke}from"./cardAbout.js";function H($){return $==="spec"?{lo:"LSL",hi:"USL",noun:"spec limits"}:{lo:"Lo limit",hi:"Hi limit",noun:"test limits"}}function be($){let W;for(const G of $){if(!G.hasSpec)continue;const N=G.limitBasis??"test";if(W===void 0)W=N;else if(W!==N)return"mixed"}return W}const qe=30,xe=160,ye=90,ge=28,y=42;function U($){return $===null?"\u2014":$.toFixed(2)}export function renderCapabilityPanel($){const{title:W="Process capability",items:G,testDefs:N,onSaveImage:ve,onSelectTest:Y}=$;let te=$.selectedTestNumber??null;const{card:c,body:T,setAbout:Se}=We(W,ve,$.ownerDocument);Se(Ke("capability"));const Me=N.some(n=>n.testNumber!==void 0);T.style.overflowX="hidden";function $e(){return G}const I=c.ownerDocument.createElement("div");Object.assign(I.style,{display:"flex",flexDirection:"column",gap:C.xs,marginBottom:C.sm}),c.insertBefore(I,T);const B=He(c);let K=()=>{};function Le(n,i,m,s,p,a){I.innerHTML="";const f=c.ownerDocument.createElement("span");Object.assign(f.style,{display:"inline-flex",alignItems:"center",gap:C.sm,color:F.value,fontSize:se.body,fontWeight:"500"});const b=m-n,g=(i>0?` \xB7 ${i} without both limits`:"")+(a?` \xB7 ${a.total.toLocaleString("en-GB")} values outside ${he(a.limitSet)} excluded`:""),k=c.ownerDocument.createElement("span");k.dataset.wmapCaption="1",k.textContent=b>0?`${n} of ${m} tests shown${g} \xB7 ${b} excluded (no recorded values)`:`${n} test${n!==1?"s":""} shown${g}`,f.appendChild(k),I.appendChild(f);const q=i>=n,P=c.ownerDocument.createElement("div");P.dataset.wmapCaption="1",P.textContent=q?"No test has both limits, so each is normalised to its own observed range (min = 0, max = 1) and sorted most-variable first. Ppk needs limits, so none is shown.":(p==="mixed"?"Normalised to each test's spec limits (LSL = 0, USL = 1), or its test limits (Lo limit = 0, Hi limit = 1) where it has no spec limits, worst Ppk first. ":`Normalised to ${H(p).noun} (${H(p).lo} = 0, ${H(p).hi} = 1), worst Ppk first. `)+"Tests without both limits are normalised to their own observed range and drawn muted/dashed.",q||P.append(" ",Ne(c.ownerDocument,Ge.goal),"."),Object.assign(P.style,{color:F.label,fontSize:se.body,lineHeight:Ae.base,marginTop:C.xs,maxWidth:"78ch"}),I.appendChild(P),I.appendChild(Ce(c.ownerDocument,i>0,q,s>0))}function Ce(n,i,m=!1,s=!1){const p=n.createElement("div");Object.assign(p.style,{display:"flex",flexWrap:"wrap",alignItems:"center",gap:`${C.xs} ${C.xl}`,marginTop:C.xl,marginBottom:C.xs,fontSize:se.body,color:F.label});const a=m?[]:[{color:Z(2),label:"Capable \xB7 Ppk \u2265 1.33"},{color:Z(1.1),label:"Marginal \xB7 Ppk \u2265 1.0"},{color:Z(.5),label:"Poor \xB7 Ppk < 1.0"}];i&&a.push({color:F.label,label:"No limits \xB7 no Ppk",dashed:!0});for(const f of a){const b=n.createElement("span");Object.assign(b.style,{display:"inline-flex",alignItems:"center",gap:C.sm});const g=n.createElement("span");g.style.cssText=ze(f.color,f.dashed?"outline":"solid");const k=n.createElement("span");k.textContent=f.label,b.append(g,k),p.appendChild(b)}if(s){const f=n.createElement("span");Object.assign(f.style,{display:"inline-flex",alignItems:"center",gap:C.sm});const b=n.createElement("span");b.textContent=ae,Object.assign(b.style,{color:F.value,fontWeight:"600"});const g=n.createElement("span");g.textContent=ue,f.append(b,g),p.appendChild(f)}return p}function Te(n){if(T.innerHTML="",n.length===0)return je(T,"No parametric tests have any recorded values.",{maxWidth:"480px"}),()=>{};const i=c.ownerDocument.createElement("canvas");i.style.display="block",i.style.cursor="default",T.appendChild(i);let m=0;const s=c.ownerDocument.createElement("div");s.dataset.wmapColScroll="1",s.tabIndex=0,s.setAttribute("aria-label",`Scroll the ${n.length} tests`),Object.assign(s.style,{position:"absolute",display:"none",height:"12px",overflowX:"auto",overflowY:"hidden",zIndex:"1"});const p=c.ownerDocument.createElement("div");p.style.height="1px",s.appendChild(p),T.appendChild(s),s.addEventListener("scroll",()=>{Math.abs(s.scrollLeft-m)<1||(m=s.scrollLeft,B.style.display="none",Q())}),i.addEventListener("wheel",t=>{if(s.style.display==="none")return;const l=t.deltaX||(t.shiftKey?t.deltaY:0);if(!l)return;const o=s.scrollLeft;s.scrollLeft+=t.deltaMode===1?l*16:l,s.scrollLeft!==o&&t.preventDefault()},{passive:!1});const a=n.length,f=Math.min(0,...n.map(t=>t.min)),b=Math.max(1,...n.map(t=>t.max)),g=(b-f)*.05||.1,k=f-g,P=b+g-k||1;function re(t){const l=Math.floor(t/a);return Math.max(qe,Ie(c)?l:Math.min(xe,l))}function E(t,l,o){return l+(1-(t-k)/P)*o}function we(t,l,o,r,v){const S=n.filter(e=>e.hasSpec).length,V=S===n.length,d=S===0,O=be(n),w=O==="mixed"?{lo:"Lo",hi:"Hi",noun:"limits"}:H(O),R=d?"max":O==="spec"?w.hi:"Hi",M=d?"min":O==="spec"?w.lo:"Lo",J=V?`normalised to ${w.noun}`:d?"normalised to range":"normalised (per test)";t.font=`${ie(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle";for(const[e,x]of[[1,R],[0,M]]){const D=E(e,o,r);D<o-1||D>o+r+1||(t.strokeStyle=l.limitLine,t.lineWidth=1,t.beginPath(),t.moveTo(y-5,D),t.lineTo(y,D),t.stroke(),t.fillStyle=l.textMuted,t.fillText(x,y-8,D))}t.save(),t.translate(9,o+r/2),t.rotate(-Math.PI/2),t.textAlign="center",t.fillStyle=l.textMuted,t.fillText(J,0,0),t.restore()}let _=-1;function Q(){Oe(i);const t=T.clientWidth,l=re(t-y),o=l*a,r=Math.max(10,Math.min(o,t-y)),v=o>r+.5,S=v?14:0;m=v?Math.max(0,Math.min(m,o-r)):0;const V=r,d=ge,O=y+r,w=Be(c,T,i,ge+200+ye+S),R=Math.max(d+60,w-ye-S),M=R-d;s.style.display=v?"block":"none",v&&(Object.assign(s.style,{left:`${i.offsetLeft+y}px`,width:`${r}px`,top:`${i.offsetTop+w-13}px`}),p.style.width=`${o}px`,Math.abs(s.scrollLeft-m)>=1&&(s.scrollLeft=m));const J=Fe(i,c,O,w);if(!J)return;const{ctx:e}=J,x=Xe(c);e.save(),e.beginPath(),e.rect(y,0,r,w),e.clip();const D=Math.max(0,Math.floor(m/l)-1),Pe=Math.min(a,Math.ceil((m+r)/l)+1);n.forEach((h,j)=>{if(j<D||j>=Pe)return;const A=y+j*l-m,u=A+l/2,L=Math.max(4,Math.min(l,xe)*.55);if(j===_&&(e.fillStyle=x.bgHover,e.fillRect(A,d,l,R-d)),n[j].testNumber===te&&(e.fillStyle=x.accent,e.fillRect(A,R-2,l,2)),h.hasSpec){const pe=E(0,d,M),fe=E(1,d,M);e.strokeStyle=x.limitLine,e.setLineDash([3,3]),e.lineWidth=1,e.beginPath(),e.moveTo(A,pe),e.lineTo(A+l,pe),e.moveTo(A,fe),e.lineTo(A+l,fe),e.stroke(),e.setLineDash([])}const ne=h.hasSpec?Z(h.ppk):x.textMuted,oe=E(h.min,d,M),X=E(h.q1,d,M),de=E(h.median,d,M),z=E(h.q3,d,M),le=E(h.max,d,M);e.strokeStyle=x.textMuted,e.lineWidth=1,e.beginPath(),e.moveTo(u,oe),e.lineTo(u,X),e.moveTo(u,z),e.lineTo(u,le),e.moveTo(u-L/4,oe),e.lineTo(u+L/4,oe),e.moveTo(u-L/4,le),e.lineTo(u+L/4,le),e.stroke(),e.fillStyle=ne,e.globalAlpha=.5,e.fillRect(u-L/2,Math.min(X,z),L,Math.max(1,Math.abs(z-X))),e.globalAlpha=1,e.strokeStyle=ne,h.hasSpec||e.setLineDash([4,2]),e.strokeRect(u-L/2,Math.min(X,z),L,Math.max(1,Math.abs(z-X))),e.setLineDash([]),e.strokeStyle=x.text,e.lineWidth=2,e.beginPath(),e.moveTo(u-L/2,de),e.lineTo(u+L/2,de),e.stroke(),e.lineWidth=1,e.font=`${ie(-1)}px system-ui, sans-serif`,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=h.hasSpec?ne:x.textMuted,e.fillText(h.hasSpec?U(h.ppk):"\u2014",u,d-8);const me=h.label.length>12?`${h.label.slice(0,11)}\u2026`:h.label;e.save(),e.translate(u,R+6),e.rotate(-Math.PI/4),e.textAlign="right",e.textBaseline="middle",e.font=`${ie(-1)}px system-ui, sans-serif`,e.fillStyle=x.textMuted,e.fillText(me,0,0),h.derived&&(e.fillStyle=x.text,e.fillText(`${ae} `,-e.measureText(me).width,0)),e.restore()}),e.restore(),e.strokeStyle=x.border,e.lineWidth=1,e.strokeRect(y,d,V,M),we(e,x,d,M,V)}function ce(t){const l=i.getBoundingClientRect(),o=T.clientWidth,r=re(o-y),v=(t.clientX-l.left)*(i.width/Ue(i)/l.width)-y;if(v<0)return-1;const S=Math.floor((v+m)/r);return S>=0&&S<a?S:-1}return i.addEventListener("mousemove",t=>{const l=ce(t);if(l!==_&&(_=l,Q()),l===-1){B.style.display="none";return}const o=n[l],r=S=>ee(Ye(S,o.unit)),v=o.derived?`<em>${ae} ${ee(ue)}</em>`+(o.expression?`<br><code>${ee(o.expression)}</code>`:"")+"<br>":"";B.innerHTML=`<strong>${ee(o.label)}</strong> (n=${o.n}${o.excluded?`, ${o.excluded.count} outside ${he(o.excluded.limitSet)} excluded`:""})<br>${v}`+(o.hasSpec?`${H(o.limitBasis).lo} ${r(o.lsl)} \xB7 ${H(o.limitBasis).hi} ${r(o.usl)}<br>mean ${r(o.mean)}<br>Cp ${U(o.cp)} \xB7 Cpk ${U(o.cpk)}<br>Pp ${U(o.pp)} \xB7 Ppk ${U(o.ppk)}`:`<em>No limits \u2014 sorted by variability</em><br>mean ${r(o.mean)} \xB7 stddev ${r(o.stdOverall)}`)+(Y?"<br><em>click to view in boxplot</em>":""),B.style.display="block",_e(B,c,t.clientX,t.clientY),i.style.cursor=Y?"pointer":"default"}),i.addEventListener("mouseleave",()=>{_!==-1&&(_=-1,Q()),B.style.display="none"}),i.addEventListener("click",t=>{if(!Y)return;const l=ce(t);l!==-1&&Y(n[l].testNumber)}),Q}function ke(){const n=De($e(),N),i=N.filter(a=>a.testNumber!==void 0).length,m=n.filter(a=>!a.hasSpec).length,s=n.reduce((a,f)=>a+(f.excluded?.count??0),0),p=n.find(a=>a.excluded)?.excluded?.limitSet;Le(n.length,m,i,n.filter(a=>a.derived).length,be(n),s>0&&p?{total:s,limitSet:p}:void 0),K=Te(n),K()}const Ee=Re(c,()=>K());return ke(),{card:c,hasData:Me,setTest:n=>{te!==n&&(te=n,K())},destroy:()=>Ee.disconnect()}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PlotChart } from '../../stats/plotSpec.js';
|
|
2
|
+
import { type CardKind } from '../../stats/chartCatalogue.js';
|
|
3
|
+
export type { CardKind };
|
|
4
|
+
/** A card's About line, and what the card is, which names its menu row. */
|
|
5
|
+
export interface CardAboutLine {
|
|
6
|
+
text: string;
|
|
7
|
+
noun: 'chart' | 'table';
|
|
8
|
+
}
|
|
9
|
+
/** The About line of a plot: its built-in card's, or its chart type's for a reader's own plot. */
|
|
10
|
+
export declare function plotAbout(spec: {
|
|
11
|
+
id: string;
|
|
12
|
+
chart: PlotChart;
|
|
13
|
+
}): CardAboutLine;
|
|
14
|
+
/** The About line of a built-in card that is not a plot. */
|
|
15
|
+
export declare function cardAbout(kind: CardKind): CardAboutLine;
|
|
16
|
+
/** @internal Every line the table holds, for tests. */
|
|
17
|
+
export declare const ABOUT_LINES: {
|
|
18
|
+
cards: Record<string, string>;
|
|
19
|
+
charts: Record<"scatter" | "histogram" | "box" | "bar" | "line" | "sweep" | "probability" | "control" | "goal" | "heatmap", string>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=cardAbout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CHART_CATALOGUE as c}from"../../stats/chartCatalogue.js";const a={},n={},o={};for(const t of c){for(const r of t.cards??[])a[r]=t.about;t.card&&(n[t.card]=t.about),t.chart&&(o[t.chart]=t.about)}const s=new Set(c.flatMap(t=>t.kind==="table"&&t.card?[t.card]:[]));export function plotAbout(t){const r=t.id.startsWith("card-pass-rate-")?"card-pass-rate":t.id;return{text:a[r]??o[t.chart],noun:"chart"}}export function cardAbout(t){return{text:n[t],noun:s.has(t)?"table":"chart"}}export const ABOUT_LINES={cards:a,charts:o};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { type OverlayHandle, type SaveImageHandler } from '../toolbar.js';
|
|
2
|
+
import type { CardAboutLine } from './cardAbout.js';
|
|
3
|
+
import type { GuideSection } from '../../stats/guideSections.js';
|
|
2
4
|
import { robustFence } from '../../stats/math.js';
|
|
3
5
|
export type { SaveImageHandler };
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (found via exactly that — every card kept its expand icon once expanded).
|
|
10
|
-
* The button is found on the card (`data-wmap-chart-expand`) rather than
|
|
11
|
-
* passed in, so a card opened straight into a modal by something other than
|
|
12
|
-
* its own button — a drilldown — gets the same treatment.
|
|
7
|
+
* Opens a card in its own resizable window. While it is there (`data-wmap-expanded`) the card's Expand button is
|
|
8
|
+
* hidden: expanding a card already in its window would reparent it into a second, nested window and leave the first
|
|
9
|
+
* one empty. The flag is on the card, so a card opened straight into a window by something other than its own button
|
|
10
|
+
* (a drilldown) gets the same treatment.
|
|
13
11
|
*
|
|
14
12
|
* `opts.anchor` is for a card that is not on the page yet (see
|
|
15
13
|
* `ReparentModalOptions.anchor`); `opts.onClosed` runs once the modal has
|
|
@@ -44,6 +42,8 @@ export interface ChartCanvasColors {
|
|
|
44
42
|
* limit line and its label need.
|
|
45
43
|
*/
|
|
46
44
|
limitLine: string;
|
|
45
|
+
/** A point that breaks a rule (a control chart's out-of-control wafer): the theme's error text colour, readable on a panel. */
|
|
46
|
+
alert: string;
|
|
47
47
|
/**
|
|
48
48
|
* Gridlines: `border` at `GRID_ALPHA`. A gridline is a reading aid behind the
|
|
49
49
|
* data; drawn at full `border` strength (the axis colour) it competed with the
|
|
@@ -289,6 +289,23 @@ export interface CardShell {
|
|
|
289
289
|
body: HTMLElement;
|
|
290
290
|
/** What the card's Save as PNG adds under the title, besides the canvas (a caption, a legend). Read at the moment of saving. */
|
|
291
291
|
setPngDecor(read: () => PngDecor | undefined): void;
|
|
292
|
+
/** The canvas Save as PNG saves, made at the moment of saving, for a card that draws more than one (a grid of panels).
|
|
293
|
+
* Absent = the card's first canvas. */
|
|
294
|
+
setPngCanvas(make: () => HTMLCanvasElement | null): void;
|
|
295
|
+
/** The one line "About this chart" (or "About this table") shows (`cardAbout`). Absent = the menu has no About row. */
|
|
296
|
+
setAbout(line: CardAboutLine | undefined): void;
|
|
297
|
+
/** Rows of the card's own in its ⋯ menu, after Save as PNG (Edit as plot). Read each time the menu opens. */
|
|
298
|
+
setMenuRows(read: () => CardMenuRow[]): void;
|
|
299
|
+
}
|
|
300
|
+
/** A row of a card's own in its ⋯ menu: an action, or one greyed with the reason it cannot run now. */
|
|
301
|
+
export interface CardMenuRow {
|
|
302
|
+
label: string;
|
|
303
|
+
onClick: () => void;
|
|
304
|
+
disabledHint?: string;
|
|
305
|
+
}
|
|
306
|
+
export interface CardShellOptions {
|
|
307
|
+
/** Default true. False for a card whose image is saved by something else (a panel of a grid, saved with the grid). */
|
|
308
|
+
png?: boolean;
|
|
292
309
|
}
|
|
293
310
|
/**
|
|
294
311
|
* THE colour chip that stands for a data series, everywhere in the chart suite.
|
|
@@ -342,13 +359,36 @@ export interface SeriesLegendItem {
|
|
|
342
359
|
*/
|
|
343
360
|
export declare function makeSeriesLegendItem(label: string, color: string, ownerDocument?: Document): SeriesLegendItem;
|
|
344
361
|
export declare function cardFrameStyle(): Partial<CSSStyleDeclaration>;
|
|
345
|
-
export declare function cardShell(title: string, onSaveImage?: SaveImageHandler, ownerDocument?: Document): CardShell;
|
|
362
|
+
export declare function cardShell(title: string, onSaveImage?: SaveImageHandler, ownerDocument?: Document, opts?: CardShellOptions): CardShell;
|
|
363
|
+
/**
|
|
364
|
+
* "How to read this: *Control charts* in the user guide" (no full stop), the title a link that opens the guide at that
|
|
365
|
+
* section, beside the app (a separate window where the platform allows one, otherwise a floating window over it); an
|
|
366
|
+
* open guide moves there. A saved image or print carries `guideCiteText` instead.
|
|
367
|
+
*/
|
|
368
|
+
export declare function guideCite(doc: Document, section: GuideSection, lead?: string): HTMLSpanElement;
|
|
369
|
+
/** A footnote's "how to read this: *A* and *B* in the user guide", each title a link (`guideCite`). Nothing for none. */
|
|
370
|
+
export declare function appendGuideCites(el: HTMLElement, sections: readonly GuideSection[]): void;
|
|
371
|
+
/** A text box's look in an editor: the one style the plot, sweep and filter editors' boxes share. */
|
|
372
|
+
export declare function inputStyle(): Partial<CSSStyleDeclaration>;
|
|
346
373
|
export declare function makeSegmented(
|
|
347
374
|
/** An option's optional third element is its hover hint, for a label that does not explain itself. */
|
|
348
375
|
options: Array<[value: string, label: string, hint?: string]>, current: string, onChange: (value: string) => void, ownerDocument?: Document,
|
|
349
376
|
/** Smaller type/padding for the summary panel's 260px column, where the
|
|
350
377
|
* chart-card sizing overflows a section header. Charts keep the default. */
|
|
351
378
|
compact?: boolean): HTMLElement;
|
|
379
|
+
/**
|
|
380
|
+
* A table that lists its first `first` rows, with a button to list every one and back. Listed in full it scrolls inside
|
|
381
|
+
* `scroller` after `ALL_ROWS_MAX_PX`, so a lot of a hundred wafers is a scrolling table in a card of the usual size,
|
|
382
|
+
* never a card as tall as all its rows (which also stretches every card beside it in the grid). `fill(all)` writes the
|
|
383
|
+
* rows; the button is returned for the caller to place under the table. No button shows when every row fits the first.
|
|
384
|
+
*/
|
|
385
|
+
export declare function firstRowsToggle(doc: Document, o: {
|
|
386
|
+
total: number;
|
|
387
|
+
first: number;
|
|
388
|
+
noun: string;
|
|
389
|
+
scroller: HTMLElement;
|
|
390
|
+
fill: (all: boolean) => void;
|
|
391
|
+
}): HTMLButtonElement;
|
|
352
392
|
export declare function makeBackButton(onBack: () => void, ownerDocument?: Document): HTMLButtonElement;
|
|
353
393
|
export declare function renderEmptyState(body: HTMLElement, message: string, styleOverrides?: Partial<CSSStyleDeclaration>): void;
|
|
354
394
|
export interface ListSelectOption {
|
|
@@ -563,7 +603,11 @@ export interface AxisPrefs {
|
|
|
563
603
|
/** Which limits the charts draw. Undefined = `'both'`. */
|
|
564
604
|
limits?: LimitsShown;
|
|
565
605
|
}
|
|
566
|
-
|
|
606
|
+
/**
|
|
607
|
+
* `pat`: one wafer's part-average-testing limits (stats/pat.ts), drawn only on a plot of that wafer; `whatif`: proposed limits
|
|
608
|
+
* for a histogram or probability plot; `ref`: a line or band the reader put on the axis.
|
|
609
|
+
*/
|
|
610
|
+
export type LimitKind = 'test' | 'spec' | 'pat' | 'whatif' | 'ref';
|
|
567
611
|
/** The Insights "Limits" choice. */
|
|
568
612
|
export type LimitsShown = 'test' | 'spec' | 'both' | 'none';
|
|
569
613
|
export interface LimitLine {
|
|
@@ -572,12 +616,14 @@ export interface LimitLine {
|
|
|
572
616
|
/** Which end of its pair: the low limit or the high one. */
|
|
573
617
|
end: 'lo' | 'hi';
|
|
574
618
|
label: string;
|
|
619
|
+
/** A reference band: the other edge, shaded between it and `value`. Set on the band's lower line only. */
|
|
620
|
+
bandTo?: number;
|
|
575
621
|
}
|
|
576
622
|
export declare const LIMIT_LABEL: Readonly<Record<LimitKind, {
|
|
577
623
|
lo: string;
|
|
578
624
|
hi: string;
|
|
579
625
|
}>>;
|
|
580
|
-
/** Canvas dash pattern per kind: short dashes for test limits, long for spec. */
|
|
626
|
+
/** Canvas dash pattern per kind: short dashes for test limits, long for spec, dots for PAT. */
|
|
581
627
|
export declare const LIMIT_DASH: Readonly<Record<LimitKind, number[]>>;
|
|
582
628
|
export declare const LIMITS_SHOWN_OPTIONS: ReadonlyArray<{
|
|
583
629
|
value: LimitsShown;
|
|
@@ -588,6 +634,10 @@ type LimitSource = {
|
|
|
588
634
|
limitHigh?: number;
|
|
589
635
|
specLow?: number;
|
|
590
636
|
specHigh?: number;
|
|
637
|
+
patLow?: number;
|
|
638
|
+
patHigh?: number;
|
|
639
|
+
whatIfLow?: number;
|
|
640
|
+
whatIfHigh?: number;
|
|
591
641
|
} | undefined;
|
|
592
642
|
/** Whether a test has both kinds of limit — the only case with a choice to make. */
|
|
593
643
|
export declare function hasBothLimitKinds(def: LimitSource): boolean;
|
|
@@ -720,5 +770,8 @@ export declare function drawOffAxisLimits(ctx: CanvasRenderingContext2D, offAxis
|
|
|
720
770
|
}, orient: 'horizontal' | 'vertical', color: string, format: (v: number) => string,
|
|
721
771
|
/** Panel colour to back each marker with (`fillTextOnHalo`), for charts
|
|
722
772
|
* where lines can run under the markers. */
|
|
723
|
-
halo?: string
|
|
773
|
+
halo?: string,
|
|
774
|
+
/** Labels already on the plot (the other axis's limits): each marker steps inward clear of them, and is added, so a
|
|
775
|
+
* label placed after it keeps clear of it too. */
|
|
776
|
+
taken?: LabelBox[]): void;
|
|
724
777
|
//# sourceMappingURL=chartShell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SHADOW as V,LEADING as G,wireTooltip as U,wireControlHover as B,controlStyle as j,SPACE as w,RADIUS as T,fontPx as F,FONT as L,CLR as m,Z_BASE as ie,menuLayerFor as re,wireListNavigation as le,MENU_SEARCH_THRESHOLD as X,makeMenuSearchBox as se,markMenuTrigger as N,markNoPrint as P,saveImageBlob as ae,openReparentedModal as ce}from"../toolbar.js";import{ICONS as K}from"../icons.js";import{minOf as de,maxOf as ue}from"../../core/utils.js";import{robustFence as Y}from"../../stats/math.js";import{fmt as pe,fmtColorbarAxis as fe}from"../../renderer/fmt.js";import{markedTestLabel as me,DERIVED_LANE_PAD as he}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,n={}){for(const s of e.querySelectorAll('div[style*="position: absolute"]'))s.style.display==="block"&&s.style.pointerEvents==="none"&&(s.style.display="none");const t=e.querySelector("[data-wmap-chart-expand]"),i=e.getAttribute("style")??"",r=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const l=ce([e],{title:o,anchor:n.anchor,ownerDocument:e.ownerDocument,boxSize:xe[r],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),t&&(t.style.display="flex"),n.onClosed?.()}});if(!l)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),null;if(t&&(t.style.display="none"),r==="rows"){const s=()=>{const a=Number(e.dataset.wmapChartFullH);if(!a)return;const p=l.box.offsetHeight-l.contentWrap.clientHeight;l.setNaturalHeight(`min(90vh, ${Math.ceil(p+a)}px)`)};s(),(e.ownerDocument.defaultView??window).requestAnimationFrame(s)}return l}const xe={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,o){const n=e.trim();let t,i,r,l=1;const s=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=n.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const p=s[1].length===3?s[1].split("").map(c=>c+c).join(""):s[1];[t,i,r]=[0,2,4].map(c=>parseInt(p.slice(c,c+2),16)),p.length===8&&(l=parseInt(p.slice(6,8),16)/255)}else if(a)[t,i,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${t}, ${i}, ${r}, ${+(l*o).toFixed(3)})`}const ge={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309"},Z={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),n={};for(const t of Object.keys(Z)){const i=o.getPropertyValue(`--wmap-${Z[t]}`).trim();n[t]=i||ge[t]}return n.grid=withAlpha(n.border,GRID_ALPHA),n}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const n=e.ownerDocument.defaultView??window;let t=0;const i=new n.ResizeObserver(()=>{t||(t=n.requestAnimationFrame(()=>{t=0,o()}))});return i.observe(e),{disconnect:()=>{t&&n.cancelAnimationFrame(t),t=0,i.disconnect()}}}export function growCardToFitContent(e,o,n){const t=`${W(e,o)+n}px`;e.style.minHeight!==t&&(e.style.minHeight=t)}function W(e,o){const n=e.ownerDocument.defaultView??window,t=n.getComputedStyle(e);let i=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=n.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(i+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return t.boxSizing==="border-box"&&(i+=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)+(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0)),i}function J(e,o){const n=e.ownerDocument.defaultView??window;let t=0;for(const i of Array.from(e.children)){if(i===o)continue;const r=i,l=n.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(t+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return t}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,n){const t=e.toLocaleString(),i=e===1?"die":"dies";return n?e===o?`${t} ${i} ${n}`:`${t} of ${o.toLocaleString()} dies ${n} (partial and edge-excluded dies left out)`:`${t} ${i}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,n){const i=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(i.paddingTop)||0)-(parseFloat(i.paddingBottom)||0),l=i.boxSizing==="border-box"?(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0):0;return r-(W(e,o)-l)-(n?J(o,n):0)}export function fitRowsHeight(e,o,n,t,i=0){if(growCardToFitContent(e,o,i+n),e.dataset.wmapChartFullH=String(Math.ceil(W(e,o)+i+t)),!isExpandedCard(e))return n;const r=bodyRoom(e,o)-i;return Math.max(n,Math.min(t,Math.floor(r)))}export function chartFillHeight(e,o,n,t){const i=J(o,n);return growCardToFitContent(e,o,i+t),Math.max(t,o.clientHeight-i)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,n,t){const i=chartDpr(e);e.width=Math.max(1,Math.floor(n*i)),e.height=Math.max(1,Math.floor(t*i)),e.style.width=`${n}px`,e.style.height=`${t}px`;const r=e.getContext("2d");return r?(r.setTransform(i,0,0,i,0,0),r.clearRect(0,0,n,t),r.font=`${F(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let n;if(typeof o=="number")n=o;else{const t=(o.ownerDocument.defaultView??window).getComputedStyle(o);n=o.offsetTop+o.offsetHeight+(parseFloat(t.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${n}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:pe(e,void 0,"engineering"):"\u2014"}export function makeAxisFormat(e,o,n){if(!o&&n===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const{tickFmt:t,axisLabel:i,scaledUnit:r}=fe(e,null,o,"engineering",n);return{tick:t,tickWithUnit:r?l=>`${t(l)} ${r}`:t,unitLabel:i}}const be=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,n){return(t,i)=>{const r=makeAxisFormat(o,n,t).tick;return i.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+be}}export function drawAxisUnit(e,o,n,t,i){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${F(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=i,e.fillText(`(${o})`,n,t),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(o=>o.replace(/[\s·]+$/,"").trim()).filter(o=>o&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(o)&&!/\(.*(click|drag).*\)/i.test(o)).join(" \xB7 ")}const M=(e,o)=>{for(let n=e;n&&n!==o.parentElement;n=n.parentElement)if(n.style.display==="none")return!1;return!0},ye=/\s*[▾▼]\s*$/,_=new WeakMap;export function describeCard(e){const o=[],n=e.querySelector("[data-wmap-controls]");if(n){for(const l of n.querySelectorAll("button[aria-haspopup]")){if(!M(l,n))continue;const s=(l.textContent??"").replace(ye,"").trim();if(!s)continue;const a=l.closest("label"),c=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(c&&c!==s?`${c}: ${s}`:s)}for(const l of n.querySelectorAll('[role="radiogroup"]')){if(!M(l,n))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of n.querySelectorAll('input[type="checkbox"]:checked')){if(!M(l,n))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const t=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!M(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&t.push(s)}const i=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&i.push({label:p,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&i.push({label:p,color:a})}const r=_.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(t.length=0,t.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(i.length=0,i.push(...r.legend))),{controls:o,captions:t,legend:i}}function we(e){const o=describeCard(e),n=_.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:n?.colorbar}}function Q(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const n=o.querySelector(":scope > [data-wmap-print-only]");if(!n)continue;const t=describeCard(o);n.replaceChildren();const i=[t.controls.length?t.controls.join(" \xB7 "):"",...t.captions].filter(Boolean);for(const r of i){const l=e.createElement("div");l.textContent=r,n.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ee=new WeakSet;function Ce(e){if(ee.has(e))return;ee.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const n=e.defaultView;n?.addEventListener("beforeprint",()=>Q(e));try{n?.matchMedia?.("print").addEventListener?.("change",t=>{t.matches&&Q(e)})}catch{}}function Se(e){const o=e.ownerDocument.defaultView;for(let n=e;n&&o;n=n.parentElement){const t=o.getComputedStyle(n).backgroundColor;if(t&&t!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(t))return t}return"#ffffff"}export function composeChartPng(e,o){const n=e.ownerDocument,t=n.createElement("canvas"),i=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=n.createElement("canvas").getContext("2d"),s=12*i,a=(f,y="400")=>`${y} ${f*i}px system-ui, -apple-system, "Segoe UI", sans-serif`,p=(f,y)=>l?(l.font=y,l.measureText(f).width):f.length*7*i,c=[];let d=0;if(o){d=s,c.push({kind:"text",text:o.title,x:s,y:d+14*i,font:a(16,"600"),alpha:1}),d+=24*i;const f=o.decor,y=[];f?.controls?.length&&y.push({text:f.controls.join(" \xB7 "),alpha:1});for(const h of f?.caption===void 0?[]:typeof f.caption=="string"?[f.caption]:f.caption)y.push({text:h,alpha:.75});const g=a(12);for(const{text:h,alpha:C}of y){let b="";for(const E of h.split(" ")){const O=b?`${b} ${E}`:E;b&&p(O,g)>r-2*s?(c.push({kind:"text",text:b,x:s,y:d+11*i,font:g,alpha:C}),d+=17*i,b=E):b=O}b&&(c.push({kind:"text",text:b,x:s,y:d+11*i,font:g,alpha:C}),d+=17*i)}if(f?.legend?.length){d+=4*i;const h=a(12);let C=s;for(const b of f.legend){const E=14*i+p(b.label,h)+14*i;C>s&&C+E>r-s&&(C=s,d+=18*i),c.push({kind:"dot",x:C+5*i,y:d+7*i,r:5*i,color:b.color}),c.push({kind:"text",text:b.label,x:C+14*i,y:d+11*i,font:h,alpha:1}),C+=E}d+=20*i}if(f?.colorbar){d+=4*i;const h=a(12),C=f.colorbar;let b=s;c.push({kind:"text",text:C.label,x:b,y:d+10*i,font:h,alpha:1}),b+=p(C.label,h)+10*i,c.push({kind:"text",text:C.lo,x:b,y:d+10*i,font:h,alpha:.75}),b+=p(C.lo,h)+6*i,c.push({kind:"strip",x:b,y:d+1*i,w:200*i,h:10*i,color:C.color}),b+=206*i,c.push({kind:"text",text:C.hi,x:b,y:d+10*i,font:h,alpha:.75}),d+=20*i}d+=6*i}t.width=r,t.height=Math.ceil(e.height+d);const u=t.getContext("2d");if(u.fillStyle=o?Se(o.card):"#ffffff",u.fillRect(0,0,t.width,t.height),o){const f=n.defaultView,y=f&&f.getComputedStyle(o.card).color||"#222222";u.textBaseline="alphabetic";for(const g of c)if(g.kind==="text")u.font=g.font,u.fillStyle=y,u.globalAlpha=g.alpha,u.fillText(g.text,g.x,g.y),u.globalAlpha=1;else if(g.kind==="dot")u.fillStyle=g.color,u.beginPath(),u.arc(g.x,g.y,g.r,0,Math.PI*2),u.fill();else for(let h=0;h<g.w;h++)u.fillStyle=g.color(h/Math.max(1,g.w-1)),u.fillRect(g.x+h,g.y,1,g.h)}return u.drawImage(e,0,d),t}export function saveCanvasPng(e,o,n,t){composeChartPng(e,t).toBlob(i=>{i&&ae(i,o,n)},"image/png")}const te="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${te}`,`height:${te}`,`border-radius:${T.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const ve="0.35";export function makeSeriesLegendItem(e,o,n=document){const t=n.createElement("button");t.type="button",Object.assign(t.style,{display:"inline-flex",alignItems:"center",gap:w.xs,padding:`${w.xs} ${w.md}`,borderRadius:T.pill,border:`1px solid ${m.menuBorder}`,background:"none",cursor:"pointer",fontSize:L.body,color:m.text,whiteSpace:"nowrap"}),B(t,"bare");const i=n.createElement("span");return i.style.cssText=chartSwatchCss(o),t.append(i,n.createTextNode(e)),{el:t,setState({selected:r,dimmed:l}){t.style.borderColor=r?m.iconActive:m.menuBorder,t.style.fontWeight=r?"600":"400",t.style.opacity=l?ve:"1",t.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:m.menuBg,border:`1px solid ${m.menuBorder}`,borderRadius:T.container,padding:w.xl,fontVariantNumeric:"tabular-nums"}}export function cardShell(e,o,n=document){const t=n.createElement("div");t.dataset.wmapChartCard="1",t.dataset.wmapChartTitle=e,Object.assign(t.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const i=t.ownerDocument.createElement("div");Object.assign(i.style,{display:"flex",alignItems:"center",gap:w.sm,paddingBottom:"6px",marginBottom:w.md,borderBottom:`1px solid ${m.menuBorder}`});const r=t.ownerDocument.createElement("div");r.textContent=e,Object.assign(r.style,{color:m.value,fontSize:L.heading,fontWeight:"600",flex:"1"}),i.appendChild(r);const l=makeTooltip(t),s=t.ownerDocument.createElement("button");s.type="button",s.setAttribute("aria-label","Save as PNG"),s.innerHTML=K.download,Object.assign(s.style,{...j("outlined"),color:m.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(s),attachChartTip(s,t,l,"Save as PNG"),s.addEventListener("click",()=>{const u=t.querySelector("canvas");u&&saveCanvasPng(u,r.textContent||e,o,{card:t,title:r.textContent||e,decor:we(t)})}),P(s),i.appendChild(s);const a=t.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=K.expand,Object.assign(a.style,{...j("outlined"),color:m.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(a),attachChartTip(a,t,l,"Expand"),a.dataset.wmapChartExpand="1",a.addEventListener("click",()=>openChartExpandModal(t,r.textContent??e)),P(a),i.appendChild(a),t.appendChild(i);const p=t.ownerDocument.createElement("div");p.dataset.wmapPrintOnly="1",Object.assign(p.style,{display:"none",color:m.label,fontSize:L.body,marginBottom:w.sm}),t.appendChild(p),Ce(t.ownerDocument);const c=t.ownerDocument.createElement("div");c.dataset.wmapControls="1",Object.assign(c.style,{display:"flex",gap:w.sm,marginBottom:w.md,flexWrap:"wrap",alignItems:"center"}),P(c),t.appendChild(c);const d=t.ownerDocument.createElement("div");return Object.assign(d.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),t.appendChild(d),{card:t,heading:r,controlsRow:c,body:d,setPngDecor:u=>{_.set(t,u)}}}export function makeSegmented(e,o,n,t=document,i=!1){const r=t.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",border:`1px solid ${m.menuBorder}`,borderRadius:T.control,overflow:"hidden"});const l=`seg-${Math.random().toString(36).slice(2,9)}`,s=[];return e.forEach(([a,p,c],d)=>{const u=t.createElement("label");c&&U(u,c),Object.assign(u.style,{display:"inline-flex",alignItems:"center",fontSize:L.body,padding:i?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",borderLeft:d>0?`1px solid ${m.menuBorder}`:"none"}),B(u,"bare");const f=t.createElement("input");f.type="radio",f.name=l,f.value=a,f.checked=a===o,Object.assign(f.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const y=()=>{u.style.background=f.checked?m.bgActive:m.menuBg,u.style.color=f.checked?m.iconActive:m.text,u.dataset.on=f.checked?"true":"false"};s.push(y),y(),f.addEventListener("change",()=>{if(f.checked){for(const g of s)g();n(a)}}),u.append(f,t.createTextNode(p)),r.appendChild(u)}),r}export function makeBackButton(e,o=document){const n=o.createElement("button");return n.type="button",n.textContent="\u2190 Back",Object.assign(n.style,{...j("outlined"),background:m.menuBg,color:m.label}),B(n),n.addEventListener("click",e),n}export function renderEmptyState(e,o,n){const t=e.ownerDocument.createElement("div");t.textContent=o,Object.assign(t.style,{color:m.label,fontSize:L.body,padding:"8px 0"}),n&&Object.assign(t.style,n),e.appendChild(t)}export function makeListSelect(e,o,n,t={}){const{maxWidth:i="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:p}=t;let c=o;const d=k=>e.find(D=>D.value===k)?.label??"",u=r.createElement("button");u.type="button",p&&(u.dataset.wmapSelect=p),l&&u.setAttribute("aria-label",l),Object.assign(u.style,{fontSize:L.body,padding:`${w.xxs} ${w.sm}`,background:m.menuBg,color:m.text,border:`1px solid ${m.menuBorder}`,borderRadius:T.control,maxWidth:i,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:w.sm,justifyContent:"space-between"}),B(u),N(u,!1);const f=r.createElement("span");Object.assign(f.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const y=r.createElement("span");y.textContent="\u25BE",y.style.flex="0 0 auto",u.append(f,y);const g=()=>{f.textContent=e.length===0?s??"(none)":d(c)||s||"(none)"};if(g(),e.length===0)return u.disabled=!0,u.style.opacity="0.6",u.style.cursor="default",Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,g()}});let h=null;const C=()=>{h&&(h.remove(),h=null,N(u,!1))},b=()=>{C(),u.focus()};function E(){const k=u.getBoundingClientRect(),D=r.defaultView??window,z=Math.max(k.width,220),ne=Math.min(k.left,Math.max(4,(D.innerWidth??1/0)-z-4));h=r.createElement("div"),h.setAttribute("role","listbox"),h.setAttribute("aria-label",l??"Options"),Object.assign(h.style,{position:"fixed",top:`${k.bottom+4}px`,left:`${ne}px`,background:m.menuBg,border:`1px solid ${m.menuBorder}`,borderRadius:T.control,boxShadow:V.menu,zIndex:ie,minWidth:`${z}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const A=[],H=()=>A.filter(x=>x.row.style.display!=="none").map(x=>x.row),I=[],oe=()=>{for(const x of I)x.el.style.display=A.slice(x.first,x.last+1).some(S=>S.row.style.display!=="none")?"":"none"};if(e.length>X){const x=se(S=>{for(const v of A)v.row.style.display=v.label.includes(S)?"":"none";oe()},a,r);Object.assign(x.style,{position:"sticky",top:"0",zIndex:"1",background:m.menuBg}),x.addEventListener("keydown",S=>{if(S.key==="Escape"){S.preventDefault(),b();return}S.key==="ArrowDown"&&(S.preventDefault(),H()[0]?.focus())}),h.appendChild(x)}let q;for(const x of e){if(x.group!==void 0&&x.group!==q){const $=r.createElement("div");$.textContent=x.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${w.sm} ${w.xl} ${w.xxs}`,fontSize:L.sub,color:m.label,fontWeight:"600"}),h.appendChild($),I.push({el:$,first:A.length,last:A.length})}q=x.group;const S=x.value===c,v=r.createElement("div");v.textContent=x.disabled?`${x.label} \u2014 ${x.disabled}`:x.label,v.setAttribute("role","option"),v.setAttribute("aria-selected",S?"true":"false"),x.disabled&&v.setAttribute("aria-disabled","true"),v.tabIndex=-1,Object.assign(v.style,{padding:`${w.sm} ${w.xl}`,fontSize:L.body,cursor:x.disabled?"default":"pointer",color:x.disabled?m.label:S?m.iconActive:m.text,fontWeight:S?"700":"400",opacity:x.disabled?"0.7":"",background:S?m.menuActive:"transparent",whiteSpace:"nowrap"}),v.addEventListener("mouseenter",()=>{!S&&!x.disabled&&(v.style.background=m.menuHover)}),v.addEventListener("mouseleave",()=>{S||(v.style.background="transparent")}),v.addEventListener("click",$=>{$.stopPropagation(),!x.disabled&&(c=x.value,g(),b(),n(x.value))}),h.appendChild(v),A.push({row:v,label:x.label.toLowerCase()}),I.length&&(I[I.length-1].last=A.length-1)}if(le(h,H,b),re(u).appendChild(h),N(u,!0),e.length<=X){const x=e.findIndex(S=>S.value===c);H()[x>=0?x:0]?.focus()}}u.addEventListener("click",k=>{if(k.stopPropagation(),h){C();return}E()});const O=k=>{if(!u.isConnected){r.removeEventListener("click",O);return}h&&!h.contains(k.target)&&!u.contains(k.target)&&C()};return r.addEventListener("click",O),Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,g()}})}export function testOptionLabels(e){const o=e.some(n=>n.derived);return e.map(n=>(o&&!n.derived?he:"")+me(n,n.testNumber))}export function makeTestSelect(e,o,n,t={}){const{maxWidth:i="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=t;return makeListSelect(testOptionLabels(e).map((s,a)=>({value:String(e[a].testNumber),label:s})),o!==null?String(o):"",s=>n(Number(s)),{maxWidth:i,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,n,t=document){let i=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>n({includeLimits:i,clipOutliers:r,limits:l});return{get:()=>({includeLimits:i,clipOutliers:r,limits:l}),sync(a,p,c=!1){e.innerHTML="",c&&e.appendChild(makeLimitsSelect(l,d=>{l=d,s()},t)),p&&e.appendChild(makeToggle("Axis includes limits",a,d=>{i=d,s()},t,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,d=>{r=d,s()},t,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const p=a.limits??"both";return a.includeLimits===i&&a.clipOutliers===r&&p===l?!1:(i=a.includeLimits,r=a.clipOutliers,l=p,!0)}}}export function makeLinkedTestSelect(e,o,n,t={}){let i=o;const r=makeTestSelect(e,i,l=>{l!==i&&(i=l,n(l))},t);return{el:r,get:()=>i,set(l){return i===l||!e.some(s=>s.testNumber===l)?!1:(i=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,n,t,i={}){let r=n;const l=c=>c??ALL_GROUPS,s=c=>c===ALL_GROUPS?null:c,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(c=>({value:c,label:c}))],l(r),c=>{const d=s(c);d!==r&&(r=d,t(d))},{...i,hook:"group-scope"}),p=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(c){return r===c||c!==null&&!e.includes(c)?!1:(r=c,p&&(p.value=l(c)),!0)}}}export function makeWaferSelect(e,o,n,t={}){const{maxWidth:i="160px",allLabel:r="All wafers",ownerDocument:l=document}=t,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,p)=>({value:String(p),label:a.label??`#${p}`}))],o===null?s:String(o),a=>n(a===s?null:Number(a)),{maxWidth:i,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,n,t=document,i){const r=t.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:w.xs,fontSize:L.body,color:m.label,cursor:"pointer",userSelect:"none"}),B(r,"bare");const l=t.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>n(l.checked)),r.append(l,t.createTextNode(e)),i&&U(r,i),r}export function makeLabeledSelect(e,o,n,t,i={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document}=i,a=s.createElement("label");a.textContent=e,Object.assign(a.style,{color:m.label,fontSize:L.body,display:"flex",alignItems:"center",gap:w.xs});const p=makeListSelect(o,n,t,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return a.appendChild(p),a}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:w.lg,flex:"0 0 auto"}),o}export function makeTooltip(e){const o=e.ownerDocument.createElement("div");return Object.assign(o.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:T.control,padding:`${w.sm} ${w.xl}`,fontSize:L.sub,fontFamily:L.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:V.menu}),e.appendChild(o),o}export function attachChartTip(e,o,n,t){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=t),e.addEventListener("mouseenter",i=>{n.textContent=t,n.style.display="block",positionChartTooltip(n,o,i.clientX,i.clientY)}),e.addEventListener("mousemove",i=>{n.style.display==="block"&&positionChartTooltip(n,o,i.clientX,i.clientY)}),e.addEventListener("mouseleave",()=>{n.style.display="none"}),e.addEventListener("click",()=>{n.style.display="none"}),e.addEventListener("focus",()=>{n.textContent=t,n.style.display="block";const i=e.getBoundingClientRect();positionChartTooltip(n,o,i.left+i.width/2,i.bottom)}),e.addEventListener("blur",()=>{n.style.display="none"})}export function positionChartTooltip(e,o,n,t){const i=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let p=n-i.left+r,c=t-i.top+r;p+s+l>i.width&&(p=n-i.left-r-s),c+a+l>i.height&&(c=t-i.top-r-a),p=Math.max(l,p),c=Math.max(l,c),e.style.left=`${p}px`,e.style.top=`${c}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"}},LIMIT_DASH={test:[3,3],spec:[10,4]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function R(e,o){const[n,t]=o==="test"?[e?.limitLow,e?.limitHigh]:[e?.specLow,e?.specHigh],i=[];return n!==void 0&&Number.isFinite(n)&&i.push({value:n,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),t!==void 0&&Number.isFinite(t)&&i.push({value:t,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),i}export function hasBothLimitKinds(e){return R(e,"test").length>0&&R(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const n=R(e,"test"),t=R(e,"spec"),i=o==="test"?n:o==="spec"?t:[...n,...t];return i.length?i:[...n,...t]}export function limitExtent(e){if(!e.length)return{};const o=e.map(n=>n.value);return{lo:de(o),hi:ue(o)}}export function placeClearOf(e,o,n,t=6){const i=l=>e.some(s=>l.x0<s.x1&&l.x1>s.x0&&l.y0<s.y1&&l.y1>s.y0);let r=o;for(let l=0;l<t&&i(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+n,y1:r.y1+n};return e.push(r),r}export function stackLabelRows(e,o=4){const n=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),t=[],i=new Array(e.length).fill(0);for(const r of n){let l=t.findIndex(s=>r.start>=s+o);l===-1?(l=t.length,t.push(r.end)):t[l]=r.end,i[r.i]=l}return i}export function fillTextOnHalo(e,o,n,t,i){if(i){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=i,e.fillRect(n-r.actualBoundingBoxLeft-l,t-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,n,t)}export function strokeLimitLine(e,o,n,t,i,r,l){e.save(),e.strokeStyle=n,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(t,i),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,n=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,t=>o(t),{maxWidth:"170px",hook:"limits-shown",ownerDocument:n})}export{Y as robustFence};export function shouldIncludeLimitsByDefault(e,o,n,t,i=1/3){if(n===void 0&&t===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,n??e),s=Math.max(o,t??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=i}export function resolveAxisRange(e){const{dataMin:o,dataMax:n,limits:t=[],includeLimits:i,clipOutliers:r,values:l}=e;let s=o,a=n,p=0;if(r&&l?.length){const d=Y(l);if(d){const u=Math.max(s,d.lo),f=Math.min(a,d.hi);f>u&&(p=l.filter(y=>Number.isFinite(y)&&(y<u||y>f)).length,s=u,a=f)}}if(i)for(const d of t)s=Math.min(s,d.value),a=Math.max(a,d.value);s===a&&(s-=1,a+=1);const c=[];for(const d of t)d.value<s?c.push({value:d.value,label:d.label,side:"lo"}):d.value>a&&c.push({value:d.value,label:d.label,side:"hi"});return{lo:s,hi:a,offAxis:c,clippedCount:p}}export function limitLabelSide(e,o,n,t,i,r=3){const l=i?-1:1;return(l<0?e-r-o>=n:e+r+o<=t)?l:-l}export function drawOffAxisLimits(e,o,n,t,i,r,l){if(!o.length)return;e.save(),e.fillStyle=i,e.font=`${F(-1)}px system-ui, sans-serif`;const s={lo:0,hi:0},a=F(-1)+2;for(const{value:p,label:c,side:d}of o){const u=s[d]++*a,f=t==="horizontal"?d==="lo"?"\u2190":"\u2192":d==="lo"?"\u2193":"\u2191",y=d==="lo"?`${f} ${c} ${r(p)}`:`${c} ${r(p)} ${f}`;t==="horizontal"?(e.textBaseline="top",e.textAlign=d==="lo"?"left":"right",fillTextOnHalo(e,y,d==="lo"?n.left+2:n.right-2,n.top+2+u,l)):(e.textBaseline=d==="lo"?"bottom":"top",e.textAlign="left",fillTextOnHalo(e,y,n.left+4,d==="lo"?n.bottom-2-u:n.top+2+u,l))}e.restore()}
|
|
1
|
+
import{SHADOW as G,LEADING as re,wireTooltip as U,wireControlHover as O,controlStyle as _,SPACE as v,RADIUS as $,fontPx as H,FONT as A,CLR as g,Z_BASE as le,menuLayerFor as se,wireListNavigation as ae,MENU_SEARCH_THRESHOLD as X,makeMenuSearchBox as ce,markMenuTrigger as D,markNoPrint as W,openCommandMenu as de,saveImageBlob as ue,openReparentedModal as pe}from"../toolbar.js";import{ICONS as Y}from"../icons.js";import{openGuideAt as fe}from"../guideWindow.js";import{minOf as me,maxOf as he}from"../../core/utils.js";import{robustFence as K}from"../../stats/math.js";import{fmt as ge,fmtColorbarAxis as xe}from"../../renderer/fmt.js";import{markedTestLabel as be,DERIVED_LANE_PAD as ye}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,t={}){for(const a of e.querySelectorAll('div[style*="position: absolute"]'))a.style.display==="block"&&a.style.pointerEvents==="none"&&(a.style.display="none");const i=e.getAttribute("style")??"",n=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const r=e.querySelector(":scope > div > [data-wmap-card-expand]"),l=a=>{r&&(r.style.display=a?"flex":"none")};l(!1);const s=pe([e],{title:o,anchor:t.anchor,ownerDocument:e.ownerDocument,boxSize:we[n],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),t.onClosed?.()}});if(!s)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),null;if(n==="rows"){const a=()=>{const d=Number(e.dataset.wmapChartFullH);if(!d)return;const c=s.box.offsetHeight-s.contentWrap.clientHeight;s.setNaturalHeight(`min(90vh, ${Math.ceil(c+d)}px)`)};a(),(e.ownerDocument.defaultView??window).requestAnimationFrame(a)}return s}const we={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,o){const t=e.trim();let i,n,r,l=1;const s=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const d=s[1].length===3?s[1].split("").map(c=>c+c).join(""):s[1];[i,n,r]=[0,2,4].map(c=>parseInt(d.slice(c,c+2),16)),d.length===8&&(l=parseInt(d.slice(6,8),16)/255)}else if(a)[i,n,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${i}, ${n}, ${r}, ${+(l*o).toFixed(3)})`}const Ce={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309",alert:"#7a1c1c"},Z={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text",alert:"err-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),t={};for(const i of Object.keys(Z)){const n=o.getPropertyValue(`--wmap-${Z[i]}`).trim();t[i]=n||Ce[i]}return t.grid=withAlpha(t.border,GRID_ALPHA),t}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const t=e.ownerDocument.defaultView??window;let i=0;const n=new t.ResizeObserver(()=>{i||(i=t.requestAnimationFrame(()=>{i=0,o()}))});return n.observe(e),{disconnect:()=>{i&&t.cancelAnimationFrame(i),i=0,n.disconnect()}}}export function growCardToFitContent(e,o,t){const i=`${z(e,o)+t}px`;e.style.minHeight!==i&&(e.style.minHeight=i)}function z(e,o){const t=e.ownerDocument.defaultView??window,i=t.getComputedStyle(e);let n=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=t.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(n+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return i.boxSizing==="border-box"&&(n+=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0)),n}function J(e,o){const t=e.ownerDocument.defaultView??window;let i=0;for(const n of Array.from(e.children)){if(n===o)continue;const r=n,l=t.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(i+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return i}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,t){const i=e.toLocaleString(),n=e===1?"die":"dies";return t?e===o?`${i} ${n} ${t}`:`${i} of ${o.toLocaleString()} dies ${t} (partial and edge-excluded dies left out)`:`${i} ${n}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,t){const n=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(n.paddingTop)||0)-(parseFloat(n.paddingBottom)||0),l=n.boxSizing==="border-box"?(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0):0;return r-(z(e,o)-l)-(t?J(o,t):0)}export function fitRowsHeight(e,o,t,i,n=0){if(growCardToFitContent(e,o,n+t),e.dataset.wmapChartFullH=String(Math.ceil(z(e,o)+n+i)),!isExpandedCard(e))return t;const r=bodyRoom(e,o)-n;return Math.max(t,Math.min(i,Math.floor(r)))}export function chartFillHeight(e,o,t,i){const n=J(o,t);return growCardToFitContent(e,o,n+i),Math.max(i,o.clientHeight-n)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,t,i){const n=chartDpr(e);e.width=Math.max(1,Math.floor(t*n)),e.height=Math.max(1,Math.floor(i*n)),e.style.width=`${t}px`,e.style.height=`${i}px`;const r=e.getContext("2d");return r?(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,t,i),r.font=`${H(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let t;if(typeof o=="number")t=o;else{const i=(o.ownerDocument.defaultView??window).getComputedStyle(o);t=o.offsetTop+o.offsetHeight+(parseFloat(i.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${t}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:ge(e,void 0,"engineering"):"\u2014"}export function makeAxisFormat(e,o,t){if(!o&&t===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const{tickFmt:i,axisLabel:n,scaledUnit:r}=xe(e,null,o,"engineering",t);return{tick:i,tickWithUnit:r?l=>`${i(l)} ${r}`:i,unitLabel:n}}const ve=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,t){return(i,n)=>{const r=makeAxisFormat(o,t,i).tick;return n.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+ve}}export function drawAxisUnit(e,o,t,i,n){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${H(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=n,e.fillText(`(${o})`,t,i),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(o=>o.replace(/[\s·]+$/,"").trim()).filter(o=>o&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(o)&&!/\(.*(click|drag).*\)/i.test(o)).join(" \xB7 ")}const j=(e,o)=>{for(let t=e;t&&t!==o.parentElement;t=t.parentElement)if(t.style.display==="none")return!1;return!0},Se=/\s*[▾▼]\s*$/,q=new WeakMap;export function describeCard(e){const o=[],t=e.querySelector("[data-wmap-controls]");if(t){for(const l of t.querySelectorAll("button[aria-haspopup]")){if(!j(l,t))continue;const s=(l.textContent??"").replace(Se,"").trim();if(!s)continue;const a=l.closest("label"),c=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(c&&c!==s?`${c}: ${s}`:s)}for(const l of t.querySelectorAll('[role="radiogroup"]')){if(!j(l,t))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of t.querySelectorAll('input[type="checkbox"]:checked')){if(!j(l,t))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const i=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!j(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&i.push(s)}const n=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,d=(l.textContent??"").trim();d&&a&&a!=="transparent"&&n.push({label:d,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,d=(l.textContent??"").trim();d&&a&&a!=="transparent"&&n.push({label:d,color:a})}const r=q.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(i.length=0,i.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(n.length=0,n.push(...r.legend))),{controls:o,captions:i,legend:n}}function ke(e){const o=describeCard(e),t=q.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:t?.colorbar}}function Q(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const t=o.querySelector(":scope > [data-wmap-print-only]");if(!t)continue;const i=describeCard(o);t.replaceChildren();const n=[i.controls.length?i.controls.join(" \xB7 "):"",...i.captions].filter(Boolean);for(const r of n){const l=e.createElement("div");l.textContent=r,t.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ee=new WeakSet;function Le(e){if(ee.has(e))return;ee.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const t=e.defaultView;t?.addEventListener("beforeprint",()=>Q(e));try{t?.matchMedia?.("print").addEventListener?.("change",i=>{i.matches&&Q(e)})}catch{}}function Ae(e){const o=e.ownerDocument.defaultView;for(let t=e;t&&o;t=t.parentElement){const i=o.getComputedStyle(t).backgroundColor;if(i&&i!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(i))return i}return"#ffffff"}export function composeChartPng(e,o){const t=e.ownerDocument,i=t.createElement("canvas"),n=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=t.createElement("canvas").getContext("2d"),s=12*n,a=(f,x="400")=>`${x} ${f*n}px system-ui, -apple-system, "Segoe UI", sans-serif`,d=(f,x)=>l?(l.font=x,l.measureText(f).width):f.length*7*n,c=[];let u=0;if(o){u=s,c.push({kind:"text",text:o.title,x:s,y:u+14*n,font:a(16,"600"),alpha:1}),u+=24*n;const f=o.decor,x=[];f?.controls?.length&&x.push({text:f.controls.join(" \xB7 "),alpha:1});for(const m of f?.caption===void 0?[]:typeof f.caption=="string"?[f.caption]:f.caption)x.push({text:m,alpha:.75});const b=a(12);for(const{text:m,alpha:C}of x){let y="";for(const S of m.split(" ")){const T=y?`${y} ${S}`:S;y&&d(T,b)>r-2*s?(c.push({kind:"text",text:y,x:s,y:u+11*n,font:b,alpha:C}),u+=17*n,y=S):y=T}y&&(c.push({kind:"text",text:y,x:s,y:u+11*n,font:b,alpha:C}),u+=17*n)}if(f?.legend?.length){u+=4*n;const m=a(12);let C=s;for(const y of f.legend){const S=14*n+d(y.label,m)+14*n;C>s&&C+S>r-s&&(C=s,u+=18*n),c.push({kind:"dot",x:C+5*n,y:u+7*n,r:5*n,color:y.color}),c.push({kind:"text",text:y.label,x:C+14*n,y:u+11*n,font:m,alpha:1}),C+=S}u+=20*n}if(f?.colorbar){u+=4*n;const m=a(12),C=f.colorbar;let y=s;c.push({kind:"text",text:C.label,x:y,y:u+10*n,font:m,alpha:1}),y+=d(C.label,m)+10*n,c.push({kind:"text",text:C.lo,x:y,y:u+10*n,font:m,alpha:.75}),y+=d(C.lo,m)+6*n,c.push({kind:"strip",x:y,y:u+1*n,w:200*n,h:10*n,color:C.color}),y+=206*n,c.push({kind:"text",text:C.hi,x:y,y:u+10*n,font:m,alpha:.75}),u+=20*n}u+=6*n}i.width=r,i.height=Math.ceil(e.height+u);const p=i.getContext("2d");if(p.fillStyle=o?Ae(o.card):"#ffffff",p.fillRect(0,0,i.width,i.height),o){const f=t.defaultView,x=f&&f.getComputedStyle(o.card).color||"#222222";p.textBaseline="alphabetic";for(const b of c)if(b.kind==="text")p.font=b.font,p.fillStyle=x,p.globalAlpha=b.alpha,p.fillText(b.text,b.x,b.y),p.globalAlpha=1;else if(b.kind==="dot")p.fillStyle=b.color,p.beginPath(),p.arc(b.x,b.y,b.r,0,Math.PI*2),p.fill();else for(let m=0;m<b.w;m++)p.fillStyle=b.color(m/Math.max(1,b.w-1)),p.fillRect(b.x+m,b.y,1,b.h)}return p.drawImage(e,0,u),i}export function saveCanvasPng(e,o,t,i){composeChartPng(e,i).toBlob(n=>{n&&ue(n,o,t)},"image/png")}const te="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${te}`,`height:${te}`,`border-radius:${$.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Ee="0.35";export function makeSeriesLegendItem(e,o,t=document){const i=t.createElement("button");i.type="button",Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:v.xs,padding:`${v.xs} ${v.md}`,borderRadius:$.pill,border:`1px solid ${g.menuBorder}`,background:"none",cursor:"pointer",fontSize:A.body,color:g.text,whiteSpace:"nowrap"}),O(i,"bare");const n=t.createElement("span");return n.style.cssText=chartSwatchCss(o),i.append(n,t.createTextNode(e)),{el:i,setState({selected:r,dimmed:l}){i.style.borderColor=r?g.iconActive:g.menuBorder,i.style.fontWeight=r?"600":"400",i.style.opacity=l?Ee:"1",i.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:$.container,padding:v.xl,fontVariantNumeric:"tabular-nums"}}function ne(e){Object.assign(e.style,{..._("outlined"),color:g.label,padding:"0",width:"22px",height:"22px",lineHeight:re.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),O(e)}export function cardShell(e,o,t=document,i={}){const n=t.createElement("div");n.dataset.wmapChartCard="1",n.dataset.wmapChartTitle=e,Object.assign(n.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const r=n.ownerDocument.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:v.sm,paddingBottom:"6px",marginBottom:v.md,borderBottom:`1px solid ${g.menuBorder}`});const l=n.ownerDocument.createElement("div");l.textContent=e,Object.assign(l.style,{color:g.value,fontSize:A.heading,fontWeight:"600",flex:"1"}),r.appendChild(l);const s=makeTooltip(n),a=n.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=Y.expand,a.dataset.wmapCardExpand="1",ne(a),attachChartTip(a,n,s,"Expand"),W(a),a.addEventListener("click",()=>{isExpandedCard(n)||openChartExpandModal(n,l.textContent??e)}),r.appendChild(a);const d=n.ownerDocument.createElement("button");d.type="button",d.setAttribute("aria-label","Chart actions"),d.innerHTML=Y.more,d.dataset.wmapCardMenu="1",ne(d),attachChartTip(d,n,s,"Chart actions"),D(d,!1),W(d),r.appendChild(d);const c=n.ownerDocument.createElement("div");c.dataset.wmapCardAbout="1",c.setAttribute("role","note"),Object.assign(c.style,{display:"none",color:g.label,fontSize:A.body,marginBottom:v.md}),W(c);let u;const p=h=>{c.textContent=h?u?.text??"":"",c.style.display=h?"":"none"};let f,x;const b=()=>{const h=f?f():n.querySelector("canvas");h&&saveCanvasPng(h,l.textContent||e,o,{card:n,title:l.textContent||e,decor:ke(n)})},m=()=>{const h=[],M=(E,P,B)=>({label:E,active:!1,action:!0,enabled:!B,disabledHint:B,onClick:()=>{C?.(),P()}});i.png!==!1&&(f||n.querySelector("canvas"))&&h.push(M("Save as PNG",b));for(const E of x?.()??[])h.push(M(E.label,E.onClick,E.disabledHint));if(u){const E=c.style.display!=="none";h.push({label:`About this ${u.noun}`,active:E,onClick:()=>{C?.(),p(!E)}})}return h};let C;d.addEventListener("click",()=>{if(d.getAttribute("aria-expanded")==="true"){C?.();return}const h=m();h.length!==0&&(C=de(d.getBoundingClientRect(),d,h,`${l.textContent||e}: chart actions`,{trigger:d,hook:"wmapCardMenuList"}))}),n.appendChild(r),n.appendChild(c);const y=n.ownerDocument.createElement("div");y.dataset.wmapPrintOnly="1",Object.assign(y.style,{display:"none",color:g.label,fontSize:A.body,marginBottom:v.sm}),n.appendChild(y),Le(n.ownerDocument);const S=n.ownerDocument.createElement("div");S.dataset.wmapControls="1",Object.assign(S.style,{display:"flex",gap:v.sm,marginBottom:v.md,flexWrap:"wrap",alignItems:"center"}),W(S),n.appendChild(S);const T=n.ownerDocument.createElement("div");return Object.assign(T.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),n.appendChild(T),{card:n,heading:l,controlsRow:S,body:T,setPngDecor:h=>{q.set(n,h)},setPngCanvas:h=>{f=h},setAbout:h=>{u=h,p(!!h&&c.style.display!=="none")},setMenuRows:h=>{x=h}}}export function guideCite(e,o,t="How to read this"){const i=e.createElement("span");return i.append(`${t}: `,oe(e,o)," in the user guide"),i}function oe(e,o){const t=e.createElement("button");return t.type="button",t.textContent=o.title,t.dataset.wmapGuideLink=o.id,Object.assign(t.style,{border:"none",background:"none",padding:"0",font:"inherit",color:g.iconActive,textDecoration:"underline",cursor:"pointer"}),O(t),t.addEventListener("click",()=>fe(o.id,t)),t}export function appendGuideCites(e,o){if(o.length===0)return;const t=e.ownerDocument;e.append(" \xB7 how to read this: "),o.forEach((i,n)=>{n>0&&e.append(n===o.length-1?" and ":", "),e.append(oe(t,i))}),e.append(" in the user guide")}export function inputStyle(){return{background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,padding:`${v.xs} ${v.sm}`,fontSize:A.body,fontFamily:A.family,boxSizing:"border-box",minWidth:"0"}}export function makeSegmented(e,o,t,i=document,n=!1){const r=i.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",flexWrap:"wrap",maxWidth:"100%",padding:"1px 0 0 1px"});const l=e.length-1,s=`seg-${Math.random().toString(36).slice(2,9)}`,a=[];return e.forEach(([d,c,u],p)=>{const f=i.createElement("label");u&&U(f,u),Object.assign(f.style,{display:"inline-flex",alignItems:"center",fontSize:A.body,padding:n?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",border:`1px solid ${g.menuBorder}`,margin:"-1px 0 0 -1px",borderTopLeftRadius:p===0?$.control:"0",borderBottomLeftRadius:p===0?$.control:"0",borderTopRightRadius:p===l?$.control:"0",borderBottomRightRadius:p===l?$.control:"0"}),O(f,"bare");const x=i.createElement("input");x.type="radio",x.name=s,x.value=d,x.checked=d===o,Object.assign(x.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const b=()=>{f.style.background=x.checked?g.bgActive:g.menuBg,f.style.color=x.checked?g.iconActive:g.text,f.dataset.on=x.checked?"true":"false"};a.push(b),b(),x.addEventListener("change",()=>{if(x.checked){for(const m of a)m();t(d)}}),f.append(x,i.createTextNode(c)),r.appendChild(f)}),r}const $e=360;export function firstRowsToggle(e,o){let t=!1;const i=e.createElement("button");i.type="button",Object.assign(i.style,{..._("outlined"),marginTop:v.sm}),O(i);const n=()=>{o.fill(t),Object.assign(o.scroller.style,{maxHeight:t?`${$e}px`:"",overflowY:t?"auto":""}),i.textContent=t?`Show the first ${o.noun}`:`Show all ${o.total} ${o.noun}`,i.style.display=o.total>o.first?"":"none"};return i.addEventListener("click",()=>{t=!t,n()}),n(),i}export function makeBackButton(e,o=document){const t=o.createElement("button");return t.type="button",t.textContent="\u2190 Back",Object.assign(t.style,{..._("outlined"),background:g.menuBg,color:g.label}),O(t),t.addEventListener("click",e),t}export function renderEmptyState(e,o,t){const i=e.ownerDocument.createElement("div");i.textContent=o,Object.assign(i.style,{color:g.label,fontSize:A.body,padding:"8px 0"}),t&&Object.assign(i.style,t),e.appendChild(i)}export function makeListSelect(e,o,t,i={}){const{maxWidth:n="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:d}=i;let c=o;const u=h=>e.find(M=>M.value===h)?.label??"",p=r.createElement("button");p.type="button",d&&(p.dataset.wmapSelect=d),l&&p.setAttribute("aria-label",l),Object.assign(p.style,{fontSize:A.body,padding:`${v.xxs} ${v.sm}`,background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,maxWidth:n,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:v.sm,justifyContent:"space-between"}),O(p),D(p,!1);const f=r.createElement("span");Object.assign(f.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const x=r.createElement("span");x.textContent="\u25BE",x.style.flex="0 0 auto",p.append(f,x);const b=()=>{f.textContent=e.length===0?s??"(none)":u(c)||s||"(none)"};if(b(),e.length===0)return p.disabled=!0,p.style.opacity="0.6",p.style.cursor="default",Object.defineProperty(p,"value",{get:()=>c,set:h=>{c=h,b()}});let m=null;const C=()=>{m&&(m.remove(),m=null,D(p,!1))},y=()=>{C(),p.focus()};function S(){const h=p.getBoundingClientRect(),M=r.defaultView??window,E=Math.max(h.width,220),P=Math.min(h.left,Math.max(4,(M.innerWidth??1/0)-E-4));m=r.createElement("div"),m.setAttribute("role","listbox"),m.setAttribute("aria-label",l??"Options"),Object.assign(m.style,{position:"fixed",top:`${h.bottom+4}px`,left:`${P}px`,background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,boxShadow:G.menu,zIndex:le,minWidth:`${E}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const B=[],N=()=>B.filter(w=>w.row.style.display!=="none").map(w=>w.row),F=[],ie=()=>{for(const w of F)w.el.style.display=B.slice(w.first,w.last+1).some(k=>k.row.style.display!=="none")?"":"none"};if(e.length>X){const w=ce(k=>{for(const L of B)L.row.style.display=L.label.includes(k)?"":"none";ie()},a,r);Object.assign(w.style,{position:"sticky",top:"0",zIndex:"1",background:g.menuBg}),w.addEventListener("keydown",k=>{if(k.key==="Escape"){k.preventDefault(),y();return}k.key==="ArrowDown"&&(k.preventDefault(),N()[0]?.focus())}),m.appendChild(w)}let V;for(const w of e){if(w.group!==void 0&&w.group!==V){const R=r.createElement("div");R.textContent=w.group,R.setAttribute("role","presentation"),Object.assign(R.style,{padding:`${v.sm} ${v.xl} ${v.xxs}`,fontSize:A.sub,color:g.label,fontWeight:"600"}),m.appendChild(R),F.push({el:R,first:B.length,last:B.length})}V=w.group;const k=w.value===c,L=r.createElement("div");L.textContent=w.disabled?`${w.label} \u2014 ${w.disabled}`:w.label,L.setAttribute("role","option"),L.setAttribute("aria-selected",k?"true":"false"),w.disabled&&L.setAttribute("aria-disabled","true"),L.tabIndex=-1,Object.assign(L.style,{padding:`${v.sm} ${v.xl}`,fontSize:A.body,cursor:w.disabled?"default":"pointer",color:w.disabled?g.label:k?g.iconActive:g.text,fontWeight:k?"700":"400",opacity:w.disabled?"0.7":"",background:k?g.menuActive:"transparent",whiteSpace:"nowrap"}),L.addEventListener("mouseenter",()=>{!k&&!w.disabled&&(L.style.background=g.menuHover)}),L.addEventListener("mouseleave",()=>{k||(L.style.background="transparent")}),L.addEventListener("click",R=>{R.stopPropagation(),!w.disabled&&(c=w.value,b(),y(),t(w.value))}),m.appendChild(L),B.push({row:L,label:w.label.toLowerCase()}),F.length&&(F[F.length-1].last=B.length-1)}if(ae(m,N,y),se(p).appendChild(m),D(p,!0),e.length<=X){const w=e.findIndex(k=>k.value===c);N()[w>=0?w:0]?.focus()}}p.addEventListener("click",h=>{if(h.stopPropagation(),m){C();return}S()});const T=h=>{if(!p.isConnected){r.removeEventListener("click",T);return}m&&!m.contains(h.target)&&!p.contains(h.target)&&C()};return r.addEventListener("click",T),Object.defineProperty(p,"value",{get:()=>c,set:h=>{c=h,b()}})}export function testOptionLabels(e){const o=e.some(t=>t.derived);return e.map(t=>(o&&!t.derived?ye:"")+be(t,t.testNumber))}export function makeTestSelect(e,o,t,i={}){const{maxWidth:n="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=i;return makeListSelect(testOptionLabels(e).map((s,a)=>({value:String(e[a].testNumber),label:s})),o!==null?String(o):"",s=>t(Number(s)),{maxWidth:n,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,t,i=document){let n=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>t({includeLimits:n,clipOutliers:r,limits:l});return{get:()=>({includeLimits:n,clipOutliers:r,limits:l}),sync(a,d,c=!1){e.innerHTML="",c&&e.appendChild(makeLimitsSelect(l,u=>{l=u,s()},i)),d&&e.appendChild(makeToggle("Axis includes limits",a,u=>{n=u,s()},i,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,u=>{r=u,s()},i,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const d=a.limits??"both";return a.includeLimits===n&&a.clipOutliers===r&&d===l?!1:(n=a.includeLimits,r=a.clipOutliers,l=d,!0)}}}export function makeLinkedTestSelect(e,o,t,i={}){let n=o;const r=makeTestSelect(e,n,l=>{l!==n&&(n=l,t(l))},i);return{el:r,get:()=>n,set(l){return n===l||!e.some(s=>s.testNumber===l)?!1:(n=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,t,i,n={}){let r=t;const l=c=>c??ALL_GROUPS,s=c=>c===ALL_GROUPS?null:c,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(c=>({value:c,label:c}))],l(r),c=>{const u=s(c);u!==r&&(r=u,i(u))},{...n,hook:"group-scope"}),d=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(c){return r===c||c!==null&&!e.includes(c)?!1:(r=c,d&&(d.value=l(c)),!0)}}}export function makeWaferSelect(e,o,t,i={}){const{maxWidth:n="160px",allLabel:r="All wafers",ownerDocument:l=document}=i,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,d)=>({value:String(d),label:a.label??`#${d}`}))],o===null?s:String(o),a=>t(a===s?null:Number(a)),{maxWidth:n,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,t,i=document,n){const r=i.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:v.xs,fontSize:A.body,color:g.label,cursor:"pointer",userSelect:"none"}),O(r,"bare");const l=i.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>t(l.checked)),r.append(l,i.createTextNode(e)),n&&U(r,n),r}export function makeLabeledSelect(e,o,t,i,n={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document}=n,a=s.createElement("label");a.textContent=e,Object.assign(a.style,{color:g.label,fontSize:A.body,display:"flex",alignItems:"center",gap:v.xs});const d=makeListSelect(o,t,i,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return a.appendChild(d),a}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:v.lg,flex:"0 0 auto"}),o}export function makeTooltip(e){const o=e.ownerDocument.createElement("div");return Object.assign(o.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:$.control,padding:`${v.sm} ${v.xl}`,fontSize:A.sub,fontFamily:A.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:G.menu}),e.appendChild(o),o}export function attachChartTip(e,o,t,i){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=i),e.addEventListener("mouseenter",n=>{t.textContent=i,t.style.display="block",positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mousemove",n=>{t.style.display==="block"&&positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{t.style.display="none"}),e.addEventListener("click",()=>{t.style.display="none"}),e.addEventListener("focus",()=>{t.textContent=i,t.style.display="block";const n=e.getBoundingClientRect();positionChartTooltip(t,o,n.left+n.width/2,n.bottom)}),e.addEventListener("blur",()=>{t.style.display="none"})}export function positionChartTooltip(e,o,t,i){const n=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let d=t-n.left+r,c=i-n.top+r;d+s+l>n.width&&(d=t-n.left-r-s),c+a+l>n.height&&(c=i-n.top-r-a),d=Math.max(l,d),c=Math.max(l,c),e.style.left=`${d}px`,e.style.top=`${c}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"},pat:{lo:"PAT lo",hi:"PAT hi"},whatif:{lo:"What-if lo",hi:"What-if hi"},ref:{lo:"",hi:""}},LIMIT_DASH={test:[3,3],spec:[10,4],pat:[1,3],whatif:[8,3,2,3],ref:[6,2,1,2]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function I(e,o){const[t,i]=o==="test"?[e?.limitLow,e?.limitHigh]:o==="spec"?[e?.specLow,e?.specHigh]:o==="pat"?[e?.patLow,e?.patHigh]:o==="whatif"?[e?.whatIfLow,e?.whatIfHigh]:[void 0,void 0],n=[];return t!==void 0&&Number.isFinite(t)&&n.push({value:t,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),i!==void 0&&Number.isFinite(i)&&n.push({value:i,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),n}export function hasBothLimitKinds(e){return I(e,"test").length>0&&I(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const t=I(e,"test"),i=I(e,"spec"),n=o==="test"?t:o==="spec"?i:[...t,...i];return[...n.length?n:[...t,...i],...I(e,"pat"),...I(e,"whatif")]}export function limitExtent(e){if(!e.length)return{};const o=e.map(t=>t.value);return{lo:me(o),hi:he(o)}}export function placeClearOf(e,o,t,i=6){const n=l=>e.some(s=>l.x0<s.x1&&l.x1>s.x0&&l.y0<s.y1&&l.y1>s.y0);let r=o;for(let l=0;l<i&&n(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+t,y1:r.y1+t};return e.push(r),r}export function stackLabelRows(e,o=4){const t=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),i=[],n=new Array(e.length).fill(0);for(const r of t){let l=i.findIndex(s=>r.start>=s+o);l===-1?(l=i.length,i.push(r.end)):i[l]=r.end,n[r.i]=l}return n}export function fillTextOnHalo(e,o,t,i,n){if(n){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=n,e.fillRect(t-r.actualBoundingBoxLeft-l,i-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,t,i)}export function strokeLimitLine(e,o,t,i,n,r,l){e.save(),e.strokeStyle=t,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(i,n),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,t=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,i=>o(i),{maxWidth:"170px",hook:"limits-shown",ownerDocument:t})}export{K as robustFence};export function shouldIncludeLimitsByDefault(e,o,t,i,n=1/3){if(t===void 0&&i===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,t??e),s=Math.max(o,i??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=n}export function resolveAxisRange(e){const{dataMin:o,dataMax:t,limits:i=[],includeLimits:n,clipOutliers:r,values:l}=e;let s=o,a=t,d=0;if(r&&l?.length){const u=K(l);if(u){const p=Math.max(s,u.lo),f=Math.min(a,u.hi);f>p&&(d=l.filter(x=>Number.isFinite(x)&&(x<p||x>f)).length,s=p,a=f)}}if(n)for(const u of i)s=Math.min(s,u.value),a=Math.max(a,u.value);s===a&&(s-=1,a+=1);const c=[];for(const u of i)u.value<s?c.push({value:u.value,label:u.label,side:"lo"}):u.value>a&&c.push({value:u.value,label:u.label,side:"hi"});return{lo:s,hi:a,offAxis:c,clippedCount:d}}export function limitLabelSide(e,o,t,i,n,r=3){const l=n?-1:1;return(l<0?e-r-o>=t:e+r+o<=i)?l:-l}export function drawOffAxisLimits(e,o,t,i,n,r,l,s){if(!o.length)return;e.save(),e.fillStyle=n,e.font=`${H(-1)}px system-ui, sans-serif`;const a={lo:0,hi:0},d=H(-1)+2;for(const{value:c,label:u,side:p}of o){const f=a[p]++*d,x=i==="horizontal"?p==="lo"?"\u2190":"\u2192":p==="lo"?"\u2193":"\u2191",b=p==="lo"?`${x} ${u} ${r(c)}`:`${u} ${r(c)} ${x}`,m=e.measureText(b).width;if(i==="horizontal"){const C=p==="lo"?t.left+2:t.right-2-m,y={x0:C,x1:C+m,y0:t.top+2+f,y1:t.top+2+f+d},S=s?placeClearOf(s,y,d):y;e.textBaseline="top",e.textAlign=p==="lo"?"left":"right",fillTextOnHalo(e,b,p==="lo"?t.left+2:t.right-2,S.y0,l)}else{const C=p==="lo"?t.bottom-2-f-d:t.top+2+f,y={x0:t.left+4,x1:t.left+4+m,y0:C,y1:C+d},S=s?placeClearOf(s,y,p==="lo"?-d:d):y;e.textBaseline="top",e.textAlign="left",fillTextOnHalo(e,b,t.left+4,S.y0,l)}}e.restore()}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CommonalityField, type CommonalityWafer } from '../../stats/commonality.js';
|
|
2
|
+
import type { FacetCuration } from '../../stats/facets.js';
|
|
3
|
+
export interface CommonalityPanelOptions {
|
|
4
|
+
wafers: readonly CommonalityWafer[];
|
|
5
|
+
/** The wafer fields that divide the wafers (the Group by list). */
|
|
6
|
+
fields: readonly CommonalityField[];
|
|
7
|
+
curation?: Record<string, FacetCuration>;
|
|
8
|
+
/** The field Insights is grouped by now, if any: its row says so instead of offering it. */
|
|
9
|
+
groupedBy?: string;
|
|
10
|
+
/** Group Insights by this field. */
|
|
11
|
+
onGroupBy: (key: string) => void;
|
|
12
|
+
ownerDocument?: Document;
|
|
13
|
+
}
|
|
14
|
+
export declare function renderCommonalityPanel(o: CommonalityPanelOptions): {
|
|
15
|
+
card: HTMLElement;
|
|
16
|
+
destroy: () => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=commonality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rankCommonality as A,measureLabel as N}from"../../stats/commonality.js";import{formatP as y}from"../../stats/groupCompare.js";import{CLR as h,FONT as E,SPACE as p,controlStyle as O,wireControlHover as B,wireTooltip as b}from"../toolbar.js";import{cardShell as T,firstRowsToggle as G,guideCite as R,renderEmptyState as F}from"./chartShell.js";import{GUIDE_SECTIONS as q}from"../../stats/guideSections.js";import{cardAbout as I}from"./cardAbout.js";const j=8;export function renderCommonalityPanel(l){const r=l.ownerDocument??document,{card:d,body:u,setAbout:v}=T("What divides yield",void 0,r);v(I("commonality")),d.dataset.wmapCommonality="1",d.style.gridColumn="1 / -1",d.style.flex="0 0 auto";const s=A(l.wafers,l.fields,l.curation);if(l.fields.length===0||s.rows.length===0)return F(u,l.fields.length===0?"No wafer field divides these wafers, so there is nothing to compare.":"No wafer field has two groups of two or more wafers, so there is nothing to compare."),{card:d,destroy:()=>{}};const f=r.createElement("div"),g=[`Every wafer field, compared for yield and for the ${s.bins.length} most common fail bin${s.bins.length===1?"":"s"}, with each wafer as one value. Ranked by q (Welch's p adjusted for the ${s.rows.length} comparisons). A low q says the groups differ by more than wafer-to-wafer noise; it does not say why.`];s.confounded.length&&g.push(`These fields group the wafers identically, so the wafers cannot tell them apart: ${s.confounded.map(([n,e])=>`${n.label} and ${e.label}`).join("; ")}.`),s.untestable.length&&g.push(`Not compared, with no two groups of two or more wafers: ${s.untestable.map(n=>n.label).join(", ")}.`),f.textContent=g.join(" ")+" ",f.append(R(r,q.dividesYield),"."),Object.assign(f.style,{color:h.label,fontSize:E.body,marginBottom:p.sm}),u.appendChild(f);const c=r.createElement("table");Object.assign(c.style,{borderCollapse:"collapse",width:"100%",fontSize:E.body,fontVariantNumeric:"tabular-nums"});const C=r.createElement("tr"),i=(n,e,t="right")=>{const o=r.createElement("th");o.scope="col",o.textContent=n,e&&b(o,e),Object.assign(o.style,{textAlign:t,padding:`${p.xs} ${p.sm}`,borderBottom:`1px solid ${h.menuBorder}`,color:h.label,fontWeight:"600",whiteSpace:"nowrap"}),C.appendChild(o)};i("Field",void 0,"left"),i("Measure","Yield, or a fail bin\u2019s share of the judged dies","left"),i("Worst group","The group with the lowest yield, or the highest rate of the bin: its mean over its wafers","left"),i("Best group",void 0,"left"),i("Spread","Worst to best, in percentage points"),i("Welch p","Do the groups\u2019 wafer means differ? Welch\u2019s ANOVA, or Welch\u2019s t for two groups"),i("Rank p","The same question on ranks (Kruskal\u2013Wallis)"),i("q","Welch p adjusted for every comparison in the table (Benjamini\u2013Hochberg)"),i("");const $=r.createElement("thead");$.appendChild(C),c.appendChild($);const w=r.createElement("tbody");c.appendChild(w);const a=(n,e,t={})=>{const o=r.createElement("td");typeof e=="string"?o.textContent=e:o.appendChild(e),t.title&&b(o,t.title),Object.assign(o.style,{padding:`${p.xs} ${p.sm}`,textAlign:t.align??"right",borderBottom:`1px solid ${h.menuBorder}`,whiteSpace:"nowrap",fontWeight:t.strong?"700":"400"}),n.appendChild(o)},k=n=>`${n.toFixed(1)}%`,x=(n,e)=>e.comparison.groups.find(t=>t.key===n)?.n??0;function S(n){w.replaceChildren();for(const e of n?s.rows:s.rows.slice(0,j)){const t=r.createElement("tr");if(a(t,e.field.label,{align:"left"}),a(t,N(e.measure),{align:"left"}),a(t,`${e.worst.key}: ${k(e.worst.mean)} (${x(e.worst.key,e)} wafers)`,{align:"left"}),a(t,`${e.best.key}: ${k(e.best.mean)} (${x(e.best.key,e)} wafers)`,{align:"left"}),a(t,`${e.spread.toFixed(1)} pts`),a(t,y(e.comparison.welch?.p??NaN),{title:e.comparison.issue}),a(t,`${y(e.comparison.kruskal?.p??NaN)}${e.comparison.kruskal?.approximate?"*":""}`,{title:e.comparison.kruskal?.approximate?"Approximate: fewer than five wafers in a group":void 0}),a(t,y(e.pAdjusted),{strong:e.pAdjusted<.05}),e.field.key===l.groupedBy)a(t,"Grouped by this",{align:"left"});else{const o=r.createElement("button");o.type="button",o.textContent="Group by",o.dataset.wmapCommonalityGroup=e.field.key,b(o,`Group Insights by ${e.field.label}, so every chart compares its groups`),Object.assign(o.style,O("outlined")),B(o),o.addEventListener("click",()=>l.onGroupBy(e.field.key)),a(t,o,{align:"left"})}w.appendChild(t)}}const m=r.createElement("div");Object.assign(m.style,{overflowX:"auto"}),m.appendChild(c);const W=G(r,{total:s.rows.length,first:j,noun:"rows",scroller:m,fill:S});return u.append(m,W),{card:d,destroy:()=>{}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCorrelationMatrix as $t,filterCorrelationMatrix as It,correlationSampleNote as Tt}from"../../stats/correlation.js";import{maxOf as St}from"../../core/utils.js";import{CORRELATION_POSITIVE as st,CORRELATION_NEGATIVE as rt}from"./palette.js";import{buildFacetTable as Dt}from"../../stats/facets.js";import{wireControlHover as Rt,wireTooltip as pt,controlStyle as At,SPACE as L,RADIUS as lt,fontPx as ft,FONT as j,CLR as g}from"../toolbar.js";import{exportCsv as kt}from"../tableExport.js";import{attachChartTip as _t,cardShell as Bt,setChartGrow as Nt,isExpandedCard as Ot,bodyRoom as Wt,observeResize as Ht,makeTooltip as Xt,positionChartTooltip as jt,makeWaferSelect as Vt,renderEmptyState as zt,resolveChartCanvasColors as Ft,prepareCanvas as Pt,chartDpr as ut}from"./chartShell.js";import{escHtml as K}from"../../core/utils.js";import{unmarkedLabel as ht,derivedCsvCell as xt,DERIVED_CSV_HEADER as gt,DERIVED_MARK as Yt,DERIVED_KEY as Gt}from"../../renderer/testLabel.js";const it=5,at=100,bt=20;function q(b){const d=b.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(d)return[+d[1],+d[2],+d[3]];const h=b.trim().replace("#","");return h.length===6?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16)]:null}function Ut(b){const d=q(b);return d?(d[0]*299+d[1]*587+d[2]*114)/1e3>140?"#111":"#fff":"#000"}function yt(b,d,h){const O=q(b);if(!O)return b;const J=Math.round(d[0]+(O[0]-d[0])*h),W=Math.round(d[1]+(O[1]-d[1])*h),l=Math.round(d[2]+(O[2]-d[2])*h);return`rgb(${J},${W},${l})`}export function renderCorrelationPanel(b){const{title:d="Test correlation matrix",items:h,testDefs:O,onSaveImage:J,onSelectPair:W}=b,{card:l,body:$,controlsRow:Q,setPngDecor:wt}=Bt(d,J,b.ownerDocument);wt(()=>{const e=q(l.ownerDocument.defaultView?.getComputedStyle(l).backgroundColor??"")??[255,255,255];return{colorbar:{label:"Pearson r",lo:"\u22121",hi:"+1",color:o=>yt(o<.5?rt:st,e,Math.abs(2*o-1))}}}),Nt(l,"square"),$.style.overflowX="auto",l.style.alignSelf="start";let F=bt,V=null;const H=l.ownerDocument.createElement("label");H.textContent="Max tests:",pt(H,`The most tests the matrix shows, from ${it} to ${at}`),Object.assign(H.style,{color:g.label,fontSize:j.body,display:"flex",alignItems:"center",gap:L.xs});const E=l.ownerDocument.createElement("input");E.type="number",E.min=String(it),E.max=String(at),E.value=String(F),Object.assign(E.style,{width:"52px",fontSize:j.body,padding:`${L.xxs} ${L.xs}`,background:g.menuBg,color:g.value,border:`1px solid ${g.menuBorder}`,borderRadius:lt.control}),E.addEventListener("change",()=>{const e=Math.max(it,Math.min(at,parseInt(E.value,10)||bt));E.value=String(e),e!==F&&(F=e,tt())}),H.appendChild(E),Q.appendChild(H),h.length>1&&Q.appendChild(Vt(h,V,e=>{V=e,tt()},{ownerDocument:l.ownerDocument}));function Ct(){return V!==null?h[V]?[h[V]]:[]:h}if(b.onSaveText){const e=l.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",pt(e,"Save the correlation coefficients as a CSV file, one row per pair of tests"),Object.assign(e.style,{...At("outlined"),color:g.text}),Rt(e),e.addEventListener("click",()=>{const o=ct;if(!o)return;const m=o.tests.some(s=>s.derived),p=[];for(let s=0;s<o.tests.length;s++)for(let a=s+1;a<o.tests.length;a++){const y=o.cells.find(x=>x.xIndex===a&&x.yIndex===s);y&&p.push({x:o.tests[a],y:o.tests[s],r:y.r,n:y.n})}kt([{header:"Test X",get:s=>ht(s.x.label)},{header:"Test X number",get:s=>s.x.testNumber},{header:"Test Y",get:s=>ht(s.y.label)},{header:"Test Y number",get:s=>s.y.testNumber},{header:"r",get:s=>s.r===null?"":s.r.toFixed(6)},{header:"n",get:s=>s.n},...m?[{header:`Test X ${gt.toLowerCase()}`,get:s=>xt(s.x)},{header:`Test Y ${gt.toLowerCase()}`,get:s=>xt(s.y)}]:[]],p,"test-correlation.csv",b.onSaveText)}),Q.appendChild(e)}const k=l.ownerDocument.createElement("div");Object.assign(k.style,{display:"flex",flexDirection:"column",gap:L.xs,marginBottom:L.sm}),l.insertBefore(k,$);const I=Xt(l);_t(H,l,I,"Cap on how many tests the matrix includes (strongest correlations kept first)");let Z=()=>{};function Mt(e,o,m,p,s,a,y,x){k.innerHTML="";const _=Tt(y);if(_){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=`${_} \u2014 r is an estimate, not the whole population.`,Object.assign(f.style,{color:g.label,fontSize:j.body}),k.appendChild(f)}if(s.length>0){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=`\u26A0 Mixed ${s.join(", ")} within this set \u2014 correlations may be misleading (Simpson's paradox). Use Group by, or the Wafer picker, to narrow to a like-for-like set.`,Object.assign(f.style,{color:g.warnText,background:g.warnBg,border:`1px solid ${g.warnBorder}`,borderRadius:lt.control,padding:`${L.xs} ${L.md}`,fontSize:j.body}),k.appendChild(f)}const C=l.ownerDocument.createElement("span");Object.assign(C.style,{display:"inline-flex",alignItems:"center",gap:L.sm,color:g.label,fontSize:j.body,flexWrap:"wrap"});const B=l.ownerDocument.createElement("span");B.dataset.wmapCaption="1",B.textContent=(a!==null?`Pearson r \xB7 n \u2248 ${a.toLocaleString()} dies per pair \xB7 click a cell to view that pair in scatter \xB7`:"Pearson r \xB7 click a cell to view that pair in scatter \xB7")+(x?` ${Yt} ${Gt} \xB7`:""),C.appendChild(B);const i=l.ownerDocument.createElement("span");Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:L.xs});const T=l.ownerDocument.createElement("span");T.textContent="\u22121";const P=l.ownerDocument.createElement("span");Object.assign(P.style,{display:"inline-block",width:"64px",height:"8px",borderRadius:lt.control,border:`1px solid ${g.menuBorder}`,background:`linear-gradient(to right, ${rt}, ${g.menuBg}, ${st})`});const z=l.ownerDocument.createElement("span");z.textContent="+1",i.append(T,P,z),C.appendChild(i),k.appendChild(C);const v=l.ownerDocument.createElement("span");if(v.dataset.wmapCaption="1",Object.assign(v.style,{color:g.value,fontSize:j.body,fontWeight:"500"}),e===0&&o===0)v.textContent=p?`No significant correlations found \u2014 strongest pair: ${p.xLabel} \u2194 ${p.yLabel} (r = ${p.r.toFixed(2)})`:"No significant correlations found";else{const f=[];e>0&&f.push(`${e} strong (|r| \u2265 0.7)`),o>0&&f.push(`${o} moderate (0.4\u20130.7)`);const Y=e+o;let r=f.join(", ")+` pair${Y!==1?"s":""} found`;m>0&&(r+=` \xB7 ${m} weak pair${m!==1?"s":""} not shown`),v.textContent=r}k.appendChild(v)}function Et(e){if($.innerHTML="",e.tests.length<2)return zt($,"Need at least two parametric tests for a correlation matrix."),()=>{};const o=l.ownerDocument.createElement("canvas");o.style.display="block",o.style.cursor="default",$.appendChild(o);const m=e.tests.length,p=r=>r.label.split(" (#")[0],s=Math.min(14,St(e.tests.map(r=>p(r).length))),a=s*6.5+8,y=10,x=Math.round(y*6.5*Math.sin(Math.PI/4))+14,_=14,C=28,B=44;let i=-1,T=-1;const P=96;function z(r){const c=Math.max(0,r-a),u=Math.floor(c/m);if(!Ot(l))return Math.max(_,Math.min(B,u));const n=Math.floor((Wt(l,$,o)-x-4)/m);return Math.max(_,Math.min(P,u,n))}const v=new Map;for(const r of e.cells){let c=v.get(r.yIndex);c||(c=[],v.set(r.yIndex,c)),c.push(r)}function f(){const r=Ft(l),c=q(r.bg)??[255,255,255],u=$.clientWidth,n=z(u),X=n*m,S=x+n*m+4,D=a+X,R=Pt(o,l,D,S);if(!R)return;const{ctx:t}=R;t.font=`${ft(-1)}px system-ui, sans-serif`,t.fillStyle=r.text,e.tests.forEach((A,w)=>{const M=p(A),N=M.length>y?`${M.slice(0,y-1)}\u2026`:M,et=a+w*n+n/2;t.save(),t.translate(et,x-4),t.rotate(-Math.PI/4),t.textAlign="left",t.textBaseline="bottom",t.fillStyle=w===i?r.text:r.textMuted,t.fillText(N,0,0),t.restore()}),e.tests.forEach((A,w)=>{const M=p(A),N=x+w*n,et=N+n/2;t.font=`${ft(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=w===T?r.text:r.textMuted,t.fillText(M.length>s?`${M.slice(0,s-1)}\u2026`:M,a-4,et),(v.get(w)??[]).forEach(dt=>{const nt=dt.xIndex,G=a+nt*n,Lt=nt===i&&w===T,mt=nt===w,U=dt.r;if(U===null){t.fillStyle=r.border,t.globalAlpha=.4,t.fillRect(G+1,N+1,n-2,n-2),t.globalAlpha=1;return}let ot=r.bgHover;mt?t.fillStyle=r.bgHover:(ot=yt(U>=0?st:rt,c,Math.abs(U)),t.fillStyle=ot),t.fillRect(G+1,N+1,n-2,n-2),n>=C&&!mt&&(t.font=`${Math.min(10,n*.35)}px system-ui, sans-serif`,t.fillStyle=Ut(ot),t.textAlign="center",t.textBaseline="middle",t.fillText(U.toFixed(2),G+n/2,N+n/2)),Lt&&(t.strokeStyle=r.text,t.lineWidth=2,t.strokeRect(G+1,N+1,n-2,n-2),t.lineWidth=1)})}),t.strokeStyle=r.bg,t.lineWidth=1;for(let A=0;A<=m;A++){const w=a+A*n;t.beginPath(),t.moveTo(w,x),t.lineTo(w,x+m*n),t.stroke();const M=x+A*n;t.beginPath(),t.moveTo(a,M),t.lineTo(a+m*n,M),t.stroke()}}function Y(r){const c=o.getBoundingClientRect(),u=$.clientWidth,n=z(u),X=(r.clientX-c.left)*(o.width/ut(o)/c.width),S=(r.clientY-c.top)*(o.height/ut(o)/c.height),D=Math.floor((X-a)/n),R=Math.floor((S-x)/n);return D>=0&&D<m&&R>=0&&R<m?{xi:D,yi:R}:null}return o.addEventListener("mousemove",r=>{const c=Y(r);if(!c){I.style.display="none",o.style.cursor="default";return}const{xi:u,yi:n}=c,X=u===n;o.style.cursor=X||!W?"default":"pointer";const S=e.cells.find(t=>t.xIndex===u&&t.yIndex===n),D=e.tests[u].label,R=e.tests[n].label;X?I.innerHTML=`<strong>${K(D)}</strong>`:S?.r!==null&&S?.r!==void 0?I.innerHTML=`<strong>${K(p(e.tests[n]))}</strong> (#${e.tests[n].testNumber}) vs <strong>${K(p(e.tests[u]))}</strong> (#${e.tests[u].testNumber})<br>r = ${S.r.toFixed(4)} \xB7 n = ${S.n.toLocaleString()}${W?"<br><em>click to view in scatter</em>":""}`:I.innerHTML=`${K(`${R} vs ${D}`)}<br><em>insufficient data</em>`,I.style.display="block",jt(I,l,r.clientX,r.clientY)}),o.addEventListener("mouseleave",()=>{I.style.display="none"}),o.addEventListener("click",r=>{const c=Y(r);if(!c||!W)return;const{xi:u,yi:n}=c;u!==n&&(i=u,T=n,f(),W(e.tests[u].testNumber,e.tests[n].testNumber))}),f}let ct=null;function tt(){const e=Ct(),o=e.flatMap(i=>i.dies??[]),m=$t(o,O),{matrix:p,strongPairs:s,moderatePairs:a,hiddenWeakPairs:y,strongestPair:x}=It(m,{minTests:6,maxTests:F}),_=Dt(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),C=p.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,T)=>i-T),B=C.length?C[Math.floor(C.length/2)]:null;ct=p,Mt(s,a,y,x,_,B,m.sample,p.tests.some(i=>i.derived)),Z=Et(p),Z()}const vt=Ht(l,()=>Z());return tt(),{card:l,destroy:()=>vt.disconnect()}}
|
|
1
|
+
import{buildCorrelationMatrix as It,filterCorrelationMatrix as Tt,correlationSampleNote as St}from"../../stats/correlation.js";import{maxOf as Dt}from"../../core/utils.js";import{CORRELATION_POSITIVE as st,CORRELATION_NEGATIVE as rt}from"./palette.js";import{buildFacetTable as Rt}from"../../stats/facets.js";import{wireControlHover as At,wireTooltip as ut,controlStyle as kt,SPACE as L,RADIUS as lt,fontPx as ft,FONT as j,CLR as b}from"../toolbar.js";import{exportCsv as _t}from"../tableExport.js";import{attachChartTip as Bt,cardShell as Nt,setChartGrow as Ot,isExpandedCard as Wt,bodyRoom as Ht,observeResize as Xt,makeTooltip as jt,positionChartTooltip as Vt,makeWaferSelect as zt,renderEmptyState as Ft,resolveChartCanvasColors as Pt,prepareCanvas as Yt,chartDpr as pt}from"./chartShell.js";import{escHtml as K}from"../../core/utils.js";import{unmarkedLabel as ht,derivedCsvCell as xt,DERIVED_CSV_HEADER as bt,DERIVED_MARK as Gt,DERIVED_KEY as Ut}from"../../renderer/testLabel.js";import{cardAbout as Kt}from"./cardAbout.js";const it=5,at=100,gt=20;function q(g){const d=g.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(d)return[+d[1],+d[2],+d[3]];const h=g.trim().replace("#","");return h.length===6?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16)]:null}function qt(g){const d=q(g);return d?(d[0]*299+d[1]*587+d[2]*114)/1e3>140?"#111":"#fff":"#000"}function yt(g,d,h){const O=q(g);if(!O)return g;const J=Math.round(d[0]+(O[0]-d[0])*h),W=Math.round(d[1]+(O[1]-d[1])*h),l=Math.round(d[2]+(O[2]-d[2])*h);return`rgb(${J},${W},${l})`}export function renderCorrelationPanel(g){const{title:d="Test correlation matrix",items:h,testDefs:O,onSaveImage:J,onSelectPair:W}=g,{card:l,body:$,controlsRow:Q,setPngDecor:wt,setAbout:Ct}=Nt(d,J,g.ownerDocument);Ct(Kt("correlation")),wt(()=>{const e=q(l.ownerDocument.defaultView?.getComputedStyle(l).backgroundColor??"")??[255,255,255];return{colorbar:{label:"Pearson r",lo:"\u22121",hi:"+1",color:o=>yt(o<.5?rt:st,e,Math.abs(2*o-1))}}}),Ot(l,"square"),$.style.overflowX="auto",l.style.alignSelf="start";let F=gt,V=null;const H=l.ownerDocument.createElement("label");H.textContent="Max tests:",ut(H,`The most tests the matrix shows, from ${it} to ${at}`),Object.assign(H.style,{color:b.label,fontSize:j.body,display:"flex",alignItems:"center",gap:L.xs});const E=l.ownerDocument.createElement("input");E.type="number",E.min=String(it),E.max=String(at),E.value=String(F),Object.assign(E.style,{width:"52px",fontSize:j.body,padding:`${L.xxs} ${L.xs}`,background:b.menuBg,color:b.value,border:`1px solid ${b.menuBorder}`,borderRadius:lt.control}),E.addEventListener("change",()=>{const e=Math.max(it,Math.min(at,parseInt(E.value,10)||gt));E.value=String(e),e!==F&&(F=e,tt())}),H.appendChild(E),Q.appendChild(H),h.length>1&&Q.appendChild(zt(h,V,e=>{V=e,tt()},{ownerDocument:l.ownerDocument}));function Mt(){return V!==null?h[V]?[h[V]]:[]:h}if(g.onSaveText){const e=l.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",ut(e,"Save the correlation coefficients as a CSV file, one row per pair of tests"),Object.assign(e.style,{...kt("outlined"),color:b.text}),At(e),e.addEventListener("click",()=>{const o=ct;if(!o)return;const m=o.tests.some(s=>s.derived),u=[];for(let s=0;s<o.tests.length;s++)for(let a=s+1;a<o.tests.length;a++){const y=o.cells.find(x=>x.xIndex===a&&x.yIndex===s);y&&u.push({x:o.tests[a],y:o.tests[s],r:y.r,n:y.n})}_t([{header:"Test X",get:s=>ht(s.x.label)},{header:"Test X number",get:s=>s.x.testNumber},{header:"Test Y",get:s=>ht(s.y.label)},{header:"Test Y number",get:s=>s.y.testNumber},{header:"r",get:s=>s.r===null?"":s.r.toFixed(6)},{header:"n",get:s=>s.n},...m?[{header:`Test X ${bt.toLowerCase()}`,get:s=>xt(s.x)},{header:`Test Y ${bt.toLowerCase()}`,get:s=>xt(s.y)}]:[]],u,"test-correlation.csv",g.onSaveText)}),Q.appendChild(e)}const _=l.ownerDocument.createElement("div");Object.assign(_.style,{display:"flex",flexDirection:"column",gap:L.xs,marginBottom:L.sm}),l.insertBefore(_,$);const I=jt(l);Bt(H,l,I,"Cap on how many tests the matrix includes (strongest correlations kept first)");let Z=()=>{};function Et(e,o,m,u,s,a,y,x){_.innerHTML="";const T=St(y);if(T){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=y.sample?`${T} \u2014 r is an estimate, not the whole population.`:`${T}.`,Object.assign(f.style,{color:b.label,fontSize:j.body}),_.appendChild(f)}if(s.length>0){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=`\u26A0 Mixed ${s.join(", ")} within this set \u2014 correlations may be misleading (Simpson's paradox). Use Group by, or the Wafer picker, to narrow to a like-for-like set.`,Object.assign(f.style,{color:b.warnText,background:b.warnBg,border:`1px solid ${b.warnBorder}`,borderRadius:lt.control,padding:`${L.xs} ${L.md}`,fontSize:j.body}),_.appendChild(f)}const C=l.ownerDocument.createElement("span");Object.assign(C.style,{display:"inline-flex",alignItems:"center",gap:L.sm,color:b.label,fontSize:j.body,flexWrap:"wrap"});const B=l.ownerDocument.createElement("span");B.dataset.wmapCaption="1",B.textContent=(a!==null?`Pearson r \xB7 n \u2248 ${a.toLocaleString()} dies per pair \xB7 click a cell to view that pair in scatter \xB7`:"Pearson r \xB7 click a cell to view that pair in scatter \xB7")+(x?` ${Gt} ${Ut} \xB7`:""),C.appendChild(B);const i=l.ownerDocument.createElement("span");Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:L.xs});const S=l.ownerDocument.createElement("span");S.textContent="\u22121";const P=l.ownerDocument.createElement("span");Object.assign(P.style,{display:"inline-block",width:"64px",height:"8px",borderRadius:lt.control,border:`1px solid ${b.menuBorder}`,background:`linear-gradient(to right, ${rt}, ${b.menuBg}, ${st})`});const z=l.ownerDocument.createElement("span");z.textContent="+1",i.append(S,P,z),C.appendChild(i),_.appendChild(C);const v=l.ownerDocument.createElement("span");if(v.dataset.wmapCaption="1",Object.assign(v.style,{color:b.value,fontSize:j.body,fontWeight:"500"}),e===0&&o===0)v.textContent=u?`No significant correlations found \u2014 strongest pair: ${u.xLabel} \u2194 ${u.yLabel} (r = ${u.r.toFixed(2)})`:"No significant correlations found";else{const f=[];e>0&&f.push(`${e} strong (|r| \u2265 0.7)`),o>0&&f.push(`${o} moderate (0.4\u20130.7)`);const Y=e+o;let r=f.join(", ")+` pair${Y!==1?"s":""} found`;m>0&&(r+=` \xB7 ${m} weak pair${m!==1?"s":""} not shown`),v.textContent=r}_.appendChild(v)}function vt(e){if($.innerHTML="",e.tests.length<2)return Ft($,"Need at least two parametric tests for a correlation matrix."),()=>{};const o=l.ownerDocument.createElement("canvas");o.style.display="block",o.style.cursor="default",$.appendChild(o);const m=e.tests.length,u=r=>r.label.split(" (#")[0],s=Math.min(14,Dt(e.tests.map(r=>u(r).length))),a=s*6.5+8,y=10,x=Math.round(y*6.5*Math.sin(Math.PI/4))+14,T=14,C=28,B=44;let i=-1,S=-1;const P=96;function z(r){const c=Math.max(0,r-a),p=Math.floor(c/m);if(!Wt(l))return Math.max(T,Math.min(B,p));const n=Math.floor((Ht(l,$,o)-x-4)/m);return Math.max(T,Math.min(P,p,n))}const v=new Map;for(const r of e.cells){let c=v.get(r.yIndex);c||(c=[],v.set(r.yIndex,c)),c.push(r)}function f(){const r=Pt(l),c=q(r.bg)??[255,255,255],p=$.clientWidth,n=z(p),X=n*m,D=x+n*m+4,R=a+X,A=Yt(o,l,R,D);if(!A)return;const{ctx:t}=A;t.font=`${ft(-1)}px system-ui, sans-serif`,t.fillStyle=r.text,e.tests.forEach((k,w)=>{const M=u(k),N=M.length>y?`${M.slice(0,y-1)}\u2026`:M,et=a+w*n+n/2;t.save(),t.translate(et,x-4),t.rotate(-Math.PI/4),t.textAlign="left",t.textBaseline="bottom",t.fillStyle=w===i?r.text:r.textMuted,t.fillText(N,0,0),t.restore()}),e.tests.forEach((k,w)=>{const M=u(k),N=x+w*n,et=N+n/2;t.font=`${ft(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=w===S?r.text:r.textMuted,t.fillText(M.length>s?`${M.slice(0,s-1)}\u2026`:M,a-4,et),(v.get(w)??[]).forEach(dt=>{const nt=dt.xIndex,G=a+nt*n,$t=nt===i&&w===S,mt=nt===w,U=dt.r;if(U===null){t.fillStyle=r.border,t.globalAlpha=.4,t.fillRect(G+1,N+1,n-2,n-2),t.globalAlpha=1;return}let ot=r.bgHover;mt?t.fillStyle=r.bgHover:(ot=yt(U>=0?st:rt,c,Math.abs(U)),t.fillStyle=ot),t.fillRect(G+1,N+1,n-2,n-2),n>=C&&!mt&&(t.font=`${Math.min(10,n*.35)}px system-ui, sans-serif`,t.fillStyle=qt(ot),t.textAlign="center",t.textBaseline="middle",t.fillText(U.toFixed(2),G+n/2,N+n/2)),$t&&(t.strokeStyle=r.text,t.lineWidth=2,t.strokeRect(G+1,N+1,n-2,n-2),t.lineWidth=1)})}),t.strokeStyle=r.bg,t.lineWidth=1;for(let k=0;k<=m;k++){const w=a+k*n;t.beginPath(),t.moveTo(w,x),t.lineTo(w,x+m*n),t.stroke();const M=x+k*n;t.beginPath(),t.moveTo(a,M),t.lineTo(a+m*n,M),t.stroke()}}function Y(r){const c=o.getBoundingClientRect(),p=$.clientWidth,n=z(p),X=(r.clientX-c.left)*(o.width/pt(o)/c.width),D=(r.clientY-c.top)*(o.height/pt(o)/c.height),R=Math.floor((X-a)/n),A=Math.floor((D-x)/n);return R>=0&&R<m&&A>=0&&A<m?{xi:R,yi:A}:null}return o.addEventListener("mousemove",r=>{const c=Y(r);if(!c){I.style.display="none",o.style.cursor="default";return}const{xi:p,yi:n}=c,X=p===n;o.style.cursor=X||!W?"default":"pointer";const D=e.cells.find(t=>t.xIndex===p&&t.yIndex===n),R=e.tests[p].label,A=e.tests[n].label;X?I.innerHTML=`<strong>${K(R)}</strong>`:D?.r!==null&&D?.r!==void 0?I.innerHTML=`<strong>${K(u(e.tests[n]))}</strong> (#${e.tests[n].testNumber}) vs <strong>${K(u(e.tests[p]))}</strong> (#${e.tests[p].testNumber})<br>r = ${D.r.toFixed(4)} \xB7 n = ${D.n.toLocaleString()}${W?"<br><em>click to view in scatter</em>":""}`:I.innerHTML=`${K(`${A} vs ${R}`)}<br><em>insufficient data</em>`,I.style.display="block",Vt(I,l,r.clientX,r.clientY)}),o.addEventListener("mouseleave",()=>{I.style.display="none"}),o.addEventListener("click",r=>{const c=Y(r);if(!c||!W)return;const{xi:p,yi:n}=c;p!==n&&(i=p,S=n,f(),W(e.tests[p].testNumber,e.tests[n].testNumber))}),f}let ct=null;function tt(){const e=Mt(),o=e.flatMap(i=>i.dies??[]),m=It(o,O),{matrix:u,strongPairs:s,moderatePairs:a,hiddenWeakPairs:y,strongestPair:x}=Tt(m,{minTests:6,maxTests:F}),T=Rt(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),C=u.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,S)=>i-S),B=C.length?C[Math.floor(C.length/2)]:null;ct=u,Et(s,a,y,x,T,B,m,u.tests.some(i=>i.derived)),Z=vt(u),Z()}const Lt=Xt(l,()=>Z());return tt(),{card:l,destroy:()=>Lt.disconnect()}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type CompareWafer } from '../../stats/groupCompare.js';
|
|
2
|
+
import type { TestDef } from '../../renderer/buildWaferMap.js';
|
|
3
|
+
import { type SaveTextHandler } from '../toolbar.js';
|
|
4
|
+
export interface GroupComparisonPanelOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
/** The groups to compare: each a key and its wafers' dies. */
|
|
7
|
+
groups: ReadonlyArray<{
|
|
8
|
+
key: string;
|
|
9
|
+
items: ReadonlyArray<{
|
|
10
|
+
dies: CompareWafer['dies'];
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
13
|
+
testDefs: readonly TestDef[];
|
|
14
|
+
/** What the groups are ("Process split"), for the column heads and the method note. */
|
|
15
|
+
groupLabelText?: string;
|
|
16
|
+
/** The control group, or null for none. */
|
|
17
|
+
control: string | null;
|
|
18
|
+
onControlChange: (control: string | null) => void;
|
|
19
|
+
/** The test the other panels show: its row is marked. */
|
|
20
|
+
selectedTestNumber?: number;
|
|
21
|
+
/** A row was chosen: show this test in the other panels. */
|
|
22
|
+
onSelectTest: (testNumber: number) => void;
|
|
23
|
+
onSaveText?: SaveTextHandler;
|
|
24
|
+
ownerDocument?: Document;
|
|
25
|
+
}
|
|
26
|
+
export declare function renderGroupComparisonPanel(o: GroupComparisonPanelOptions): {
|
|
27
|
+
card: HTMLElement;
|
|
28
|
+
setTest: (n: number) => void;
|
|
29
|
+
destroy: () => void;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=groupComparison.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{compareTestsByGroup as I,formatP as y,groupKeys as X}from"../../stats/groupCompare.js";import{fmt as j}from"../../renderer/fmt.js";import{testLabel as F,unmarkedLabel as J}from"../../renderer/testLabel.js";import{CLR as i,FONT as G,SPACE as b,controlStyle as q,wireControlHover as R,wireTooltip as x}from"../toolbar.js";import{exportCsv as Q}from"../tableExport.js";import{cardShell as Y,guideCite as Z,makeListSelect as ee,renderEmptyState as V}from"./chartShell.js";import{GUIDE_SECTIONS as te}from"../../stats/guideSections.js";import{cardAbout as oe}from"./cardAbout.js";const v="\0none",ne=6;export function renderGroupComparisonPanel(r){const s=r.ownerDocument??document,T=r.groupLabelText??"group",{card:g,body:w,controlsRow:L,setAbout:K}=Y(r.title??`Comparison by ${T.toLowerCase()}`,void 0,s);K(oe("comparison")),g.dataset.wmapGroupComparison="1",g.style.gridColumn="1 / -1";const N=r.groups.flatMap(t=>t.items.map(e=>({dies:e.dies,group:t.key}))),p=X(N),a=r.control!==null&&p.includes(r.control)?r.control:null,u=I(N,r.testDefs,a??void 0),O=p.length<=ne?p:[],P=ee([{value:v,label:"No control: compare all groups"},...p.map(t=>({value:t,label:`Control: ${t}`}))],a??v,t=>r.onControlChange(t===v?null:t),{ownerDocument:s,ariaLabel:"Control group",hook:"compare-control"});if(L.appendChild(P),r.onSaveText&&u.length){const t=s.createElement("button");t.type="button",t.textContent="Comparison CSV",x(t,"Save this table as a CSV file, one row per test"),Object.assign(t.style,{...q("outlined"),color:i.text}),R(t),t.addEventListener("click",()=>Q([{header:"Test",get:e=>J(F(e.test,e.test.testNumber))},{header:"Test number",get:e=>e.test.testNumber},{header:"Unit",get:e=>e.test.unit??""},...p.flatMap(e=>[{header:`${e} wafers`,get:o=>o.comparison.groups.find(n=>n.key===e)?.n??0},{header:`${e} mean`,get:o=>c(o.comparison.groups.find(n=>n.key===e)?.mean)},...a&&e!==a?[{header:`${e} minus ${a}`,get:o=>c(o.comparison.contrasts?.find(n=>n.key===e)?.delta)},{header:`${e} vs ${a} p (Holm)`,get:o=>c(o.comparison.contrasts?.find(n=>n.key===e)?.pAdjusted)}]:[]]),{header:"Welch p",get:e=>c(e.comparison.welch?.p)},{header:"Kruskal-Wallis p",get:e=>c(e.comparison.kruskal?.p)},{header:"q (Benjamini-Hochberg)",get:e=>c(e.pAdjusted)},{header:"Largest shift (wafer SDs)",get:e=>c(e.effect)},{header:"Largest shift (share of limit window)",get:e=>c(e.windowShare)},{header:"Note",get:e=>e.comparison.issue??""}],u,"group-comparison.csv",r.onSaveText)),L.appendChild(t)}if(p.length<2)return V(w,`Needs two or more ${T.toLowerCase()} groups to compare.`),{card:g,setTest:()=>{},destroy:()=>{}};if(u.length===0)return V(w,"No measured test has values in these wafers."),{card:g,setTest:()=>{},destroy:()=>{}};const C=s.createElement("div"),U=p.map(t=>`${t} ${N.filter(e=>e.group===t).length}`).join(", ");C.textContent=`Each wafer is one value, the mean of its dies, so n is wafers (${U}). Welch: Welch's ANOVA (Welch's t for two groups). Rank: Kruskal\u2013Wallis${u.some(t=>t.comparison.kruskal?.approximate)?", approximate with fewer than five wafers in a group":""}. q: Benjamini\u2013Hochberg across the ${u.length} tests, which the table is ranked by.`+(a?` Each group's difference from ${a} has a Holm-adjusted p.`:"")+" ",C.append(Z(s,te.groups),"."),Object.assign(C.style,{color:i.label,fontSize:G.body,marginBottom:b.sm}),w.appendChild(C);const S=s.createElement("div");Object.assign(S.style,{overflow:"auto",maxHeight:"420px",border:`1px solid ${i.menuBorder}`});const $=s.createElement("table");Object.assign($.style,{borderCollapse:"collapse",width:"100%",fontSize:G.body,fontVariantNumeric:"tabular-nums"});const B=s.createElement("thead"),W=s.createElement("tr"),f=(t,e,o="right")=>{const n=s.createElement("th");n.scope="col",n.textContent=t,e&&x(n,e),Object.assign(n.style,{position:"sticky",top:"0",background:i.menuBg,textAlign:o,padding:`${b.xs} ${b.sm}`,borderBottom:`1px solid ${i.menuBorder}`,color:i.label,fontWeight:"600",whiteSpace:"nowrap"}),W.appendChild(n)};f("Test",void 0,"left");for(const t of O)f(t===a?`${t} (control)`:t,a&&t!==a?`Mean of the wafer means, and the difference from ${a}`:"Mean of the wafer means");f("Welch p","Do the group means differ? Welch\u2019s ANOVA on wafer means, not assuming equal spreads"),f("Rank p","The same question on ranks (Kruskal\u2013Wallis): one odd wafer cannot drive it"),f("q","Welch p adjusted for the number of tests compared (Benjamini\u2013Hochberg); the table is ranked by it"),f("Largest shift","The largest difference between group means: in wafer-to-wafer standard deviations, and as a share of the limit window where the test has both limits"),B.appendChild(W),$.appendChild(B);const D=s.createElement("tbody"),M=new Map,h=(t,e,o={})=>{const n=s.createElement("td");typeof e=="string"?n.textContent=e:n.appendChild(e),o.title&&x(n,o.title),Object.assign(n.style,{padding:`${b.xs} ${b.sm}`,textAlign:o.align??"right",borderBottom:`1px solid ${i.menuBorder}`,whiteSpace:"nowrap",fontWeight:o.strong?"700":"400",color:o.muted?i.label:i.text}),t.appendChild(n)};for(const t of u){const e=s.createElement("tr"),o=t.comparison,n=t.test.unit,d=s.createElement("button");d.type="button",d.textContent=F(t.test,t.test.testNumber),d.dataset.wmapCompareTest=String(t.test.testNumber),x(d,`Show ${d.textContent} in the panels below${o.issue?`. ${o.issue}`:""}`),Object.assign(d.style,{...q("bare"),padding:"0",textAlign:"left",color:i.text,textDecoration:"underline",textDecorationColor:i.menuBorder}),R(d,"bare"),d.addEventListener("click",()=>{r.onSelectTest(t.test.testNumber),k(t.test.testNumber)}),h(e,d,{align:"left"});for(const E of O){const l=o.groups.find(A=>A.key===E),m=o.contrasts?.find(A=>A.key===E),H=l&&l.n?j(l.mean,n):"\u2014",_=m&&Number.isFinite(m.delta)?`${H} (${m.delta>=0?"+":""}${j(m.delta,n)}, p ${y(m.pAdjusted)})`:H;h(e,_,{title:l?`${E}: ${l.n} wafer${l.n===1?"":"s"}${l.n>=2?`, wafer-to-wafer SD ${j(l.sd,n)}`:""}`:void 0,muted:!l||l.n<2,strong:!!m&&m.pAdjusted<.05})}h(e,y(o.welch?.p??NaN),{title:o.issue}),h(e,y(o.kruskal?.p??NaN)),h(e,y(t.pAdjusted),{strong:t.pAdjusted<.05});const z=Number.isFinite(t.effect)?`${Math.abs(t.effect).toFixed(1)} SD${t.windowShare!==void 0?` \xB7 ${Math.abs(t.windowShare*100).toFixed(0)}% of limits`:""}`:"\u2014";h(e,z),M.set(t.test.testNumber,e),D.appendChild(e)}$.appendChild(D),S.appendChild($),w.appendChild(S);function k(t){for(const[e,o]of M)o.style.background=e===t?i.bgActive:"",e===t?o.setAttribute("aria-current","true"):o.removeAttribute("aria-current")}return k(r.selectedTestNumber),{card:g,setTest:k,destroy:()=>{}}}const c=r=>r===void 0||!Number.isFinite(r)?"":String(r);
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
export { renderCapabilityPanel } from './capability.js';
|
|
2
2
|
export type { CapabilityPanelOptions, CapabilityPanelHandle } from './capability.js';
|
|
3
|
-
export { renderBoxplotPanel } from './boxplot.js';
|
|
4
|
-
export type { BoxplotPanelOptions, BoxplotPanelHandle } from './boxplot.js';
|
|
5
|
-
export { renderHistogramPanel } from './histogram.js';
|
|
6
|
-
export type { HistogramPanelOptions, HistogramPanelHandle } from './histogram.js';
|
|
7
3
|
export { renderCorrelationPanel } from './correlation.js';
|
|
8
4
|
export type { CorrelationPanelOptions, CorrelationPanelHandle } from './correlation.js';
|
|
9
|
-
export { renderScatterPanel } from './scatter.js';
|
|
10
|
-
export type { ScatterPanelOptions, ScatterPanelHandle } from './scatter.js';
|
|
11
|
-
export { renderBarPanel } from './barPanel.js';
|
|
12
|
-
export type { ChartPanel, BarPanelHandle } from './barPanel.js';
|
|
13
|
-
export { renderBinClusterPanel } from './binCluster.js';
|
|
14
|
-
export type { BinClusterPanelOptions, BinClusterPanelHandle } from './binCluster.js';
|
|
15
5
|
export * from './chartShell.js';
|
|
16
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{renderCapabilityPanel}from"./capability.js";export{
|
|
1
|
+
export{renderCapabilityPanel}from"./capability.js";export{renderCorrelationPanel}from"./correlation.js";export*from"./chartShell.js";
|