@wafertools/wafermap 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/AGENTS.md +13 -10
  2. package/CHANGELOG.md +474 -0
  3. package/README.md +7 -7
  4. package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
  5. package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
  6. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  7. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
  8. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
  9. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
  10. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  11. package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
  12. package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
  13. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
  15. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
  16. package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
  17. package/dist/packages/canvas-adapter/charts/index.js +1 -1
  18. package/dist/packages/canvas-adapter/charts/patCard.d.ts +21 -0
  19. package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
  20. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
  21. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
  23. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  26. package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
  27. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  28. package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
  29. package/dist/packages/canvas-adapter/dieList.js +2 -2
  30. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
  31. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
  32. package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
  33. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  34. package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
  35. package/dist/packages/canvas-adapter/filterButton.js +1 -0
  36. package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
  37. package/dist/packages/canvas-adapter/filterEditor.js +1 -0
  38. package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
  39. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  40. package/dist/packages/canvas-adapter/icons.js +1 -1
  41. package/dist/packages/canvas-adapter/index.d.ts +1 -0
  42. package/dist/packages/canvas-adapter/index.js +1 -1
  43. package/dist/packages/canvas-adapter/insightsTab.d.ts +57 -2
  44. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  45. package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
  46. package/dist/packages/canvas-adapter/pageFilter.js +2 -0
  47. package/dist/packages/canvas-adapter/patMaps.d.ts +26 -0
  48. package/dist/packages/canvas-adapter/patMaps.js +1 -0
  49. package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
  50. package/dist/packages/canvas-adapter/plotCard.js +1 -0
  51. package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
  52. package/dist/packages/canvas-adapter/plotEditor.js +1 -1
  53. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  54. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  55. package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
  56. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  57. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
  58. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  59. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +71 -37
  60. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  61. package/dist/packages/canvas-adapter/summaryPanel.d.ts +22 -9
  62. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  63. package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
  64. package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
  65. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  66. package/dist/packages/canvas-adapter/toolbar.d.ts +12 -6
  67. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  68. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  69. package/dist/packages/canvas-adapter/userGuideHtml.js +607 -117
  70. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  71. package/dist/packages/canvas-adapter/version.js +1 -1
  72. package/dist/packages/canvas-adapter/warnings.js +1 -1
  73. package/dist/packages/core/aggregates.d.ts +10 -0
  74. package/dist/packages/core/aggregates.js +1 -1
  75. package/dist/packages/core/classify.d.ts +11 -0
  76. package/dist/packages/core/classify.js +1 -1
  77. package/dist/packages/core/dieTable.d.ts +5 -0
  78. package/dist/packages/core/dieTable.js +1 -1
  79. package/dist/packages/core/dies.d.ts +2 -0
  80. package/dist/packages/core/dies.js +1 -1
  81. package/dist/packages/core/wafer.d.ts +10 -1
  82. package/dist/packages/core/wafer.js +1 -1
  83. package/dist/packages/renderer/buildView.d.ts +5 -0
  84. package/dist/packages/renderer/buildView.js +1 -1
  85. package/dist/packages/renderer/buildWaferMap.d.ts +21 -4
  86. package/dist/packages/renderer/buildWaferMap.js +1 -1
  87. package/dist/packages/renderer/deprecate.d.ts +2 -8
  88. package/dist/packages/renderer/deprecate.js +1 -1
  89. package/dist/packages/renderer/derivedTests/parser.js +1 -1
  90. package/dist/packages/renderer/fmt.d.ts +10 -0
  91. package/dist/packages/renderer/fmt.js +1 -1
  92. package/dist/packages/renderer/index.d.ts +1 -0
  93. package/dist/packages/renderer/index.js +1 -1
  94. package/dist/packages/renderer/testLabel.d.ts +0 -11
  95. package/dist/packages/renderer/testLabel.js +1 -1
  96. package/dist/packages/renderer/valueFilter.d.ts +1 -1
  97. package/dist/packages/renderer/valueFilter.js +1 -1
  98. package/dist/packages/stats/analyzeWaferLot.d.ts +22 -0
  99. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  100. package/dist/packages/stats/analyzeWaferMap.d.ts +26 -1
  101. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  102. package/dist/packages/stats/binPareto.d.ts +2 -54
  103. package/dist/packages/stats/binPareto.js +1 -1
  104. package/dist/packages/stats/binRows.js +1 -1
  105. package/dist/packages/stats/capability.d.ts +10 -0
  106. package/dist/packages/stats/capability.js +1 -1
  107. package/dist/packages/stats/cardSpec.d.ts +53 -0
  108. package/dist/packages/stats/cardSpec.js +1 -0
  109. package/dist/packages/stats/chartCatalogue.d.ts +37 -0
  110. package/dist/packages/stats/chartCatalogue.js +1 -0
  111. package/dist/packages/stats/clusterDetection.d.ts +9 -0
  112. package/dist/packages/stats/clusterDetection.js +1 -1
  113. package/dist/packages/stats/commonality.d.ts +62 -0
  114. package/dist/packages/stats/commonality.js +1 -0
  115. package/dist/packages/stats/connectedComponents.js +1 -1
  116. package/dist/packages/stats/control.d.ts +21 -0
  117. package/dist/packages/stats/control.js +1 -0
  118. package/dist/packages/stats/correlation.d.ts +42 -4
  119. package/dist/packages/stats/correlation.js +1 -1
  120. package/dist/packages/stats/dieRegions.d.ts +4 -1
  121. package/dist/packages/stats/dieRegions.js +1 -1
  122. package/dist/packages/stats/differenceMap.d.ts +22 -0
  123. package/dist/packages/stats/differenceMap.js +1 -0
  124. package/dist/packages/stats/examplePicks.d.ts +22 -0
  125. package/dist/packages/stats/examplePicks.js +1 -0
  126. package/dist/packages/stats/filterFile.d.ts +41 -0
  127. package/dist/packages/stats/filterFile.js +2 -0
  128. package/dist/packages/stats/filterFindings.d.ts +21 -6
  129. package/dist/packages/stats/filterFindings.js +1 -1
  130. package/dist/packages/stats/findingText.d.ts +8 -0
  131. package/dist/packages/stats/findingText.js +2 -2
  132. package/dist/packages/stats/groupCompare.d.ts +87 -0
  133. package/dist/packages/stats/groupCompare.js +1 -0
  134. package/dist/packages/stats/guideSections.d.ts +55 -0
  135. package/dist/packages/stats/guideSections.js +1 -0
  136. package/dist/packages/stats/index.d.ts +5 -2
  137. package/dist/packages/stats/index.js +1 -1
  138. package/dist/packages/stats/lotDrift.js +1 -1
  139. package/dist/packages/stats/math.d.ts +29 -4
  140. package/dist/packages/stats/math.js +1 -1
  141. package/dist/packages/stats/mergeTestDefs.js +1 -1
  142. package/dist/packages/stats/metadataColumns.d.ts +3 -0
  143. package/dist/packages/stats/metadataColumns.js +1 -1
  144. package/dist/packages/stats/pat.d.ts +58 -0
  145. package/dist/packages/stats/pat.js +1 -0
  146. package/dist/packages/stats/patSummary.d.ts +45 -0
  147. package/dist/packages/stats/patSummary.js +1 -0
  148. package/dist/packages/stats/patternClassification.d.ts +3 -3
  149. package/dist/packages/stats/patternClassification.js +1 -1
  150. package/dist/packages/stats/plotData.d.ts +294 -17
  151. package/dist/packages/stats/plotData.js +1 -1
  152. package/dist/packages/stats/plotId.d.ts +2 -0
  153. package/dist/packages/stats/plotId.js +1 -1
  154. package/dist/packages/stats/plotReferences.d.ts +17 -0
  155. package/dist/packages/stats/plotReferences.js +1 -0
  156. package/dist/packages/stats/plotSpec.d.ts +239 -3
  157. package/dist/packages/stats/plotSpec.js +4 -4
  158. package/dist/packages/stats/regions.js +1 -1
  159. package/dist/packages/stats/renderSummaryReport.js +33 -33
  160. package/dist/packages/stats/reportHtml.d.ts +5 -12
  161. package/dist/packages/stats/reportHtml.js +98 -40
  162. package/dist/packages/stats/synthesis.d.ts +48 -16
  163. package/dist/packages/stats/synthesis.js +1 -1
  164. package/dist/packages/stats/testPassRate.d.ts +7 -0
  165. package/dist/packages/stats/testPassRate.js +1 -1
  166. package/dist/packages/stats/testValueBudget.d.ts +15 -0
  167. package/dist/packages/stats/testValueBudget.js +1 -0
  168. package/dist/packages/stats/types.d.ts +90 -30
  169. package/dist/packages/stats/yield.d.ts +3 -11
  170. package/dist/packages/stats/yield.js +1 -1
  171. package/llms.txt +1 -1
  172. package/package.json +2 -1
  173. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
  174. package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
  175. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
  176. package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
  177. package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
  178. package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
  179. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
  180. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
  181. package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
  182. package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
  183. package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
  184. package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
  185. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
  186. package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
  187. package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
  188. package/dist/packages/canvas-adapter/charts/trend.js +0 -1
@@ -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 b=u.selectedTestNumber??ie[0]?.testNumber??null,le=!1,F=0,w=null,D=null,se=null,we=null;function ye(){const i=!g||g.length===0?"":w??"\0overview";if(se&&we===i)return se;const p=!g||g.length===0?Ge:w!==null?g.find(k=>k.key===w)?.items??[]:g.map(k=>({label:k.key,dies:k.items.flatMap(T=>T.dies??[])}));return se=p,we=i,p}function Te(){w!==null&&!D?(D=ht(()=>{ve(null),u.onGroupChange?.(null)},a.ownerDocument),U.appendChild(D)):w===null&&D&&(D.remove(),D=null),ze.textContent=w!==null?`${ne} \u2014 ${oe}: ${w}`:ne}function ve(i){return w===i||i!==null&&!(g??[]).some(p=>p.key===i)?!1:(w=i,Te(),j(),S(),!0)}const ke=gt(ie,b,i=>{b=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&&w===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`:"")+(b!==null?Wt(ye().flatMap(T=>T.dies??[]),b):"")}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||b===null){Oe(x,"No parametric test data available for box plots.");return}const T=ye(),h=rt(T,b),K=be.find(t=>t.testNumber===b),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 y=L+f*(A+$),r=y+A/2;f===N&&(e.fillStyle=t.bgHover,e.fillRect(0,y-$/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=y+3,z=y+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),y=e.measureText(o.label).width,r=At(f,y,l,l+c,o.end==="lo"),te=r<0?f-3-y:f+3;return{l:o,x:f,dir:r,start:te,end:te+y}}),tt=It(Ie),nt=_(-1)+2;Ie.forEach(({l:o,x:f,dir:y},r)=>{Bt(e,o,t.limitLine,f,0,f,v),e.fillStyle=t.limitLine,e.textAlign=y<0?"right":"left",e.textBaseline="bottom",e.fillText(o.label,f+y*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&&w===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&&b!==null&&Q(d,b)}),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,b??void 0,t))}),ce?.disconnect(),ce=dt(a,()=>ee()),ee()}S();function Ue(i){ke.set(i)&&(b=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()}}
@@ -1,80 +0,0 @@
1
- import { type ScatterItem, type ScatterPoint } from '../../stats/scatter.js';
2
- import { type FacetItem } from '../../stats/facets.js';
3
- import type { TestDef } from '../../renderer/buildWaferMap.js';
4
- import { type SaveImageHandler, type AxisPrefs } from './chartShell.js';
5
- type ScatterPanelItem = FacetItem & ScatterItem & {
6
- label?: string;
7
- };
8
- export declare const NO_BIN_CATEGORY = "none";
9
- export declare function binCategoryOf(hbin: number | undefined): string;
10
- /** Legend order: bins ascending, then "No bin data" last. */
11
- export declare function binCategories(points: readonly Pick<ScatterPoint, 'hbin'>[]): string[];
12
- export interface ScatterPanelOptions {
13
- title?: string;
14
- items: ScatterPanelItem[];
15
- testDefs: TestDef[];
16
- xTestNumber?: number;
17
- yTestNumber?: number;
18
- /**
19
- * The host map's resolved hard-bin colours (`View.binColors.hard`), so a
20
- * point is the colour its die is on the map. Omitted ⇒ points without a
21
- * group colour take the no-data fill.
22
- */
23
- binColors?: ReadonlyMap<number, string>;
24
- onSaveImage?: SaveImageHandler;
25
- /**
26
- * When the Analysis tab's "Group by" is active, every group's points are
27
- * plotted together (never restricted to one group, unlike capability/
28
- * correlation) but coloured by group instead of hard bin, with a
29
- * click-to-filter legend keyed on group instead of bin. `items` above is
30
- * used to compute the Simpson's-paradox warning when `groups` is absent;
31
- * ignored for point data when `groups` is provided.
32
- */
33
- groups?: {
34
- key: string;
35
- items: ScatterPanelItem[];
36
- }[];
37
- /**
38
- * The Insights tab's shared axis preferences. Scatter reads only `limits`
39
- * (which limit lines to draw), and offers the "Limits:" choice when either
40
- * axis's test has both test and spec limits.
41
- */
42
- axisPrefs?: AxisPrefs;
43
- /** Called when the user changes the "Limits:" choice here. */
44
- onAxisPrefsChange?: (prefs: AxisPrefs) => void;
45
- /**
46
- * Click a point to open its die's wafer, on the X test — the same
47
- * `(waferIndex, testNumber)` the boxplot and trend use. Needs each item's
48
- * `waferIndex`; a point without one is not clickable. Omit for no click action.
49
- */
50
- onOpen?: (waferIndex: number, testNumber: number) => void;
51
- /** What a click does, in the reader's words, when it is not "open this wafer" (a single-wafer host
52
- * shows the X test on its map instead). Default `open this wafer`. */
53
- openActionLabel?: string;
54
- /**
55
- * Drag a rectangle over the plot to select the dies inside it (only points the
56
- * legend filter leaves visible). Called on release with those points, the
57
- * pointer position and the canvas, so the host can open a menu there. The
58
- * selection stays ringed until X/Y change or a click on empty space.
59
- */
60
- onSelect?: (points: ScatterPoint[], at: {
61
- x: number;
62
- y: number;
63
- }, anchor: HTMLElement, xTestNumber: number) => void;
64
- /** Document to build this panel's DOM into. Default `document` — pass the
65
- * host's own `ownerDocument` when the container might live in a
66
- * different document (e.g. a gallery card detached into its own popup
67
- * window). */
68
- ownerDocument?: Document;
69
- }
70
- export interface ScatterPanelHandle {
71
- card: HTMLElement;
72
- /** Cross-panel link (e.g. from the correlation matrix): switch X/Y in place. */
73
- setXY: (xTestNumber: number, yTestNumber: number) => void;
74
- /** Adopt axis preferences chosen in another panel (only `limits` applies). */
75
- setAxisPrefs: (prefs: AxisPrefs) => void;
76
- destroy: () => void;
77
- }
78
- export declare function renderScatterPanel(options: ScatterPanelOptions): ScatterPanelHandle;
79
- export {};
80
- //# sourceMappingURL=scatter.d.ts.map
@@ -1 +0,0 @@
1
- import{NO_DATA_FILL as Fe}from"../../renderer/colorMap.js";import{escHtml as Z,maxOf as se,minOf as _e}from"../../core/utils.js";import{fmt as je}from"../../renderer/fmt.js";import{categorical as dt}from"./palette.js";import{buildScatterData as ft,buildScatterDataGrouped as mt}from"../../stats/scatter.js";import{pearsonOfPairs as ut}from"../../stats/correlation.js";import{buildFacetTable as pt}from"../../stats/facets.js";import{SPACE as B,RADIUS as xt,fontPx as N,FONT as ge,CLR as ee}from"../toolbar.js";import{fitTicks as Ge}from"../../renderer/axisTicks.js";import{wirePointInteractions as ht}from"./pointInteractions.js";import{placeClearOf as Xe,cardShell as bt,observeResize as yt,makeTooltip as gt,attachChartTip as wt,makeTestSelect as St,makeWaferSelect as Tt,chartFillHeight as kt,applyCanvasFlow as Mt,drawAxisUnit as vt,resolveChartCanvasColors as Ct,makeAxisFormat as le,horizontalTickSpacing as Lt,VERTICAL_TICK_SPACING_PX as Ot,makeSeriesLegendItem as At,prepareCanvas as Pt,drawOffAxisLimits as Ye,limitLines as $t,hasBothLimitKinds as It,makeLimitsSelect as Dt,stackLabelRows as Ue,strokeLimitLine as Ke,fillTextOnHalo as Ve}from"./chartShell.js";const p=52,Bt=16,c=16,Et=44;export const NO_BIN_CATEGORY="none";export function binCategoryOf(x){return x===void 0?NO_BIN_CATEGORY:String(x)}export function binCategories(x){const te=new Set;let v=!1;for(const R of x)R.hbin===void 0?v=!0:te.add(R.hbin);const O=Array.from(te).sort((R,ae)=>R-ae).map(String);return v&&O.push(NO_BIN_CATEGORY),O}export function renderScatterPanel(x){const{title:te="Test scatter",items:v,testDefs:O,binColors:R,onSaveImage:ae,groups:_}=x,{card:l,body:H,controlsRow:re}=bt(te,ae,x.ownerDocument),ne=O.filter(e=>e.testNumber!==void 0),A=!!(_&&_.length>0),we=(_??[]).map(e=>e.key),qe=new Map(we.map((e,n)=>[e,n]));let f=x.xTestNumber??ne[0]?.testNumber??null,w=x.yTestNumber??ne[1]?.testNumber??f,j=null;const Se=()=>j!==null?v[j]?[v[j]]:[]:v;function Te(e,n,o){const a=l.ownerDocument.createElement("label");Object.assign(a.style,{display:"inline-flex",alignItems:"center",gap:B.xs,fontSize:ge.body,color:ee.label});const y=l.ownerDocument.createElement("span");y.textContent=e;const r=St(ne,n,o,{maxWidth:"180px",emptyText:"No tests",ownerDocument:l.ownerDocument});return a.append(y,r),{wrap:a,select:r}}const{wrap:Je,select:Qe}=Te("X:",f,e=>{f=e,K()}),{wrap:Ze,select:et}=Te("Y:",w,e=>{w=e,K()});re.append(Je,Ze);let P=x.axisPrefs??{clipOutliers:!1};const ke=l.ownerDocument.createElement("span");re.appendChild(ke);function Me(){const e=[f,w].map(n=>O.find(o=>o.testNumber===n));ke.replaceChildren(...e.some(It)?[Dt(P.limits??"both",n=>{P={...P,limits:n},x.onAxisPrefsChange?.(P),L()},l.ownerDocument)]:[])}!A&&v.length>1&&re.appendChild(Tt(v,j,e=>{j=e,K()},{ownerDocument:l.ownerDocument}));const F=l.ownerDocument.createElement("div");F.dataset.wmapCaption="1",Object.assign(F.style,{color:ee.warnText,background:ee.warnBg,border:`1px solid ${ee.warnBorder}`,borderRadius:xt.control,padding:`${B.xs} ${B.md}`,fontSize:ge.body,marginBottom:B.xs,display:"none"}),l.insertBefore(F,H);function ve(){const e=A?[]:pt(Se(),{facetableOnly:!0}).filter(n=>n.splittable).map(n=>n.label);e.length>0?(F.textContent=`\u26A0 Mixed ${e.join(", ")} across these points \u2014 trends here may be confounded (Simpson's paradox). Use Group by, or the Wafer picker, to narrow to a like-for-like set.`,F.style.display=""):F.style.display="none"}ve();const oe=l.ownerDocument.createElement("div");oe.dataset.wmapCaption="1",Object.assign(oe.style,{color:ee.label,fontSize:ge.body,marginBottom:B.xs}),l.insertBefore(oe,H);function G(){const e=(A?"One point per die \xB7 coloured by group \xB7 click legend to filter":"One point per die across all wafers \xB7 coloured by hard bin \xB7 click legend to filter")+(fe?` \xB7 click a point to ${Oe}`:"")+(de?C.size>0?` \xB7 ${C.size.toLocaleString()} selected (click empty space to clear)`:" \xB7 drag to select dies":""),n=h.size===0?b:b.filter(y=>h.has(E(y))),{r:o,n:a}=ut(n);oe.textContent=o===null?`${e} \xB7 n = ${a.toLocaleString()}`:`${e} \xB7 r = ${o.toFixed(3)} \xB7 n = ${a.toLocaleString()}`}const E=e=>A?e.group??"\u2014":binCategoryOf(e.hbin),Ce=e=>A?dt(qe.get(e)??0):e===NO_BIN_CATEGORY?Fe:R?.get(Number(e))??Fe,ce=e=>A?e:e===NO_BIN_CATEGORY?"No bin data":`Bin ${e}`,h=new Set,X=l.ownerDocument.createElement("div");Object.assign(X.style,{display:"flex",flexWrap:"wrap",gap:B.sm,marginTop:B.md,marginBottom:B.xl}),H.appendChild(X);const $=l.ownerDocument.createElement("canvas");$.style.display="block",$.style.cursor="crosshair",H.appendChild($);const Le=gt(l);let b=[],g=0,I=1,S=0,W=1,Y=[],ie=null;const C=new Set,de=x.onSelect,fe=x.onOpen,Oe=x.openActionLabel??"open this wafer",Ae=new Map;for(const e of[...v,...(_??[]).flatMap(n=>n.items)])e.waferIndex!==void 0&&e.label&&Ae.set(e.waferIndex,e.label);function U(e){const n=O.find(o=>o.testNumber===e);return{unit:n?.unit,lines:$t(n,P.limits)}}function Pe(){const e=H.clientWidth,n=Math.max(200,Math.min(400,e*.65)),o=kt(l,H,$,n);return{w:e,h:o,plotW:Math.max(10,e-p-Bt),plotH:Math.max(10,o-c-Et)}}const me=new Map;function $e(){for(const[e,n]of me){const o=h.has(e);n.setState({selected:o,dimmed:h.size>0&&!o})}}function Ie(e){X.innerHTML="",me.clear(),h.clear();for(const n of e){const o=At(ce(n),Ce(n),l.ownerDocument),a=o.el;a.dataset.cat=n,me.set(n,o),wt(a,l,Le,`${ce(n)} \u2014 click to filter`),a.addEventListener("click",()=>{h.has(n)?h.delete(n):h.add(n),$e(),G(),L()}),X.appendChild(a)}$e()}function L(){Mt($,X);const e=Ct(l),n=I-g,o=W-S,{w:a,h:y,plotW:r,plotH:s}=Pe(),z=Pt($,l,a,y);if(!z)return;const{ctx:t}=z;if(b.length===0){Y=[],t.font=`${N()}px system-ui, sans-serif`,t.fillStyle=e.textMuted,t.textAlign="center",t.textBaseline="middle",t.fillText("No data \u2014 select two parametric tests with values.",a/2,y/2);return}t.font=`${N(-1)}px system-ui, sans-serif`;const M=f!==null?U(f).unit:void 0,V=Ge(g,I,r,Lt(t,Math.max(Math.abs(g),Math.abs(I)),M)),q=Ge(S,W,s,()=>Ot),ue=le(Math.max(Math.abs(g),Math.abs(I)),f!==null?U(f).unit:void 0,V.step||void 0),pe=le(Math.max(Math.abs(S),Math.abs(W)),w!==null?U(w).unit:void 0,q.step||void 0);t.font=`${N(-1)}px system-ui, sans-serif`,t.strokeStyle=e.grid,t.lineWidth=.5,t.fillStyle=e.textMuted;for(const m of V.ticks){const d=p+(m-g)/n*r;t.beginPath(),t.moveTo(d,c),t.lineTo(d,c+s),t.stroke(),t.textAlign="center",t.textBaseline="top",t.fillText(ue.tick(m),d,c+s+4)}for(const m of q.ticks){const d=c+(1-(m-S)/o)*s;t.beginPath(),t.moveTo(p,d),t.lineTo(p+r,d),t.stroke(),t.textAlign="right",t.textBaseline="middle",t.fillText(pe.tick(m),p-4,d)}ue.unitLabel&&vt(t,ue.unitLabel,p+r/2,c+s+24,e.textMuted),pe.unitLabel&&(t.save(),t.font=`${N(-1)}px system-ui, sans-serif`,t.fillStyle=e.textMuted,t.textAlign="center",t.textBaseline="middle",t.translate(6,c+s/2),t.rotate(-Math.PI/2),t.fillText(`(${pe.unitLabel})`,0,0),t.restore());const J=h.size===0?b:b.filter(m=>h.has(E(m))),Be=J.length>5e3?Math.ceil(J.length/5e3):1;t.globalAlpha=Math.max(.15,Math.min(.7,200/(J.length/Be))),Y=[];for(let m=0;m<J.length;m+=Be){const d=J[m],T=p+(d.x-g)/n*r,D=c+(1-(d.y-S)/o)*s;Y.push({p:d,cx:T,cy:D}),t.beginPath(),t.arc(T,D,2.5,0,Math.PI*2),t.fillStyle=Ce(E(d)),t.fill()}t.globalAlpha=1;const xe=ie?Y.find(m=>m.p===ie):void 0;if(xe&&(t.beginPath(),t.arc(xe.cx,xe.cy,5,0,Math.PI*2),t.lineWidth=2,t.strokeStyle=e.text,t.stroke()),C.size>0){t.lineWidth=1.5,t.strokeStyle=e.text;let m=0;for(const d of C){if(h.size>0&&!h.has(E(d)))continue;if(++m>5e3)break;const T=p+(d.x-g)/n*r,D=c+(1-(d.y-S)/o)*s;t.beginPath(),t.arc(T,D,4,0,Math.PI*2),t.stroke()}}if(f!==null&&w!==null){const m=U(f),d=U(w);t.strokeStyle=e.limitLine,t.fillStyle=e.limitLine,t.lineWidth=1,t.font=`${N(-1)}px system-ui, sans-serif`,t.textBaseline="top";const T=N(-1)+2,D=m.lines.filter(i=>i.value>=g&&i.value<=I).map(i=>{const u=p+(i.value-g)/n*r;return{l:i,cx:u,start:u+2,end:u+2+t.measureText(i.label).width}}),Ee=Ue(D),We=[];D.forEach(({l:i,cx:u,start:Q,end:k},ye)=>{Ke(t,i,e.limitLine,u,c,u,c+s),t.textAlign="left";const He=c+2+Ee[ye]*T,ct=Xe(We,{x0:Q,x1:k,y0:He,y1:He+T},T);Ve(t,i.label,u+2,ct.y0,e.bg)});const he=d.lines.filter(i=>i.value>=S&&i.value<=W).map(i=>{const u=c+(1-(i.value-S)/o)*s;return{l:i,cy:u,start:u+2,end:u+2+N(-1)}}),lt=Ue(he,1),at=se(he.map(i=>t.measureText(i.l.label).width))+8;he.forEach(({l:i,cy:u},Q)=>{Ke(t,i,e.limitLine,p,u,p+r,u),t.textAlign="left";const k=p+3+lt[Q]*at,ye=Xe(We,{x0:k,x1:k+t.measureText(i.label).width,y0:u+2,y1:u+2+T},T);Ve(t,i.label,k,ye.y0,e.bg)});const ze=(i,u,Q)=>i.filter(k=>k.value<u||k.value>Q).map(k=>({value:k.value,label:k.label,side:k.value<u?"lo":"hi"})),Ne={left:p,right:p+r,top:c,bottom:c+s},be=ze(m.lines,g,I),Re=c+(D.length?(se(Ee)+1)*T:0),rt=Math.max(be.filter(i=>i.side==="lo").length,be.filter(i=>i.side==="hi").length);Ye(t,be,{...Ne,top:Re},"horizontal",e.limitLine,i=>le(Math.abs(i),m.unit).tick(i),e.bg),Ye(t,ze(d.lines,S,W),{...Ne,top:Re+rt*T},"vertical",e.limitLine,i=>le(Math.abs(i),d.unit).tick(i),e.bg),t.setLineDash([])}t.strokeStyle=e.border,t.lineWidth=1,t.beginPath(),t.moveTo(p,c),t.lineTo(p,c+s),t.moveTo(p,c+s),t.lineTo(p+r,c+s),t.stroke()}function K(){if(ie=null,C.clear(),ve(),Me(),ne.length<2||f===null||w===null){b=[],Ie([]),G(),L();return}b=A?mt(_,f,w):ft(Se(),f,w);let e;if(A){const n=new Set(b.map(E));e=we.filter(o=>n.has(o))}else e=binCategories(b);if(Ie(e),G(),b.length>0){const n=b.map(M=>M.x),o=b.map(M=>M.y),a=_e(n),y=se(n),r=_e(o),s=se(o),z=(y-a)*.05||1,t=(s-r)*.05||1;g=a-z,I=y+z,S=r-t,W=s+t}L()}const De=e=>!!fe&&e.waferIndex!==void 0;function tt(e){const n=O.find(s=>s.testNumber===f),o=O.find(s=>s.testNumber===w),a=e.waferIndex!==void 0?Ae.get(e.waferIndex):void 0,y=e.die&&e.die.x!==void 0?`die (${e.die.x}, ${e.die.y})`:"",r=[a,y].filter(Boolean).join(" \xB7 ");return(r?`<strong>${Z(r)}</strong><br>`:"")+Z(`${n?.name??"X"}: ${je(e.x,n?.unit)}`)+"<br>"+Z(`${o?.name??"Y"}: ${je(e.y,o?.unit)}`)+"<br>"+Z(ce(E(e)))+(De(e)?`<br><em>click to ${Z(Oe)}</em>`:"")}const nt=ht({card:l,canvas:$,tooltip:Le,drawn:()=>Y,describe:tt,clickable:De,onOpen:e=>{f!==null&&fe(e.waferIndex,f)},onHover:e=>{ie=e,L()},select:de?{pick:({x0:e,y0:n,x1:o,y1:a})=>{const{plotW:y,plotH:r}=Pe(),s=I-g,z=W-S;return(h.size===0?b:b.filter(M=>h.has(E(M)))).filter(M=>{const V=p+(M.x-g)/s*y,q=c+(1-(M.y-S)/z)*r;return V>=e&&V<=o&&q>=n&&q<=a})},onPicked:(e,n)=>{C.clear();for(const o of e)C.add(o);G(),L(),e.length>0&&f!==null&&de(e,n,$,f)},onClear:()=>{C.clear(),G(),L()},hasSelection:()=>C.size>0}:void 0}),ot=yt(l,()=>L());K();function it(e,n){f=e,w=n,Qe.value=String(e),et.value=String(n),K()}function st(e){if((e.limits??"both")===(P.limits??"both")){P=e;return}P=e,Me(),L()}return{card:l,setXY:it,setAxisPrefs:st,destroy:()=>{ot.disconnect(),nt.destroy()}}}
@@ -1,27 +0,0 @@
1
- import { type TestPassKind } from '../../stats/testPassRate.js';
2
- import type { TestPassRateItem } from '../../stats/testPassRate.js';
3
- import type { TestDef } from '../../renderer/buildWaferMap.js';
4
- import { type SaveImageHandler } from './chartShell.js';
5
- export interface TestPassRatePanelOptions {
6
- title?: string;
7
- /** One entry per group. Pass a single group for the ungrouped case. */
8
- groups: {
9
- key: string;
10
- items: TestPassRateItem[];
11
- }[];
12
- testDefs: TestDef[] | undefined;
13
- onSaveImage?: SaveImageHandler;
14
- /** Click a test's row: the host picks out the dies that fail it (judged the way the card is showing). */
15
- onSelectTest?: (row: {
16
- testNumber: number;
17
- label: string;
18
- kind: TestPassKind;
19
- }, e: MouseEvent) => void;
20
- ownerDocument?: Document;
21
- }
22
- export interface TestPassRatePanelHandle {
23
- card: HTMLElement;
24
- destroy: () => void;
25
- }
26
- export declare function renderTestPassRatePanel(options: TestPassRatePanelOptions): TestPassRatePanelHandle;
27
- //# sourceMappingURL=testPassRate.d.ts.map
@@ -1 +0,0 @@
1
- import{buildTestPassRateData as F,hasJudgeableTests as E}from"../../stats/testPassRate.js";import{categorical as I,QUANTITY as B}from"./palette.js";import{SPACE as _,FONT as H,CLR as L}from"../toolbar.js";import{cardShell as A,makeTooltip as O,makeSegmented as j,renderEmptyState as y}from"./chartShell.js";import{renderGroupedBarPlot as k}from"./groupedBarPlot.js";import{escHtml as f}from"../../core/utils.js";const M=100,G=8,K={spec:"Test limits",testFlag:"Tester flag",functional:"Functional"},J={spec:"Judged from each die's measured value against the test's limits",testFlag:"The pass or fail the tester recorded for each die",functional:"Tests that only pass or fail and have no measured value"},U={spec:"Parametric pass rate \xB7 test limits",testFlag:"Parametric pass rate \xB7 tester flag",functional:"Functional test pass rate"};export function renderTestPassRatePanel(i){const{groups:h,testDefs:b,onSaveImage:v}=i,p=i.ownerDocument??document,$=h.flatMap(e=>e.items.flatMap(o=>o.dies??[])),m=["spec","testFlag","functional"].filter(e=>E(b,e,$));let s=m[0]??"spec";const T=e=>U[e],{card:n,heading:C,body:c,controlsRow:P}=A(T(s),v,p);n.style.alignSelf="start",m.length>1&&P.appendChild(j(m.map(e=>[e,K[e],J[e]]),s,e=>{s=e,C.textContent=T(s),S()},p));const r=p.createElement("div");r.dataset.wmapCaption="1",Object.assign(r.style,{color:L.label,fontSize:H.body,marginBottom:_.sm}),n.insertBefore(r,c);const D=O(n);let g=null;function S(){if(g?.destroy(),g=null,c.innerHTML="",m.length===0){r.textContent="",y(c,"No tests with a pass/fail verdict \u2014 parametric tests need test limits, functional tests need recorded results.");return}const e=F(h,b,s);if(e.rows.length===0){r.textContent="",y(c,s==="spec"?"No parametric test has test limits to judge against.":s==="testFlag"?"No parametric test has a recorded tester verdict.":"No functional test has recorded results.");return}const o=e.groups.length>1,R=s==="spec"?"Dies within test limits, per test":s==="testFlag"?"Dies the tester marked pass, per test":"Dies passing the recorded verdict, per test";if(r.textContent=R+(o?" \xB7 one bar per group":"")+" \xB7 worst first"+(i.onSelectTest?" \xB7 click a test to chart or tabulate the dies that fail it":""),e.disagreementDies){const t=p.createElement("span");t.textContent=` \xB7 ${e.disagreementDies.toLocaleString()} die${e.disagreementDies===1?"":"s"} judged differently by limits and tester flag`,Object.assign(t.style,{color:L.warnText}),r.appendChild(t)}const u=e.rows,x=t=>o?I(t):B;g=k(n,c,D,{rows:u.map(t=>({label:t.label,bars:t.byGroup.map(l=>({fraction:l.passRatePercent===null?null:l.passRatePercent/100})),trailing:t.overall.passRatePercent===null?"\u2014":`${t.overall.passRatePercent.toFixed(1)}%`})),groups:e.groups,labelWidth:M,maxVisibleRows:G,showLegend:o,maxLabelChars:14,emptyBarText:"no data",colorOf:x,onRowClick:i.onSelectTest?(t,l,a)=>i.onSelectTest({testNumber:u[t].testNumber,label:u[t].label,kind:s},a):void 0,tooltipHtml:(t,l)=>{const a=u[t],d=a.byGroup[l],w=o?` \xB7 ${f(String(e.groups[l]))}`:"";if(d.passRatePercent===null)return`<strong>${f(a.label)}</strong>${w}<br>no dies with a verdict`;const N=s==="spec"&&!o&&(a.failLowDies||a.failHighDies)?`<br>${a.failLowDies??0} below the low limit \xB7 ${a.failHighDies??0} above the high limit`:"";return`<strong>${f(a.label)}</strong>${w}<br>${d.passRatePercent.toFixed(1)}% pass<br>${d.passDies.toLocaleString()} pass \xB7 ${d.failDies.toLocaleString()} fail \xB7 n = ${d.totalDies.toLocaleString()}`+N}})}return S(),{card:n,destroy:()=>{g?.destroy(),D.remove(),n.remove()}}}
@@ -1,50 +0,0 @@
1
- import { type TrendItem } from '../../stats/trend.js';
2
- import { type TestDef } from '../../renderer/buildWaferMap.js';
3
- import { type AxisPrefs, type SaveImageHandler, type WaferContextMenuHandler } from './chartShell.js';
4
- export interface TrendPanelOptions {
5
- title?: string;
6
- items: TrendItem[];
7
- testDefs: TestDef[];
8
- selectedTestNumber?: number;
9
- onSaveImage?: SaveImageHandler;
10
- /** Click a point to open that wafer's map on this test. */
11
- onOpen?: (key: number, testNumber: number) => void;
12
- /** Right-click on a wafer's point — see `WaferContextMenuHandler`. */
13
- onWaferContextMenu?: WaferContextMenuHandler;
14
- /**
15
- * Drag across the trend to pick a run of wafers: their `key`s (the wafer indexes), the test shown, where the pointer
16
- * was released and the canvas to anchor a menu on. The wafers' own dies are the population.
17
- */
18
- onSelectWafers?: (sel: {
19
- keys: number[];
20
- testNumber: number;
21
- }, at: {
22
- x: number;
23
- y: number;
24
- }, anchor: HTMLElement) => void;
25
- /**
26
- * What the dashed reference line is, as a noun phrase — "lot mean" when the
27
- * items are one lot, else "mean of all wafers" (see stats/population.ts).
28
- * The panel sees no wafer metadata, so the host names it. Default
29
- * "mean of all wafers", which is true of any set.
30
- */
31
- centreLabel?: string;
32
- /** Initial axis toggles, shared with the sibling distribution panels. */
33
- axisPrefs?: AxisPrefs;
34
- /** Fired when the user changes an axis toggle here, so siblings can follow. */
35
- onAxisPrefsChange?: (prefs: AxisPrefs) => void;
36
- /** Fired when the USER picks a test here, so siblings can follow. Not fired
37
- * by `setTest`, which is how a broadcast avoids bouncing back. */
38
- onTestChange?: (testNumber: number) => void;
39
- ownerDocument?: Document;
40
- }
41
- export interface TrendPanelHandle {
42
- card: HTMLElement;
43
- destroy: () => void;
44
- /** Cross-panel link — switch the displayed test in place. */
45
- setTest: (testNumber: number) => void;
46
- /** Adopt the shared axis toggles (see `AxisPrefs`). */
47
- setAxisPrefs: (prefs: AxisPrefs) => void;
48
- }
49
- export declare function renderTrendPanel(options: TrendPanelOptions): TrendPanelHandle;
50
- //# sourceMappingURL=trend.d.ts.map
@@ -1 +0,0 @@
1
- import{buildTestTrendData as Se,trendCentre as Ce}from"../../stats/trend.js";import{isParametricTest as Ae}from"../../renderer/buildWaferMap.js";import{fmt as H}from"../../renderer/fmt.js";import{SPACE as ce,fontPx as me,FONT as Pe,CLR as Me}from"../toolbar.js";import{QUANTITY as X}from"./palette.js";import{wirePointInteractions as Ne}from"./pointInteractions.js";import{cardShell as Ie,observeResize as We,makeTooltip as Ee,makeLinkedTestSelect as De,makeLinkedAxisPrefs as Oe,renderEmptyState as j,chartFillHeight as He,PADDING as K,resolveAxisRange as $e,shouldIncludeLimitsByDefault as Re,drawOffAxisLimits as _e,limitLines as fe,limitExtent as de,hasBothLimitKinds as Be,stackLabelRows as Fe,strokeLimitLine as ze,makeAxisFormat as Ge,VERTICAL_TICK_SPACING_PX as Ue,WAFER_MENU_HINT as Xe,prepareCanvas as je}from"./chartShell.js";import{fitTicks as Ke}from"../../renderer/axisTicks.js";import{escHtml as Q}from"../../core/utils.js";import{maxOf as Qe}from"../../core/utils.js";const ue=220,Ve=56,Ye=34,he=3.5;export function renderTrendPanel(a){const{items:V,testDefs:pe,onSaveImage:xe,onOpen:M,centreLabel:Y="mean of all wafers"}=a,be=a.title??"Wafer-to-wafer trend",{card:c,body:h,controlsRow:q}=Ie(be,xe,a.ownerDocument);c.style.alignSelf="start";const N=pe.filter(l=>l.testNumber!==void 0&&Ae(l));let f=a.selectedTestNumber??N[0]?.testNumber??null,$=0;const J=De(N,f,l=>{f=l,S(),a.onTestChange?.(l)},{maxWidth:"240px",emptyText:"No parametric tests",ownerDocument:c.ownerDocument});q.appendChild(J.el);const R=c.ownerDocument.createElement("span");Object.assign(R.style,{display:"inline-flex",gap:ce.lg,alignItems:"center"}),q.appendChild(R);const _=Oe(R,a.axisPrefs,l=>{a.onAxisPrefsChange?.(l),S()},c.ownerDocument),y=c.ownerDocument.createElement("div");y.dataset.wmapCaption="1",Object.assign(y.style,{color:Me.label,fontSize:Pe.body,marginBottom:ce.sm}),c.insertBefore(y,h);const B=Ee(c);let I=null,s=[];function ge(l){return N.find(F=>F.testNumber===l)}function S(){const{includeLimits:l,clipOutliers:F,limits:ye}=_.get();if(h.innerHTML="",I?.disconnect(),I=null,N.length===0||f===null){y.textContent="",j(h,"No parametric test data available for a trend.");return}if(V.length<2){y.textContent="",j(h,"A wafer-to-wafer trend needs at least two wafers.");return}if(s=Se(V,f),!s.some(i=>i.count>0)){y.textContent="",j(h,"No values recorded for this test.");return}const p=ge(f),W=fe(p,ye),v=Ce(s),Z=()=>{y.textContent=`Point = wafer mean, whisker = \xB11\u03C3, dashed = ${Y} \xB7 wafers in slot order`+(M?" \xB7 click a point to open that wafer":"")+(a.onSelectWafers?" \xB7 drag across the plot to select wafers":"")+($?` \xB7 axis clipped, ${$} outside`:"")};Z();const x=c.ownerDocument.createElement("canvas");x.style.display="block",h.appendChild(x);let T=null;const C=new Set,E=()=>{const i=Math.max(1,h.clientWidth),n=Math.max(ue,He(c,h,x,ue)),o=je(x,c,i,n);if(!o)return;const{ctx:e,theme:u}=o;let A=1/0,P=-1/0;const te=[];for(const t of s)!t.count||!Number.isFinite(t.mean)||(A=Math.min(A,t.mean-t.stddev),P=Math.max(P,t.mean+t.stddev),te.push(t.mean-t.stddev,t.mean+t.stddev));if(!Number.isFinite(A)||!Number.isFinite(P))return;const ne=l??Re(A,P,de(W).lo,de(W).hi);_.sync(ne,fe(p).length>0,Be(p));const D=$e({dataMin:A,dataMax:P,limits:W,includeLimits:ne,clipOutliers:F,values:te});$=D.clippedCount,Z();let b=D.lo,k=D.hi;const se=(k-b)*.08;b-=se,k+=se;const m=K+Ve;e.font=`${me(-1)}px system-ui, sans-serif`;const ie=t=>t.length>8?`${t.slice(0,7)}\u2026`:t,ve=s.length?Math.ceil(Math.max(e.measureText(ie(s[0].label)).width,e.measureText(ie(s[s.length-1].label)).width)/2):0,w=i-K-ve,O=K,L=n-Ye,g=t=>L-(t-b)/(k-b)*(L-O),oe=s.length>1?(w-m)/(s.length-1):0;T={left:m,step:oe};const z=t=>s.length>1?m+t*oe:(m+w)/2;e.strokeStyle=u.border,e.lineWidth=1,e.beginPath(),e.moveTo(m,O),e.lineTo(m,L),e.lineTo(w,L),e.stroke(),e.fillStyle=u.text,e.textAlign="right",e.textBaseline="middle";const le=Ke(b,k,L-O,()=>Ue),Te=Ge(Math.max(Math.abs(b),Math.abs(k)),p?.unit,le.step||void 0);for(const t of le.ticks)e.fillText(Te.tickWithUnit(t),m-6,g(t));_e(e,D.offAxis,{left:m,right:w,top:O,bottom:L},"vertical",u.limitLine,t=>H(t,p?.unit));const re=me(-1),G=W.filter(t=>t.value>=b&&t.value<=k).map(t=>{const r=g(t.value);return{l:t,y:r,start:r-6-re/2,end:r-6+re/2}}),ke=Fe(G,1),we=Qe(G.map(t=>e.measureText(t.l.label).width))+8;if(G.forEach(({l:t,y:r},d)=>{e.save(),e.globalAlpha=.7,ze(e,t,u.limitLine,m,r,w,r),e.restore(),e.save(),e.fillStyle=u.limitLine,e.textAlign="left",e.fillText(t.label,m+3+ke[d]*we,r-6),e.restore()}),v!==null&&v>=b&&v<=k){const t=g(v);e.save(),e.strokeStyle=u.text,e.globalAlpha=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(m,t),e.lineTo(w,t),e.stroke(),e.restore()}e.strokeStyle=X,e.lineWidth=1.5,e.beginPath();let U=!1;s.forEach((t,r)=>{if(!t.count||!Number.isFinite(t.mean)){U=!1;return}const d=z(r),ae=g(t.mean);U?e.lineTo(d,ae):e.moveTo(d,ae),U=!0}),e.stroke(),s.forEach((t,r)=>{if(!t.count||!Number.isFinite(t.mean))return;const d=z(r);t.stddev>0&&(e.save(),e.strokeStyle=X,e.globalAlpha=.55,e.lineWidth=1,e.beginPath(),e.moveTo(d,g(t.mean-t.stddev)),e.lineTo(d,g(t.mean+t.stddev)),e.stroke(),e.restore()),e.fillStyle=X,e.beginPath(),e.arc(d,g(t.mean),he,0,Math.PI*2),e.fill(),C.has(r)&&(e.beginPath(),e.arc(d,g(t.mean),he+3,0,Math.PI*2),e.strokeStyle=u.text,e.lineWidth=1.5,e.stroke())}),e.fillStyle=u.text,e.textBaseline="top",e.textAlign="center";const Le=Math.max(1,Math.ceil(s.length*42/Math.max(1,w-m)));s.forEach((t,r)=>{if(r%Le!==0&&r!==s.length-1)return;const d=t.label.length>8?`${t.label.slice(0,7)}\u2026`:t.label;e.fillText(d,z(r),L+6)})},ee=i=>{if(!T||T.step<=0)return-1;const n=x.getBoundingClientRect(),o=Math.round((i.clientX-n.left-T.left)/T.step);return o>=0&&o<s.length&&s[o].count>0?o:-1};Ne({card:c,canvas:x,tooltip:B,drawn:()=>[],locate:i=>{const n=ee(i);return n<0?null:n},describe:i=>{const n=s[i];return`<strong>${Q(n.label)}</strong><br>`+Q(`mean ${H(n.mean,p?.unit)} \xB7 \u03C3 ${H(n.stddev,p?.unit)}`)+`<br>n = ${n.count.toLocaleString()}`+(v!==null?"<br>"+Q(`\u0394 vs ${Y} ${n.mean-v>=0?"+":""}${H(n.mean-v,p?.unit)}`):"")+(M&&n.key!==void 0?"<br><em>click to open this wafer</em>":"")+(a.onSelectWafers?"<br><em>drag across the plot to select wafers</em>":"")+(a.onWaferContextMenu&&n.key!==void 0?Xe:"")},clickable:i=>!!M&&s[i].key!==void 0,onOpen:i=>{const n=s[i];n.key!==void 0&&f!==null&&M(n.key,f)},onHover:()=>{},select:a.onSelectWafers?{pick:({x0:i,x1:n})=>{if(!T)return[];const o=T;return s.map((e,u)=>u).filter(e=>s[e].count>0&&o.left+e*o.step>=i&&o.left+e*o.step<=n)},onPicked:(i,n)=>{C.clear();for(const e of i)C.add(e);E();const o=i.map(e=>s[e].key).filter(e=>e!==void 0);o.length>0&&f!==null&&a.onSelectWafers({keys:o,testNumber:f},n,x)},onClear:()=>{C.clear(),E()},hasSelection:()=>C.size>0}:void 0}),x.addEventListener("contextmenu",i=>{const n=ee(i),o=n<0?void 0:s[n].key;o===void 0||!a.onWaferContextMenu||(B.style.display="none",a.onWaferContextMenu(o,f??void 0,i))}),E(),I=We(h,E)}return S(),{card:c,destroy:()=>{I?.disconnect(),B.remove(),c.remove()},setTest:l=>{J.set(l)&&(f=l,S())},setAxisPrefs:l=>{_.set(l)&&S()}}}