@wafertools/wafermap 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -1
- package/README.md +2 -2
- package/dist/packages/canvas-adapter/charts/barPanel.d.ts +1 -1
- package/dist/packages/canvas-adapter/charts/binCluster.js +1 -1
- package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +17 -2
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +6 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/scatter.js +1 -1
- package/dist/packages/canvas-adapter/charts/testPassRate.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.d.ts +6 -0
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.js +6 -6
- package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/identityHeader.d.ts +4 -1
- package/dist/packages/canvas-adapter/identityHeader.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +3 -1
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/plotEditor.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +3 -0
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +8 -0
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +8 -0
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +8 -3
- package/dist/packages/canvas-adapter/summaryPanel.js +2 -2
- package/dist/packages/canvas-adapter/sweepEditor.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +21 -7
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/core/index.d.ts +1 -1
- package/dist/packages/core/index.js +1 -1
- package/dist/packages/core/reticle.d.ts +20 -0
- package/dist/packages/core/reticle.js +1 -1
- package/dist/packages/core/wafer.d.ts +15 -0
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/apply.js +1 -1
- package/dist/packages/renderer/derivedTests/evaluate.d.ts +3 -1
- package/dist/packages/renderer/derivedTests/evaluate.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.d.ts +7 -0
- package/dist/packages/renderer/derivedTests/parser.js +2 -2
- package/dist/packages/stats/dieRegions.d.ts +42 -0
- package/dist/packages/stats/dieRegions.js +1 -0
- package/dist/packages/stats/facets.d.ts +8 -0
- package/dist/packages/stats/facets.js +1 -1
- package/dist/packages/stats/index.d.ts +2 -1
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/metadataColumns.js +1 -1
- package/dist/packages/stats/plotData.d.ts +1 -1
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +1 -1
- package/dist/packages/stats/plotSpec.js +1 -1
- package/dist/packages/stats/regions.d.ts +9 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/reportHtml.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -22,6 +22,65 @@ under `### Breaking`.
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
## [Unreleased]
|
|
26
|
+
|
|
27
|
+
## [0.35.0] — 2026-10-06
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Reticle cell and Reticle shot, as die fields.** With a `reticleConfig`, a die's position within the mask (**Reticle cell**,
|
|
32
|
+
`Reticle cell (1, 3)`) and where on the wafer the mask was placed for it (**Reticle shot**, `Reticle shot (-1, 2)`) join ring and
|
|
33
|
+
quadrant as categories to colour a plot by, to put on a bar or box's axis and to split yield by, as columns of the Dies table, and
|
|
34
|
+
**Reticle cell** is a third choice beside Ring | Quadrant in the Summary panel's region yield, one row per cell in numeric order.
|
|
35
|
+
They are offered only when a reticle is set. The wafer carries it as `wafer.reticle`. A cell repeats in every shot, so it shows a
|
|
36
|
+
problem with the mask; a shot is one place on the wafer, so it shows one that varies across it. `getReticleShot` is exported
|
|
37
|
+
beside `getReticleCell`.
|
|
38
|
+
- **Pass/fail tests are plot fields, under Verdicts.** A functional test, or a derived test that gives a verdict, is offered as a
|
|
39
|
+
category (`Scan Chain (pass/fail)`: Pass or Fail per die) to colour a plot by, to compare on a bar or box's axis, and to split
|
|
40
|
+
yield by, so "Vth for dies that pass the scan chain and dies that fail it" is a box with two boxes. It is never an axis value, and a
|
|
41
|
+
die with no recorded outcome is in neither group.
|
|
42
|
+
- **A derived-test expression can read a die's own fields.** `dieX()`, `dieY()`, `hbin()`, `sbin()` and `site()` give a die's position,
|
|
43
|
+
bins and probe site, so a derived test can be cut by bin (`hbin() == 5`) or position (`if(dieX() < 5, t[1010], 0 - 1)`). A field
|
|
44
|
+
the die lacks is no value, not zero. Written without its parentheses it is refused with the call to use.
|
|
45
|
+
- **Reticle cell yield, a card on the Overview.** With a `reticleConfig` the Overview gains a grid of the stepper field, one cell per
|
|
46
|
+
position in it (row 0 at the bottom), filled from the same yield ramp as the ring and quadrant cards and labelled with its yield.
|
|
47
|
+
A cell pools every field on every wafer, so a low one points at the mask, not the wafer. Hover a cell for which it is and its dies;
|
|
48
|
+
click it to chart or tabulate them. `renderRegionYieldDiagram` takes `mode: 'reticleCell'` and `grid`, and `parseReticleCellKey`
|
|
49
|
+
reads a cell's column and row from its key.
|
|
50
|
+
|
|
51
|
+
- **`attributes` on `renderWaferMap` and `renderWaferGallery`: your own names for wafer attributes.** One entry per metadata key
|
|
52
|
+
(`{ label, facet?, date? }`, over the defaults) says what an attribute is called, whether it is a Group by and Compare by choice
|
|
53
|
+
(`facet: false` keeps a low-value field such as a program revision out of those lists while it still shows on the header strip,
|
|
54
|
+
in the Wafers table and in reports), and whether it is a date, grouped by day. The header strip and its popover, Group by, the
|
|
55
|
+
plot fields (also in the right-click plot menu), the Wafers table and the reports name an attribute through one function,
|
|
56
|
+
`attributeLabel(key, curation?)`, so they cannot disagree. `WaferAttributeDef` is the entry's type.
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- **A wafer attribute has one name everywhere.** Group by and the plot fields call the test program **Test Program** and the date
|
|
61
|
+
**Test Date**, as the header strip, the Wafers table and the reports already did (they were "Program" and "Test date" there). The
|
|
62
|
+
plot fields no longer list an attribute that is unique to each wafer (`waferId`): the Wafer field is that.
|
|
63
|
+
- **The plot editor's Categories and Colour hints say what they compare.** A hint now reads "Compare by this field" and names the two kinds
|
|
64
|
+
of field it takes, a wafer attribute or a die region, and the guide explains how that differs from Group by.
|
|
65
|
+
- **Ring, quadrant and the reticle regions are defined once.** The plot fields and the Dies table read one definition
|
|
66
|
+
(`stats/dieRegions.ts`: `DIE_REGIONS`, `availableRegions`), so a region is offered, named and valued the same way in both, and findings and region yield group dies by the same definition. The
|
|
67
|
+
Dies table says `Ring 2` where it said `2` (the exported file keeps the bare number) and shows Ring and Quadrant only for dies
|
|
68
|
+
whose position in millimetres is known.
|
|
69
|
+
- **Escape in a menu closes the menu and leaves its window open.** A menu opened from a plot or sweep editor, or any other
|
|
70
|
+
window, closes on Escape; a second Escape closes the window. Keys that something inside a window has already handled no
|
|
71
|
+
longer also close it.
|
|
72
|
+
- **The segmented toggles say what each choice means.** Hard bins and Soft bins, Ring, Quadrant and Reticle cell, the pass-rate
|
|
73
|
+
judgements (Test limits, Tester flag, Functional), the plot editor's chart types and its Setup and Customise tabs, a sweep's X
|
|
74
|
+
value source, and the Data tab's Statistics, Dies, Wafers and Wide, Long switches carry a hover hint. A segmented control's option
|
|
75
|
+
takes an optional third element, its hint.
|
|
76
|
+
- **The Plot tab's buttons, the chart axis toggles and the CSV buttons carry a hover hint.** New plot, New sweep, Add
|
|
77
|
+
examples, Import, Export, Delete all and each card's Edit, Duplicate and Delete say what they do; so do Axis includes
|
|
78
|
+
limits, Clip outliers, Log scale, Max tests, and the Test values, Functional and Correlation CSV buttons. A hint's text is
|
|
79
|
+
recorded on its element as `data-wmap-tip`.
|
|
80
|
+
- **Limit labels on a scatter's two axes keep clear of each other.** A high limit on Y and a low limit on X both labelled
|
|
81
|
+
the top-left corner and drew on top of one another; a label now moves down a row until it overlaps none already drawn, in
|
|
82
|
+
the Plot tab's scatter and the Insights scatter alike (`placeClearOf` in `charts/chartShell.ts` is the one rule).
|
|
83
|
+
|
|
25
84
|
## [0.34.0] — 2026-10-06
|
|
26
85
|
|
|
27
86
|
### Added
|
|
@@ -231,7 +290,7 @@ under `### Breaking`.
|
|
|
231
290
|
- **One σ rule: the sample standard deviation (n−1).** The Test Values table, per-test statistics, the
|
|
232
291
|
lot trend, the lot drift σ and the report's pooled σ all divide by n−1, as the capability indices
|
|
233
292
|
already did, so a cell shows the same σ whichever path filled it. A displayed σ is √(n/(n−1)) times
|
|
234
|
-
the population σ of the same values (about 2.
|
|
293
|
+
the population σ of the same values (about 2.6% at n = 20; negligible on large lots). Exported
|
|
235
294
|
`sampleVariance` in `stats/math.ts` is the single implementation.
|
|
236
295
|
|
|
237
296
|
## [0.33.0] — 2026-10-02
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/wafertools/wafermap/actions/workflows/deploy.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/@wafertools/wafermap)
|
|
7
7
|

|
|
8
|
-

|
|
9
9
|
[](./LICENSE)
|
|
10
10
|
|
|
11
11
|
<img src="docs/images/hero-test-values.png" alt="wafermap demo" style="max-width:640px; display:block; margin:8px 0;" />
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Browser-first wafer map visualization for semiconductor test data.
|
|
14
14
|
|
|
15
15
|
**Zero runtime dependencies.** Pure ES modules with TypeScript types — works in React,
|
|
16
|
-
Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~
|
|
16
|
+
Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~65 kB
|
|
17
17
|
min+gz; the interactive renderer is larger, and its chart suite and in-app guide are
|
|
18
18
|
loaded on demand rather than shipped up front — [measured sizes](docs/performance.md).
|
|
19
19
|
|
|
@@ -12,7 +12,7 @@ export interface ChartPanel {
|
|
|
12
12
|
*/
|
|
13
13
|
selfControl?: {
|
|
14
14
|
current: string;
|
|
15
|
-
options: Array<[value: string, label: string]>;
|
|
15
|
+
options: Array<[value: string, label: string, hint?: string]>;
|
|
16
16
|
onChange: (value: string) => {
|
|
17
17
|
data: ChartDatum[];
|
|
18
18
|
title?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildBinClusterData as
|
|
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 +1 @@
|
|
|
1
|
-
import{buildTestBoxplotData as rt}from"../../stats/boxplot.js";import{SPACE as He,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 De}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
|
|
1
|
+
import{buildTestBoxplotData as rt}from"../../stats/boxplot.js";import{SPACE as He,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 De}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 Ee,fitRowsHeight as yt,setChartGrow as Tt,resolveChartCanvasColors as vt,makeAxisFormat as Oe,horizontalTickSpacing as kt,resolveAxisRange as Mt,shouldIncludeLimitsByDefault as Lt,drawOffAxisLimits as Ct,limitLabelSide as At,limitLines as We,limitExtent as $t,hasBothLimitKinds as St,stackLabelRows as It,strokeLimitLine as Bt,PADDING as M,VALUE_WIDTH as Rt,WAFER_MENU_HINT as Ht,prepareCanvas as Dt}from"./chartShell.js";import{escHtml as L,maxOf as Et,minOf as Ot}from"../../core/utils.js";const C=24,A=5,Pe=110,Wt=12,_e=20;export function renderBoxplotPanel(u){const{title:ne="Test value distribution",items:Ge,testDefs:be,onSaveImage:Ne,groups:g,groupLabelText:oe="group",onOpen:Q}=u,Xe=u.openActionLabel??"open that wafer",qe=u.openActionLabel??"open this wafer",{card:a,heading:Ye,body:x,controlsRow:U}=mt(ne,Ne,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 ze(){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(v=>v.key===b)?.items??[]:g.map(v=>({label:v.key,dies:v.items.flatMap(S=>S.dies??[])}));return se=p,we=i,p}function ye(){b!==null&&!D?(D=ht(()=>{Te(null),u.onGroupChange?.(null)},a.ownerDocument),U.appendChild(D)):b===null&&D&&(D.remove(),D=null),Ye.textContent=b!==null?`${ne} \u2014 ${oe}: ${b}`:ne}function Te(i){return b===i||i!==null&&!(g??[]).some(p=>p.key===i)?!1:(b=i,ye(),j(),$(),!0)}const ve=gt(ie,y,i=>{y=i,$(),u.onTestChange?.(i)},{maxWidth:"240px",emptyText:"No parametric tests",ownerDocument:a.ownerDocument}),Qe=ve.el;U.appendChild(Qe),U.appendChild(bt("Log scale",le,i=>{le=i,$()},a.ownerDocument,"Draw the value axis on a logarithmic scale"));const ae=a.ownerDocument.createElement("span");Object.assign(ae.style,{display:"inline-flex",gap:He.lg,alignItems:"center"}),U.appendChild(ae);const re=wt(ae,u.axisPrefs,i=>{u.onAxisPrefsChange?.(i),$()},a.ownerDocument),V=a.ownerDocument.createElement("div");V.dataset.wmapCaption="1",Object.assign(V.style,{color:ft.label,fontSize:ct.body,marginBottom:He.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 ${Xe}`);const v=p.length?`${p[0][0].toUpperCase()}${p[0].slice(1)} \xB7 `:"";V.textContent=`${v}box = Q1\u2013Q3, line = median, whiskers = min/max \xB7 value shown is the median`+(F?` \xB7 axis clipped, ${F} value${F===1?"":"s"} outside`:"")}j(),ye();const E=xt(a);let ce=null;function $(){const{includeLimits:i,clipOutliers:p,limits:v}=re.get();if(j(),x.innerHTML="",ie.length===0||y===null){Ee(x,"No parametric test data available for box plots.");return}const S=ze(),h=rt(S,y),K=be.find(t=>t.testNumber===y),O=K?.unit,fe=We(K,v),{lo:Ve,hi:je}=$t(fe);if(h.every(t=>t.count===0)){Ee(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 ke=M*2+Math.min(h.length,Wt)*(C+A)+_e;x.style.maxHeight=`${ke}px`,x.style.overflowY="auto",x.style.scrollbarGutter="stable";let G=-1;const ue=h.filter(t=>t.count>0),Me=Ot(ue.map(t=>t.min)),Le=Et(ue.map(t=>t.max)),Ce=i??Lt(Me,Le,Ve,je);re.sync(Ce,We(K).length>0,St(K));const N=Mt({dataMin:Me,dataMax:Le,limits:fe,includeLimits:Ce,clipOutliers:p,values:ue.flatMap(t=>[t.min,t.q1,t.median,t.q3,t.max])});F=N.clippedCount,j();const W=N.lo,J=N.hi,Ke=J-W||1,Z=le&&W>0,me=Z?Math.log10(W):0,Ae=(Z?Math.log10(J):0)-me||1,de=Math.max(Math.abs(W),Math.abs(J));function Je(){const t=M+Pe,s=m.clientWidth-t-Rt-M;return{plotX:t,plotMaxWidth:Math.max(10,s)}}function I(t,s,n){return Z?s+(Math.log10(t)-me)/Ae*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+Ae*e/4));return{ticks:d,axis:Oe(de,O)}}const n=ut(W,J,s,kt(t,de,O));return{ticks:n.ticks,axis:Oe(de,O,n.step||void 0)}}function ee(){const t=vt(a),s=M*2+h.length*(C+A)+_e;x.style.maxHeight=`${yt(a,x,ke,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=M+f*(C+A),r=w+C/2;f===G&&(e.fillStyle=t.bgHover,e.fillRect(0,w-A/2,n,C+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,M+Pe-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)),Ie=I(o.min,l,c),Be=I(o.max,l,c),B=q(Ie),Y=q(I(o.q1,l,c)),Re=q(I(o.median,l,c)),he=q(I(o.q3,l,c)),R=q(Be),lt=Ie<B,st=Be>R,H=w+3,z=w+C-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 k=3;lt?(e.moveTo(B+k,r-k),e.lineTo(B,r),e.lineTo(B+k,r+k)):(e.moveTo(B,H),e.lineTo(B,z)),st?(e.moveTo(R-k,r-k),e.lineTo(R,r),e.lineTo(R-k,r+k)):(e.moveTo(R,H),e.lineTo(R,z)),e.stroke(),e.fillStyle=De,e.globalAlpha=.35,e.fillRect(Y,H,Math.max(1,he-Y),z-H),e.globalAlpha=1,e.strokeStyle=De,e.strokeRect(Y,H,Math.max(1,he-Y),z-H),e.strokeStyle=t.text,e.lineWidth=2,e.beginPath(),e.moveTo(Re,H),e.lineTo(Re,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 T=M+h.length*(C+A);e.font=`${_(-1)}px system-ui, sans-serif`,Ct(e,N.offAxis,{left:l,right:l+c,top:0,bottom:T},"horizontal",t.limitLine,o=>ge(o,O,"engineering"));const et=new Set(N.offAxis.map(o=>o.value)),Se=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(Se),nt=_(-1)+2;Se.forEach(({l:o,x:f,dir:w},r)=>{Bt(e,o,t.limitLine,f,0,f,T),e.fillStyle=t.limitLine,e.textAlign=w<0?"right":"left",e.textBaseline="bottom",e.fillText(o.label,f+w*3,T-1-tt[r]*nt)}),e.font=`${_(-1)}px system-ui, sans-serif`,e.strokeStyle=t.border,e.lineWidth=1,e.beginPath(),e.moveTo(l,T),e.lineTo(l+c,T),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,T),e.lineTo(f,T+4),e.stroke(),e.fillText(pe.tick(o),f,T+6)}pe.unitLabel&&(e.textAlign="left",e.font=`${_(-1)}px system-ui, sans-serif`,e.fillText(`(${pe.unitLabel})`,l+c+22,T+6),e.font=`${_(-1)}px system-ui, sans-serif`),e.textBaseline="middle"}function xe(t){const s=Math.floor((t-M+A/2)/(C+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,$e=t=>!P&&!!Q&&S[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||$e(n));if(n!==G&&(G=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 ${L(oe)} by wafer</em>`:$e(n)?`<br><em>click to ${L(qe)}</em>`:"",c=!P&&u.onWaferContextMenu&&S[n]?.waferIndex!==void 0?Ht:"";E.innerHTML=`<strong>${L(e.label)}</strong> (${e.count} dies)<br>max ${L(X(e.max))}<br>q3 ${L(X(e.q3))}<br>median ${L(X(e.median))}<br>q1 ${L(X(e.q1))}<br>min ${L(X(e.min))}${l}${c}`,E.style.display="block",pt(E,a,t.clientX,t.clientY)}else E.style.display="none"}),m.addEventListener("mouseleave",()=>{G!==-1&&(G=-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;Te(e),u.onGroupChange?.(e);return}const d=S[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:S[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()}$();function Ue(i){ve.set(i)&&(y=i,$())}function Fe(i){re.set(i)&&$()}return{card:a,setTest:Ue,setAxisPrefs:Fe,destroy:()=>ce?.disconnect()}}
|
|
@@ -343,7 +343,9 @@ export interface SeriesLegendItem {
|
|
|
343
343
|
export declare function makeSeriesLegendItem(label: string, color: string, ownerDocument?: Document): SeriesLegendItem;
|
|
344
344
|
export declare function cardFrameStyle(): Partial<CSSStyleDeclaration>;
|
|
345
345
|
export declare function cardShell(title: string, onSaveImage?: SaveImageHandler, ownerDocument?: Document): CardShell;
|
|
346
|
-
export declare function makeSegmented(
|
|
346
|
+
export declare function makeSegmented(
|
|
347
|
+
/** An option's optional third element is its hover hint, for a label that does not explain itself. */
|
|
348
|
+
options: Array<[value: string, label: string, hint?: string]>, current: string, onChange: (value: string) => void, ownerDocument?: Document,
|
|
347
349
|
/** Smaller type/padding for the summary panel's 260px column, where the
|
|
348
350
|
* chart-card sizing overflows a section header. Charts keep the default. */
|
|
349
351
|
compact?: boolean): HTMLElement;
|
|
@@ -509,7 +511,7 @@ export declare function makeWaferSelect(items: readonly WaferSelectItem[], selec
|
|
|
509
511
|
}): HTMLElement & {
|
|
510
512
|
value: string;
|
|
511
513
|
};
|
|
512
|
-
export declare function makeToggle(labelText: string, checked: boolean, onChange: (v: boolean) => void, ownerDocument?: Document): HTMLLabelElement;
|
|
514
|
+
export declare function makeToggle(labelText: string, checked: boolean, onChange: (v: boolean) => void, ownerDocument?: Document, hint?: string): HTMLLabelElement;
|
|
513
515
|
export declare function makeLabeledSelect(labelText: string, options: readonly {
|
|
514
516
|
value: string;
|
|
515
517
|
label: string;
|
|
@@ -610,6 +612,19 @@ export declare function limitExtent(lines: readonly LimitLine[]): {
|
|
|
610
612
|
* (0 = the chart's usual label position), in input order. Greedy by position,
|
|
611
613
|
* so it is stable: labels that never collide all stay on row 0.
|
|
612
614
|
*/
|
|
615
|
+
export interface LabelBox {
|
|
616
|
+
x0: number;
|
|
617
|
+
y0: number;
|
|
618
|
+
x1: number;
|
|
619
|
+
y1: number;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Where a label goes so it does not sit on one already drawn: `box` moved down in whole `step`s until it overlaps none of
|
|
623
|
+
* `taken` (at most `maxSteps`, so a crowded chart gives up rather than pushes a label off the plot). The result is added to
|
|
624
|
+
* `taken`. The x-axis and y-axis limit labels of one chart are placed independently, so a high limit on Y and a low limit on X
|
|
625
|
+
* both want the top-left corner; this is what keeps them apart.
|
|
626
|
+
*/
|
|
627
|
+
export declare function placeClearOf(taken: LabelBox[], box: LabelBox, step: number, maxSteps?: number): LabelBox;
|
|
613
628
|
export declare function stackLabelRows(spans: ReadonlyArray<{
|
|
614
629
|
start: number;
|
|
615
630
|
end: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SHADOW as V,LEADING as G,wireControlHover as B,controlStyle as j,SPACE as w,RADIUS as T,fontPx as F,FONT as L,CLR as f,Z_BASE as oe,menuLayerFor as ie,wireListNavigation as re,MENU_SEARCH_THRESHOLD as U,makeMenuSearchBox as le,markMenuTrigger as N,markNoPrint as P,saveImageBlob as se,openReparentedModal as ae}from"../toolbar.js";import{ICONS as X}from"../icons.js";import{minOf as ce,maxOf as de}from"../../core/utils.js";import{robustFence as K}from"../../stats/math.js";import{fmt as ue,fmtColorbarAxis as pe}from"../../renderer/fmt.js";import{markedTestLabel as fe,DERIVED_LANE_PAD as me}from"../../renderer/testLabel.js";export function openChartExpandModal(e,i,n={}){for(const s of e.querySelectorAll('div[style*="position: absolute"]'))s.style.display==="block"&&s.style.pointerEvents==="none"&&(s.style.display="none");const t=e.querySelector("[data-wmap-chart-expand]"),o=e.getAttribute("style")??"",r=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const l=ae([e],{title:i,anchor:n.anchor,ownerDocument:e.ownerDocument,boxSize:he[r],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",o),t&&(t.style.display="flex"),n.onClosed?.()}});if(!l)return delete e.dataset.wmapExpanded,e.setAttribute("style",o),null;if(t&&(t.style.display="none"),r==="rows"){const s=()=>{const a=Number(e.dataset.wmapChartFullH);if(!a)return;const p=l.box.offsetHeight-l.contentWrap.clientHeight;l.setNaturalHeight(`min(90vh, ${Math.ceil(p+a)}px)`)};s(),(e.ownerDocument.defaultView??window).requestAnimationFrame(s)}return l}const he={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,i){const n=e.trim();let t,o,r,l=1;const s=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=n.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const p=s[1].length===3?s[1].split("").map(c=>c+c).join(""):s[1];[t,o,r]=[0,2,4].map(c=>parseInt(p.slice(c,c+2),16)),p.length===8&&(l=parseInt(p.slice(6,8),16)/255)}else if(a)[t,o,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${t}, ${o}, ${r}, ${+(l*i).toFixed(3)})`}const ge={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309"},Y={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text"};export function resolveChartCanvasColors(e){const i=getComputedStyle(e),n={};for(const t of Object.keys(Y)){const o=i.getPropertyValue(`--wmap-${Y[t]}`).trim();n[t]=o||ge[t]}return n.grid=withAlpha(n.border,GRID_ALPHA),n}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,i){const n=e.ownerDocument.defaultView??window;let t=0;const o=new n.ResizeObserver(()=>{t||(t=n.requestAnimationFrame(()=>{t=0,i()}))});return o.observe(e),{disconnect:()=>{t&&n.cancelAnimationFrame(t),t=0,o.disconnect()}}}export function growCardToFitContent(e,i,n){const t=`${W(e,i)+n}px`;e.style.minHeight!==t&&(e.style.minHeight=t)}function W(e,i){const n=e.ownerDocument.defaultView??window,t=n.getComputedStyle(e);let o=0;for(const r of Array.from(e.children)){if(r===i)continue;const l=r,s=n.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(o+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return t.boxSizing==="border-box"&&(o+=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)+(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0)),o}function Z(e,i){const n=e.ownerDocument.defaultView??window;let t=0;for(const o of Array.from(e.children)){if(o===i)continue;const r=o,l=n.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(t+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return t}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,i,n){const t=e.toLocaleString(),o=e===1?"die":"dies";return n?e===i?`${t} ${o} ${n}`:`${t} of ${i.toLocaleString()} dies ${n} (partial and edge-excluded dies left out)`:`${t} ${o}`}export function setChartGrow(e,i){e.dataset.wmapChartGrow=i}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,i,n){const o=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0),l=o.boxSizing==="border-box"?(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0)+(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0):0;return r-(W(e,i)-l)-(n?Z(i,n):0)}export function fitRowsHeight(e,i,n,t,o=0){if(growCardToFitContent(e,i,o+n),e.dataset.wmapChartFullH=String(Math.ceil(W(e,i)+o+t)),!isExpandedCard(e))return n;const r=bodyRoom(e,i)-o;return Math.max(n,Math.min(t,Math.floor(r)))}export function chartFillHeight(e,i,n,t){const o=Z(i,n);return growCardToFitContent(e,i,o+t),Math.max(t,i.clientHeight-o)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,i,n,t){const o=chartDpr(e);e.width=Math.max(1,Math.floor(n*o)),e.height=Math.max(1,Math.floor(t*o)),e.style.width=`${n}px`,e.style.height=`${t}px`;const r=e.getContext("2d");return r?(r.setTransform(o,0,0,o,0,0),r.clearRect(0,0,n,t),r.font=`${F(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(i)}):null}export function applyCanvasFlow(e,i=0){let n;if(typeof i=="number")n=i;else{const t=(i.ownerDocument.defaultView??window).getComputedStyle(i);n=i.offsetTop+i.offsetHeight+(parseFloat(t.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${n}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:ue(e,void 0,"engineering"):"\u2014"}export function makeAxisFormat(e,i,n){if(!i&&n===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const{tickFmt:t,axisLabel:o,scaledUnit:r}=pe(e,null,i,"engineering",n);return{tick:t,tickWithUnit:r?l=>`${t(l)} ${r}`:t,unitLabel:o}}const xe=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,i,n){return(t,o)=>{const r=makeAxisFormat(i,n,t).tick;return o.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+xe}}export function drawAxisUnit(e,i,n,t,o){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${F(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=o,e.fillText(`(${i})`,n,t),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(i=>i.replace(/[\s·]+$/,"").trim()).filter(i=>i&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(i)&&!/\(.*(click|drag).*\)/i.test(i)).join(" \xB7 ")}const M=(e,i)=>{for(let n=e;n&&n!==i.parentElement;n=n.parentElement)if(n.style.display==="none")return!1;return!0},be=/\s*[▾▼]\s*$/,_=new WeakMap;export function describeCard(e){const i=[],n=e.querySelector("[data-wmap-controls]");if(n){for(const l of n.querySelectorAll("button[aria-haspopup]")){if(!M(l,n))continue;const s=(l.textContent??"").replace(be,"").trim();if(!s)continue;const a=l.closest("label"),c=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";i.push(c&&c!==s?`${c}: ${s}`:s)}for(const l of n.querySelectorAll('[role="radiogroup"]')){if(!M(l,n))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&i.push(a)}for(const l of n.querySelectorAll('input[type="checkbox"]:checked')){if(!M(l,n))continue;const s=l.closest("label")?.textContent?.trim();s&&i.push(s)}}const t=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!M(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&t.push(s)}const o=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&o.push({label:p,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&o.push({label:p,color:a})}const r=_.get(e)?.();return r&&(r.controls&&i.push(...r.controls),r.caption!==void 0&&(t.length=0,t.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(o.length=0,o.push(...r.legend))),{controls:i,captions:t,legend:o}}function ye(e){const i=describeCard(e),n=_.get(e)?.();return{controls:i.controls,caption:i.captions,legend:i.legend.length?i.legend:void 0,colorbar:n?.colorbar}}function J(e){for(const i of e.querySelectorAll("[data-wmap-chart-card]")){const n=i.querySelector(":scope > [data-wmap-print-only]");if(!n)continue;const t=describeCard(i);n.replaceChildren();const o=[t.controls.length?t.controls.join(" \xB7 "):"",...t.captions].filter(Boolean);for(const r of o){const l=e.createElement("div");l.textContent=r,n.appendChild(l)}for(const r of i.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const Q=new WeakSet;function we(e){if(Q.has(e))return;Q.add(e);const i=e.createElement("style");i.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(i);const n=e.defaultView;n?.addEventListener("beforeprint",()=>J(e));try{n?.matchMedia?.("print").addEventListener?.("change",t=>{t.matches&&J(e)})}catch{}}function Ce(e){const i=e.ownerDocument.defaultView;for(let n=e;n&&i;n=n.parentElement){const t=i.getComputedStyle(n).backgroundColor;if(t&&t!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(t))return t}return"#ffffff"}export function composeChartPng(e,i){const n=e.ownerDocument,t=n.createElement("canvas"),o=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=n.createElement("canvas").getContext("2d"),s=12*o,a=(g,y="400")=>`${y} ${g*o}px system-ui, -apple-system, "Segoe UI", sans-serif`,p=(g,y)=>l?(l.font=y,l.measureText(g).width):g.length*7*o,c=[];let d=0;if(i){d=s,c.push({kind:"text",text:i.title,x:s,y:d+14*o,font:a(16,"600"),alpha:1}),d+=24*o;const g=i.decor,y=[];g?.controls?.length&&y.push({text:g.controls.join(" \xB7 "),alpha:1});for(const m of g?.caption===void 0?[]:typeof g.caption=="string"?[g.caption]:g.caption)y.push({text:m,alpha:.75});const x=a(12);for(const{text:m,alpha:C}of y){let b="";for(const E of m.split(" ")){const O=b?`${b} ${E}`:E;b&&p(O,x)>r-2*s?(c.push({kind:"text",text:b,x:s,y:d+11*o,font:x,alpha:C}),d+=17*o,b=E):b=O}b&&(c.push({kind:"text",text:b,x:s,y:d+11*o,font:x,alpha:C}),d+=17*o)}if(g?.legend?.length){d+=4*o;const m=a(12);let C=s;for(const b of g.legend){const E=14*o+p(b.label,m)+14*o;C>s&&C+E>r-s&&(C=s,d+=18*o),c.push({kind:"dot",x:C+5*o,y:d+7*o,r:5*o,color:b.color}),c.push({kind:"text",text:b.label,x:C+14*o,y:d+11*o,font:m,alpha:1}),C+=E}d+=20*o}if(g?.colorbar){d+=4*o;const m=a(12),C=g.colorbar;let b=s;c.push({kind:"text",text:C.label,x:b,y:d+10*o,font:m,alpha:1}),b+=p(C.label,m)+10*o,c.push({kind:"text",text:C.lo,x:b,y:d+10*o,font:m,alpha:.75}),b+=p(C.lo,m)+6*o,c.push({kind:"strip",x:b,y:d+1*o,w:200*o,h:10*o,color:C.color}),b+=206*o,c.push({kind:"text",text:C.hi,x:b,y:d+10*o,font:m,alpha:.75}),d+=20*o}d+=6*o}t.width=r,t.height=Math.ceil(e.height+d);const u=t.getContext("2d");if(u.fillStyle=i?Ce(i.card):"#ffffff",u.fillRect(0,0,t.width,t.height),i){const g=n.defaultView,y=g&&g.getComputedStyle(i.card).color||"#222222";u.textBaseline="alphabetic";for(const x of c)if(x.kind==="text")u.font=x.font,u.fillStyle=y,u.globalAlpha=x.alpha,u.fillText(x.text,x.x,x.y),u.globalAlpha=1;else if(x.kind==="dot")u.fillStyle=x.color,u.beginPath(),u.arc(x.x,x.y,x.r,0,Math.PI*2),u.fill();else for(let m=0;m<x.w;m++)u.fillStyle=x.color(m/Math.max(1,x.w-1)),u.fillRect(x.x+m,x.y,1,x.h)}return u.drawImage(e,0,d),t}export function saveCanvasPng(e,i,n,t){composeChartPng(e,t).toBlob(o=>{o&&se(o,i,n)},"image/png")}const ee="10px";export function chartSwatchCss(e,i="solid"){return["display:inline-block",`width:${ee}`,`height:${ee}`,`border-radius:${T.pill}`,`background:${i==="outline"?"transparent":e}`,`border:1px ${i==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Se="0.35";export function makeSeriesLegendItem(e,i,n=document){const t=n.createElement("button");t.type="button",Object.assign(t.style,{display:"inline-flex",alignItems:"center",gap:w.xs,padding:`${w.xs} ${w.md}`,borderRadius:T.pill,border:`1px solid ${f.menuBorder}`,background:"none",cursor:"pointer",fontSize:L.body,color:f.text,whiteSpace:"nowrap"}),B(t,"bare");const o=n.createElement("span");return o.style.cssText=chartSwatchCss(i),t.append(o,n.createTextNode(e)),{el:t,setState({selected:r,dimmed:l}){t.style.borderColor=r?f.iconActive:f.menuBorder,t.style.fontWeight=r?"600":"400",t.style.opacity=l?Se:"1",t.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:f.menuBg,border:`1px solid ${f.menuBorder}`,borderRadius:T.container,padding:w.xl,fontVariantNumeric:"tabular-nums"}}export function cardShell(e,i,n=document){const t=n.createElement("div");t.dataset.wmapChartCard="1",t.dataset.wmapChartTitle=e,Object.assign(t.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const o=t.ownerDocument.createElement("div");Object.assign(o.style,{display:"flex",alignItems:"center",gap:w.sm,paddingBottom:"6px",marginBottom:w.md,borderBottom:`1px solid ${f.menuBorder}`});const r=t.ownerDocument.createElement("div");r.textContent=e,Object.assign(r.style,{color:f.value,fontSize:L.heading,fontWeight:"600",flex:"1"}),o.appendChild(r);const l=makeTooltip(t),s=t.ownerDocument.createElement("button");s.type="button",s.setAttribute("aria-label","Save as PNG"),s.innerHTML=X.download,Object.assign(s.style,{...j("outlined"),color:f.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(s),attachChartTip(s,t,l,"Save as PNG"),s.addEventListener("click",()=>{const u=t.querySelector("canvas");u&&saveCanvasPng(u,r.textContent||e,i,{card:t,title:r.textContent||e,decor:ye(t)})}),P(s),o.appendChild(s);const a=t.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=X.expand,Object.assign(a.style,{...j("outlined"),color:f.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(a),attachChartTip(a,t,l,"Expand"),a.dataset.wmapChartExpand="1",a.addEventListener("click",()=>openChartExpandModal(t,r.textContent??e)),P(a),o.appendChild(a),t.appendChild(o);const p=t.ownerDocument.createElement("div");p.dataset.wmapPrintOnly="1",Object.assign(p.style,{display:"none",color:f.label,fontSize:L.body,marginBottom:w.sm}),t.appendChild(p),we(t.ownerDocument);const c=t.ownerDocument.createElement("div");c.dataset.wmapControls="1",Object.assign(c.style,{display:"flex",gap:w.sm,marginBottom:w.md,flexWrap:"wrap",alignItems:"center"}),P(c),t.appendChild(c);const d=t.ownerDocument.createElement("div");return Object.assign(d.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),t.appendChild(d),{card:t,heading:r,controlsRow:c,body:d,setPngDecor:u=>{_.set(t,u)}}}export function makeSegmented(e,i,n,t=document,o=!1){const r=t.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",border:`1px solid ${f.menuBorder}`,borderRadius:T.control,overflow:"hidden"});const l=`seg-${Math.random().toString(36).slice(2,9)}`,s=[];return e.forEach(([a,p],c)=>{const d=t.createElement("label");Object.assign(d.style,{display:"inline-flex",alignItems:"center",fontSize:L.body,padding:o?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",borderLeft:c>0?`1px solid ${f.menuBorder}`:"none"}),B(d,"bare");const u=t.createElement("input");u.type="radio",u.name=l,u.value=a,u.checked=a===i,Object.assign(u.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const g=()=>{d.style.background=u.checked?f.bgActive:f.menuBg,d.style.color=u.checked?f.iconActive:f.text,d.dataset.on=u.checked?"true":"false"};s.push(g),g(),u.addEventListener("change",()=>{if(u.checked){for(const y of s)y();n(a)}}),d.append(u,t.createTextNode(p)),r.appendChild(d)}),r}export function makeBackButton(e,i=document){const n=i.createElement("button");return n.type="button",n.textContent="\u2190 Back",Object.assign(n.style,{...j("outlined"),background:f.menuBg,color:f.label}),B(n),n.addEventListener("click",e),n}export function renderEmptyState(e,i,n){const t=e.ownerDocument.createElement("div");t.textContent=i,Object.assign(t.style,{color:f.label,fontSize:L.body,padding:"8px 0"}),n&&Object.assign(t.style,n),e.appendChild(t)}export function makeListSelect(e,i,n,t={}){const{maxWidth:o="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:p}=t;let c=i;const d=k=>e.find(H=>H.value===k)?.label??"",u=r.createElement("button");u.type="button",p&&(u.dataset.wmapSelect=p),l&&u.setAttribute("aria-label",l),Object.assign(u.style,{fontSize:L.body,padding:`${w.xxs} ${w.sm}`,background:f.menuBg,color:f.text,border:`1px solid ${f.menuBorder}`,borderRadius:T.control,maxWidth:o,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:w.sm,justifyContent:"space-between"}),B(u),N(u,!1);const g=r.createElement("span");Object.assign(g.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const y=r.createElement("span");y.textContent="\u25BE",y.style.flex="0 0 auto",u.append(g,y);const x=()=>{g.textContent=e.length===0?s??"(none)":d(c)||s||"(none)"};if(x(),e.length===0)return u.disabled=!0,u.style.opacity="0.6",u.style.cursor="default",Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,x()}});let m=null;const C=()=>{m&&(m.remove(),m=null,N(u,!1))},b=()=>{C(),u.focus()};function E(){const k=u.getBoundingClientRect(),H=r.defaultView??window,z=Math.max(k.width,220),te=Math.min(k.left,Math.max(4,(H.innerWidth??1/0)-z-4));m=r.createElement("div"),m.setAttribute("role","listbox"),m.setAttribute("aria-label",l??"Options"),Object.assign(m.style,{position:"fixed",top:`${k.bottom+4}px`,left:`${te}px`,background:f.menuBg,border:`1px solid ${f.menuBorder}`,borderRadius:T.control,boxShadow:V.menu,zIndex:oe,minWidth:`${z}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const A=[],D=()=>A.filter(h=>h.row.style.display!=="none").map(h=>h.row),I=[],ne=()=>{for(const h of I)h.el.style.display=A.slice(h.first,h.last+1).some(S=>S.row.style.display!=="none")?"":"none"};if(e.length>U){const h=le(S=>{for(const v of A)v.row.style.display=v.label.includes(S)?"":"none";ne()},a,r);Object.assign(h.style,{position:"sticky",top:"0",zIndex:"1",background:f.menuBg}),h.addEventListener("keydown",S=>{if(S.key==="Escape"){b();return}S.key==="ArrowDown"&&(S.preventDefault(),D()[0]?.focus())}),m.appendChild(h)}let q;for(const h of e){if(h.group!==void 0&&h.group!==q){const $=r.createElement("div");$.textContent=h.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${w.sm} ${w.xl} ${w.xxs}`,fontSize:L.sub,color:f.label,fontWeight:"600"}),m.appendChild($),I.push({el:$,first:A.length,last:A.length})}q=h.group;const S=h.value===c,v=r.createElement("div");v.textContent=h.disabled?`${h.label} \u2014 ${h.disabled}`:h.label,v.setAttribute("role","option"),v.setAttribute("aria-selected",S?"true":"false"),h.disabled&&v.setAttribute("aria-disabled","true"),v.tabIndex=-1,Object.assign(v.style,{padding:`${w.sm} ${w.xl}`,fontSize:L.body,cursor:h.disabled?"default":"pointer",color:h.disabled?f.label:S?f.iconActive:f.text,fontWeight:S?"700":"400",opacity:h.disabled?"0.7":"",background:S?f.menuActive:"transparent",whiteSpace:"nowrap"}),v.addEventListener("mouseenter",()=>{!S&&!h.disabled&&(v.style.background=f.menuHover)}),v.addEventListener("mouseleave",()=>{S||(v.style.background="transparent")}),v.addEventListener("click",$=>{$.stopPropagation(),!h.disabled&&(c=h.value,x(),b(),n(h.value))}),m.appendChild(v),A.push({row:v,label:h.label.toLowerCase()}),I.length&&(I[I.length-1].last=A.length-1)}if(re(m,D,b),ie(u).appendChild(m),N(u,!0),e.length<=U){const h=e.findIndex(S=>S.value===c);D()[h>=0?h:0]?.focus()}}u.addEventListener("click",k=>{if(k.stopPropagation(),m){C();return}E()});const O=k=>{if(!u.isConnected){r.removeEventListener("click",O);return}m&&!m.contains(k.target)&&!u.contains(k.target)&&C()};return r.addEventListener("click",O),Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,x()}})}export function testOptionLabels(e){const i=e.some(n=>n.derived);return e.map(n=>(i&&!n.derived?me:"")+fe(n,n.testNumber))}export function makeTestSelect(e,i,n,t={}){const{maxWidth:o="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=t;return makeListSelect(testOptionLabels(e).map((s,a)=>({value:String(e[a].testNumber),label:s})),i!==null?String(i):"",s=>n(Number(s)),{maxWidth:o,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,i,n,t=document){let o=i?.includeLimits,r=i?.clipOutliers??!1,l=i?.limits??"both";const s=()=>n({includeLimits:o,clipOutliers:r,limits:l});return{get:()=>({includeLimits:o,clipOutliers:r,limits:l}),sync(a,p,c=!1){e.innerHTML="",c&&e.appendChild(makeLimitsSelect(l,d=>{l=d,s()},t)),p&&e.appendChild(makeToggle("Axis includes limits",a,d=>{o=d,s()},t)),e.appendChild(makeToggle("Clip outliers",r,d=>{r=d,s()},t))},set(a){const p=a.limits??"both";return a.includeLimits===o&&a.clipOutliers===r&&p===l?!1:(o=a.includeLimits,r=a.clipOutliers,l=p,!0)}}}export function makeLinkedTestSelect(e,i,n,t={}){let o=i;const r=makeTestSelect(e,o,l=>{l!==o&&(o=l,n(l))},t);return{el:r,get:()=>o,set(l){return o===l||!e.some(s=>s.testNumber===l)?!1:(o=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,i,n,t,o={}){let r=n;const l=c=>c??ALL_GROUPS,s=c=>c===ALL_GROUPS?null:c,a=makeLabeledSelect(i,[{value:ALL_GROUPS,label:"All groups"},...e.map(c=>({value:c,label:c}))],l(r),c=>{const d=s(c);d!==r&&(r=d,t(d))},{...o,hook:"group-scope"}),p=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(c){return r===c||c!==null&&!e.includes(c)?!1:(r=c,p&&(p.value=l(c)),!0)}}}export function makeWaferSelect(e,i,n,t={}){const{maxWidth:o="160px",allLabel:r="All wafers",ownerDocument:l=document}=t,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,p)=>({value:String(p),label:a.label??`#${p}`}))],i===null?s:String(i),a=>n(a===s?null:Number(a)),{maxWidth:o,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,i,n,t=document){const o=t.createElement("label");Object.assign(o.style,{display:"inline-flex",alignItems:"center",gap:w.xs,fontSize:L.body,color:f.label,cursor:"pointer",userSelect:"none"}),B(o,"bare");const r=t.createElement("input");return r.type="checkbox",r.checked=i,r.style.cssText="margin:0;cursor:pointer;",r.addEventListener("change",()=>n(r.checked)),o.append(r,t.createTextNode(e)),o}export function makeLabeledSelect(e,i,n,t,o={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document}=o,a=s.createElement("label");a.textContent=e,Object.assign(a.style,{color:f.label,fontSize:L.body,display:"flex",alignItems:"center",gap:w.xs});const p=makeListSelect(i,n,t,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return a.appendChild(p),a}export function makeChartGridWrap(e=document){const i=e.createElement("div");return i.dataset.wmapChartGrid="1",Object.assign(i.style,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:w.lg,flex:"0 0 auto"}),i}export function makeTooltip(e){const i=e.ownerDocument.createElement("div");return Object.assign(i.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:T.control,padding:`${w.sm} ${w.xl}`,fontSize:L.sub,fontFamily:L.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:V.menu}),e.appendChild(i),i}export function attachChartTip(e,i,n,t){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=t),e.addEventListener("mouseenter",o=>{n.textContent=t,n.style.display="block",positionChartTooltip(n,i,o.clientX,o.clientY)}),e.addEventListener("mousemove",o=>{n.style.display==="block"&&positionChartTooltip(n,i,o.clientX,o.clientY)}),e.addEventListener("mouseleave",()=>{n.style.display="none"}),e.addEventListener("click",()=>{n.style.display="none"}),e.addEventListener("focus",()=>{n.textContent=t,n.style.display="block";const o=e.getBoundingClientRect();positionChartTooltip(n,i,o.left+o.width/2,o.bottom)}),e.addEventListener("blur",()=>{n.style.display="none"})}export function positionChartTooltip(e,i,n,t){const o=i.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let p=n-o.left+r,c=t-o.top+r;p+s+l>o.width&&(p=n-o.left-r-s),c+a+l>o.height&&(c=t-o.top-r-a),p=Math.max(l,p),c=Math.max(l,c),e.style.left=`${p}px`,e.style.top=`${c}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"}},LIMIT_DASH={test:[3,3],spec:[10,4]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function R(e,i){const[n,t]=i==="test"?[e?.limitLow,e?.limitHigh]:[e?.specLow,e?.specHigh],o=[];return n!==void 0&&Number.isFinite(n)&&o.push({value:n,kind:i,end:"lo",label:LIMIT_LABEL[i].lo}),t!==void 0&&Number.isFinite(t)&&o.push({value:t,kind:i,end:"hi",label:LIMIT_LABEL[i].hi}),o}export function hasBothLimitKinds(e){return R(e,"test").length>0&&R(e,"spec").length>0}export function limitLines(e,i="both"){if(i==="none")return[];const n=R(e,"test"),t=R(e,"spec"),o=i==="test"?n:i==="spec"?t:[...n,...t];return o.length?o:[...n,...t]}export function limitExtent(e){if(!e.length)return{};const i=e.map(n=>n.value);return{lo:ce(i),hi:de(i)}}export function stackLabelRows(e,i=4){const n=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),t=[],o=new Array(e.length).fill(0);for(const r of n){let l=t.findIndex(s=>r.start>=s+i);l===-1?(l=t.length,t.push(r.end)):t[l]=r.end,o[r.i]=l}return o}export function fillTextOnHalo(e,i,n,t,o){if(o){const r=e.measureText(i),l=2,s=e.fillStyle;e.fillStyle=o,e.fillRect(n-r.actualBoundingBoxLeft-l,t-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(i,n,t)}export function strokeLimitLine(e,i,n,t,o,r,l){e.save(),e.strokeStyle=n,e.lineWidth=1,e.setLineDash(LIMIT_DASH[i.kind]),e.beginPath(),e.moveTo(t,o),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,i,n=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,t=>i(t),{maxWidth:"170px",hook:"limits-shown",ownerDocument:n})}export{K as robustFence};export function shouldIncludeLimitsByDefault(e,i,n,t,o=1/3){if(n===void 0&&t===void 0||!Number.isFinite(e)||!Number.isFinite(i))return!1;const r=Math.min(e,n??e),s=Math.max(i,t??i)-r;if(s<=0)return!0;const a=i-e;return a===0?!0:a/s>=o}export function resolveAxisRange(e){const{dataMin:i,dataMax:n,limits:t=[],includeLimits:o,clipOutliers:r,values:l}=e;let s=i,a=n,p=0;if(r&&l?.length){const d=K(l);if(d){const u=Math.max(s,d.lo),g=Math.min(a,d.hi);g>u&&(p=l.filter(y=>Number.isFinite(y)&&(y<u||y>g)).length,s=u,a=g)}}if(o)for(const d of t)s=Math.min(s,d.value),a=Math.max(a,d.value);s===a&&(s-=1,a+=1);const c=[];for(const d of t)d.value<s?c.push({value:d.value,label:d.label,side:"lo"}):d.value>a&&c.push({value:d.value,label:d.label,side:"hi"});return{lo:s,hi:a,offAxis:c,clippedCount:p}}export function limitLabelSide(e,i,n,t,o,r=3){const l=o?-1:1;return(l<0?e-r-i>=n:e+r+i<=t)?l:-l}export function drawOffAxisLimits(e,i,n,t,o,r,l){if(!i.length)return;e.save(),e.fillStyle=o,e.font=`${F(-1)}px system-ui, sans-serif`;const s={lo:0,hi:0},a=F(-1)+2;for(const{value:p,label:c,side:d}of i){const u=s[d]++*a,g=t==="horizontal"?d==="lo"?"\u2190":"\u2192":d==="lo"?"\u2193":"\u2191",y=d==="lo"?`${g} ${c} ${r(p)}`:`${c} ${r(p)} ${g}`;t==="horizontal"?(e.textBaseline="top",e.textAlign=d==="lo"?"left":"right",fillTextOnHalo(e,y,d==="lo"?n.left+2:n.right-2,n.top+2+u,l)):(e.textBaseline=d==="lo"?"bottom":"top",e.textAlign="left",fillTextOnHalo(e,y,n.left+4,d==="lo"?n.bottom-2-u:n.top+2+u,l))}e.restore()}
|
|
1
|
+
import{SHADOW as V,LEADING as G,wireTooltip as U,wireControlHover as B,controlStyle as j,SPACE as w,RADIUS as T,fontPx as F,FONT as L,CLR as m,Z_BASE as ie,menuLayerFor as re,wireListNavigation as le,MENU_SEARCH_THRESHOLD as X,makeMenuSearchBox as se,markMenuTrigger as N,markNoPrint as P,saveImageBlob as ae,openReparentedModal as ce}from"../toolbar.js";import{ICONS as K}from"../icons.js";import{minOf as de,maxOf as ue}from"../../core/utils.js";import{robustFence as Y}from"../../stats/math.js";import{fmt as pe,fmtColorbarAxis as fe}from"../../renderer/fmt.js";import{markedTestLabel as me,DERIVED_LANE_PAD as he}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,n={}){for(const s of e.querySelectorAll('div[style*="position: absolute"]'))s.style.display==="block"&&s.style.pointerEvents==="none"&&(s.style.display="none");const t=e.querySelector("[data-wmap-chart-expand]"),i=e.getAttribute("style")??"",r=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const l=ce([e],{title:o,anchor:n.anchor,ownerDocument:e.ownerDocument,boxSize:xe[r],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),t&&(t.style.display="flex"),n.onClosed?.()}});if(!l)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),null;if(t&&(t.style.display="none"),r==="rows"){const s=()=>{const a=Number(e.dataset.wmapChartFullH);if(!a)return;const p=l.box.offsetHeight-l.contentWrap.clientHeight;l.setNaturalHeight(`min(90vh, ${Math.ceil(p+a)}px)`)};s(),(e.ownerDocument.defaultView??window).requestAnimationFrame(s)}return l}const xe={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,o){const n=e.trim();let t,i,r,l=1;const s=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=n.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const p=s[1].length===3?s[1].split("").map(c=>c+c).join(""):s[1];[t,i,r]=[0,2,4].map(c=>parseInt(p.slice(c,c+2),16)),p.length===8&&(l=parseInt(p.slice(6,8),16)/255)}else if(a)[t,i,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${t}, ${i}, ${r}, ${+(l*o).toFixed(3)})`}const ge={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309"},Z={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),n={};for(const t of Object.keys(Z)){const i=o.getPropertyValue(`--wmap-${Z[t]}`).trim();n[t]=i||ge[t]}return n.grid=withAlpha(n.border,GRID_ALPHA),n}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const n=e.ownerDocument.defaultView??window;let t=0;const i=new n.ResizeObserver(()=>{t||(t=n.requestAnimationFrame(()=>{t=0,o()}))});return i.observe(e),{disconnect:()=>{t&&n.cancelAnimationFrame(t),t=0,i.disconnect()}}}export function growCardToFitContent(e,o,n){const t=`${W(e,o)+n}px`;e.style.minHeight!==t&&(e.style.minHeight=t)}function W(e,o){const n=e.ownerDocument.defaultView??window,t=n.getComputedStyle(e);let i=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=n.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(i+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return t.boxSizing==="border-box"&&(i+=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)+(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0)),i}function J(e,o){const n=e.ownerDocument.defaultView??window;let t=0;for(const i of Array.from(e.children)){if(i===o)continue;const r=i,l=n.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(t+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return t}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,n){const t=e.toLocaleString(),i=e===1?"die":"dies";return n?e===o?`${t} ${i} ${n}`:`${t} of ${o.toLocaleString()} dies ${n} (partial and edge-excluded dies left out)`:`${t} ${i}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,n){const i=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(i.paddingTop)||0)-(parseFloat(i.paddingBottom)||0),l=i.boxSizing==="border-box"?(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0):0;return r-(W(e,o)-l)-(n?J(o,n):0)}export function fitRowsHeight(e,o,n,t,i=0){if(growCardToFitContent(e,o,i+n),e.dataset.wmapChartFullH=String(Math.ceil(W(e,o)+i+t)),!isExpandedCard(e))return n;const r=bodyRoom(e,o)-i;return Math.max(n,Math.min(t,Math.floor(r)))}export function chartFillHeight(e,o,n,t){const i=J(o,n);return growCardToFitContent(e,o,i+t),Math.max(t,o.clientHeight-i)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,n,t){const i=chartDpr(e);e.width=Math.max(1,Math.floor(n*i)),e.height=Math.max(1,Math.floor(t*i)),e.style.width=`${n}px`,e.style.height=`${t}px`;const r=e.getContext("2d");return r?(r.setTransform(i,0,0,i,0,0),r.clearRect(0,0,n,t),r.font=`${F(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let n;if(typeof o=="number")n=o;else{const t=(o.ownerDocument.defaultView??window).getComputedStyle(o);n=o.offsetTop+o.offsetHeight+(parseFloat(t.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${n}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:pe(e,void 0,"engineering"):"\u2014"}export function makeAxisFormat(e,o,n){if(!o&&n===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const{tickFmt:t,axisLabel:i,scaledUnit:r}=fe(e,null,o,"engineering",n);return{tick:t,tickWithUnit:r?l=>`${t(l)} ${r}`:t,unitLabel:i}}const be=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,n){return(t,i)=>{const r=makeAxisFormat(o,n,t).tick;return i.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+be}}export function drawAxisUnit(e,o,n,t,i){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${F(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=i,e.fillText(`(${o})`,n,t),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(o=>o.replace(/[\s·]+$/,"").trim()).filter(o=>o&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(o)&&!/\(.*(click|drag).*\)/i.test(o)).join(" \xB7 ")}const M=(e,o)=>{for(let n=e;n&&n!==o.parentElement;n=n.parentElement)if(n.style.display==="none")return!1;return!0},ye=/\s*[▾▼]\s*$/,_=new WeakMap;export function describeCard(e){const o=[],n=e.querySelector("[data-wmap-controls]");if(n){for(const l of n.querySelectorAll("button[aria-haspopup]")){if(!M(l,n))continue;const s=(l.textContent??"").replace(ye,"").trim();if(!s)continue;const a=l.closest("label"),c=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(c&&c!==s?`${c}: ${s}`:s)}for(const l of n.querySelectorAll('[role="radiogroup"]')){if(!M(l,n))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of n.querySelectorAll('input[type="checkbox"]:checked')){if(!M(l,n))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const t=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!M(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&t.push(s)}const i=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&i.push({label:p,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,p=(l.textContent??"").trim();p&&a&&a!=="transparent"&&i.push({label:p,color:a})}const r=_.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(t.length=0,t.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(i.length=0,i.push(...r.legend))),{controls:o,captions:t,legend:i}}function we(e){const o=describeCard(e),n=_.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:n?.colorbar}}function Q(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const n=o.querySelector(":scope > [data-wmap-print-only]");if(!n)continue;const t=describeCard(o);n.replaceChildren();const i=[t.controls.length?t.controls.join(" \xB7 "):"",...t.captions].filter(Boolean);for(const r of i){const l=e.createElement("div");l.textContent=r,n.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ee=new WeakSet;function Ce(e){if(ee.has(e))return;ee.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const n=e.defaultView;n?.addEventListener("beforeprint",()=>Q(e));try{n?.matchMedia?.("print").addEventListener?.("change",t=>{t.matches&&Q(e)})}catch{}}function Se(e){const o=e.ownerDocument.defaultView;for(let n=e;n&&o;n=n.parentElement){const t=o.getComputedStyle(n).backgroundColor;if(t&&t!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(t))return t}return"#ffffff"}export function composeChartPng(e,o){const n=e.ownerDocument,t=n.createElement("canvas"),i=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=n.createElement("canvas").getContext("2d"),s=12*i,a=(f,y="400")=>`${y} ${f*i}px system-ui, -apple-system, "Segoe UI", sans-serif`,p=(f,y)=>l?(l.font=y,l.measureText(f).width):f.length*7*i,c=[];let d=0;if(o){d=s,c.push({kind:"text",text:o.title,x:s,y:d+14*i,font:a(16,"600"),alpha:1}),d+=24*i;const f=o.decor,y=[];f?.controls?.length&&y.push({text:f.controls.join(" \xB7 "),alpha:1});for(const h of f?.caption===void 0?[]:typeof f.caption=="string"?[f.caption]:f.caption)y.push({text:h,alpha:.75});const g=a(12);for(const{text:h,alpha:C}of y){let b="";for(const E of h.split(" ")){const O=b?`${b} ${E}`:E;b&&p(O,g)>r-2*s?(c.push({kind:"text",text:b,x:s,y:d+11*i,font:g,alpha:C}),d+=17*i,b=E):b=O}b&&(c.push({kind:"text",text:b,x:s,y:d+11*i,font:g,alpha:C}),d+=17*i)}if(f?.legend?.length){d+=4*i;const h=a(12);let C=s;for(const b of f.legend){const E=14*i+p(b.label,h)+14*i;C>s&&C+E>r-s&&(C=s,d+=18*i),c.push({kind:"dot",x:C+5*i,y:d+7*i,r:5*i,color:b.color}),c.push({kind:"text",text:b.label,x:C+14*i,y:d+11*i,font:h,alpha:1}),C+=E}d+=20*i}if(f?.colorbar){d+=4*i;const h=a(12),C=f.colorbar;let b=s;c.push({kind:"text",text:C.label,x:b,y:d+10*i,font:h,alpha:1}),b+=p(C.label,h)+10*i,c.push({kind:"text",text:C.lo,x:b,y:d+10*i,font:h,alpha:.75}),b+=p(C.lo,h)+6*i,c.push({kind:"strip",x:b,y:d+1*i,w:200*i,h:10*i,color:C.color}),b+=206*i,c.push({kind:"text",text:C.hi,x:b,y:d+10*i,font:h,alpha:.75}),d+=20*i}d+=6*i}t.width=r,t.height=Math.ceil(e.height+d);const u=t.getContext("2d");if(u.fillStyle=o?Se(o.card):"#ffffff",u.fillRect(0,0,t.width,t.height),o){const f=n.defaultView,y=f&&f.getComputedStyle(o.card).color||"#222222";u.textBaseline="alphabetic";for(const g of c)if(g.kind==="text")u.font=g.font,u.fillStyle=y,u.globalAlpha=g.alpha,u.fillText(g.text,g.x,g.y),u.globalAlpha=1;else if(g.kind==="dot")u.fillStyle=g.color,u.beginPath(),u.arc(g.x,g.y,g.r,0,Math.PI*2),u.fill();else for(let h=0;h<g.w;h++)u.fillStyle=g.color(h/Math.max(1,g.w-1)),u.fillRect(g.x+h,g.y,1,g.h)}return u.drawImage(e,0,d),t}export function saveCanvasPng(e,o,n,t){composeChartPng(e,t).toBlob(i=>{i&&ae(i,o,n)},"image/png")}const te="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${te}`,`height:${te}`,`border-radius:${T.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const ve="0.35";export function makeSeriesLegendItem(e,o,n=document){const t=n.createElement("button");t.type="button",Object.assign(t.style,{display:"inline-flex",alignItems:"center",gap:w.xs,padding:`${w.xs} ${w.md}`,borderRadius:T.pill,border:`1px solid ${m.menuBorder}`,background:"none",cursor:"pointer",fontSize:L.body,color:m.text,whiteSpace:"nowrap"}),B(t,"bare");const i=n.createElement("span");return i.style.cssText=chartSwatchCss(o),t.append(i,n.createTextNode(e)),{el:t,setState({selected:r,dimmed:l}){t.style.borderColor=r?m.iconActive:m.menuBorder,t.style.fontWeight=r?"600":"400",t.style.opacity=l?ve:"1",t.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:m.menuBg,border:`1px solid ${m.menuBorder}`,borderRadius:T.container,padding:w.xl,fontVariantNumeric:"tabular-nums"}}export function cardShell(e,o,n=document){const t=n.createElement("div");t.dataset.wmapChartCard="1",t.dataset.wmapChartTitle=e,Object.assign(t.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const i=t.ownerDocument.createElement("div");Object.assign(i.style,{display:"flex",alignItems:"center",gap:w.sm,paddingBottom:"6px",marginBottom:w.md,borderBottom:`1px solid ${m.menuBorder}`});const r=t.ownerDocument.createElement("div");r.textContent=e,Object.assign(r.style,{color:m.value,fontSize:L.heading,fontWeight:"600",flex:"1"}),i.appendChild(r);const l=makeTooltip(t),s=t.ownerDocument.createElement("button");s.type="button",s.setAttribute("aria-label","Save as PNG"),s.innerHTML=K.download,Object.assign(s.style,{...j("outlined"),color:m.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(s),attachChartTip(s,t,l,"Save as PNG"),s.addEventListener("click",()=>{const u=t.querySelector("canvas");u&&saveCanvasPng(u,r.textContent||e,o,{card:t,title:r.textContent||e,decor:we(t)})}),P(s),i.appendChild(s);const a=t.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=K.expand,Object.assign(a.style,{...j("outlined"),color:m.label,padding:"0",width:"22px",height:"22px",lineHeight:G.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),B(a),attachChartTip(a,t,l,"Expand"),a.dataset.wmapChartExpand="1",a.addEventListener("click",()=>openChartExpandModal(t,r.textContent??e)),P(a),i.appendChild(a),t.appendChild(i);const p=t.ownerDocument.createElement("div");p.dataset.wmapPrintOnly="1",Object.assign(p.style,{display:"none",color:m.label,fontSize:L.body,marginBottom:w.sm}),t.appendChild(p),Ce(t.ownerDocument);const c=t.ownerDocument.createElement("div");c.dataset.wmapControls="1",Object.assign(c.style,{display:"flex",gap:w.sm,marginBottom:w.md,flexWrap:"wrap",alignItems:"center"}),P(c),t.appendChild(c);const d=t.ownerDocument.createElement("div");return Object.assign(d.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),t.appendChild(d),{card:t,heading:r,controlsRow:c,body:d,setPngDecor:u=>{_.set(t,u)}}}export function makeSegmented(e,o,n,t=document,i=!1){const r=t.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",border:`1px solid ${m.menuBorder}`,borderRadius:T.control,overflow:"hidden"});const l=`seg-${Math.random().toString(36).slice(2,9)}`,s=[];return e.forEach(([a,p,c],d)=>{const u=t.createElement("label");c&&U(u,c),Object.assign(u.style,{display:"inline-flex",alignItems:"center",fontSize:L.body,padding:i?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",borderLeft:d>0?`1px solid ${m.menuBorder}`:"none"}),B(u,"bare");const f=t.createElement("input");f.type="radio",f.name=l,f.value=a,f.checked=a===o,Object.assign(f.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const y=()=>{u.style.background=f.checked?m.bgActive:m.menuBg,u.style.color=f.checked?m.iconActive:m.text,u.dataset.on=f.checked?"true":"false"};s.push(y),y(),f.addEventListener("change",()=>{if(f.checked){for(const g of s)g();n(a)}}),u.append(f,t.createTextNode(p)),r.appendChild(u)}),r}export function makeBackButton(e,o=document){const n=o.createElement("button");return n.type="button",n.textContent="\u2190 Back",Object.assign(n.style,{...j("outlined"),background:m.menuBg,color:m.label}),B(n),n.addEventListener("click",e),n}export function renderEmptyState(e,o,n){const t=e.ownerDocument.createElement("div");t.textContent=o,Object.assign(t.style,{color:m.label,fontSize:L.body,padding:"8px 0"}),n&&Object.assign(t.style,n),e.appendChild(t)}export function makeListSelect(e,o,n,t={}){const{maxWidth:i="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:p}=t;let c=o;const d=k=>e.find(D=>D.value===k)?.label??"",u=r.createElement("button");u.type="button",p&&(u.dataset.wmapSelect=p),l&&u.setAttribute("aria-label",l),Object.assign(u.style,{fontSize:L.body,padding:`${w.xxs} ${w.sm}`,background:m.menuBg,color:m.text,border:`1px solid ${m.menuBorder}`,borderRadius:T.control,maxWidth:i,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:w.sm,justifyContent:"space-between"}),B(u),N(u,!1);const f=r.createElement("span");Object.assign(f.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const y=r.createElement("span");y.textContent="\u25BE",y.style.flex="0 0 auto",u.append(f,y);const g=()=>{f.textContent=e.length===0?s??"(none)":d(c)||s||"(none)"};if(g(),e.length===0)return u.disabled=!0,u.style.opacity="0.6",u.style.cursor="default",Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,g()}});let h=null;const C=()=>{h&&(h.remove(),h=null,N(u,!1))},b=()=>{C(),u.focus()};function E(){const k=u.getBoundingClientRect(),D=r.defaultView??window,z=Math.max(k.width,220),ne=Math.min(k.left,Math.max(4,(D.innerWidth??1/0)-z-4));h=r.createElement("div"),h.setAttribute("role","listbox"),h.setAttribute("aria-label",l??"Options"),Object.assign(h.style,{position:"fixed",top:`${k.bottom+4}px`,left:`${ne}px`,background:m.menuBg,border:`1px solid ${m.menuBorder}`,borderRadius:T.control,boxShadow:V.menu,zIndex:ie,minWidth:`${z}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const A=[],H=()=>A.filter(x=>x.row.style.display!=="none").map(x=>x.row),I=[],oe=()=>{for(const x of I)x.el.style.display=A.slice(x.first,x.last+1).some(S=>S.row.style.display!=="none")?"":"none"};if(e.length>X){const x=se(S=>{for(const v of A)v.row.style.display=v.label.includes(S)?"":"none";oe()},a,r);Object.assign(x.style,{position:"sticky",top:"0",zIndex:"1",background:m.menuBg}),x.addEventListener("keydown",S=>{if(S.key==="Escape"){S.preventDefault(),b();return}S.key==="ArrowDown"&&(S.preventDefault(),H()[0]?.focus())}),h.appendChild(x)}let q;for(const x of e){if(x.group!==void 0&&x.group!==q){const $=r.createElement("div");$.textContent=x.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${w.sm} ${w.xl} ${w.xxs}`,fontSize:L.sub,color:m.label,fontWeight:"600"}),h.appendChild($),I.push({el:$,first:A.length,last:A.length})}q=x.group;const S=x.value===c,v=r.createElement("div");v.textContent=x.disabled?`${x.label} \u2014 ${x.disabled}`:x.label,v.setAttribute("role","option"),v.setAttribute("aria-selected",S?"true":"false"),x.disabled&&v.setAttribute("aria-disabled","true"),v.tabIndex=-1,Object.assign(v.style,{padding:`${w.sm} ${w.xl}`,fontSize:L.body,cursor:x.disabled?"default":"pointer",color:x.disabled?m.label:S?m.iconActive:m.text,fontWeight:S?"700":"400",opacity:x.disabled?"0.7":"",background:S?m.menuActive:"transparent",whiteSpace:"nowrap"}),v.addEventListener("mouseenter",()=>{!S&&!x.disabled&&(v.style.background=m.menuHover)}),v.addEventListener("mouseleave",()=>{S||(v.style.background="transparent")}),v.addEventListener("click",$=>{$.stopPropagation(),!x.disabled&&(c=x.value,g(),b(),n(x.value))}),h.appendChild(v),A.push({row:v,label:x.label.toLowerCase()}),I.length&&(I[I.length-1].last=A.length-1)}if(le(h,H,b),re(u).appendChild(h),N(u,!0),e.length<=X){const x=e.findIndex(S=>S.value===c);H()[x>=0?x:0]?.focus()}}u.addEventListener("click",k=>{if(k.stopPropagation(),h){C();return}E()});const O=k=>{if(!u.isConnected){r.removeEventListener("click",O);return}h&&!h.contains(k.target)&&!u.contains(k.target)&&C()};return r.addEventListener("click",O),Object.defineProperty(u,"value",{get:()=>c,set:k=>{c=k,g()}})}export function testOptionLabels(e){const o=e.some(n=>n.derived);return e.map(n=>(o&&!n.derived?he:"")+me(n,n.testNumber))}export function makeTestSelect(e,o,n,t={}){const{maxWidth:i="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=t;return makeListSelect(testOptionLabels(e).map((s,a)=>({value:String(e[a].testNumber),label:s})),o!==null?String(o):"",s=>n(Number(s)),{maxWidth:i,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,n,t=document){let i=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>n({includeLimits:i,clipOutliers:r,limits:l});return{get:()=>({includeLimits:i,clipOutliers:r,limits:l}),sync(a,p,c=!1){e.innerHTML="",c&&e.appendChild(makeLimitsSelect(l,d=>{l=d,s()},t)),p&&e.appendChild(makeToggle("Axis includes limits",a,d=>{i=d,s()},t,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,d=>{r=d,s()},t,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const p=a.limits??"both";return a.includeLimits===i&&a.clipOutliers===r&&p===l?!1:(i=a.includeLimits,r=a.clipOutliers,l=p,!0)}}}export function makeLinkedTestSelect(e,o,n,t={}){let i=o;const r=makeTestSelect(e,i,l=>{l!==i&&(i=l,n(l))},t);return{el:r,get:()=>i,set(l){return i===l||!e.some(s=>s.testNumber===l)?!1:(i=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,n,t,i={}){let r=n;const l=c=>c??ALL_GROUPS,s=c=>c===ALL_GROUPS?null:c,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(c=>({value:c,label:c}))],l(r),c=>{const d=s(c);d!==r&&(r=d,t(d))},{...i,hook:"group-scope"}),p=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(c){return r===c||c!==null&&!e.includes(c)?!1:(r=c,p&&(p.value=l(c)),!0)}}}export function makeWaferSelect(e,o,n,t={}){const{maxWidth:i="160px",allLabel:r="All wafers",ownerDocument:l=document}=t,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,p)=>({value:String(p),label:a.label??`#${p}`}))],o===null?s:String(o),a=>n(a===s?null:Number(a)),{maxWidth:i,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,n,t=document,i){const r=t.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:w.xs,fontSize:L.body,color:m.label,cursor:"pointer",userSelect:"none"}),B(r,"bare");const l=t.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>n(l.checked)),r.append(l,t.createTextNode(e)),i&&U(r,i),r}export function makeLabeledSelect(e,o,n,t,i={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document}=i,a=s.createElement("label");a.textContent=e,Object.assign(a.style,{color:m.label,fontSize:L.body,display:"flex",alignItems:"center",gap:w.xs});const p=makeListSelect(o,n,t,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return a.appendChild(p),a}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:w.lg,flex:"0 0 auto"}),o}export function makeTooltip(e){const o=e.ownerDocument.createElement("div");return Object.assign(o.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:T.control,padding:`${w.sm} ${w.xl}`,fontSize:L.sub,fontFamily:L.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:V.menu}),e.appendChild(o),o}export function attachChartTip(e,o,n,t){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=t),e.addEventListener("mouseenter",i=>{n.textContent=t,n.style.display="block",positionChartTooltip(n,o,i.clientX,i.clientY)}),e.addEventListener("mousemove",i=>{n.style.display==="block"&&positionChartTooltip(n,o,i.clientX,i.clientY)}),e.addEventListener("mouseleave",()=>{n.style.display="none"}),e.addEventListener("click",()=>{n.style.display="none"}),e.addEventListener("focus",()=>{n.textContent=t,n.style.display="block";const i=e.getBoundingClientRect();positionChartTooltip(n,o,i.left+i.width/2,i.bottom)}),e.addEventListener("blur",()=>{n.style.display="none"})}export function positionChartTooltip(e,o,n,t){const i=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let p=n-i.left+r,c=t-i.top+r;p+s+l>i.width&&(p=n-i.left-r-s),c+a+l>i.height&&(c=t-i.top-r-a),p=Math.max(l,p),c=Math.max(l,c),e.style.left=`${p}px`,e.style.top=`${c}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"}},LIMIT_DASH={test:[3,3],spec:[10,4]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function R(e,o){const[n,t]=o==="test"?[e?.limitLow,e?.limitHigh]:[e?.specLow,e?.specHigh],i=[];return n!==void 0&&Number.isFinite(n)&&i.push({value:n,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),t!==void 0&&Number.isFinite(t)&&i.push({value:t,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),i}export function hasBothLimitKinds(e){return R(e,"test").length>0&&R(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const n=R(e,"test"),t=R(e,"spec"),i=o==="test"?n:o==="spec"?t:[...n,...t];return i.length?i:[...n,...t]}export function limitExtent(e){if(!e.length)return{};const o=e.map(n=>n.value);return{lo:de(o),hi:ue(o)}}export function placeClearOf(e,o,n,t=6){const i=l=>e.some(s=>l.x0<s.x1&&l.x1>s.x0&&l.y0<s.y1&&l.y1>s.y0);let r=o;for(let l=0;l<t&&i(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+n,y1:r.y1+n};return e.push(r),r}export function stackLabelRows(e,o=4){const n=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),t=[],i=new Array(e.length).fill(0);for(const r of n){let l=t.findIndex(s=>r.start>=s+o);l===-1?(l=t.length,t.push(r.end)):t[l]=r.end,i[r.i]=l}return i}export function fillTextOnHalo(e,o,n,t,i){if(i){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=i,e.fillRect(n-r.actualBoundingBoxLeft-l,t-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,n,t)}export function strokeLimitLine(e,o,n,t,i,r,l){e.save(),e.strokeStyle=n,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(t,i),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,n=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,t=>o(t),{maxWidth:"170px",hook:"limits-shown",ownerDocument:n})}export{Y as robustFence};export function shouldIncludeLimitsByDefault(e,o,n,t,i=1/3){if(n===void 0&&t===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,n??e),s=Math.max(o,t??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=i}export function resolveAxisRange(e){const{dataMin:o,dataMax:n,limits:t=[],includeLimits:i,clipOutliers:r,values:l}=e;let s=o,a=n,p=0;if(r&&l?.length){const d=Y(l);if(d){const u=Math.max(s,d.lo),f=Math.min(a,d.hi);f>u&&(p=l.filter(y=>Number.isFinite(y)&&(y<u||y>f)).length,s=u,a=f)}}if(i)for(const d of t)s=Math.min(s,d.value),a=Math.max(a,d.value);s===a&&(s-=1,a+=1);const c=[];for(const d of t)d.value<s?c.push({value:d.value,label:d.label,side:"lo"}):d.value>a&&c.push({value:d.value,label:d.label,side:"hi"});return{lo:s,hi:a,offAxis:c,clippedCount:p}}export function limitLabelSide(e,o,n,t,i,r=3){const l=i?-1:1;return(l<0?e-r-o>=n:e+r+o<=t)?l:-l}export function drawOffAxisLimits(e,o,n,t,i,r,l){if(!o.length)return;e.save(),e.fillStyle=i,e.font=`${F(-1)}px system-ui, sans-serif`;const s={lo:0,hi:0},a=F(-1)+2;for(const{value:p,label:c,side:d}of o){const u=s[d]++*a,f=t==="horizontal"?d==="lo"?"\u2190":"\u2192":d==="lo"?"\u2193":"\u2191",y=d==="lo"?`${f} ${c} ${r(p)}`:`${c} ${r(p)} ${f}`;t==="horizontal"?(e.textBaseline="top",e.textAlign=d==="lo"?"left":"right",fillTextOnHalo(e,y,d==="lo"?n.left+2:n.right-2,n.top+2+u,l)):(e.textBaseline=d==="lo"?"bottom":"top",e.textAlign="left",fillTextOnHalo(e,y,n.left+4,d==="lo"?n.bottom-2-u:n.top+2+u,l))}e.restore()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCorrelationMatrix as vt,filterCorrelationMatrix as It,correlationSampleNote as $t}from"../../stats/correlation.js";import{maxOf as Tt}from"../../core/utils.js";import{CORRELATION_POSITIVE as st,CORRELATION_NEGATIVE as lt}from"./palette.js";import{buildFacetTable as St}from"../../stats/facets.js";import{wireControlHover as Dt,controlStyle as Rt,SPACE as v,RADIUS as rt,fontPx as dt,FONT as X,CLR as g}from"../toolbar.js";import{exportCsv as At}from"../tableExport.js";import{attachChartTip as kt,cardShell as _t,setChartGrow as Bt,isExpandedCard as Nt,bodyRoom as Ot,observeResize as Wt,makeTooltip as Ht,positionChartTooltip as Xt,makeWaferSelect as jt,renderEmptyState as zt,resolveChartCanvasColors as Ft,prepareCanvas as Vt,chartDpr as ut}from"./chartShell.js";import{escHtml as K}from"../../core/utils.js";import{unmarkedLabel as mt,derivedCsvCell as pt,DERIVED_CSV_HEADER as ft,DERIVED_MARK as Pt,DERIVED_KEY as Yt}from"../../renderer/testLabel.js";const ht=5,xt=100,gt=20;function q(b){const d=b.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(d)return[+d[1],+d[2],+d[3]];const h=b.trim().replace("#","");return h.length===6?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16)]:null}function Gt(b){const d=q(b);return d?(d[0]*299+d[1]*587+d[2]*114)/1e3>140?"#111":"#fff":"#000"}function bt(b,d,h){const O=q(b);if(!O)return b;const J=Math.round(d[0]+(O[0]-d[0])*h),W=Math.round(d[1]+(O[1]-d[1])*h),r=Math.round(d[2]+(O[2]-d[2])*h);return`rgb(${J},${W},${r})`}export function renderCorrelationPanel(b){const{title:d="Test correlation matrix",items:h,testDefs:O,onSaveImage:J,onSelectPair:W}=b,{card:r,body:I,controlsRow:Q,setPngDecor:yt}=_t(d,J,b.ownerDocument);yt(()=>{const e=q(r.ownerDocument.defaultView?.getComputedStyle(r).backgroundColor??"")??[255,255,255];return{colorbar:{label:"Pearson r",lo:"\u22121",hi:"+1",color:o=>bt(o<.5?lt:st,e,Math.abs(2*o-1))}}}),Bt(r,"square"),I.style.overflowX="auto",r.style.alignSelf="start";let V=gt,j=null;const z=r.ownerDocument.createElement("label");z.textContent="Max tests:",Object.assign(z.style,{color:g.label,fontSize:X.body,display:"flex",alignItems:"center",gap:v.xs});const E=r.ownerDocument.createElement("input");E.type="number",E.min=String(ht),E.max=String(xt),E.value=String(V),Object.assign(E.style,{width:"52px",fontSize:X.body,padding:`${v.xxs} ${v.xs}`,background:g.menuBg,color:g.value,border:`1px solid ${g.menuBorder}`,borderRadius:rt.control}),E.addEventListener("change",()=>{const e=Math.max(ht,Math.min(xt,parseInt(E.value,10)||gt));E.value=String(e),e!==V&&(V=e,tt())}),z.appendChild(E),Q.appendChild(z),h.length>1&&Q.appendChild(jt(h,j,e=>{j=e,tt()},{ownerDocument:r.ownerDocument}));function Ct(){return j!==null?h[j]?[h[j]]:[]:h}if(b.onSaveText){const e=r.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",Object.assign(e.style,{...Rt("outlined"),color:g.text}),Dt(e),e.addEventListener("click",()=>{const o=it;if(!o)return;const u=o.tests.some(s=>s.derived),m=[];for(let s=0;s<o.tests.length;s++)for(let a=s+1;a<o.tests.length;a++){const y=o.cells.find(x=>x.xIndex===a&&x.yIndex===s);y&&m.push({x:o.tests[a],y:o.tests[s],r:y.r,n:y.n})}At([{header:"Test X",get:s=>mt(s.x.label)},{header:"Test X number",get:s=>s.x.testNumber},{header:"Test Y",get:s=>mt(s.y.label)},{header:"Test Y number",get:s=>s.y.testNumber},{header:"r",get:s=>s.r===null?"":s.r.toFixed(6)},{header:"n",get:s=>s.n},...u?[{header:`Test X ${ft.toLowerCase()}`,get:s=>pt(s.x)},{header:`Test Y ${ft.toLowerCase()}`,get:s=>pt(s.y)}]:[]],m,"test-correlation.csv",b.onSaveText)}),Q.appendChild(e)}const k=r.ownerDocument.createElement("div");Object.assign(k.style,{display:"flex",flexDirection:"column",gap:v.xs,marginBottom:v.sm}),r.insertBefore(k,I);const $=Ht(r);kt(z,r,$,"Cap on how many tests the matrix includes (strongest correlations kept first)");let Z=()=>{};function wt(e,o,u,m,s,a,y,x){k.innerHTML="";const _=$t(y);if(_){const p=r.ownerDocument.createElement("div");p.dataset.wmapCaption="1",p.textContent=`${_} \u2014 r is an estimate, not the whole population.`,Object.assign(p.style,{color:g.label,fontSize:X.body}),k.appendChild(p)}if(s.length>0){const p=r.ownerDocument.createElement("div");p.dataset.wmapCaption="1",p.textContent=`\u26A0 Mixed ${s.join(", ")} within this set \u2014 correlations may be misleading (Simpson's paradox). Use Group by, or the Wafer picker, to narrow to a like-for-like set.`,Object.assign(p.style,{color:g.warnText,background:g.warnBg,border:`1px solid ${g.warnBorder}`,borderRadius:rt.control,padding:`${v.xs} ${v.md}`,fontSize:X.body}),k.appendChild(p)}const w=r.ownerDocument.createElement("span");Object.assign(w.style,{display:"inline-flex",alignItems:"center",gap:v.sm,color:g.label,fontSize:X.body,flexWrap:"wrap"});const B=r.ownerDocument.createElement("span");B.dataset.wmapCaption="1",B.textContent=(a!==null?`Pearson r \xB7 n \u2248 ${a.toLocaleString()} dies per pair \xB7 click a cell to view that pair in scatter \xB7`:"Pearson r \xB7 click a cell to view that pair in scatter \xB7")+(x?` ${Pt} ${Yt} \xB7`:""),w.appendChild(B);const i=r.ownerDocument.createElement("span");Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:v.xs});const T=r.ownerDocument.createElement("span");T.textContent="\u22121";const P=r.ownerDocument.createElement("span");Object.assign(P.style,{display:"inline-block",width:"64px",height:"8px",borderRadius:rt.control,border:`1px solid ${g.menuBorder}`,background:`linear-gradient(to right, ${lt}, ${g.menuBg}, ${st})`});const F=r.ownerDocument.createElement("span");F.textContent="+1",i.append(T,P,F),w.appendChild(i),k.appendChild(w);const L=r.ownerDocument.createElement("span");if(L.dataset.wmapCaption="1",Object.assign(L.style,{color:g.value,fontSize:X.body,fontWeight:"500"}),e===0&&o===0)L.textContent=m?`No significant correlations found \u2014 strongest pair: ${m.xLabel} \u2194 ${m.yLabel} (r = ${m.r.toFixed(2)})`:"No significant correlations found";else{const p=[];e>0&&p.push(`${e} strong (|r| \u2265 0.7)`),o>0&&p.push(`${o} moderate (0.4\u20130.7)`);const Y=e+o;let l=p.join(", ")+` pair${Y!==1?"s":""} found`;u>0&&(l+=` \xB7 ${u} weak pair${u!==1?"s":""} not shown`),L.textContent=l}k.appendChild(L)}function Mt(e){if(I.innerHTML="",e.tests.length<2)return zt(I,"Need at least two parametric tests for a correlation matrix."),()=>{};const o=r.ownerDocument.createElement("canvas");o.style.display="block",o.style.cursor="default",I.appendChild(o);const u=e.tests.length,m=l=>l.label.split(" (#")[0],s=Math.min(14,Tt(e.tests.map(l=>m(l).length))),a=s*6.5+8,y=10,x=Math.round(y*6.5*Math.sin(Math.PI/4))+14,_=14,w=28,B=44;let i=-1,T=-1;const P=96;function F(l){const c=Math.max(0,l-a),f=Math.floor(c/u);if(!Nt(r))return Math.max(_,Math.min(B,f));const n=Math.floor((Ot(r,I,o)-x-4)/u);return Math.max(_,Math.min(P,f,n))}const L=new Map;for(const l of e.cells){let c=L.get(l.yIndex);c||(c=[],L.set(l.yIndex,c)),c.push(l)}function p(){const l=Ft(r),c=q(l.bg)??[255,255,255],f=I.clientWidth,n=F(f),H=n*u,S=x+n*u+4,D=a+H,R=Vt(o,r,D,S);if(!R)return;const{ctx:t}=R;t.font=`${dt(-1)}px system-ui, sans-serif`,t.fillStyle=l.text,e.tests.forEach((A,C)=>{const M=m(A),N=M.length>y?`${M.slice(0,y-1)}\u2026`:M,et=a+C*n+n/2;t.save(),t.translate(et,x-4),t.rotate(-Math.PI/4),t.textAlign="left",t.textBaseline="bottom",t.fillStyle=C===i?l.text:l.textMuted,t.fillText(N,0,0),t.restore()}),e.tests.forEach((A,C)=>{const M=m(A),N=x+C*n,et=N+n/2;t.font=`${dt(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=C===T?l.text:l.textMuted,t.fillText(M.length>s?`${M.slice(0,s-1)}\u2026`:M,a-4,et),(L.get(C)??[]).forEach(at=>{const nt=at.xIndex,G=a+nt*n,Lt=nt===i&&C===T,ct=nt===C,U=at.r;if(U===null){t.fillStyle=l.border,t.globalAlpha=.4,t.fillRect(G+1,N+1,n-2,n-2),t.globalAlpha=1;return}let ot=l.bgHover;ct?t.fillStyle=l.bgHover:(ot=bt(U>=0?st:lt,c,Math.abs(U)),t.fillStyle=ot),t.fillRect(G+1,N+1,n-2,n-2),n>=w&&!ct&&(t.font=`${Math.min(10,n*.35)}px system-ui, sans-serif`,t.fillStyle=Gt(ot),t.textAlign="center",t.textBaseline="middle",t.fillText(U.toFixed(2),G+n/2,N+n/2)),Lt&&(t.strokeStyle=l.text,t.lineWidth=2,t.strokeRect(G+1,N+1,n-2,n-2),t.lineWidth=1)})}),t.strokeStyle=l.bg,t.lineWidth=1;for(let A=0;A<=u;A++){const C=a+A*n;t.beginPath(),t.moveTo(C,x),t.lineTo(C,x+u*n),t.stroke();const M=x+A*n;t.beginPath(),t.moveTo(a,M),t.lineTo(a+u*n,M),t.stroke()}}function Y(l){const c=o.getBoundingClientRect(),f=I.clientWidth,n=F(f),H=(l.clientX-c.left)*(o.width/ut(o)/c.width),S=(l.clientY-c.top)*(o.height/ut(o)/c.height),D=Math.floor((H-a)/n),R=Math.floor((S-x)/n);return D>=0&&D<u&&R>=0&&R<u?{xi:D,yi:R}:null}return o.addEventListener("mousemove",l=>{const c=Y(l);if(!c){$.style.display="none",o.style.cursor="default";return}const{xi:f,yi:n}=c,H=f===n;o.style.cursor=H||!W?"default":"pointer";const S=e.cells.find(t=>t.xIndex===f&&t.yIndex===n),D=e.tests[f].label,R=e.tests[n].label;H?$.innerHTML=`<strong>${K(D)}</strong>`:S?.r!==null&&S?.r!==void 0?$.innerHTML=`<strong>${K(m(e.tests[n]))}</strong> (#${e.tests[n].testNumber}) vs <strong>${K(m(e.tests[f]))}</strong> (#${e.tests[f].testNumber})<br>r = ${S.r.toFixed(4)} \xB7 n = ${S.n.toLocaleString()}${W?"<br><em>click to view in scatter</em>":""}`:$.innerHTML=`${K(`${R} vs ${D}`)}<br><em>insufficient data</em>`,$.style.display="block",Xt($,r,l.clientX,l.clientY)}),o.addEventListener("mouseleave",()=>{$.style.display="none"}),o.addEventListener("click",l=>{const c=Y(l);if(!c||!W)return;const{xi:f,yi:n}=c;f!==n&&(i=f,T=n,p(),W(e.tests[f].testNumber,e.tests[n].testNumber))}),p}let it=null;function tt(){const e=Ct(),o=e.flatMap(i=>i.dies??[]),u=vt(o,O),{matrix:m,strongPairs:s,moderatePairs:a,hiddenWeakPairs:y,strongestPair:x}=It(u,{minTests:6,maxTests:V}),_=St(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),w=m.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,T)=>i-T),B=w.length?w[Math.floor(w.length/2)]:null;it=m,wt(s,a,y,x,_,B,u.sample,m.tests.some(i=>i.derived)),Z=Mt(m),Z()}const Et=Wt(r,()=>Z());return tt(),{card:r,destroy:()=>Et.disconnect()}}
|
|
1
|
+
import{buildCorrelationMatrix as $t,filterCorrelationMatrix as It,correlationSampleNote as Tt}from"../../stats/correlation.js";import{maxOf as St}from"../../core/utils.js";import{CORRELATION_POSITIVE as st,CORRELATION_NEGATIVE as rt}from"./palette.js";import{buildFacetTable as Dt}from"../../stats/facets.js";import{wireControlHover as Rt,wireTooltip as pt,controlStyle as At,SPACE as L,RADIUS as lt,fontPx as ft,FONT as j,CLR as g}from"../toolbar.js";import{exportCsv as kt}from"../tableExport.js";import{attachChartTip as _t,cardShell as Bt,setChartGrow as Nt,isExpandedCard as Ot,bodyRoom as Wt,observeResize as Ht,makeTooltip as Xt,positionChartTooltip as jt,makeWaferSelect as Vt,renderEmptyState as zt,resolveChartCanvasColors as Ft,prepareCanvas as Pt,chartDpr as ut}from"./chartShell.js";import{escHtml as K}from"../../core/utils.js";import{unmarkedLabel as ht,derivedCsvCell as xt,DERIVED_CSV_HEADER as gt,DERIVED_MARK as Yt,DERIVED_KEY as Gt}from"../../renderer/testLabel.js";const it=5,at=100,bt=20;function q(b){const d=b.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(d)return[+d[1],+d[2],+d[3]];const h=b.trim().replace("#","");return h.length===6?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16)]:null}function Ut(b){const d=q(b);return d?(d[0]*299+d[1]*587+d[2]*114)/1e3>140?"#111":"#fff":"#000"}function yt(b,d,h){const O=q(b);if(!O)return b;const J=Math.round(d[0]+(O[0]-d[0])*h),W=Math.round(d[1]+(O[1]-d[1])*h),l=Math.round(d[2]+(O[2]-d[2])*h);return`rgb(${J},${W},${l})`}export function renderCorrelationPanel(b){const{title:d="Test correlation matrix",items:h,testDefs:O,onSaveImage:J,onSelectPair:W}=b,{card:l,body:$,controlsRow:Q,setPngDecor:wt}=Bt(d,J,b.ownerDocument);wt(()=>{const e=q(l.ownerDocument.defaultView?.getComputedStyle(l).backgroundColor??"")??[255,255,255];return{colorbar:{label:"Pearson r",lo:"\u22121",hi:"+1",color:o=>yt(o<.5?rt:st,e,Math.abs(2*o-1))}}}),Nt(l,"square"),$.style.overflowX="auto",l.style.alignSelf="start";let F=bt,V=null;const H=l.ownerDocument.createElement("label");H.textContent="Max tests:",pt(H,`The most tests the matrix shows, from ${it} to ${at}`),Object.assign(H.style,{color:g.label,fontSize:j.body,display:"flex",alignItems:"center",gap:L.xs});const E=l.ownerDocument.createElement("input");E.type="number",E.min=String(it),E.max=String(at),E.value=String(F),Object.assign(E.style,{width:"52px",fontSize:j.body,padding:`${L.xxs} ${L.xs}`,background:g.menuBg,color:g.value,border:`1px solid ${g.menuBorder}`,borderRadius:lt.control}),E.addEventListener("change",()=>{const e=Math.max(it,Math.min(at,parseInt(E.value,10)||bt));E.value=String(e),e!==F&&(F=e,tt())}),H.appendChild(E),Q.appendChild(H),h.length>1&&Q.appendChild(Vt(h,V,e=>{V=e,tt()},{ownerDocument:l.ownerDocument}));function Ct(){return V!==null?h[V]?[h[V]]:[]:h}if(b.onSaveText){const e=l.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",pt(e,"Save the correlation coefficients as a CSV file, one row per pair of tests"),Object.assign(e.style,{...At("outlined"),color:g.text}),Rt(e),e.addEventListener("click",()=>{const o=ct;if(!o)return;const m=o.tests.some(s=>s.derived),p=[];for(let s=0;s<o.tests.length;s++)for(let a=s+1;a<o.tests.length;a++){const y=o.cells.find(x=>x.xIndex===a&&x.yIndex===s);y&&p.push({x:o.tests[a],y:o.tests[s],r:y.r,n:y.n})}kt([{header:"Test X",get:s=>ht(s.x.label)},{header:"Test X number",get:s=>s.x.testNumber},{header:"Test Y",get:s=>ht(s.y.label)},{header:"Test Y number",get:s=>s.y.testNumber},{header:"r",get:s=>s.r===null?"":s.r.toFixed(6)},{header:"n",get:s=>s.n},...m?[{header:`Test X ${gt.toLowerCase()}`,get:s=>xt(s.x)},{header:`Test Y ${gt.toLowerCase()}`,get:s=>xt(s.y)}]:[]],p,"test-correlation.csv",b.onSaveText)}),Q.appendChild(e)}const k=l.ownerDocument.createElement("div");Object.assign(k.style,{display:"flex",flexDirection:"column",gap:L.xs,marginBottom:L.sm}),l.insertBefore(k,$);const I=Xt(l);_t(H,l,I,"Cap on how many tests the matrix includes (strongest correlations kept first)");let Z=()=>{};function Mt(e,o,m,p,s,a,y,x){k.innerHTML="";const _=Tt(y);if(_){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=`${_} \u2014 r is an estimate, not the whole population.`,Object.assign(f.style,{color:g.label,fontSize:j.body}),k.appendChild(f)}if(s.length>0){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=`\u26A0 Mixed ${s.join(", ")} within this set \u2014 correlations may be misleading (Simpson's paradox). Use Group by, or the Wafer picker, to narrow to a like-for-like set.`,Object.assign(f.style,{color:g.warnText,background:g.warnBg,border:`1px solid ${g.warnBorder}`,borderRadius:lt.control,padding:`${L.xs} ${L.md}`,fontSize:j.body}),k.appendChild(f)}const C=l.ownerDocument.createElement("span");Object.assign(C.style,{display:"inline-flex",alignItems:"center",gap:L.sm,color:g.label,fontSize:j.body,flexWrap:"wrap"});const B=l.ownerDocument.createElement("span");B.dataset.wmapCaption="1",B.textContent=(a!==null?`Pearson r \xB7 n \u2248 ${a.toLocaleString()} dies per pair \xB7 click a cell to view that pair in scatter \xB7`:"Pearson r \xB7 click a cell to view that pair in scatter \xB7")+(x?` ${Yt} ${Gt} \xB7`:""),C.appendChild(B);const i=l.ownerDocument.createElement("span");Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:L.xs});const T=l.ownerDocument.createElement("span");T.textContent="\u22121";const P=l.ownerDocument.createElement("span");Object.assign(P.style,{display:"inline-block",width:"64px",height:"8px",borderRadius:lt.control,border:`1px solid ${g.menuBorder}`,background:`linear-gradient(to right, ${rt}, ${g.menuBg}, ${st})`});const z=l.ownerDocument.createElement("span");z.textContent="+1",i.append(T,P,z),C.appendChild(i),k.appendChild(C);const v=l.ownerDocument.createElement("span");if(v.dataset.wmapCaption="1",Object.assign(v.style,{color:g.value,fontSize:j.body,fontWeight:"500"}),e===0&&o===0)v.textContent=p?`No significant correlations found \u2014 strongest pair: ${p.xLabel} \u2194 ${p.yLabel} (r = ${p.r.toFixed(2)})`:"No significant correlations found";else{const f=[];e>0&&f.push(`${e} strong (|r| \u2265 0.7)`),o>0&&f.push(`${o} moderate (0.4\u20130.7)`);const Y=e+o;let r=f.join(", ")+` pair${Y!==1?"s":""} found`;m>0&&(r+=` \xB7 ${m} weak pair${m!==1?"s":""} not shown`),v.textContent=r}k.appendChild(v)}function Et(e){if($.innerHTML="",e.tests.length<2)return zt($,"Need at least two parametric tests for a correlation matrix."),()=>{};const o=l.ownerDocument.createElement("canvas");o.style.display="block",o.style.cursor="default",$.appendChild(o);const m=e.tests.length,p=r=>r.label.split(" (#")[0],s=Math.min(14,St(e.tests.map(r=>p(r).length))),a=s*6.5+8,y=10,x=Math.round(y*6.5*Math.sin(Math.PI/4))+14,_=14,C=28,B=44;let i=-1,T=-1;const P=96;function z(r){const c=Math.max(0,r-a),u=Math.floor(c/m);if(!Ot(l))return Math.max(_,Math.min(B,u));const n=Math.floor((Wt(l,$,o)-x-4)/m);return Math.max(_,Math.min(P,u,n))}const v=new Map;for(const r of e.cells){let c=v.get(r.yIndex);c||(c=[],v.set(r.yIndex,c)),c.push(r)}function f(){const r=Ft(l),c=q(r.bg)??[255,255,255],u=$.clientWidth,n=z(u),X=n*m,S=x+n*m+4,D=a+X,R=Pt(o,l,D,S);if(!R)return;const{ctx:t}=R;t.font=`${ft(-1)}px system-ui, sans-serif`,t.fillStyle=r.text,e.tests.forEach((A,w)=>{const M=p(A),N=M.length>y?`${M.slice(0,y-1)}\u2026`:M,et=a+w*n+n/2;t.save(),t.translate(et,x-4),t.rotate(-Math.PI/4),t.textAlign="left",t.textBaseline="bottom",t.fillStyle=w===i?r.text:r.textMuted,t.fillText(N,0,0),t.restore()}),e.tests.forEach((A,w)=>{const M=p(A),N=x+w*n,et=N+n/2;t.font=`${ft(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=w===T?r.text:r.textMuted,t.fillText(M.length>s?`${M.slice(0,s-1)}\u2026`:M,a-4,et),(v.get(w)??[]).forEach(dt=>{const nt=dt.xIndex,G=a+nt*n,Lt=nt===i&&w===T,mt=nt===w,U=dt.r;if(U===null){t.fillStyle=r.border,t.globalAlpha=.4,t.fillRect(G+1,N+1,n-2,n-2),t.globalAlpha=1;return}let ot=r.bgHover;mt?t.fillStyle=r.bgHover:(ot=yt(U>=0?st:rt,c,Math.abs(U)),t.fillStyle=ot),t.fillRect(G+1,N+1,n-2,n-2),n>=C&&!mt&&(t.font=`${Math.min(10,n*.35)}px system-ui, sans-serif`,t.fillStyle=Ut(ot),t.textAlign="center",t.textBaseline="middle",t.fillText(U.toFixed(2),G+n/2,N+n/2)),Lt&&(t.strokeStyle=r.text,t.lineWidth=2,t.strokeRect(G+1,N+1,n-2,n-2),t.lineWidth=1)})}),t.strokeStyle=r.bg,t.lineWidth=1;for(let A=0;A<=m;A++){const w=a+A*n;t.beginPath(),t.moveTo(w,x),t.lineTo(w,x+m*n),t.stroke();const M=x+A*n;t.beginPath(),t.moveTo(a,M),t.lineTo(a+m*n,M),t.stroke()}}function Y(r){const c=o.getBoundingClientRect(),u=$.clientWidth,n=z(u),X=(r.clientX-c.left)*(o.width/ut(o)/c.width),S=(r.clientY-c.top)*(o.height/ut(o)/c.height),D=Math.floor((X-a)/n),R=Math.floor((S-x)/n);return D>=0&&D<m&&R>=0&&R<m?{xi:D,yi:R}:null}return o.addEventListener("mousemove",r=>{const c=Y(r);if(!c){I.style.display="none",o.style.cursor="default";return}const{xi:u,yi:n}=c,X=u===n;o.style.cursor=X||!W?"default":"pointer";const S=e.cells.find(t=>t.xIndex===u&&t.yIndex===n),D=e.tests[u].label,R=e.tests[n].label;X?I.innerHTML=`<strong>${K(D)}</strong>`:S?.r!==null&&S?.r!==void 0?I.innerHTML=`<strong>${K(p(e.tests[n]))}</strong> (#${e.tests[n].testNumber}) vs <strong>${K(p(e.tests[u]))}</strong> (#${e.tests[u].testNumber})<br>r = ${S.r.toFixed(4)} \xB7 n = ${S.n.toLocaleString()}${W?"<br><em>click to view in scatter</em>":""}`:I.innerHTML=`${K(`${R} vs ${D}`)}<br><em>insufficient data</em>`,I.style.display="block",jt(I,l,r.clientX,r.clientY)}),o.addEventListener("mouseleave",()=>{I.style.display="none"}),o.addEventListener("click",r=>{const c=Y(r);if(!c||!W)return;const{xi:u,yi:n}=c;u!==n&&(i=u,T=n,f(),W(e.tests[u].testNumber,e.tests[n].testNumber))}),f}let ct=null;function tt(){const e=Ct(),o=e.flatMap(i=>i.dies??[]),m=$t(o,O),{matrix:p,strongPairs:s,moderatePairs:a,hiddenWeakPairs:y,strongestPair:x}=It(m,{minTests:6,maxTests:F}),_=Dt(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),C=p.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,T)=>i-T),B=C.length?C[Math.floor(C.length/2)]:null;ct=p,Mt(s,a,y,x,_,B,m.sample,p.tests.some(i=>i.derived)),Z=Et(p),Z()}const vt=Ht(l,()=>Z());return tt(),{card:l,destroy:()=>vt.disconnect()}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{escHtml as I,maxOf as fe,minOf as We}from"../../core/utils.js";import{fiveNumberSummary as Be}from"../../stats/math.js";import{fmt as R}from"../../renderer/fmt.js";import{fitTicks as Te}from"../../renderer/axisTicks.js";import{plotFootnote as Fe,plotTestNumber as Oe,plotTitle as et}from"../../stats/plotData.js";import{SPACE as ee,RADIUS as tt,fontPx as me,FONT as we,CLR as xe,markNoPrint as ze}from"../toolbar.js";import{cardShell as nt,observeResize as ot,makeTooltip as it,attachChartTip as lt,chartFillHeight as st,applyCanvasFlow as ke,prepareCanvas as Me,positionChartTooltip as Le,resolveChartCanvasColors as ve,makeAxisFormat as at,horizontalTickSpacing as rt,VERTICAL_TICK_SPACING_PX as ct,makeSeriesLegendItem as ft,renderEmptyState as Re,limitLines as mt,limitExtent as ht,stackLabelRows as qe,strokeLimitLine as He,drawOffAxisLimits as ut,limitLabelSide as dt,shouldIncludeLimitsByDefault as gt}from"./chartShell.js";import{categorical as pt}from"./palette.js";import{resolveValueColorFn as $e}from"../../renderer/colorSchemes.js";import{wirePointInteractions as yt}from"./pointInteractions.js";const M=64,Xe=16,k=12,he=52,bt=16,Pe=5e3;function te(b,P,$={}){const q=P.scale==="log";let w=b.length?We(b):0,O=b.length?fe(b):1;q&&(w=Math.log10(Math.max(w,Number.MIN_VALUE)),O=Math.log10(Math.max(O,Number.MIN_VALUE)));const ne=(O-w)*.05||(q?.5:1);w=$.floorAtZero&&!q&&w>=0?0:w-ne,O+=ne;const s=x=>x===void 0||!Number.isFinite(x)?void 0:q?x>0?Math.log10(x):void 0:x,g=s(P.min),H=s(P.max);g!==void 0&&(w=g),H!==void 0&&(O=H),O>w||(O=w+1);const C=O-w,V=!!P.reverse,Z=x=>{const Y=((q?Math.log10(Math.max(x,Number.MIN_VALUE)):x)-w)/C;return V?1-Y:Y};return{lo:q?10**w:w,hi:q?10**O:O,log:q,reverse:V,frac:Z}}function _e(b,P,$,q){if(P/b<10)return Te(b,P,$,q);const w=Math.floor(Math.log10(b)),O=Math.ceil(Math.log10(P)),ne=g=>{const H=[];for(let C=w;C<=O;C++)for(const V of g){const Z=V*10**C;Z>=b&&Z<=P&&H.push(Z)}return H},L=ne([1]);return{ticks:L.length>=4?L:ne([1,2,5]),step:0}}export function renderPlotChart(b){const P=b.ownerDocument??document,{card:$,heading:q,body:w,controlsRow:O,setPngDecor:ne}=nt("Plot",b.onSaveImage,P);$.dataset.wmapPlotCard="1";const L=it($);let s,g,H,C,V,Z=[];const x=new Set,Y=new Set;let ue=null,X=-1,ce=[],z,K,G,_=null,J=[],D=-1,de=he;const oe=e=>pt(e),ge=e=>s?.groups[e]||"";function pe(){const e=w.clientWidth,l=Math.max(220,Math.min(420,e*.62))+(de-he),c=st($,w,g,l);return{w:e,h:c,plotW:Math.max(10,e-M-Xe),plotH:Math.max(10,c-k-de)}}const ie=e=>mt(e?.limits,s?.spec.limits??"both").filter(l=>e?.scale!=="log"||l.value>0),ae=(e,l)=>{const c=e.filter(Number.isFinite);if(!l.length||c.length===0)return e;const{lo:r,hi:i}=ht(l);return gt(We(c),fe(c),r,i)?[...e,...l.map(o=>o.value)]:e};function re(e,l,c,r,i,o,t,n){if(o.length===0)return;const f=o.filter(h=>h.value>=i.lo&&h.value<=i.hi),p=o.filter(h=>!f.includes(h)).map(h=>({value:h.value,label:h.label,side:h.value<i.lo?"lo":"hi"}));e.save(),e.font=`${me(-1)}px system-ui, sans-serif`;const d=h=>`${h.label} ${R(h.value,t.unit)}`,a=me(-1)+2;if(n==="y"){const h=f.map(m=>{const y=k+(1-i.frac(m.value))*r;return{l:m,y,start:y-6-a/2,end:y-6+a/2}}),S=qe(h,1),u=h.length?fe(h.map(m=>e.measureText(d(m.l)).width))+8:0;h.forEach(({l:m,y},v)=>{e.globalAlpha=.7,He(e,m,l,M,y,M+c,y),e.globalAlpha=1,e.fillStyle=l,e.textAlign="left",e.textBaseline="alphabetic",e.fillText(d(m),M+3+S[v]*u,y-4)})}else{const h=f.map(u=>{const m=M+i.frac(u.value)*c,y=e.measureText(d(u)).width,v=dt(m,y,M,M+c,u.end==="lo");return{l:u,x:m,side:v,start:v<0?m-3-y:m+3,end:v<0?m-3:m+3+y}}),S=qe(h,4);h.forEach(({l:u,x:m,side:y},v)=>{e.globalAlpha=.7,He(e,u,l,m,k,m,k+r),e.globalAlpha=1,e.fillStyle=l,e.textAlign=y<0?"right":"left",e.textBaseline="top",e.fillText(d(u),m+y*3,k+2+S[v]*a)})}e.restore(),ut(e,p,{left:M,right:M+c,top:k,bottom:k+r},n==="y"?"vertical":"horizontal",l,h=>R(h,t.unit))}function Ee(e,l,c,r){return at(Math.max(Math.abs(l),Math.abs(c)),e.unit,r)}function Ce(e,l){return l?`${e.label} (${l})`:e.label}function ye(e,l,c,r,i,o,t,n,f,p){e.font=`${me(-1)}px system-ui, sans-serif`;const d=()=>ct,a=n.log?_e(n.lo,n.hi,o,d):Te(n.lo,n.hi,o,d),h=Ee(p,n.lo,n.hi,a.step||void 0);e.strokeStyle=l.grid,e.lineWidth=.5,e.fillStyle=l.textMuted;let S="";if("labels"in t){const u=t.labels.length;t.labels.forEach((m,y)=>{const v=M+(y+.5)/u*i,T=m.length>22?`${m.slice(0,21)}\u2026`:m;t.rotate?(e.save(),e.translate(v,k+o+6),e.rotate(-Math.PI/4),e.textAlign="right",e.textBaseline="middle",e.fillText(T,0,0),e.restore()):(e.textAlign="center",e.textBaseline="top",e.fillText(T,v,k+o+4))})}else{const u=rt(e,Math.max(Math.abs(t.lo),Math.abs(t.hi)),f.unit),m=t.log?_e(t.lo,t.hi,i,u):Te(t.lo,t.hi,i,u),y=Ee(f,t.lo,t.hi,m.step||void 0);S=y.unitLabel;for(const v of m.ticks){const T=M+t.frac(v)*i;e.beginPath(),e.moveTo(T,k),e.lineTo(T,k+o),e.stroke(),e.textAlign="center",e.textBaseline="top",e.fillText(y.tick(v),T,k+o+4)}}for(const u of a.ticks){const m=k+(1-n.frac(u))*o;e.beginPath(),e.moveTo(M,m),e.lineTo(M+i,m),e.stroke(),e.textAlign="right",e.textBaseline="middle",e.fillText(h.tick(u),M-4,m)}e.font=`${me(0)}px system-ui, sans-serif`,e.fillStyle=l.text,e.textAlign="center",e.textBaseline="bottom",e.fillText(Ce(f,S),M+i/2,r-6),e.save(),e.translate(14,k+o/2),e.rotate(-Math.PI/2),e.textBaseline="top",e.fillText(Ce(p,h.unitLabel),0,0),e.restore(),e.strokeStyle=l.border,e.lineWidth=1,e.beginPath(),e.moveTo(M,k),e.lineTo(M,k+o),e.moveTo(M,k+o),e.lineTo(M+i,k+o),e.stroke()}function je(){if(!s||!g||s.marks?.type!=="scatter"||!s.x||!s.y)return;ke(g,C??0);const e=ve($),{w:l,h:c,plotW:r,plotH:i}=pe(),o=Me(g,$,l,c);if(!o)return;const{ctx:t}=o,n=s.marks.points,f=x.size===0?n:n.filter(A=>x.has(A.group)),p=s.colorScale,d=$e(),a=ie(s.x),h=ie(s.y),S=te(ae(n.map(A=>A.x),a),s.x),u=te(ae(n.map(A=>A.y),h),s.y);z={x:S,y:u,plotW:r,plotH:i},ye(t,e,l,c,r,i,S,u,s.x,s.y),re(t,e.limitLine,r,i,S,a,s.x,"x"),re(t,e.limitLine,r,i,u,h,s.y,"y");const m=f.length>Pe?Math.ceil(f.length/Pe):1;t.globalAlpha=Math.max(.15,Math.min(.7,200/(f.length/m))),ce=[];const y=M,v=M+r,T=k,le=k+i;for(let A=0;A<f.length;A+=m){const N=f[A],se=M+S.frac(N.x)*r,U=k+(1-u.frac(N.y))*i;se<y||se>v||U<T||U>le||(ce.push({p:N,cx:se,cy:U}),t.beginPath(),t.arc(se,U,2.5,0,Math.PI*2),t.fillStyle=p&&N.value!==void 0?d((N.value-p.lo)/(p.hi-p.lo||1)):oe(N.group),t.fill())}t.globalAlpha=1;const E=ue?ce.find(A=>A.p===ue):void 0;if(E&&(t.beginPath(),t.arc(E.cx,E.cy,5,0,Math.PI*2),t.lineWidth=2,t.strokeStyle=e.text,t.stroke()),Y.size>0){t.lineWidth=1.5,t.strokeStyle=e.text;let A=0;for(const N of Y)if(!(x.size>0&&!x.has(N.group))){if(++A>Pe)break;t.beginPath(),t.arc(M+S.frac(N.x)*r,k+(1-u.frac(N.y))*i,4,0,Math.PI*2),t.stroke()}}}function Ue(){if(K=void 0,!s||s.marks?.type!=="histogram"||!s.x)return;const e=s.marks.values,l=e.flat();if(l.length===0)return;const c=te(ae(l,ie(s.x)),s.x),r=Math.max(1,s.spec.bins??bt),i=c.log?Math.log10(c.lo):c.lo,o=c.log?Math.log10(c.hi):c.hi,t=Array.from({length:r+1},(f,p)=>{const d=i+(o-i)*p/r;return c.log?10**d:d}),n=e.map(()=>new Array(r).fill(0));e.forEach((f,p)=>{for(const d of f){const a=c.log?d>0?Math.log10(d):NaN:d;if(!Number.isFinite(a)||a<i||a>o)continue;const h=Math.min(r-1,Math.floor((a-i)/(o-i)*r));n[p][h]++}}),K={edges:t,counts:n,maxCount:Math.max(1,...n.map(f=>fe(f)))}}function Ye(){if(!s||!g||!K||!s.x||!s.y)return;ke(g,C??0);const e=ve($),{w:l,h:c,plotW:r,plotH:i}=pe(),o=Me(g,$,l,c);if(!o)return;const{ctx:t}=o,{edges:n,counts:f,maxCount:p}=K,d=te([n[0],n[n.length-1]],{...s.x,min:n[0],max:n[n.length-1]}),a=te([0,p],{label:s.y.label,scale:"linear",min:0,max:p*1.05});z={x:d,y:a,plotW:r,plotH:i},ye(t,e,l,c,r,i,d,a,s.x,s.y),re(t,e.limitLine,r,i,d,ie(s.x),s.x,"x");const h=f.map((u,m)=>m).filter(u=>x.size===0||x.has(u)),S=h.length>1;for(const u of h)t.globalAlpha=S?.55:.85,t.fillStyle=oe(u),f[u].forEach((m,y)=>{if(m===0)return;const v=M+Math.min(d.frac(n[y]),d.frac(n[y+1]))*r,T=M+Math.max(d.frac(n[y]),d.frac(n[y+1]))*r,le=k+(1-a.frac(m))*i;t.fillRect(v,le,Math.max(1,T-v-1),k+i-le)});if(t.globalAlpha=1,X>=0){const u=M+Math.min(d.frac(n[X]),d.frac(n[X+1]))*r,m=M+Math.max(d.frac(n[X]),d.frac(n[X+1]))*r;t.lineWidth=1.5,t.strokeStyle=e.text,t.strokeRect(u,k,Math.max(1,m-u),i)}}function Ge(){const e=s?.marks;if(!s||!g||!s.x||!s.y||!e||e.type!=="box"&&e.type!=="bar")return;ke(g,C??0);const l=ve($),c=g.getContext("2d");let r=0;c&&(c.font=`${me(-1)}px system-ui, sans-serif`,r=fe(e.categories.map(E=>c.measureText(E.length>22?`${E.slice(0,21)}\u2026`:E).width)));const i=Math.max(10,w.clientWidth-M-Xe)/Math.max(1,e.categories.length),o=r+8>i;de=o?he+Math.min(110,r*.72):he;const{w:t,h:n,plotW:f,plotH:p}=pe(),d=Me(g,$,t,n);if(!d)return;const{ctx:a}=d,h=E=>E.filter(Number.isFinite),S=ie(s.y),u=te(ae(e.type==="bar"?[...h(e.values.flat()),0]:h(e.cells.flat(2)),S),s.y,{floorAtZero:e.type==="bar"});z={x:u,y:u,plotW:f,plotH:p},ye(a,l,t,n,f,p,{labels:e.categories,rotate:o},u,s.x,s.y),re(a,l.limitLine,f,p,u,S,s.y,"y");const m=e.categories.length,y=s.groups.length,v=f/m,T=v*.8/y;G={slotW:v,gw:T,n:m,groups:y,plotW:f};const le=u.log?k+p:k+(1-u.frac(0))*p;for(let E=0;E<y;E++){if(x.size>0&&!x.has(E))continue;const A=oe(E);for(let N=0;N<m;N++){const se=M+N*v+v*.1+E*T;if(e.type==="bar"){const U=e.values[E][N];if(!Number.isFinite(U))continue;const j=k+(1-u.frac(U))*p;a.fillStyle=A,a.globalAlpha=.9,a.fillRect(se+1,Math.min(j,le),Math.max(1,T-2),Math.max(1,Math.abs(le-j))),a.globalAlpha=1}else{const U=e.cells[E][N];if(U.length===0)continue;const j=se+T/2,Q=Math.max(3,Math.min(T*.7,46)),B=Be(Float64Array.from(U)),F=be=>k+(1-u.frac(be))*p;if(a.strokeStyle=A,a.fillStyle=A,a.lineWidth=1.5,U.length===1){a.beginPath(),a.arc(j,F(B.median),3,0,Math.PI*2),a.fill();continue}a.beginPath(),a.moveTo(j,F(B.min)),a.lineTo(j,F(B.max)),a.stroke();for(const be of[B.min,B.max])a.beginPath(),a.moveTo(j-Q/4,F(be)),a.lineTo(j+Q/4,F(be)),a.stroke();a.globalAlpha=.35,a.fillRect(j-Q/2,Math.min(F(B.q1),F(B.q3)),Q,Math.max(1,Math.abs(F(B.q1)-F(B.q3)))),a.globalAlpha=1,a.strokeRect(j-Q/2,Math.min(F(B.q1),F(B.q3)),Q,Math.max(1,Math.abs(F(B.q1)-F(B.q3)))),a.lineWidth=2.5,a.beginPath(),a.moveTo(j-Q/2,F(B.median)),a.lineTo(j+Q/2,F(B.median)),a.stroke()}}}if(_){const E=M+_.c*v+v*.1+_.g*T;a.lineWidth=1.5,a.strokeStyle=l.text,a.strokeRect(E,k,T,p)}}function Ae(e){if(!G||!g)return null;const l=g.getBoundingClientRect(),c=e.clientX-l.left-M;if(c<0||c>G.plotW)return null;const r=Math.min(G.n-1,Math.floor(c/G.slotW)),i=Math.floor((c-r*G.slotW-G.slotW*.1)/G.gw);return i<0||i>=G.groups?null:{g:i,c:r}}function De(e){const l=s,c=l.marks,r=l.level==="die"?"dies":"wafers",i=c.cells[e.g][e.c],o=`<strong>${I(c.categories[e.c])}${l.groups.length>1?` \xB7 ${I(ge(e.g))}`:""}</strong><br>`,t=l.y?.unit;if(i.length===0)return`${o}no ${r}`;const n=`${i.length.toLocaleString("en-GB")} ${r}`,f=c.categoryItems&&b.onOpenWafer?`<br><em>click to ${I(b.openActionLabel??"open this wafer")}</em>`:"";if(c.type==="bar"){const d=c.values[e.g][e.c];return`${o}${I(`${l.y.label}: ${R(d,t)}`)}<br>${I(n)}${f}`}const p=Be(Float64Array.from(i));return`${o}${["max","q3","median","q1","min"].map(d=>I(`${{max:"max",q3:"upper quartile",median:"median",q1:"lower quartile",min:"min"}[d]}: ${R(p[d],t)}`)).join("<br>")}<br>${I(n)}${f}`}function Ve(){const e=s?.marks;if(!s||!g||!s.x||!s.y||!e||e.type!=="line")return;ke(g,C??0);const l=ve($),{w:c,h:r,plotW:i,plotH:o}=pe(),t=Me(g,$,c,r);if(!t)return;const{ctx:n}=t,f=ie(s.x),p=ie(s.y),d=te(ae(e.xs,f),s.x),a=te(ae(e.values.flat().filter(Number.isFinite),p),s.y);z={x:d,y:a,plotW:i,plotH:o},ye(n,l,c,r,i,o,d,a,s.x,s.y),re(n,l.limitLine,i,o,d,f,s.x,"x"),re(n,l.limitLine,i,o,a,p,s.y,"y"),J=e.xs.map(h=>M+d.frac(h)*i),e.values.forEach((h,S)=>{if(x.size>0&&!x.has(S))return;n.strokeStyle=oe(S),n.fillStyle=oe(S),n.lineWidth=2;let u=!1;n.beginPath(),h.forEach((m,y)=>{if(!Number.isFinite(m)){u=!1;return}const v=J[y],T=k+(1-a.frac(m))*o;u?n.lineTo(v,T):n.moveTo(v,T),u=!0}),n.stroke(),h.forEach((m,y)=>{Number.isFinite(m)&&(n.beginPath(),n.arc(J[y],k+(1-a.frac(m))*o,D===y?4.5:3,0,Math.PI*2),n.fill())})}),D>=0&&(n.lineWidth=1,n.strokeStyle=l.textMuted,n.beginPath(),n.moveTo(J[D],k),n.lineTo(J[D],k+o),n.stroke())}function Ie(e){const l=s?.marks;if(!l||l.type!=="line"||!g||!s?.x||J.length===0)return null;const c=e.clientX-g.getBoundingClientRect().left;let r=-1,i=24;if(J.forEach((n,f)=>{const p=Math.abs(n-c);p<i&&(i=p,r=f)}),D=r,r<0)return null;const o=s.level==="die"?"dies":"wafers",t=l.values.map((n,f)=>({g:f,v:n[r],n:l.counts[f][r]})).filter(n=>Number.isFinite(n.v)&&(x.size===0||x.has(n.g)));return`<strong>${I(`${s.x.label}: ${R(l.xs[r],s.x.unit)}`)}</strong><br>`+t.map(n=>I(`${s.groups.length>1?`${ge(n.g)}: `:""}${R(n.v,s.y.unit)} (${n.n.toLocaleString("en-GB")} ${o})`)).join("<br>")}function W(){const e=s?.marks?.type;e==="scatter"?je():e==="histogram"?Ye():e==="box"||e==="bar"?Ge():e==="line"&&Ve()}function Ze(e){const l=s,c=b.waferLabel(e.item),r=e.die&&e.die.x!==void 0?`die (${e.die.x}, ${e.die.y})`:"",i=[c,r].filter(Boolean).join(" \xB7 "),o=(t,n)=>`${t.label}: ${R(n,t.unit)}`;return(i?`<strong>${I(i)}</strong><br>`:"")+I(o(l.x,e.x))+"<br>"+I(o(l.y,e.y))+(l.colorScale&&e.value!==void 0?`<br>${I(`${l.colorScale.label}: ${R(e.value,l.colorScale.unit)}`)}`:"")+(l.groups.length>1?`<br>${I(ge(e.group))}`:"")+(b.onOpenWafer?`<br><em>click to ${I(b.openActionLabel??"open this wafer")}</em>`:"")}function Ne(e){if(!K||!z||!s?.x)return null;const l=g.getBoundingClientRect(),r=(e.clientX-l.left-M)/z.plotW;if(r<0||r>1)return null;const i=z.x.reverse?1-r:r,{edges:o,counts:t}=K,n=o.length-1,f=Math.min(n-1,Math.max(0,Math.floor(i*n)));X=f;const p=s.x,d=t.map((a,h)=>({g:h,n:a[f]})).filter(a=>a.n>0&&(x.size===0||x.has(a.g)));return`<strong>${I(`${R(o[f],p.unit)} to ${R(o[f+1],p.unit)}`)}</strong><br>`+(d.length?d.map(a=>I(`${s.groups.length>1?`${ge(a.g)}: `:""}${a.n.toLocaleString("en-GB")} ${s.level==="die"?"dies":"wafers"}`)).join("<br>"):"none")}function Ke(e){const l=P.createElement("div");l.dataset.wmapPlotColorbar="1",Object.assign(l.style,{display:"flex",alignItems:"center",gap:ee.md,marginTop:ee.md,marginBottom:ee.xl,fontSize:we.body,color:xe.label});const c=P.createElement("canvas");c.width=200,c.height=10,Object.assign(c.style,{width:"200px",height:"10px",borderRadius:tt.control,flex:"0 0 auto"});const r=c.getContext("2d"),i=$e();if(r)for(let f=0;f<200;f++)r.fillStyle=i(f/199),r.fillRect(f,0,1,10);const o=P.createElement("span");o.textContent=R(e.lo,e.unit);const t=P.createElement("span");t.textContent=R(e.hi,e.unit);const n=P.createElement("span");return n.textContent=e.label,n.style.color=xe.text,l.append(n,o,c,t),l}const Se=(e,l,c)=>l.map(r=>{const{item:i,die:o}=e(r);return{x:0,y:0,group:c,item:i,die:o}});function Je(){V?.destroy(),V=void 0,w.innerHTML="",g=void 0,H=void 0,C=void 0,Z=[],ue=null,X=-1,ce=[],z=void 0,G=void 0,_=null,J=[],D=-1,de=he,x.clear(),Y.clear();const e=s;if(!e)return;if(q.textContent=et(e),$.dataset.wmapChartTitle=q.textContent,e.issues.length||!e.marks){for(const i of e.issues)Re(w,i);return}const l=P.createElement("div");Object.assign(l.style,{color:xe.label,fontSize:we.body,marginBottom:ee.xs});const c=b.openActionLabel??"open this wafer",r=e.marks.type==="scatter"?(b.onOpenWafer?` \xB7 click a point to ${c}`:"")+(b.onSelectPoints?` \xB7 drag to select ${e.level==="die"?"dies":"wafers"}`:""):e.marks.type==="box"||e.marks.type==="bar"?(b.onOpenWafer&&e.marks.categoryItems?` \xB7 click to ${c}`:b.onSelectPoints?" \xB7 click to chart or tabulate what it counts":"")+(e.marks.type==="box"?" \xB7 box: quartiles; whiskers: minimum and maximum":""):e.marks.type==="histogram"&&b.onSelectPoints?" \xB7 click a bar to chart or tabulate its dies":e.marks.type==="line"&&b.onSelectPoints?" \xB7 click a point to chart or tabulate what it averages":"";l.textContent=Fe(e)+r,ze(l),C=P.createElement("div"),C.style.display="flow-root",w.appendChild(C),C.appendChild(l);for(const i of e.notes){const o=P.createElement("div");ze(o),o.textContent=i,Object.assign(o.style,{color:xe.warnText,fontSize:we.body,marginBottom:ee.xs}),C.appendChild(o)}if(e.plotted===0){Re(w,"Nothing to plot: no mark has every value this plot needs.");return}if(e.groups.length>1&&(H=P.createElement("div"),Object.assign(H.style,{display:"flex",flexWrap:"wrap",gap:ee.sm,marginTop:ee.md,marginBottom:ee.xl}),e.groups.forEach((i,o)=>{const t=ft(i||"(none)",oe(o),P);lt(t.el,$,L,`${i||"(none)"} \u2014 click to filter`),t.el.addEventListener("click",()=>{x.has(o)?x.delete(o):x.add(o),Z.forEach((n,f)=>n.setState({selected:x.has(f),dimmed:x.size>0&&!x.has(f)})),W()}),Z.push(t),H.appendChild(t.el)}),C.appendChild(H)),e.colorScale&&(H=Ke(e.colorScale),C.appendChild(H)),g=P.createElement("canvas"),g.style.display="block",g.style.cursor=e.marks.type==="scatter"?"crosshair":"default",w.appendChild(g),e.marks.type==="scatter"){const i=e.marks,o=!!b.onSelectPoints;V=yt({card:$,canvas:g,tooltip:L,drawn:()=>ce,describe:Ze,clickable:()=>!!b.onOpenWafer,onOpen:t=>b.onOpenWafer?.(t.item,Oe(e.spec)),onHover:t=>{ue=t,W()},select:o?{pick:({x0:t,y0:n,x1:f,y1:p})=>z?(x.size===0?i.points:i.points.filter(a=>x.has(a.group))).filter(a=>{const h=M+z.x.frac(a.x)*z.plotW,S=k+(1-z.y.frac(a.y))*z.plotH;return h>=t&&h<=f&&S>=n&&S<=p}):[],onPicked:(t,n)=>{Y.clear();for(const f of t)Y.add(f);W(),t.length>0&&b.onSelectPoints(t,n,g)},onClear:()=>{Y.clear(),W()},hasSelection:()=>Y.size>0}:void 0})}else if(e.marks.type==="histogram"){Ue(),g.addEventListener("mousemove",o=>{const t=Ne(o);if(!t){L.style.display="none",X>=0&&(X=-1,W());return}L.innerHTML=t,L.style.display="block",Le(L,$,o.clientX,o.clientY),W()}),g.addEventListener("mouseleave",()=>{L.style.display="none",X>=0&&(X=-1,W())});const i=e.marks;b.onSelectPoints&&(g.style.cursor="pointer",g.addEventListener("click",o=>{if(!K||Ne(o)===null)return;const t=X,{edges:n}=K,f=z?.x.log,p=f?Math.log10(n[0]):n[0],d=f?Math.log10(n[n.length-1]):n[n.length-1],a=n.length-1,h=[];i.values.forEach((S,u)=>{if(x.size>0&&!x.has(u))return;const m=[];S.forEach((y,v)=>{const T=f?y>0?Math.log10(y):NaN:y;!Number.isFinite(T)||T<p||T>d||Math.min(a-1,Math.floor((T-p)/(d-p)*a))===t&&m.push(i.units[u][v])}),h.push(...Se(i.unit,m,u))}),h.length>0&&(L.style.display="none",b.onSelectPoints(h,{x:o.clientX,y:o.clientY},g))}))}else if(e.marks.type==="box"||e.marks.type==="bar"){const i=e.marks;g.addEventListener("mousemove",o=>{const t=Ae(o);if(g.style.cursor=t&&(i.categoryItems&&b.onOpenWafer||b.onSelectPoints&&i.cellUnits[t.g][t.c].length>0)?"pointer":"default",!t){L.style.display="none",_&&(_=null,W());return}L.innerHTML=De(t),L.style.display="block",Le(L,$,o.clientX,o.clientY),(!_||_.g!==t.g||_.c!==t.c)&&(_=t,W())}),g.addEventListener("mouseleave",()=>{L.style.display="none",_&&(_=null,W())}),g.addEventListener("click",o=>{const t=Ae(o);if(!t)return;const n=i.categoryItems?.[t.c];if(n!==void 0&&n>=0&&b.onOpenWafer){b.onOpenWafer(n,Oe(e.spec));return}const f=i.cellUnits[t.g][t.c];f.length>0&&b.onSelectPoints&&(L.style.display="none",b.onSelectPoints(Se(i.unit,f,t.g),{x:o.clientX,y:o.clientY},g))})}else if(e.marks.type==="line"){g.addEventListener("mousemove",o=>{const t=Ie(o);if(!t){L.style.display="none",W();return}L.innerHTML=t,L.style.display="block",Le(L,$,o.clientX,o.clientY),W()}),g.addEventListener("mouseleave",()=>{L.style.display="none",D>=0&&(D=-1,W())});const i=e.marks;b.onSelectPoints&&(g.style.cursor="pointer",g.addEventListener("click",o=>{if(Ie(o)===null||D<0)return;const t=i.cellUnits.flatMap((n,f)=>x.size>0&&!x.has(f)?[]:Se(i.unit,n[D]??[],f));t.length>0&&(L.style.display="none",b.onSelectPoints(t,{x:o.clientX,y:o.clientY},g))}))}W()}ne(()=>{const e=s;if(!e||!e.marks)return;const l=$e();return{caption:[Fe(e),...e.notes],legend:e.groups.length>1?e.groups.map((c,r)=>({label:c||"(none)",color:oe(r)})):void 0,colorbar:e.colorScale?{label:e.colorScale.label,lo:R(e.colorScale.lo,e.colorScale.unit),hi:R(e.colorScale.hi,e.colorScale.unit),color:l}:void 0}});const Qe=ot($,()=>W());return{card:$,actions:O,setPlot(e){s=e,Je()},destroy(){Qe.disconnect(),V?.destroy()}}}
|
|
1
|
+
import{escHtml as I,maxOf as fe,minOf as Oe}from"../../core/utils.js";import{fiveNumberSummary as We}from"../../stats/math.js";import{fmt as R}from"../../renderer/fmt.js";import{fitTicks as we}from"../../renderer/axisTicks.js";import{plotFootnote as Fe,plotTestNumber as ze,plotTitle as nt}from"../../stats/plotData.js";import{SPACE as te,RADIUS as ot,fontPx as me,FONT as Le,CLR as xe,markNoPrint as Re}from"../toolbar.js";import{cardShell as it,observeResize as lt,makeTooltip as st,attachChartTip as at,chartFillHeight as rt,applyCanvasFlow as ke,prepareCanvas as Me,positionChartTooltip as $e,resolveChartCanvasColors as ve,makeAxisFormat as ct,horizontalTickSpacing as ft,VERTICAL_TICK_SPACING_PX as mt,makeSeriesLegendItem as ht,renderEmptyState as qe,limitLines as ut,limitExtent as dt,stackLabelRows as He,placeClearOf as Xe,strokeLimitLine as _e,drawOffAxisLimits as gt,limitLabelSide as pt,shouldIncludeLimitsByDefault as yt}from"./chartShell.js";import{categorical as bt}from"./palette.js";import{resolveValueColorFn as Pe}from"../../renderer/colorSchemes.js";import{wirePointInteractions as xt}from"./pointInteractions.js";const M=64,je=16,k=12,he=52,kt=16,Ce=5e3;function ne(b,P,$={}){const q=P.scale==="log";let w=b.length?Oe(b):0,F=b.length?fe(b):1;q&&(w=Math.log10(Math.max(w,Number.MIN_VALUE)),F=Math.log10(Math.max(F,Number.MIN_VALUE)));const oe=(F-w)*.05||(q?.5:1);w=$.floorAtZero&&!q&&w>=0?0:w-oe,F+=oe;const a=x=>x===void 0||!Number.isFinite(x)?void 0:q?x>0?Math.log10(x):void 0:x,g=a(P.min),H=a(P.max);g!==void 0&&(w=g),H!==void 0&&(F=H),F>w||(F=w+1);const A=F-w,Z=!!P.reverse,K=x=>{const G=((q?Math.log10(Math.max(x,Number.MIN_VALUE)):x)-w)/A;return Z?1-G:G};return{lo:q?10**w:w,hi:q?10**F:F,log:q,reverse:Z,frac:K}}function Ue(b,P,$,q){if(P/b<10)return we(b,P,$,q);const w=Math.floor(Math.log10(b)),F=Math.ceil(Math.log10(P)),oe=g=>{const H=[];for(let A=w;A<=F;A++)for(const Z of g){const K=Z*10**A;K>=b&&K<=P&&H.push(K)}return H},L=oe([1]);return{ticks:L.length>=4?L:oe([1,2,5]),step:0}}export function renderPlotChart(b){const P=b.ownerDocument??document,{card:$,heading:q,body:w,controlsRow:F,setPngDecor:oe}=it("Plot",b.onSaveImage,P);$.dataset.wmapPlotCard="1";const L=st($);let a,g,H,A,Z,K=[];const x=new Set,G=new Set;let ue=null,X=-1,ce=[],z,J,D,_=null,Q=[],V=-1,Se=[],de=he;const ie=e=>bt(e),ge=e=>a?.groups[e]||"";function pe(){const e=w.clientWidth,l=Math.max(220,Math.min(420,e*.62))+(de-he),c=rt($,w,g,l);return{w:e,h:c,plotW:Math.max(10,e-M-je),plotH:Math.max(10,c-k-de)}}const le=e=>ut(e?.limits,a?.spec.limits??"both").filter(l=>e?.scale!=="log"||l.value>0),ae=(e,l)=>{const c=e.filter(Number.isFinite);if(!l.length||c.length===0)return e;const{lo:r,hi:i}=dt(l);return yt(Oe(c),fe(c),r,i)?[...e,...l.map(o=>o.value)]:e};function re(e,l,c,r,i,o,t,n){if(o.length===0)return;const f=o.filter(u=>u.value>=i.lo&&u.value<=i.hi),p=o.filter(u=>!f.includes(u)).map(u=>({value:u.value,label:u.label,side:u.value<i.lo?"lo":"hi"}));e.save(),e.font=`${me(-1)}px system-ui, sans-serif`;const h=u=>`${u.label} ${R(u.value,t.unit)}`,s=me(-1)+2;if(n==="y"){const u=f.map(m=>{const y=k+(1-i.frac(m.value))*r;return{l:m,y,start:y-6-s/2,end:y-6+s/2}}),T=He(u,1),d=u.length?fe(u.map(m=>e.measureText(h(m.l)).width))+8:0;u.forEach(({l:m,y},S)=>{e.globalAlpha=.7,_e(e,m,l,M,y,M+c,y),e.globalAlpha=1,e.fillStyle=l,e.textAlign="left",e.textBaseline="alphabetic";const v=M+3+T[S]*d,U=Xe(Se,{x0:v,x1:v+e.measureText(h(m)).width,y0:y-4-s+2,y1:y-4+2},s);e.fillText(h(m),v,U.y1-2)})}else{const u=f.map(d=>{const m=M+i.frac(d.value)*c,y=e.measureText(h(d)).width,S=pt(m,y,M,M+c,d.end==="lo");return{l:d,x:m,side:S,start:S<0?m-3-y:m+3,end:S<0?m-3:m+3+y}}),T=He(u,4);u.forEach(({l:d,x:m,side:y,start:S,end:v},U)=>{e.globalAlpha=.7,_e(e,d,l,m,k,m,k+r),e.globalAlpha=1,e.fillStyle=l,e.textAlign=y<0?"right":"left",e.textBaseline="top";const C=k+2+T[U]*s,E=Xe(Se,{x0:S,x1:v,y0:C,y1:C+s},s);e.fillText(h(d),m+y*3,E.y0)})}e.restore(),gt(e,p,{left:M,right:M+c,top:k,bottom:k+r},n==="y"?"vertical":"horizontal",l,u=>R(u,t.unit))}function Ee(e,l,c,r){return ct(Math.max(Math.abs(l),Math.abs(c)),e.unit,r)}function Ae(e,l){return l?`${e.label} (${l})`:e.label}function ye(e,l,c,r,i,o,t,n,f,p){Se=[],e.font=`${me(-1)}px system-ui, sans-serif`;const h=()=>mt,s=n.log?Ue(n.lo,n.hi,o,h):we(n.lo,n.hi,o,h),u=Ee(p,n.lo,n.hi,s.step||void 0);e.strokeStyle=l.grid,e.lineWidth=.5,e.fillStyle=l.textMuted;let T="";if("labels"in t){const d=t.labels.length;t.labels.forEach((m,y)=>{const S=M+(y+.5)/d*i,v=m.length>22?`${m.slice(0,21)}\u2026`:m;t.rotate?(e.save(),e.translate(S,k+o+6),e.rotate(-Math.PI/4),e.textAlign="right",e.textBaseline="middle",e.fillText(v,0,0),e.restore()):(e.textAlign="center",e.textBaseline="top",e.fillText(v,S,k+o+4))})}else{const d=ft(e,Math.max(Math.abs(t.lo),Math.abs(t.hi)),f.unit),m=t.log?Ue(t.lo,t.hi,i,d):we(t.lo,t.hi,i,d),y=Ee(f,t.lo,t.hi,m.step||void 0);T=y.unitLabel;for(const S of m.ticks){const v=M+t.frac(S)*i;e.beginPath(),e.moveTo(v,k),e.lineTo(v,k+o),e.stroke(),e.textAlign="center",e.textBaseline="top",e.fillText(y.tick(S),v,k+o+4)}}for(const d of s.ticks){const m=k+(1-n.frac(d))*o;e.beginPath(),e.moveTo(M,m),e.lineTo(M+i,m),e.stroke(),e.textAlign="right",e.textBaseline="middle",e.fillText(u.tick(d),M-4,m)}e.font=`${me(0)}px system-ui, sans-serif`,e.fillStyle=l.text,e.textAlign="center",e.textBaseline="bottom",e.fillText(Ae(f,T),M+i/2,r-6),e.save(),e.translate(14,k+o/2),e.rotate(-Math.PI/2),e.textBaseline="top",e.fillText(Ae(p,u.unitLabel),0,0),e.restore(),e.strokeStyle=l.border,e.lineWidth=1,e.beginPath(),e.moveTo(M,k),e.lineTo(M,k+o),e.moveTo(M,k+o),e.lineTo(M+i,k+o),e.stroke()}function Ye(){if(!a||!g||a.marks?.type!=="scatter"||!a.x||!a.y)return;ke(g,A??0);const e=ve($),{w:l,h:c,plotW:r,plotH:i}=pe(),o=Me(g,$,l,c);if(!o)return;const{ctx:t}=o,n=a.marks.points,f=x.size===0?n:n.filter(E=>x.has(E.group)),p=a.colorScale,h=Pe(),s=le(a.x),u=le(a.y),T=ne(ae(n.map(E=>E.x),s),a.x),d=ne(ae(n.map(E=>E.y),u),a.y);z={x:T,y:d,plotW:r,plotH:i},ye(t,e,l,c,r,i,T,d,a.x,a.y),re(t,e.limitLine,r,i,T,s,a.x,"x"),re(t,e.limitLine,r,i,d,u,a.y,"y");const m=f.length>Ce?Math.ceil(f.length/Ce):1;t.globalAlpha=Math.max(.15,Math.min(.7,200/(f.length/m))),ce=[];const y=M,S=M+r,v=k,U=k+i;for(let E=0;E<f.length;E+=m){const N=f[E],se=M+T.frac(N.x)*r,Y=k+(1-d.frac(N.y))*i;se<y||se>S||Y<v||Y>U||(ce.push({p:N,cx:se,cy:Y}),t.beginPath(),t.arc(se,Y,2.5,0,Math.PI*2),t.fillStyle=p&&N.value!==void 0?h((N.value-p.lo)/(p.hi-p.lo||1)):ie(N.group),t.fill())}t.globalAlpha=1;const C=ue?ce.find(E=>E.p===ue):void 0;if(C&&(t.beginPath(),t.arc(C.cx,C.cy,5,0,Math.PI*2),t.lineWidth=2,t.strokeStyle=e.text,t.stroke()),G.size>0){t.lineWidth=1.5,t.strokeStyle=e.text;let E=0;for(const N of G)if(!(x.size>0&&!x.has(N.group))){if(++E>Ce)break;t.beginPath(),t.arc(M+T.frac(N.x)*r,k+(1-d.frac(N.y))*i,4,0,Math.PI*2),t.stroke()}}}function Ge(){if(J=void 0,!a||a.marks?.type!=="histogram"||!a.x)return;const e=a.marks.values,l=e.flat();if(l.length===0)return;const c=ne(ae(l,le(a.x)),a.x),r=Math.max(1,a.spec.bins??kt),i=c.log?Math.log10(c.lo):c.lo,o=c.log?Math.log10(c.hi):c.hi,t=Array.from({length:r+1},(f,p)=>{const h=i+(o-i)*p/r;return c.log?10**h:h}),n=e.map(()=>new Array(r).fill(0));e.forEach((f,p)=>{for(const h of f){const s=c.log?h>0?Math.log10(h):NaN:h;if(!Number.isFinite(s)||s<i||s>o)continue;const u=Math.min(r-1,Math.floor((s-i)/(o-i)*r));n[p][u]++}}),J={edges:t,counts:n,maxCount:Math.max(1,...n.map(f=>fe(f)))}}function De(){if(!a||!g||!J||!a.x||!a.y)return;ke(g,A??0);const e=ve($),{w:l,h:c,plotW:r,plotH:i}=pe(),o=Me(g,$,l,c);if(!o)return;const{ctx:t}=o,{edges:n,counts:f,maxCount:p}=J,h=ne([n[0],n[n.length-1]],{...a.x,min:n[0],max:n[n.length-1]}),s=ne([0,p],{label:a.y.label,scale:"linear",min:0,max:p*1.05});z={x:h,y:s,plotW:r,plotH:i},ye(t,e,l,c,r,i,h,s,a.x,a.y),re(t,e.limitLine,r,i,h,le(a.x),a.x,"x");const u=f.map((d,m)=>m).filter(d=>x.size===0||x.has(d)),T=u.length>1;for(const d of u)t.globalAlpha=T?.55:.85,t.fillStyle=ie(d),f[d].forEach((m,y)=>{if(m===0)return;const S=M+Math.min(h.frac(n[y]),h.frac(n[y+1]))*r,v=M+Math.max(h.frac(n[y]),h.frac(n[y+1]))*r,U=k+(1-s.frac(m))*i;t.fillRect(S,U,Math.max(1,v-S-1),k+i-U)});if(t.globalAlpha=1,X>=0){const d=M+Math.min(h.frac(n[X]),h.frac(n[X+1]))*r,m=M+Math.max(h.frac(n[X]),h.frac(n[X+1]))*r;t.lineWidth=1.5,t.strokeStyle=e.text,t.strokeRect(d,k,Math.max(1,m-d),i)}}function Ve(){const e=a?.marks;if(!a||!g||!a.x||!a.y||!e||e.type!=="box"&&e.type!=="bar")return;ke(g,A??0);const l=ve($),c=g.getContext("2d");let r=0;c&&(c.font=`${me(-1)}px system-ui, sans-serif`,r=fe(e.categories.map(C=>c.measureText(C.length>22?`${C.slice(0,21)}\u2026`:C).width)));const i=Math.max(10,w.clientWidth-M-je)/Math.max(1,e.categories.length),o=r+8>i;de=o?he+Math.min(110,r*.72):he;const{w:t,h:n,plotW:f,plotH:p}=pe(),h=Me(g,$,t,n);if(!h)return;const{ctx:s}=h,u=C=>C.filter(Number.isFinite),T=le(a.y),d=ne(ae(e.type==="bar"?[...u(e.values.flat()),0]:u(e.cells.flat(2)),T),a.y,{floorAtZero:e.type==="bar"});z={x:d,y:d,plotW:f,plotH:p},ye(s,l,t,n,f,p,{labels:e.categories,rotate:o},d,a.x,a.y),re(s,l.limitLine,f,p,d,T,a.y,"y");const m=e.categories.length,y=a.groups.length,S=f/m,v=S*.8/y;D={slotW:S,gw:v,n:m,groups:y,plotW:f};const U=d.log?k+p:k+(1-d.frac(0))*p;for(let C=0;C<y;C++){if(x.size>0&&!x.has(C))continue;const E=ie(C);for(let N=0;N<m;N++){const se=M+N*S+S*.1+C*v;if(e.type==="bar"){const Y=e.values[C][N];if(!Number.isFinite(Y))continue;const j=k+(1-d.frac(Y))*p;s.fillStyle=E,s.globalAlpha=.9,s.fillRect(se+1,Math.min(j,U),Math.max(1,v-2),Math.max(1,Math.abs(U-j))),s.globalAlpha=1}else{const Y=e.cells[C][N];if(Y.length===0)continue;const j=se+v/2,ee=Math.max(3,Math.min(v*.7,46)),O=We(Float64Array.from(Y)),W=be=>k+(1-d.frac(be))*p;if(s.strokeStyle=E,s.fillStyle=E,s.lineWidth=1.5,Y.length===1){s.beginPath(),s.arc(j,W(O.median),3,0,Math.PI*2),s.fill();continue}s.beginPath(),s.moveTo(j,W(O.min)),s.lineTo(j,W(O.max)),s.stroke();for(const be of[O.min,O.max])s.beginPath(),s.moveTo(j-ee/4,W(be)),s.lineTo(j+ee/4,W(be)),s.stroke();s.globalAlpha=.35,s.fillRect(j-ee/2,Math.min(W(O.q1),W(O.q3)),ee,Math.max(1,Math.abs(W(O.q1)-W(O.q3)))),s.globalAlpha=1,s.strokeRect(j-ee/2,Math.min(W(O.q1),W(O.q3)),ee,Math.max(1,Math.abs(W(O.q1)-W(O.q3)))),s.lineWidth=2.5,s.beginPath(),s.moveTo(j-ee/2,W(O.median)),s.lineTo(j+ee/2,W(O.median)),s.stroke()}}}if(_){const C=M+_.c*S+S*.1+_.g*v;s.lineWidth=1.5,s.strokeStyle=l.text,s.strokeRect(C,k,v,p)}}function Ie(e){if(!D||!g)return null;const l=g.getBoundingClientRect(),c=e.clientX-l.left-M;if(c<0||c>D.plotW)return null;const r=Math.min(D.n-1,Math.floor(c/D.slotW)),i=Math.floor((c-r*D.slotW-D.slotW*.1)/D.gw);return i<0||i>=D.groups?null:{g:i,c:r}}function Ze(e){const l=a,c=l.marks,r=l.level==="die"?"dies":"wafers",i=c.cells[e.g][e.c],o=`<strong>${I(c.categories[e.c])}${l.groups.length>1?` \xB7 ${I(ge(e.g))}`:""}</strong><br>`,t=l.y?.unit;if(i.length===0)return`${o}no ${r}`;const n=`${i.length.toLocaleString("en-GB")} ${r}`,f=c.categoryItems&&b.onOpenWafer?`<br><em>click to ${I(b.openActionLabel??"open this wafer")}</em>`:"";if(c.type==="bar"){const h=c.values[e.g][e.c];return`${o}${I(`${l.y.label}: ${R(h,t)}`)}<br>${I(n)}${f}`}const p=We(Float64Array.from(i));return`${o}${["max","q3","median","q1","min"].map(h=>I(`${{max:"max",q3:"upper quartile",median:"median",q1:"lower quartile",min:"min"}[h]}: ${R(p[h],t)}`)).join("<br>")}<br>${I(n)}${f}`}function Ke(){const e=a?.marks;if(!a||!g||!a.x||!a.y||!e||e.type!=="line")return;ke(g,A??0);const l=ve($),{w:c,h:r,plotW:i,plotH:o}=pe(),t=Me(g,$,c,r);if(!t)return;const{ctx:n}=t,f=le(a.x),p=le(a.y),h=ne(ae(e.xs,f),a.x),s=ne(ae(e.values.flat().filter(Number.isFinite),p),a.y);z={x:h,y:s,plotW:i,plotH:o},ye(n,l,c,r,i,o,h,s,a.x,a.y),re(n,l.limitLine,i,o,h,f,a.x,"x"),re(n,l.limitLine,i,o,s,p,a.y,"y"),Q=e.xs.map(u=>M+h.frac(u)*i),e.values.forEach((u,T)=>{if(x.size>0&&!x.has(T))return;n.strokeStyle=ie(T),n.fillStyle=ie(T),n.lineWidth=2;let d=!1;n.beginPath(),u.forEach((m,y)=>{if(!Number.isFinite(m)){d=!1;return}const S=Q[y],v=k+(1-s.frac(m))*o;d?n.lineTo(S,v):n.moveTo(S,v),d=!0}),n.stroke(),u.forEach((m,y)=>{Number.isFinite(m)&&(n.beginPath(),n.arc(Q[y],k+(1-s.frac(m))*o,V===y?4.5:3,0,Math.PI*2),n.fill())})}),V>=0&&(n.lineWidth=1,n.strokeStyle=l.textMuted,n.beginPath(),n.moveTo(Q[V],k),n.lineTo(Q[V],k+o),n.stroke())}function Ne(e){const l=a?.marks;if(!l||l.type!=="line"||!g||!a?.x||Q.length===0)return null;const c=e.clientX-g.getBoundingClientRect().left;let r=-1,i=24;if(Q.forEach((n,f)=>{const p=Math.abs(n-c);p<i&&(i=p,r=f)}),V=r,r<0)return null;const o=a.level==="die"?"dies":"wafers",t=l.values.map((n,f)=>({g:f,v:n[r],n:l.counts[f][r]})).filter(n=>Number.isFinite(n.v)&&(x.size===0||x.has(n.g)));return`<strong>${I(`${a.x.label}: ${R(l.xs[r],a.x.unit)}`)}</strong><br>`+t.map(n=>I(`${a.groups.length>1?`${ge(n.g)}: `:""}${R(n.v,a.y.unit)} (${n.n.toLocaleString("en-GB")} ${o})`)).join("<br>")}function B(){const e=a?.marks?.type;e==="scatter"?Ye():e==="histogram"?De():e==="box"||e==="bar"?Ve():e==="line"&&Ke()}function Je(e){const l=a,c=b.waferLabel(e.item),r=e.die&&e.die.x!==void 0?`die (${e.die.x}, ${e.die.y})`:"",i=[c,r].filter(Boolean).join(" \xB7 "),o=(t,n)=>`${t.label}: ${R(n,t.unit)}`;return(i?`<strong>${I(i)}</strong><br>`:"")+I(o(l.x,e.x))+"<br>"+I(o(l.y,e.y))+(l.colorScale&&e.value!==void 0?`<br>${I(`${l.colorScale.label}: ${R(e.value,l.colorScale.unit)}`)}`:"")+(l.groups.length>1?`<br>${I(ge(e.group))}`:"")+(b.onOpenWafer?`<br><em>click to ${I(b.openActionLabel??"open this wafer")}</em>`:"")}function Be(e){if(!J||!z||!a?.x)return null;const l=g.getBoundingClientRect(),r=(e.clientX-l.left-M)/z.plotW;if(r<0||r>1)return null;const i=z.x.reverse?1-r:r,{edges:o,counts:t}=J,n=o.length-1,f=Math.min(n-1,Math.max(0,Math.floor(i*n)));X=f;const p=a.x,h=t.map((s,u)=>({g:u,n:s[f]})).filter(s=>s.n>0&&(x.size===0||x.has(s.g)));return`<strong>${I(`${R(o[f],p.unit)} to ${R(o[f+1],p.unit)}`)}</strong><br>`+(h.length?h.map(s=>I(`${a.groups.length>1?`${ge(s.g)}: `:""}${s.n.toLocaleString("en-GB")} ${a.level==="die"?"dies":"wafers"}`)).join("<br>"):"none")}function Qe(e){const l=P.createElement("div");l.dataset.wmapPlotColorbar="1",Object.assign(l.style,{display:"flex",alignItems:"center",gap:te.md,marginTop:te.md,marginBottom:te.xl,fontSize:Le.body,color:xe.label});const c=P.createElement("canvas");c.width=200,c.height=10,Object.assign(c.style,{width:"200px",height:"10px",borderRadius:ot.control,flex:"0 0 auto"});const r=c.getContext("2d"),i=Pe();if(r)for(let f=0;f<200;f++)r.fillStyle=i(f/199),r.fillRect(f,0,1,10);const o=P.createElement("span");o.textContent=R(e.lo,e.unit);const t=P.createElement("span");t.textContent=R(e.hi,e.unit);const n=P.createElement("span");return n.textContent=e.label,n.style.color=xe.text,l.append(n,o,c,t),l}const Te=(e,l,c)=>l.map(r=>{const{item:i,die:o}=e(r);return{x:0,y:0,group:c,item:i,die:o}});function et(){Z?.destroy(),Z=void 0,w.innerHTML="",g=void 0,H=void 0,A=void 0,K=[],ue=null,X=-1,ce=[],z=void 0,D=void 0,_=null,Q=[],V=-1,de=he,x.clear(),G.clear();const e=a;if(!e)return;if(q.textContent=nt(e),$.dataset.wmapChartTitle=q.textContent,e.issues.length||!e.marks){for(const i of e.issues)qe(w,i);return}const l=P.createElement("div");Object.assign(l.style,{color:xe.label,fontSize:Le.body,marginBottom:te.xs});const c=b.openActionLabel??"open this wafer",r=e.marks.type==="scatter"?(b.onOpenWafer?` \xB7 click a point to ${c}`:"")+(b.onSelectPoints?` \xB7 drag to select ${e.level==="die"?"dies":"wafers"}`:""):e.marks.type==="box"||e.marks.type==="bar"?(b.onOpenWafer&&e.marks.categoryItems?` \xB7 click to ${c}`:b.onSelectPoints?" \xB7 click to chart or tabulate what it counts":"")+(e.marks.type==="box"?" \xB7 box: quartiles; whiskers: minimum and maximum":""):e.marks.type==="histogram"&&b.onSelectPoints?" \xB7 click a bar to chart or tabulate its dies":e.marks.type==="line"&&b.onSelectPoints?" \xB7 click a point to chart or tabulate what it averages":"";l.textContent=Fe(e)+r,Re(l),A=P.createElement("div"),A.style.display="flow-root",w.appendChild(A),A.appendChild(l);for(const i of e.notes){const o=P.createElement("div");Re(o),o.textContent=i,Object.assign(o.style,{color:xe.warnText,fontSize:Le.body,marginBottom:te.xs}),A.appendChild(o)}if(e.plotted===0){qe(w,"Nothing to plot: no mark has every value this plot needs.");return}if(e.groups.length>1&&(H=P.createElement("div"),Object.assign(H.style,{display:"flex",flexWrap:"wrap",gap:te.sm,marginTop:te.md,marginBottom:te.xl}),e.groups.forEach((i,o)=>{const t=ht(i||"(none)",ie(o),P);at(t.el,$,L,`${i||"(none)"} \u2014 click to filter`),t.el.addEventListener("click",()=>{x.has(o)?x.delete(o):x.add(o),K.forEach((n,f)=>n.setState({selected:x.has(f),dimmed:x.size>0&&!x.has(f)})),B()}),K.push(t),H.appendChild(t.el)}),A.appendChild(H)),e.colorScale&&(H=Qe(e.colorScale),A.appendChild(H)),g=P.createElement("canvas"),g.style.display="block",g.style.cursor=e.marks.type==="scatter"?"crosshair":"default",w.appendChild(g),e.marks.type==="scatter"){const i=e.marks,o=!!b.onSelectPoints;Z=xt({card:$,canvas:g,tooltip:L,drawn:()=>ce,describe:Je,clickable:()=>!!b.onOpenWafer,onOpen:t=>b.onOpenWafer?.(t.item,ze(e.spec)),onHover:t=>{ue=t,B()},select:o?{pick:({x0:t,y0:n,x1:f,y1:p})=>z?(x.size===0?i.points:i.points.filter(s=>x.has(s.group))).filter(s=>{const u=M+z.x.frac(s.x)*z.plotW,T=k+(1-z.y.frac(s.y))*z.plotH;return u>=t&&u<=f&&T>=n&&T<=p}):[],onPicked:(t,n)=>{G.clear();for(const f of t)G.add(f);B(),t.length>0&&b.onSelectPoints(t,n,g)},onClear:()=>{G.clear(),B()},hasSelection:()=>G.size>0}:void 0})}else if(e.marks.type==="histogram"){Ge(),g.addEventListener("mousemove",o=>{const t=Be(o);if(!t){L.style.display="none",X>=0&&(X=-1,B());return}L.innerHTML=t,L.style.display="block",$e(L,$,o.clientX,o.clientY),B()}),g.addEventListener("mouseleave",()=>{L.style.display="none",X>=0&&(X=-1,B())});const i=e.marks;b.onSelectPoints&&(g.style.cursor="pointer",g.addEventListener("click",o=>{if(!J||Be(o)===null)return;const t=X,{edges:n}=J,f=z?.x.log,p=f?Math.log10(n[0]):n[0],h=f?Math.log10(n[n.length-1]):n[n.length-1],s=n.length-1,u=[];i.values.forEach((T,d)=>{if(x.size>0&&!x.has(d))return;const m=[];T.forEach((y,S)=>{const v=f?y>0?Math.log10(y):NaN:y;!Number.isFinite(v)||v<p||v>h||Math.min(s-1,Math.floor((v-p)/(h-p)*s))===t&&m.push(i.units[d][S])}),u.push(...Te(i.unit,m,d))}),u.length>0&&(L.style.display="none",b.onSelectPoints(u,{x:o.clientX,y:o.clientY},g))}))}else if(e.marks.type==="box"||e.marks.type==="bar"){const i=e.marks;g.addEventListener("mousemove",o=>{const t=Ie(o);if(g.style.cursor=t&&(i.categoryItems&&b.onOpenWafer||b.onSelectPoints&&i.cellUnits[t.g][t.c].length>0)?"pointer":"default",!t){L.style.display="none",_&&(_=null,B());return}L.innerHTML=Ze(t),L.style.display="block",$e(L,$,o.clientX,o.clientY),(!_||_.g!==t.g||_.c!==t.c)&&(_=t,B())}),g.addEventListener("mouseleave",()=>{L.style.display="none",_&&(_=null,B())}),g.addEventListener("click",o=>{const t=Ie(o);if(!t)return;const n=i.categoryItems?.[t.c];if(n!==void 0&&n>=0&&b.onOpenWafer){b.onOpenWafer(n,ze(e.spec));return}const f=i.cellUnits[t.g][t.c];f.length>0&&b.onSelectPoints&&(L.style.display="none",b.onSelectPoints(Te(i.unit,f,t.g),{x:o.clientX,y:o.clientY},g))})}else if(e.marks.type==="line"){g.addEventListener("mousemove",o=>{const t=Ne(o);if(!t){L.style.display="none",B();return}L.innerHTML=t,L.style.display="block",$e(L,$,o.clientX,o.clientY),B()}),g.addEventListener("mouseleave",()=>{L.style.display="none",V>=0&&(V=-1,B())});const i=e.marks;b.onSelectPoints&&(g.style.cursor="pointer",g.addEventListener("click",o=>{if(Ne(o)===null||V<0)return;const t=i.cellUnits.flatMap((n,f)=>x.size>0&&!x.has(f)?[]:Te(i.unit,n[V]??[],f));t.length>0&&(L.style.display="none",b.onSelectPoints(t,{x:o.clientX,y:o.clientY},g))}))}B()}oe(()=>{const e=a;if(!e||!e.marks)return;const l=Pe();return{caption:[Fe(e),...e.notes],legend:e.groups.length>1?e.groups.map((c,r)=>({label:c||"(none)",color:ie(r)})):void 0,colorbar:e.colorScale?{label:e.colorScale.label,lo:R(e.colorScale.lo,e.colorScale.unit),hi:R(e.colorScale.hi,e.colorScale.unit),color:l}:void 0}});const tt=lt($,()=>B());return{card:$,actions:F,setPlot(e){a=e,et()},destroy(){tt.disconnect(),Z?.destroy()}}}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { RegionYieldDatum } from '../../stats/regions.js';
|
|
2
2
|
import { type SaveImageHandler } from './chartShell.js';
|
|
3
|
-
export type RegionYieldMode = 'ring' | 'quadrant';
|
|
3
|
+
export type RegionYieldMode = 'ring' | 'quadrant' | 'reticleCell';
|
|
4
4
|
export interface RegionYieldDiagramOptions {
|
|
5
5
|
title?: string;
|
|
6
6
|
mode: RegionYieldMode;
|
|
7
7
|
/** Ring mode: ordered ring 1 (core) → ring N (edge), matching `buildRegionYieldData`'s output for `buildRingRegions`. Quadrant mode: any order — each row's quadrant is read from its `key` (`quadrant:NE` etc.), not position. */
|
|
8
8
|
rows: RegionYieldDatum[];
|
|
9
|
+
/** Reticle-cell mode: the field's size in dies, so cells with no data still take their place. Without it the grid is as large as the cells given. */
|
|
10
|
+
grid?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
9
14
|
/** Click a region: called with it and the click, so the host can pick out the dies it counts and open a menu there. */
|
|
10
15
|
onSelectRegion?: (row: RegionYieldDatum, e: MouseEvent) => void;
|
|
11
16
|
onSaveImage?: SaveImageHandler;
|