@wafertools/wafermap 0.34.0 → 0.35.1
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 +7 -1
- package/CHANGELOG.md +189 -1
- package/README.md +6 -3
- package/dist/packages/canvas-adapter/charts/barPanel.d.ts +1 -1
- package/dist/packages/canvas-adapter/charts/binCluster.js +1 -1
- package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +17 -2
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +6 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/scatter.js +1 -1
- package/dist/packages/canvas-adapter/charts/testPassRate.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.d.ts +6 -0
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.js +6 -6
- package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/identityHeader.d.ts +4 -1
- package/dist/packages/canvas-adapter/identityHeader.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +3 -1
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/plotEditor.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +3 -0
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +8 -0
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +22 -1
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +39 -11
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
- package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
- package/dist/packages/canvas-adapter/sweepEditor.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +8 -0
- 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 +57 -27
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/classify.d.ts +5 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +26 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/index.d.ts +1 -1
- package/dist/packages/core/index.js +1 -1
- package/dist/packages/core/passBins.d.ts +6 -0
- package/dist/packages/core/passBins.js +1 -1
- package/dist/packages/core/reticle.d.ts +20 -0
- package/dist/packages/core/reticle.js +1 -1
- package/dist/packages/core/wafer.d.ts +15 -0
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +32 -1
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/apply.js +1 -1
- package/dist/packages/renderer/derivedTests/evaluate.d.ts +3 -1
- package/dist/packages/renderer/derivedTests/evaluate.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.d.ts +7 -0
- package/dist/packages/renderer/derivedTests/parser.js +2 -2
- package/dist/packages/renderer/spec.d.ts +4 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +55 -0
- package/dist/packages/renderer/valueFilter.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +44 -3
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/capability.d.ts +5 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/connectedComponents.d.ts +19 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/dieRegions.d.ts +42 -0
- package/dist/packages/stats/dieRegions.js +1 -0
- package/dist/packages/stats/facets.d.ts +8 -0
- package/dist/packages/stats/facets.js +1 -1
- package/dist/packages/stats/index.d.ts +2 -1
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotPattern.js +1 -1
- package/dist/packages/stats/math.d.ts +25 -3
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/metadataColumns.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +44 -18
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +12 -1
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +1 -1
- package/dist/packages/stats/plotSpec.js +1 -1
- package/dist/packages/stats/regions.d.ts +15 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +7 -6
- package/dist/packages/stats/reportHtml.js +39 -37
- package/dist/packages/stats/synthesis.d.ts +44 -17
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/types.d.ts +12 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
- package/dist/packages/canvas-adapter/summaryRail.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isYieldEligibleDie as W}from"../core/dies.js";import{testValue as O}from"../core/dieTable.js";import{metadataDisplayValue as I}from"../core/metadata.js";import{prettyKey as z}from"../core/utils.js";import{tableToTsv as N}from"../core/tableCsv.js";import{commonMetadata as H}from"../stats/facets.js";import{buildYieldData as Y}from"../stats/yield.js";import{isParametricTest as k}from"../renderer/buildWaferMap.js";import{fmt as G}from"../renderer/fmt.js";import{testLabel as R}from"../renderer/testLabel.js";import{resolveDieColumns as U}from"./dieList.js";import{createVirtualTable as V}from"./virtualTable.js";import{exportCsv as E}from"./tableExport.js";import{CLR as y,FONT as L,RADIUS as j,SPACE as C,controlStyle as K,wireControlHover as A,wireTooltip as $}from"./toolbar.js";import{buildTestSection as q,buildFunctionalTestSection as X}from"./summaryPanel.js";export const DATA_VIEWS=[{key:"statistics",label:"Statistics"},{key:"dies",label:"Dies"},{key:"wafers",label:"Wafers"}],EXCEL_ROW_LIMIT=1048576,COPY_CELL_LIMIT=2e5,WAFER_TEST_COLUMNS=50;const D=(e,i,s=i+"s")=>`${e.toLocaleString()} ${e===1?i:s}`;export function renderDataSection(e){const{doc:i}=e,s=i.createElement("div");s.dataset.wmapDataTab="1",Object.assign(s.style,{display:"flex",flexDirection:"column",gap:C.md,minWidth:"0"});const c=i.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",gap:C.md,flexWrap:"wrap"}),s.appendChild(c);const p=i.createElement("div");Object.assign(p.style,{display:"flex",flexDirection:"column",gap:C.md,minWidth:"0"}),s.appendChild(p);const g=DATA_VIEWS.filter(f=>!e.views||e.views.includes(f.key)),r=F(i,"Table",g,e.view,"wmapDataView",f=>e.onViewChange(f));c.appendChild(r.el);let d;switch(e.view){case"dies":d=Q(e);break;case"wafers":d=Z(e);break;default:d=J(e)}let u=()=>{};if(e.view==="dies"){const f=F(i,"Export format",[{key:"wide",label:"Wide"},{key:"long",label:"Long"}],e.diesLayout,"wmapDataLayout",t=>{f.set(t),e.onDiesLayoutChange(t),d.actions?.setLayout?.(t),u()});$(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 l=i.createElement("span");Object.assign(l.style,{display:"inline-flex",alignItems:"center",gap:C.sm});const o=i.createElement("span");o.textContent="Export format:",Object.assign(o.style,{color:y.label,fontSize:L.body}),l.append(o,f.el),c.appendChild(l)}if(d.actions){const f=d.actions,l=i.createElement("div");l.style.flex="1",c.appendChild(l);const o=B(i,"Export CSV");o.dataset.wmapDataExport="1",o.addEventListener("click",()=>{if(o.disabled)return;const m=o.textContent,h=f.exportCsv();h&&(o.disabled=!0,o.setAttribute("aria-busy","true"),h.catch(()=>{}).finally(()=>{o.disabled=!1,o.removeAttribute("aria-busy"),o.textContent=m}))});const t=B(i,"Copy");t.dataset.wmapDataCopy="1",f.copyText?($(t,"Copy the table as tab-separated text, to paste into a spreadsheet"),t.addEventListener("click",()=>{const m=f.copyText(),h=i.defaultView?.navigator?.clipboard;if(!h)return;const w=t.textContent;h.writeText(m).then(()=>{t.textContent="Copied",i.defaultView?.setTimeout(()=>{t.textContent=w},1500)}).catch(()=>{})})):(t.disabled=!0,$(t,`Too large to copy (over ${COPY_CELL_LIMIT.toLocaleString()} cells). Use Export CSV.`)),c.append(t,o);const a=i.createElement("div");a.dataset.wmapDataNote="1",a.textContent=f.note(),u=()=>{a.textContent=f.note()},Object.assign(a.style,{color:y.label,fontSize:L.body}),s.insertBefore(a,p)}return p.appendChild(d.el),{card:s,destroy:()=>d.destroy()}}function J(e){const{doc:i}=e,s=i.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:C.lg,minWidth:"0"});const c=[],p=e.groups&&e.groups.length>0?e.groups:void 0,g=p??[{key:"",items:e.items}];for(const r of g){if(p){const u=i.createElement("div");u.textContent=`${e.groupLabelText??"Group"}: ${r.key}`,Object.assign(u.style,{fontWeight:"700",color:y.text,fontSize:L.body}),s.appendChild(u)}const d=e.buildStatistics(r.items);c.push(d.destroy);for(const u of d.cards)s.appendChild(u)}return!s.querySelector("table")&&!s.textContent&&(s.textContent="No test statistics to show for these wafers.",Object.assign(s.style,{color:y.label,fontSize:L.body})),{el:s,destroy:()=>{for(const r of c)r()}}}function Q(e){const{doc:i,items:s}=e,c=new WeakMap,p=new WeakMap,g=new WeakMap,r=[];let d=!1;for(const n of s){n.wafer&&(d=!0);for(const b of n.dies)c.set(b,n.label),g.set(b,n.waferIndex),n.wafer&&p.set(b,n.wafer),r.push(b)}if(r.length===0)return M(i,"No dies to show.");const{columns:u,visibleColumns:f}=U(r,e.allTestDefs,{...e.dieListOptions,metadataFields:e.metadataFields,extraColumn:s.length>1||e.population?{label:"Wafer",get:n=>c.get(n)}:void 0,getWafer:d?(n=>p.get(n)):void 0,ringCount:e.ringCount,waferMetadata:s.some(n=>n.wafer)?H(s.map(n=>({metadata:n.wafer?.metadata}))):void 0,ownerDocument:i}),l=f.map(n=>({header:n.label,get:n.get,numeric:n.test!==void 0&&k(n.test),...n.test!==void 0&&k(n.test)?{sortKey:b=>O(b,n.test.testNumber)}:{}})),o=V({columns:l,rows:r,ariaLabel:`Dies (${r.length})`,ownerDocument:i,onRowClick:e.onLocateDie?n=>e.onLocateDie(n,g.get(n)):void 0});o.el.style.maxHeight="70vh",o.el.style.minHeight="240px";const t=e.population?`-${e.population.fileTag}`:"",a=u.filter(n=>n.test!==void 0),m=u.filter(n=>n.test===void 0),h=r.length*u.length,w=r.length*a.length,x=()=>u.map(n=>({header:n.csvLabel??n.label,get:n.csvGet??n.get})),v=()=>[...m.map(n=>({header:n.csvLabel??n.label,get:b=>(n.csvGet??n.get)(b.die)})),{header:"Test",get:n=>R(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*_(){for(const n of o.orderedRows())for(const b of a){const S=(b.csvGet??b.get)(n);S===""||S===void 0||S===null||(yield{die:n,test:b.test,value:S})}}let T=e.diesLayout==="long"&&a.length>0;const P=()=>T?`Long format: up to ${D(w,"row")} (a die with no result for a test has no row)`+(w>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()}).`:"."):`Wide format: ${D(r.length,"row")} \xD7 ${D(u.length,"column")}`+(r.length>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()} rows).`:".");return{el:o.el,destroy:()=>o.destroy(),actions:{note:()=>`${D(r.length,"die")} ${e.population?.phrase??`on ${D(s.length,"wafer")}`}. ${P()} Export follows the order shown.${e.onLocateDie?" Click a row to show that die on the map.":""}`,setLayout:n=>{T=n==="long"&&a.length>0},exportCsv:()=>T?E(v(),_(),`die-list-long${t}.csv`,e.onSaveText,{rowCount:w}):E(x(),o.orderedRows(),`die-list${t}.csv`,e.onSaveText,{rowCount:r.length}),copyText:h<=COPY_CELL_LIMIT?()=>N(x(),o.orderedRows()):null}}}function Z(e){const{doc:i,items:s}=e;if(s.length===0)return M(i,"No wafers to show.");const c=s.map(t=>{const a=e.yieldByWaferIndex.get(t.waferIndex),m=Y([{label:t.label,dies:t.dies,passBins:t.passBins,yieldPercent:a,key:t.waferIndex}])[0]?.percent;return{item:t,yieldPercent:t.dies.length?m??null:null}}),p=[];for(const{item:t}of c)for(const a of Object.keys(t.wafer?.metadata??{}))!p.includes(a)&&I((t.wafer?.metadata)[a])!==void 0&&p.push(a);const g=e.testDefs.slice(0,WAFER_TEST_COLUMNS),r=(t,a)=>{const m=t.item.statsSummary?.stats.perTestStats?.find(x=>x.testNumber===a.testNumber);if(m)return m.mean;let h=0,w=0;for(const x of t.item.dies){if(!W(x))continue;const v=O(x,a.testNumber);v!==void 0&&Number.isFinite(v)&&(h++,w+=v)}return h?w/h:void 0},d=[{header:"Wafer",cell:t=>t.item.label},...p.map(t=>({header:z(t),cell:a=>I(a.item.wafer?.metadata?.[t])??""})),{header:"Dies",cell:t=>t.item.dies.length,numeric:!0},{header:"Yield-eligible dies",cell:t=>t.item.dies.filter(a=>W(a)).length,numeric:!0},{header:"Yield %",cell:t=>t.yieldPercent===null?"":t.yieldPercent,show:t=>t.yieldPercent===null?"":t.yieldPercent.toFixed(1),numeric:!0},...g.map(t=>({header:`${R(t,t.testNumber)}${t.unit?` (${t.unit})`:""} mean`,cell:a=>r(a,t),show:a=>{const m=r(a,t);return m===void 0?"":G(m,t.unit)},numeric:!0}))],u=d.map(t=>({header:t.header,get:a=>t.show?t.show(a):String(t.cell(a)??""),numeric:t.numeric,...t.numeric?{sortKey:a=>{const m=t.cell(a);return typeof m=="number"?m:void 0}}:{}})),f=V({columns:u,rows:c,ariaLabel:`Wafers (${c.length})`,ownerDocument:i,onRowClick:e.onOpenWafer?t=>e.onOpenWafer(t.item.waferIndex,t.item.label):void 0});f.el.style.maxHeight="70vh",f.el.style.minHeight="120px";const l=()=>d.map(t=>({header:t.header,get:t.cell})),o=e.testDefs.length>g.length?` Mean columns cover the first ${g.length} of ${e.testDefs.length} tests.`:"";return{el:f.el,destroy:()=>f.destroy(),actions:{note:()=>`${D(c.length,"wafer")}.${o}${e.onOpenWafer?" Click a row to open that wafer.":""} Export follows the order shown.`,exportCsv:()=>E(l(),f.orderedRows(),"wafers.csv",e.onSaveText,{rowCount:c.length}),copyText:c.length*d.length<=COPY_CELL_LIMIT?()=>N(l(),f.orderedRows()):null}}}function M(e,i){const s=e.createElement("div");return s.textContent=i,Object.assign(s.style,{color:y.label,fontSize:L.body,padding:C.md}),{el:s,destroy:()=>{}}}function B(e,i){const s=e.createElement("button");return s.type="button",s.textContent=i,Object.assign(s.style,{fontSize:L.body,padding:"3px 10px",borderRadius:j.control,...K("outlined"),background:y.menuBg}),A(s),s}function F(e,i,s,c,p,g){const r=e.createElement("div");r.setAttribute("role","radiogroup"),r.setAttribute("aria-label",i),Object.assign(r.style,{display:"inline-flex",background:y.menuBg,border:`1px solid ${y.menuBorder}`,borderRadius:j.control,overflow:"hidden"});const d=[];let u=c;const f=()=>{for(const l of d){const o=l.dataset[p]===u;l.setAttribute("aria-checked",String(o)),l.tabIndex=o?0:-1,Object.assign(l.style,{background:o?y.bgActive:"transparent",color:o?y.iconActive:y.label,fontWeight:o?"600":"400"})}};for(const l of s){const o=e.createElement("button");o.type="button",o.textContent=l.label,o.dataset[p]=l.key,o.setAttribute("role","radio"),Object.assign(o.style,{border:"none",cursor:"pointer",fontSize:L.body,padding:`${C.xs} ${C.md}`,whiteSpace:"nowrap"}),A(o,"bare"),o.addEventListener("click",()=>{u!==l.key&&g(l.key)}),d.push(o),r.appendChild(o)}return f(),r.addEventListener("keydown",l=>{if(l.key!=="ArrowLeft"&&l.key!=="ArrowRight")return;const o=d.indexOf(e.activeElement);if(o<0)return;l.preventDefault();const t=d[(o+(l.key==="ArrowRight"?1:-1)+d.length)%d.length];t.click(),t.focus()}),{el:r,set:l=>{u=l,f()}}}export function renderDataTables(e){const{doc:i}=e,s=i.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",flex:"1",padding:C.md});const c=e.items.map((a,m)=>({...a,waferIndex:a.waferIndex??m})),p=c.flatMap(a=>a.dies),g=e.testDefs??[],r=g.filter(k),d=e.views??(c.length>1?["statistics","dies","wafers"]:["statistics","dies"]),u=e.population?{populationLabel:`${D(p.length,"die")} ${e.population}`}:c.length>1?{perWaferMetadata:c.map(a=>a.wafer?.metadata??{}),populationLabel:`${D(c.length,"wafer")} pooled`}:{waferMetadata:c[0]?.wafer?.metadata};let f=d.includes(e.view)?e.view:d[0],l="wide",o=null;const t=()=>{o?.destroy(),o=renderDataSection({doc:i,items:c,testDefs:r,allTestDefs:g,ringCount:e.ringCount,yieldByWaferIndex:new Map,onSaveText:e.onSaveText,views:d,view:f,dieListOptions:e.dieListOptions,metadataFields:e.metadataFields,onLocateDie:e.onLocateDie,population:e.population?{phrase:e.population,fileTag:"selection"}:void 0,buildStatistics:a=>{const m=a.flatMap(v=>v.dies),h=[],w=q(m,r,void 0,void 0,e.onSaveText,u,a.map(v=>({dies:v.dies})),void 0,"full");w&&h.push(w);const x=X(m,g,void 0,e.onSaveText,u);return x&&h.push(x),{cards:h,destroy:()=>{}}},onViewChange:a=>{f=a,t()},diesLayout:l,onDiesLayoutChange:a=>{l=a}}),s.replaceChildren(o.card)};return t(),{el:s,destroy:()=>o?.destroy()}}export function renderSelectionTables(e){return renderDataTables({...e,views:e.items.length>1?["statistics","dies","wafers"]:["statistics","dies"]})}
|
|
1
|
+
import{isYieldEligibleDie as O}from"../core/dies.js";import{testValue as W}from"../core/dieTable.js";import{metadataDisplayValue as I}from"../core/metadata.js";import{attributeLabel as z}from"../stats/facets.js";import{tableToTsv as A}from"../core/tableCsv.js";import{commonMetadata as H}from"../stats/facets.js";import{buildYieldData as Y}from"../stats/yield.js";import{isParametricTest as E}from"../renderer/buildWaferMap.js";import{fmt as G}from"../renderer/fmt.js";import{testLabel as N}from"../renderer/testLabel.js";import{resolveDieColumns as U}from"./dieList.js";import{createVirtualTable as R}from"./virtualTable.js";import{exportCsv as $}from"./tableExport.js";import{CLR as y,FONT as L,RADIUS as V,SPACE as C,controlStyle as K,wireControlHover as j,wireTooltip as T}from"./toolbar.js";import{buildTestSection as q,buildFunctionalTestSection as X}from"./summaryPanel.js";export const DATA_VIEWS=[{key:"statistics",label:"Statistics",hint:"One row per test: count, spread, limits and limit yield"},{key:"dies",label:"Dies",hint:"One row per die, with its position, bins and every test"},{key:"wafers",label:"Wafers",hint:"One row per wafer: its attributes, die counts, yield and test means"}],EXCEL_ROW_LIMIT=1048576,COPY_CELL_LIMIT=2e5,WAFER_TEST_COLUMNS=50;const D=(e,i,s=i+"s")=>`${e.toLocaleString()} ${e===1?i:s}`;export function renderDataSection(e){const{doc:i}=e,s=i.createElement("div");s.dataset.wmapDataTab="1",Object.assign(s.style,{display:"flex",flexDirection:"column",gap:C.md,minWidth:"0"});const c=i.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",gap:C.md,flexWrap:"wrap"}),s.appendChild(c);const p=i.createElement("div");Object.assign(p.style,{display:"flex",flexDirection:"column",gap:C.md,minWidth:"0"}),s.appendChild(p);const g=DATA_VIEWS.filter(f=>!e.views||e.views.includes(f.key)),l=F(i,"Table",g,e.view,"wmapDataView",f=>e.onViewChange(f));c.appendChild(l.el);let d;switch(e.view){case"dies":d=Q(e);break;case"wafers":d=Z(e);break;default:d=J(e)}let u=()=>{};if(e.view==="dies"){const f=F(i,"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",t=>{f.set(t),e.onDiesLayoutChange(t),d.actions?.setLayout?.(t),u()});T(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 r=i.createElement("span");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:C.sm});const o=i.createElement("span");o.textContent="Export format:",Object.assign(o.style,{color:y.label,fontSize:L.body}),r.append(o,f.el),c.appendChild(r)}if(d.actions){const f=d.actions,r=i.createElement("div");r.style.flex="1",c.appendChild(r);const o=B(i,"Export CSV");o.dataset.wmapDataExport="1",o.addEventListener("click",()=>{if(o.disabled)return;const m=o.textContent,h=f.exportCsv();h&&(o.disabled=!0,o.setAttribute("aria-busy","true"),h.catch(()=>{}).finally(()=>{o.disabled=!1,o.removeAttribute("aria-busy"),o.textContent=m}))});const t=B(i,"Copy");t.dataset.wmapDataCopy="1",f.copyText?(T(t,"Copy the table as tab-separated text, to paste into a spreadsheet"),t.addEventListener("click",()=>{const m=f.copyText(),h=i.defaultView?.navigator?.clipboard;if(!h)return;const w=t.textContent;h.writeText(m).then(()=>{t.textContent="Copied",i.defaultView?.setTimeout(()=>{t.textContent=w},1500)}).catch(()=>{})})):(t.disabled=!0,T(t,`Too large to copy (over ${COPY_CELL_LIMIT.toLocaleString()} cells). Use Export CSV.`)),c.append(t,o);const a=i.createElement("div");a.dataset.wmapDataNote="1",a.textContent=f.note(),u=()=>{a.textContent=f.note()},Object.assign(a.style,{color:y.label,fontSize:L.body}),s.insertBefore(a,p)}return p.appendChild(d.el),{card:s,destroy:()=>d.destroy()}}function J(e){const{doc:i}=e,s=i.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:C.lg,minWidth:"0"});const c=[],p=e.groups&&e.groups.length>0?e.groups:void 0,g=p??[{key:"",items:e.items}];for(const l of g){if(p){const u=i.createElement("div");u.textContent=`${e.groupLabelText??"Group"}: ${l.key}`,Object.assign(u.style,{fontWeight:"700",color:y.text,fontSize:L.body}),s.appendChild(u)}const d=e.buildStatistics(l.items);c.push(d.destroy);for(const u of d.cards)s.appendChild(u)}return!s.querySelector("table")&&!s.textContent&&(s.textContent="No test statistics to show for these wafers.",Object.assign(s.style,{color:y.label,fontSize:L.body})),{el:s,destroy:()=>{for(const l of c)l()}}}function Q(e){const{doc:i,items:s}=e,c=new WeakMap,p=new WeakMap,g=new WeakMap,l=[];let d=!1;for(const n of s){n.wafer&&(d=!0);for(const b of n.dies)c.set(b,n.label),g.set(b,n.waferIndex),n.wafer&&p.set(b,n.wafer),l.push(b)}if(l.length===0)return M(i,"No dies to show.");const{columns:u,visibleColumns:f}=U(l,e.allTestDefs,{...e.dieListOptions,metadataFields:e.metadataFields,extraColumn:s.length>1||e.population?{label:"Wafer",get:n=>c.get(n)}:void 0,getWafer:d?(n=>p.get(n)):void 0,ringCount:e.ringCount,waferMetadata:s.some(n=>n.wafer)?H(s.map(n=>({metadata:n.wafer?.metadata}))):void 0,ownerDocument:i}),r=f.map(n=>({header:n.label,get:n.get,numeric:n.test!==void 0&&E(n.test),...n.test!==void 0&&E(n.test)?{sortKey:b=>W(b,n.test.testNumber)}:{}})),o=R({columns:r,rows:l,ariaLabel:`Dies (${l.length})`,ownerDocument:i,onRowClick:e.onLocateDie?n=>e.onLocateDie(n,g.get(n)):void 0});o.el.style.maxHeight="70vh",o.el.style.minHeight="240px";const t=e.population?`-${e.population.fileTag}`:"",a=u.filter(n=>n.test!==void 0),m=u.filter(n=>n.test===void 0),h=l.length*u.length,w=l.length*a.length,x=()=>u.map(n=>({header:n.csvLabel??n.label,get:n.csvGet??n.get})),v=()=>[...m.map(n=>({header:n.csvLabel??n.label,get:b=>(n.csvGet??n.get)(b.die)})),{header:"Test",get:n=>N(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*_(){for(const n of o.orderedRows())for(const b of a){const S=(b.csvGet??b.get)(n);S===""||S===void 0||S===null||(yield{die:n,test:b.test,value:S})}}let k=e.diesLayout==="long"&&a.length>0;const P=()=>k?`Long format: up to ${D(w,"row")} (a die with no result for a test has no row)`+(w>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()}).`:"."):`Wide format: ${D(l.length,"row")} \xD7 ${D(u.length,"column")}`+(l.length>EXCEL_ROW_LIMIT?` \u2014 more than Excel opens (${EXCEL_ROW_LIMIT.toLocaleString()} rows).`:".");return{el:o.el,destroy:()=>o.destroy(),actions:{note:()=>`${D(l.length,"die")} ${e.population?.phrase??`on ${D(s.length,"wafer")}`}. ${P()} Export follows the order shown.${e.onLocateDie?" Click a row to show that die on the map.":""}`,setLayout:n=>{k=n==="long"&&a.length>0},exportCsv:()=>k?$(v(),_(),`die-list-long${t}.csv`,e.onSaveText,{rowCount:w}):$(x(),o.orderedRows(),`die-list${t}.csv`,e.onSaveText,{rowCount:l.length}),copyText:h<=COPY_CELL_LIMIT?()=>A(x(),o.orderedRows()):null}}}function Z(e){const{doc:i,items:s}=e;if(s.length===0)return M(i,"No wafers to show.");const c=s.map(t=>{const a=e.yieldByWaferIndex.get(t.waferIndex),m=Y([{label:t.label,dies:t.dies,passBins:t.passBins,yieldPercent:a,key:t.waferIndex}])[0]?.percent;return{item:t,yieldPercent:t.dies.length?m??null:null}}),p=[];for(const{item:t}of c)for(const a of Object.keys(t.wafer?.metadata??{}))!p.includes(a)&&I((t.wafer?.metadata)[a])!==void 0&&p.push(a);const g=e.testDefs.slice(0,WAFER_TEST_COLUMNS),l=(t,a)=>{const m=t.item.statsSummary?.stats.perTestStats?.find(x=>x.testNumber===a.testNumber);if(m)return m.mean;let h=0,w=0;for(const x of t.item.dies){if(!O(x))continue;const v=W(x,a.testNumber);v!==void 0&&Number.isFinite(v)&&(h++,w+=v)}return h?w/h:void 0},d=[{header:"Wafer",cell:t=>t.item.label},...p.map(t=>({header:z(t,e.attributes),cell:a=>I(a.item.wafer?.metadata?.[t])??""})),{header:"Dies",cell:t=>t.item.dies.length,numeric:!0},{header:"Yield-eligible dies",cell:t=>t.item.dies.filter(a=>O(a)).length,numeric:!0},{header:"Yield %",cell:t=>t.yieldPercent===null?"":t.yieldPercent,show:t=>t.yieldPercent===null?"":t.yieldPercent.toFixed(1),numeric:!0},...g.map(t=>({header:`${N(t,t.testNumber)}${t.unit?` (${t.unit})`:""} mean`,cell:a=>l(a,t),show:a=>{const m=l(a,t);return m===void 0?"":G(m,t.unit)},numeric:!0}))],u=d.map(t=>({header:t.header,get:a=>t.show?t.show(a):String(t.cell(a)??""),numeric:t.numeric,...t.numeric?{sortKey:a=>{const m=t.cell(a);return typeof m=="number"?m:void 0}}:{}})),f=R({columns:u,rows:c,ariaLabel:`Wafers (${c.length})`,ownerDocument:i,onRowClick:e.onOpenWafer?t=>e.onOpenWafer(t.item.waferIndex,t.item.label):void 0});f.el.style.maxHeight="70vh",f.el.style.minHeight="120px";const r=()=>d.map(t=>({header:t.header,get:t.cell})),o=e.testDefs.length>g.length?` Mean columns cover the first ${g.length} of ${e.testDefs.length} tests.`:"";return{el:f.el,destroy:()=>f.destroy(),actions:{note:()=>`${D(c.length,"wafer")}.${o}${e.onOpenWafer?" Click a row to open that wafer.":""} Export follows the order shown.`,exportCsv:()=>$(r(),f.orderedRows(),"wafers.csv",e.onSaveText,{rowCount:c.length}),copyText:c.length*d.length<=COPY_CELL_LIMIT?()=>A(r(),f.orderedRows()):null}}}function M(e,i){const s=e.createElement("div");return s.textContent=i,Object.assign(s.style,{color:y.label,fontSize:L.body,padding:C.md}),{el:s,destroy:()=>{}}}function B(e,i){const s=e.createElement("button");return s.type="button",s.textContent=i,Object.assign(s.style,{fontSize:L.body,padding:"3px 10px",borderRadius:V.control,...K("outlined"),background:y.menuBg}),j(s),s}function F(e,i,s,c,p,g){const l=e.createElement("div");l.setAttribute("role","radiogroup"),l.setAttribute("aria-label",i),Object.assign(l.style,{display:"inline-flex",background:y.menuBg,border:`1px solid ${y.menuBorder}`,borderRadius:V.control,overflow:"hidden"});const d=[];let u=c;const f=()=>{for(const r of d){const o=r.dataset[p]===u;r.setAttribute("aria-checked",String(o)),r.tabIndex=o?0:-1,Object.assign(r.style,{background:o?y.bgActive:"transparent",color:o?y.iconActive:y.label,fontWeight:o?"600":"400"})}};for(const r of s){const o=e.createElement("button");r.hint&&T(o,r.hint),o.type="button",o.textContent=r.label,o.dataset[p]=r.key,o.setAttribute("role","radio"),Object.assign(o.style,{border:"none",cursor:"pointer",fontSize:L.body,padding:`${C.xs} ${C.md}`,whiteSpace:"nowrap"}),j(o,"bare"),o.addEventListener("click",()=>{u!==r.key&&g(r.key)}),d.push(o),l.appendChild(o)}return f(),l.addEventListener("keydown",r=>{if(r.key!=="ArrowLeft"&&r.key!=="ArrowRight")return;const o=d.indexOf(e.activeElement);if(o<0)return;r.preventDefault();const t=d[(o+(r.key==="ArrowRight"?1:-1)+d.length)%d.length];t.click(),t.focus()}),{el:l,set:r=>{u=r,f()}}}export function renderDataTables(e){const{doc:i}=e,s=i.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",flex:"1",padding:C.md});const c=e.items.map((a,m)=>({...a,waferIndex:a.waferIndex??m})),p=c.flatMap(a=>a.dies),g=e.testDefs??[],l=g.filter(E),d=e.views??(c.length>1?["statistics","dies","wafers"]:["statistics","dies"]),u=e.population?{populationLabel:`${D(p.length,"die")} ${e.population}`}:c.length>1?{perWaferMetadata:c.map(a=>a.wafer?.metadata??{}),populationLabel:`${D(c.length,"wafer")} pooled`}:{waferMetadata:c[0]?.wafer?.metadata};let f=d.includes(e.view)?e.view:d[0],r="wide",o=null;const t=()=>{o?.destroy(),o=renderDataSection({doc:i,items:c,testDefs:l,allTestDefs:g,ringCount:e.ringCount,yieldByWaferIndex:new Map,onSaveText:e.onSaveText,views:d,view:f,dieListOptions:e.dieListOptions,metadataFields:e.metadataFields,attributes:e.attributes,onLocateDie:e.onLocateDie,population:e.population?{phrase:e.population,fileTag:"selection"}:void 0,buildStatistics:a=>{const m=a.flatMap(v=>v.dies),h=[],w=q(m,l,void 0,void 0,e.onSaveText,u,a.map(v=>({dies:v.dies})),void 0,"full");w&&h.push(w);const x=X(m,g,void 0,e.onSaveText,u);return x&&h.push(x),{cards:h,destroy:()=>{}}},onViewChange:a=>{f=a,t()},diesLayout:r,onDiesLayoutChange:a=>{r=a}}),s.replaceChildren(o.card)};return t(),{el:s,destroy:()=>o?.destroy()}}export function renderSelectionTables(e){return renderDataTables({...e,views:e.items.length>1?["statistics","dies","wafers"]:["statistics","dies"]})}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{requireRingCount as
|
|
1
|
+
import{requireRingCount as K}from"../core/ringCount.js";import{hasPosition as D,isPositionedDie as M}from"../core/dies.js";import{testsPresent as G,testValue as T}from"../core/dieTable.js";import{DIE_REGIONS as O,DIE_REGION_KEYS as P}from"../stats/dieRegions.js";import{isParametricTest as _,getTestPassStatus as E}from"../renderer/buildWaferMap.js";import{resolveMetadataColumns as z}from"../stats/metadataColumns.js";import{LEADING as N,TRACKING as B,wireControlHover as W,controlStyle as j,SPACE as V,RADIUS as k,FONT as w,CLR as f}from"./toolbar.js";import{exportCsv as Y}from"./tableExport.js";import{fmt as U}from"../renderer/fmt.js";import{testLabel as L,markedTestLabel as H,derivedFields as X,derivedKeyText as q,derivedTestSource as J,isDerivedTest as Q,DERIVED_KEY as Z}from"../renderer/testLabel.js";const $=(t,r)=>r?`${t} (${r})`:t,ee=5e4,F=new WeakSet;export function ensureStylesInjected(t){if(F.has(t))return;F.add(t);const r=t.createElement("style");r.textContent=`
|
|
2
2
|
.wmap-dielist-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
3
3
|
.wmap-dielist-th {
|
|
4
4
|
text-align: left; padding: 4px 8px; position: sticky; top: 0;
|
|
5
|
-
background: ${
|
|
6
|
-
border-bottom: 1px solid ${
|
|
5
|
+
background: ${f.panelBg}; color: ${f.label}; font-weight: 600;
|
|
6
|
+
border-bottom: 1px solid ${f.menuBorder}; white-space: nowrap;
|
|
7
7
|
}
|
|
8
8
|
.wmap-dielist-td {
|
|
9
|
-
padding: 4px 8px; color: ${
|
|
10
|
-
border-bottom: 1px solid ${
|
|
9
|
+
padding: 4px 8px; color: ${f.text};
|
|
10
|
+
border-bottom: 1px solid ${f.menuBorder}; white-space: nowrap;
|
|
11
11
|
}
|
|
12
|
-
`,t.head.appendChild(r)}function
|
|
12
|
+
`,t.head.appendChild(r)}function c(t,r,n,l){const s=t.createElement(r);return n&&Object.assign(s.style,n),l!==void 0&&(s.textContent=l),s}function te(t){return D(t)?String(t.x):""}function ne(t){return D(t)?String(t.y):""}function le(t,r){return r!==void 0?r.filter(n=>n.testNumber!==void 0):G(t,"values").map(n=>({testNumber:n,name:L(void 0,n)}))}function re(t,r,n){if(!r)return[];const l=K(n,"the die list"),s=[];for(const v of P){const p=O[v],u=i=>({wafer:r(i),ringCount:l});if(!t.some(i=>M(i)&&p.valueOf(i,u(i))!==void 0))continue;const h=new Map,o=i=>{let e=h.get(i);return e===void 0&&(e=p.valueOf(i,u(i))??"",h.set(i,e)),e};s.push({label:p.label,get:o,...p.rawOf?{csvGet:i=>p.rawOf(i,u(i))??""}:{}})}return s}export function resolveDieColumns(t,r,n={}){const l=le(t,r),s=re(t,n.getWafer,n),v=t.some(e=>e.edgeExcluded===!0),p=[...n.extraColumn?[n.extraColumn.label]:[],"X","Y",...P.map(e=>O[e].label),"Edge excluded","Site","Hard bin","Soft bin",...l.map(e=>$(L(e,e.testNumber),e.unit))],{columns:u,truncatedKeys:h}=z({dies:t,waferMetadata:n.waferMetadata,metadataFields:n.metadataFields,dieKeys:n.metadataColumns,waferKeys:n.waferMetadataColumns==="none"?"none":void 0,waferPlacement:n.waferMetadataColumns??"csv",reservedLabels:p}),o=[...n.extraColumn?[{label:n.extraColumn.label,get:e=>n.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):""},...l.map(e=>{const y=!_(e);return{test:e,label:$(H(e,e.testNumber),e.unit),...Q(e)?{csvLabel:`${$(L(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=T(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=T(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}))],i=o.filter(e=>!e.csvOnly);return{columns:o,visibleColumns:i,testColumns:l,truncatedKeys:h}}export function buildDieListSection(t,r,n={}){if(!t.length)return null;const l=n.ownerDocument??document;ensureStylesInjected(l);const s=n.maxRows??ee,v=Math.max(0,t.length-s),p=v>0?t.slice(0,s):t,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.meta,fontWeight:"700",letterSpacing:B,textTransform:"uppercase",color:f.label},n.title??`Die list (${t.length})`));const o=c(l,"button",{fontSize:w.body,padding:"3px 8px",borderRadius:k.control,...j("outlined"),background:f.menuBg},"Export CSV");o.type="button",W(o),h.appendChild(o),u.appendChild(h),n.note&&u.appendChild(c(l,"div",{fontSize:w.body,color:f.label,lineHeight:N.base,flexShrink:"0"},n.note));const{columns:i,visibleColumns:e,testColumns:y,truncatedKeys:d}=resolveDieColumns(t,r,n),x=q(y.map(a=>({label:H(a,a.testNumber),...X(a)})));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,...n.maxHeight?{maxHeight:n.maxHeight}:{}}),m=l.createElement("table");m.className="wmap-dielist-table",m.setAttribute("aria-label",n.title??`Die list (${t.length} dies)`);const A=c(l,"thead"),I=c(l,"tr");for(const a of e){const b=l.createElement("th");b.className="wmap-dielist-th",b.scope="col",b.textContent=a.label,I.appendChild(b)}A.appendChild(I),m.appendChild(A);const R=c(l,"tbody");for(const a 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(a),b.appendChild(S)}R.appendChild(b)}if(m.appendChild(R),C.appendChild(m),u.appendChild(C),v>0||d.length>0){const a=[];v>0&&a.push(`Showing the first ${s.toLocaleString()} of ${t.length.toLocaleString()} dies. The CSV export contains all ${t.length.toLocaleString()}.`),d.length>0&&a.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"},a.join(" ")))}return o.addEventListener("click",()=>{if(o.disabled)return;const a=o.textContent,b=Y(i.map(g=>({header:g.csvLabel??g.label,get:g.csvGet??g.get})),t,"die-list.csv",n.onSaveText,{onProgress:(g,S)=>{o.textContent=S?`Exporting ${Math.floor(100*g/S)}%`:`Exporting ${g.toLocaleString()} rows`}});b&&(o.disabled=!0,o.setAttribute("aria-busy","true"),b.catch(()=>{}).finally(()=>{o.disabled=!1,o.removeAttribute("aria-busy"),o.textContent=a}))}),u}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Die } from '../core/dies.js';
|
|
2
|
+
import type { FacetCuration } from '../stats/facets.js';
|
|
2
3
|
import { type SaveImageHandler, type SaveTextHandler } from './toolbar.js';
|
|
3
4
|
import type { DrilldownSource, DrilldownItem } from './chartPopulation.js';
|
|
4
5
|
import type { PlotStore } from './plotStore.js';
|
|
5
6
|
export type { DrilldownSource, DrilldownItem };
|
|
6
7
|
/** What the targets can draw on — the host's chart definitions and hooks. */
|
|
7
8
|
export interface DrilldownContext {
|
|
9
|
+
/** The host's own wafer attributes, so a plot opened on a selection offers and names them as Insights does. */
|
|
10
|
+
attributes?: Record<string, FacetCuration>;
|
|
8
11
|
/** The reader's saved plots: each is a row in the menu, opened on the selection. */
|
|
9
12
|
plots?: PlotStore;
|
|
10
13
|
onSaveImage?: SaveImageHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isYieldEligibleDie as P}from"../core/dies.js";import{testValue as k}from"../core/dieTable.js";import{isParametricTest as C}from"../renderer/buildWaferMap.js";import{buildSweepData as
|
|
1
|
+
import{isYieldEligibleDie as P}from"../core/dies.js";import{testValue as k}from"../core/dieTable.js";import{isParametricTest as C}from"../renderer/buildWaferMap.js";import{buildSweepData as L}from"../stats/sweep.js";import{plotToSweep as x}from"../stats/plotSpec.js";import{renderHistogramPanel as O}from"./charts/histogram.js";import{renderCapabilityPanel as W}from"./charts/capability.js";import{openChartExpandModal as A,populationPhrase as D}from"./charts/chartShell.js";import{buildCheckMenuEl as F,createToolbarHelpers as V,getTooltip as H,menuLayerFor as j,wireMenuA11y as q,CLR as z,FONT as B,SPACE as M,openReparentedModal as _,controlStyle as K,wireControlHover as U}from"./toolbar.js";import{requireRingCount as Y}from"../core/ringCount.js";import{defaultPlot as G,defaultSweep as J,fieldCatalogue as Q,plotTitle as X,resolvePlot as Z}from"../stats/plotData.js";import{newPlotId as y}from"../stats/plotSpec.js";import{sourceFromPoints as ee,toPlotItems as S}from"./plotItems.js";const E=30,g=e=>e.items.flatMap(t=>t.dies);function te(e){return e.items.map(t=>({...t,dies:t.dies.filter(n=>P(n))}))}function N(e,t,n){return(e.testDefs??[]).filter(C).map(a=>a.testNumber).filter(a=>{let o=0;for(const s of t){const d=k(s,a);if(d!==void 0&&Number.isFinite(d)&&++o>=n)return!0}return!1})}function $(e,t,n,a,o,s){const d=e.ownerDocument,l=d.createElement("div"),f=d.createElement("span");f.textContent=n,f.dataset.wmapPopulation="1",Object.assign(l.style,{color:z.label,fontSize:B.body,marginBottom:M.sm,display:"flex",alignItems:"center",gap:M.lg,flexWrap:"wrap"}),l.appendChild(f);let h=null;if(s){const c=d.createElement("button");c.type="button",c.textContent=s.label,c.dataset[s.hook]="1",Object.assign(c.style,K("outlined")),U(c),c.addEventListener("click",()=>s.run(()=>h?.close())),l.appendChild(c)}const i=e.querySelector("[data-wmap-chart-expand]")?.parentElement;i?.parentElement===e?i.after(l):e.prepend(l),h=A(e,t,{anchor:a,onClosed:o})}function ne(e,t){const n=g(t);return t.notMeasuredReason?t.notMeasuredReason:n.some(o=>P(o))?L(n,t.testDefs,e).series.some(o=>o.points.some(s=>s.count>0))?null:"These dies have no values for this sweep\u2019s tests":"These dies are all partial or edge-excluded, which charts leave out"}function oe(e,t,n){const a=te(e),o=g(e).length,s=a.flatMap(r=>r.dies),d=D(s.length,o,e.population),l=(e.testDefs??[]).filter(C),f=n.ownerDocument,h=(r,p)=>e.notMeasuredReason?e.notMeasuredReason:s.length===0?"These dies are all partial or edge-excluded, which charts leave out":N(e,s,r).length>0?null:p,i={section:"Distributions",label:"Value histogram",unavailable:h(1,"These dies have no parametric test values"),open:()=>{let r=e.activeTest??l[0]?.testNumber;const p=O({title:"Value histogram",items:a,testDefs:l,selectedTestNumber:e.activeTest,onTestChange:m=>{r=m},onSaveImage:t.onSaveImage,ownerDocument:f}),u=I(e,t,n),b=u&&r!==void 0?{label:"Edit as new plot",hook:"wmapEditAsPlot",run:m=>{const w=l.find(v=>v.testNumber===r);m(),u({id:y(),chart:"histogram",fields:{y:{test:r,...w?.name?{name:w.name}:{}},color:{none:!0}}},!0)()}}:void 0;$(p.card,`Value histogram \u2014 ${d}`,`Population: ${d}`,n,()=>p.destroy(),b)}},c={section:"Distributions",label:"Process capability",unavailable:h(2,"Needs at least 2 of these dies with values for one test"),open:()=>{const r=W({title:"Process capability",items:a,testDefs:l,selectedTestNumber:e.activeTest,onSaveImage:t.onSaveImage,ownerDocument:f}),p=s.length<E?` \xB7 fewer than ${E} dies, so each Ppk is a rough estimate`:"";$(r.card,`Process capability \u2014 ${d}`,`Population: ${d}${p}`,n,()=>r.destroy())}};return[i,c]}function I(e,t,n){const a=t.plots;if(!a)return null;const o=n.ownerDocument,s=S(e.items),d={testDefs:e.testDefs,curation:t.attributes},l=g(e),f=D(l.length,l.length,e.population),h=D(l.filter(i=>P(i)).length,l.length,e.population);return(i,c)=>()=>{const r=i.chart==="sweep",p=r?h:f;import("./plotModal.js").then(({openPlotEditor:u})=>u({doc:o,anchor:n,store:a,plot:i,draft:c,items:s,ctx:d,population:p,rawPopulation:e.population,title:`${c?r?"New sweep":"New plot":r?"Sweep":"Plot"} \u2014 ${p}`,chart:{onSaveImage:t.onSaveImage,onSelectPoints:(b,m,w)=>{const v=ee(b,s,e.testDefs);v&&openDrilldownMenu(m,w,v,t)}}}))}}function se(e,t,n){const a=t.plots,o=I(e,t,n);if(!a||!o)return[];const s=S(e.items),d={testDefs:e.testDefs,curation:t.attributes},l=g(e),f=e.notMeasuredReason??(l.length===0?"Nothing is selected":null),h=a.get().map(p=>{const u=x(p);if(u)return{section:"Plots",label:u.title,unavailable:ne(u,e),open:o(p,!1)};const b=Z(p,s,d);return{section:"Plots",label:X(b)||"Plot",unavailable:f??b.issues[0]??(b.plotted===0?"No die here has the values this plot needs":null),open:o(p,!1)}}),i=Q(s,d),c=i.some(p=>p.group==="Tests");h.push({section:"Plots",label:"New plot\u2026",unavailable:f??(c?null:"These dies have no parametric test values"),open:o(G(i,y()),!0)});const r=(e.testDefs??[]).filter(p=>C(p));return h.push({section:"Plots",label:"New sweep\u2026",unavailable:f??(r.length>0?null:"These dies have no parametric test values"),open:o(J(e.testDefs??[],y()),!0)}),h}function ae(e,t,n){const a=g(e),o=e.notMeasuredReason??(a.length===0?"Nothing is selected":null),s=a.length,d=D(s,s,e.population),l=(f,h)=>()=>{import("./dataTab.js").then(({renderSelectionTables:i})=>{const c=n.ownerDocument;let r;const p=i({doc:c,ringCount:Y(e.items[0],"the drilldown tables"),items:e.items,testDefs:e.testDefs,population:e.population,view:f,onSaveText:t.onSaveText,onLocateDie:t.onLocateDie?(b,m)=>{r?.(),t.onLocateDie(b,m)}:void 0}),u=_([p.el],{title:`${h} \u2014 ${d}`,anchor:n,ownerDocument:c,boxSize:{width:"min(96vw, 1200px)",height:"min(92vh, 780px)"},onClosed:p.destroy});u?r=()=>u.close():p.destroy()})};return[{section:"Tables",label:"Dies",unavailable:o,open:l("dies","Dies")},{section:"Tables",label:"Test statistics",unavailable:o??(N(e,a,1).length>0?null:"These dies have no parametric test values"),open:l("statistics","Test statistics")},...e.items.length>1?[{section:"Tables",label:"Wafers",unavailable:o,open:l("wafers","Wafers")}]:[]]}function le(e,t,n){return[...oe(e,t,n),...se(e,t,n),...ae(e,t,n)]}const T=new WeakMap;export function openDrilldownMenu(e,t,n,a){const o=t.ownerDocument,s=o.defaultView??window;T.get(o)?.();const d=le(n,a,t),l=[];if(a.narrower){const{label:m,source:w,ctx:v}=a.narrower,R={label:`${a.narrower.backLabel??"All selected"} \u2014 ${D(g(n).length,g(n).length,n.population)}`,source:n,ctx:a};l.push({section:"Dies"}),l.push({label:m,active:!1,action:!0,enabled:!0,onClick:()=>{u(),openDrilldownMenu(e,t,w,{...v??a,narrower:R})}})}let f;for(const m of d)m.section!==f&&(l.push({section:m.section}),f=m.section),l.push({label:m.label,active:!1,action:!0,enabled:m.unavailable===null,disabledHint:m.unavailable??void 0,onClick:()=>{u(),m.open()}});const{makeMenuSection:h}=V(H(o)),i=F(new DOMRect(e.x,e.y-4,0,0),l,{makeMenuSection:h},s),c=g(n).length;i.setAttribute("role","menu"),i.setAttribute("aria-label",`Open a chart or table of ${D(c,c,n.population)}`),i.dataset.wmapDrilldownMenu="1",j(t).appendChild(i);const r=i.getBoundingClientRect();r.bottom>s.innerHeight-4&&(i.style.top=`${Math.max(4,e.y-r.height)}px`),r.right>s.innerWidth-4&&(i.style.left=`${Math.max(4,s.innerWidth-r.width-4)}px`);let p=!1;function u(){p||(p=!0,i.remove(),o.removeEventListener("pointerdown",b,!0),s.removeEventListener("blur",u),T.get(o)===u&&T.delete(o))}function b(m){i.contains(m.target)||u()}return o.addEventListener("pointerdown",b,!0),s.addEventListener("blur",u),q(i,t,u),T.set(o,u),u}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { WaferMetadata } from '../core/metadata.js';
|
|
2
|
+
import { type FacetCuration } from '../stats/facets.js';
|
|
2
3
|
export interface IdentityHeaderLotStack {
|
|
3
4
|
lotSize: number;
|
|
4
5
|
aggrMethod?: string;
|
|
5
6
|
}
|
|
6
7
|
export interface IdentityHeaderOptions {
|
|
8
|
+
/** The host's own wafer attributes (`attributes` on the render options): what each field is called. */
|
|
9
|
+
attributes?: Record<string, FacetCuration>;
|
|
7
10
|
/** Present when the host result is a lot-stack aggregation rather than a
|
|
8
11
|
* single wafer — the metadata panel then leads with wafer count + method
|
|
9
12
|
* instead of a (nonexistent) single waferId. */
|
|
@@ -56,7 +59,7 @@ export declare function createMetaPanelEl(doc: Document): HTMLDivElement;
|
|
|
56
59
|
* wafer has no metadata to show. The fixed-label counterpart of
|
|
57
60
|
* `createIdentityHeader`, for views whose label never changes.
|
|
58
61
|
*/
|
|
59
|
-
export declare function attachExpandableMetadata(doc: Document, toggleEl: HTMLElement, label: string, metadata: WaferMetadata | null | undefined): HTMLDivElement | null;
|
|
62
|
+
export declare function attachExpandableMetadata(doc: Document, toggleEl: HTMLElement, label: string, metadata: WaferMetadata | null | undefined, attributes?: Record<string, FacetCuration>): HTMLDivElement | null;
|
|
60
63
|
export declare function collapsedLabel(meta: WaferMetadata, lotStack: IdentityHeaderLotStack | undefined): string | undefined;
|
|
61
64
|
export declare function createIdentityHeader(label: string, metadata: WaferMetadata | null | undefined, opts?: IdentityHeaderOptions): IdentityHeaderController;
|
|
62
65
|
//# sourceMappingURL=identityHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{metadataEntries as v,buildCompactMetadataRows as $}from"./summaryPanel.js";import{
|
|
1
|
+
import{metadataEntries as v,buildCompactMetadataRows as $}from"./summaryPanel.js";import{attributeLabel as M}from"../stats/facets.js";import{SHADOW as L,LEADING as E,SPACE as C,FONT as g,CLR as x,RADIUS as j,Z_ABOVE as H,wireExpandToggle as z,wireControlHover as P}from"./toolbar.js";export function createMetaPanelEl(i){const t=i.createElement("div");return Object.assign(t.style,{position:"absolute",top:"0",left:"0",right:"0",zIndex:H,background:x.menuBg,borderBottom:`1px solid ${x.menuBorder}`,boxShadow:L.menu,padding:`${C.md} ${C.lg}`,fontSize:g.body,display:"none"}),t}export function attachExpandableMetadata(i,t,a,n,p){const o=n??{};if(v(o).length===0)return null;const r=i.createElement("span");Object.assign(r.style,{fontSize:g.body,lineHeight:E.none,color:x.label,flexShrink:"0"}),r.textContent="\u25BE",t.appendChild(r),Object.assign(t.style,{cursor:"pointer",borderRadius:j.control}),P(t,"bare");const s=createMetaPanelEl(i);s.dataset.wmapCardMetaPanel="1";const d=$(o,p);return d&&s.appendChild(d),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-label",`Wafer info for ${a||"this card"}. Click to expand.`),z(t,e=>{r.textContent=e?"\u25B4":"\u25BE",t.setAttribute("aria-expanded",String(e)),s.style.display=e?"block":"none"}),s}export function collapsedLabel(i,t){if(t)return t.aggrMethod?`${t.lotSize} wafers \xB7 ${t.aggrMethod}`:`${t.lotSize} wafers`;if(i.lot&&i.waferId!==void 0&&i.waferId!==""){const a=String(i.lot),n=String(i.waferId);return n.includes(a)?n:`${a} \xB7 ${n}`}for(const a of["lot","waferId","product","testProgram"]){const n=i[a];if(n!=null&&n!=="")return String(n)}}export function createIdentityHeader(i,t,a={}){let n=i,p=t??{},o=a.lotStack,r=!1,s=!1;const d=a.ownerDocument??document,e=d.createElement("div");Object.assign(e.style,{display:"flex",alignItems:"center",gap:C.xs,minWidth:"0"});const h=d.createElement("span");Object.assign(h.style,{fontWeight:"700",fontSize:g.sub,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),e.appendChild(h);const w=d.createElement("span");Object.assign(w.style,{fontSize:g.body,lineHeight:E.none,color:x.label,flexShrink:"0",display:"none"}),e.appendChild(w);const A=4,c=d.createElement("span");Object.assign(c.style,{fontSize:g.body,color:x.label,whiteSpace:"nowrap",overflow:"hidden",flexShrink:"0",display:"none",marginLeft:C.sm}),e.appendChild(c);const f=createMetaPanelEl(d);f.dataset.wmapMetaPanel="1";function S(){return v(p).length>0||!!o}function I(){return o?[]:v(p).filter(([,l])=>!n.includes(l))}function W(){return e.clientWidth?h.scrollWidth>h.clientWidth||c.scrollWidth>c.clientWidth||e.scrollWidth>e.clientWidth:!0}function m(){h.textContent=n;const l=I();c.textContent=l.map(([b,y])=>`${M(b,a.attributes)}: ${y}`).join(" \xB7 "),c.style.display=l.length>0?"":"none",s=l.length>0&&l.length<=A&&!W(),c.style.display=s?"":"none";const u=S()&&!s;if(w.style.display=u?"":"none",e.style.cursor=u?"pointer":"",u||(r=!1),w.textContent=r?"\u25B4":"\u25BE",f.style.display=r?"block":"none",u?(e.setAttribute("aria-expanded",String(r)),e.setAttribute("aria-label",`Wafer info: ${n||"this wafer"}. ${r?"Click to collapse.":"Click to expand."}`)):(e.removeAttribute("aria-expanded"),e.removeAttribute("aria-label")),f.innerHTML="",r){if(o){const y=d.createElement("div");Object.assign(y.style,{fontWeight:"600",marginBottom:"3px"}),y.textContent=o.aggrMethod?`${o.lotSize} wafers stacked \xB7 ${o.aggrMethod}`:`${o.lotSize} wafers stacked`,f.appendChild(y)}const b=$(p,a.attributes);b&&f.appendChild(b)}}const k=z(e,l=>{!S()||s||(r=l,m())});m();const O=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>m());return O?.observe(e),{wrap:e,metaPanel:f,update(l,u,b){n=l,p=u??{},o=b,m()},isEmpty(){return!n&&!S()},collapse(){r&&(r=!1,m())},destroy(){O?.disconnect(),k.destroy(),e.remove(),f.remove()}}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Die } from '../core/dies.js';
|
|
2
2
|
import type { Wafer } from '../core/wafer.js';
|
|
3
3
|
import type { LotStatsSummary, StatsSummary } from '../stats/types.js';
|
|
4
|
-
import { type FacetItem } from '../stats/facets.js';
|
|
4
|
+
import { type FacetCuration, type FacetItem } from '../stats/facets.js';
|
|
5
5
|
import { type TestDef } from '../renderer/buildWaferMap.js';
|
|
6
6
|
import type { WaferMapDisplayItem } from './renderWaferGallery.js';
|
|
7
7
|
import { type PlotStore } from './plotStore.js';
|
|
@@ -83,6 +83,8 @@ export interface InsightsOptions {
|
|
|
83
83
|
defaultOpen?: boolean;
|
|
84
84
|
}
|
|
85
85
|
export interface InsightsTabDeps {
|
|
86
|
+
/** The host's own wafer attributes (`attributes` on the render options): what Group by offers and calls each, the plot fields, the Wafers table's columns and the strip. Over the defaults. */
|
|
87
|
+
attributes?: Record<string, FacetCuration>;
|
|
86
88
|
/** Current gallery/single-wafer items — read fresh each render (a gallery's list can still be building). `null` entries (not-yet-built cards) are skipped. */
|
|
87
89
|
getItems: () => Array<WaferMapDisplayItem | null>;
|
|
88
90
|
/** Precomputed lot-level yield, when the host has one — reused directly instead of recomputing (see stats/yield.ts). Omit when there is no lot (e.g. a single wafer). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MEAN_WAFER_YIELD_LABEL as Ue}from"../stats/presentation.js";import{buildFacetTable as qe,facetValueOf as Ke,FACET_NONE_VALUE as Qe}from"../stats/facets.js";import{mergeTestDefs as he}from"../stats/mergeTestDefs.js";import{isParametricTest as we}from"../renderer/buildWaferMap.js";import{dieFailsTest as Xe}from"../stats/testPassRate.js";import{fmt as Ce}from"../renderer/fmt.js";import{testLabel as Je}from"../renderer/testLabel.js";import{waferDisplayLabel as Ze,waferIdentityLabel as et}from"../core/waferLabel.js";import{waferPopulation as tt}from"./chartPopulation.js";import{openDrilldownMenu as se}from"./drilldown.js";import{plotStoreFor as nt}from"./plotStore.js";import{itemPassBins as ot,passBinsLabel as Se}from"../core/passBins.js";import{NO_DATA_FILL as xe}from"../renderer/colorMap.js";import{describeWaferPopulation as at,populationStat as rt}from"../stats/population.js";import{LEADING as it,ALPHA as st,SPACE as x,EDGE_GUTTER as le,FONT as M,CLR as B,RADIUS as lt,SHADOW as dt,controlStyle as ct,wireControlHover as de,wireTooltip as pt}from"./toolbar.js";import{ICONS as ut}from"./icons.js";import{renderCapabilityPanel as ft}from"./charts/capability.js";import{renderBoxplotPanel as mt}from"./charts/boxplot.js";import{renderTrendPanel as bt}from"./charts/trend.js";import{renderHistogramPanel as gt}from"./charts/histogram.js";import{renderCorrelationPanel as yt}from"./charts/correlation.js";import{renderScatterPanel as ht}from"./charts/scatter.js";import{renderBarPanel as ke}from"./charts/barPanel.js";import{renderBinClusterPanel as wt}from"./charts/binCluster.js";import{renderTestPassRatePanel as Ct}from"./charts/testPassRate.js";import{QUANTITY as St}from"./charts/palette.js";import{cardFrameStyle as xt,makeChartGridWrap as ce,makeLabeledSelect as kt,makeLinkedGroupSelect as vt}from"./charts/chartShell.js";import{buildYieldData as J,buildYieldDataCombined as ve}from"../stats/yield.js";import{buildBinParetoData as Tt}from"../stats/binPareto.js";import{buildLotTestSectionSteps as Dt,buildLotFunctionalSection as Bt,buildMetadataStripBox as $t}from"./summaryPanel.js";import{runChunked as Lt}from"./chunked.js";import{buildRegionYieldData as Te,buildRingRegions as De,buildQuadrantRegions as Be,diesInRegion as It}from"../stats/regions.js";import{renderDataSection as Et}from"./dataTab.js";import{sourceFromDies as Pt}from"./plotItems.js";import{renderRegionYieldDiagram as $e}from"./charts/regionYieldDiagram.js";const Ot=[{key:"overview",label:"Overview"},{key:"distributions",label:"Distributions"},{key:"correlation",label:"Correlation"}],At={key:"data",label:"Data"},Rt={key:"plot",label:"Plot"};export function createInsightsTab($){const{getItems:Le,getLotStats:pe,getBinColors:ue,getRingCount:F,onSaveImage:k,onSaveText:A,openWafer:R,focusTest:Z,locateDie:_}=$,Ie=$.showMetadataStrip??!0,z=$.contentInset??le,m=$.ownerDocument??document,N=m.createElement("div");Object.assign(N.style,{display:"none",flexDirection:"column",width:"100%",paddingTop:"0"});const Ee=le,Y=m.createElement("div");Object.assign(Y.style,{paddingLeft:Ee});const E=m.createElement("div");Object.assign(E.style,{display:"flex",gap:x.xs,alignItems:"center",background:B.menuBg,border:`1px solid ${B.menuBorder}`,borderRadius:lt.container,boxShadow:dt.panel,padding:`0 ${x.lg}`,marginBottom:x.lg,marginLeft:z,marginRight:z}),E.setAttribute("role","tablist"),E.addEventListener("keydown",e=>{if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const n=Array.from(E.querySelectorAll('[role="tab"]')),a=n.indexOf(m.activeElement);if(a===-1)return;e.preventDefault();const d=n[(a+(e.key==="ArrowRight"?1:-1)+n.length)%n.length];d.focus(),d.click()});const U=m.createElement("div");Object.assign(U.style,{display:"flex",flexDirection:"column",gap:x.lg,marginTop:"0",paddingLeft:z,paddingRight:z}),N.appendChild(Y),N.appendChild(E),N.appendChild(U);const Pe=[...Ot,At,Rt],q=$.plotStore??nt($);let L=$.defaultView==="sweeps"?"plot":$.defaultView??"overview",W,fe="statistics",me="wide",P=null,O=null,K={includeLimits:void 0,clipOutliers:!1,limits:"both"};const ee=new Map,be=(e,n)=>{K=e;for(const a of ee.values())for(const d of a)d!==n&&d.setAxisPrefs(e)},te=e=>{O!==e&&(O=e,G())};let j=new Map;function ge(){for(const e of j.values())e.destroy();j=new Map}function ne(e,n,a){R?.(e,n,a)}function oe(e){return(n,a,d)=>{const r=e.find(p=>p.waferIndex===n);if(!r)return;d.preventDefault();const f=tt(r.dies,{waferLabel:r.identity,testDefs:r.testDefs,activeTest:a??P??void 0,waferIndex:n,wafer:r.wafer,passBins:r.passBins,ringCount:F()});se({x:d.clientX,y:d.clientY},d.target,f,{plots:q,onSaveImage:k,onSaveText:A,onLocateDie:_})}}function Q(e,n,a,d,r){ye({x:e.clientX,y:e.clientY},e.target,n,a,d,r)}function ye(e,n,a,d,r,f){const p=Pt(a.map(l=>({label:l.identity??l.label,dies:l.dies,waferIndex:l.waferIndex,wafer:l.wafer,passBins:l.passBins,ringCount:F()})),d,r,he(a).defs,f);p&&se(e,n,p,{plots:q,onSaveImage:k,onSaveText:A,onLocateDie:_})}function ae(e){return R?{open:(n,a)=>ne(n,`Wafer ${e.find(d=>d.waferIndex===n)?.label??n}`,a)}:Z&&e.length===1?{open:(n,a)=>Z(a),label:"show this test on the map"}:null}function Oe(){return Le().map((e,n)=>e==null?null:{metadata:e.wafer.metadata??void 0,dies:e.dies,wafer:e.wafer,label:Ze(e,n),identity:et(e),waferIndex:n,passBins:ot(e),statsSummary:e.statsSummary,testDefs:e.testDefs}).filter(e=>e!=null)}function Ae(e,n){Object.assign(e.style,{background:"none",border:"none",borderBottom:n?`2px solid ${B.iconActive}`:"2px solid transparent",color:n?B.iconActive:B.label,fontWeight:n?"700":"500",fontSize:M.body,padding:`${x.sm} ${le} ${x.md}`,cursor:"pointer",marginBottom:"-1px"})}function Re(e,n){const a=m.createElement("button");a.type="button",a.textContent=n;const d=e===L;return Ae(a,d),a.dataset.on=d?"true":"false",de(a,"bare"),a.dataset.wmapInsightsTab=e,a.setAttribute("role","tab"),a.setAttribute("aria-selected",d?"true":"false"),a.tabIndex=d?0:-1,a.addEventListener("click",()=>{L!==e&&(L=e,G({keepSections:!0}))}),a}function We(e,n,a,d=!0){const r=ce(m),f=ue();let p="label";const l=a??"group",y=Se(e.map(u=>u.passBins)),c=pe?.(),b=new Map(c?.lotYieldSeries.map(u=>[u.waferIndex,u.yieldPercent])),s=u=>({...u,label:u.label.replace(/\s*·\s*\d+(\.\d+)?%$/,""),yieldPercent:b.get(u.waferIndex),key:u.waferIndex}),g=e.map(s),h=n?.map(u=>({key:u.key,items:u.items.map(s)})),i=()=>h?ve(h,p):J(g,p),t={title:n?`Yield by ${l} (pass: ${y})`:`Yield by wafer (pass: ${y})`,data:i(),selfControl:{current:p,options:[["yield","Sort: yield"],["label",n?`Sort: ${l}`:"Sort: wafer ID"]],onChange:u=>(p=u,{data:i()})},barColor:()=>St,valueLabel:u=>`${u.percent.toFixed(1)}%`,reference:u=>{if(u.length<3)return null;const C=u.map(I=>I.percent).sort((I,V)=>I-V),D=C.length%2?C[(C.length-1)/2]:(C[C.length/2-1]+C[C.length/2])/2;return{value:D,label:`median ${D.toFixed(1)}%`}},drill:h?{onOpenGroup:u=>{const C=h.find(D=>D.key===u.label)?.items??[];return{data:J(C,p),title:`Yield by wafer \u2014 ${l}: ${u.label} (pass: ${y})`}},onBack:()=>({data:i(),title:`Yield by ${l} (pass: ${y})`}),groupLabelText:l}:void 0,onOpen:R?u=>{typeof u.key=="number"&&ne(u.key,`Wafer ${u.label}`)}:void 0,onWaferContextMenu:oe(e),ownerDocument:m};let o=null;if(d&&(o=ke(t,k),o.card.style.minHeight="360px",r.appendChild(o.card)),n){const u=wt({title:"Hard bin pareto",groups:n.map(C=>({key:C.key,items:C.items.map(D=>({dies:D.dies,hardBinCounts:D.statsSummary?.stats.hardBinCounts,softBinCounts:D.statsSummary?.stats.softBinCounts}))})),onSelectBin:(C,D)=>{const I=n.find(X=>X.key===C.groupKey);if(!I)return;const V=C.binType==="hbin"?"hard":"soft";Q(D,I.items,`in ${V} bin ${C.bin} of ${C.groupKey}`,X=>(C.binType==="hbin"?X.hbin:X.sbin)===C.bin)},onSaveImage:k,ownerDocument:m});return u.card.style.minHeight="360px",r.appendChild(u.card),{card:r,destroy:()=>{o?.destroy(),u.destroy()}}}let w="hbin";const S=u=>u===void 0?xe:(w==="hbin"?f.hard:f.soft).get(u)??xe,v=e.map(u=>({dies:u.dies,hardBinCounts:u.statsSummary?.stats.hardBinCounts,softBinCounts:u.statsSummary?.stats.softBinCounts})),H=()=>Tt(v,w),ie={title:"Hard bin pareto",data:H(),selfControl:{current:w,options:[["hbin","Hard bins"],["sbin","Soft bins"]],onChange:u=>(w=u,{data:H(),title:`${w==="hbin"?"Hard":"Soft"} bin pareto`})},barColor:u=>S(u.binCode),onSelectBar:(u,C)=>{const D=w==="hbin"?"hard":"soft",I=u.binCode;Q(C,e,I===void 0?`with no ${D} bin recorded`:`in ${D} bin ${I}`,V=>(w==="hbin"?V.hbin:V.sbin)===I)},selectLabel:"chart or tabulate its dies",ownerDocument:m},T=ke(ie,k);return T.card.style.minHeight="360px",r.appendChild(T.card),{card:r,destroy:()=>{o?.destroy(),T.destroy()}}}function re(){const e=m.createElement("div");return e.dataset.wmapChartCard="1",Object.assign(e.style,{...xt(),display:"flex",flexDirection:"column",gap:x.lg,minWidth:"0"}),e}function Me(e){if(Y.innerHTML="",Y.style.marginBottom="0",!Ie)return;const n=$t(e.map(a=>({metadata:a.metadata})),void 0,{facetableOnly:!1});n&&(n.style.marginBottom="0",Y.appendChild(n),Y.style.marginBottom=x.xs)}function Fe(e,n,a,d){if(!e.length)return{elements:[],destroy:()=>{}};const r=e.map(i=>i.wafer),f=e.map(i=>i.dies),p=F(),l=[],y=[],b=Ct({groups:(d??[{key:"",items:e}]).map(i=>({key:i.key,items:i.items.map(t=>({dies:t.dies,testSpecYield:t.statsSummary?.stats.testSpecYield,functionalYield:t.statsSummary?.stats.functionalYield}))})),testDefs:a,onSaveImage:k,onSelectTest:(i,t)=>{const o=a.find(w=>w.testNumber===i.testNumber);o&&Q(t,e,`failing ${i.label}`,w=>Xe(w,o,i.kind)===!0,we(o)?i.testNumber:void 0)},ownerDocument:m});b.card.style.minHeight="300px",l.push(b.card),y.push(b.destroy);const s=i=>(t,o)=>{const w=new Set;for(const S of e)for(const v of It(S.dies,S.wafer,p,t.key,i))w.add(v);Q(o,e,`in ${t.label}`,S=>w.has(S))},g=Te(f,r,p,i=>e[i].passBins,De);if(g.length){const i=$e({title:"Ring yield",mode:"ring",rows:g,onSelectRegion:s(De),onSaveImage:k,ownerDocument:m});l.push(i.card),y.push(i.destroy)}const h=Te(f,r,p,i=>e[i].passBins,Be);if(h.length){const i=$e({title:"Quadrant yield",mode:"quadrant",rows:h,onSelectRegion:s(Be),onSaveImage:k,ownerDocument:m});l.push(i.card),y.push(i.destroy)}return{elements:l,destroy:()=>{for(const i of y)i()}}}function Ne(e,n,a){if(!e.length)return{cards:[],destroy:()=>{}};const d=e.map(s=>s.dies),r=e.flatMap(s=>s.dies),f=e.map(s=>s.statsSummary),p=f.every(s=>s!==void 0)?f:void 0,l=[],y=[];let c=null;if(n.length){const s=re();let g=null;const h=Lt(Dt(r,n,void 0,p,A,d.map(i=>({dies:i})),void 0,"full"),{onDone:i=>{g=i,s.removeAttribute("aria-busy"),i?s.replaceChildren(i):s.remove()}});if(h.done)g&&(c=s);else{const i=m.createElement("div");i.textContent="Computing test statistics\u2026",Object.assign(i.style,{color:B.label,fontSize:M.body}),s.setAttribute("aria-busy","true"),s.appendChild(i),c=s,l.push(()=>h.cancel())}}let b=null;if(a.length){const s=Bt(r,a,p,A);if(s){const g=re();g.appendChild(s),b=g}}return c&&y.push(c),b&&y.push(b),{cards:y,destroy:()=>{for(const s of l)s()}}}function Ye(e){const n=Se(e.map(c=>c.passBins)),a=e.length===1,d=e[0],r=re();Object.assign(r.style,{flexDirection:"row",flexWrap:"wrap",gap:x.md});const f=c=>{const b=c.lastElementChild;return b&&Object.assign(b.style,{borderRight:"none",paddingRight:"0",marginRight:"0"}),c};function p(c,b,s){const g=m.createElement("div");Object.assign(g.style,{display:"flex",alignItems:"baseline",gap:x.sm,paddingRight:x.xxl,marginRight:x.md,borderRight:`1px solid ${B.menuBorder}`});const h=m.createElement("div");h.textContent=c,Object.assign(h.style,{fontSize:M.heading,fontWeight:"700",color:B.value,lineHeight:it.tight});const i=m.createElement("div");if(i.textContent=b,Object.assign(i.style,{fontSize:M.body,color:B.label}),g.append(h,i),s){const t=m.createElement("div");t.textContent=s,Object.assign(t.style,{fontSize:M.meta,color:B.label,opacity:st.muted}),g.appendChild(t)}return g}if(a){const c=J([{...d,key:d.waferIndex}])[0]?.percent;return c!==void 0&&r.appendChild(p(`${c.toFixed(1)}%`,`Yield \xB7 pass: ${n}`)),r.appendChild(p(String(d.dies.length),"Total dies")),f(r)}r.appendChild(p(String(e.length),"Wafers"));const l=J(e.map(c=>({...c,key:c.waferIndex}))).map(c=>c.percent).filter(c=>Number.isFinite(c));if(l.length){const c=l.reduce((g,h)=>g+h,0)/l.length,b=ve([{key:"all",items:e.map(g=>({...g,key:g.waferIndex}))}])[0]?.percent,s=b!==void 0&&b.toFixed(1)!==c.toFixed(1);r.appendChild(p(`${c.toFixed(1)}%`,`${Ue} \xB7 pass: ${n}`,s?`${b.toFixed(1)}% by dies`:void 0))}const y=e.map(c=>c.statsSummary);if(y.every(c=>c!==void 0)){const c=y.reduce((s,g)=>s+g.stats.analyzedDies,0),b=y.reduce((s,g)=>s+g.stats.excludedDies,0);r.appendChild(p(c.toLocaleString(),"Dies analysed",b?`${b.toLocaleString()} excluded`:void 0))}else r.appendChild(p(e.reduce((c,b)=>c+b.dies.length,0).toLocaleString(),"Total dies"));return f(r)}function je(e,n,a,d,r){const f=m.createElement("div");Object.assign(f.style,{display:"flex",flexDirection:"column",gap:x.lg});const p=e.length===1&&!d;e.length&&!d&&f.appendChild(Ye(e));const l=We(e,d,r,!p);f.appendChild(l.card);const y=Fe(e,n,a,d);for(const c of y.elements)l.card.appendChild(c);return f.appendChild(Ge()),{card:f,destroy:()=>{l.destroy(),y.destroy()}}}function Ge(){const e=m.createElement("div");Object.assign(e.style,{fontSize:M.body,color:B.label});const n=m.createElement("button");return n.type="button",n.textContent="Data tab",n.dataset.wmapOpenDataTab="1",Object.assign(n.style,{border:"none",background:"none",padding:"0",cursor:"pointer",font:"inherit",color:B.iconActive,textDecoration:"underline"}),de(n,"bare"),n.addEventListener("click",()=>{L="data",G({keepSections:!0})}),e.append("Test statistics, every die and every wafer as tables, with CSV export: see the ",n,"."),e}function He(e,n,a,d){const r=m.createElement("div");r.style.width="100%";let f,p=!1;return import("./plotTab.js").then(({createPlotSection:l})=>{if(p)return;const y=l({doc:m,store:q,items:e,testDefs:n,ringCount:F(),groupBy:a,groupLabel:d,onSaveImage:k,onSaveText:A,openWafer:R?(c,b,s)=>R(c,b,s):void 0,focusTest:Z,locateDie:_,pickPlotsFile:$.onPickPlotsFile});r.appendChild(y.card),f=y}),{card:r,destroy:()=>{p=!0,f?.destroy()}}}function Ve(e,n,a,d,r){const f=pe?.(),p=()=>{j.get("data")?.destroy(),j.delete("data"),G({keepSections:!0})};return Et({doc:m,items:e,testDefs:n,allTestDefs:a,groups:d,groupLabelText:r,ringCount:F(),yieldByWaferIndex:new Map(f?.lotYieldSeries.map(l=>[l.waferIndex,l.yieldPercent])),onSaveText:A,onLocateDie:_,onOpenWafer:R?(l,y)=>R(l,y):void 0,buildStatistics:l=>Ne(l,n,a),view:fe,onViewChange:l=>{fe=l,p()},diesLayout:me,onDiesLayoutChange:l=>{me=l}})}function _e(e,n,a,d){const r=ce(m),f=ae(e),p=t=>o=>be(o,t()),l=t=>({...t,testStats:t.statsSummary?.stats.perTestStats}),y=e.map(l),c=a?.map(t=>({key:t.key,items:t.items.map(l)})),b=mt({title:"Test value distribution",axisPrefs:K,onAxisPrefsChange:p(()=>b),onTestChange:t=>h(t),selectedTestNumber:P??void 0,items:y,testDefs:n,groups:c,groupLabelText:d,onSaveImage:k,onGroupChange:t=>te(t),onOpen:f?.open,openActionLabel:f?.label,onWaferContextMenu:oe(e),ownerDocument:m}),s=gt({title:"Value histogram",axisPrefs:K,onAxisPrefsChange:p(()=>s),onTestChange:t=>h(t),selectedTestNumber:P??void 0,items:e,testDefs:n,groups:a,onGroupChange:t=>te(t),onSaveImage:k,onSelectBucket:(t,o)=>{const w=n.find(T=>T.testNumber===t.testNumber),S=new Set(t.items.map(T=>T.item)),v=new Set(t.items.flatMap(T=>T.dies)),H=Ce(t.low,w?.unit,"engineering"),ie=Ce(t.high,w?.unit,"engineering");Q(o,e.filter(T=>S.has(T)),`with ${w?Je(w,w.testNumber):`test ${t.testNumber}`} from ${H} to ${ie}${t.group?` in ${t.group}`:""}`,T=>v.has(T),t.testNumber)},ownerDocument:m}),g=bt({title:"Wafer-to-wafer trend",axisPrefs:K,onAxisPrefsChange:p(()=>g),onTestChange:t=>h(t),selectedTestNumber:P??void 0,items:e.map(t=>({label:t.label,key:t.waferIndex,dies:t.dies,testStats:t.statsSummary?.stats.perTestStats})),testDefs:n,onSaveImage:k,centreLabel:rt(at(e.map(t=>t.wafer.metadata)),"mean"),onOpen:R?(t,o)=>ne(t,`Wafer ${e.find(w=>w.waferIndex===t)?.label??t}`,o):void 0,onSelectWafers:(t,o,w)=>{const S=new Set(t.keys);ye(o,w,e.filter(v=>S.has(v.waferIndex)),"selected in the trend",()=>!0,t.testNumber)},onWaferContextMenu:oe(e),ownerDocument:m}),h=t=>{P=t,b.setTest(t),s.setTest(t),g.setTest(t),i.setTest(t)};ee.set("distribution",[b,s,g]);const i=ft({title:"Process capability",items:e,testDefs:n,onSaveImage:k,selectedTestNumber:P??void 0,onSelectTest:t=>h(t),ownerDocument:m});return r.append(i.card,b.card,s.card,g.card),{card:r,destroy:()=>{i.destroy(),b.destroy(),s.destroy(),g.destroy()}}}function ze(e,n,a){const d=ce(m),r=ht({title:"Test scatter",items:e,testDefs:n,groups:a,binColors:ue().hard,onSaveImage:k,axisPrefs:K,onAxisPrefsChange:p=>be(p,r),onOpen:ae(e)?.open,openActionLabel:ae(e)?.label,onSelect:(p,l,y,c)=>{const b=new Map;for(const h of p){if(h.waferIndex===void 0||!h.die)continue;const i=b.get(h.waferIndex);i?i.push(h.die):b.set(h.waferIndex,[h.die])}const s=[...b].flatMap(([h,i])=>{const t=e.find(o=>o.waferIndex===h);return t?[{label:t.identity??t.label,dies:i,waferIndex:h,wafer:t.wafer,passBins:t.passBins,ringCount:F()}]:[]});if(s.length===0)return;const g=s.length===1?`selected on ${s[0].label} in the scatter`:`selected in the scatter, across ${s.length} wafers`;se(l,y,{items:s,population:g,testDefs:n,activeTest:c},{plots:q,onSaveImage:k,onSaveText:A,onLocateDie:_})},ownerDocument:m});ee.set("correlation",[r]);const f=yt({title:"Test correlation matrix",items:e,testDefs:n,onSaveImage:k,onSaveText:A,onSelectPair:(p,l)=>r.setXY(p,l),ownerDocument:m});return d.append(f.card,r.card),{card:d,destroy:()=>{f.destroy(),r.destroy()}}}function G(e){e?.keepSections||ge(),U.innerHTML="",E.innerHTML="";for(const o of Pe)E.appendChild(Re(o.key,o.label));const n=Oe();Me(n);const a=qe(n,{facetableOnly:!0}).filter(o=>o.splittable),d=m.createElement("div");Object.assign(d.style,{display:"flex",gap:x.md,alignItems:"center",marginLeft:x.xxl,paddingBottom:x.xs});let r;a.length>0?(d.appendChild(kt("Group by:",[{value:"",label:"None"},...a.map(o=>({value:o.key,label:`${o.label} (${o.values.length})`}))],W??"",o=>{W=o||void 0,O=null,G()},{hook:"group-by",ownerDocument:m})),r=a.find(o=>o.key===W)?.label):W=void 0;let f;if(W){const o=new Map,w=[];for(const S of n){const v=Ke(S.metadata,W)??Qe;o.has(v)||(o.set(v,[]),w.push(v)),o.get(v).push(S)}f=w.map(S=>({key:S,items:o.get(S)}))}O!==null&&!f?.some(o=>o.key===O)&&(O=null),f&&f.length>0&&d.appendChild(vt(f.map(o=>o.key),"Show:",O,o=>te(o),{ownerDocument:m}).el);let p=null;if($.onOpenGuide){const o=m.createElement("button");o.type="button",o.innerHTML=ut.help,o.setAttribute("aria-label","User guide"),Object.assign(o.style,{...ct("bare"),display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",flexShrink:"0"}),de(o,"bare"),pt(o,"User guide"),o.addEventListener("click",()=>$.onOpenGuide()),Object.assign(o.style,{marginLeft:"auto"}),p=o}E.appendChild(d),p&&E.appendChild(p);const l=O!==null?f?.find(o=>o.key===O):void 0,y=l?.items??n,c=l?void 0:f,b=he(y),s=b.defs,g=s.filter(we);P!==null&&!g.some(o=>o.testNumber===P)&&(P=null);const h=e?.keepSections?j.get(L):void 0,i=h??(L==="overview"?je(y,g,s,c,r):L==="distributions"?_e(y,g,c,r):L==="data"?Ve(y,g,s,c,r):L==="plot"?He(y,s,l?void 0:W,l?void 0:r):ze(y,g,c));h||j.set(L,i);const t=b.conflicts.filter(o=>o.excluded);if(t.length>0){const o=m.createElement("div");Object.assign(o.style,{color:B.label,fontSize:M.body,padding:`0 ${z} ${x.sm}`});const w=t.slice(0,6).map(H=>H.testNumber).join(", "),S=t.length>6?`, and ${t.length-6} more`:"",v=t.length===1?"it":"them";o.textContent=`${t.length} test ${t.length===1?"number is":"numbers are"} hidden (${w}${S}) \u2014 the wafers in view describe ${v} differently, so their values cannot be pooled. `+(f&&f.length>0?`Pick one ${r??"group"} under "Show:" to analyse ${v}.`:"Load one test program at a time to analyse them."),o.dataset.wmapWithheldTests=String(t.length),U.appendChild(o)}U.appendChild(i.card)}return{el:N,render:G,destroy:()=>{ge(),q.flush(),N.remove()}}}
|
|
1
|
+
import{MEAN_WAFER_YIELD_LABEL as qe}from"../stats/presentation.js";import{buildFacetTable as Ke,facetValueOf as Qe,FACET_NONE_VALUE as Xe,DEFAULT_FACET_CURATION as Je}from"../stats/facets.js";import{mergeTestDefs as Se}from"../stats/mergeTestDefs.js";import{isParametricTest as xe}from"../renderer/buildWaferMap.js";import{dieFailsTest as Ze}from"../stats/testPassRate.js";import{fmt as ke}from"../renderer/fmt.js";import{testLabel as et}from"../renderer/testLabel.js";import{waferDisplayLabel as tt,waferIdentityLabel as nt}from"../core/waferLabel.js";import{waferPopulation as ot}from"./chartPopulation.js";import{openDrilldownMenu as se}from"./drilldown.js";import{plotStoreFor as it}from"./plotStore.js";import{itemPassBins as rt,passBinsLabel as Te}from"../core/passBins.js";import{NO_DATA_FILL as ve}from"../renderer/colorMap.js";import{describeWaferPopulation as at,populationStat as st}from"../stats/population.js";import{LEADING as lt,ALPHA as dt,SPACE as T,EDGE_GUTTER as le,FONT as F,CLR as $,RADIUS as ct,SHADOW as ut,controlStyle as pt,wireControlHover as de,wireTooltip as ft}from"./toolbar.js";import{ICONS as mt}from"./icons.js";import{renderCapabilityPanel as bt}from"./charts/capability.js";import{renderBoxplotPanel as ht}from"./charts/boxplot.js";import{renderTrendPanel as gt}from"./charts/trend.js";import{renderHistogramPanel as yt}from"./charts/histogram.js";import{renderCorrelationPanel as wt}from"./charts/correlation.js";import{renderScatterPanel as Ct}from"./charts/scatter.js";import{renderBarPanel as De}from"./charts/barPanel.js";import{renderBinClusterPanel as St}from"./charts/binCluster.js";import{renderTestPassRatePanel as xt}from"./charts/testPassRate.js";import{QUANTITY as kt}from"./charts/palette.js";import{cardFrameStyle as Tt,makeChartGridWrap as ce,makeLabeledSelect as vt,makeLinkedGroupSelect as Dt}from"./charts/chartShell.js";import{buildYieldData as J,buildYieldDataCombined as Be}from"../stats/yield.js";import{buildBinParetoData as Bt}from"../stats/binPareto.js";import{buildLotTestSectionSteps as $t,buildLotFunctionalSection as Lt,buildMetadataStripBox as It}from"./summaryPanel.js";import{runChunked as Et}from"./chunked.js";import{buildRegionYieldData as ue,buildRingRegions as $e,buildQuadrantRegions as Le,buildReticlePositionRegions as Pt,diesInRegion as At}from"../stats/regions.js";import{renderDataSection as Ot}from"./dataTab.js";import{sourceFromDies as Rt}from"./plotItems.js";import{renderRegionYieldDiagram as pe}from"./charts/regionYieldDiagram.js";const Wt=[{key:"overview",label:"Overview"},{key:"distributions",label:"Distributions"},{key:"correlation",label:"Correlation"}],Mt={key:"data",label:"Data"},Ft={key:"plot",label:"Plot"};export function createInsightsTab(v){const{getItems:Ie,getLotStats:fe,getBinColors:me,getRingCount:N,onSaveImage:k,onSaveText:O,openWafer:R,focusTest:Z,locateDie:V}=v,be={...Je,...v.attributes},Ee=v.showMetadataStrip??!0,z=v.contentInset??le,f=v.ownerDocument??document,Y=f.createElement("div");Object.assign(Y.style,{display:"none",flexDirection:"column",width:"100%",paddingTop:"0"});const Pe=le,j=f.createElement("div");Object.assign(j.style,{paddingLeft:Pe});const E=f.createElement("div");Object.assign(E.style,{display:"flex",gap:T.xs,alignItems:"center",background:$.menuBg,border:`1px solid ${$.menuBorder}`,borderRadius:ct.container,boxShadow:ut.panel,padding:`0 ${T.lg}`,marginBottom:T.lg,marginLeft:z,marginRight:z}),E.setAttribute("role","tablist"),E.addEventListener("keydown",e=>{if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const n=Array.from(E.querySelectorAll('[role="tab"]')),r=n.indexOf(f.activeElement);if(r===-1)return;e.preventDefault();const l=n[(r+(e.key==="ArrowRight"?1:-1)+n.length)%n.length];l.focus(),l.click()});const U=f.createElement("div");Object.assign(U.style,{display:"flex",flexDirection:"column",gap:T.lg,marginTop:"0",paddingLeft:z,paddingRight:z}),Y.appendChild(j),Y.appendChild(E),Y.appendChild(U);const Ae=[...Wt,Mt,Ft],q=v.plotStore??it(v);let L=v.defaultView==="sweeps"?"plot":v.defaultView??"overview",M,he="statistics",ge="wide",P=null,A=null,K={includeLimits:void 0,clipOutliers:!1,limits:"both"};const ee=new Map,ye=(e,n)=>{K=e;for(const r of ee.values())for(const l of r)l!==n&&l.setAxisPrefs(e)},te=e=>{A!==e&&(A=e,H())};let G=new Map;function we(){for(const e of G.values())e.destroy();G=new Map}function ne(e,n,r){R?.(e,n,r)}function oe(e){return(n,r,l)=>{const i=e.find(c=>c.waferIndex===n);if(!i)return;l.preventDefault();const u=ot(i.dies,{waferLabel:i.identity,testDefs:i.testDefs,activeTest:r??P??void 0,waferIndex:n,wafer:i.wafer,passBins:i.passBins,ringCount:N()});se({x:l.clientX,y:l.clientY},l.target,u,{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})}}function Q(e,n,r,l,i){Ce({x:e.clientX,y:e.clientY},e.target,n,r,l,i)}function Ce(e,n,r,l,i,u){const c=Rt(r.map(s=>({label:s.identity??s.label,dies:s.dies,waferIndex:s.waferIndex,wafer:s.wafer,passBins:s.passBins,ringCount:N()})),l,i,Se(r).defs,u);c&&se(e,n,c,{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})}function ie(e){return R?{open:(n,r)=>ne(n,`Wafer ${e.find(l=>l.waferIndex===n)?.label??n}`,r)}:Z&&e.length===1?{open:(n,r)=>Z(r),label:"show this test on the map"}:null}function Oe(){return Ie().map((e,n)=>e==null?null:{metadata:e.wafer.metadata??void 0,dies:e.dies,wafer:e.wafer,label:tt(e,n),identity:nt(e),waferIndex:n,passBins:rt(e),statsSummary:e.statsSummary,testDefs:e.testDefs}).filter(e=>e!=null)}function Re(e,n){Object.assign(e.style,{background:"none",border:"none",borderBottom:n?`2px solid ${$.iconActive}`:"2px solid transparent",color:n?$.iconActive:$.label,fontWeight:n?"700":"500",fontSize:F.body,padding:`${T.sm} ${le} ${T.md}`,cursor:"pointer",marginBottom:"-1px"})}function We(e,n){const r=f.createElement("button");r.type="button",r.textContent=n;const l=e===L;return Re(r,l),r.dataset.on=l?"true":"false",de(r,"bare"),r.dataset.wmapInsightsTab=e,r.setAttribute("role","tab"),r.setAttribute("aria-selected",l?"true":"false"),r.tabIndex=l?0:-1,r.addEventListener("click",()=>{L!==e&&(L=e,H({keepSections:!0}))}),r}function Me(e,n,r,l=!0){const i=ce(f),u=me();let c="label";const s=r??"group",h=Te(e.map(p=>p.passBins)),d=fe?.(),m=new Map(d?.lotYieldSeries.map(p=>[p.waferIndex,p.yieldPercent])),a=p=>({...p,label:p.label.replace(/\s*·\s*\d+(\.\d+)?%$/,""),yieldPercent:m.get(p.waferIndex),key:p.waferIndex}),b=e.map(a),y=n?.map(p=>({key:p.key,items:p.items.map(a)})),w=()=>y?Be(y,c):J(b,c),t={title:n?`Yield by ${s} (pass: ${h})`:`Yield by wafer (pass: ${h})`,data:w(),selfControl:{current:c,options:[["yield","Sort: yield"],["label",n?`Sort: ${s}`:"Sort: wafer ID"]],onChange:p=>(c=p,{data:w()})},barColor:()=>kt,valueLabel:p=>`${p.percent.toFixed(1)}%`,reference:p=>{if(p.length<3)return null;const S=p.map(I=>I.percent).sort((I,_)=>I-_),B=S.length%2?S[(S.length-1)/2]:(S[S.length/2-1]+S[S.length/2])/2;return{value:B,label:`median ${B.toFixed(1)}%`}},drill:y?{onOpenGroup:p=>{const S=y.find(B=>B.key===p.label)?.items??[];return{data:J(S,c),title:`Yield by wafer \u2014 ${s}: ${p.label} (pass: ${h})`}},onBack:()=>({data:w(),title:`Yield by ${s} (pass: ${h})`}),groupLabelText:s}:void 0,onOpen:R?p=>{typeof p.key=="number"&&ne(p.key,`Wafer ${p.label}`)}:void 0,onWaferContextMenu:oe(e),ownerDocument:f};let o=null;if(l&&(o=De(t,k),o.card.style.minHeight="360px",i.appendChild(o.card)),n){const p=St({title:"Hard bin pareto",groups:n.map(S=>({key:S.key,items:S.items.map(B=>({dies:B.dies,hardBinCounts:B.statsSummary?.stats.hardBinCounts,softBinCounts:B.statsSummary?.stats.softBinCounts}))})),onSelectBin:(S,B)=>{const I=n.find(X=>X.key===S.groupKey);if(!I)return;const _=S.binType==="hbin"?"hard":"soft";Q(B,I.items,`in ${_} bin ${S.bin} of ${S.groupKey}`,X=>(S.binType==="hbin"?X.hbin:X.sbin)===S.bin)},onSaveImage:k,ownerDocument:f});return p.card.style.minHeight="360px",i.appendChild(p.card),{card:i,destroy:()=>{o?.destroy(),p.destroy()}}}let g="hbin";const C=p=>p===void 0?ve:(g==="hbin"?u.hard:u.soft).get(p)??ve,x=e.map(p=>({dies:p.dies,hardBinCounts:p.statsSummary?.stats.hardBinCounts,softBinCounts:p.statsSummary?.stats.softBinCounts})),W=()=>Bt(x,g),ae={title:"Hard bin pareto",data:W(),selfControl:{current:g,options:[["hbin","Hard bins","The physical sort result: where the part goes on the handler"],["sbin","Soft bins","The test program\u2019s failure category: many soft bins can map to one hard bin"]],onChange:p=>(g=p,{data:W(),title:`${g==="hbin"?"Hard":"Soft"} bin pareto`})},barColor:p=>C(p.binCode),onSelectBar:(p,S)=>{const B=g==="hbin"?"hard":"soft",I=p.binCode;Q(S,e,I===void 0?`with no ${B} bin recorded`:`in ${B} bin ${I}`,_=>(g==="hbin"?_.hbin:_.sbin)===I)},selectLabel:"chart or tabulate its dies",ownerDocument:f},D=De(ae,k);return D.card.style.minHeight="360px",i.appendChild(D.card),{card:i,destroy:()=>{o?.destroy(),D.destroy()}}}function re(){const e=f.createElement("div");return e.dataset.wmapChartCard="1",Object.assign(e.style,{...Tt(),display:"flex",flexDirection:"column",gap:T.lg,minWidth:"0"}),e}function Fe(e){if(j.innerHTML="",j.style.marginBottom="0",!Ee)return;const n=It(e.map(r=>({metadata:r.metadata})),void 0,{facetableOnly:!1});n&&(n.style.marginBottom="0",j.appendChild(n),j.style.marginBottom=T.xs)}function Ne(e,n,r,l){if(!e.length)return{elements:[],destroy:()=>{}};const i=e.map(t=>t.wafer),u=e.map(t=>t.dies),c=N(),s=[],h=[],m=xt({groups:(l??[{key:"",items:e}]).map(t=>({key:t.key,items:t.items.map(o=>({dies:o.dies,testSpecYield:o.statsSummary?.stats.testSpecYield,functionalYield:o.statsSummary?.stats.functionalYield}))})),testDefs:r,onSaveImage:k,onSelectTest:(t,o)=>{const g=r.find(C=>C.testNumber===t.testNumber);g&&Q(o,e,`failing ${t.label}`,C=>Ze(C,g,t.kind)===!0,xe(g)?t.testNumber:void 0)},ownerDocument:f});m.card.style.minHeight="300px",s.push(m.card),h.push(m.destroy);const a=t=>(o,g)=>{const C=new Set;for(const x of e)for(const W of At(x.dies,x.wafer,c,o.key,t))C.add(W);Q(g,e,`in ${o.label}`,x=>C.has(x))},b=ue(u,i,c,t=>e[t].passBins,$e);if(b.length){const t=pe({title:"Ring yield",mode:"ring",rows:b,onSelectRegion:a($e),onSaveImage:k,ownerDocument:f});s.push(t.card),h.push(t.destroy)}const y=ue(u,i,c,t=>e[t].passBins,Le);if(y.length){const t=pe({title:"Quadrant yield",mode:"quadrant",rows:y,onSelectRegion:a(Le),onSaveImage:k,ownerDocument:f});s.push(t.card),h.push(t.destroy)}const w=i.find(t=>t.reticle!==void 0)?.reticle;if(w){const t=(g,C)=>Pt(g,C.reticle),o=ue(u,i,c,g=>e[g].passBins,t);if(o.length){const g=pe({title:"Reticle cell yield",mode:"reticleCell",rows:o,grid:{width:w.width,height:w.height},onSelectRegion:a(t),onSaveImage:k,ownerDocument:f});s.push(g.card),h.push(g.destroy)}}return{elements:s,destroy:()=>{for(const t of h)t()}}}function Ye(e,n,r){if(!e.length)return{cards:[],destroy:()=>{}};const l=e.map(a=>a.dies),i=e.flatMap(a=>a.dies),u=e.map(a=>a.statsSummary),c=u.every(a=>a!==void 0)?u:void 0,s=[],h=[];let d=null;if(n.length){const a=re();let b=null;const y=Et($t(i,n,void 0,c,O,l.map(w=>({dies:w})),void 0,"full"),{onDone:w=>{b=w,a.removeAttribute("aria-busy"),w?a.replaceChildren(w):a.remove()}});if(y.done)b&&(d=a);else{const w=f.createElement("div");w.textContent="Computing test statistics\u2026",Object.assign(w.style,{color:$.label,fontSize:F.body}),a.setAttribute("aria-busy","true"),a.appendChild(w),d=a,s.push(()=>y.cancel())}}let m=null;if(r.length){const a=Lt(i,r,c,O);if(a){const b=re();b.appendChild(a),m=b}}return d&&h.push(d),m&&h.push(m),{cards:h,destroy:()=>{for(const a of s)a()}}}function je(e){const n=Te(e.map(d=>d.passBins)),r=e.length===1,l=e[0],i=re();Object.assign(i.style,{flexDirection:"row",flexWrap:"wrap",gap:T.md});const u=d=>{const m=d.lastElementChild;return m&&Object.assign(m.style,{borderRight:"none",paddingRight:"0",marginRight:"0"}),d};function c(d,m,a){const b=f.createElement("div");Object.assign(b.style,{display:"flex",alignItems:"baseline",gap:T.sm,paddingRight:T.xxl,marginRight:T.md,borderRight:`1px solid ${$.menuBorder}`});const y=f.createElement("div");y.textContent=d,Object.assign(y.style,{fontSize:F.heading,fontWeight:"700",color:$.value,lineHeight:lt.tight});const w=f.createElement("div");if(w.textContent=m,Object.assign(w.style,{fontSize:F.body,color:$.label}),b.append(y,w),a){const t=f.createElement("div");t.textContent=a,Object.assign(t.style,{fontSize:F.meta,color:$.label,opacity:dt.muted}),b.appendChild(t)}return b}if(r){const d=J([{...l,key:l.waferIndex}])[0]?.percent;return d!==void 0&&i.appendChild(c(`${d.toFixed(1)}%`,`Yield \xB7 pass: ${n}`)),i.appendChild(c(String(l.dies.length),"Total dies")),u(i)}i.appendChild(c(String(e.length),"Wafers"));const s=J(e.map(d=>({...d,key:d.waferIndex}))).map(d=>d.percent).filter(d=>Number.isFinite(d));if(s.length){const d=s.reduce((b,y)=>b+y,0)/s.length,m=Be([{key:"all",items:e.map(b=>({...b,key:b.waferIndex}))}])[0]?.percent,a=m!==void 0&&m.toFixed(1)!==d.toFixed(1);i.appendChild(c(`${d.toFixed(1)}%`,`${qe} \xB7 pass: ${n}`,a?`${m.toFixed(1)}% by dies`:void 0))}const h=e.map(d=>d.statsSummary);if(h.every(d=>d!==void 0)){const d=h.reduce((a,b)=>a+b.stats.analyzedDies,0),m=h.reduce((a,b)=>a+b.stats.excludedDies,0);i.appendChild(c(d.toLocaleString(),"Dies analysed",m?`${m.toLocaleString()} excluded`:void 0))}else i.appendChild(c(e.reduce((d,m)=>d+m.dies.length,0).toLocaleString(),"Total dies"));return u(i)}function Ge(e,n,r,l,i){const u=f.createElement("div");Object.assign(u.style,{display:"flex",flexDirection:"column",gap:T.lg});const c=e.length===1&&!l;e.length&&!l&&u.appendChild(je(e));const s=Me(e,l,i,!c);u.appendChild(s.card);const h=Ne(e,n,r,l);for(const d of h.elements)s.card.appendChild(d);return u.appendChild(He()),{card:u,destroy:()=>{s.destroy(),h.destroy()}}}function He(){const e=f.createElement("div");Object.assign(e.style,{fontSize:F.body,color:$.label});const n=f.createElement("button");return n.type="button",n.textContent="Data tab",n.dataset.wmapOpenDataTab="1",Object.assign(n.style,{border:"none",background:"none",padding:"0",cursor:"pointer",font:"inherit",color:$.iconActive,textDecoration:"underline"}),de(n,"bare"),n.addEventListener("click",()=>{L="data",H({keepSections:!0})}),e.append("Test statistics, every die and every wafer as tables, with CSV export: see the ",n,"."),e}function _e(e,n,r,l){const i=f.createElement("div");i.style.width="100%";let u,c=!1;return import("./plotTab.js").then(({createPlotSection:s})=>{if(c)return;const h=s({doc:f,store:q,items:e,testDefs:n,ringCount:N(),attributes:v.attributes,groupBy:r,groupLabel:l,onSaveImage:k,onSaveText:O,openWafer:R?(d,m,a)=>R(d,m,a):void 0,focusTest:Z,locateDie:V,pickPlotsFile:v.onPickPlotsFile});i.appendChild(h.card),u=h}),{card:i,destroy:()=>{c=!0,u?.destroy()}}}function Ve(e,n,r,l,i){const u=fe?.(),c=()=>{G.get("data")?.destroy(),G.delete("data"),H({keepSections:!0})};return Ot({doc:f,items:e,testDefs:n,allTestDefs:r,groups:l,groupLabelText:i,ringCount:N(),attributes:v.attributes,yieldByWaferIndex:new Map(u?.lotYieldSeries.map(s=>[s.waferIndex,s.yieldPercent])),onSaveText:O,onLocateDie:V,onOpenWafer:R?(s,h)=>R(s,h):void 0,buildStatistics:s=>Ye(s,n,r),view:he,onViewChange:s=>{he=s,c()},diesLayout:ge,onDiesLayoutChange:s=>{ge=s}})}function ze(e,n,r,l){const i=ce(f),u=ie(e),c=t=>o=>ye(o,t()),s=t=>({...t,testStats:t.statsSummary?.stats.perTestStats}),h=e.map(s),d=r?.map(t=>({key:t.key,items:t.items.map(s)})),m=ht({title:"Test value distribution",axisPrefs:K,onAxisPrefsChange:c(()=>m),onTestChange:t=>y(t),selectedTestNumber:P??void 0,items:h,testDefs:n,groups:d,groupLabelText:l,onSaveImage:k,onGroupChange:t=>te(t),onOpen:u?.open,openActionLabel:u?.label,onWaferContextMenu:oe(e),ownerDocument:f}),a=yt({title:"Value histogram",axisPrefs:K,onAxisPrefsChange:c(()=>a),onTestChange:t=>y(t),selectedTestNumber:P??void 0,items:e,testDefs:n,groups:r,onGroupChange:t=>te(t),onSaveImage:k,onSelectBucket:(t,o)=>{const g=n.find(D=>D.testNumber===t.testNumber),C=new Set(t.items.map(D=>D.item)),x=new Set(t.items.flatMap(D=>D.dies)),W=ke(t.low,g?.unit,"engineering"),ae=ke(t.high,g?.unit,"engineering");Q(o,e.filter(D=>C.has(D)),`with ${g?et(g,g.testNumber):`test ${t.testNumber}`} from ${W} to ${ae}${t.group?` in ${t.group}`:""}`,D=>x.has(D),t.testNumber)},ownerDocument:f}),b=gt({title:"Wafer-to-wafer trend",axisPrefs:K,onAxisPrefsChange:c(()=>b),onTestChange:t=>y(t),selectedTestNumber:P??void 0,items:e.map(t=>({label:t.label,key:t.waferIndex,dies:t.dies,testStats:t.statsSummary?.stats.perTestStats})),testDefs:n,onSaveImage:k,centreLabel:st(at(e.map(t=>t.wafer.metadata)),"mean"),onOpen:R?(t,o)=>ne(t,`Wafer ${e.find(g=>g.waferIndex===t)?.label??t}`,o):void 0,onSelectWafers:(t,o,g)=>{const C=new Set(t.keys);Ce(o,g,e.filter(x=>C.has(x.waferIndex)),"selected in the trend",()=>!0,t.testNumber)},onWaferContextMenu:oe(e),ownerDocument:f}),y=t=>{P=t,m.setTest(t),a.setTest(t),b.setTest(t),w.setTest(t)};ee.set("distribution",[m,a,b]);const w=bt({title:"Process capability",items:e,testDefs:n,onSaveImage:k,selectedTestNumber:P??void 0,onSelectTest:t=>y(t),ownerDocument:f});return i.append(w.card,m.card,a.card,b.card),{card:i,destroy:()=>{w.destroy(),m.destroy(),a.destroy(),b.destroy()}}}function Ue(e,n,r){const l=ce(f),i=Ct({title:"Test scatter",items:e,testDefs:n,groups:r,binColors:me().hard,onSaveImage:k,axisPrefs:K,onAxisPrefsChange:c=>ye(c,i),onOpen:ie(e)?.open,openActionLabel:ie(e)?.label,onSelect:(c,s,h,d)=>{const m=new Map;for(const y of c){if(y.waferIndex===void 0||!y.die)continue;const w=m.get(y.waferIndex);w?w.push(y.die):m.set(y.waferIndex,[y.die])}const a=[...m].flatMap(([y,w])=>{const t=e.find(o=>o.waferIndex===y);return t?[{label:t.identity??t.label,dies:w,waferIndex:y,wafer:t.wafer,passBins:t.passBins,ringCount:N()}]:[]});if(a.length===0)return;const b=a.length===1?`selected on ${a[0].label} in the scatter`:`selected in the scatter, across ${a.length} wafers`;se(s,h,{items:a,population:b,testDefs:n,activeTest:d},{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})},ownerDocument:f});ee.set("correlation",[i]);const u=wt({title:"Test correlation matrix",items:e,testDefs:n,onSaveImage:k,onSaveText:O,onSelectPair:(c,s)=>i.setXY(c,s),ownerDocument:f});return l.append(u.card,i.card),{card:l,destroy:()=>{u.destroy(),i.destroy()}}}function H(e){e?.keepSections||we(),U.innerHTML="",E.innerHTML="";for(const o of Ae)E.appendChild(We(o.key,o.label));const n=Oe();Fe(n);const r=Ke(n,{facetableOnly:!0,curation:be}).filter(o=>o.splittable),l=f.createElement("div");Object.assign(l.style,{display:"flex",gap:T.md,alignItems:"center",marginLeft:T.xxl,paddingBottom:T.xs});let i;r.length>0?(l.appendChild(vt("Group by:",[{value:"",label:"None"},...r.map(o=>({value:o.key,label:`${o.label} (${o.values.length})`}))],M??"",o=>{M=o||void 0,A=null,H()},{hook:"group-by",ownerDocument:f})),i=r.find(o=>o.key===M)?.label):M=void 0;let u;if(M){const o=new Map,g=[];for(const C of n){const x=Qe(C.metadata,M,be)??Xe;o.has(x)||(o.set(x,[]),g.push(x)),o.get(x).push(C)}u=g.map(C=>({key:C,items:o.get(C)}))}A!==null&&!u?.some(o=>o.key===A)&&(A=null),u&&u.length>0&&l.appendChild(Dt(u.map(o=>o.key),"Show:",A,o=>te(o),{ownerDocument:f}).el);let c=null;if(v.onOpenGuide){const o=f.createElement("button");o.type="button",o.innerHTML=mt.help,o.setAttribute("aria-label","User guide"),Object.assign(o.style,{...pt("bare"),display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",flexShrink:"0"}),de(o,"bare"),ft(o,"User guide"),o.addEventListener("click",()=>v.onOpenGuide()),Object.assign(o.style,{marginLeft:"auto"}),c=o}E.appendChild(l),c&&E.appendChild(c);const s=A!==null?u?.find(o=>o.key===A):void 0,h=s?.items??n,d=s?void 0:u,m=Se(h),a=m.defs,b=a.filter(xe);P!==null&&!b.some(o=>o.testNumber===P)&&(P=null);const y=e?.keepSections?G.get(L):void 0,w=y??(L==="overview"?Ge(h,b,a,d,i):L==="distributions"?ze(h,b,d,i):L==="data"?Ve(h,b,a,d,i):L==="plot"?_e(h,a,s?void 0:M,s?void 0:i):Ue(h,b,d));y||G.set(L,w);const t=m.conflicts.filter(o=>o.excluded);if(t.length>0){const o=f.createElement("div");Object.assign(o.style,{color:$.label,fontSize:F.body,padding:`0 ${z} ${T.sm}`});const g=t.slice(0,6).map(W=>W.testNumber).join(", "),C=t.length>6?`, and ${t.length-6} more`:"",x=t.length===1?"it":"them";o.textContent=`${t.length} test ${t.length===1?"number is":"numbers are"} hidden (${g}${C}) \u2014 the wafers in view describe ${x} differently, so their values cannot be pooled. `+(u&&u.length>0?`Pick one ${i??"group"} under "Show:" to analyse ${x}.`:"Load one test program at a time to analyse them."),o.dataset.wmapWithheldTests=String(t.length),U.appendChild(o)}U.appendChild(w.card)}return{el:Y,render:H,destroy:()=>{we(),q.flush(),Y.remove()}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{combinationIssue as le,describeTitleDrift as oe,fieldKey as k,fieldsForRole as H,titleDrift as ae}from"../stats/plotData.js";import{sameField as j}from"../stats/plotSpec.js";import{CLR as m,FONT as S,RADIUS as V,SPACE as b,controlStyle as K,wireControlHover as _}from"./toolbar.js";import{makeListSelect as X,makeSegmented as N,makeToggle as se}from"./charts/chartShell.js";const Y="\0follow",z="\0none",re=[["scatter","Scatter"],["histogram","Histogram"],["box","Box"],["bar","Bar"],["line","Line"]],A="\0auto",G="\0count",Q={mean:"Mean",median:"Median",min:"Minimum",max:"Maximum",sum:"Sum",count:"Count",yield:"Pooled yield (passing over judged dies)"};export function inputStyle(){return{background:m.menuBg,color:m.text,border:`1px solid ${m.menuBorder}`,borderRadius:V.control,padding:`${b.xs} ${b.sm}`,fontSize:S.body,fontFamily:S.family,boxSizing:"border-box",minWidth:"0"}}export function fieldRow(c,r,B,a){const p=c.createElement("div");Object.assign(p.style,{display:"flex",flexDirection:"column",gap:b.xxs,minWidth:"0"});const x=c.createElement("div");if(x.textContent=r,Object.assign(x.style,{fontSize:S.sub,color:m.label,fontWeight:"600"}),p.append(x,B),a){const T=c.createElement("div");T.textContent=a,Object.assign(T.style,{fontSize:S.sub,color:m.label}),p.appendChild(T)}return p}export function createPlotEditor(c){const{doc:r}=c,B=t=>t.fields?t:{...t,fields:{}};let a=B(c.plot),p="setup";const x=r.createElement("div");x.dataset.wmapPlotEditor="1",Object.assign(x.style,{display:"flex",flexDirection:"column",gap:b.lg,minWidth:"0"});const T=t=>{a=t,c.onChange(t)},y=t=>{const e=JSON.parse(JSON.stringify(a));t(e),T(e)},d=(t,e,i)=>fieldRow(r,t,e,i),D=t=>{const e=t&&c.catalogue.find(i=>j(i.field,t));return e?{label:e.name,level:e.level,kind:e.kind,yield:"builtin"in e.field&&e.field.builtin==="yield"}:void 0};function Z(t,e){const i=a.fields??{},n=i.color&&!("follow"in i.color)&&!("none"in i.color)?i.color:void 0,l={x:D(i.x),y:D(i.y),color:D(n)};l[t]=D(e.field);const o=a.chart==="scatter"&&l.color?.kind==="numeric"&&!!n&&!("meta"in n);return le(a.chart,l,{aggregate:a.aggregate,level:a.level,continuousColor:o})?.short}const I=t=>{const e=a.fields?.[t],i=e&&!("follow"in e)&&!("none"in e)?e:void 0;return H(c.catalogue,a.chart,t).map(n=>{const l=i&&j(n.field,i)?void 0:Z(t,n);return{value:k(n.field),label:n.label,group:n.group,...l?{disabled:l}:{}}})},J=t=>c.catalogue.find(e=>k(e.field)===t)?.field;function v(t,e,i={}){const n=a.fields[t],l=I(t);if(i.optional&&l.unshift({value:G,label:i.optional,group:"Count"}),n&&!l.some(u=>u.value===k(n))){const u=c.catalogue.some(C=>j(C.field,n)),h="test"in n?n.name??`Test ${n.test}`:"meta"in n?n.meta:n.builtin;l.unshift({value:k(n),label:`${h} (${u?"not usable here":"not in this lot"})`,group:"Saved"})}const o=n?k(n):i.optional?G:"",s=X(l,o,u=>{if(u===G){y(C=>{delete C.fields[t]});return}const h=J(u)??a.fields[t];h&&y(C=>{C.fields[t]=h})},{maxWidth:"100%",ownerDocument:r,ariaLabel:e,emptyText:"Choose a field\u2026",searchPlaceholder:"Filter fields\u2026",hook:`plot-${t}`});return s.style.width="100%",s}const P={},F={};function ee(t){y(e=>{e.chart=t;for(const i of["x","y"]){const n=H(c.catalogue,t,i),l=h=>!!h&&n.some(C=>j(C.field,h)),o=e.fields[i];if(o&&!l(o)&&(j(o,F[i])||(P[i]=o),delete e.fields[i]),e.fields[i]||i==="y"&&t==="bar")continue;const s=P[i];if(l(s)){e.fields[i]=s,delete P[i],delete F[i];continue}const u=i==="x"&&(t==="box"||t==="bar")?{builtin:"wafer"}:i==="x"&&t==="line"?n.find(h=>h.group==="Wafer")?.field??n[0]?.field:n[0]?.field;u&&!(i==="x"&&t==="histogram")&&(e.fields[i]=u,F[i]=u)}}),E()}function te(){const t=!!a.fields.y&&"builtin"in a.fields.y&&a.fields.y.builtin==="yield",e=[{value:A,label:"Automatic"},...["mean","median","min","max","sum","count"].map(n=>({value:n,label:Q[n]}))];t&&e.push({value:"yield",label:Q.yield});const i=X(e,a.aggregate??A,n=>y(l=>{n===A?delete l.aggregate:l.aggregate=n}),{maxWidth:"100%",ownerDocument:r,ariaLabel:"Combine values by",hook:"plot-aggregate"});return i.style.width="100%",i}function ie(){const t=a.fields.color,e=c.followLabel(),i=[{value:Y,label:e?`Follow Group by (${e})`:"Follow Group by (single colour)",group:"Colour"},{value:z,label:"None",group:"Colour"},...I("color")],n=t===void 0||"follow"in t?Y:"none"in t?z:k(t),l=X(i,n,o=>{y(s=>{if(o===Y)delete s.fields.color;else if(o===z)s.fields.color={none:!0};else{const u=J(o);u&&(s.fields.color=u)}})},{maxWidth:"100%",ownerDocument:r,ariaLabel:"Colour",searchPlaceholder:"Filter fields\u2026",hook:"plot-color"});return l.style.width="100%",l}function U(t,e,i,n){const l=r.createElement("input");return l.type="text",l.value=t,l.placeholder=e,l.setAttribute("aria-label",i),Object.assign(l.style,inputStyle(),{width:"100%"}),l.addEventListener("input",()=>n(l.value)),l.addEventListener("keydown",o=>{o.key==="Escape"&&(o.stopPropagation(),l.blur())}),l}function R(t,e,i){const n=r.createElement("input");n.type="text",n.inputMode="decimal",n.value=t===void 0?"":String(t),n.placeholder="auto",n.setAttribute("aria-label",e),Object.assign(n.style,inputStyle(),{width:"100%",fontVariantNumeric:"tabular-nums"});const l=()=>{const o=n.value.trim();if(o===""){i(void 0);return}const s=Number(o);Number.isFinite(s)?i(s):n.value=t===void 0?"":String(t)};return n.addEventListener("change",l),n.addEventListener("keydown",o=>{o.key==="Enter"&&l(),o.key==="Escape"&&(o.stopPropagation(),n.value=t===void 0?"":String(t),n.blur())}),n}function q(t,e,i,n){const l=a.axes?.[t]??{},o=g=>y(f=>{f.axes=f.axes??{};const O=f.axes[t]=f.axes[t]??{};g(O);for(const $ of Object.keys(O))(O[$]===void 0||O[$]===""||$==="reverse"&&O[$]===!1)&&delete O[$];Object.keys(O).length===0&&delete f.axes[t],Object.keys(f.axes).length===0&&delete f.axes}),s=r.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:b.md,padding:b.lg,border:`1px solid ${m.menuBorder}`,borderRadius:V.control});const u=r.createElement("div");u.textContent=e,Object.assign(u.style,{fontSize:S.body,fontWeight:"600",color:m.value}),s.appendChild(u);const h=U(l.label??"",i??"",`${e} title`,g=>o(f=>{f.label=g.trim()===""?void 0:g}));if(h.dataset.wmapPlotAxisTitle=t,s.appendChild(d("Title",h)),n.limits===!1)return s;const C=r.createElement("div");return Object.assign(C.style,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:b.md}),C.append(d("Minimum",R(l.min,`${e} minimum`,g=>o(f=>{f.min=g}))),d("Maximum",R(l.max,`${e} maximum`,g=>o(f=>{f.max=g})))),s.appendChild(C),n.scale&&s.appendChild(d("Scale",N([["linear","Linear"],["log","Log"]],l.scale??"linear",g=>o(f=>{f.scale=g==="log"?"log":void 0}),r))),s.appendChild(se("Reverse direction",!!l.reverse,g=>o(f=>{f.reverse=g}),r)),s}const ne=t=>x.querySelector(`[role="tab"][data-tab="${t}"]`);let L,w;const W=new Map;function M(){if(!w)return;const t=oe(ae(a,c.catalogue));if(w.replaceChildren(),w.style.display=t?"flex":"none",!t)return;const e=r.createElement("span");e.textContent=t;const i=r.createElement("button");i.type="button",i.textContent="Use the automatic title",i.dataset.wmapPlotAutoTitle="1",Object.assign(i.style,K("outlined")),_(i),i.addEventListener("click",()=>{y(n=>{delete n.title}),E()}),w.append(e,i)}function E(){x.replaceChildren(),W.clear();const t=r.createElement("div");t.setAttribute("role","tablist"),Object.assign(t.style,{display:"flex",gap:b.sm,borderBottom:`1px solid ${m.menuBorder}`});for(const[i,n]of[["setup","Setup"],["customise","Customise"]]){const l=r.createElement("button");l.type="button",l.textContent=n,l.setAttribute("role","tab"),l.dataset.tab=i,l.setAttribute("aria-selected",String(p===i)),Object.assign(l.style,{...K("bare"),padding:`${b.sm} ${b.lg}`,fontSize:S.body,borderBottom:`2px solid ${p===i?m.iconActive:"transparent"}`,borderRadius:"0",color:p===i?m.iconActive:m.text,fontWeight:p===i?"600":"400"}),_(l,"bare"),l.tabIndex=p===i?0:-1,l.addEventListener("click",()=>{p=i,E()}),l.addEventListener("keydown",o=>{o.key!=="ArrowLeft"&&o.key!=="ArrowRight"||(o.preventDefault(),p=i==="setup"?"customise":"setup",E(),ne(p)?.focus())}),t.appendChild(l)}x.appendChild(t);const e=r.createElement("div");if(e.setAttribute("role","tabpanel"),Object.assign(e.style,{display:"flex",flexDirection:"column",gap:b.lg}),p==="setup"){e.appendChild(d("Chart type",N(re,a.chart,n=>ee(n),r,!0)));const i=a.level==="wafer"?"wafers":"dies";switch(a.chart){case"scatter":e.appendChild(d("X axis",v("x","X axis"))),e.appendChild(d("Y axis",v("y","Y axis")));break;case"histogram":e.appendChild(d("Values",v("y","Values")));break;case"box":e.appendChild(d("Categories (X axis)",v("x","Categories"),"One box per value of this field.")),e.appendChild(d("Values (Y axis)",v("y","Values")));break;case"bar":e.appendChild(d("Categories (X axis)",v("x","Categories"),"One bar per value of this field.")),e.appendChild(d("Values (Y axis)",v("y","Values",{optional:`Count of ${i}`})));break;case"line":e.appendChild(d("X axis",v("x","X axis"),"A line joins the value at each X.")),e.appendChild(d("Y axis",v("y","Y axis")));break}e.appendChild(d("Colour",ie(),"Each value of the field gets its own colour. Follow Group by takes it from the Group by control.")),(a.chart==="bar"||a.chart==="line"||a.level==="wafer")&&e.appendChild(d("Combine values by",te())),e.appendChild(d("One mark per",N([[A,"Automatic"],["die","Die"],["wafer","Wafer"]],a.level??A,n=>{y(l=>{n===A?delete l.level:l.level=n}),E()},r,!0),a.level==="wafer"?"Die-level values are combined per wafer.":"Automatic uses the finest level the chosen fields allow."))}else{L=U(a.title??"",c.autoText().title,"Plot title",o=>{y(s=>{o.trim()===""?delete s.title:Object.assign(s,{title:o})}),M()}),L.dataset.wmapPlotTitle="1",w=r.createElement("div"),w.dataset.wmapPlotTitleDrift="1",Object.assign(w.style,{display:"none",flexDirection:"column",gap:b.sm,alignItems:"flex-start",padding:`${b.sm} ${b.md}`,background:m.warnBg,border:`1px solid ${m.warnBorder}`,borderRadius:V.control,color:m.warnText,fontSize:S.body}),e.appendChild(d("Title",L)),e.appendChild(w),M();const i=c.autoText(),n=a.chart==="box"||a.chart==="bar";e.appendChild(q("x",a.chart==="histogram"?"Values axis":n?"Categories axis":"X axis",i.x,{scale:!n,limits:!n})),e.appendChild(q("y",a.chart==="histogram"?"Count axis":n||a.chart==="line"?"Values axis":"Y axis",i.y,{scale:a.chart!=="histogram"})),a.chart==="histogram"&&e.appendChild(d("Bins",R(a.bins,"Number of bins",o=>y(s=>{o===void 0||!Number.isInteger(o)||o<1?delete s.bins:s.bins=Math.min(o,200)})),"Automatic is 16 equal bins."));const l=a.fields??{};(l.x&&"test"in l.x||l.y&&"test"in l.y)&&e.appendChild(d("Limits",N([["both","Test + spec"],["test","Test"],["spec","Spec"],["none","None"]],a.limits??"both",o=>y(s=>{o==="both"?delete s.limits:s.limits=o}),r),"Drawn as dashed lines on the axis of a test that has them: short dashes for test limits, long for spec limits."));for(const o of e.querySelectorAll("[data-wmap-plot-axis-title]"))W.set(o.dataset.wmapPlotAxisTitle,o)}x.appendChild(e)}return E(),{el:x,setPlot(t){const e=B(t);JSON.stringify(e)!==JSON.stringify(a)&&(a=e,E())},refreshAuto(){const t=c.autoText();L&&(L.placeholder=t.title),M();for(const[e,i]of W)i.placeholder=(e==="x"?t.x:t.y)??""}}}
|
|
1
|
+
import{combinationIssue as le,describeTitleDrift as oe,fieldKey as k,fieldsForRole as q,titleDrift as ae}from"../stats/plotData.js";import{sameField as $}from"../stats/plotSpec.js";import{CLR as m,FONT as S,RADIUS as V,SPACE as b,controlStyle as K,wireControlHover as _,wireTooltip as se}from"./toolbar.js";import{makeListSelect as X,makeSegmented as N,makeToggle as re}from"./charts/chartShell.js";const Y="\0follow",z="\0none",ce=[["scatter","Scatter","One point per die or wafer, one value against another"],["histogram","Histogram","How often each value occurs"],["box","Box","Quartiles, with whiskers to the minimum and maximum, for each category"],["bar","Bar","One combined value for each category, or a count"],["line","Line","One combined value at each X, joined"]],A="\0auto",G="\0count",Q={mean:"Mean",median:"Median",min:"Minimum",max:"Maximum",sum:"Sum",count:"Count",yield:"Pooled yield (passing over judged dies)"};export function inputStyle(){return{background:m.menuBg,color:m.text,border:`1px solid ${m.menuBorder}`,borderRadius:V.control,padding:`${b.xs} ${b.sm}`,fontSize:S.body,fontFamily:S.family,boxSizing:"border-box",minWidth:"0"}}export function fieldRow(d,r,B,a){const p=d.createElement("div");Object.assign(p.style,{display:"flex",flexDirection:"column",gap:b.xxs,minWidth:"0"});const x=d.createElement("div");if(x.textContent=r,Object.assign(x.style,{fontSize:S.sub,color:m.label,fontWeight:"600"}),p.append(x,B),a){const T=d.createElement("div");T.textContent=a,Object.assign(T.style,{fontSize:S.sub,color:m.label}),p.appendChild(T)}return p}export function createPlotEditor(d){const{doc:r}=d,B=t=>t.fields?t:{...t,fields:{}};let a=B(d.plot),p="setup";const x=r.createElement("div");x.dataset.wmapPlotEditor="1",Object.assign(x.style,{display:"flex",flexDirection:"column",gap:b.lg,minWidth:"0"});const T=t=>{a=t,d.onChange(t)},y=t=>{const e=JSON.parse(JSON.stringify(a));t(e),T(e)},c=(t,e,i)=>fieldRow(r,t,e,i),D=t=>{const e=t&&d.catalogue.find(i=>$(i.field,t));return e?{label:e.name,level:e.level,kind:e.kind,yield:"builtin"in e.field&&e.field.builtin==="yield"}:void 0};function Z(t,e){const i=a.fields??{},n=i.color&&!("follow"in i.color)&&!("none"in i.color)?i.color:void 0,o={x:D(i.x),y:D(i.y),color:D(n)};o[t]=D(e.field);const l=a.chart==="scatter"&&o.color?.kind==="numeric"&&!!n&&!("meta"in n);return le(a.chart,o,{aggregate:a.aggregate,level:a.level,continuousColor:l})?.short}const I=t=>{const e=a.fields?.[t],i=e&&!("follow"in e)&&!("none"in e)?e:void 0;return q(d.catalogue,a.chart,t).map(n=>{const o=i&&$(n.field,i)?void 0:Z(t,n);return{value:k(n.field),label:n.label,group:n.group,...o?{disabled:o}:{}}})},H=t=>d.catalogue.find(e=>k(e.field)===t)?.field;function w(t,e,i={}){const n=a.fields[t],o=I(t);if(i.optional&&o.unshift({value:G,label:i.optional,group:"Count"}),n&&!o.some(u=>u.value===k(n))){const u=d.catalogue.some(C=>$(C.field,n)),h="test"in n?n.name??`Test ${n.test}`:"meta"in n?n.meta:n.builtin;o.unshift({value:k(n),label:`${h} (${u?"not usable here":"not in this lot"})`,group:"Saved"})}const l=n?k(n):i.optional?G:"",s=X(o,l,u=>{if(u===G){y(C=>{delete C.fields[t]});return}const h=H(u)??a.fields[t];h&&y(C=>{C.fields[t]=h})},{maxWidth:"100%",ownerDocument:r,ariaLabel:e,emptyText:"Choose a field\u2026",searchPlaceholder:"Filter fields\u2026",hook:`plot-${t}`});return s.style.width="100%",s}const P={},F={};function ee(t){y(e=>{e.chart=t;for(const i of["x","y"]){const n=q(d.catalogue,t,i),o=h=>!!h&&n.some(C=>$(C.field,h)),l=e.fields[i];if(l&&!o(l)&&($(l,F[i])||(P[i]=l),delete e.fields[i]),e.fields[i]||i==="y"&&t==="bar")continue;const s=P[i];if(o(s)){e.fields[i]=s,delete P[i],delete F[i];continue}const u=i==="x"&&(t==="box"||t==="bar")?{builtin:"wafer"}:i==="x"&&t==="line"?n.find(h=>h.group==="Wafer")?.field??n[0]?.field:n[0]?.field;u&&!(i==="x"&&t==="histogram")&&(e.fields[i]=u,F[i]=u)}}),O()}function te(){const t=!!a.fields.y&&"builtin"in a.fields.y&&a.fields.y.builtin==="yield",e=[{value:A,label:"Automatic"},...["mean","median","min","max","sum","count"].map(n=>({value:n,label:Q[n]}))];t&&e.push({value:"yield",label:Q.yield});const i=X(e,a.aggregate??A,n=>y(o=>{n===A?delete o.aggregate:o.aggregate=n}),{maxWidth:"100%",ownerDocument:r,ariaLabel:"Combine values by",hook:"plot-aggregate"});return i.style.width="100%",i}function ie(){const t=a.fields.color,e=d.followLabel(),i=[{value:Y,label:e?`Follow Group by (${e})`:"Follow Group by (single colour)",group:"Colour"},{value:z,label:"None",group:"Colour"},...I("color")],n=t===void 0||"follow"in t?Y:"none"in t?z:k(t),o=X(i,n,l=>{y(s=>{if(l===Y)delete s.fields.color;else if(l===z)s.fields.color={none:!0};else{const u=H(l);u&&(s.fields.color=u)}})},{maxWidth:"100%",ownerDocument:r,ariaLabel:"Colour",searchPlaceholder:"Filter fields\u2026",hook:"plot-color"});return o.style.width="100%",o}function J(t,e,i,n){const o=r.createElement("input");return o.type="text",o.value=t,o.placeholder=e,o.setAttribute("aria-label",i),Object.assign(o.style,inputStyle(),{width:"100%"}),o.addEventListener("input",()=>n(o.value)),o.addEventListener("keydown",l=>{l.key==="Escape"&&(l.stopPropagation(),o.blur())}),o}function W(t,e,i){const n=r.createElement("input");n.type="text",n.inputMode="decimal",n.value=t===void 0?"":String(t),n.placeholder="auto",n.setAttribute("aria-label",e),Object.assign(n.style,inputStyle(),{width:"100%",fontVariantNumeric:"tabular-nums"});const o=()=>{const l=n.value.trim();if(l===""){i(void 0);return}const s=Number(l);Number.isFinite(s)?i(s):n.value=t===void 0?"":String(t)};return n.addEventListener("change",o),n.addEventListener("keydown",l=>{l.key==="Enter"&&o(),l.key==="Escape"&&(l.stopPropagation(),n.value=t===void 0?"":String(t),n.blur())}),n}function U(t,e,i,n){const o=a.axes?.[t]??{},l=g=>y(f=>{f.axes=f.axes??{};const E=f.axes[t]=f.axes[t]??{};g(E);for(const j of Object.keys(E))(E[j]===void 0||E[j]===""||j==="reverse"&&E[j]===!1)&&delete E[j];Object.keys(E).length===0&&delete f.axes[t],Object.keys(f.axes).length===0&&delete f.axes}),s=r.createElement("div");Object.assign(s.style,{display:"flex",flexDirection:"column",gap:b.md,padding:b.lg,border:`1px solid ${m.menuBorder}`,borderRadius:V.control});const u=r.createElement("div");u.textContent=e,Object.assign(u.style,{fontSize:S.body,fontWeight:"600",color:m.value}),s.appendChild(u);const h=J(o.label??"",i??"",`${e} title`,g=>l(f=>{f.label=g.trim()===""?void 0:g}));if(h.dataset.wmapPlotAxisTitle=t,s.appendChild(c("Title",h)),n.limits===!1)return s;const C=r.createElement("div");return Object.assign(C.style,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:b.md}),C.append(c("Minimum",W(o.min,`${e} minimum`,g=>l(f=>{f.min=g}))),c("Maximum",W(o.max,`${e} maximum`,g=>l(f=>{f.max=g})))),s.appendChild(C),n.scale&&s.appendChild(c("Scale",N([["linear","Linear"],["log","Log"]],o.scale??"linear",g=>l(f=>{f.scale=g==="log"?"log":void 0}),r))),s.appendChild(re("Reverse direction",!!o.reverse,g=>l(f=>{f.reverse=g}),r)),s}const ne=t=>x.querySelector(`[role="tab"][data-tab="${t}"]`);let L,v;const R=new Map;function M(){if(!v)return;const t=oe(ae(a,d.catalogue));if(v.replaceChildren(),v.style.display=t?"flex":"none",!t)return;const e=r.createElement("span");e.textContent=t;const i=r.createElement("button");i.type="button",i.textContent="Use the automatic title",i.dataset.wmapPlotAutoTitle="1",Object.assign(i.style,K("outlined")),_(i),i.addEventListener("click",()=>{y(n=>{delete n.title}),O()}),v.append(e,i)}function O(){x.replaceChildren(),R.clear();const t=r.createElement("div");t.setAttribute("role","tablist"),Object.assign(t.style,{display:"flex",gap:b.sm,borderBottom:`1px solid ${m.menuBorder}`});for(const[i,n,o]of[["setup","Setup","Which fields to plot and how they are combined"],["customise","Customise","Titles, axis limits, scale and direction"]]){const l=r.createElement("button");l.type="button",l.textContent=n,se(l,o),l.setAttribute("role","tab"),l.dataset.tab=i,l.setAttribute("aria-selected",String(p===i)),Object.assign(l.style,{...K("bare"),padding:`${b.sm} ${b.lg}`,fontSize:S.body,borderBottom:`2px solid ${p===i?m.iconActive:"transparent"}`,borderRadius:"0",color:p===i?m.iconActive:m.text,fontWeight:p===i?"600":"400"}),_(l,"bare"),l.tabIndex=p===i?0:-1,l.addEventListener("click",()=>{p=i,O()}),l.addEventListener("keydown",s=>{s.key!=="ArrowLeft"&&s.key!=="ArrowRight"||(s.preventDefault(),p=i==="setup"?"customise":"setup",O(),ne(p)?.focus())}),t.appendChild(l)}x.appendChild(t);const e=r.createElement("div");if(e.setAttribute("role","tabpanel"),Object.assign(e.style,{display:"flex",flexDirection:"column",gap:b.lg}),p==="setup"){e.appendChild(c("Chart type",N(ce,a.chart,n=>ee(n),r,!0)));const i=a.level==="wafer"?"wafers":"dies";switch(a.chart){case"scatter":e.appendChild(c("X axis",w("x","X axis"))),e.appendChild(c("Y axis",w("y","Y axis")));break;case"histogram":e.appendChild(c("Values",w("y","Values")));break;case"box":e.appendChild(c("Categories (X axis)",w("x","Categories"),"Compare by this field: one box per value, whether it is a wafer attribute (lot, split) or a die region (ring, reticle cell).")),e.appendChild(c("Values (Y axis)",w("y","Values")));break;case"bar":e.appendChild(c("Categories (X axis)",w("x","Categories"),"Compare by this field: one bar per value, whether it is a wafer attribute (lot, split) or a die region (ring, reticle cell).")),e.appendChild(c("Values (Y axis)",w("y","Values",{optional:`Count of ${i}`})));break;case"line":e.appendChild(c("X axis",w("x","X axis"),"A line joins the value at each X.")),e.appendChild(c("Y axis",w("y","Y axis")));break}e.appendChild(c("Colour",ie(),"Compare by this field: each value gets its own colour. Follow Group by takes it from the Group by control.")),(a.chart==="bar"||a.chart==="line"||a.level==="wafer")&&e.appendChild(c("Combine values by",te())),e.appendChild(c("One mark per",N([[A,"Automatic"],["die","Die"],["wafer","Wafer"]],a.level??A,n=>{y(o=>{n===A?delete o.level:o.level=n}),O()},r,!0),a.level==="wafer"?"Die-level values are combined per wafer.":"Automatic uses the finest level the chosen fields allow."))}else{L=J(a.title??"",d.autoText().title,"Plot title",l=>{y(s=>{l.trim()===""?delete s.title:Object.assign(s,{title:l})}),M()}),L.dataset.wmapPlotTitle="1",v=r.createElement("div"),v.dataset.wmapPlotTitleDrift="1",Object.assign(v.style,{display:"none",flexDirection:"column",gap:b.sm,alignItems:"flex-start",padding:`${b.sm} ${b.md}`,background:m.warnBg,border:`1px solid ${m.warnBorder}`,borderRadius:V.control,color:m.warnText,fontSize:S.body}),e.appendChild(c("Title",L)),e.appendChild(v),M();const i=d.autoText(),n=a.chart==="box"||a.chart==="bar";e.appendChild(U("x",a.chart==="histogram"?"Values axis":n?"Categories axis":"X axis",i.x,{scale:!n,limits:!n})),e.appendChild(U("y",a.chart==="histogram"?"Count axis":n||a.chart==="line"?"Values axis":"Y axis",i.y,{scale:a.chart!=="histogram"})),a.chart==="histogram"&&e.appendChild(c("Bins",W(a.bins,"Number of bins",l=>y(s=>{l===void 0||!Number.isInteger(l)||l<1?delete s.bins:s.bins=Math.min(l,200)})),"Automatic is 16 equal bins."));const o=a.fields??{};(o.x&&"test"in o.x||o.y&&"test"in o.y)&&e.appendChild(c("Limits",N([["both","Test + spec"],["test","Test"],["spec","Spec"],["none","None"]],a.limits??"both",l=>y(s=>{l==="both"?delete s.limits:s.limits=l}),r),"Drawn as dashed lines on the axis of a test that has them: short dashes for test limits, long for spec limits."));for(const l of e.querySelectorAll("[data-wmap-plot-axis-title]"))R.set(l.dataset.wmapPlotAxisTitle,l)}x.appendChild(e)}return O(),{el:x,setPlot(t){const e=B(t);JSON.stringify(e)!==JSON.stringify(a)&&(a=e,O())},refreshAuto(){const t=d.autoText();L&&(L.placeholder=t.title),M();for(const[e,i]of R)i.placeholder=(e==="x"?t.x:t.y)??""}}}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Die } from '../core/dies.js';
|
|
2
2
|
import type { TestDef } from '../renderer/buildWaferMap.js';
|
|
3
|
+
import type { FacetCuration } from '../stats/facets.js';
|
|
3
4
|
import type { PlotStore } from './plotStore.js';
|
|
4
5
|
import type { InsightsItem } from './insightsTab.js';
|
|
5
6
|
import { type SaveImageHandler, type SaveTextHandler } from './toolbar.js';
|
|
6
7
|
export interface PlotSectionDeps {
|
|
8
|
+
/** The host's own wafer attributes: which are offered as fields, and what they are called. Over the defaults. */
|
|
9
|
+
attributes?: Record<string, FacetCuration>;
|
|
7
10
|
doc: Document;
|
|
8
11
|
store: PlotStore;
|
|
9
12
|
items: InsightsItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defaultPlot as Z,defaultSweep as ee,describeTitleDrift as te,examplePlots as oe,fieldCatalogue as ne,resolvePlot as se,titleDrift as
|
|
1
|
+
import{defaultPlot as Z,defaultSweep as ee,describeTitleDrift as te,examplePlots as oe,fieldCatalogue as ne,resolvePlot as se,titleDrift as re}from"../stats/plotData.js";import{addPlots as le,newPlotId as T,readPlotsFile as ae,writePlotsFile as ie}from"../stats/plotSpec.js";import{isYieldEligibleDie as ce}from"../core/dies.js";import{testValue as pe}from"../core/dieTable.js";import{sweepAppliesTo as de}from"../stats/sweep.js";import{plotToSweep as L}from"../stats/plotSpec.js";import{renderPlotChart as fe}from"./charts/plotChart.js";import{renderSweepPanel as ue}from"./charts/sweep.js";import{makeChartGridWrap as me}from"./charts/chartShell.js";import{confirmDialog as he}from"./confirmDialog.js";import{openDrilldownMenu as O}from"./drilldown.js";import{openPlotEditor as ge}from"./plotModal.js";import{sourceFromDies as ye,sourceFromPoints as we,toPlotItems as be}from"./plotItems.js";import{CLR as g,FONT as S,RADIUS as F,SPACE as u,controlStyle as xe,markNoPrint as E,saveTextFile as Pe,wireControlHover as ve,wireTooltip as De}from"./toolbar.js";const R=1e4;export function createPlotSection(r){const{doc:i,store:l}=r,c=be(r.items.map(e=>({label:e.identity??e.label,dies:e.dies,waferIndex:e.waferIndex,wafer:e.wafer,passBins:e.passBins,ringCount:r.ringCount}))),C={testDefs:r.testDefs,groupBy:r.groupBy,curation:r.attributes},U=e=>se(e,c,C),b=ne(c,C),m=i.createElement("div");m.dataset.wmapPlotTab="1",Object.assign(m.style,{display:"flex",flexDirection:"column",gap:u.lg,width:"100%"});const x=i.createElement("div");Object.assign(x.style,{display:"flex",flexWrap:"wrap",gap:u.md,alignItems:"center"});const d=(e,t,n,o)=>{const s=i.createElement("button");return s.type="button",s.textContent=e,s.dataset[t]="1",Object.assign(s.style,{...xe("outlined"),fontSize:S.body}),ve(s),De(s,n),s.addEventListener("click",o),s},P=d("Delete all plots\u2026","wmapPlotDeleteAll","Remove every plot and sweep. You are asked first, and Undo brings them back for ten seconds",()=>{V()});x.append(d("+ New plot","wmapPlotNew","Start a chart of your own: choose its type, what goes on each axis and how it is coloured",()=>z()),d("+ New sweep","wmapPlotNewSweep","Read an ordered run of tests as a response curve, and measure where two curves cross",()=>M()),d("Add examples","wmapPlotExamples","Draw one example of each chart type this lot can show, to edit or delete",()=>Y()),d("Import plots\u2026","wmapPlotImport","Add the plots from a file written by Export plots\u2026",()=>{Q()}),d("Export plots\u2026","wmapPlotExport","Save all your plots to a file, to share or to keep a copy",()=>X()),P),E(x),m.appendChild(x);const p=i.createElement("div");p.setAttribute("role","status"),Object.assign(p.style,{display:"none",flexWrap:"wrap",gap:u.md,alignItems:"center",padding:`${u.sm} ${u.md}`,background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:F.container,color:g.text,fontSize:S.body}),E(p),m.appendChild(p);let h;function y(e,t,n=[]){h!==void 0&&clearTimeout(h),p.replaceChildren();const o=i.createElement("span");if(o.textContent=e,p.appendChild(o),t){const s=d(t.label,"wmapPlotNoticeAction",t.label==="Undo"?"Put back what was just removed":t.label,()=>{t.run(),I()});p.appendChild(s)}for(const s of n){const a=i.createElement("div");a.textContent=s,Object.assign(a.style,{flexBasis:"100%",color:g.label}),p.appendChild(a)}p.style.display="flex",h=setTimeout(I,t?R:R*2)}function I(){h!==void 0&&(clearTimeout(h),h=void 0),p.style.display="none",p.replaceChildren()}const v=i.createElement("div");v.textContent="No plots yet. A plot is any measured value against another, or a distribution, that you choose: New plot starts one, and it is kept for the next lot. Add examples draws one of each chart type from this lot to start from.",Object.assign(v.style,{color:g.label,fontSize:S.body,padding:`${u.lg} 0`});const D=me(i);m.append(v,D);const w=new Map,A=()=>({onSaveImage:r.onSaveImage,onOpenWafer:r.openWafer?(e,t)=>r.openWafer(c[e].waferIndex??e,c[e].label,t):r.focusTest&&c.length===1?(e,t)=>{t!==void 0&&r.focusTest(t)}:void 0,openActionLabel:!r.openWafer&&r.focusTest&&c.length===1?"show this test on the map":void 0,onSelectPoints:(e,t,n)=>W(e,t,n)}),$=()=>({plots:l,onSaveImage:r.onSaveImage,onSaveText:r.onSaveText,onLocateDie:r.locateDie});function W(e,t,n){const o=we(e,c,r.testDefs);o&&O(t,n,o,$())}function k(e,t=!1){ge({doc:i,anchor:m,store:l,plot:e,draft:t,items:c,ctx:C,groupLabel:r.groupLabel,chart:A(),onSelectLevel:j})}function M(){const e=ee(r.testDefs,T());l.upsert(e),k(e)}function j(e,t){const n=s=>e.testNumbers.some(a=>{const f=pe(s,a);return f!==void 0&&Number.isFinite(f)}),o=ye(c,`measured at ${e.label}`,s=>ce(s)&&n(s),r.testDefs,e.testNumbers[0]);o&&O({x:t.clientX,y:t.clientY},t.target,o,$())}function z(){const e=Z(b,T());l.upsert(e),k(e)}function Y(){const e=o=>JSON.stringify([o.chart,o.fields,o.aggregate??null,o.sweep??null]),t=new Set(l.get().map(e)),n=oe(b,c.length,T).filter(o=>!t.has(e(o)));if(n.length===0){y(b.some(o=>o.group==="Tests")?"The examples for this lot are already in your plots.":"There are no measured values in this lot to draw examples from.");return}for(const o of n)l.upsert(o);y(`Added ${n.length} example plot${n.length===1?"":"s"}: ${n.map(o=>o.chart).join(", ")}. Edit one to make it yours, or Delete what you do not need.`)}function N(e,t){const n=(o,s,a,f)=>e.appendChild(d(o,s,a,f));n("Edit","wmapPlotEdit","Change this plot\u2019s type, fields, titles, limits and axes",()=>{const o=l.get().find(s=>s.id===t.id);o&&k(o)}),n("Duplicate","wmapPlotDuplicate","Make a copy of this plot to vary",()=>{l.duplicate(t.id)}),n("Delete","wmapPlotDelete","Remove this plot. Undo brings it back for ten seconds",()=>{const o=l.remove(t.id);o&&y(`Deleted \u201C${o.plot.title??"plot"}\u201D.`,{label:"Undo",run:()=>l.insertAt(o.index,o.plot)})})}function _(e){return e.chart==="sweep"?J(e):H(e)}function H(e){const t=fe({ownerDocument:i,waferLabel:s=>c[s]?.label??"",...A()});t.card.dataset.wmapPlotId=e.id,E(t.actions),N(t.actions,e);const n=i.createElement("div");n.dataset.wmapPlotTitleDrift="1",Object.assign(n.style,{display:"none",flexWrap:"wrap",gap:u.md,alignItems:"center",flexBasis:"100%",padding:`${u.xs} ${u.md}`,background:g.warnBg,border:`1px solid ${g.warnBorder}`,borderRadius:F.control,color:g.warnText,fontSize:S.body}),t.actions.appendChild(n);const o={card:t.card,actions:t.actions,json:"",driftNote:n,destroy:()=>t.destroy(),update:s=>{const a=U(s);t.setPlot(a),t.card.style.opacity=a.issues.length?"0.7":"1",G(n,s)}};return w.set(e.id,o),o}function J(e){const t=L(e),n=c.flatMap(a=>a.dies),o=ue({spec:t,dies:n,testDefs:r.testDefs,onSaveImage:r.onSaveImage,ownerDocument:i,onSelectPoint:j});o.card.dataset.wmapPlotId=e.id,o.card.dataset.wmapSweepPlot="1",E(o.actions),N(o.actions,e);const s={card:o.card,actions:o.actions,json:"",destroy:()=>o.destroy(),update:a=>{const f=L(a);o.setSpec(f),o.card.style.opacity=de(f,r.testDefs)?"1":"0.7"}};return w.set(e.id,s),s}function G(e,t){const n=te(re(t,b));if(e.replaceChildren(),e.style.display=n?"flex":"none",!n)return;const o=i.createElement("span");o.textContent=n,e.append(o,d("Use the automatic title","wmapPlotAutoTitle","Replace the title you typed with the one written from the plot\u2019s settings",()=>{const s=l.get().find(f=>f.id===t.id);if(!s)return;const a={...s};delete a.title,l.upsert(a)}))}function B(){const e=l.get();for(const[t,n]of w)e.some(o=>o.id===t)||(n.destroy(),n.card.remove(),w.delete(t));e.forEach((t,n)=>{const o=w.get(t.id)??_(t),s=JSON.stringify(t);o.json!==s&&(o.json=s,o.update(t)),D.children[n]!==o.card&&D.insertBefore(o.card,D.children[n]??null)}),v.style.display=e.length===0?"":"none",P.disabled=e.length===0,P.style.opacity=e.length===0?"0.5":"1",P.style.cursor=e.length===0?"default":"pointer"}const K=l.subscribe(B);B();async function V(){const e=l.get().slice();if(e.length===0)return;const t=e.length;if(!await he({doc:i,anchor:m,title:"Delete all plots",message:t===1?"Delete your 1 saved plot? It is kept on this computer for the next lot, so it will not be there for the next file either. Export plots\u2026 first to keep a copy.":`Delete all ${t} saved plots, sweeps included? They are kept on this computer for the next lot, so they will not be there for the next file either. Export plots\u2026 first to keep a copy.`,confirmLabel:t===1?"Delete 1 plot":`Delete ${t} plots`}))return;const o=l.get().slice();o.length!==0&&(l.replaceAll([]),y(`Deleted ${o.length===1?"1 plot":`all ${o.length} plots`}.`,{label:"Undo",run:()=>l.replaceAll(o)}))}function X(){const e=l.get();if(e.length===0){y("There are no plots to export yet.");return}Pe(ie(e),"wafermap-plots.json","application/json",r.onSaveText)}async function q(){return r.pickPlotsFile?r.pickPlotsFile():new Promise(e=>{const t=i.createElement("input");t.type="file",t.accept=".json,application/json",t.addEventListener("change",()=>{const n=t.files?.[0];if(!n){e(null);return}n.text().then(e,()=>e(null))}),t.addEventListener("cancel",()=>e(null)),t.click()})}async function Q(){const e=await q();if(e===null)return;const t=ae(e);if(t.error){y(`Could not import: ${t.error}`);return}const{plots:n,copies:o}=le(l.get(),t.plots);l.replaceAll(n);const s=[...t.warnings,...o.length?[`Kept as copies, since a plot with the same id already existed: ${o.join(", ")}`]:[]];y(`Imported ${t.plots.length} plot${t.plots.length===1?"":"s"}.`,void 0,s)}return{card:m,destroy:()=>{K(),h!==void 0&&clearTimeout(h);for(const e of w.values())e.destroy();w.clear(),l.flush()}}}
|
|
@@ -7,6 +7,7 @@ import type { RenderableWaferMap } from './renderWaferMap.js';
|
|
|
7
7
|
import type { LotStatsSummary } from '../stats/types.js';
|
|
8
8
|
import { type WarningsOptions } from './warnings.js';
|
|
9
9
|
import type { SummaryPanelOptions, FindingsNotice } from './summaryPanel.js';
|
|
10
|
+
import { type WaferAttributeDef } from '../stats/facets.js';
|
|
10
11
|
import type { InsightsOptions } from './insightsTab.js';
|
|
11
12
|
import type { DieListDisplayOptions } from './dieList.js';
|
|
12
13
|
/**
|
|
@@ -202,6 +203,13 @@ export interface GalleryOptions {
|
|
|
202
203
|
* recomputing it — no other host wiring beyond this option.
|
|
203
204
|
*/
|
|
204
205
|
insights?: InsightsOptions;
|
|
206
|
+
/**
|
|
207
|
+
* What the host calls its wafer attributes (lot, product, temperature, your own columns), over the defaults: a label, whether it
|
|
208
|
+
* is a Group by and Compare by choice (`facet: false` keeps a low-value field like a program revision out of those lists, while
|
|
209
|
+
* it still shows on the header strip, in the Wafers table and in reports), and whether it is a date (grouped by day). One entry
|
|
210
|
+
* per metadata key, so the strip, Group by, the plot fields, the Wafers table and the reports all name an attribute the same way.
|
|
211
|
+
*/
|
|
212
|
+
attributes?: Record<string, WaferAttributeDef>;
|
|
205
213
|
/**
|
|
206
214
|
* Built-in surfacing of the library's own data warnings (see `WarningsOptions`).
|
|
207
215
|
* Defaults on. The gallery collects across every item and de-duplicates, so a
|