@wafertools/wafermap 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +357 -0
  3. package/README.md +7 -7
  4. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
  6. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
  7. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
  8. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  9. package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
  10. package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
  11. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
  13. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
  14. package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
  15. package/dist/packages/canvas-adapter/charts/index.js +1 -1
  16. package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
  17. package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
  18. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
  19. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  20. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
  21. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  23. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  24. package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
  25. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  26. package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
  27. package/dist/packages/canvas-adapter/dieList.js +2 -2
  28. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
  29. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
  30. package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
  31. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  32. package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
  33. package/dist/packages/canvas-adapter/filterButton.js +1 -0
  34. package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
  35. package/dist/packages/canvas-adapter/filterEditor.js +1 -0
  36. package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
  37. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  38. package/dist/packages/canvas-adapter/icons.js +1 -1
  39. package/dist/packages/canvas-adapter/insightsTab.d.ts +50 -2
  40. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  41. package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
  42. package/dist/packages/canvas-adapter/pageFilter.js +2 -0
  43. package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
  44. package/dist/packages/canvas-adapter/patMaps.js +1 -0
  45. package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
  46. package/dist/packages/canvas-adapter/plotCard.js +1 -0
  47. package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
  48. package/dist/packages/canvas-adapter/plotEditor.js +1 -1
  49. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  50. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  51. package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
  52. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  53. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  54. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  55. package/dist/packages/canvas-adapter/summaryPanel.d.ts +15 -5
  56. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  57. package/dist/packages/canvas-adapter/toolbar.d.ts +12 -0
  58. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  59. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  60. package/dist/packages/canvas-adapter/userGuideHtml.js +598 -115
  61. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  62. package/dist/packages/canvas-adapter/version.js +1 -1
  63. package/dist/packages/core/classify.d.ts +11 -0
  64. package/dist/packages/core/classify.js +1 -1
  65. package/dist/packages/core/dies.d.ts +2 -0
  66. package/dist/packages/core/dies.js +1 -1
  67. package/dist/packages/core/wafer.d.ts +2 -2
  68. package/dist/packages/renderer/buildView.js +1 -1
  69. package/dist/packages/renderer/buildWaferMap.d.ts +2 -0
  70. package/dist/packages/renderer/buildWaferMap.js +1 -1
  71. package/dist/packages/renderer/deprecate.d.ts +2 -8
  72. package/dist/packages/renderer/deprecate.js +1 -1
  73. package/dist/packages/renderer/fmt.js +1 -1
  74. package/dist/packages/renderer/testLabel.d.ts +0 -11
  75. package/dist/packages/renderer/testLabel.js +1 -1
  76. package/dist/packages/stats/analyzeWaferLot.d.ts +6 -0
  77. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  78. package/dist/packages/stats/analyzeWaferMap.d.ts +8 -0
  79. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  80. package/dist/packages/stats/binPareto.d.ts +2 -54
  81. package/dist/packages/stats/binPareto.js +1 -1
  82. package/dist/packages/stats/binRows.js +1 -1
  83. package/dist/packages/stats/capability.d.ts +10 -0
  84. package/dist/packages/stats/capability.js +1 -1
  85. package/dist/packages/stats/cardSpec.d.ts +53 -0
  86. package/dist/packages/stats/cardSpec.js +1 -0
  87. package/dist/packages/stats/chartCatalogue.d.ts +37 -0
  88. package/dist/packages/stats/chartCatalogue.js +1 -0
  89. package/dist/packages/stats/clusterDetection.d.ts +9 -0
  90. package/dist/packages/stats/clusterDetection.js +1 -1
  91. package/dist/packages/stats/commonality.d.ts +62 -0
  92. package/dist/packages/stats/commonality.js +1 -0
  93. package/dist/packages/stats/control.d.ts +21 -0
  94. package/dist/packages/stats/control.js +1 -0
  95. package/dist/packages/stats/correlation.d.ts +9 -3
  96. package/dist/packages/stats/correlation.js +1 -1
  97. package/dist/packages/stats/dieRegions.d.ts +4 -1
  98. package/dist/packages/stats/dieRegions.js +1 -1
  99. package/dist/packages/stats/differenceMap.d.ts +22 -0
  100. package/dist/packages/stats/differenceMap.js +1 -0
  101. package/dist/packages/stats/examplePicks.d.ts +22 -0
  102. package/dist/packages/stats/examplePicks.js +1 -0
  103. package/dist/packages/stats/filterFile.d.ts +41 -0
  104. package/dist/packages/stats/filterFile.js +2 -0
  105. package/dist/packages/stats/filterFindings.d.ts +20 -5
  106. package/dist/packages/stats/filterFindings.js +1 -1
  107. package/dist/packages/stats/groupCompare.d.ts +87 -0
  108. package/dist/packages/stats/groupCompare.js +1 -0
  109. package/dist/packages/stats/guideSections.d.ts +55 -0
  110. package/dist/packages/stats/guideSections.js +1 -0
  111. package/dist/packages/stats/index.d.ts +3 -1
  112. package/dist/packages/stats/index.js +1 -1
  113. package/dist/packages/stats/math.d.ts +29 -4
  114. package/dist/packages/stats/math.js +1 -1
  115. package/dist/packages/stats/metadataColumns.d.ts +3 -0
  116. package/dist/packages/stats/metadataColumns.js +1 -1
  117. package/dist/packages/stats/pat.d.ts +58 -0
  118. package/dist/packages/stats/pat.js +1 -0
  119. package/dist/packages/stats/patSummary.d.ts +45 -0
  120. package/dist/packages/stats/patSummary.js +1 -0
  121. package/dist/packages/stats/patternClassification.d.ts +3 -3
  122. package/dist/packages/stats/patternClassification.js +1 -1
  123. package/dist/packages/stats/plotData.d.ts +294 -17
  124. package/dist/packages/stats/plotData.js +1 -1
  125. package/dist/packages/stats/plotId.d.ts +2 -0
  126. package/dist/packages/stats/plotId.js +1 -1
  127. package/dist/packages/stats/plotReferences.d.ts +17 -0
  128. package/dist/packages/stats/plotReferences.js +1 -0
  129. package/dist/packages/stats/plotSpec.d.ts +239 -3
  130. package/dist/packages/stats/plotSpec.js +4 -4
  131. package/dist/packages/stats/regions.js +1 -1
  132. package/dist/packages/stats/renderSummaryReport.js +31 -31
  133. package/dist/packages/stats/reportHtml.js +9 -13
  134. package/dist/packages/stats/synthesis.d.ts +44 -16
  135. package/dist/packages/stats/synthesis.js +1 -1
  136. package/dist/packages/stats/testPassRate.d.ts +7 -0
  137. package/dist/packages/stats/testPassRate.js +1 -1
  138. package/dist/packages/stats/types.d.ts +13 -8
  139. package/dist/packages/stats/yield.d.ts +3 -11
  140. package/dist/packages/stats/yield.js +1 -1
  141. package/llms.txt +1 -1
  142. package/package.json +2 -1
  143. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
  144. package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
  145. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
  146. package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
  147. package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
  148. package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
  149. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
  150. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
  151. package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
  152. package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
  153. package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
  154. package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
  155. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
  156. package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
  157. package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
  158. package/dist/packages/canvas-adapter/charts/trend.js +0 -1
@@ -62,6 +62,11 @@ export declare function buildTestPassRateData(groups: {
62
62
  * (`classifySpec`, `getTestPassStatus`), for picking out the failing dies a pass-rate row counts.
63
63
  */
64
64
  export declare function dieFailsTest(die: Die, def: TestDef, kind: TestPassKind): boolean | undefined;
65
+ /**
66
+ * `dieFailsTest`'s judgement with the side a die failed on: judged by test limits, `failLow` or `failHigh`; by a
67
+ * recorded verdict, `fail`. Undefined where the die cannot be judged.
68
+ */
69
+ export declare function dieTestVerdict(die: Die, def: TestDef, kind: TestPassKind): 'pass' | 'fail' | 'failLow' | 'failHigh' | undefined;
65
70
  /**
66
71
  * True when this `kind` has something to show — used to decide which modes the
67
72
  * chart's selector offers.
@@ -70,6 +75,8 @@ export declare function dieFailsTest(die: Die, def: TestDef, kind: TestPassKind)
70
75
  * every parametric test *could* have one, so a definition-only check would offer
71
76
  * a mode that renders empty on the (common) data that has none.
72
77
  */
78
+ /** The tests a pass rate under `kind` covers: parametric tests with limits, parametric tests, or functional tests. */
79
+ export declare function testsForPassKind(testDefs: readonly TestDef[] | undefined, kind: TestPassKind): TestDef[];
73
80
  export declare function hasJudgeableTests(testDefs: TestDef[] | undefined, kind: TestPassKind, dies?: Die[]): boolean;
74
81
  /**
75
82
  * Pool per-wafer functional-test results into one lot-level set.
@@ -1 +1 @@
1
- import{isYieldEligibleDie as H}from"../core/dies.js";import{dieHasVerdicts as M,testValue as V,testValuesReader as $}from"../core/dieTable.js";import{isParametricTest as P,getTestPassStatus as N,testPassStatusReader as C}from"../renderer/buildWaferMap.js";import{classifySpec as I}from"../renderer/spec.js";import{testLabel as x,derivedFields as O}from"../renderer/testLabel.js";const K=(e,t)=>t===0?null:e/t*100;export function buildTestPassRateData(e,t,r){const i=e.map(a=>a.key),s={groups:i,rows:[],disagreementDies:null};if(!t?.length)return s;const l=t.filter(a=>a.testNumber!==void 0&&_(a,r));if(!l.length)return s;const p=()=>({pass:0,fail:0,failLow:0,failHigh:0}),u=new Map;for(const a of l){const c=a.testNumber;u.set(c,{label:x(a,c),overall:p(),perGroup:i.map(()=>p())})}const w=(a,c,b)=>{const d=u.get(a);if(d)for(const m of[d.overall,d.perGroup[c]])m.pass+=b.pass??0,m.fail+=b.fail??0,m.failLow+=b.failLow??0,m.failHigh+=b.failHigh??0},n=r==="spec"||r==="testFlag";let o=0,g=0;e.forEach(function(c,b){for(const d of c.items){if(r==="spec"&&d.testSpecYield&&!j(d)){for(const f of d.testSpecYield)w(f.testNumber,b,{pass:f.passDies,fail:f.failLowDies+f.failHighDies,failLow:f.failLowDies,failHigh:f.failHighDies});continue}if(r==="functional"&&d.functionalYield){for(const f of d.functionalYield)w(f.testNumber,b,{pass:f.passDies,fail:f.failDies});continue}const m=B(d.dies??[],l,r);o+=m.comparable,g+=m.disagreements;for(let f=0;f<l.length;f++){const A=u.get(l[f].testNumber);for(const L of[A.overall,A.perGroup[b]])L.pass+=m.pass[f],L.fail+=m.fail[f],L.failLow+=m.failLow[f],L.failHigh+=m.failHigh[f]}}});const h=a=>({passDies:a.pass,failDies:a.fail,totalDies:a.pass+a.fail,passRatePercent:K(a.pass,a.pass+a.fail)}),D=[];for(const[a,c]of u)c.overall.pass+c.overall.fail!==0&&D.push({testNumber:a,label:c.label,overall:h(c.overall),byGroup:c.perGroup.map(h),...r==="spec"?{failLowDies:c.overall.failLow,failHighDies:c.overall.failHigh}:{}});return D.sort((a,c)=>(a.overall.passRatePercent??101)-(c.overall.passRatePercent??101)||a.testNumber-c.testNumber),{groups:i,rows:D,disagreementDies:n&&o>0?g:null}}const S=0,v=1,y=2,F=3,T=4,G=5,E=6,z=7,R=new WeakMap,Y=e=>`${e.testNumber},${e.limitLow},${e.limitHigh},${e.limitLowInclusive},${e.limitHighInclusive},${e.testType}`;function B(e,t,r){let i=R.get(e);i||(i=new Map,R.set(e,i));const s=t.map(Y),l=t.filter((n,o)=>!i.has(s[o]));l.length&&J(e,l,i);const p=t.length,u={pass:new Int32Array(p),fail:new Int32Array(p),failLow:new Int32Array(p),failHigh:new Int32Array(p),comparable:0,disagreements:0},w=r==="spec"||r==="testFlag";for(let n=0;n<p;n++){const o=i.get(s[n]);w&&(u.comparable+=o[G],u.disagreements+=o[E]),r==="spec"?(u.pass[n]=o[S],u.failLow[n]=o[v],u.failHigh[n]=o[y],u.fail[n]=o[v]+o[y]):(u.pass[n]=o[F],u.fail[n]=o[T])}return u}function J(e,t,r){const i=t.length,s=t.map(()=>new Int32Array(z)),l=$(t.map(n=>n.testNumber)),p=new Float64Array(i),u=C(t),w=new Int8Array(i);for(const n of e)if(H(n)){l(n,p),u(n,w);for(let o=0;o<i;o++){const g=s[o],h=I(p[o],t[o]),D=w[o];h!==null&&(h==="pass"?g[S]++:h==="failLow"?g[v]++:g[y]++),D!==-1&&(D===1?g[F]++:g[T]++,h!==null&&(g[G]++,h==="pass"!=(D===1)&&g[E]++))}}for(let n=0;n<i;n++)r.set(Y(t[n]),s[n])}export function dieFailsTest(e,t,r){const i=t.testNumber;if(i===void 0||!H(e))return;if(r==="spec"){const l=V(e,i),p=l===void 0?null:I(l,t);return p===null?void 0:p!=="pass"}const s=N(e,i,t);return s===void 0?void 0:!s}function j(e){return(e.dies??[]).some(M)}function _(e,t){return t==="functional"?!P(e):P(e)?t==="spec"?e.limitLow!==void 0||e.limitHigh!==void 0:!0:!1}export function hasJudgeableTests(e,t,r){if(!e?.length)return!1;const i=e.filter(s=>s.testNumber!==void 0&&_(s,t));return i.length?t!=="testFlag"?!0:(r??[]).some(s=>i.some(l=>N(s,l.testNumber,l)!==void 0)):!1}export function poolFunctionalYield(e){if(!e?.length||!e.every(i=>i.stats.functionalYield!==void 0))return;const t=new Map;for(const i of e)for(const s of i.stats.functionalYield??[]){const l=t.get(s.testNumber)??{label:s.label,...O(s),passDies:0,failDies:0,totalDies:0};l.passDies+=s.passDies,l.failDies+=s.failDies,l.totalDies+=s.totalDies,t.set(s.testNumber,l)}const r=[...t.entries()].map(([i,s])=>({testNumber:i,...s,passRatePercent:s.totalDies>0?s.passDies/s.totalDies*100:null}));return r.length?r:void 0}
1
+ import{isYieldEligibleDie as P}from"../core/dies.js";import{dieHasVerdicts as V,testValue as x,testValuesReader as M}from"../core/dieTable.js";import{isParametricTest as N,getTestPassStatus as I,testPassStatusReader as $}from"../renderer/buildWaferMap.js";import{classifySpec as S}from"../renderer/spec.js";import{testLabel as C,derivedFields as O}from"../renderer/testLabel.js";const K=(e,t)=>t===0?null:e/t*100;export function buildTestPassRateData(e,t,n){const s=e.map(o=>o.key),i={groups:s,rows:[],disagreementDies:null};if(!t?.length)return i;const l=t.filter(o=>o.testNumber!==void 0&&A(o,n));if(!l.length)return i;const p=()=>({pass:0,fail:0,failLow:0,failHigh:0}),u=new Map;for(const o of l){const c=o.testNumber;u.set(c,{label:C(o,c),overall:p(),perGroup:s.map(()=>p())})}const w=(o,c,b)=>{const d=u.get(o);if(d)for(const m of[d.overall,d.perGroup[c]])m.pass+=b.pass??0,m.fail+=b.fail??0,m.failLow+=b.failLow??0,m.failHigh+=b.failHigh??0},a=n==="spec"||n==="testFlag";let r=0,g=0;e.forEach(function(c,b){for(const d of c.items){if(n==="spec"&&d.testSpecYield&&!j(d)){for(const f of d.testSpecYield)w(f.testNumber,b,{pass:f.passDies,fail:f.failLowDies+f.failHighDies,failLow:f.failLowDies,failHigh:f.failHighDies});continue}if(n==="functional"&&d.functionalYield){for(const f of d.functionalYield)w(f.testNumber,b,{pass:f.passDies,fail:f.failDies});continue}const m=B(d.dies??[],l,n);r+=m.comparable,g+=m.disagreements;for(let f=0;f<l.length;f++){const H=u.get(l[f].testNumber);for(const L of[H.overall,H.perGroup[b]])L.pass+=m.pass[f],L.fail+=m.fail[f],L.failLow+=m.failLow[f],L.failHigh+=m.failHigh[f]}}});const h=o=>({passDies:o.pass,failDies:o.fail,totalDies:o.pass+o.fail,passRatePercent:K(o.pass,o.pass+o.fail)}),D=[];for(const[o,c]of u)c.overall.pass+c.overall.fail!==0&&D.push({testNumber:o,label:c.label,overall:h(c.overall),byGroup:c.perGroup.map(h),...n==="spec"?{failLowDies:c.overall.failLow,failHighDies:c.overall.failHigh}:{}});return D.sort((o,c)=>(o.overall.passRatePercent??101)-(c.overall.passRatePercent??101)||o.testNumber-c.testNumber),{groups:s,rows:D,disagreementDies:a&&r>0?g:null}}const F=0,v=1,y=2,T=3,G=4,E=5,R=6,z=7,Y=new WeakMap,_=e=>`${e.testNumber},${e.limitLow},${e.limitHigh},${e.limitLowInclusive},${e.limitHighInclusive},${e.testType}`;function B(e,t,n){let s=Y.get(e);s||(s=new Map,Y.set(e,s));const i=t.map(_),l=t.filter((a,r)=>!s.has(i[r]));l.length&&J(e,l,s);const p=t.length,u={pass:new Int32Array(p),fail:new Int32Array(p),failLow:new Int32Array(p),failHigh:new Int32Array(p),comparable:0,disagreements:0},w=n==="spec"||n==="testFlag";for(let a=0;a<p;a++){const r=s.get(i[a]);w&&(u.comparable+=r[E],u.disagreements+=r[R]),n==="spec"?(u.pass[a]=r[F],u.failLow[a]=r[v],u.failHigh[a]=r[y],u.fail[a]=r[v]+r[y]):(u.pass[a]=r[T],u.fail[a]=r[G])}return u}function J(e,t,n){const s=t.length,i=t.map(()=>new Int32Array(z)),l=M(t.map(a=>a.testNumber)),p=new Float64Array(s),u=$(t),w=new Int8Array(s);for(const a of e)if(P(a)){l(a,p),u(a,w);for(let r=0;r<s;r++){const g=i[r],h=S(p[r],t[r]),D=w[r];h!==null&&(h==="pass"?g[F]++:h==="failLow"?g[v]++:g[y]++),D!==-1&&(D===1?g[T]++:g[G]++,h!==null&&(g[E]++,h==="pass"!=(D===1)&&g[R]++))}}for(let a=0;a<s;a++)n.set(_(t[a]),i[a])}export function dieFailsTest(e,t,n){const s=dieTestVerdict(e,t,n);return s===void 0?void 0:s!=="pass"}export function dieTestVerdict(e,t,n){const s=t.testNumber;if(s===void 0||!P(e))return;if(n==="spec"){const l=x(e,s),p=l===void 0?null:S(l,t);return p===null?void 0:p}const i=I(e,s,t);return i===void 0?void 0:i?"pass":"fail"}function j(e){return(e.dies??[]).some(V)}function A(e,t){return t==="functional"?!N(e):N(e)?t==="spec"?e.limitLow!==void 0||e.limitHigh!==void 0:!0:!1}export function testsForPassKind(e,t){return(e??[]).filter(n=>n.testNumber!==void 0&&A(n,t))}export function hasJudgeableTests(e,t,n){if(!e?.length)return!1;const s=e.filter(i=>i.testNumber!==void 0&&A(i,t));return s.length?t!=="testFlag"?!0:(n??[]).some(i=>s.some(l=>I(i,l.testNumber,l)!==void 0)):!1}export function poolFunctionalYield(e){if(!e?.length||!e.every(s=>s.stats.functionalYield!==void 0))return;const t=new Map;for(const s of e)for(const i of s.stats.functionalYield??[]){const l=t.get(i.testNumber)??{label:i.label,...O(i),passDies:0,failDies:0,totalDies:0};l.passDies+=i.passDies,l.failDies+=i.failDies,l.totalDies+=i.totalDies,t.set(i.testNumber,l)}const n=[...t.entries()].map(([s,i])=>({testNumber:s,...i,passRatePercent:i.totalDies>0?i.passDies/i.totalDies*100:null}));return n.length?n:void 0}
@@ -170,10 +170,13 @@ export interface StatsFinding {
170
170
  */
171
171
  highlight: HighlightTarget;
172
172
  /**
173
- * IDs of other findings that describe the same signal at a finer level of
174
- * detail. Note these do NOT all resolve to entries in `findings`: when a run
175
- * of per-region findings is merged into one (e.g. `Rings 3–4`), this is the
176
- * audit trail of the constituents it REPLACED, and those no longer exist.
173
+ * IDs of other findings that describe the same signal, which reading surfaces
174
+ * show under this one: on a spatial pattern, the ring, quadrant, sector, arc
175
+ * and cluster findings it explains; on a cluster of one hard bin, the rises in
176
+ * that bin in a ring, quadrant or sector that the cluster makes up. Note these
177
+ * do NOT all resolve to entries in `findings`: when a run of per-region
178
+ * findings is merged into one (e.g. `Rings 3–4`), this is the audit trail of
179
+ * the constituents it REPLACED, and those no longer exist.
177
180
  */
178
181
  relatedIds?: string[];
179
182
  /**
@@ -246,13 +249,15 @@ export interface StatsSummary {
246
249
  softBinsConsidered: number[];
247
250
  /**
248
251
  * Die counts per hard/soft bin, keyed by bin code, over the same
249
- * yield-eligible population `YieldSummary`/`buildBinParetoData` use
252
+ * yield-eligible population `YieldSummary` and the Insights bin pareto use
250
253
  * (`isYieldEligibleDie` — excludes `partial`/`edgeExcluded` dies).
251
254
  * Unlike `hardBinsConsidered`/`softBinsConsidered` (which list every bin
252
255
  * code that appears anywhere, eligible or not), these are the actual
253
256
  * counts a bin-breakdown display should show. Consumed by
254
- * `buildBinParetoData`/`buildBinClusterData` and the summary panel's bin
257
+ * the Insights bin pareto and the summary panel's bin
255
258
  * section when supplied, instead of each independently re-walking dies.
259
+ * Absent on a value stack (any `lotStack` method but `'mode'`), whose dies
260
+ * carry one wafer's bins rather than the stack's.
256
261
  */
257
262
  hardBinCounts?: Record<number, number>;
258
263
  softBinCounts?: Record<number, number>;
@@ -300,8 +305,8 @@ export interface StatsSummary {
300
305
  * `testSpecYield` counts in `failLowDies + failHighDies`), failing for a functional test
301
306
  * (`functionalYield`'s `failDies`). `dieKeys` are `getDieKey` strings; `lostDies` is how many of
302
307
  * them also fail the wafer's yield (not in a pass bin, or with no bin to judge by), so a test's
303
- * failures on dies binned as passing are told apart from the yield it costs. Only tests with a
304
- * failing die are present.
308
+ * failures on dies binned as passing are told apart from the yield it costs. On a value stack,
309
+ * which has no yield, every failing die counts. Only tests with a failing die are present.
305
310
  */
306
311
  testFailures?: Record<number, {
307
312
  dieKeys: string[];
@@ -52,17 +52,9 @@ export declare function yieldCounts(dies: readonly Die[], passBins: readonly num
52
52
  /** One bar per item. */
53
53
  export declare function buildYieldData(items: YieldItem[], sortBy?: YieldSortBy): ChartDatum[];
54
54
  /**
55
- * Combined yield: one bar per group, pooling the group's items. The pooled
56
- * yield is the yield-eligible-die-count-weighted mean of per-item yields —
57
- * exact for the standard pass/total definition (Σ pass / Σ total =
58
- * Σ(yield·dies)/Σ dies), *provided* `dies` is the same population the rate
59
- * was computed over. Weighting uses `yieldEligibleDieCount` (excludes
60
- * partial/edge-excluded dies), not raw `dies.length` — a per-item
61
- * `yieldPercent` (own or precomputed, e.g. from `analyzeWaferLot`) already
62
- * excludes those dies from its own numerator/denominator (`resolveYieldPercent`
63
- * → `isYieldEligibleDie`), so weighting by the raw count would let a wafer's
64
- * excluded dies (which count toward yield nowhere else) still skew this
65
- * combined bar.
55
+ * Combined yield: one row per group, pooling the group's items: each item's yield weighted by its judged dies
56
+ * (`yieldJudgedCount`), which is exactly Σ pass / Σ judged over the group, the rule the plot builder pools by. A die
57
+ * with no bin, or a partial or edge-excluded one, weighs nothing, as it counts toward no yield.
66
58
  */
67
59
  export declare function buildYieldDataCombined(groups: {
68
60
  key: string;
@@ -1 +1 @@
1
- import{requirePassBins as f}from"../core/passBins.js";import{isYieldEligibleDie as a,diePassStatus as p}from"../core/dies.js";import{compareNatural as b}from"../core/utils.js";export function yieldCounts(e,i){let n=0,t=0;const r=new Set(i);for(const o of e){if(!a(o))continue;const l=p(o,r);l!==void 0&&(t++,l&&n++)}return{pass:n,total:t}}function m(e,i){const{pass:n,total:t}=yieldCounts(e,i);return t>0?n/t*100:0}function c(e){return e.yieldPercent!==void 0?e.yieldPercent??0:m(e.dies??[],f(e,"yield"))}function y(e){let i=0;for(const n of e)a(n)&&i++;return i}function d(e,i){i==="yield"?e.sort((n,t)=>t.value-n.value):e.sort((n,t)=>b(n.label,t.label))}export function buildYieldData(e,i="label"){const n=e.map((t,r)=>{const o=c(t);return{label:t.label??`#${r}`,value:o,percent:o,itemCount:1,key:t.key}});return d(n,i),n}export function buildYieldDataCombined(e,i="label"){const n=e.map(t=>{let r=0,o=0;for(const s of t.items){const u=y(s.dies??[]);r+=c(s)*u,o+=u}const l=o>0?r/o:0;return{label:t.key,value:l,percent:l,itemCount:t.items.length}});return d(n,i),n}
1
+ import{requirePassBins as a}from"../core/passBins.js";import{isYieldEligibleDie as f,diePassStatus as p}from"../core/dies.js";import{compareNatural as m}from"../core/utils.js";export function yieldCounts(e,i){let n=0,t=0;const r=new Set(i);for(const o of e){if(!f(o))continue;const l=p(o,r);l!==void 0&&(t++,l&&n++)}return{pass:n,total:t}}function b(e,i){const{pass:n,total:t}=yieldCounts(e,i);return t>0?n/t*100:0}function d(e){return e.yieldPercent!==void 0?e.yieldPercent??0:b(e.dies??[],a(e,"yield"))}function y(e,i){return yieldCounts(e,i).total}function c(e,i){i==="yield"?e.sort((n,t)=>t.value-n.value):e.sort((n,t)=>m(n.label,t.label))}export function buildYieldData(e,i="label"){const n=e.map((t,r)=>{const o=d(t);return{label:t.label??`#${r}`,value:o,percent:o,itemCount:1,key:t.key}});return c(n,i),n}export function buildYieldDataCombined(e,i="label"){const n=e.map(t=>{let r=0,o=0;for(const s of t.items){const u=y(s.dies??[],a(s,"yield"));r+=d(s)*u,o+=u}const l=o>0?r/o:0;return{label:t.key,value:l,percent:l,itemCount:t.items.length}});return c(n,i),n}
package/llms.txt CHANGED
@@ -32,7 +32,7 @@ where repo-relative paths do not resolve.
32
32
  - [Package surface and types](https://wafertools.github.io/wafermap/api/reference/) - exports, helpers, types, limitations.
33
33
  - [Quick start](https://wafertools.github.io/wafermap/quickstart/) - install and first map.
34
34
  - [Troubleshooting](https://wafertools.github.io/wafermap/troubleshooting/) - common failure modes.
35
- - [Examples](https://wafertools.github.io/wafermap/examples/) - 25 runnable demo pages, also downloadable at https://wafertools.github.io/wafermap/wafermap-examples.zip to run offline.
35
+ - [Examples](https://wafertools.github.io/wafermap/examples/) - 27 runnable demo pages, also downloadable at https://wafertools.github.io/wafermap/wafermap-examples.zip to run offline.
36
36
 
37
37
  ## Public package entry points
38
38
  - `@wafertools/wafermap` - `buildWaferMap()`, geometry, colour-scheme registries. Pure, no DOM.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wafertools/wafermap",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "Interactive wafer map visualization and yield analysis for semiconductor test data. Hard bins, soft bins, test values, retests, edge exclusion, reticle overlays, spatial statistics, failure clustering, and lot-level trend analysis — pure ES modules, no runtime dependencies, no server required.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -77,6 +77,7 @@
77
77
  "clean": "rm -rf dist",
78
78
  "check": "node scripts/build-user-guide.mjs && node scripts/sync-version.mjs && tsc --noEmit -p tsconfig.json && node scripts/check-examples-manifest.mjs && node scripts/build-agents-page.mjs --check && node scripts/check-agents-guide.mjs && node scripts/check-toolbar-docs.mjs && node scripts/check-doc-links.mjs && node scripts/check-quickstart-snippet.mjs && node scripts/check-overlay-conventions.mjs && node scripts/check-changelog.mjs && node scripts/help.mjs --check && node scripts/check-api-claims.mjs && node scripts/check-style-scales.mjs packages/canvas-adapter && node scripts/check-spread-limits.mjs && node scripts/check-pass-bin-defaults.mjs && node scripts/check-clones.mjs packages",
79
79
  "build:examples-index": "node scripts/build-examples-index.mjs",
80
+ "build:chart-index": "node scripts/build-chart-index.mjs",
80
81
  "check:drift": "node scripts/check-drift.mjs",
81
82
  "dev": "rm -rf docs/dist && cp -r dist docs/dist && ./.venv/bin/zensical serve --dev-addr localhost:8001",
82
83
  "test": "npm run build && node scripts/check-bundle-size.mjs && node --test tests/*.test.mjs",
@@ -1,83 +0,0 @@
1
- import type { ChartDatum } from '../../stats/yield.js';
2
- import { type SaveImageHandler, type WaferContextMenuHandler } from './chartShell.js';
3
- export interface ChartPanel {
4
- title: string;
5
- data: ChartDatum[];
6
- barColor?: (datum: ChartDatum, index: number) => string;
7
- valueLabel?: (datum: ChartDatum) => string;
8
- /**
9
- * Optional self-contained segmented control (yield sort, hard/soft bins).
10
- * When present the panel renders a radio group and, on change, recomputes
11
- * its own data and redraws in place.
12
- */
13
- selfControl?: {
14
- current: string;
15
- options: Array<[value: string, label: string, hint?: string]>;
16
- onChange: (value: string) => {
17
- data: ChartDatum[];
18
- title?: string;
19
- };
20
- };
21
- /**
22
- * In-place drill-down for a grouped row (`itemCount > 1`). When present,
23
- * clicking such a row calls `onOpenGroup`, which returns the detail
24
- * data/title to redraw in place (no modal, no grid rebuild) and shows a
25
- * Back button; clicking it calls `onBack`, which returns the overview
26
- * data/title.
27
- */
28
- drill?: {
29
- onOpenGroup: (datum: ChartDatum) => {
30
- data: ChartDatum[];
31
- title: string;
32
- };
33
- onBack: () => {
34
- data: ChartDatum[];
35
- title: string;
36
- };
37
- groupLabelText: string;
38
- };
39
- /**
40
- * Vertical rule drawn across the plot at `value`, with `label` printed at the
41
- * top — a population reference the bars are read against.
42
- *
43
- * The yield chart needs it: without a reference, "is W07 bad?" has no visual
44
- * answer on the chart itself, only by reading every printed percentage. The
45
- * docked Summary panel's own per-wafer yield bars already mark the lot median,
46
- * and this is the larger, more prominent view of that same data.
47
- *
48
- * Called on every draw, so a drilled-into group gets its own reference rather
49
- * than the overall one.
50
- */
51
- reference?: (data: ChartDatum[]) => {
52
- value: number;
53
- label: string;
54
- } | null;
55
- /**
56
- * Clicking a leaf row (`itemCount === 1` — a single wafer, whether reached
57
- * directly or by drilling into a group first) calls this to open that
58
- * wafer's map. A group row (`itemCount > 1`, drill not yet active) drills
59
- * instead, via `drill.onOpenGroup` — this is never called for those.
60
- */
61
- onOpen?: (datum: ChartDatum) => void;
62
- /**
63
- * Clicking a bar picks out the dies it counts (a bin's dies, in the bin pareto): called with the bar and the click, so
64
- * the host can open a menu there. Takes the place of `onOpen` for panels whose bars are not wafers. `selectLabel` is
65
- * what the click does, in the reader's words ("chart or tabulate these dies").
66
- */
67
- onSelectBar?: (datum: ChartDatum, e: MouseEvent) => void;
68
- selectLabel?: string;
69
- /** Right-click on a leaf row that carries a wafer (`datum.key`) — see
70
- * `WaferContextMenuHandler`. Not called for a group row. */
71
- onWaferContextMenu?: WaferContextMenuHandler;
72
- /** Document to build this panel's DOM into. Default `document` — pass the
73
- * host's own `ownerDocument` when the container might live in a
74
- * different document (e.g. a gallery card detached into its own popup
75
- * window). */
76
- ownerDocument?: Document;
77
- }
78
- export interface BarPanelHandle {
79
- card: HTMLElement;
80
- destroy: () => void;
81
- }
82
- export declare function renderBarPanel(panel: ChartPanel, onSaveImage?: SaveImageHandler): BarPanelHandle;
83
- //# sourceMappingURL=barPanel.d.ts.map
@@ -1 +0,0 @@
1
- import{SPACE as nt,fontPx as ot,FONT as lt,CLR as it}from"../toolbar.js";import{cardShell as rt,formatValue as st,observeResize as ct,makeTooltip as at,positionChartTooltip as ft,makeBackButton as ut,makeSegmented as dt,fitRowsHeight as ht,setChartGrow as mt,resolveChartCanvasColors as xt,PADDING as u,VALUE_WIDTH as j,WAFER_MENU_HINT as bt,prepareCanvas as pt}from"./chartShell.js";import{escHtml as D}from"../../core/utils.js";const d=24,m=5,yt=15,z=110,gt=12;export function renderBarPanel(l,U){const{barColor:G,valueLabel:I}=l;let y=l.title,i=l.data;const{card:r,heading:E,controlsRow:P,body:A}=rt(y,U,l.ownerDocument);if(mt(r,"rows"),l.selfControl){const e=l.selfControl;P.appendChild(dt(e.options,e.current,n=>q(n),r.ownerDocument))}const{drill:f}=l;let g=!1,W=null;const H=r.ownerDocument.createElement("div");H.dataset.wmapCaption="1",Object.assign(H.style,{color:it.label,fontSize:lt.body,marginBottom:nt.sm}),r.insertBefore(H,A);function $(){const e=[];l.onOpen&&e.push("click to open this wafer"),l.onSelectBar&&e.push(`click a bar to ${l.selectLabel??"see what it counts"}`),f&&!g&&e.push(`click a ${f.groupLabelText} to see it by wafer`);const n=e.join(", or ");let o=n?`${n[0].toUpperCase()}${n.slice(1)}.`:"";const t=l.reference?.(i);t&&(o=o?`${o} Dashed line: ${t.label}.`:`Dashed line: ${t.label}.`),H.textContent=o}$();const k=r.ownerDocument.createElement("div"),w=()=>l.reference?yt:0,Y=()=>u*2+w()+Math.min(i.length,gt)*(d+m);Object.assign(k.style,{overflowX:"hidden",overflowY:"auto",minHeight:"0",flex:"1",maxHeight:`${Y()}px`,scrollbarGutter:"stable"}),A.appendChild(k);const s=r.ownerDocument.createElement("canvas");s.style.display="block",s.style.cursor="default",k.appendChild(s);const C=at(r);let x=-1,M=Math.max(1,...i.map(e=>e.value));const N=e=>I?I(e):`${st(e.value)} (${e.percent.toFixed(1)}%)`;function F(e){const n=u+w()+e*(d+m),o=u+z,t=s.clientWidth-o-j-u;return{y:n,barX:o,barMaxWidth:Math.max(10,t)}}function v(){const e=u*2+w()+i.length*(d+m);k.style.maxHeight=`${ht(r,A,Y(),e)}px`;const n=k.clientWidth,o=pt(s,r,n,e);if(!o)return;const{ctx:t}=o;t.font=`${ot(-1)}px system-ui, sans-serif`,t.textBaseline="middle";const c=xt(r);i.forEach((a,p)=>{const{y:h,barX:B,barMaxWidth:S}=F(p);p===x&&(t.fillStyle=c.bgHover,t.fillRect(0,h-m/2,n,d+m)),t.fillStyle=c.text,t.textAlign="right";const R=a.label.length>16?`${a.label.slice(0,15)}\u2026`:a.label;t.fillText(R,u+z-8,h+d/2),t.fillStyle=c.track,t.fillRect(B,h,S,d);const L=Math.max(1,a.value/M*S);t.fillStyle=G?G(a,p):c.text,t.fillRect(B,h,L,d),t.fillStyle=c.text,t.textAlign="right",t.fillText(N(a),B+S+j,h+d/2)});const b=l.reference?.(i);if(b&&i.length){const{barX:a,barMaxWidth:p}=F(0),h=Math.round(a+Math.max(0,Math.min(1,b.value/M))*p)+.5,B=u+w()-3,S=u+w()+i.length*(d+m)-m,R=(Z,tt,et)=>{t.save(),t.strokeStyle=Z,t.lineWidth=tt,t.setLineDash(et),t.beginPath(),t.moveTo(h,B),t.lineTo(h,S),t.stroke(),t.restore()};R(c.bg,3.5,[]),R(c.text,1.5,[4,3]),t.save(),t.font="600 10px system-ui, sans-serif",t.textBaseline="middle",t.textAlign="left";const L=4,_=t.measureText(b.label).width+L*2,X=13,V=u+w()-X-1;let T=h-_/2;T=Math.max(a,Math.min(T,a+p-_)),t.fillStyle=c.bg,t.strokeStyle=c.border,t.lineWidth=1,t.beginPath(),t.rect(T,V,_,X),t.fill(),t.stroke(),t.fillStyle=c.text,t.fillText(b.label,T+L,V+X/2+.5),t.restore()}}function q(e){if(!l.selfControl)return;l.selfControl.current=e;const n=l.selfControl.onChange(e);i=n.data,M=Math.max(1,...i.map(o=>o.value)),x=-1,n.title&&(y=n.title,E.textContent=y),$(),v()}function J(e){if(!f)return;const n=f.onOpenGroup(e);i=n.data,y=n.title,E.textContent=y,M=Math.max(1,...i.map(o=>o.value)),x=-1,g||(g=!0,W=ut(()=>K(),r.ownerDocument),P.appendChild(W)),$(),v()}function K(){if(!f)return;const e=f.onBack();i=e.data,y=e.title,E.textContent=y,M=Math.max(1,...i.map(n=>n.value)),x=-1,g=!1,W?.remove(),W=null,$(),v()}function O(e){const n=Math.floor((e-u+m/2)/(d+m));return n>=0&&n<i.length?n:-1}s.addEventListener("mousemove",e=>{const n=s.getBoundingClientRect(),o=O(e.clientY-n.top),t=o>=0&&f&&!g&&i[o].itemCount>1,c=o>=0&&(t||(!!l.onOpen||!!l.onSelectBar)&&!t);if(o!==x&&(x=o,s.style.cursor=c?"pointer":"default",v()),o>=0){const b=i[o],a=t?`<br><em>click to see this ${D(f.groupLabelText)} by wafer</em>`:l.onOpen?"<br><em>click to open this wafer</em>":l.onSelectBar?`<br><em>click to ${D(l.selectLabel??"see what it counts")}</em>`:"",p=!t&&l.onWaferContextMenu&&typeof b.key=="number"?bt:"";C.innerHTML=`<strong>${D(b.label)}</strong><br>${D(N(b))}${a}${p}`,C.style.display="block",ft(C,r,e.clientX,e.clientY)}else C.style.display="none"}),s.addEventListener("mouseleave",()=>{x!==-1&&(x=-1,v()),C.style.display="none"}),s.addEventListener("click",e=>{const n=s.getBoundingClientRect(),o=O(e.clientY-n.top);if(o===-1)return;const t=i[o];if(f&&!g&&t.itemCount>1){J(t);return}if(l.onSelectBar){C.style.display="none",l.onSelectBar(t,e);return}l.onOpen?.(t)}),s.addEventListener("contextmenu",e=>{const n=s.getBoundingClientRect(),o=O(e.clientY-n.top);if(o===-1||!l.onWaferContextMenu)return;const t=i[o];f&&!g&&t.itemCount>1||typeof t.key!="number"||(C.style.display="none",l.onWaferContextMenu(t.key,void 0,e))});const Q=ct(r,()=>v());return v(),{card:r,destroy:()=>Q.disconnect()}}
@@ -1,27 +0,0 @@
1
- import { type BinItem, type BinType } from '../../stats/binPareto.js';
2
- import { type SaveImageHandler } from './chartShell.js';
3
- export interface BinClusterPanelOptions {
4
- title?: string;
5
- groups: {
6
- key: string;
7
- items: BinItem[];
8
- }[];
9
- onSaveImage?: SaveImageHandler;
10
- /** Click a sub-bar: a bin in one group. The host picks out those dies and opens a menu at the click. */
11
- onSelectBin?: (sel: {
12
- bin: number;
13
- binType: BinType;
14
- groupKey: string;
15
- }, e: MouseEvent) => void;
16
- /** Document to build this panel's DOM into. Default `document` — pass the
17
- * host's own `ownerDocument` when the container might live in a
18
- * different document (e.g. a gallery card detached into its own popup
19
- * window). */
20
- ownerDocument?: Document;
21
- }
22
- export interface BinClusterPanelHandle {
23
- card: HTMLElement;
24
- destroy: () => void;
25
- }
26
- export declare function renderBinClusterPanel(options: BinClusterPanelOptions): BinClusterPanelHandle;
27
- //# sourceMappingURL=binCluster.d.ts.map
@@ -1 +0,0 @@
1
- import{buildBinClusterData as T}from"../../stats/binPareto.js";import{SPACE as x,FONT as H,CLR as E}from"../toolbar.js";import{cardShell as L,makeTooltip as $,makeSegmented as D,renderEmptyState as I}from"./chartShell.js";import{renderGroupedBarPlot as R}from"./groupedBarPlot.js";import{escHtml as g}from"../../core/utils.js";const k=90,M=8;export function renderBinClusterPanel(e){const{groups:h,onSaveImage:f}=e;let i="hbin",u=e.title??"Hard bin pareto";const{card:o,heading:S,body:l,controlsRow:y}=L(u,f,e.ownerDocument);y.appendChild(D([["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"]],i,n=>{i=n,u=`${i==="hbin"?"Hard":"Soft"} bin pareto`,S.textContent=u,m()},o.ownerDocument));const s=o.ownerDocument.createElement("div");s.dataset.wmapCaption="1",s.textContent="One cluster per bin \xB7 a sub-bar per group"+(e.onSelectBin?" \xB7 click a sub-bar to chart or tabulate its dies":""),Object.assign(s.style,{color:E.label,fontSize:H.body,marginBottom:x.sm}),o.insertBefore(s,l);const B=$(o);let c=null;function m(){c?.destroy(),c=null,l.innerHTML="";const n=T(h,i);if(n.bins.length===0||n.groups.length===0){I(l,"No bin data available for the current grouping.");return}const d=n.groups,b=n.bins,C=Math.max(1,...b.flatMap(t=>t.counts));c=R(o,l,B,{rows:b.map(t=>({label:t.label,bars:t.counts.map(r=>({fraction:r/C})),trailing:`${t.total}`})),groups:d,labelWidth:k,maxVisibleRows:M,onRowClick:e.onSelectBin?(t,r,a)=>e.onSelectBin({bin:b[t].binCode,binType:i,groupKey:d[r]},a):void 0,tooltipHtml:(t,r)=>{const a=b[t],p=a.counts[r],w=a.total>0?p/a.total*100:0;return`<strong>${g(a.label)}</strong> \xB7 ${g(String(d[r]))}<br>${p} dies (${w.toFixed(1)}% of bin)`}})}return m(),{card:o,destroy:()=>c?.destroy()}}
@@ -1,72 +0,0 @@
1
- import { type BoxplotItem } from '../../stats/boxplot.js';
2
- import type { TestDef } from '../../renderer/buildWaferMap.js';
3
- import { type AxisPrefs, type SaveImageHandler, type WaferContextMenuHandler } from './chartShell.js';
4
- /** A `BoxplotItem` carrying enough identity for the panel to open its wafer
5
- * on a leaf-row click — the tab's own item shape already has this. */
6
- export type BoxplotPanelItem = BoxplotItem & {
7
- waferIndex?: number;
8
- };
9
- export interface BoxplotPanelOptions {
10
- title?: string;
11
- items: BoxplotPanelItem[];
12
- testDefs: TestDef[];
13
- selectedTestNumber?: number;
14
- onSaveImage?: SaveImageHandler;
15
- /**
16
- * When the Analysis tab's "Group by" is active, this panel shows one
17
- * pooled row per group by default (all of that group's items' dies
18
- * combined into one five-number summary); clicking a group's row drills
19
- * in place into that group's own per-item rows, with a Back button.
20
- * `items` above is ignored when `groups` is provided. Absent ⇒ today's
21
- * plain ungrouped per-item rows, no drill.
22
- */
23
- groups?: {
24
- key: string;
25
- items: BoxplotPanelItem[];
26
- }[];
27
- /** Initial axis toggles, shared with the sibling distribution panels. */
28
- axisPrefs?: AxisPrefs;
29
- /** Fired when the user changes an axis toggle here, so siblings can follow. */
30
- onAxisPrefsChange?: (prefs: AxisPrefs) => void;
31
- /** Fired when the USER picks a test here, so siblings can follow. */
32
- onTestChange?: (testNumber: number) => void;
33
- /** Human label of the active facet (e.g. "Split"), used in the overview
34
- * hint text ("click a <label>'s box to see it by wafer"). */
35
- groupLabelText?: string;
36
- /** Fired when the user narrows to one group here — by clicking a group's box
37
- * to drill in, or Back to leave. The Insights tab owns the scope; this panel
38
- * only reports the gesture. */
39
- onGroupChange?: (key: string | null) => void;
40
- /** Clicking a leaf row (a real per-item row — ungrouped, or drilled into
41
- * a group) calls this with that item's `waferIndex` and the boxplot's
42
- * currently selected `testNumber`, so the opened wafer can land on the
43
- * same test in value mode instead of defaulting to hard-bin mode.
44
- * Never called for a pooled group-overview row (that drills instead). */
45
- onOpen?: (waferIndex: number, testNumber: number) => void;
46
- /** Right-click on a wafer's box — see `WaferContextMenuHandler`. Not called
47
- * for a pooled group row. */
48
- onWaferContextMenu?: WaferContextMenuHandler;
49
- /** What `onOpen` will actually do, in the user's words — substituted into
50
- * both click affordances ("click a box to …" / "click to …"). Default
51
- * wording describes opening that wafer, which is what a gallery host does;
52
- * a single-wafer host, where there is no other wafer to open and the click
53
- * instead shows the selected test on the map it already has, passes its own
54
- * (see `InsightsTabDeps.focusTest`). One string rather than two because the
55
- * two affordances describe one action — if they can disagree, they will. */
56
- openActionLabel?: string;
57
- /** Document to build this panel's DOM into. Default `document` — pass the
58
- * host's own `ownerDocument` when the container might live in a
59
- * different document (e.g. a gallery card detached into its own popup
60
- * window). */
61
- ownerDocument?: Document;
62
- }
63
- export interface BoxplotPanelHandle {
64
- card: HTMLElement;
65
- /** Cross-panel link (e.g. from the capability panel): switch to `testNumber` in place. */
66
- setTest: (testNumber: number) => void;
67
- /** Adopt the shared axis toggles (see `AxisPrefs`). */
68
- setAxisPrefs: (prefs: AxisPrefs) => void;
69
- destroy: () => void;
70
- }
71
- export declare function renderBoxplotPanel(options: BoxplotPanelOptions): BoxplotPanelHandle;
72
- //# sourceMappingURL=boxplot.d.ts.map
@@ -1 +0,0 @@
1
- import{buildTestBoxplotData as rt}from"../../stats/boxplot.js";import{SPACE as De,fontPx as _,FONT as ct,CLR as ft}from"../toolbar.js";import{fmt as ge}from"../../renderer/fmt.js";import{fitTicks as ut}from"../../renderer/axisTicks.js";import{QUANTITY as Ee}from"./palette.js";import{cardShell as mt,observeResize as dt,makeTooltip as xt,positionChartTooltip as pt,makeBackButton as ht,makeLinkedTestSelect as gt,makeToggle as bt,makeLinkedAxisPrefs as wt,renderEmptyState as Oe,fitRowsHeight as yt,setChartGrow as Tt,resolveChartCanvasColors as vt,makeAxisFormat as We,horizontalTickSpacing as kt,resolveAxisRange as Mt,shouldIncludeLimitsByDefault as Lt,drawOffAxisLimits as Ct,limitLabelSide as At,limitLines as Pe,limitExtent as $t,hasBothLimitKinds as St,stackLabelRows as It,strokeLimitLine as Bt,PADDING as L,VALUE_WIDTH as Rt,WAFER_MENU_HINT as Ht,prepareCanvas as Dt}from"./chartShell.js";import{escHtml as C,maxOf as Et,minOf as Ot}from"../../core/utils.js";import{excludedNote as Wt}from"../../renderer/valueFilter.js";const A=24,$=5,_e=110,Pt=12,Ne=20;export function renderBoxplotPanel(u){const{title:ne="Test value distribution",items:Ge,testDefs:be,onSaveImage:Xe,groups:g,groupLabelText:oe="group",onOpen:Q}=u,qe=u.openActionLabel??"open that wafer",Ye=u.openActionLabel??"open this wafer",{card:a,heading:ze,body:x,controlsRow:U}=mt(ne,Xe,u.ownerDocument);Tt(a,"rows"),a.style.flex="0 0 auto",x.style.flex="0 0 auto",a.style.alignSelf="start";const ie=be.filter(i=>i.testNumber!==void 0);let y=u.selectedTestNumber??ie[0]?.testNumber??null,le=!1,F=0,b=null,D=null,se=null,we=null;function ye(){const i=!g||g.length===0?"":b??"\0overview";if(se&&we===i)return se;const p=!g||g.length===0?Ge:b!==null?g.find(k=>k.key===b)?.items??[]:g.map(k=>({label:k.key,dies:k.items.flatMap(T=>T.dies??[])}));return se=p,we=i,p}function Te(){b!==null&&!D?(D=ht(()=>{ve(null),u.onGroupChange?.(null)},a.ownerDocument),U.appendChild(D)):b===null&&D&&(D.remove(),D=null),ze.textContent=b!==null?`${ne} \u2014 ${oe}: ${b}`:ne}function ve(i){return b===i||i!==null&&!(g??[]).some(p=>p.key===i)?!1:(b=i,Te(),j(),S(),!0)}const ke=gt(ie,y,i=>{y=i,S(),u.onTestChange?.(i)},{maxWidth:"240px",emptyText:"No parametric tests",ownerDocument:a.ownerDocument}),Qe=ke.el;U.appendChild(Qe),U.appendChild(bt("Log scale",le,i=>{le=i,S()},a.ownerDocument,"Draw the value axis on a logarithmic scale"));const ae=a.ownerDocument.createElement("span");Object.assign(ae.style,{display:"inline-flex",gap:De.lg,alignItems:"center"}),U.appendChild(ae);const re=wt(ae,u.axisPrefs,i=>{u.onAxisPrefsChange?.(i),S()},a.ownerDocument),V=a.ownerDocument.createElement("div");V.dataset.wmapCaption="1",Object.assign(V.style,{color:ft.label,fontSize:ct.body,marginBottom:De.sm}),a.insertBefore(V,x);function j(){const i=!!g&&g.length>0&&b===null,p=[];i?p.push(`click a ${oe}'s box to see it by wafer`):Q&&p.push(`click a box to ${qe}`);const k=p.length?`${p[0][0].toUpperCase()}${p[0].slice(1)} \xB7 `:"";V.textContent=`${k}box = Q1\u2013Q3, line = median, whiskers = min/max \xB7 value shown is the median`+(F?` \xB7 axis clipped, ${F} value${F===1?"":"s"} outside`:"")+Wt(ye().flatMap(T=>T.dies??[]),y)}j(),Te();const E=xt(a);let ce=null;function S(){const{includeLimits:i,clipOutliers:p,limits:k}=re.get();if(j(),x.innerHTML="",ie.length===0||y===null){Oe(x,"No parametric test data available for box plots.");return}const T=ye(),h=rt(T,y),K=be.find(t=>t.testNumber===y),O=K?.unit,fe=Pe(K,k),{lo:Ve,hi:je}=$t(fe);if(h.every(t=>t.count===0)){Oe(x,"No parametric test data available for box plots.");return}const m=a.ownerDocument.createElement("canvas");m.style.display="block",m.style.cursor="default",x.appendChild(m);const Me=L*2+Math.min(h.length,Pt)*(A+$)+Ne;x.style.maxHeight=`${Me}px`,x.style.overflowY="auto",x.style.scrollbarGutter="stable";let N=-1;const ue=h.filter(t=>t.count>0),Le=Ot(ue.map(t=>t.min)),Ce=Et(ue.map(t=>t.max)),Ae=i??Lt(Le,Ce,Ve,je);re.sync(Ae,Pe(K).length>0,St(K));const G=Mt({dataMin:Le,dataMax:Ce,limits:fe,includeLimits:Ae,clipOutliers:p,values:ue.flatMap(t=>[t.min,t.q1,t.median,t.q3,t.max])});F=G.clippedCount,j();const W=G.lo,J=G.hi,Ke=J-W||1,Z=le&&W>0,me=Z?Math.log10(W):0,$e=(Z?Math.log10(J):0)-me||1,de=Math.max(Math.abs(W),Math.abs(J));function Je(){const t=L+_e,s=m.clientWidth-t-Rt-L;return{plotX:t,plotMaxWidth:Math.max(10,s)}}function I(t,s,n){return Z?s+(Math.log10(t)-me)/$e*n:s+(t-W)/Ke*n}function Ze(t,s){if(Z){const d=[];for(let e=0;e<=4;e++)d.push(Math.pow(10,me+$e*e/4));return{ticks:d,axis:We(de,O)}}const n=ut(W,J,s,kt(t,de,O));return{ticks:n.ticks,axis:We(de,O,n.step||void 0)}}function ee(){const t=vt(a),s=L*2+h.length*(A+$)+Ne;x.style.maxHeight=`${yt(a,x,Me,s)}px`;const n=x.clientWidth,d=Dt(m,a,n,s);if(!d)return;const{ctx:e}=d;e.font=`${_(-1)}px system-ui, sans-serif`,e.textBaseline="middle";const{plotX:l,plotMaxWidth:c}=Je();h.forEach((o,f)=>{const w=L+f*(A+$),r=w+A/2;f===N&&(e.fillStyle=t.bgHover,e.fillRect(0,w-$/2,n,A+$)),e.fillStyle=t.text,e.textAlign="right";const te=o.label.length>16?`${o.label.slice(0,15)}\u2026`:o.label;if(e.fillText(te,L+_e-8,r),o.count===0){e.fillStyle=t.textMuted,e.textAlign="left",e.fillText("no data",l,r);return}const it=l+c,q=at=>Math.min(it,Math.max(l,at)),Be=I(o.min,l,c),Re=I(o.max,l,c),B=q(Be),Y=q(I(o.q1,l,c)),He=q(I(o.median,l,c)),he=q(I(o.q3,l,c)),R=q(Re),lt=Be<B,st=Re>R,H=w+3,z=w+A-3;e.strokeStyle=t.textMuted,e.lineWidth=1,e.beginPath(),e.moveTo(B,r),e.lineTo(Y,r),e.moveTo(he,r),e.lineTo(R,r);const M=3;lt?(e.moveTo(B+M,r-M),e.lineTo(B,r),e.lineTo(B+M,r+M)):(e.moveTo(B,H),e.lineTo(B,z)),st?(e.moveTo(R-M,r-M),e.lineTo(R,r),e.lineTo(R-M,r+M)):(e.moveTo(R,H),e.lineTo(R,z)),e.stroke(),e.fillStyle=Ee,e.globalAlpha=.35,e.fillRect(Y,H,Math.max(1,he-Y),z-H),e.globalAlpha=1,e.strokeStyle=Ee,e.strokeRect(Y,H,Math.max(1,he-Y),z-H),e.strokeStyle=t.text,e.lineWidth=2,e.beginPath(),e.moveTo(He,H),e.lineTo(He,z),e.stroke(),e.lineWidth=1,e.fillStyle=t.textMuted,e.textAlign="left",e.fillText(ge(o.median,O,"engineering"),l+c+10,r)});const v=L+h.length*(A+$);e.font=`${_(-1)}px system-ui, sans-serif`,Ct(e,G.offAxis,{left:l,right:l+c,top:0,bottom:v},"horizontal",t.limitLine,o=>ge(o,O,"engineering"));const et=new Set(G.offAxis.map(o=>o.value)),Ie=fe.filter(o=>!et.has(o.value)).map(o=>{const f=I(o.value,l,c),w=e.measureText(o.label).width,r=At(f,w,l,l+c,o.end==="lo"),te=r<0?f-3-w:f+3;return{l:o,x:f,dir:r,start:te,end:te+w}}),tt=It(Ie),nt=_(-1)+2;Ie.forEach(({l:o,x:f,dir:w},r)=>{Bt(e,o,t.limitLine,f,0,f,v),e.fillStyle=t.limitLine,e.textAlign=w<0?"right":"left",e.textBaseline="bottom",e.fillText(o.label,f+w*3,v-1-tt[r]*nt)}),e.font=`${_(-1)}px system-ui, sans-serif`,e.strokeStyle=t.border,e.lineWidth=1,e.beginPath(),e.moveTo(l,v),e.lineTo(l+c,v),e.stroke(),e.fillStyle=t.textMuted,e.textAlign="center",e.textBaseline="top";const{ticks:ot,axis:pe}=Ze(e,c);for(const o of ot){const f=I(o,l,c);e.beginPath(),e.moveTo(f,v),e.lineTo(f,v+4),e.stroke(),e.fillText(pe.tick(o),f,v+6)}pe.unitLabel&&(e.textAlign="left",e.font=`${_(-1)}px system-ui, sans-serif`,e.fillText(`(${pe.unitLabel})`,l+c+22,v+6),e.font=`${_(-1)}px system-ui, sans-serif`),e.textBaseline="middle"}function xe(t){const s=Math.floor((t-L+$/2)/(A+$));return s>=0&&s<h.length?s:-1}function X(t){return ge(t,O,"engineering")}const P=!!g&&g.length>0&&b===null,Se=t=>!P&&!!Q&&T[t]?.waferIndex!==void 0;m.addEventListener("mousemove",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top),d=n>=0&&h[n].count>0&&(P||Se(n));if(n!==N&&(N=n,m.style.cursor=d?"pointer":"default",ee()),n>=0&&h[n].count>0){const e=h[n],l=P?`<br><em>click to see this ${C(oe)} by wafer</em>`:Se(n)?`<br><em>click to ${C(Ye)}</em>`:"",c=!P&&u.onWaferContextMenu&&T[n]?.waferIndex!==void 0?Ht:"";E.innerHTML=`<strong>${C(e.label)}</strong> (${e.count} dies)<br>max ${C(X(e.max))}<br>q3 ${C(X(e.q3))}<br>median ${C(X(e.median))}<br>q1 ${C(X(e.q1))}<br>min ${C(X(e.min))}${l}${c}`,E.style.display="block",pt(E,a,t.clientX,t.clientY)}else E.style.display="none"}),m.addEventListener("mouseleave",()=>{N!==-1&&(N=-1,ee()),E.style.display="none"}),m.addEventListener("click",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top);if(n===-1||h[n].count===0)return;if(P){const e=h[n].label;ve(e),u.onGroupChange?.(e);return}const d=T[n]?.waferIndex;Q&&d!==void 0&&y!==null&&Q(d,y)}),m.addEventListener("contextmenu",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top),d=n===-1?void 0:T[n]?.waferIndex;P||d===void 0||!u.onWaferContextMenu||(E.style.display="none",u.onWaferContextMenu(d,y??void 0,t))}),ce?.disconnect(),ce=dt(a,()=>ee()),ee()}S();function Ue(i){ke.set(i)&&(y=i,S())}function Fe(i){re.set(i)&&S()}return{card:a,setTest:Ue,setAxisPrefs:Fe,destroy:()=>ce?.disconnect()}}
@@ -1,53 +0,0 @@
1
- /** One cluster: a label, a sub-bar per group, and a trailing value. */
2
- export interface GroupedBarRow {
3
- label: string;
4
- /**
5
- * One entry per group, in group order.
6
- *
7
- * `fraction` is the bar's share of the track, 0-1 — already resolved by the
8
- * caller, because that is exactly where the two charts differ (normalised to
9
- * the chart maximum vs a fixed 0-100% scale). `null` means nothing was
10
- * measured for this group, drawn as an empty track with `emptyBarText`
11
- * rather than a zero-width bar, which would read as a real zero.
12
- */
13
- bars: Array<{
14
- fraction: number | null;
15
- }>;
16
- /** Right-hand value column, formatted by the caller. */
17
- trailing: string;
18
- }
19
- export interface GroupedBarPlotOptions {
20
- rows: GroupedBarRow[];
21
- /** Group names, in the order `GroupedBarRow.bars` uses. Drives the legend. */
22
- groups: string[];
23
- /** Width reserved for the row labels. */
24
- labelWidth: number;
25
- /** Rows visible before the plot scrolls. */
26
- maxVisibleRows?: number;
27
- /** Show the group legend above the plot. */
28
- showLegend?: boolean;
29
- /** Truncate row labels beyond this many characters. Off when omitted. */
30
- maxLabelChars?: number;
31
- /** Drawn inside an empty track where `fraction` is null. */
32
- emptyBarText?: string;
33
- /** Sub-bar colour by group index. Defaults to the CVD-safe categorical ramp. */
34
- colorOf?: (groupIndex: number) => string;
35
- /** Tooltip HTML for a hovered sub-bar. */
36
- /** HTML for the hover tooltip. Escape every label with `escHtml` (core/utils.ts): they come from input files. */
37
- tooltipHtml: (rowIndex: number, groupIndex: number) => string;
38
- /** Click a sub-bar: called with its row, its group and the click, so the host can open a menu there. */
39
- onRowClick?: (rowIndex: number, groupIndex: number, e: MouseEvent) => void;
40
- }
41
- export interface GroupedBarPlotHandle {
42
- /** Redraw — call when the theme changes or data is replaced. */
43
- draw(): void;
44
- destroy(): void;
45
- }
46
- /**
47
- * Build the legend, scroll area and canvas into `body`, and wire hover.
48
- *
49
- * `card` is needed for the theme and for tooltip positioning; `tooltip` is the
50
- * caller's own element so a panel keeps one tooltip across rebuilds.
51
- */
52
- export declare function renderGroupedBarPlot(card: HTMLElement, body: HTMLElement, tooltip: HTMLElement, options: GroupedBarPlotOptions): GroupedBarPlotHandle;
53
- //# sourceMappingURL=groupedBarPlot.d.ts.map
@@ -1 +0,0 @@
1
- import{categorical as q}from"./palette.js";import{SPACE as E,FONT as J,CLR as K}from"../toolbar.js";import{observeResize as Q,positionChartTooltip as Z,fitRowsHeight as tt,setChartGrow as et,prepareCanvas as nt,chartSwatchCss as lt,PADDING as c,VALUE_WIDTH as $}from"./chartShell.js";const ot=8,C=1,a=14,it=8;export function renderGroupedBarPlot(f,L,h,v){const{rows:w,groups:S,labelWidth:T,tooltipHtml:j,maxVisibleRows:z=it,showLegend:V=!0,maxLabelChars:R,emptyBarText:B,colorOf:k=q}=v,d=f.ownerDocument;et(f,"rows");const H=Math.max(1,S.length),A=H*a+(H-1)*C,u=A+ot;let W=0;if(V){const t=d.createElement("div");t.dataset.wmapLegend="1",Object.assign(t.style,{display:"flex",flexWrap:"wrap",gap:`${E.xs} ${E.xl}`,marginBottom:E.xs}),S.forEach((l,n)=>{const e=d.createElement("span");Object.assign(e.style,{display:"inline-flex",alignItems:"center",gap:E.sm,fontSize:J.body,color:K.text});const i=d.createElement("span");i.style.cssText=lt(k(n));const s=d.createElement("span");s.textContent=l,e.append(i,s),t.appendChild(e)}),L.appendChild(t),W=t.offsetHeight}const g=d.createElement("div"),G=c*2+Math.min(w.length,z)*u;Object.assign(g.style,{overflowX:"hidden",overflowY:"auto",minHeight:"0",flex:"1",maxHeight:`${G}px`,scrollbarGutter:"stable"}),L.appendChild(g);const o=d.createElement("canvas");o.style.display="block",o.style.cursor="default",g.appendChild(o);let r=null;function X(){const t=c+T,l=Math.max(10,o.clientWidth-t-$-c);return{barX:t,barMaxWidth:l}}function _(t,l){const n=Math.floor((l-c)/u);if(n<0||n>=w.length)return null;const e=l-c-n*u,i=Math.floor(e/(a+C));if(i<0||i>=H)return null;const{barX:s,barMaxWidth:m}=X();return t<s||t>s+m?null:{row:n,group:i}}function p(){const t=c*2+w.length*u;g.style.maxHeight=`${tt(f,L,G,t,W)}px`;const l=g.clientWidth,n=nt(o,f,l,t);if(!n)return;const{ctx:e,theme:i}=n,{barX:s,barMaxWidth:m}=X();w.forEach((x,D)=>{const b=c+D*u;if(r&&r.row===D){const y=b+r.group*(a+C);e.fillStyle=i.bgHover,e.fillRect(0,y-1,l,a+2)}e.fillStyle=i.text,e.textAlign="right";const F=R!==void 0&&x.label.length>R?`${x.label.slice(0,R-1)}\u2026`:x.label;e.fillText(F,c+T-8,b+A/2),x.bars.forEach((y,U)=>{const M=b+U*(a+C);if(e.fillStyle=i.track,e.fillRect(s,M,m,a),y.fraction===null){B&&(e.fillStyle=i.textMuted,e.textAlign="left",e.fillText(B,s+4,M+a/2));return}const N=Math.max(y.fraction>0?1:0,y.fraction*m);e.fillStyle=k(U),e.fillRect(s,M,N,a)}),e.fillStyle=i.text,e.textAlign="right",e.fillText(x.trailing,s+m+$,b+A/2)})}const I=t=>{const l=o.getBoundingClientRect(),n=_(t.clientX-l.left,t.clientY-l.top),e=n?.row!==r?.row||n?.group!==r?.group;if(r=n,e&&p(),!n){h.style.display="none";return}h.innerHTML=j(n.row,n.group),h.style.display="block",Z(h,f,t.clientX,t.clientY)},O=()=>{r&&(r=null,p()),h.style.display="none"},P=t=>{const l=o.getBoundingClientRect(),n=_(t.clientX-l.left,t.clientY-l.top);n&&v.onRowClick&&(h.style.display="none",v.onRowClick(n.row,n.group,t))};o.addEventListener("mousemove",I),o.addEventListener("mouseleave",O),v.onRowClick&&(o.style.cursor="pointer",o.addEventListener("click",P));const Y=Q(f,()=>p());return p(),{draw:p,destroy:()=>{Y?.disconnect(),o.removeEventListener("mousemove",I),o.removeEventListener("mouseleave",O),o.removeEventListener("click",P)}}}
@@ -1,61 +0,0 @@
1
- import { type HistogramItem } from '../../stats/histogram.js';
2
- import type { TestDef } from '../../renderer/buildWaferMap.js';
3
- import type { Die } from '../../core/dies.js';
4
- import { type SaveImageHandler, type AxisPrefs } from './chartShell.js';
5
- export interface HistogramPanelOptions {
6
- /** Initial axis toggles, shared with the sibling distribution panels. */
7
- axisPrefs?: AxisPrefs;
8
- /** Fired when the user changes an axis toggle here, so siblings can follow. */
9
- onAxisPrefsChange?: (prefs: AxisPrefs) => void;
10
- /** Fired when the USER picks a test here, so siblings can follow. */
11
- onTestChange?: (testNumber: number) => void;
12
- title?: string;
13
- items: HistogramItem[];
14
- testDefs: TestDef[];
15
- selectedTestNumber?: number;
16
- onSaveImage?: SaveImageHandler;
17
- /**
18
- * When the Analysis tab's "Group by" is active, this panel switches to an
19
- * overlaid multi-series view (one coloured series per group over shared
20
- * buckets, with a click-to-emphasize legend) instead of the single-item
21
- * view. `items` above is ignored when `groups` is provided. Absent ⇒
22
- * today's plain per-item view with a wafer selector.
23
- */
24
- groups?: {
25
- key: string;
26
- items: HistogramItem[];
27
- }[];
28
- /** Fired when the user narrows to one group by clicking it in the legend.
29
- * The Insights tab owns the scope; this panel only reports the gesture. */
30
- onGroupChange?: (key: string | null) => void;
31
- /**
32
- * Click a bar: the dies it counts, per item, with the bar's range and the click, so the host can open a menu on them.
33
- * On the overlaid group view the bar is the bucket across every group, or across the one the legend has emphasised
34
- * (`group` then says which): there is no one bar to click, so the column is the target.
35
- */
36
- onSelectBucket?: (sel: {
37
- testNumber: number;
38
- low: number;
39
- high: number;
40
- items: Array<{
41
- item: HistogramItem;
42
- dies: Die[];
43
- }>;
44
- group?: string;
45
- }, e: MouseEvent) => void;
46
- /** Document to build this panel's DOM into. Default `document` — pass the
47
- * host's own `ownerDocument` when the container might live in a
48
- * different document (e.g. a gallery card detached into its own popup
49
- * window). */
50
- ownerDocument?: Document;
51
- }
52
- export interface HistogramPanelHandle {
53
- card: HTMLElement;
54
- /** Cross-panel link (e.g. from the capability panel): switch to `testNumber` in place. */
55
- setTest: (testNumber: number) => void;
56
- /** Adopt the shared axis toggles (see `AxisPrefs`). */
57
- setAxisPrefs: (prefs: AxisPrefs) => void;
58
- destroy: () => void;
59
- }
60
- export declare function renderHistogramPanel(options: HistogramPanelOptions): HistogramPanelHandle;
61
- //# sourceMappingURL=histogram.d.ts.map
@@ -1 +0,0 @@
1
- import{buildTestHistogramData as ee,collectTestValues as Bt,buildTestHistogramSeries as ne,testValueExtent as At,diesInBucket as $t}from"../../stats/histogram.js";import{excludedNote as Et}from"../../renderer/valueFilter.js";import{SPACE as at,fontPx as K,FONT as Wt,CLR as Dt}from"../toolbar.js";import{fmt as bt}from"../../renderer/fmt.js";import{niceStep as ie,fitTicks as It}from"../../renderer/axisTicks.js";import{QUANTITY as oe,categorical as se}from"./palette.js";import{cardShell as le,observeResize as Pt,makeTooltip as ae,attachChartTip as re,positionChartTooltip as Rt,makeLinkedTestSelect as ce,makeWaferSelect as ue,makeLinkedAxisPrefs as de,renderEmptyState as Tt,chartFillHeight as Kt,applyCanvasFlow as Nt,makeAxisFormat as Mt,horizontalTickSpacing as Ot,PADDING as ht,robustFence as Ft,shouldIncludeLimitsByDefault as zt,drawOffAxisLimits as me,resolveAxisRange as he,limitLines as Gt,limitExtent as fe,hasBothLimitKinds as ge,stackLabelRows as pe,strokeLimitLine as xe,chartSwatchCss as be,makeSeriesLegendItem as ye,prepareCanvas as Vt}from"./chartShell.js";import{escHtml as wt,maxOf as ke}from"../../core/utils.js";const vt=230,jt=36,Te=18;function Xt(n){const E=new Set(n.map(A=>A.kind)).size;return Te+Math.max(0,E-1)*(K(-1)+2)}function _t(n,E,A,V,et,k,a){n.font=`${K(-1)}px system-ui, sans-serif`;const x=E.filter(i=>!A.has(i.value)).map(i=>{const S=V(i.value),N=n.measureText(i.label).width;return{l:i,x:S,start:S-N/2,end:S+N/2}}),U=pe(x),nt=K(-1)+2;x.forEach(({l:i,x:S},N)=>{xe(n,i,a,S,et,S,k),n.fillStyle=a,n.textAlign="center",n.textBaseline="bottom",n.fillText(i.label,S,et-2-U[N]*nt)})}function Yt(n,E,A,V,et,k,a,x=4){const U=Math.max(1,ie(k/x)),nt=V-A;n.save(),n.font=`${K(-1)}px system-ui, sans-serif`,n.textAlign="right",n.textBaseline="middle";for(let i=0;i<=k+1e-9;i+=U){const S=V-i/(k||1)*nt;n.strokeStyle=a.grid,n.lineWidth=1,n.beginPath(),n.moveTo(E,S),n.lineTo(E+et,S),n.stroke(),n.fillStyle=a.text,n.fillText(String(Math.round(i)),E-4,S)}n.strokeStyle=a.axis,n.lineWidth=1,n.beginPath(),n.moveTo(E,A),n.lineTo(E,V),n.stroke(),n.restore()}export function renderHistogramPanel(n){const{title:E="Test value distribution",items:A,testDefs:V,onSaveImage:et,groups:k}=n,{card:a,body:x,controlsRow:U}=le(E,et,n.ownerDocument),nt=V.filter(s=>s.testNumber!==void 0);let i=n.selectedTestNumber??nt[0]?.testNumber??null;const S=()=>(k?k.flatMap(s=>s.items):A).flatMap(s=>s.dies??[]);let N=null,it=0,ft;const St=ce(nt,i,s=>{i=s,q(),n.onTestChange?.(s)},{maxWidth:"200px",ownerDocument:a.ownerDocument}),Qt=St.el;U.appendChild(Qt);const gt=A.length>1?ue(A,N,s=>{N=s,q()},{ownerDocument:a.ownerDocument}):null;gt&&U.appendChild(gt);function Ut(s){return b===s||s!==null&&!(k??[]).some(L=>L.key===s)?!1:(b=s,q(),!0)}const yt=a.ownerDocument.createElement("span");Object.assign(yt.style,{display:"inline-flex",gap:at.lg,alignItems:"center"}),U.appendChild(yt);const rt=de(yt,n.axisPrefs,s=>{n.onAxisPrefsChange?.(s),q()},a.ownerDocument),C=ae(a);let ct=null,b=null;function ot(s){const L=V.find(D=>D.testNumber===s),j=Gt(L,rt.get().limits),{lo:T,hi:M}=fe(j);return{unit:L?.unit,lines:j,limitLow:T,limitHigh:M,hasLimits:Gt(L).length>0,hasBothKinds:ge(L)}}function q(){const{includeLimits:s,clipOutliers:L}=rt.get();if(ct?.disconnect(),ct=null,x.innerHTML="",i===null){Tt(x,"No parametric test data available for a histogram.");return}const j=!!k&&k.length>0;let T=!1,M;if(j){const{limitLow:u,limitHigh:m}=ot(i),g=k.flatMap(c=>c.items),{min:e,max:p}=At(g,i);if(T=s??zt(e,p,u,m),L){const c=Bt(g,i),h=Ft(c);h&&(M={lo:Math.max(e,h.lo),hi:Math.min(p,h.hi)},it=c.reduce((Z,R)=>Z+(R<M.lo||R>M.hi?1:0),0))}M||(it=0),ft=M}const D=j?ne(k,i,16,T?ot(i).limitLow:void 0,T?ot(i).limitHigh:void 0,M):null;if(gt&&(gt.style.display=D?"none":""),D){const{hasLimits:u,hasBothKinds:m}=ot(i);if(rt.sync(T,u,m),D.series.length===0){Tt(x,"No parametric test data available for a histogram.");return}qt(D);return}const O=N!==null?[A[N]]:A,{unit:W,lines:X,limitLow:w,limitHigh:_,hasLimits:ut,hasBothKinds:pt}=ot(i),dt=Bt(O,i),{min:mt,max:xt}=At(O,i),I=s??zt(mt,xt,w,_);rt.sync(I,ut,pt);const st=L?Ft(dt):null,P=st?{lo:Math.max(mt,st.lo),hi:Math.min(xt,st.hi)}:void 0;it=P?dt.filter(u=>u<P.lo||u>P.hi).length:0,ft=P;const y=ee(O,i,16,I?w:void 0,I?_:void 0,P);if(y.length===0){Tt(x,"No parametric test data available for a histogram.");return}const o=Math.max(ke(y.map(u=>u.count)),1),d=a.ownerDocument.createElement("div");d.dataset.wmapCaption="1",Object.assign(d.style,{fontSize:Wt.body,color:Dt.label,marginBottom:at.xxs}),d.textContent=`max ${o} dies/bucket`+Et(S(),i)+(it?` \xB7 ${it} value${it===1?"":"s"} outside clipped range`:"")+(n.onSelectBucket?" \xB7 click a bar to chart or tabulate its dies":""),x.appendChild(d);const l=a.ownerDocument.createElement("canvas");l.style.display="block",l.style.cursor="default",x.appendChild(l);let t=-1;const r=y[0].rangeLow,f=y[y.length-1].rangeHigh,H=f-r||1,F=Math.max(Math.abs(r),Math.abs(f));function J(u){const m=ht+36,g=l.clientWidth-m-ht,e=Xt(X),p=u-jt-e;return{plotX:m,plotMaxWidth:Math.max(10,g),plotMaxHeight:p,plotTop:e}}function v(u){const{plotX:m,plotMaxWidth:g}=J(vt);if(u<m||u>m+g)return-1;const e=Math.floor((u-m)/g*y.length);return e>=0&&e<y.length?e:-1}function $(){Nt(l,d);const u=x.clientWidth,m=Kt(a,x,l,vt),g=Vt(l,a,u,m);if(!g)return;const{ctx:e,theme:p}=g,{plotX:c,plotMaxWidth:h,plotMaxHeight:Z,plotTop:R}=J(m),B=R+Z,tt=h/y.length;Yt(e,c,R,B,h,o,{text:p.textMuted,axis:p.border,grid:p.grid}),y.forEach((G,Q)=>{const Lt=G.count/o*Z,Ht=c+Q*tt,Ct=B-Lt;e.fillStyle=Q===t?p.text:oe,e.globalAlpha=Q===t?1:.7,e.fillRect(Ht+1,Ct,Math.max(1,tt-2),Lt),e.globalAlpha=1,Q===t&&(e.fillStyle=p.text,e.textAlign="center",e.textBaseline="bottom",e.fillText(`${G.count}`,Ht+tt/2,Ct-2))});const lt=G=>c+(G-r)/H*h;e.font=`${K(-1)}px system-ui, sans-serif`;const{offAxis:z}=he({dataMin:r,dataMax:f,limits:X,includeLimits:!1});me(e,z,{left:c,right:c+h,top:R,bottom:B},"horizontal",p.limitLine,Mt(F,W).tick),_t(e,X,new Set(z.map(G=>G.value)),lt,R,B,p.limitLine),e.font=`${K(-1)}px system-ui, sans-serif`,e.strokeStyle=p.border,e.lineWidth=1,e.beginPath(),e.moveTo(c,B),e.lineTo(c+h,B),e.stroke(),e.fillStyle=p.textMuted,e.textAlign="center",e.textBaseline="top";const{ticks:Y,step:te}=It(r,f,h,Ot(e,F,W)),kt=Mt(F,W,te||void 0);for(const G of Y){const Q=c+(G-r)/H*h;e.beginPath(),e.moveTo(Q,B),e.lineTo(Q,B+4),e.stroke(),e.fillText(kt.tick(G),Q,B+6)}kt.unitLabel&&(e.save(),e.font=`${K(-1)}px system-ui, sans-serif`,e.fillStyle=p.textMuted,e.textAlign="right",e.textBaseline="top",e.fillText(`(${kt.unitLabel})`,c+h,B+20),e.restore())}l.addEventListener("mousemove",u=>{const m=l.getBoundingClientRect(),g=v(u.clientX-m.left);if(g!==t&&(t=g,$()),g>=0){const e=y[g];C.innerHTML=`<strong>${wt(`${bt(e.rangeLow,W,"engineering")} \u2013 ${bt(e.rangeHigh,W,"engineering")}`)}</strong><br>${e.count} dies`+(n.onSelectBucket&&e.count>0?"<br><em>click to chart or tabulate these dies</em>":""),C.style.display="block",Rt(C,a,u.clientX,u.clientY)}else C.style.display="none"}),l.addEventListener("mouseleave",()=>{t!==-1&&(t=-1,$()),C.style.display="none"}),n.onSelectBucket&&(l.style.cursor="pointer",l.addEventListener("click",u=>{const m=v(u.clientX-l.getBoundingClientRect().left);if(m<0||i===null||y[m].count===0)return;const g=$t(O,i,y,m,ft);g.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:y[m].rangeLow,high:y[m].rangeHigh,items:g},u))})),ct=Pt(a,()=>$()),$()}function qt(s){const{unit:L,lines:j}=ot(i),T=s.ranges,M=s.series,D=se;b&&!M.some(o=>o.groupKey===b)&&(b=null);const O=Math.max(1,...M.flatMap(o=>o.counts)),W=a.ownerDocument.createElement("div");W.dataset.wmapCaption="1",Object.assign(W.style,{fontSize:Wt.body,color:Dt.label,marginBottom:at.xxs}),W.textContent=`${M.length} groups \xB7 max ${O} dies/bucket`+Et(S(),i)+(n.onSelectBucket?" \xB7 click a column to chart or tabulate its dies":""),x.appendChild(W);const X=a.ownerDocument.createElement("div");Object.assign(X.style,{display:"flex",flexWrap:"wrap",gap:at.sm,marginTop:at.md,marginBottom:at.xl}),M.forEach((o,d)=>{const l=ye(o.groupKey,D(d),a.ownerDocument),t=l.el;re(t,a,C,`${o.groupKey} \u2014 click to emphasize (dim the rest)`),l.setState({selected:b===o.groupKey,dimmed:b!==null&&b!==o.groupKey}),t.addEventListener("click",()=>{const r=b===o.groupKey?null:o.groupKey;Ut(r),n.onGroupChange?.(r)}),X.appendChild(t)}),x.appendChild(X);const w=a.ownerDocument.createElement("canvas");w.style.display="block",w.style.cursor="default",x.appendChild(w);const _=T[0].rangeLow,ut=T[T.length-1].rangeHigh,pt=ut-_||1,dt=Math.max(Math.abs(_),Math.abs(ut)),mt=o=>{const d=(o.ownerDocument.defaultView??window).getComputedStyle(o);return o.offsetHeight+(parseFloat(d.marginTop)||0)+(parseFloat(d.marginBottom)||0)},xt=()=>mt(W)+mt(X);let I=-1,st={plotX:ht+36,plotMaxWidth:10,barWidth:10};function P(){Nt(w,xt());const o=x.clientWidth,d=Kt(a,x,w,vt),l=Vt(w,a,o,d);if(!l)return;const{ctx:t,theme:r}=l,f=ht+36,H=Math.max(10,o-f-ht),F=Xt(j),J=d-jt-F,v=F+J,$=H/T.length;st={plotX:f,plotMaxWidth:H,barWidth:$},Yt(t,f,F,v,H,O,{text:r.textMuted,axis:r.border,grid:r.grid}),I>=0&&(t.fillStyle=r.bgHover,t.globalAlpha=.5,t.fillRect(f+I*$,F,$,J),t.globalAlpha=1);const u=M.map((c,h)=>({s:c,i:h})).sort((c,h)=>(c.s.groupKey===b?1:0)-(h.s.groupKey===b?1:0));for(const{s:c,i:h}of u){const Z=b===c.groupKey,R=b!==null&&!Z,B=D(h);t.strokeStyle=B,t.fillStyle=B,t.lineWidth=Z?2:1,t.globalAlpha=R?.12:b?.32:.22,t.beginPath(),t.moveTo(f,v),c.counts.forEach((tt,lt)=>{const z=f+lt*$,Y=v-tt/O*J;t.lineTo(z,Y),t.lineTo(z+$,Y)}),t.lineTo(f+H,v),t.closePath(),t.fill(),t.globalAlpha=R?.3:1,t.beginPath(),c.counts.forEach((tt,lt)=>{const z=f+lt*$,Y=v-tt/O*J;lt===0?t.moveTo(z,Y):t.lineTo(z,Y),t.lineTo(z+$,Y)}),t.stroke()}t.globalAlpha=1;const m=c=>f+(c-_)/pt*H;t.font=`${K(-1)}px system-ui, sans-serif`,_t(t,j,new Set,m,F,v,r.limitLine),t.font=`${K(-1)}px system-ui, sans-serif`,t.strokeStyle=r.border,t.lineWidth=1,t.beginPath(),t.moveTo(f,v),t.lineTo(f+H,v),t.stroke(),t.fillStyle=r.textMuted,t.textAlign="center",t.textBaseline="top";const{ticks:g,step:e}=It(_,ut,H,Ot(t,dt,L)),p=Mt(dt,L,e||void 0);for(const c of g){const h=f+(c-_)/pt*H;t.beginPath(),t.moveTo(h,v),t.lineTo(h,v+4),t.stroke(),t.fillText(p.tick(c),h,v+6)}p.unitLabel&&(t.save(),t.font=`${K(-1)}px system-ui, sans-serif`,t.fillStyle=r.textMuted,t.textAlign="right",t.textBaseline="top",t.fillText(`(${p.unitLabel})`,f+H,v+20),t.restore())}function y(o){const{plotX:d,plotMaxWidth:l,barWidth:t}=st;if(o<d||o>d+l)return-1;const r=Math.floor((o-d)/t);return r>=0&&r<T.length?r:-1}w.addEventListener("mousemove",o=>{const d=w.getBoundingClientRect(),l=y(o.clientX-d.left);if(l!==I&&(I=l,P()),l>=0){const t=T[l],r=M.map((f,H)=>`<span style="${be(D(H))};margin-right:4px"></span>${wt(`${f.groupKey}: ${f.counts[l]}`)}`).join("<br>");C.innerHTML=`<strong>${wt(`${bt(t.rangeLow,L,"engineering")} \u2013 ${bt(t.rangeHigh,L,"engineering")}`)}</strong><br>${r}`,C.style.display="block",Rt(C,a,o.clientX,o.clientY)}else C.style.display="none"}),w.addEventListener("mouseleave",()=>{I!==-1&&(I=-1,P()),C.style.display="none"}),n.onSelectBucket&&k&&(w.style.cursor="pointer",w.addEventListener("click",o=>{const d=y(o.clientX-w.getBoundingClientRect().left);if(d<0||i===null)return;const l=b?k.filter(r=>r.key===b):k,t=$t(l.flatMap(r=>r.items),i,T,d,ft);t.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:T[d].rangeLow,high:T[d].rangeHigh,items:t,...b?{group:b}:{}},o))})),ct=Pt(a,()=>P()),P()}q();function Jt(s){St.set(s)&&(i=s,q())}function Zt(s){rt.set(s)&&q()}return{card:a,setTest:Jt,setAxisPrefs:Zt,destroy:()=>ct?.disconnect()}}