@wafertools/wafermap 0.40.0 → 0.41.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 +20 -21
- package/CHANGELOG.md +154 -0
- package/README.md +6 -6
- package/dist/packages/canvas-adapter/canvasTheme.d.ts +12 -0
- package/dist/packages/canvas-adapter/canvasTheme.js +1 -1
- package/dist/packages/canvas-adapter/cellShade.d.ts +2 -2
- package/dist/packages/canvas-adapter/cellShade.js +1 -1
- package/dist/packages/canvas-adapter/chartPopulation.d.ts +3 -0
- package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +2 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +47 -27
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/commonality.js +4 -4
- package/dist/packages/canvas-adapter/charts/correlation.d.ts +6 -12
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +45 -15
- package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -1
- package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
- package/dist/packages/canvas-adapter/charts/palette.d.ts +16 -30
- package/dist/packages/canvas-adapter/charts/palette.js +1 -1
- package/dist/packages/canvas-adapter/charts/patCard.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +29 -3
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/sweep.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
- package/dist/packages/canvas-adapter/chromeRow.d.ts +68 -0
- package/dist/packages/canvas-adapter/chromeRow.js +1 -0
- package/dist/packages/canvas-adapter/chunked.d.ts +6 -0
- package/dist/packages/canvas-adapter/chunked.js +1 -1
- package/dist/packages/canvas-adapter/columnFilterPopup.d.ts +25 -0
- package/dist/packages/canvas-adapter/columnFilterPopup.js +1 -0
- package/dist/packages/canvas-adapter/composePng.d.ts +37 -0
- package/dist/packages/canvas-adapter/composePng.js +1 -0
- package/dist/packages/canvas-adapter/dataTab.d.ts +39 -6
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.js +1 -1
- package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +3 -1
- package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
- package/dist/packages/canvas-adapter/drilldown.d.ts +20 -1
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
- package/dist/packages/canvas-adapter/filterButton.js +1 -1
- package/dist/packages/canvas-adapter/filterEditor.d.ts +5 -0
- package/dist/packages/canvas-adapter/filterEditor.js +1 -1
- package/dist/packages/canvas-adapter/guideWindow.js +1 -1
- package/dist/packages/canvas-adapter/icons.js +1 -1
- package/dist/packages/canvas-adapter/identityHeader.d.ts +5 -0
- package/dist/packages/canvas-adapter/identityHeader.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +7 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +32 -9
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/maplessSummary.d.ts +4 -2
- package/dist/packages/canvas-adapter/maplessSummary.js +1 -1
- package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
- package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
- package/dist/packages/canvas-adapter/panelChart.d.ts +7 -0
- package/dist/packages/canvas-adapter/panelChart.js +1 -0
- package/dist/packages/canvas-adapter/panelTable.d.ts +50 -0
- package/dist/packages/canvas-adapter/panelTable.js +1 -0
- package/dist/packages/canvas-adapter/plotCard.js +1 -1
- package/dist/packages/canvas-adapter/plotEditor.d.ts +12 -0
- package/dist/packages/canvas-adapter/plotEditor.js +10 -10
- package/dist/packages/canvas-adapter/plotItems.d.ts +9 -4
- package/dist/packages/canvas-adapter/plotItems.js +1 -1
- package/dist/packages/canvas-adapter/plotJsonComplete.js +1 -1
- package/dist/packages/canvas-adapter/plotModal.d.ts +7 -0
- 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 +60 -2
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +7 -0
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +41 -9
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/reportCharts.d.ts +41 -0
- package/dist/packages/canvas-adapter/reportCharts.js +1 -0
- package/dist/packages/canvas-adapter/reportExport.d.ts +91 -0
- package/dist/packages/canvas-adapter/reportExport.js +1 -0
- package/dist/packages/canvas-adapter/reportFigures.d.ts +29 -0
- package/dist/packages/canvas-adapter/reportFigures.js +1 -0
- package/dist/packages/canvas-adapter/reportRun.d.ts +9 -0
- package/dist/packages/canvas-adapter/reportRun.js +1 -0
- package/dist/packages/canvas-adapter/selectionOverlay.d.ts +12 -0
- package/dist/packages/canvas-adapter/selectionOverlay.js +1 -0
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +152 -111
- package/dist/packages/canvas-adapter/summaryPanel.js +7 -4
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -1
- package/dist/packages/canvas-adapter/tableDrilldown.d.ts +48 -0
- package/dist/packages/canvas-adapter/tableDrilldown.js +1 -0
- package/dist/packages/canvas-adapter/tableFilter.d.ts +42 -0
- package/dist/packages/canvas-adapter/tableFilter.js +1 -0
- package/dist/packages/canvas-adapter/tablePlots.d.ts +85 -0
- package/dist/packages/canvas-adapter/tablePlots.js +1 -0
- package/dist/packages/canvas-adapter/themeWatch.d.ts +7 -0
- package/dist/packages/canvas-adapter/themeWatch.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.d.ts +3 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +125 -36
- 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 +530 -414
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
- package/dist/packages/canvas-adapter/virtualTable.d.ts +37 -7
- package/dist/packages/canvas-adapter/virtualTable.js +1 -1
- package/dist/packages/core/aggregates.d.ts +14 -0
- package/dist/packages/core/aggregates.js +1 -1
- package/dist/packages/core/dies.d.ts +7 -0
- package/dist/packages/core/dies.js +1 -1
- package/dist/packages/core/utils.d.ts +2 -0
- package/dist/packages/core/utils.js +1 -1
- package/dist/packages/experimental/charts.d.ts +4 -0
- package/dist/packages/experimental/charts.js +1 -0
- package/dist/packages/renderer/binColors.d.ts +6 -2
- package/dist/packages/renderer/binColors.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +36 -14
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +8 -0
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/categoryColors.d.ts +3 -0
- package/dist/packages/renderer/categoryColors.js +1 -0
- package/dist/packages/renderer/colorMap.d.ts +15 -16
- package/dist/packages/renderer/colorMap.js +1 -1
- package/dist/packages/renderer/colorSchemes.d.ts +34 -30
- package/dist/packages/renderer/colorSchemes.js +1 -1
- package/dist/packages/renderer/dataColors.d.ts +126 -0
- package/dist/packages/renderer/dataColors.js +1 -0
- package/dist/packages/renderer/deprecate.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +16 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +2 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/renderer/spec.d.ts +5 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/stacks.d.ts +21 -0
- package/dist/packages/renderer/stacks.js +1 -0
- package/dist/packages/renderer/timeAxis.d.ts +19 -0
- package/dist/packages/renderer/timeAxis.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +2 -4
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/binRows.js +1 -1
- package/dist/packages/stats/binShifts.d.ts +59 -0
- package/dist/packages/stats/binShifts.js +1 -0
- package/dist/packages/stats/capability.d.ts +6 -1
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/chartCatalogue.d.ts +3 -0
- package/dist/packages/stats/chartCatalogue.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/columnPlot.d.ts +38 -0
- package/dist/packages/stats/columnPlot.js +1 -0
- package/dist/packages/stats/commonality.d.ts +8 -1
- package/dist/packages/stats/commonality.js +1 -1
- package/dist/packages/stats/correlation.d.ts +7 -2
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/dataTable.d.ts +44 -0
- package/dist/packages/stats/dataTable.js +1 -0
- package/dist/packages/stats/dieRegions.js +1 -1
- package/dist/packages/stats/examplePicks.js +1 -1
- package/dist/packages/stats/facets.d.ts +11 -0
- package/dist/packages/stats/facets.js +1 -1
- package/dist/packages/stats/filterFindings.d.ts +21 -0
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/groupEffects.d.ts +8 -0
- package/dist/packages/stats/groupEffects.js +1 -1
- package/dist/packages/stats/math.d.ts +2 -0
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/overview.d.ts +114 -0
- package/dist/packages/stats/overview.js +1 -0
- package/dist/packages/stats/pat.d.ts +0 -2
- package/dist/packages/stats/pat.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +20 -3
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/permutationNull.d.ts +16 -0
- package/dist/packages/stats/permutationNull.js +1 -0
- package/dist/packages/stats/plotData.d.ts +138 -12
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +10 -1
- package/dist/packages/stats/plotSpec.js +3 -3
- package/dist/packages/stats/plotTable.js +1 -1
- package/dist/packages/stats/plotWords.d.ts +52 -0
- package/dist/packages/stats/plotWords.js +1 -0
- package/dist/packages/stats/presentation.d.ts +63 -14
- package/dist/packages/stats/presentation.js +1 -1
- package/dist/packages/stats/presentationPresets.d.ts +35 -0
- package/dist/packages/stats/presentationPresets.js +1 -0
- package/dist/packages/stats/presentationSections.d.ts +83 -0
- package/dist/packages/stats/presentationSections.js +1 -0
- package/dist/packages/stats/renderSummaryReport.d.ts +80 -2
- package/dist/packages/stats/renderSummaryReport.js +1 -67
- package/dist/packages/stats/reportBlocks.d.ts +249 -0
- package/dist/packages/stats/reportBlocks.js +1 -0
- package/dist/packages/stats/reportContents.d.ts +22 -0
- package/dist/packages/stats/reportContents.js +1 -0
- package/dist/packages/stats/reportDeck.d.ts +245 -0
- package/dist/packages/stats/reportDeck.js +212 -0
- package/dist/packages/stats/reportHtml.d.ts +44 -43
- package/dist/packages/stats/reportHtml.js +82 -46
- package/dist/packages/stats/reportMaps.d.ts +67 -0
- package/dist/packages/stats/reportMaps.js +1 -0
- package/dist/packages/stats/reportSections.d.ts +55 -0
- package/dist/packages/stats/reportSections.js +1 -0
- package/dist/packages/stats/sweep.d.ts +14 -6
- package/dist/packages/stats/sweep.js +1 -1
- package/dist/packages/stats/synthesis.d.ts +87 -10
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/types.d.ts +22 -0
- package/dist/packages/stats/worthItems.d.ts +15 -0
- package/dist/packages/stats/worthItems.js +1 -0
- package/dist/packages/stats/yield.d.ts +13 -0
- package/dist/packages/stats/yield.js +1 -1
- package/llms.txt +1 -1
- package/package.json +6 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type SweepSpec } from '../../stats/sweep.js';
|
|
2
2
|
import type { Die } from '../../core/dies.js';
|
|
3
3
|
import type { TestDef } from '../../renderer/buildWaferMap.js';
|
|
4
|
+
import type { ReaderColors } from './divergingScale.js';
|
|
4
5
|
import { type SaveImageHandler } from './chartShell.js';
|
|
5
6
|
export interface SweepPanelOptions {
|
|
6
7
|
/** The curve definition. Title comes from here, not from the panel. */
|
|
@@ -28,6 +29,8 @@ export interface SweepPanelOptions {
|
|
|
28
29
|
label: string;
|
|
29
30
|
}, e: MouseEvent) => void;
|
|
30
31
|
ownerDocument?: Document;
|
|
32
|
+
/** The reader's colours: a series without a colour of its own takes the next colour of their data colour scheme. */
|
|
33
|
+
readerColors?: ReaderColors;
|
|
31
34
|
}
|
|
32
35
|
export interface SweepPanelHandle {
|
|
33
36
|
card: HTMLElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildSweepData as
|
|
1
|
+
import{buildSweepData as me}from"../../stats/sweep.js";import{testsNotInLot as xe}from"../../stats/plotData.js";import{sweepToPlot as ge}from"../../stats/plotSpec.js";import{fmt as D}from"../../renderer/fmt.js";import{SPACE as oe,fontPx as be,FONT as ie,CLR as Y,ALPHA as ye}from"../toolbar.js";import{categorical as $e}from"./palette.js";import{cardShell as ve,observeResize as Te,onRepaint as Se,makeTooltip as Le,positionChartTooltip as Me,renderEmptyState as re,chartFillHeight as Pe,populationPhrase as we,PADDING as J,prepareCanvas as ke,makeAxisFormat as Ce,VERTICAL_TICK_SPACING_PX as Ae}from"./chartShell.js";import{fitTicks as Ee}from"../../renderer/axisTicks.js";import{escHtml as x}from"../../core/utils.js";import{unmarkedLabel as Ie,derivedTestNote as De,DERIVED_MARK as Q,DERIVED_KEY as Ne}from"../../renderer/testLabel.js";import{plotAbout as He}from"./cardAbout.js";function N(f,g){return g?D(f,g).replace(/(\.\d*?)0+(?=\D|$)/,"$1").replace(/\.(?=\D|$)/,""):Number.isInteger(f)?String(f):String(Number(f.toPrecision(3)))}function le(f){const g=Ie(f.label),E=g.length>9?`${g.slice(0,8)}\u2026`:g;return f.derived?`${Q} ${E}`:E}const ae=260,Re=62,Be=56,Xe=3;function _e(f,g){const E=f.series[0]?.points[0]?.testNumber;return E===void 0?void 0:g?.find(z=>z.testNumber===E)?.unit}export function renderSweepPanel(f){const{testDefs:g,onSaveImage:E,population:z}=f;let v=f.spec,V=f.dies;const{card:b,body:M,heading:ce,controlsRow:fe,setAbout:de,setCardId:pe}=ve(v.title,E,f.ownerDocument);pe(v.id),de(He({id:v.id,chart:"sweep"})),b.style.alignSelf="start";const K=b.ownerDocument,H=K.createElement("div");H.dataset.wmapCaption="1",Object.assign(H.style,{color:Y.label,fontSize:ie.body,marginBottom:oe.sm}),b.insertBefore(H,M);const U=K.createElement("div");Object.assign(U.style,{color:Y.label,fontSize:ie.body,marginTop:oe.sm}),b.appendChild(U);const P=Le(b);let W=null,L=null,T;const X=s=>v.series[s]?.color??$e(s,f.readerColors?.dataColors);function F(){if(M.innerHTML="",U.innerHTML="",W?.disconnect(),W=null,v.series.length===0){H.textContent="",re(M,"This sweep defines no series.");return}if(L=me(V,g,v),T=_e(L,g),L.series.filter(n=>n.points.some(a=>a.count>0)).length===0){H.textContent="";const n=xe(ge(v),g??[]);re(M,n?`${n}.`:"No values recorded for the tests in this sweep."),Z();return}H.textContent=`Line = median across ${we(L.dieCount,V.length,z)}, band = p10\u2013p90`+(v.series.length>2?" \xB7 crossing and separation measured between the first two series":"")+(f.onSelectPoint?" \xB7 click a level to chart or tabulate the dies measured there":"");const c=K.createElement("canvas");c.style.display="block",M.appendChild(c);let i=null;const w=()=>{const n=L;if(n===null)return;const a=Math.max(1,M.clientWidth),p=Math.max(ae,Pe(b,M,c,ae)),y=ke(c,b,a,p);if(!y)return;const{ctx:e,theme:d}=y,$=t=>n.xScale==="log"?Math.log10(t):t;let l=1/0,o=-1/0,h=1/0,m=-1/0;for(const t of n.series)for(const r of t.points)r.count!==0&&(l=Math.min(l,r.p10),o=Math.max(o,r.p90),h=Math.min(h,$(r.x)),m=Math.max(m,$(r.x)));for(const t of n.separations)l=Math.min(l,t.y),o=Math.max(o,t.y);if(!Number.isFinite(l)||!Number.isFinite(o))return;l===o&&(l-=1,o+=1);const ee=(o-l)*.08;if(l-=ee,o+=ee,h===m&&(h-=.5,m+=.5),n.xScale==="log"){const t=(m-h)*.03;h-=t,m+=t}e.font=`${be(-1)}px system-ui, sans-serif`;const S=J+Re,R=a-J-8,_=J,k=p-Be,C=t=>k-(t-l)/(o-l)*(k-_),B=t=>S+($(t)-h)/(m-h)*(R-S);i={left:S,right:R,xLo:h,xHi:m,yOf:C,ax:$},e.strokeStyle=d.border,e.lineWidth=1,e.beginPath(),e.moveTo(S,_),e.lineTo(S,k),e.lineTo(R,k),e.stroke(),e.fillStyle=d.text,e.textAlign="right",e.textBaseline="middle";const te=Ee(l,o,k-_,()=>Ae),ue=Ce(Math.max(Math.abs(l),Math.abs(o)),T,te.step||void 0);for(const t of te.ticks)e.fillText(ue.tickWithUnit(t),S-6,C(t));for(const t of n.separations){const r=C(t.y);e.save(),e.strokeStyle=d.limitLine,e.globalAlpha=.55,e.setLineDash([4,3]),e.beginPath(),e.moveTo(S,r),e.lineTo(R,r),e.stroke(),e.restore()}if(n.series.forEach((t,r)=>{const A=t.points.filter(u=>u.count>0);if(!(A.length<2)){e.save(),e.fillStyle=X(r),e.globalAlpha=.14,e.beginPath(),A.forEach((u,I)=>{const O=B(u.x),se=C(u.p90);I===0?e.moveTo(O,se):e.lineTo(O,se)});for(let u=A.length-1;u>=0;u--){const I=A[u];e.lineTo(B(I.x),C(I.p10))}e.closePath(),e.fill(),e.restore()}}),n.series.forEach((t,r)=>{e.strokeStyle=X(r),e.lineWidth=1.75,e.beginPath();let A=!1;for(const u of t.points){if(u.count===0){A=!1;continue}const I=B(u.x),O=C(u.median);A?e.lineTo(I,O):e.moveTo(I,O),A=!0}e.stroke(),e.fillStyle=X(r);for(const u of t.points)u.count!==0&&(e.beginPath(),e.arc(B(u.x),C(u.median),Xe,0,Math.PI*2),e.fill())}),n.crossing){const t=B(n.crossing.x),r=C(n.crossing.y);e.save(),e.strokeStyle=d.text,e.globalAlpha=.45,e.setLineDash([3,3]),e.beginPath(),e.moveTo(t,r),e.lineTo(t,k),e.stroke(),e.restore(),e.save(),e.strokeStyle=d.text,e.lineWidth=2,e.beginPath(),e.arc(t,r,5.5,0,Math.PI*2),e.stroke(),e.restore()}e.fillStyle=d.text,e.textBaseline="top",e.textAlign="center";const G=n.xIsPhysical?[...new Set(n.series.flatMap(t=>t.points.map(r=>r.x)))].sort((t,r)=>t-r).map(t=>({x:t,label:N(t,n.xUnit)})):(n.series[0]?.points??[]).map(t=>({x:t.x,label:le(t)})),he=Math.max(1,Math.ceil(G.length*46/Math.max(1,R-S)));G.forEach((t,r)=>{r%he!==0&&r!==G.length-1||e.fillText(t.label,B(t.x),k+6)}),e.save(),e.fillStyle=d.text,e.globalAlpha=.75,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.xLabel,(S+R)/2,p-4),e.restore(),e.save(),e.fillStyle=d.text,e.globalAlpha=.75,e.translate(12,(_+k)/2),e.rotate(-Math.PI/2),e.textBaseline="top",e.fillText(n.yLabel+(T?` (${T})`:""),0,0),e.restore(),e.textAlign="left",e.textBaseline="middle";let j=S+4;const ne=_+8;n.series.forEach((t,r)=>{e.fillStyle=X(r),e.fillRect(j,ne-4,10,3),j+=14,e.fillStyle=d.text,e.fillText(t.label,j,ne),j+=e.measureText(t.label).width+16})};w(),W=Te(M,w);const q=n=>{const a=L;if(a===null||i===null)return null;const p=n.clientX-c.getBoundingClientRect().left,y=i.xLo+(p-i.left)/Math.max(1,i.right-i.left)*(i.xHi-i.xLo);let e=null;for(const d of a.series)for(const $ of d.points){if($.count===0)continue;const l=Math.abs(i.ax($.x)-y);(e===null||l<e.dist)&&(e={x:$.x,dist:l})}return e===null?null:e.x};if(c.addEventListener("mousemove",n=>{const a=L,p=q(n);if(a===null||p===null){P.style.display="none";return}const y={x:p},e=a.series.map(o=>o.points.find(h=>h.x===y.x&&h.count>0)),d=a.series.map((o,h)=>{const m=e[h];return m===void 0?"":`<span style="color:${X(h)}">\u25A0</span> ${m.derived?`${Q} `:""}${x(o.label)}: <strong>${x(D(m.median,T))}</strong><br><span style="opacity:${ye.muted}">p10 ${x(D(m.p10,T))} \u2013 p90 ${x(D(m.p90,T))} \xB7 n=${m.count.toLocaleString()}</span>`}).filter(Boolean);if(d.length===0){P.style.display="none";return}const $=a.series.flatMap(o=>o.points).find(o=>o.x===y.x&&o.count>0),l=[...new Set(e.map(o=>De(o)).filter(o=>o!==void 0))];P.innerHTML=`<strong>${x($?.label??"")}</strong><br>`+d.join("<br>")+l.map(o=>`<br><em>${x(o)}</em>`).join(""),P.style.display="block",Me(P,b,n.clientX,n.clientY)}),c.addEventListener("mouseleave",()=>{P.style.display="none"}),f.onSelectPoint){c.style.cursor="pointer";const n=a=>{const p=L,y=q(a);if(p===null||y===null)return!1;const e=p.series.flatMap(l=>l.points.filter(o=>o.x===y&&o.count>0));if(e.length===0)return!1;P.style.display="none";const d=/^(.*?)\s*\(([^)]+)\)\s*$/.exec(p.xLabel),$=p.xIsPhysical?p.xUnit||!d?`${p.xLabel} ${N(y,p.xUnit)}`:`${d[1]} ${N(y)} ${d[2]}`:le(e[0]);return f.onSelectPoint({testNumbers:e.map(l=>l.testNumber),label:$},a),!0};c.addEventListener("click",a=>{n(a)}),c.addEventListener("contextmenu",a=>{n(a)&&a.preventDefault()})}Z()}function Z(){const s=L;if(s===null)return;const c=[];s.notMeasured!==void 0?c.push(`<strong>Crossing and widths:</strong> not measured \u2014 ${x(s.notMeasured)}`):s.crossing?c.push(`<strong>Crossing:</strong> ${x(`${s.xLabel} = ${N(s.crossing.x,s.xUnit)}`)} \xB7 ${x(`${s.yLabel} ${D(s.crossing.y,T)}`)}`+(s.crossing.multiple?" <em>(first of several \u2014 the curves cross more than once)</em>":"")):(v.crossing??!0)&&v.series.length>=2&&c.push("<strong>Crossing:</strong> the first two series do not cross over the swept range");for(const i of s.separations)if(i.distance!==null){const w=i.ratio!==void 0&&i.from!==void 0&&i.to!==void 0?`\xD7${Number(i.ratio.toPrecision(3))} on the ${s.xLabel} axis (${N(i.from,s.xUnit)} \u2192 ${N(i.to,s.xUnit)})`:`${N(i.distance,s.xUnit)} on the ${s.xLabel} axis`;c.push(`<strong>Width at ${x(D(i.y,T))}:</strong> ${x(w)}`)}else{const w=i.reason==="second-series-never-reaches"?s.series[1]?.label:s.series[0]?.label;c.push(`<strong>Width at ${x(D(i.y,T))}:</strong> not measurable \u2014 ${x(w??"a series")} never reaches this level`)}s.series.some(i=>i.points.some(w=>w.derived))&&c.push(`${Q} ${x(Ne)} \u2014 hover a point for the expression`);for(const i of s.warnings)c.push(`<span style="color:${Y.errText}">${x(i)}</span>`);U.innerHTML=c.join("<br>")}return F(),Se(b,()=>F()),{card:b,destroy:()=>{W?.disconnect(),P.remove(),b.remove()},setDies:s=>{V=s,F()},setSpec:s=>{v=s,ce.textContent=s.title,b.dataset.wmapChartTitle=s.title,F()},actions:fe}}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare const FIT_STEP: {
|
|
2
|
+
readonly modeName: 1;
|
|
3
|
+
readonly label: 2;
|
|
4
|
+
readonly caret: 3;
|
|
5
|
+
readonly tight: 4;
|
|
6
|
+
};
|
|
7
|
+
/** The row's own look: one surface, so the controls read as one bar rather than a box per group. */
|
|
8
|
+
export declare function styleChromeSurface(row: HTMLElement): void;
|
|
9
|
+
/** A divider between zones. Hidden by `syncChromeSeparators` when it would sit at an edge or beside another. */
|
|
10
|
+
export declare function chromeSeparator(doc: Document, order: number): HTMLDivElement;
|
|
11
|
+
/**
|
|
12
|
+
* Give an icon button (from `makeBtn`) a word and, for a menu, a ▾ after its icon. The word and the ▾ carry the steps
|
|
13
|
+
* at which the row drops them, and the button's padding follows whether a word is showing (see `fitChromeRow`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function labelChromeButton(btn: HTMLButtonElement, label: string, opts?: {
|
|
16
|
+
menu?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
/**
|
|
19
|
+
* Turn a text button made elsewhere (Filter…, built before the toolbar's helpers exist) into a chrome-row button: its
|
|
20
|
+
* icon, then its word, in the look of the row's other buttons. Its click and tooltip are kept.
|
|
21
|
+
*/
|
|
22
|
+
export declare function chromeButtonFrom(btn: HTMLButtonElement, iconKey: string, label: string, opts?: {
|
|
23
|
+
menu?: boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
/** The ▾ after a menu button's word. */
|
|
26
|
+
export declare function chromeCaret(doc: Document, hideAt: number): HTMLSpanElement;
|
|
27
|
+
/**
|
|
28
|
+
* Hide every divider that has nothing visible on one side of it, or another divider right before it, so hiding a
|
|
29
|
+
* control (a mode with no log scale, Insights with no map tools) never leaves two dividers together or one at an edge.
|
|
30
|
+
*/
|
|
31
|
+
export declare function syncChromeSeparators(row: HTMLElement): void;
|
|
32
|
+
export interface ChromeFit {
|
|
33
|
+
/** Fit the row again now, after its contents changed. */
|
|
34
|
+
refit(): void;
|
|
35
|
+
/** The step the row needed last time, 0 when everything shows. */
|
|
36
|
+
step(): number;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
export interface ChromeFitOptions {
|
|
40
|
+
/** True when the identity's own name is cut: the row does not fit while it is. */
|
|
41
|
+
labelCut?: () => boolean;
|
|
42
|
+
/** Let the identity decide again whether its metadata line fits, before the row is measured. */
|
|
43
|
+
refitIdentity?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* A second arrangement for a view with more to show than the row may hold: `arrange(true)` puts the extra controls
|
|
46
|
+
* in the row, `arrange(false)` puts them elsewhere. The rich arrangement is kept while the row fits it with every
|
|
47
|
+
* word but the mode's (steps 0 and 1).
|
|
48
|
+
*/
|
|
49
|
+
arrange?: (rich: boolean) => void;
|
|
50
|
+
/** False while the row is not a chrome row (a gallery card's map, whose row holds only its tools): nothing is fitted. */
|
|
51
|
+
active?: () => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* A step the row may not go below, or null. The row's controls change between the views (Insights hides several), so
|
|
54
|
+
* left alone each view would fit its own way and the words on the buttons would come and go as the reader switches,
|
|
55
|
+
* moving the controls that are meant to stay put. The host holds the step the map view needed while Insights is open.
|
|
56
|
+
*/
|
|
57
|
+
hold?: () => number | null;
|
|
58
|
+
}
|
|
59
|
+
/** Fit a chrome row by the steps above, now and whenever its width changes. */
|
|
60
|
+
export declare function fitChromeRow(row: HTMLElement, opts?: ChromeFitOptions): ChromeFit;
|
|
61
|
+
/**
|
|
62
|
+
* Restyle the Map | Insights switch for the row: no box or shadow of its own (the row is the surface), and narrower
|
|
63
|
+
* at the last step. Its buttons keep their own selected look.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fitViewSwitch(el: HTMLElement): void;
|
|
66
|
+
/** The Export menu's icon, for a host or test that looks for it by name. */
|
|
67
|
+
export declare const EXPORT_ICON: string;
|
|
68
|
+
//# sourceMappingURL=chromeRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CLR as d,FONT as u,LEADING as S,RADIUS as h,SHADOW as b,SPACE as c}from"./toolbar.js";import{ICONS as g}from"./icons.js";export const FIT_STEP={modeName:1,label:2,caret:3,tight:4};const y=4;export function styleChromeSurface(e){e.dataset.wmapChromeRow="1",Object.assign(e.style,{display:"flex",alignItems:"center",flexWrap:"nowrap",gap:"2px",minHeight:"40px",boxSizing:"border-box",padding:`0 ${c.sm}`,background:d.menuBg,border:`1px solid ${d.menuBorder}`,borderRadius:h.container,boxShadow:b.panel,minWidth:"0"})}export function chromeSeparator(e,n){const t=e.createElement("div");return t.dataset.wmapChromeSep="1",Object.assign(t.style,{width:"1px",height:"18px",background:d.separator,margin:`0 ${c.xs}`,flexShrink:"0",order:String(n)}),t}export function labelChromeButton(e,n,t={}){const r=e.ownerDocument,i=r.createElement("span");i.textContent=n,i.dataset.wmapFitHide=String(FIT_STEP.label),i.dataset.wmapChromeLabel="1",Object.assign(i.style,{whiteSpace:"nowrap",fontSize:u.body}),e.appendChild(i),t.menu&&e.appendChild(chromeCaret(r,FIT_STEP.caret)),e.dataset.wmapFitBtn="1",Object.assign(e.style,{color:d.text}),x(e)}export function chromeButtonFrom(e,n,t,r={}){e.textContent="";const i=e.ownerDocument.createElement("span");i.innerHTML=g[n]??"",i.setAttribute("aria-hidden","true"),Object.assign(i.style,{display:"inline-flex"}),e.appendChild(i),e.setAttribute("aria-label",t),Object.assign(e.style,{display:"flex",alignItems:"center",justifyContent:"center",height:"28px",border:"none",background:"transparent",borderRadius:h.control,flexShrink:"0"}),labelChromeButton(e,t,r)}export function chromeCaret(e,n){const t=e.createElement("span");return t.textContent="\u25BE",t.setAttribute("aria-hidden","true"),t.dataset.wmapFitHide=String(n),Object.assign(t.style,{fontSize:u.meta,color:d.label,lineHeight:S.none}),t}function x(e){const t=[...e.querySelectorAll("[data-wmap-fit-hide]")].some(r=>r.style.display!=="none"&&r.dataset.wmapChromeEmpty!=="1");Object.assign(e.style,t?{width:"auto",padding:`0 ${c.sm}`,gap:c.xs}:{width:"28px",padding:"0",gap:"0"})}function w(e,n){for(const t of e.querySelectorAll("[data-wmap-fit-hide]")){const r=t.dataset.wmapChromeEmpty==="1"||n>=Number(t.dataset.wmapFitHide);t.style.display=r?"none":""}for(const t of e.querySelectorAll("[data-wmap-fit-tight]"))t.dataset.wmapTight=String(n>=Number(t.dataset.wmapFitTight)),t.dispatchEvent(new Event("wmap-fit-tight"));for(const t of e.querySelectorAll("[data-wmap-fit-btn]"))x(t);syncChromeSeparators(e)}export function syncChromeSeparators(e){const n=[...e.children],t=n.map((a,o)=>({el:a,i:o,order:Number(a.style.order||0)})).sort((a,o)=>a.order-o.order||a.i-o.i).map(a=>a.el);if(t.some((a,o)=>a!==n[o])&&!e.contains(e.ownerDocument.activeElement))for(const a of t)e.appendChild(a);const r=a=>a.dataset.wmapChromeSep==="1";let i=!1,s=null;for(const a of t){if(a.dataset.wmapChromeSpacer){s=null,i=!1;continue}if(r(a)){a.style.display="none",s=i?a:null;continue}a.style.display!=="none"&&(s&&(s.style.display="",s=null),i=!0)}}export function fitChromeRow(e,n={}){let t=0,r=-1,i=!1;const s=()=>e.scrollWidth<=e.clientWidth+1&&!(n.labelCut?.()??!1),a=l=>(w(e,l),n.refitIdentity?.(),s());function o(){if(!(n.active&&!n.active())&&!(i||!e.isConnected||e.clientWidth===0||e.style.display==="none")){i=!0;try{e.style.flexWrap="nowrap",r=e.clientWidth;const l=Math.min(y,Math.max(0,n.hold?.()??0));if(n.arrange){if(n.arrange(!0),l===0&&a(0)){t=0;return}if(l<=FIT_STEP.modeName&&a(FIT_STEP.modeName)){t=FIT_STEP.modeName;return}n.arrange(!1)}let p=l;for(;!a(p)&&p<y;)p++;t=p,s()||(e.style.flexWrap="wrap")}finally{i=!1}}}const m=e.ownerDocument.defaultView,f=m&&"ResizeObserver"in m?new m.ResizeObserver(()=>{e.clientWidth!==r&&o()}):null;return f?.observe(e),{refit:o,step:()=>t,destroy:()=>f?.disconnect()}}export function fitViewSwitch(e){Object.assign(e.style,{boxShadow:"none",background:"transparent"}),e.dataset.wmapFitTight=String(FIT_STEP.tight),e.addEventListener("wmap-fit-tight",()=>{const n=e.dataset.wmapTight==="true";for(const t of e.querySelectorAll("button"))t.dataset.wmapPad??=t.style.padding,t.style.padding=n?c.sm:t.dataset.wmapPad})}export const EXPORT_ICON=g.export;
|
|
@@ -42,4 +42,10 @@ export declare function runChunked<T>(work: Chunked<T>, opts?: {
|
|
|
42
42
|
/** Called with the result when the work finishes. Not called if cancelled. */
|
|
43
43
|
onDone?: (result: T) => void;
|
|
44
44
|
}): ChunkedRun;
|
|
45
|
+
/**
|
|
46
|
+
* Runs `work` in a task of its own once the browser has painted what the current one built, for one piece too large to
|
|
47
|
+
* share that first paint. A plain `setTimeout` can run before the paint, so it waits for a frame first; in a hidden
|
|
48
|
+
* page, which gets no frames, it only takes its own task. Returns a function that calls it off.
|
|
49
|
+
*/
|
|
50
|
+
export declare function afterPaint(work: () => void, ownerDocument: Document): () => void;
|
|
45
51
|
//# sourceMappingURL=chunked.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){return typeof performance<"u"?performance.now():Date.now()}export function runChunked(u,f={}){const{firstSliceMs:t=150,sliceMs:i=16,onDone:e}=f;let n=!1,o=!1,r;const a=c=>{if(r=void 0,n)return;const l=s();for(;;){const d=u.next();if(d.done){o=!0,e?.(d.value);return}if(s()-l>=c)break}r=setTimeout(()=>a(i),0)};return a(t),{get done(){return o},cancel(){n||o||(n=!0,r!==void 0&&(clearTimeout(r),r=void 0),u.return(void 0))}}}export function afterPaint(u,f){const t=f.defaultView;let i,e;const n=()=>{e=void 0,i=setTimeout(u,0)};return f.visibilityState!=="hidden"&&t?.requestAnimationFrame?e=t.requestAnimationFrame(n):n(),()=>{e!==void 0&&t?.cancelAnimationFrame(e),i!==void 0&&clearTimeout(i)}}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ColumnFilter } from './tableFilter.js';
|
|
2
|
+
export interface FilterPopupOptions {
|
|
3
|
+
anchor: HTMLElement;
|
|
4
|
+
/** The column's heading, for the popup's name. */
|
|
5
|
+
header: string;
|
|
6
|
+
kind: 'range' | 'values';
|
|
7
|
+
/** The filter in force on this column, if any. */
|
|
8
|
+
current?: ColumnFilter;
|
|
9
|
+
/** A number column: its smallest and largest value and how many cells hold none. */
|
|
10
|
+
extent?: {
|
|
11
|
+
min: number;
|
|
12
|
+
max: number;
|
|
13
|
+
blanks: number;
|
|
14
|
+
};
|
|
15
|
+
/** Any other column: every distinct cell text and how often it occurs, most frequent first. */
|
|
16
|
+
values?: ReadonlyArray<{
|
|
17
|
+
value: string;
|
|
18
|
+
count: number;
|
|
19
|
+
}>;
|
|
20
|
+
/** Apply. `null` removes the column's filter. */
|
|
21
|
+
onApply: (filter: ColumnFilter | null) => void;
|
|
22
|
+
}
|
|
23
|
+
/** Open the popup under `anchor`; returns its close function. */
|
|
24
|
+
export declare function openFilterPopup(o: FilterPopupOptions): () => void;
|
|
25
|
+
//# sourceMappingURL=columnFilterPopup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CLR as p,FONT as H,RADIUS as M,SPACE as g,controlStyle as W,menuLayerFor as Y,wireControlHover as _}from"./toolbar.js";import{inputStyle as T}from"./charts/chartShell.js";import{FILTER_LIST_MAX as q,filterNumber as z,isOpenFilter as U}from"./tableFilter.js";const k=(e,t)=>{const c=e.createElement("button");return c.type="button",c.textContent=t,Object.assign(c.style,{fontSize:H.body,padding:"3px 10px",borderRadius:M.control,...W("outlined"),background:p.menuBg}),_(c),c};export function openFilterPopup(e){const t=e.anchor.ownerDocument,c=t.defaultView??window,r=t.createElement("div");r.setAttribute("role","dialog"),r.setAttribute("aria-label",`Filter ${e.header}`),r.dataset.wmapColumnFilter=e.header,Object.assign(r.style,{position:"fixed",pointerEvents:"auto",boxSizing:"border-box",width:"248px",maxHeight:"70vh",overflowY:"auto",display:"flex",flexDirection:"column",gap:g.md,padding:g.lg,background:p.menuBg,color:p.text,border:`1px solid ${p.controlBorder}`,borderRadius:M.control,boxShadow:"0 4px 14px rgba(0,0,0,0.18)",fontSize:H.body});const C=t.createElement("div");C.textContent=e.header,Object.assign(C.style,{fontWeight:"600",color:p.value,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),r.appendChild(C);const S=k(t,"Apply"),R=k(t,"Clear");let L=()=>null,O=null;if(e.kind==="range"){const l=e.current?.kind==="range"?e.current:void 0,y=(i,a,f)=>{const b=t.createElement("label");Object.assign(b.style,{display:"flex",alignItems:"center",gap:g.md});const m=t.createElement("span");m.textContent=i,Object.assign(m.style,{width:"34px",color:p.label});const n=t.createElement("input");return n.type="text",n.inputMode="decimal",n.value=a===void 0?"":String(a),n.placeholder=f,Object.assign(n.style,{...T(),flex:"1",minWidth:"0"}),b.append(m,n),r.appendChild(b),n},o=y("From",l?.min,e.extent?String(e.extent.min):""),s=y("To",l?.max,e.extent?String(e.extent.max):"");O=o;let d=null;if((e.extent?.blanks??0)>0||l?.blank){const i=t.createElement("label");Object.assign(i.style,{display:"flex",alignItems:"center",gap:g.md}),d=t.createElement("input"),d.type="checkbox",d.checked=l?.blank??!1;const a=t.createElement("span");a.textContent=`Include blank cells${e.extent?` (${e.extent.blanks.toLocaleString()})`:""}`,i.append(d,a),r.appendChild(i)}const u=t.createElement("div");u.setAttribute("role","alert"),Object.assign(u.style,{color:p.label,minHeight:"0"}),r.appendChild(u),L=()=>{const i=o.value.trim()===""?void 0:z(o.value),a=s.value.trim()===""?void 0:z(s.value);if(i!==void 0&&!Number.isFinite(i)||a!==void 0&&!Number.isFinite(a)){u.textContent="Enter numbers only.";return}if(i!==void 0&&a!==void 0&&i>a){u.textContent="From must not be above To.";return}u.textContent="";const f={kind:"range",...i!==void 0?{min:i}:{},...a!==void 0?{max:a}:{},blank:d?.checked??!1};return U(f)?null:f};for(const i of[o,s])i.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),S.click())})}else{const l=e.values??[],y=e.current?.kind==="values"?e.current:void 0,o=new Set(y?y.values:l.map(n=>n.value)),s=t.createElement("input");s.type="search",s.placeholder="Search values",s.setAttribute("aria-label",`Search ${e.header} values`),Object.assign(s.style,{...T(),width:"100%",boxSizing:"border-box"}),O=s;const d=t.createElement("div");Object.assign(d.style,{display:"flex",gap:g.md});const u=k(t,"Select all"),i=k(t,"Select none");d.append(u,i);const a=t.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label",`${e.header} values`),Object.assign(a.style,{display:"flex",flexDirection:"column",gap:"2px",maxHeight:"240px",overflowY:"auto"});const f=t.createElement("div");Object.assign(f.style,{color:p.label});const b=()=>{const n=s.value.trim().toLowerCase();return n===""?l:l.filter(x=>(x.value===""?"(blank)":x.value).toLowerCase().includes(n))},m=()=>{const n=b(),x=n.slice(0,q);a.replaceChildren(...x.map(v=>{const A=t.createElement("label");Object.assign(A.style,{display:"flex",alignItems:"center",gap:g.md,padding:"1px 0"});const E=t.createElement("input");E.type="checkbox",E.checked=o.has(v.value),E.addEventListener("change",()=>{E.checked?o.add(v.value):o.delete(v.value)});const F=t.createElement("span");F.textContent=v.value===""?"(blank)":v.value,Object.assign(F.style,{flex:"1",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const $=t.createElement("span");return $.textContent=v.count.toLocaleString(),Object.assign($.style,{color:p.label}),A.append(E,F,$),A})),f.textContent=n.length>x.length?`Showing ${x.length} of ${n.length.toLocaleString()} values; search to find others.`:n.length===0?"No value matches.":""};s.addEventListener("input",m),u.addEventListener("click",()=>{for(const n of b())o.add(n.value);m()}),i.addEventListener("click",()=>{for(const n of b())o.delete(n.value);m()}),r.append(s,d,a,f),m(),L=()=>l.every(n=>o.has(n.value))?null:{kind:"values",values:l.filter(n=>o.has(n.value)).map(n=>n.value)}}const j=t.createElement("div");Object.assign(j.style,{display:"flex",gap:g.md,justifyContent:"flex-end"}),j.append(R,S),r.appendChild(j);let B=!1;function h(l=!0){B||(B=!0,r.remove(),t.removeEventListener("pointerdown",I,!0),c.removeEventListener("blur",D),e.anchor.setAttribute("aria-expanded","false"),l&&e.anchor.focus())}const I=l=>{!r.contains(l.target)&&!e.anchor.contains(l.target)&&h(!1)},D=()=>h(!1);S.addEventListener("click",()=>{const l=L();l!==void 0&&(e.onApply(l),h())}),R.addEventListener("click",()=>{e.onApply(null),h()}),r.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),h())}),t.addEventListener("pointerdown",I,!0),c.addEventListener("blur",D),Y(e.anchor).appendChild(r),e.anchor.setAttribute("aria-expanded","true");const w=e.anchor.getBoundingClientRect(),P=r.getBoundingClientRect().width||248;r.style.left=`${Math.max(4,Math.min(w.left,c.innerWidth-P-4))}px`,r.style.top=`${w.bottom+4}px`;const N=r.getBoundingClientRect().height;return w.bottom+4+N>c.innerHeight-4&&(r.style.top=`${Math.max(4,w.top-N-4)}px`),O?.focus(),()=>h(!1)}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** What a saved chart carries besides its canvas: the legend and the statement of what it shows are DOM, not canvas. */
|
|
2
|
+
export interface PngDecor {
|
|
3
|
+
/** Which test, wafer, group or sort the card's controls are set to ("Test: vth_n_mV · 1001"): a chart saved without them is unlabelled. */
|
|
4
|
+
controls?: readonly string[];
|
|
5
|
+
/** The population and what was combined or left out, under the title: a line, or several. */
|
|
6
|
+
caption?: string | readonly string[];
|
|
7
|
+
/** The colour key of a chart coloured by category. */
|
|
8
|
+
legend?: ReadonlyArray<{
|
|
9
|
+
label: string;
|
|
10
|
+
color: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** The colour key of a chart coloured on a gradient. */
|
|
13
|
+
colorbar?: {
|
|
14
|
+
label: string;
|
|
15
|
+
lo: string;
|
|
16
|
+
hi: string;
|
|
17
|
+
mid?: string; /** Captions under the strip, at their place along it (0 to 1). */
|
|
18
|
+
ticks?: ReadonlyArray<{
|
|
19
|
+
at: number;
|
|
20
|
+
text: string;
|
|
21
|
+
}>;
|
|
22
|
+
color: (t: number) => string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface PngHeader {
|
|
26
|
+
/** The card the chart lives in: its colours are the saved image's, so a dark theme saves a legible dark image. */
|
|
27
|
+
card: HTMLElement;
|
|
28
|
+
title: string;
|
|
29
|
+
decor?: PngDecor;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The canvas as it is saved: under a header that names the chart, states what it shows, and carries the legend.
|
|
33
|
+
* A bare canvas saved with none of these is a picture of unlabelled marks: the title, the population ("6 wafers · 3,966
|
|
34
|
+
* dies"), and the key to the colours live in the card around the canvas, not in it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function composeChartPng(canvas: HTMLCanvasElement, header?: PngHeader): HTMLCanvasElement;
|
|
37
|
+
//# sourceMappingURL=composePng.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function b(a){const p=a.ownerDocument.defaultView;for(let u=a;u&&p;u=u.parentElement){const r=p.getComputedStyle(u).backgroundColor;if(r&&r!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(r))return r}return"#ffffff"}export function composeChartPng(a,p){const u=a.ownerDocument,r=u.createElement("canvas"),t=Math.max(1,Number(a.dataset.wmapPixelRatio)||a.width/(a.clientWidth||a.width)),m=a.width,k=u.createElement("canvas").getContext("2d"),x=12*t,g=(f,d="400")=>`${d} ${f*t}px system-ui, -apple-system, "Segoe UI", sans-serif`,y=(f,d)=>k?(k.font=d,k.measureText(f).width):f.length*7*t,c=[];let e=0;if(p){e=x,c.push({kind:"text",text:p.title,x,y:e+14*t,font:g(16,"600"),alpha:1}),e+=24*t;const f=p.decor,d=[];f?.controls?.length&&d.push({text:f.controls.join(" \xB7 "),alpha:1});for(const i of f?.caption===void 0?[]:typeof f.caption=="string"?[f.caption]:f.caption)d.push({text:i,alpha:.75});const l=g(12);for(const{text:i,alpha:o}of d){let n="";for(const h of i.split(" ")){const w=n?`${n} ${h}`:h;n&&y(w,l)>m-2*x?(c.push({kind:"text",text:n,x,y:e+11*t,font:l,alpha:o}),e+=17*t,n=h):n=w}n&&(c.push({kind:"text",text:n,x,y:e+11*t,font:l,alpha:o}),e+=17*t)}if(f?.legend?.length){e+=4*t;const i=g(12);let o=x;for(const n of f.legend){const h=14*t+y(n.label,i)+14*t;o>x&&o+h>m-x&&(o=x,e+=18*t),c.push({kind:"dot",x:o+5*t,y:e+7*t,r:5*t,color:n.color}),c.push({kind:"text",text:n.label,x:o+14*t,y:e+11*t,font:i,alpha:1}),o+=h}e+=20*t}if(f?.colorbar){e+=4*t;const i=g(12),o=f.colorbar;let n=x;if(c.push({kind:"text",text:o.label,x:n,y:e+10*t,font:i,alpha:1}),n+=y(o.label,i)+10*t,c.push({kind:"text",text:o.lo,x:n,y:e+10*t,font:i,alpha:.75}),n+=y(o.lo,i)+6*t,c.push({kind:"strip",x:n,y:e+1*t,w:200*t,h:10*t,color:o.color}),o.mid&&c.push({kind:"text",text:o.mid,x:n+100*t-y(o.mid,i)/2,y:e+22*t,font:i,alpha:.75}),o.ticks)for(const h of o.ticks)c.push({kind:"text",text:h.text,x:n+h.at*200*t-y(h.text,i)/2,y:e+22*t,font:i,alpha:.75});n+=206*t,c.push({kind:"text",text:o.hi,x:n,y:e+10*t,font:i,alpha:.75}),e+=(o.mid||o.ticks?32:20)*t}e+=6*t}r.width=m,r.height=Math.ceil(a.height+e);const s=r.getContext("2d");if(s.fillStyle=p?b(p.card):"#ffffff",s.fillRect(0,0,r.width,r.height),p){const f=u.defaultView,d=f&&f.getComputedStyle(p.card).color||"#222222";s.textBaseline="alphabetic";for(const l of c)if(l.kind==="text")s.font=l.font,s.fillStyle=d,s.globalAlpha=l.alpha,s.fillText(l.text,l.x,l.y),s.globalAlpha=1;else if(l.kind==="dot")s.fillStyle=l.color,s.beginPath(),s.arc(l.x,l.y,l.r,0,Math.PI*2),s.fill();else for(let i=0;i<l.w;i++)s.fillStyle=l.color(i/Math.max(1,l.w-1)),s.fillRect(l.x+i,l.y,1,l.h)}return s.drawImage(a,0,e),r}
|
|
@@ -2,9 +2,11 @@ import type { Die } from '../core/dies.js';
|
|
|
2
2
|
import { type FacetCuration } from '../stats/facets.js';
|
|
3
3
|
import { type MetadataFieldDef, type TestDef } from '../renderer/buildWaferMap.js';
|
|
4
4
|
import { type DieListDisplayOptions } from './dieList.js';
|
|
5
|
+
import { type ColumnFilter } from './virtualTable.js';
|
|
5
6
|
import { type SaveTextHandler } from './toolbar.js';
|
|
6
7
|
import type { InsightsItem } from './insightsTab.js';
|
|
7
8
|
import type { Wafer } from '../core/wafer.js';
|
|
9
|
+
import { type PlotSpec } from '../stats/plotSpec.js';
|
|
8
10
|
export type DataView = 'statistics' | 'dies' | 'wafers';
|
|
9
11
|
/** What a table needs of a wafer. An `InsightsItem` fits; so does one wafer's share
|
|
10
12
|
* of a drilldown population, which has no `Wafer` object or stats of its own. */
|
|
@@ -61,10 +63,16 @@ export interface DataSectionDeps {
|
|
|
61
63
|
metadataFields?: MetadataFieldDef[];
|
|
62
64
|
/** The host's own wafer attributes (`attributes` on the render options): the Wafers table names its columns by them. */
|
|
63
65
|
attributes?: Record<string, FacetCuration>;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* A die row was clicked: show that die on its wafer's map, on the test whose column was clicked (none for another
|
|
68
|
+
* column). When set, Dies rows are clickable and say so.
|
|
69
|
+
*/
|
|
70
|
+
onLocateDie?: (die: Die, waferIndex: number | undefined, testNumber?: number) => void;
|
|
71
|
+
/**
|
|
72
|
+
* A wafer row was clicked: open that wafer, on the test whose mean column was clicked, or on its bins for its yield.
|
|
73
|
+
* When set, Wafers rows are clickable and say so.
|
|
74
|
+
*/
|
|
75
|
+
onOpenWafer?: (waferIndex: number, label: string, testNumber?: number, view?: 'bins') => void;
|
|
68
76
|
/** Set when the tables describe part of a population (a drilldown selection): what to say after the
|
|
69
77
|
* counts ("selected on W03"), and a wafer column and file-name tag so a file says so too. */
|
|
70
78
|
population?: {
|
|
@@ -73,9 +81,34 @@ export interface DataSectionDeps {
|
|
|
73
81
|
};
|
|
74
82
|
view: DataView;
|
|
75
83
|
onViewChange: (view: DataView) => void;
|
|
84
|
+
/** The wafer fields that divide the wafers, as Group by lists them: the Statistics view's By offers each. */
|
|
85
|
+
byFields?: ReadonlyArray<{
|
|
86
|
+
key: string;
|
|
87
|
+
label: string;
|
|
88
|
+
}>;
|
|
89
|
+
/** What the Statistics view compares across: 'lot', 'wafer', 'site', 'group' (Group by's field) or 'field:<key>'. */
|
|
90
|
+
statsBy?: string;
|
|
91
|
+
onStatsByChange?: (by: string) => void;
|
|
76
92
|
/** The Dies view's Wide | Long choice. */
|
|
77
93
|
diesLayout: 'wide' | 'long';
|
|
78
94
|
onDiesLayoutChange: (layout: 'wide' | 'long') => void;
|
|
95
|
+
/** Column filters to start each table with, by view, and the way to hear of a change, so a view keeps its filters while the reader looks at another. */
|
|
96
|
+
tableFilters?: Partial<Record<DataView, Record<string, ColumnFilter>>>;
|
|
97
|
+
onTableFiltersChange?: (view: DataView, filters: Record<string, ColumnFilter>) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Plot the columns ticked in the Wafers or Dies table, over the rows that pass the column filters. When set, those
|
|
100
|
+
* tables offer a tick under each column that stands for a plot field, and a Plot columns button.
|
|
101
|
+
*/
|
|
102
|
+
onPlotColumns?: (request: PlotColumnsRequest, anchor: HTMLElement) => void;
|
|
103
|
+
}
|
|
104
|
+
/** What Plot columns asks the host to draw: a starting plot and the rows it is drawn over. */
|
|
105
|
+
export interface PlotColumnsRequest {
|
|
106
|
+
/** A draft the reader can change in the plot builder; kept only if they add it. */
|
|
107
|
+
plot: PlotSpec;
|
|
108
|
+
/** The population: the rows that pass the column filters, one entry per wafer (a part of a wafer's dies when filtered). */
|
|
109
|
+
items: DataItem[];
|
|
110
|
+
/** Who the rows are, read after a count: "in the table", "filtered by Site: 2". */
|
|
111
|
+
population: string;
|
|
79
112
|
}
|
|
80
113
|
export declare function renderDataSection(deps: DataSectionDeps): {
|
|
81
114
|
card: HTMLElement;
|
|
@@ -106,8 +139,8 @@ export interface DataTablesInput {
|
|
|
106
139
|
metadataFields?: MetadataFieldDef[];
|
|
107
140
|
/** The host's own wafer attributes, for the Wafers table's column names. */
|
|
108
141
|
attributes?: Record<string, FacetCuration>;
|
|
109
|
-
/** A die row clicked: show that die on its map. The caller closes the table around it. */
|
|
110
|
-
onLocateDie?: (die: Die, waferIndex: number | undefined) => void;
|
|
142
|
+
/** A die row clicked: show that die on its map, on the test whose column was clicked. The caller closes the table around it. */
|
|
143
|
+
onLocateDie?: (die: Die, waferIndex: number | undefined, testNumber?: number) => void;
|
|
111
144
|
dieListOptions?: DieListDisplayOptions;
|
|
112
145
|
onSaveText?: SaveTextHandler;
|
|
113
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{maxOf as J}from"../core/utils.js";import{isYieldEligibleDie as z}from"../core/dies.js";import{testValue as B}from"../core/dieTable.js";import{metadataDisplayValue as _}from"../core/metadata.js";import{attributeLabel as F}from"../stats/facets.js";import{tableToTsv as H}from"../core/tableCsv.js";import{commonMetadata as Z}from"../stats/facets.js";import{buildYieldData as ee}from"../stats/yield.js";import{isParametricTest as j}from"../renderer/buildWaferMap.js";import{fmt as I}from"../renderer/fmt.js";import{testLabel as M}from"../renderer/testLabel.js";import{resolveDieColumns as te}from"./dieList.js";import{createVirtualTable as P}from"./virtualTable.js";import{exportCsv as A}from"./tableExport.js";import{CLR as S,FONT as k,RADIUS as q,SPACE as T,controlStyle as ne,wireControlHover as G,wireTooltip as V}from"./toolbar.js";import{buildTestSection as oe,buildFunctionalTestSection as se}from"./summaryPanel.js";import{pooledTestStatsSteps as ie}from"../stats/capability.js";import{runChunked as ae}from"./chunked.js";import{capabilityShade as re,outOfLimitsShade as le,shadesAmong as K,shortfallShade as U}from"./cellShade.js";import{patTests as de,waferPatVerdicts as ce,PAT_VERDICT_LABEL as ue}from"../stats/pat.js";export const DATA_VIEWS=[{key:"statistics",label:"Statistics",hint:"One row per test: count, spread, limits and limit yield"},{key:"wafers",label:"Wafers",hint:"One row per wafer: its attributes, die counts, yield and test means"},{key:"dies",label:"Dies",hint:"One row per die, with its position, bins and every test"}],EXCEL_ROW_LIMIT=1048576,COPY_CELL_LIMIT=2e5,WAFER_TEST_COLUMNS=50;const O=(t,d,s=d+"s")=>`${t.toLocaleString()} ${t===1?d:s}`;export function renderDataSection(t){const{doc:d}=t,s=d.createElement("div");s.dataset.wmapDataTab="1",Object.assign(s.style,{display:"flex",flexDirection:"column",gap:T.md,minWidth:"0"});const a=d.createElement("div");Object.assign(a.style,{display:"flex",alignItems:"center",gap:T.md,flexWrap:"wrap"}),s.appendChild(a);const h=d.createElement("div");Object.assign(h.style,{display:"flex",flexDirection:"column",gap:T.md,minWidth:"0"}),s.appendChild(h);const y=DATA_VIEWS.filter(f=>!t.views||t.views.includes(f.key)),o=X(d,"Table",y,t.view,"wmapDataView",f=>t.onViewChange(f));a.appendChild(o.el);let r;switch(t.view){case"dies":r=pe(t);break;case"wafers":r=ge(t);break;default:r=fe(t)}let p=()=>{};if(t.view==="dies"){const f=X(d,"Export format",[{key:"wide",label:"Wide",hint:"A column for each test"},{key:"long",label:"Long",hint:"A row for each die and test, the shape statistics tools prefer"}],t.diesLayout,"wmapDataLayout",u=>{f.set(u),t.onDiesLayoutChange(u),r.actions?.setLayout?.(u),p()});V(f.el,"Wide: a column per test. Long: a row per die per test, for tools that want tidy data. The table on screen is always wide.");const c=d.createElement("span");Object.assign(c.style,{display:"inline-flex",alignItems:"center",gap:T.sm});const l=d.createElement("span");l.textContent="Export format:",Object.assign(l.style,{color:S.label,fontSize:k.body}),c.append(l,f.el),a.appendChild(c)}if(r.actions){const f=r.actions,c=d.createElement("div");c.style.flex="1",a.appendChild(c);const l=Y(d,"Export CSV");l.dataset.wmapDataExport="1",l.addEventListener("click",()=>{if(l.disabled)return;const w=l.textContent,b=f.exportCsv();b&&(l.disabled=!0,l.setAttribute("aria-busy","true"),b.catch(()=>{}).finally(()=>{l.disabled=!1,l.removeAttribute("aria-busy"),l.textContent=w}))});const u=Y(d,"Copy");u.dataset.wmapDataCopy="1",f.copyText?(V(u,"Copy the table as tab-separated text, to paste into a spreadsheet"),u.addEventListener("click",()=>{const w=f.copyText(),b=d.defaultView?.navigator?.clipboard;if(!b)return;const x=u.textContent;b.writeText(w).then(()=>{u.textContent="Copied",d.defaultView?.setTimeout(()=>{u.textContent=x},1500)}).catch(()=>{})})):(u.disabled=!0,V(u,`Too large to copy (over ${COPY_CELL_LIMIT.toLocaleString()} cells). Use Export CSV.`)),a.append(u,l);const g=d.createElement("div");g.dataset.wmapDataNote="1",g.textContent=f.note(),p=()=>{g.textContent=f.note()},Object.assign(g.style,{color:S.label,fontSize:k.body}),s.insertBefore(g,h)}return h.appendChild(r.el),{card:s,destroy:()=>r.destroy()}}function fe(t){const{doc:d}=t,s=d.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:T.lg,minWidth:"0"});const a=[],h=t.groups&&t.groups.length>0?t.groups:void 0,y=h??[{key:"",items:t.items}];if(h&&h.length>1){const o=me(t,h);o&&(s.appendChild(o.el),a.push(o.destroy))}for(const o of y){if(h){const p=d.createElement("div");p.textContent=`${t.groupLabelText??"Group"}: ${o.key}`,Object.assign(p.style,{fontWeight:"700",color:S.text,fontSize:k.body}),s.appendChild(p)}const r=t.buildStatistics(o.items);a.push(r.destroy);for(const p of r.cards)s.appendChild(p)}return!s.querySelector("table")&&!s.textContent&&(s.textContent="No test statistics to show for these wafers.",Object.assign(s.style,{color:S.label,fontSize:k.body})),{el:s,destroy:()=>{for(const o of a)o()}}}function me(t,d){const{doc:s}=t,a=t.testDefs.filter(b=>b.testNumber!==void 0&&j(b));if(a.length===0)return null;const h=t.groupLabelText??"Group",y=s.createElement("div");y.dataset.wmapGroupStats="1",Object.assign(y.style,{display:"flex",flexDirection:"column",gap:T.sm,minWidth:"0"});const o=s.createElement("div");Object.assign(o.style,{display:"flex",alignItems:"center",gap:T.md,flexWrap:"wrap"});const r=s.createElement("div");r.textContent=`Compared across ${h}`,Object.assign(r.style,{fontWeight:"700",color:S.text,fontSize:k.body}),o.appendChild(r);const p=s.createElement("div");p.textContent="Computing test statistics\u2026",Object.assign(p.style,{color:S.label,fontSize:k.body}),y.append(o,p);const f=new Map;let c=d.length,l,u=!1;const g=()=>{if(u)return;const b=[];for(const e of a)for(const n of d){const m=f.get(n.key),i=m?.stats.get(e.testNumber);if(!m||!i)continue;const C=m.specTally.get(e.testNumber);b.push({def:e,group:n.key,count:i.count,min:i.min,q1:i.q1,median:i.median,mean:i.mean,q3:i.q3,max:i.max,stddev:i.stddev,ppk:m.capability.find(W=>W.testNumber===e.testNumber)?.ppk??null,limitYield:C&&C.n>0?100*(1-C.fail/C.n):void 0})}if(b.length===0){y.remove();return}const x=new Map;for(const e of b){const n=x.get(e.def.testNumber);n?n.push(e):x.set(e.def.testNumber,[e])}for(const e of x.values()){const n=K(e.map(i=>i.mean),i=>I(i,e[0].def.unit)),m=J(e.map(i=>i.limitYield??-1/0));e.forEach((i,C)=>{i.meanShade=n[C],i.yieldShade=i.limitYield===void 0||!Number.isFinite(m)?void 0:U(i.limitYield-m)})}const v=e=>({get:n=>I(e(n),n.def.unit),numeric:!0,sortKey:e}),L=(e,n)=>({get:m=>{const i=e(m);return i===void 0||!Number.isFinite(i)?"":n(i)},numeric:!0,sortKey:m=>{const i=e(m);return i===void 0||!Number.isFinite(i)?void 0:i}}),D=[{header:"Test",get:e=>`${M(e.def,e.def.testNumber)}${e.def.unit?` (${e.def.unit})`:""}`},{header:h,get:e=>e.group},{header:"N",...L(e=>e.count,e=>String(e))},{header:"Min",...v(e=>e.min)},{header:"Q1",...v(e=>e.q1)},{header:"Median",...v(e=>e.median)},{header:"Mean",...v(e=>e.mean),shade:e=>e.meanShade},{header:"Q3",...v(e=>e.q3)},{header:"Max",...v(e=>e.max)},{header:"Std dev",...v(e=>e.stddev)},{header:"Ppk",...L(e=>e.ppk??void 0,e=>e.toFixed(2)),shade:e=>re(e.ppk)},{header:"Limit yield %",...L(e=>e.limitYield,e=>e.toFixed(1)),shade:e=>e.yieldShade}],E=P({columns:D,rows:b,ariaLabel:`Statistics by ${h} (${b.length})`,ownerDocument:s});E.el.style.maxHeight="50vh",E.el.style.minHeight="120px",l=E;const N=()=>[{header:"Test number",get:e=>e.def.testNumber??null},{header:"Test",get:e=>M(e.def,e.def.testNumber)},{header:"Unit",get:e=>e.def.unit??""},{header:h,get:e=>e.group},{header:"N",get:e=>e.count},{header:"Min",get:e=>e.min},{header:"Q1",get:e=>e.q1},{header:"Median",get:e=>e.median},{header:"Mean",get:e=>e.mean},{header:"Q3",get:e=>e.q3},{header:"Max",get:e=>e.max},{header:"Std dev",get:e=>e.stddev},{header:"Ppk",get:e=>e.ppk},{header:"Limit yield %",get:e=>e.limitYield??null}],$=Y(s,"Statistics CSV");$.dataset.wmapGroupStatsCsv="1",$.addEventListener("click",()=>{A(N(),E.orderedRows(),`statistics-by-${h.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.csv`,t.onSaveText,{rowCount:b.length})}),o.appendChild($),p.replaceWith(E.el)},w=[];for(const b of d)w.push(ae(ie(b.items.map(x=>({dies:x.dies})),a),{onDone:x=>{f.set(b.key,x),--c===0&&g()}}));return{el:y,destroy:()=>{u=!0;for(const b of w)b.cancel();l?.destroy()}}}function he(t,d,s){if(de(d).length===0)return;const a=new Map;for(const o of t){const r=o.allDies??(s?void 0:o.dies);if(!r)continue;const p=ce(r,d,o.passBins);r.forEach((f,c)=>a.set(f,p[c]))}if(a.size===0)return;const h=o=>{const r=d.find(p=>p.testNumber===o);return r?M(r,o):`Test ${o}`};let y=!1;for(const o of a.values())if(o.verdict==="outlier"){y=!0;break}return{verdict:o=>{const r=a.get(o)?.verdict;return r?ue[r]:void 0},tests:o=>{const r=a.get(o);return r?.verdict==="outlier"?r.tests.map(h).join("; "):""},anyOutlier:y}}function pe(t){const{doc:d,items:s}=t,a=new WeakMap,h=new WeakMap,y=new WeakMap,o=[];let r=!1;for(const e of s){e.wafer&&(r=!0);for(const n of e.dies)a.set(n,e.label),y.set(n,e.waferIndex),e.wafer&&h.set(n,e.wafer),o.push(n)}if(o.length===0)return Q(d,"No dies to show.");const p=he(s,t.allTestDefs,!!t.population),{columns:f,visibleColumns:c}=te(o,t.allTestDefs,{...t.dieListOptions,...p?{patColumns:p}:{},metadataFields:t.metadataFields,extraColumn:s.length>1||t.population?{label:"Wafer",get:e=>a.get(e)}:void 0,getWafer:r?(e=>h.get(e)):void 0,ringCount:t.ringCount,waferMetadata:s.some(e=>e.wafer)?Z(s.map(e=>({metadata:e.wafer?.metadata}))):void 0,attributes:t.attributes,ownerDocument:d}),l=c.map(e=>({header:e.label,get:e.get,numeric:e.test!==void 0&&j(e.test),...e.test!==void 0&&j(e.test)?{sortKey:n=>B(n,e.test.testNumber),shade:n=>{const m=e.test,i=B(n,m.testNumber);return i!==void 0&&Number.isFinite(i)&&(m.limitLow!==void 0&&i<m.limitLow||m.limitHigh!==void 0&&i>m.limitHigh)?le():void 0}}:{}})),u=P({columns:l,rows:o,ariaLabel:`Dies (${o.length})`,ownerDocument:d,onRowClick:t.onLocateDie?e=>t.onLocateDie(e,y.get(e)):void 0});u.el.style.maxHeight="70vh",u.el.style.minHeight="240px";const g=t.population?`-${t.population.fileTag}`:"",w=f.filter(e=>e.test!==void 0),b=f.filter(e=>e.test===void 0),x=o.length*f.length,v=o.length*w.length,L=()=>f.map(e=>({header:e.csvLabel??e.label,get:e.csvGet??e.get})),D=()=>[...b.map(e=>({header:e.csvLabel??e.label,get:n=>(e.csvGet??e.get)(n.die)})),{header:"Test",get:e=>M(e.test,e.test.testNumber)},{header:"Test number",get:e=>e.test.testNumber},{header:"Unit",get:e=>e.test.unit??""},{header:"Value",get:e=>e.value}];function*E(){for(const e of u.orderedRows())for(const n of w){const m=(n.csvGet??n.get)(e);m===""||m===void 0||m===null||(yield{die:e,test:n.test,value:m})}}let N=t.diesLayout==="long"&&w.length>0;const $=()=>N?`Long format: up to ${O(v,"row")} (a die with no result for a test has no row)`+(v>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()}).`:"."):`Wide format: ${O(o.length,"row")} \xD7 ${O(f.length,"column")}`+(o.length>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()} rows).`:".");return{el:u.el,destroy:()=>u.destroy(),actions:{note:()=>`${O(o.length,"die")} ${t.population?.phrase??`on ${O(s.length,"wafer")}`}. ${$()} Export follows the order shown.${t.onLocateDie?" Click a row to show that die on the map.":""}`,setLayout:e=>{N=e==="long"&&w.length>0},exportCsv:()=>N?A(D(),E(),`die-list-long${g}.csv`,t.onSaveText,{rowCount:v}):A(L(),u.orderedRows(),`die-list${g}.csv`,t.onSaveText,{rowCount:o.length}),copyText:x<=COPY_CELL_LIMIT?()=>H(L(),u.orderedRows()):null}}}function ge(t){const{doc:d,items:s}=t;if(s.length===0)return Q(d,"No wafers to show.");const a=s.map(e=>{const n=t.yieldByWaferIndex.get(e.waferIndex),m=ee([{label:e.label,dies:e.dies,passBins:e.passBins,yieldPercent:n,key:e.waferIndex}])[0]?.percent;return{item:e,yieldPercent:e.dies.length?m??null:null}}),h=[];for(const{item:e}of a)for(const n of Object.keys(e.wafer?.metadata??{}))!h.includes(n)&&_((e.wafer?.metadata)[n])!==void 0&&h.push(n);const y=t.testDefs.slice(0,WAFER_TEST_COLUMNS),o=(e,n)=>{const m=e.item.statsSummary?.stats.perTestStats?.find(W=>W.testNumber===n.testNumber);if(m)return m.mean;let i=0,C=0;for(const W of e.item.dies){if(!z(W))continue;const R=B(W,n.testNumber);R!==void 0&&Number.isFinite(R)&&(i++,C+=R)}return i?C/i:void 0},r=(e,n)=>_(e.item.wafer?.metadata?.[n])??"",p=e=>({header:F(e,t.attributes),cell:n=>r(n,e)}),f=e=>a.length>1&&a.every(n=>r(n,e)===r(a[0],e)),c=h.filter(f),l=h.filter(e=>!c.includes(e)),u=t.groupLabelText?l.find(e=>F(e,t.attributes)===t.groupLabelText):void 0,g=a.map(e=>e.yieldPercent).filter(e=>e!==null&&Number.isFinite(e)),w=g.length?g.reduce((e,n)=>e+n,0)/g.length:void 0,b=[{header:"Dies",cell:e=>e.item.dies.length,numeric:!0},{header:"Yield-eligible dies",cell:e=>e.item.dies.filter(n=>z(n)).length,numeric:!0},{header:"Yield %",cell:e=>e.yieldPercent===null?"":e.yieldPercent,show:e=>e.yieldPercent===null?"":e.yieldPercent.toFixed(1),numeric:!0,shade:e=>e.yieldPercent===null||w===void 0?void 0:U(e.yieldPercent-w)},...y.map(e=>{const n=new Map,m=K(a.map(i=>o(i,e)??NaN),i=>I(i,e.unit));return a.forEach((i,C)=>n.set(i,m[C])),{header:`${M(e,e.testNumber)}${e.unit?` (${e.unit})`:""} mean`,cell:i=>o(i,e),show:i=>{const C=o(i,e);return C===void 0?"":I(C,e.unit)},numeric:!0,shade:i=>n.get(i)}})],x=[{header:"Wafer",cell:e=>e.item.label},...u?[p(u)]:[],...b,...l.filter(e=>e!==u).map(p)],v=[...x,...c.map(p)],L=x.map(e=>({header:e.header,get:n=>e.show?e.show(n):String(e.cell(n)??""),numeric:e.numeric,...e.shade?{shade:e.shade}:{},...e.numeric?{sortKey:n=>{const m=e.cell(n);return typeof m=="number"?m:void 0}}:{}})),D=P({columns:L,rows:a,ariaLabel:`Wafers (${a.length})`,ownerDocument:d,onRowClick:t.onOpenWafer?e=>t.onOpenWafer(e.item.waferIndex,e.item.label):void 0});D.el.style.maxHeight="70vh",D.el.style.minHeight="120px";const E=()=>v.map(e=>({header:e.header,get:e.cell})),N=t.testDefs.length>y.length?` Mean columns cover the first ${y.length} of ${t.testDefs.length} tests.`:"";let $=D.el;if(c.length){const e=d.createElement("div");e.dataset.wmapWafersSame="1",e.textContent=`Same on every wafer: ${c.map(n=>`${F(n,t.attributes)} ${r(a[0],n)}`).join(" \xB7 ")}`,Object.assign(e.style,{color:S.label,fontSize:k.body,lineHeight:"1.5",marginBottom:T.sm}),$=d.createElement("div"),$.append(e,D.el)}return{el:$,destroy:()=>D.destroy(),actions:{note:()=>`${O(a.length,"wafer")}.${N}${t.onOpenWafer?" Click a row to open that wafer.":""} Export follows the order shown.`,exportCsv:()=>A(E(),D.orderedRows(),"wafers.csv",t.onSaveText,{rowCount:a.length}),copyText:a.length*v.length<=COPY_CELL_LIMIT?()=>H(E(),D.orderedRows()):null}}}function Q(t,d){const s=t.createElement("div");return s.textContent=d,Object.assign(s.style,{color:S.label,fontSize:k.body,padding:T.md}),{el:s,destroy:()=>{}}}function Y(t,d){const s=t.createElement("button");return s.type="button",s.textContent=d,Object.assign(s.style,{fontSize:k.body,padding:"3px 10px",borderRadius:q.control,...ne("outlined"),background:S.menuBg}),G(s),s}function X(t,d,s,a,h,y){const o=t.createElement("div");o.setAttribute("role","radiogroup"),o.setAttribute("aria-label",d),Object.assign(o.style,{display:"inline-flex",background:S.menuBg,border:`1px solid ${S.menuBorder}`,borderRadius:q.control,overflow:"hidden"});const r=[];let p=a;const f=()=>{for(const c of r){const l=c.dataset[h]===p;c.setAttribute("aria-checked",String(l)),c.tabIndex=l?0:-1,Object.assign(c.style,{background:l?S.bgActive:"transparent",color:l?S.iconActive:S.label,fontWeight:l?"600":"400"})}};for(const c of s){const l=t.createElement("button");c.hint&&V(l,c.hint),l.type="button",l.textContent=c.label,l.dataset[h]=c.key,l.setAttribute("role","radio"),Object.assign(l.style,{border:"none",cursor:"pointer",fontSize:k.body,padding:`${T.xs} ${T.md}`,whiteSpace:"nowrap"}),G(l,"bare"),l.addEventListener("click",()=>{p!==c.key&&y(c.key)}),r.push(l),o.appendChild(l)}return f(),o.addEventListener("keydown",c=>{if(c.key!=="ArrowLeft"&&c.key!=="ArrowRight")return;const l=r.indexOf(t.activeElement);if(l<0)return;c.preventDefault();const u=r[(l+(c.key==="ArrowRight"?1:-1)+r.length)%r.length];u.click(),u.focus()}),{el:o,set:c=>{p=c,f()}}}export function renderDataTables(t){const{doc:d}=t,s=d.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",flex:"1",padding:T.md});const a=t.items.map((g,w)=>({...g,waferIndex:g.waferIndex??w})),h=a.flatMap(g=>g.dies),y=t.testDefs??[],o=y.filter(j),r=t.views??(a.length>1?["statistics","wafers","dies"]:["statistics","dies"]),p=t.population?{populationLabel:`${O(h.length,"die")} ${t.population}`}:a.length>1?{perWaferMetadata:a.map(g=>g.wafer?.metadata??{}),populationLabel:`${O(a.length,"wafer")} pooled`}:{waferMetadata:a[0]?.wafer?.metadata};let f=r.includes(t.view)?t.view:r[0],c="wide",l=null;const u=()=>{l?.destroy(),l=renderDataSection({doc:d,items:a,testDefs:o,allTestDefs:y,ringCount:t.ringCount,yieldByWaferIndex:new Map,onSaveText:t.onSaveText,views:r,view:f,dieListOptions:t.dieListOptions,metadataFields:t.metadataFields,attributes:t.attributes,onLocateDie:t.onLocateDie,population:t.population?{phrase:t.population,fileTag:"selection"}:void 0,buildStatistics:g=>{const w=g.flatMap(L=>L.dies),b=[],x=oe(w,o,void 0,void 0,t.onSaveText,p,g.map(L=>({dies:L.dies})),void 0,"full");x&&b.push(x);const v=se(w,y,void 0,t.onSaveText,p);return v&&b.push(v),{cards:b,destroy:()=>{}}},onViewChange:g=>{f=g,u()},diesLayout:c,onDiesLayoutChange:g=>{c=g}}),s.replaceChildren(l.card)};return u(),{el:s,destroy:()=>l?.destroy()}}export function renderSelectionTables(t){return renderDataTables({...t,views:t.items.length>1?["statistics","wafers","dies"]:["statistics","dies"]})}
|
|
1
|
+
import{listInWords as ke,maxOf as De,medianOfSorted as Ee}from"../core/utils.js";import{isYieldEligibleDie as ie}from"../core/dies.js";import{testValue as le}from"../core/dieTable.js";import{metadataDisplayValue as pe}from"../core/metadata.js";import{attributeLabel as Z,buildFacetTable as $e,facetValueOf as re}from"../stats/facets.js";import{makeLabeledSelect as Oe}from"./charts/chartShell.js";import{tableToTsv as ce}from"../core/tableCsv.js";import{commonMetadata as Ne}from"../stats/facets.js";import{buildYieldData as Be}from"../stats/yield.js";import{binFieldOf as Fe,isParametricTest as ee}from"../renderer/buildWaferMap.js";import{fmt as de,fmtRow as Me}from"../renderer/fmt.js";import{testLabel as te}from"../renderer/testLabel.js";import{resolveDieColumns as We}from"./dieList.js";import{createVirtualTable as ue}from"./virtualTable.js";import{exportCsv as oe}from"./tableExport.js";import{CLR as I,FONT as z,LEADING as Ae,RADIUS as he,SPACE as j,controlStyle as ge,openCommandMenu as Ie,wireControlHover as se,wireTooltip as K}from"./toolbar.js";import{buildTestSection as Pe,buildFunctionalTestSection as je,openFieldListCard as Ve,TABLE_CSV as be}from"./summaryPanel.js";import{pooledTestStatsSteps as Re}from"../stats/capability.js";import{runChunked as _e}from"./chunked.js";import{capabilityShade as ze,outOfLimitsShade as Ge,shadesAmong as ye,shortfallShade as we}from"./cellShade.js";import{patTests as He,waferPatVerdicts as Ye,PAT_VERDICT_LABEL as Ke}from"../stats/pat.js";import{DIE_REGIONS as qe,DIE_REGION_KEYS as Ue}from"../stats/dieRegions.js";import{newPlotId as Qe}from"../stats/plotSpec.js";import{conditionForFilter as Xe,plotForColumns as Je}from"../stats/columnPlot.js";import{applyConditions as Ze,passFailOf as et}from"../stats/plotData.js";import{maxGroups as tt}from"../stats/groupEffects.js";import{toPlotItems as nt}from"./plotItems.js";export const DATA_VIEWS=[{key:"statistics",label:"Statistics",hint:"One row per test: count, spread, limits and limit yield"},{key:"wafers",label:"Wafers",hint:"One row per wafer: its attributes, die counts, yield and test means"},{key:"dies",label:"Dies",hint:"One row per die, with its position, bins and every test"}],EXCEL_ROW_LIMIT=1048576,COPY_CELL_LIMIT=2e5,WAFER_TEST_COLUMNS=50;const U=(e,a,s=a+"s")=>`${e.toLocaleString()} ${e===1?a:s}`;function ve(e){const a=(c,d)=>pe(c.wafer?.metadata?.[d])??"",s=[];for(const c of e)for(const d of Object.keys(c.wafer?.metadata??{}))!s.includes(d)&&pe((c.wafer?.metadata)[d])!==void 0&&s.push(d);const i=c=>e.length>1&&e.every(d=>a(d,c)===a(e[0],c));return{metaOf:a,constantKeys:s.filter(i),varyingKeys:s.filter(c=>!i(c))}}export function renderDataSection(e){const{doc:a}=e,s=a.createElement("div");s.dataset.wmapDataTab="1",Object.assign(s.style,{display:"flex",flexDirection:"column",gap:j.md,minWidth:"0"});const i=a.createElement("div");Object.assign(i.style,{display:"flex",alignItems:"center",gap:j.md,flexWrap:"wrap"}),s.appendChild(i);const c=a.createElement("div");Object.assign(c.style,{display:"flex",flexDirection:"column",gap:j.md,minWidth:"0"}),s.appendChild(c);const d=DATA_VIEWS.filter(u=>!e.views||e.views.includes(u.key)),p=me(a,"Table",d,e.view,"wmapDataView",u=>e.onViewChange(u));i.appendChild(p.el);let f;switch(e.view){case"dies":f=ct(e);break;case"wafers":f=dt(e);break;default:f=ot(e)}let m=()=>{};if(e.view==="dies"){const u=me(a,"Export format",[{key:"wide",label:"Wide",hint:"A column for each test"},{key:"long",label:"Long",hint:"A row for each die and test, the shape statistics tools prefer"}],e.diesLayout,"wmapDataLayout",g=>{u.set(g),e.onDiesLayoutChange(g),f.actions?.setLayout?.(g),m()});K(u.el,"Wide: a column per test. Long: a row per die per test, for tools that want tidy data. The table on screen is always wide.");const l=a.createElement("span");Object.assign(l.style,{display:"inline-flex",alignItems:"center",gap:j.sm});const r=a.createElement("span");r.textContent="Export format:",Object.assign(r.style,{color:I.label,fontSize:z.body}),l.append(r,u.el),i.appendChild(l)}if(f.actions){const u=f.actions,l=f.table,r=f.plot&&e.onPlotColumns?f.plot:void 0;let g="filtered";const B=a.createElement("div");Object.assign(B.style,{display:"flex",flexDirection:"column",gap:j.xs,color:I.label,fontSize:z.body});const y=a.createElement("div");y.dataset.wmapDataNote="1",B.appendChild(y),f.shared?.length&&B.appendChild(lt(a,f.shared));const b=a.createElement("details");b.dataset.wmapDataHow="1";const L=a.createElement("summary");L.textContent="How to read this",Object.assign(L.style,{cursor:"pointer",width:"fit-content"}),se(L,"bare");const k=a.createElement("div");Object.assign(k.style,{marginTop:j.xs,lineHeight:Ae.base}),b.append(L,k),B.appendChild(b),s.insertBefore(B,c);const T=a.createElement("div");T.style.flex="1",i.appendChild(T);const M=me(a,"Rows to export",[{key:"filtered",label:"Filtered",hint:"Only the rows that pass the column filters, in the order shown"},{key:"all",label:"All",hint:"Every row of the table, in the order shown, whatever the filters"}],g,"wmapDataScope",W=>{g=W,M.set(W),m()}),F=a.createElement("span");F.dataset.wmapDataScopeGroup="1",Object.assign(F.style,{display:"none",alignItems:"center",gap:j.sm});const V=a.createElement("span");V.textContent="Rows:",Object.assign(V.style,{color:I.label,fontSize:z.body}),F.append(V,M.el),K(M.el,"Export CSV and Copy: only the rows that pass the column filters, or every row. This does not change the table on screen.");const o=J(a,"Clear filters");o.dataset.wmapDataClearFilters="1",o.style.display="none",K(o,"Remove every column filter"),o.addEventListener("click",()=>l?.clearFilters());const x=r?J(a,"Plot columns"):null,C=r?J(a,"Cancel"):null;x&&C&&(x.dataset.wmapDataPlot="1",C.dataset.wmapDataPlotCancel="1",C.style.display="none",K(C,"Stop choosing columns to plot"),C.addEventListener("click",()=>l.setSelecting(!1)),x.addEventListener("click",()=>{if(!l.selecting){l.setSelecting(!0);return}x.getAttribute("aria-disabled")!=="true"&&e.onPlotColumns(r.request(l.selectedColumns()),x)}));const w=J(a,"Export CSV");w.dataset.wmapDataExport="1",w.addEventListener("click",()=>{if(w.disabled)return;const W=w.textContent,R=u.exportCsv(g);R&&(w.disabled=!0,w.setAttribute("aria-busy","true"),R.catch(()=>{}).finally(()=>{w.disabled=!1,w.removeAttribute("aria-busy"),w.textContent=W}))});const E=J(a,"Copy");E.dataset.wmapDataCopy="1",K(E,()=>u.copyAllowed(g)?"Copy the table as tab-separated text, to paste into a spreadsheet":`Too large to copy (over ${COPY_CELL_LIMIT.toLocaleString()} cells). Use Export CSV.`),E.addEventListener("click",()=>{if(!u.copyAllowed(g))return;const W=u.copyText(g),R=a.defaultView?.navigator?.clipboard;if(!R)return;const _=E.textContent;R.writeText(W).then(()=>{E.textContent="Copied",a.defaultView?.setTimeout(()=>{E.textContent=_},1500)}).catch(()=>{})}),i.append(F,o),x&&C&&i.append(C,x),i.append(E,w);let O="";x&&K(x,()=>l.selecting?O||"Open the plot builder on the ticked columns, over the rows shown":"Choose columns to plot: a tick appears under each heading that can be plotted"),m=()=>{const W=!!l&&l.filterSummary()!=="";!W&&g!=="filtered"&&(g="filtered",M.set("filtered")),F.style.display=W?"inline-flex":"none",o.style.display=W?"":"none";const R=u.copyAllowed(g);E.disabled=!R;const _=l?.selecting?l.selectedColumns():[],Q=r&&l?.selecting&&_.length?r.check(_):null,X=u.note(g);if(y.textContent=X.line+(r&&l?.selecting?` ${Q??"Tick the columns to plot, then press Plot."}`:""),k.textContent=X.howTo.join(" "),b.style.display=X.howTo.length?"":"none",x&&C&&l){const G=l.selectedColumns(),q=l.selecting?r.check(G):null;O=q??"",x.setAttribute("aria-disabled",q?"true":"false"),x.style.opacity=q?"0.6":"",x.textContent=l.selecting?G.length?`Plot (${G.length})`:"Plot":"Plot columns",C.style.display=l.selecting?"":"none"}},l?.subscribe(()=>{e.onTableFiltersChange?.(e.view,l.filters()),m()}),m()}if(f.tables){const u=f.tables,l=a.createElement("div");l.style.flex="1";const r=(y,b,L)=>{const k=u();if(k.length===1){L(k[0]);return}k.length&&Ie(y.getBoundingClientRect(),y,k.map(T=>({label:T.title,active:!1,action:!0,closeMenu:!0,onClick:()=>L(T)})),b,{trigger:y})},g=J(a,"Copy");g.dataset.wmapDataCopy="1",K(g,()=>u().length>1?"Copy one of the tables as tab-separated text, to paste into a spreadsheet":"Copy the table as tab-separated text, to paste into a spreadsheet"),g.addEventListener("click",()=>r(g,"Copy which table",y=>{if(!y.copyAllowed)return;const b=a.defaultView?.navigator?.clipboard;if(!b)return;const L=g.textContent;b.writeText(y.copyText()).then(()=>{g.textContent="Copied",a.defaultView?.setTimeout(()=>{g.textContent=L},1500)}).catch(()=>{})}));const B=J(a,"Export CSV");B.dataset.wmapDataExport="1",K(B,()=>u().length>1?"Save one of the tables as a CSV file":"Save the table as a CSV file"),B.addEventListener("click",()=>r(B,"Export which table",y=>{y.exportCsv()})),i.append(l,g,B)}return c.appendChild(f.el),{card:s,destroy:()=>f.destroy()}}function ot(e){const{doc:a}=e,s=a.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:j.lg,minWidth:"0"});const i=[],c=st(e),d=c.some(m=>m.value===e.statsBy)?e.statsBy:c[0].value;if(c.length>1&&e.onStatsByChange){const m=a.createElement("div");m.appendChild(Oe("By",c,d,u=>e.onStatsByChange(u),{hook:"stats-by",ownerDocument:a,hint:"Compare each test\u2019s statistics across the wafers, the test sites or a wafer field"})),s.appendChild(m)}if(d!=="lot"&&d!=="group"){const m=at(e,d),u=c.find(r=>r.value===d).label,l=m.length>1?xe({...e,groupLabelText:u},m):null;if(l)s.appendChild(l.el),i.push(l.destroy);else{const r=a.createElement("div");r.textContent=`No test statistics to compare by ${u.toLowerCase()}.`,Object.assign(r.style,{color:I.label,fontSize:z.body}),s.appendChild(r)}return{el:s,destroy:()=>{for(const r of i)r()},tables:Ce(e,s)}}const p=e.groups&&e.groups.length>0?e.groups:void 0,f=p??[{key:"",items:e.items}];if(p&&p.length>1){const m=xe(e,p);m&&(s.appendChild(m.el),i.push(m.destroy))}for(const m of f){const u=p?a.createElement("div"):s;if(p){u.dataset.wmapStatsGroup=`${e.groupLabelText??"Group"}: ${m.key}`,Object.assign(u.style,{display:"flex",flexDirection:"column",gap:j.lg,minWidth:"0"});const r=a.createElement("div");r.textContent=`${e.groupLabelText??"Group"}: ${m.key}`,Object.assign(r.style,{fontWeight:"700",color:I.text,fontSize:z.body}),u.appendChild(r),s.appendChild(u)}const l=e.buildStatistics(m.items);i.push(l.destroy);for(const r of l.cards)u.appendChild(r)}return!s.querySelector("table")&&!s.textContent&&(s.textContent="No test statistics to show for these wafers.",Object.assign(s.style,{color:I.label,fontSize:z.body})),{el:s,destroy:()=>{for(const m of i)m()},tables:Ce(e,s)}}function st(e){const a=[];e.groups&&e.groups.length>1&&a.push({value:"group",label:e.groupLabelText??"Group"}),a.push({value:"lot",label:e.items.length>1?"Lot":"Wafer"}),e.items.length>1&&a.push({value:"wafer",label:"Wafer"});const s=new Set;for(const i of e.items)for(const c of i.dies)if(c.siteNum!==void 0&&(s.add(c.siteNum),s.size>1))break;s.size>1&&a.push({value:"site",label:"Site"});for(const i of e.byFields??[]){const c=new Set(e.items.map(d=>re(d.wafer?.metadata,i.key,e.attributes)).filter(d=>d!==void 0));c.size>=2&&c.size<=e.items.length/2&&a.push({value:`field:${i.key}`,label:i.label})}return a}function at(e,a){if(a==="wafer")return e.items.map(s=>({key:s.label,items:[s]}));if(a==="site"){const s=new Map;for(const i of e.items){const c=new Map;for(const d of i.dies)d.siteNum!==void 0&&(c.get(d.siteNum)??c.set(d.siteNum,[]).get(d.siteNum)).push(d);for(const[d,p]of c)(s.get(d)??s.set(d,[]).get(d)).push({...i,dies:p,allDies:i.allDies??i.dies})}return[...s].sort((i,c)=>i[0]-c[0]).map(([i,c])=>({key:`Site ${i}`,items:c}))}if(a.startsWith("field:")){const s=a.slice(6),i=new Map;for(const c of e.items){const d=re(c.wafer?.metadata,s,e.attributes);d!==void 0&&(i.get(d)??i.set(d,[]).get(d)).push(c)}return[...i].sort((c,d)=>c[0].localeCompare(d[0],"en",{numeric:!0})).map(([c,d])=>({key:c,items:d}))}return[]}function xe(e,a){const{doc:s}=e,i=e.testDefs.filter(b=>b.testNumber!==void 0&&ee(b));if(i.length===0)return null;const c=e.groupLabelText??"Group",d=s.createElement("div");d.dataset.wmapGroupStats="1",Object.assign(d.style,{display:"flex",flexDirection:"column",gap:j.sm,minWidth:"0"});const p=s.createElement("div");Object.assign(p.style,{display:"flex",alignItems:"center",gap:j.md,flexWrap:"wrap"});const f=s.createElement("div");f.textContent=`Compared across ${c}`,Object.assign(f.style,{fontWeight:"700",color:I.text,fontSize:z.body}),p.appendChild(f);const m=s.createElement("div");m.textContent="Computing test statistics\u2026",Object.assign(m.style,{color:I.label,fontSize:z.body}),d.append(p,m);const u=new Map;let l=a.length,r,g=!1;const B=()=>{if(g)return;const b=[];for(const o of i)for(const x of a){const C=u.get(x.key),w=C?.stats.get(o.testNumber);if(!C||!w)continue;const E=C.specTally.get(o.testNumber);b.push({def:o,group:x.key,count:w.count,min:w.min,q1:w.q1,median:w.median,mean:w.mean,q3:w.q3,max:w.max,stddev:w.stddev,ppk:C.capability.find(O=>O.testNumber===o.testNumber)?.ppk??null,limitYield:E&&E.n>0?100*(1-E.fail/E.n):void 0,below:E&&o.limitLow!==void 0?E.low:void 0,above:E&&o.limitHigh!==void 0?E.high:void 0})}if(b.length===0){d.remove();return}const L=new Map;for(const o of b){const x=L.get(o.def.testNumber);x?x.push(o):L.set(o.def.testNumber,[o])}for(const o of L.values()){const x=o.map(O=>O.median).sort((O,W)=>O-W),C=Me(x[Math.floor(x.length/2)],o[0].def.unit,o[0].def.name);for(const O of o)O.fmtValue=C;const w=ye(o.map(O=>O.mean),C),E=De(o.map(O=>O.limitYield??-1/0));o.forEach((O,W)=>{O.meanShade=w[W],O.yieldShade=O.limitYield===void 0||!Number.isFinite(E)?void 0:we(O.limitYield-E)})}const k=o=>({get:x=>(x.fmtValue??(C=>de(C,x.def.unit)))(o(x)),numeric:!0,sortKey:o}),T=(o,x)=>({get:C=>{const w=o(C);return w===void 0||!Number.isFinite(w)?"":x(w)},numeric:!0,sortKey:C=>{const w=o(C);return w===void 0||!Number.isFinite(w)?void 0:w}}),M=[{header:"Test",get:o=>`${te(o.def,o.def.testNumber)}${o.def.unit?` (${o.def.unit})`:""}`},{header:c,get:o=>o.group},{header:"N",...T(o=>o.count,o=>String(o))},{header:"Min",...k(o=>o.min)},{header:"Q1",...k(o=>o.q1)},{header:"Median",...k(o=>o.median)},{header:"Mean",...k(o=>o.mean),shade:o=>o.meanShade},{header:"Q3",...k(o=>o.q3)},{header:"Max",...k(o=>o.max)},{header:"Std dev",...k(o=>o.stddev)},{header:"Below lo",...T(o=>o.below,o=>o.toLocaleString("en-GB"))},{header:"Above hi",...T(o=>o.above,o=>o.toLocaleString("en-GB"))},{header:"Ppk",...T(o=>o.ppk??void 0,o=>o.toFixed(2)),shade:o=>ze(o.ppk)},{header:"Limit yield %",...T(o=>o.limitYield,o=>o.toFixed(1)),shade:o=>o.yieldShade}],F=ue({columns:M,rows:b,ariaLabel:`Statistics by ${c} (${b.length})`,ownerDocument:s});F.el.style.maxHeight="50vh",F.el.style.minHeight="120px",r=F;const V=()=>[{header:"Test number",get:o=>o.def.testNumber??null},{header:"Test",get:o=>te(o.def,o.def.testNumber)},{header:"Unit",get:o=>o.def.unit??""},{header:c,get:o=>o.group},{header:"N",get:o=>o.count},{header:"Min",get:o=>o.min},{header:"Q1",get:o=>o.q1},{header:"Median",get:o=>o.median},{header:"Mean",get:o=>o.mean},{header:"Q3",get:o=>o.q3},{header:"Max",get:o=>o.max},{header:"Std dev",get:o=>o.stddev},{header:"Below lo",get:o=>o.below??null},{header:"Above hi",get:o=>o.above??null},{header:"Ppk",get:o=>o.ppk},{header:"Limit yield %",get:o=>o.limitYield??null}];d.dataset.wmapTableCsv="group-stats",be.set(d,{title:`Compared across ${c}`,fileName:`statistics-by-${c.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.csv`,build:()=>({columns:V(),rows:[...F.orderedRows()]}),save:()=>oe(V(),F.orderedRows(),`statistics-by-${c.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.csv`,e.onSaveText,{rowCount:b.length})}),m.replaceWith(F.el)},y=[];for(const b of a)y.push(_e(Re(b.items.map(L=>({dies:L.dies})),i),{onDone:L=>{u.set(b.key,L),--l===0&&B()}}));return{el:d,destroy:()=>{g=!0;for(const b of y)b.cancel();r?.destroy()}}}function it(e,a,s){if(He(a).length===0)return;const i=new Map;for(const p of e){const f=p.allDies??(s?void 0:p.dies);if(!f)continue;const m=Ye(f,a,p.passBins);f.forEach((u,l)=>i.set(u,m[l]))}if(i.size===0)return;const c=p=>{const f=a.find(m=>m.testNumber===p);return f?te(f,p):`Test ${p}`};let d=!1;for(const p of i.values())if(p.verdict==="outlier"){d=!0;break}return{verdict:p=>{const f=i.get(p)?.verdict;return f?Ke[f]:void 0},tests:p=>{const f=i.get(p);return f?.verdict==="outlier"?f.tests.map(c).join("; "):""},anyOutlier:d}}function Ce(e,a){return()=>[...a.querySelectorAll("[data-wmap-table-csv]")].flatMap(s=>{const i=be.get(s);if(!i)return[];const c=s.closest("[data-wmap-stats-group]")?.dataset.wmapStatsGroup;return[{title:c?`${i.title}, ${c}`:i.title,exportCsv:()=>i.save(),copyText:()=>{const p=i.build();return ce(p.columns,p.rows)},copyAllowed:(()=>{const p=i.build();return p.rows.length*p.columns.length<=COPY_CELL_LIMIT})()}]})}function Se(e,a,s){const i=e.filterSummary();return i?a==="filtered"?` Filtered by ${i}. A file holds the ${s(e.length)} shown, of ${e.totalLength.toLocaleString()}.`:` Filtered by ${i}. A file holds all ${s(e.totalLength)}: the filters are not applied.`:""}function lt(e,a){const s=e.createElement("button");s.type="button",s.dataset.wmapDataShared=String(a.length),s.textContent=`${a.length===1?"1 field is":`${a.length} fields are`} the same on every wafer \u25B8`,s.setAttribute("aria-expanded","false"),s.setAttribute("aria-haspopup","dialog"),Object.assign(s.style,{...ge("bare"),color:I.iconActive,alignSelf:"flex-start",fontSize:z.body}),se(s,"bare"),K(s,"Fields every wafer here shares. They are not columns of the table; every export holds them.");let i=null;return s.addEventListener("click",()=>{if(i){i();return}i=Ve({anchor:s,trigger:s,pairs:a,label:"Fields the same on every wafer",onClose:()=>{i=null}})}),s}const fe=(e,a)=>a==="filtered"&&e.filterSummary()?"-filtered":"",rt={X:{builtin:"x"},Y:{builtin:"y"},Site:{builtin:"site"},"Hard bin":{builtin:"hbin"},"Soft bin":{builtin:"sbin"},"Pass / fail":{builtin:"passFail"},Wafer:{builtin:"wafer"},...Object.fromEntries(Ue.map(e=>[qe[e].label,{builtin:e}]))};function Le(e,a,s,i,c,d){const p=m=>Je(m.map(u=>({field:s[u],label:i[u]})),c,Qe()),f=()=>{const m=a.filters(),u=[],l=[],r=[];if(i.forEach((b,L)=>{const k=m[b];if(!k)return;const T=s[L],M=T?Xe(T,k):void 0;M&&!("reason"in M)?(u.push(M),l.push(b)):r.push(b)}),u.length===0)return{conditions:u,notSaved:r};const g=nt(d(a.rowsPassing(r)).map(b=>({...b,ringCount:e.ringCount}))),B=Ze(u,g,{testDefs:e.allTestDefs,curation:e.attributes});return!B.issue&&(c==="wafer"?B.wafers.kept:B.dies.kept)===a.length?{conditions:u,notSaved:r}:{conditions:[],notSaved:Object.keys(m)}};return{check:m=>{const u=p(m);return"problem"in u?u.problem:null},request:m=>{const u=p(m);if("problem"in u)throw new Error(u.problem);const{conditions:l,notSaved:r}=f();return{plot:l.length?{...u.plot,where:{conditions:l}}:u.plot,items:d(a.rowsPassing(r)),population:r.length?`filtered by ${a.filterSummary(r)} (not saved with the chart)`:"in the table"}}}}function ct(e){const{doc:a,items:s}=e,i=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,f=[];let m=!1;for(const n of s){n.wafer&&(m=!0);for(const S of n.dies)p.set(S,n),i.set(S,n.label),d.set(S,n.waferIndex),n.wafer&&c.set(S,n.wafer),f.push(S)}if(f.length===0)return Te(a,"No dies to show.");const u=it(s,e.allTestDefs,!!e.population),{columns:l,visibleColumns:r}=We(f,e.allTestDefs,{...e.dieListOptions,...u?{patColumns:u}:{},metadataFields:e.metadataFields,extraColumn:s.length>1||e.population?{label:"Wafer",get:n=>i.get(n)}:void 0,getWafer:m?(n=>c.get(n)):void 0,ringCount:e.ringCount,waferMetadata:s.some(n=>n.wafer)?Ne(s.map(n=>({metadata:n.wafer?.metadata}))):void 0,attributes:e.attributes,ownerDocument:a}),g=ve(s),B=n=>new Set(s.map(S=>re(S.wafer?.metadata,n,e.attributes)??"")).size,y=s.length>1?$e(s.map(n=>({metadata:n.wafer?.metadata})),{facetableOnly:!0,curation:e.attributes}).filter(n=>n.splittable&&g.varyingKeys.includes(n.key)&&B(n.key)<=tt(s.length)).map(n=>n.key):[],b=e.groupLabelText?y.find(n=>Z(n,e.attributes)===e.groupLabelText):void 0,L=b?[b,...y.filter(n=>n!==b)]:y,k=new Set(l.map(n=>n.label)),T=L.map(n=>({key:n,column:{label:Z(n,e.attributes),get:S=>{const D=p.get(S);return D?g.metaOf(D,n):""}}})).filter(n=>!k.has(n.column.label)),M=new Map(T.map(n=>[n.column,{meta:n.key}]));if(!k.has("Pass / fail")&&f.some(n=>n.hbin!==void 0||n.sbin!==void 0)){const n=new Map,S={label:"Pass / fail",get:$=>{const A=p.get($);if(!A)return"";let H=n.get(A);return H||(H=new Set(A.passBins),n.set(A,H)),et($,H)??""}},D=$=>{const A=Math.max($.findIndex(t=>t.label==="Soft bin"),$.findIndex(t=>t.label==="Hard bin")),H=[...$];return H.splice(A>=0?A+1:H.length,0,S),H};l.splice(0,l.length,...D(l)),r.splice(0,r.length,...D(r))}if(T.length){const n=S=>{const D=S.findIndex(A=>A.label==="Wafer"),$=[...S];return $.splice(D+1,0,...T.map(A=>A.column)),$};l.splice(0,l.length,...n(l)),r.splice(0,r.length,...n(r))}const F=n=>M.get(n)??(n.test!==void 0?ee(n.test)?{test:n.test.testNumber,...n.test.name?{name:n.test.name}:{}}:void 0:rt[n.label]),V=r.map(n=>({header:n.label,get:n.get,numeric:n.test!==void 0&&ee(n.test),...F(n)?{plotField:F(n)}:{},...n.test!==void 0&&ee(n.test)?{sortKey:S=>le(S,n.test.testNumber),shade:S=>{const D=n.test,$=le(S,D.testNumber);return $!==void 0&&Number.isFinite($)&&(D.limitLow!==void 0&&$<D.limitLow||D.limitHigh!==void 0&&$>D.limitHigh)?Ge():void 0}}:{}})),o=ue({columns:V,rows:f,ariaLabel:`Dies (${f.length})`,ownerDocument:a,filters:e.tableFilters?.dies,selectable:!!e.onPlotColumns,onRowClick:e.onLocateDie?(n,S,D)=>e.onLocateDie(n,d.get(n),r[D]?.test?.testNumber):void 0});o.el.style.maxHeight="70vh",o.el.style.minHeight="240px";const x=e.population?`-${e.population.fileTag}`:"",C=l.filter(n=>n.test!==void 0),w=l.filter(n=>n.test===void 0),E=n=>n==="all"?f.length:o.length,O=n=>E(n)*C.length,W=()=>l.map(n=>({header:n.csvLabel??n.label,get:n.csvGet??n.get})),R=()=>[...w.map(n=>({header:n.csvLabel??n.label,get:S=>(n.csvGet??n.get)(S.die)})),{header:"Test",get:n=>te(n.test,n.test.testNumber)},{header:"Test number",get:n=>n.test.testNumber},{header:"Unit",get:n=>n.test.unit??""},{header:"Value",get:n=>n.value}];function*_(n){for(const S of o.orderedRows(n))for(const D of C){const $=(D.csvGet??D.get)(S);$===""||$===void 0||$===null||(yield{die:S,test:D.test,value:$})}}let Q=e.diesLayout==="long"&&C.length>0;const X=n=>Q?`Long format: up to ${U(O(n),"row")} (a die with no result for a test has no row)`+(O(n)>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()}).`:"."):`Wide format: ${U(E(n),"row")} \xD7 ${U(l.length,"column")}`+(E(n)>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()} rows).`:"."),G=n=>U(n,"die"),q=r.map(F),P=n=>{const S=new Set(n);return s.flatMap(D=>{const $=S.size===f.length?D.dies:D.dies.filter(A=>S.has(A));return $.length===0?[]:[$.length===D.dies.length?D:{...D,dies:$,allDies:D.allDies??D.dies}]})};return{el:o.el,table:o,destroy:()=>o.destroy(),shared:g.constantKeys.map(n=>[Z(n,e.attributes),g.metaOf(s[0],n)]),...q.some(n=>n)?{plot:Le(e,o,q,r.map(n=>n.label),"die",P)}:{},actions:{note:n=>({line:`${o.filterSummary()?`${o.length.toLocaleString()} of ${G(f.length)} shown`:G(f.length)} ${e.population?.phrase??`on ${U(s.length,"wafer")}`}.${Se(o,n,G)}`,howTo:[...T.length?[`${ke(T.map(S=>S.column.label))} ${T.length===1?"is a field":"are fields"} of each die\u2019s wafer.`]:[],X(n),"The export follows the order shown and holds every field, the shared ones too.",...e.onLocateDie?["Click a row to see that die ringed on the map of its wafer, on the test whose column you click."]:[]]}),setLayout:n=>{Q=n==="long"&&C.length>0},exportCsv:n=>Q?oe(R(),_(n),`die-list-long${x}${fe(o,n)}.csv`,e.onSaveText,{rowCount:O(n)}):oe(W(),o.orderedRows(n),`die-list${x}${fe(o,n)}.csv`,e.onSaveText,{rowCount:E(n)}),copyAllowed:n=>E(n)*l.length<=COPY_CELL_LIMIT,copyText:n=>ce(W(),o.orderedRows(n))}}}function dt(e){const{doc:a,items:s}=e;if(s.length===0)return Te(a,"No wafers to show.");const i=s.map(t=>{const h=e.yieldByWaferIndex.get(t.waferIndex),N=Be([{label:t.label,dies:t.dies,passBins:t.passBins,yieldPercent:h,key:t.waferIndex}])[0]?.percent;return{item:t,yieldPercent:t.dies.length?N??null:null}}),c=ve(s),d=e.testDefs.slice(0,WAFER_TEST_COLUMNS),p=(t,h)=>{const N=t.item.statsSummary?.stats.perTestStats?.find(ne=>ne.testNumber===h.testNumber);if(N)return N.mean;let v=0,Y=0;for(const ne of t.item.dies){if(!ie(ne))continue;const ae=le(ne,h.testNumber);ae!==void 0&&Number.isFinite(ae)&&(v++,Y+=ae)}return v?Y/v:void 0},f=(t,h)=>c.metaOf(t.item,h),m=t=>({header:Z(t,e.attributes),cell:h=>f(h,t),field:{meta:t}}),{constantKeys:u,varyingKeys:l}=c,r=e.groupLabelText?l.find(t=>Z(t,e.attributes)===e.groupLabelText):void 0,g=i.map(t=>t.yieldPercent).filter(t=>t!==null&&Number.isFinite(t)),B=g.length?Ee([...g].sort((t,h)=>t-h)):void 0,y=Fe(s.map(t=>t.dies)),b=y==="sbin"?"Soft bin":"Bin",L=i.map(t=>{const h=new Map;for(const N of t.item.dies){const v=N[y];ie(N)&&v!==void 0&&h.set(v,(h.get(v)??0)+1)}return h}),k=L.map(t=>[...t.values()].reduce((h,N)=>h+N,0)),T=new Map;for(const t of L)for(const[h,N]of t)T.set(h,(T.get(h)??0)+N);const M=new Set(s.flatMap(t=>t.passBins)),F=[...T.keys()].sort((t,h)=>Number(M.has(h))-Number(M.has(t))||T.get(h)-T.get(t)||t-h),V=8,o=new Map(i.map((t,h)=>[t,h])),x=t=>{const h=v=>L[o.get(v)].get(t)??0,N=v=>{const Y=k[o.get(v)];return Y?100*h(v)/Y:0};return{header:`${b} ${t}${M.has(t)?" (pass)":""}`,cell:h,numeric:!0,show:v=>`${h(v).toLocaleString("en-GB")} \xB7 ${N(v).toFixed(1)}%`,opens:"bins"}},C=t=>t.item.dies.filter(h=>ie(h)).length,w=i.some(t=>C(t)!==t.item.dies.length),E=[{header:"Dies",cell:t=>t.item.dies.length,numeric:!0,field:{builtin:"dieCount"}},...w?[{header:"Yield-eligible dies",cell:C,numeric:!0}]:[],{header:"Yield %",cell:t=>t.yieldPercent===null?"":t.yieldPercent,show:t=>t.yieldPercent===null?"":t.yieldPercent.toFixed(1),numeric:!0,shade:t=>t.yieldPercent===null||B===void 0?void 0:we(t.yieldPercent-B),opens:"bins",field:{builtin:"yield"}},...d.map(t=>{const h=new Map,N=ye(i.map(v=>p(v,t)??NaN),v=>de(v,t.unit));return i.forEach((v,Y)=>h.set(v,N[Y])),{header:`${te(t,t.testNumber)}${t.unit?` (${t.unit})`:""} mean`,cell:v=>p(v,t),show:v=>{const Y=p(v,t);return Y===void 0?"":de(Y,t.unit)},numeric:!0,shade:v=>h.get(v),opens:{testNumber:t.testNumber},field:{test:t.testNumber,...t.name?{name:t.name}:{}}}})],O=t=>i.every(h=>f(h,t)===h.item.label),W=[{header:"Wafer",cell:t=>t.item.label,field:{builtin:"wafer"}},...r?[m(r)]:[],...E],R=l.filter(t=>t!==r&&!O(t)).map(m),_=[...W,...F.slice(0,V).map(x),...R],Q=new Map(i.map((t,h)=>[t,h])),X=(t,h)=>({header:`${h.header} %`,cell:N=>{const v=Q.get(N);return k[v]?100*(L[v].get(t)??0)/k[v]:0},numeric:!0}),G=[...W,...R,...w?[]:[{header:"Yield-eligible dies",cell:C,numeric:!0}],...F.flatMap(t=>{const h=x(t);return[h,X(t,h)]}),...l.filter(t=>O(t)&&t!==r).map(m),...u.map(m)],q=_.map(t=>({header:t.header,get:h=>t.show?t.show(h):String(t.cell(h)??""),numeric:t.numeric,...t.field?{plotField:t.field}:{},...t.shade?{shade:t.shade}:{},...t.numeric?{sortKey:h=>{const N=t.cell(h);return typeof N=="number"?N:void 0}}:{}})),P=ue({columns:q,rows:i,ariaLabel:`Wafers (${i.length})`,ownerDocument:a,filters:e.tableFilters?.wafers,selectable:!!e.onPlotColumns,onRowClick:e.onOpenWafer?(t,h,N)=>{const v=_[N]?.opens;e.onOpenWafer(t.item.waferIndex,t.item.label,typeof v=="object"?v.testNumber:void 0,v==="bins"?"bins":void 0)}:void 0});P.el.style.maxHeight="70vh",P.el.style.minHeight="120px";const n=()=>G.map(t=>({header:t.header,get:t.cell})),S=[...e.testDefs.length>d.length?[`Mean columns cover the first ${d.length} of ${e.testDefs.length} tests.`]:[],...F.length>V?[`Bin columns show ${V} of ${F.length} hard bins; the export has every one.`]:[],...F.length?["A bin cell is its dies and their share of the wafer\u2019s judged dies."]:[]],D=P.el,$=t=>U(t,"wafer"),A=t=>t==="all"?i.length:P.length,H=t=>{const h=new Set(t);return i.filter(N=>h.has(N)).map(N=>N.item)};return{el:D,table:P,destroy:()=>P.destroy(),shared:u.map(t=>[Z(t,e.attributes),f(i[0],t)]),..._.some(t=>t.field)?{plot:Le(e,P,_.map(t=>t.field),_.map(t=>t.header),"wafer",H)}:{},actions:{note:t=>({line:`${P.filterSummary()?`${P.length.toLocaleString()} of ${$(i.length)} shown`:$(i.length)}.${Se(P,t,$)}`,howTo:[...S,...e.onOpenWafer?["Click a row to open that wafer, on the test whose mean you click, or on its bins for its yield."]:[],"The export follows the order shown and holds every field, the shared ones too."]}),exportCsv:t=>oe(n(),P.orderedRows(t),`wafers${fe(P,t)}.csv`,e.onSaveText,{rowCount:A(t)}),copyAllowed:t=>A(t)*G.length<=COPY_CELL_LIMIT,copyText:t=>ce(n(),P.orderedRows(t))}}}function Te(e,a){const s=e.createElement("div");return s.textContent=a,Object.assign(s.style,{color:I.label,fontSize:z.body,padding:j.md}),{el:s,destroy:()=>{}}}function J(e,a){const s=e.createElement("button");return s.type="button",s.textContent=a,Object.assign(s.style,{fontSize:z.body,padding:"3px 10px",borderRadius:he.control,...ge("outlined"),background:I.menuBg}),se(s),s}function me(e,a,s,i,c,d){const p=e.createElement("div");p.setAttribute("role","radiogroup"),p.setAttribute("aria-label",a),Object.assign(p.style,{display:"inline-flex",background:I.menuBg,border:`1px solid ${I.menuBorder}`,borderRadius:he.control,overflow:"hidden"});const f=[];let m=i;const u=()=>{for(const l of f){const r=l.dataset[c]===m;l.setAttribute("aria-checked",String(r)),l.tabIndex=r?0:-1,Object.assign(l.style,{background:r?I.bgActive:"transparent",color:r?I.iconActive:I.label,fontWeight:r?"600":"400"})}};for(const l of s){const r=e.createElement("button");l.hint&&K(r,l.hint),r.type="button",r.textContent=l.label,r.dataset[c]=l.key,r.setAttribute("role","radio"),Object.assign(r.style,{border:"none",cursor:"pointer",fontSize:z.body,padding:`${j.xs} ${j.md}`,whiteSpace:"nowrap"}),se(r,"bare"),r.addEventListener("click",()=>{m!==l.key&&d(l.key)}),f.push(r),p.appendChild(r)}return u(),p.addEventListener("keydown",l=>{if(l.key!=="ArrowLeft"&&l.key!=="ArrowRight")return;const r=f.indexOf(e.activeElement);if(r<0)return;l.preventDefault();const g=f[(r+(l.key==="ArrowRight"?1:-1)+f.length)%f.length];g.click(),g.focus()}),{el:p,set:l=>{m=l,u()}}}export function renderDataTables(e){const{doc:a}=e,s=a.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",flex:"1",padding:j.md});const i=e.items.map((y,b)=>({...y,waferIndex:y.waferIndex??b})),c=i.flatMap(y=>y.dies),d=e.testDefs??[],p=d.filter(ee),f=e.views??(i.length>1?["statistics","wafers","dies"]:["statistics","dies"]),m=e.population?{populationLabel:`${U(c.length,"die")} ${e.population}`}:i.length>1?{perWaferMetadata:i.map(y=>y.wafer?.metadata??{}),populationLabel:`all dies of ${U(i.length,"wafer")}`}:{waferMetadata:i[0]?.wafer?.metadata};let u=f.includes(e.view)?e.view:f[0],l="wide";const r={};let g=null;const B=()=>{g?.destroy(),g=renderDataSection({doc:a,items:i,testDefs:p,allTestDefs:d,ringCount:e.ringCount,yieldByWaferIndex:new Map,onSaveText:e.onSaveText,views:f,view:u,dieListOptions:e.dieListOptions,metadataFields:e.metadataFields,attributes:e.attributes,onLocateDie:e.onLocateDie,population:e.population?{phrase:e.population,fileTag:"selection"}:void 0,buildStatistics:y=>{const b=y.flatMap(M=>M.dies),L=[],k=Pe(b,p,void 0,void 0,e.onSaveText,m,y.map(M=>({dies:M.dies})),void 0,"full");k&&L.push(k);const T=je(b,d,void 0,e.onSaveText,m);return T&&L.push(T),{cards:L,destroy:()=>{}}},onViewChange:y=>{u=y,B()},diesLayout:l,onDiesLayoutChange:y=>{l=y},tableFilters:r,onTableFiltersChange:(y,b)=>{r[y]=b}}),s.replaceChildren(g.card)};return B(),{el:s,destroy:()=>g?.destroy()}}export function renderSelectionTables(e){return renderDataTables({...e,views:e.items.length>1?["statistics","wafers","dies"]:["statistics","dies"]})}
|
|
@@ -9,4 +9,4 @@ import{requireRingCount as K}from"../core/ringCount.js";import{hasPosition as P,
|
|
|
9
9
|
padding: 4px 8px; color: ${f.text};
|
|
10
10
|
border-bottom: 1px solid ${f.menuBorder}; white-space: nowrap;
|
|
11
11
|
}
|
|
12
|
-
`,n.head.appendChild(r)}function c(n,r,t,l){const s=n.createElement(r);return t&&Object.assign(s.style,t),l!==void 0&&(s.textContent=l),s}function te(n){return P(n)?String(n.x):""}function ne(n){return P(n)?String(n.y):""}function le(n,r){return r!==void 0?r.filter(t=>t.testNumber!==void 0):G(n,"values").map(t=>({testNumber:t,name:A(void 0,t)}))}function re(n,r,t){if(!r)return[];const l=K(t,"the die list"),s=[];for(const v of O){const p=D[v],u=o=>({wafer:r(o),ringCount:l});if(!n.some(o=>M(o)&&p.valueOf(o,u(o))!==void 0))continue;const h=new Map,a=o=>{let e=h.get(o);return e===void 0&&(e=p.valueOf(o,u(o))??"",h.set(o,e)),e};s.push({label:p.label,get:a,...p.rawOf?{csvGet:o=>p.rawOf(o,u(o))??""}:{}})}return s}export function resolveDieColumns(n,r,t={}){const l=le(n,r),s=re(n,t.getWafer,t),v=n.some(e=>e.edgeExcluded===!0),p=[...t.extraColumn?[t.extraColumn.label]:[],"X","Y",...O.map(e=>D[e].label),"Edge excluded","Site","Hard bin","Soft bin","PAT","PAT tests",...l.map(e=>L(A(e,e.testNumber),e.unit))],{columns:u,truncatedKeys:h}=z({dies:n,waferMetadata:t.waferMetadata,metadataFields:t.metadataFields,dieKeys:t.metadataColumns,waferKeys:t.waferMetadataColumns==="none"?"none":void 0,waferPlacement:t.waferMetadataColumns??"csv",reservedLabels:p,curation:t.attributes}),a=[...t.extraColumn?[{label:t.extraColumn.label,get:e=>t.extraColumn.get(e)??""}]:[],{label:"X",get:te},{label:"Y",get:ne},...s,...v?[{label:"Edge excluded",get:e=>e.edgeExcluded?"Yes":"No"}]:[],{label:"Site",get:e=>e.siteNum!==void 0?String(e.siteNum):""},{label:"Hard bin",get:e=>e.hbin!==void 0?String(e.hbin):""},{label:"Soft bin",get:e=>e.sbin!==void 0?String(e.sbin):""},...t.patColumns?[{label:"PAT",get:e=>t.patColumns.verdict(e)??""},...t.patColumns.anyOutlier?[{label:"PAT tests",get:e=>t.patColumns.tests(e)}]:[]]:[],...l.map(e=>{const y=!_(e);return{test:e,label:L(H(e,e.testNumber),e.unit),...Q(e)?{csvLabel:`${L(A(e,e.testNumber),e.unit)} [derived from ${J(e)??Z}]`}:{},get:d=>{if(y){const m=E(d,e.testNumber,e);return m===void 0?"":m?"PASS":"FAIL"}const x=R(d,e.testNumber);if(x!==void 0)return U(x,e.unit);const C=E(d,e.testNumber,e);return C===void 0?"":C?"PASS":"FAIL"},csvGet:d=>{if(y){const m=E(d,e.testNumber,e);return m===void 0?"":m?"PASS":"FAIL"}const x=R(d,e.testNumber);if(x!==void 0)return x;const C=E(d,e.testNumber,e);return C===void 0?"":C?"PASS":"FAIL"}}}),...u.map(e=>({label:e.label,get:e.get,csvOnly:e.csvOnly}))],o=a.filter(e=>!e.csvOnly);return{columns:a,visibleColumns:o,testColumns:l,truncatedKeys:h}}export function buildDieListSection(n,r,t={}){if(!n.length)return null;const l=t.ownerDocument??document;ensureStylesInjected(l);const s=t.maxRows??ee,v=Math.max(0,n.length-s),p=v>0?n.slice(0,s):n,u=c(l,"div",{display:"flex",flexDirection:"column",gap:V.md,flex:"1",minHeight:"0",minWidth:"0"}),h=c(l,"div",{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:"0"});h.appendChild(c(l,"div",{fontSize:w.
|
|
12
|
+
`,n.head.appendChild(r)}function c(n,r,t,l){const s=n.createElement(r);return t&&Object.assign(s.style,t),l!==void 0&&(s.textContent=l),s}function te(n){return P(n)?String(n.x):""}function ne(n){return P(n)?String(n.y):""}function le(n,r){return r!==void 0?r.filter(t=>t.testNumber!==void 0):G(n,"values").map(t=>({testNumber:t,name:A(void 0,t)}))}function re(n,r,t){if(!r)return[];const l=K(t,"the die list"),s=[];for(const v of O){const p=D[v],u=o=>({wafer:r(o),ringCount:l});if(!n.some(o=>M(o)&&p.valueOf(o,u(o))!==void 0))continue;const h=new Map,a=o=>{let e=h.get(o);return e===void 0&&(e=p.valueOf(o,u(o))??"",h.set(o,e)),e};s.push({label:p.label,get:a,...p.rawOf?{csvGet:o=>p.rawOf(o,u(o))??""}:{}})}return s}export function resolveDieColumns(n,r,t={}){const l=le(n,r),s=re(n,t.getWafer,t),v=n.some(e=>e.edgeExcluded===!0),p=[...t.extraColumn?[t.extraColumn.label]:[],"X","Y",...O.map(e=>D[e].label),"Edge excluded","Site","Hard bin","Soft bin","PAT","PAT tests",...l.map(e=>L(A(e,e.testNumber),e.unit))],{columns:u,truncatedKeys:h}=z({dies:n,waferMetadata:t.waferMetadata,metadataFields:t.metadataFields,dieKeys:t.metadataColumns,waferKeys:t.waferMetadataColumns==="none"?"none":void 0,waferPlacement:t.waferMetadataColumns??"csv",reservedLabels:p,curation:t.attributes}),a=[...t.extraColumn?[{label:t.extraColumn.label,get:e=>t.extraColumn.get(e)??""}]:[],{label:"X",get:te},{label:"Y",get:ne},...s,...v?[{label:"Edge excluded",get:e=>e.edgeExcluded?"Yes":"No"}]:[],{label:"Site",get:e=>e.siteNum!==void 0?String(e.siteNum):""},{label:"Hard bin",get:e=>e.hbin!==void 0?String(e.hbin):""},{label:"Soft bin",get:e=>e.sbin!==void 0?String(e.sbin):""},...t.patColumns?[{label:"PAT",get:e=>t.patColumns.verdict(e)??""},...t.patColumns.anyOutlier?[{label:"PAT tests",get:e=>t.patColumns.tests(e)}]:[]]:[],...l.map(e=>{const y=!_(e);return{test:e,label:L(H(e,e.testNumber),e.unit),...Q(e)?{csvLabel:`${L(A(e,e.testNumber),e.unit)} [derived from ${J(e)??Z}]`}:{},get:d=>{if(y){const m=E(d,e.testNumber,e);return m===void 0?"":m?"PASS":"FAIL"}const x=R(d,e.testNumber);if(x!==void 0)return U(x,e.unit);const C=E(d,e.testNumber,e);return C===void 0?"":C?"PASS":"FAIL"},csvGet:d=>{if(y){const m=E(d,e.testNumber,e);return m===void 0?"":m?"PASS":"FAIL"}const x=R(d,e.testNumber);if(x!==void 0)return x;const C=E(d,e.testNumber,e);return C===void 0?"":C?"PASS":"FAIL"}}}),...u.map(e=>({label:e.label,get:e.get,csvOnly:e.csvOnly}))],o=a.filter(e=>!e.csvOnly);return{columns:a,visibleColumns:o,testColumns:l,truncatedKeys:h}}export function buildDieListSection(n,r,t={}){if(!n.length)return null;const l=t.ownerDocument??document;ensureStylesInjected(l);const s=t.maxRows??ee,v=Math.max(0,n.length-s),p=v>0?n.slice(0,s):n,u=c(l,"div",{display:"flex",flexDirection:"column",gap:V.md,flex:"1",minHeight:"0",minWidth:"0"}),h=c(l,"div",{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:"0"});h.appendChild(c(l,"div",{fontSize:w.body,fontWeight:"600",letterSpacing:B,textTransform:"uppercase",color:f.label},t.title??`Die list (${n.length})`));const a=c(l,"button",{fontSize:w.body,padding:"3px 8px",borderRadius:k.control,...j("outlined"),background:f.menuBg},"Export CSV");a.type="button",W(a),h.appendChild(a),u.appendChild(h),t.note&&u.appendChild(c(l,"div",{fontSize:w.body,color:f.label,lineHeight:N.base,flexShrink:"0"},t.note));const{columns:o,visibleColumns:e,testColumns:y,truncatedKeys:d}=resolveDieColumns(n,r,t),x=q(y.map(i=>({label:H(i,i.testNumber),...X(i)})));x&&u.appendChild(c(l,"div",{fontSize:w.body,color:f.label,lineHeight:N.base,flexShrink:"0"},x));const C=c(l,"div",{overflow:"auto",flex:"1",minHeight:"0",minWidth:"0",border:`1px solid ${f.menuBorder}`,borderRadius:k.control,...t.maxHeight?{maxHeight:t.maxHeight}:{}}),m=l.createElement("table");m.className="wmap-dielist-table",m.setAttribute("aria-label",t.title??`Die list (${n.length} dies)`);const $=c(l,"thead"),T=c(l,"tr");for(const i of e){const b=l.createElement("th");b.className="wmap-dielist-th",b.scope="col",b.textContent=i.label,T.appendChild(b)}$.appendChild(T),m.appendChild($);const I=c(l,"tbody");for(const i of p){const b=c(l,"tr");for(const g of e){const S=l.createElement("td");S.className="wmap-dielist-td",S.textContent=g.get(i),b.appendChild(S)}I.appendChild(b)}if(m.appendChild(I),C.appendChild(m),u.appendChild(C),v>0||d.length>0){const i=[];v>0&&i.push(`Showing the first ${s.toLocaleString()} of ${n.length.toLocaleString()} dies. The CSV export contains all ${n.length.toLocaleString()}.`),d.length>0&&i.push(`${d.length} further metadata field${d.length===1?"":"s"} not shown.`),u.appendChild(c(l,"div",{fontSize:w.body,color:f.label,lineHeight:N.base,flexShrink:"0"},i.join(" ")))}return a.addEventListener("click",()=>{if(a.disabled)return;const i=a.textContent,b=Y(o.map(g=>({header:g.csvLabel??g.label,get:g.csvGet??g.get})),n,"die-list.csv",t.onSaveText,{onProgress:(g,S)=>{a.textContent=S?`Exporting ${Math.floor(100*g/S)}%`:`Exporting ${g.toLocaleString()} rows`}});b&&(a.disabled=!0,a.setAttribute("aria-busy","true"),b.catch(()=>{}).finally(()=>{a.disabled=!1,a.removeAttribute("aria-busy"),a.textContent=i}))}),u}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import './charts/divergingScale.js';
|
|
2
1
|
import { type TestDef } from '../renderer/buildWaferMap.js';
|
|
3
2
|
import type { Die } from '../core/dies.js';
|
|
4
3
|
import { type SaveImageHandler } from './charts/chartShell.js';
|
|
4
|
+
import type { ReaderColors } from './charts/divergingScale.js';
|
|
5
5
|
import { type RenderableWaferMap } from './renderWaferMap.js';
|
|
6
6
|
export interface DifferenceMapPanelOptions {
|
|
7
7
|
groups: ReadonlyArray<{
|
|
@@ -18,6 +18,8 @@ export interface DifferenceMapPanelOptions {
|
|
|
18
18
|
selectedTestNumber?: number;
|
|
19
19
|
onSaveImage?: SaveImageHandler;
|
|
20
20
|
ownerDocument?: Document;
|
|
21
|
+
/** The reader's data colours: the map draws the chosen scheme's signed scale. */
|
|
22
|
+
readerColors?: ReaderColors;
|
|
21
23
|
}
|
|
22
24
|
export declare function renderDifferenceMapPanel(o: DifferenceMapPanelOptions): {
|
|
23
25
|
card: HTMLElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{NEGLIGIBLE_SPREAD as L}from"../core/utils.js";import{differenceMap as Y}from"../stats/differenceMap.js";import{isParametricTest as q}from"../renderer/buildWaferMap.js";import{testLabel as R}from"../renderer/testLabel.js";import{fmt as G}from"../renderer/fmt.js";import{CLR as A,FONT as k,MAP_CHROME_INSET as K,SPACE as U}from"./toolbar.js";import{bodyRoom as X,cardShell as J,guideCite as Q,isExpandedCard as Z,makeListSelect as O,observeResize as ee,onRepaint as te,renderEmptyState as se}from"./charts/chartShell.js";import{GUIDE_SECTIONS as oe}from"../stats/guideSections.js";import{renderWaferMapCard as ne}from"./renderWaferMap.js";import{cardAbout as re,cardKindId as ae}from"./charts/cardAbout.js";const f="\0yield";export function renderDifferenceMapPanel(t){const l=t.ownerDocument??document,{card:r,body:v,controlsRow:_,setAbout:P,setCardId:z}=J("Difference map",t.onSaveImage,l,{png:!1});z(ae("difference-map")),P(re("difference-map")),r.dataset.wmapDifferenceMap="1";const y=t.groups.map(e=>e.key),p=t.testDefs.filter(q);let c=y[0],d=y[1],s=t.selectedTestNumber!==void 0&&p.some(e=>e.testNumber===t.selectedTestNumber)?String(t.selectedTestNumber):p[0]?String(p[0].testNumber):f,I=!0,u;if(y.length<2)return se(v,"Needs two groups to subtract."),{card:r,setTest:()=>{},destroy:()=>{}};const M=(t.groupLabelText??"Group").toLowerCase(),D=(e,o,i,w)=>O(y.map(m=>({value:m,label:m})),e,m=>{w(m),h()},{ownerDocument:l,ariaLabel:o,hook:i}),$=l.createElement("span");$.textContent="minus",Object.assign($.style,{color:A.label,fontSize:k.body});const T=()=>O([{value:f,label:"Yield"},...p.map(e=>({value:String(e.testNumber),label:R(e,e.testNumber)}))],s,e=>{s=e,I=!1,h()},{ownerDocument:l,ariaLabel:"Measure",hook:"difference-measure",searchPlaceholder:"Filter tests\u2026"});let C=T();_.append(D(c,`First ${M}`,"difference-a",e=>{c=e}),$,D(d,`Second ${M}`,"difference-b",e=>{d=e}),C);const b=l.createElement("div");Object.assign(b.style,{color:A.label,fontSize:k.body,marginBottom:U.sm});const a=l.createElement("div"),N=380,B=480;Object.assign(a.style,{position:"relative",height:`${N}px`}),v.append(b,a);const V=ee(r,()=>{const e=a.clientWidth,o=e?Math.min(B,Math.max(N,e)):N,i=`${Z(r)?Math.max(o,Math.floor(X(r,v,a))):o}px`;a.style.height!==i&&(a.style.height=i)});function h(){if(u?.destroy(),u=void 0,a.replaceChildren(),c===d){b.textContent="Choose two different groups.";return}const e=t.groups.find(g=>g.key===c),o=t.groups.find(g=>g.key===d),i=s===f?{yield:!0}:{test:Number(s)},w=s===f?void 0:p.find(g=>g.testNumber===Number(s)),m=s===f?"Yield":R(w,Number(s)),x=s===f?"%":w?.unit,n=Y(e.items,o.items,i),S=Math.max(n.maxAbs,n.level*L),j=n.compared>0&&n.maxAbs<n.level*L;b.textContent=n.compared?`${m}: ${c} (${e.items.length} wafer${e.items.length===1?"":"s"}) minus ${d} (${o.items.length}), each the mean over its wafers at the position${s===f?" of the share passing":""}. ${n.compared.toLocaleString("en-GB")} positions compared; the colours run from \u2212${G(S,x)} to +${G(S,x)}, zero in the middle${j?" (no difference is over 1% of the level, so the groups do not differ in a way worth reading)":""}. Grey: a position one group has no value at.`:`${c} and ${d} have no position with a value of ${m} in common.`,n.compared&&b.append(" ",Q(l,oe.heatmap),".");const E=e.items[0]?.source;if(!E||!n.compared)return;const{metadata:me,...F}=E.wafer,H={...E,wafer:F,dies:n.dies,passBins:[...e.items[0].passBins],testDefs:[{testNumber:0,name:`${m}: ${c} \u2212 ${d}`,unit:x}]},W=[-(S||1),S||1];u=ne(a,H,{viewOptions:{plotMode:"value",activeTest:0,valueRange:W,signedValues:!0,dataColors:t.readerColors?.dataColors},showIdentity:!1,insights:{enabled:!1},onSaveImage:t.onSaveImage,chromeInset:K,onExpand:()=>r.querySelector("[data-wmap-card-expand]")?.click()}),u.setViewControlsVisible(!1),u.setSummaryVisible(!1)}return h(),te(r,()=>h()),{card:r,setTest:e=>{if(!I||!p.some(i=>i.testNumber===e)||String(e)===s)return;s=String(e);const o=T();C.replaceWith(o),C=o,h()},destroy:()=>{V.disconnect(),u?.destroy()}}}
|