@wafertools/wafermap 0.35.0 → 0.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +7 -1
- package/CHANGELOG.md +129 -0
- package/README.md +6 -3
- package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +14 -1
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +31 -8
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
- package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
- package/dist/packages/canvas-adapter/toolbar.d.ts +8 -0
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +37 -21
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/classify.d.ts +5 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +26 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/passBins.d.ts +6 -0
- package/dist/packages/core/passBins.js +1 -1
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +32 -1
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/spec.d.ts +4 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +55 -0
- package/dist/packages/renderer/valueFilter.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +44 -3
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/capability.d.ts +5 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/connectedComponents.d.ts +19 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/lotPattern.js +1 -1
- package/dist/packages/stats/math.d.ts +25 -3
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +44 -18
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +11 -0
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/regions.d.ts +6 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +7 -6
- package/dist/packages/stats/reportHtml.js +39 -37
- package/dist/packages/stats/synthesis.d.ts +44 -17
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/types.d.ts +12 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
- package/dist/packages/canvas-adapter/summaryRail.js +0 -1
package/AGENTS.md
CHANGED
|
@@ -117,6 +117,12 @@ worth reporting, not a pattern to build on.
|
|
|
117
117
|
lot. Supply or replace the analysis later with `setStatsSummary()`. There is no
|
|
118
118
|
chart-data API to hand-build them from. Charting a selection or one wafer (right-click → histogram, capability,
|
|
119
119
|
saved plots and sweeps) is built in too, with no wiring.
|
|
120
|
+
- **Keep the reader's plots in the host, hand them back in.** The library stores nothing: supply `insights.plots` and keep
|
|
121
|
+
it current from `insights.onPlotsChange` (the whole list, after every change). Wafer attribute names (`attributes`) and the
|
|
122
|
+
Data tab need no wiring beyond that.
|
|
123
|
+
- **A value that is not a measurement is excluded by limits, not by editing the data.** A tester clamp or open-circuit reading is
|
|
124
|
+
handled by `TestDef.validLow`/`validHigh` and `valueFilter` (default `'validity'`). Removing or zeroing such values in the host hides
|
|
125
|
+
them from the count the library would have shown; deleting the dies changes the yield.
|
|
120
126
|
- **A value computed from other tests is a derived test, not a host-side column.** Pass
|
|
121
127
|
`derivedTests` (a `TestDef` plus an `expression`, e.g. `'abs(t[1020] - t[1010])'`) to
|
|
122
128
|
`buildWaferMap`; it then behaves as a measured test everywhere, marked `†` as not
|
|
@@ -241,7 +247,7 @@ compatibility shims for them.
|
|
|
241
247
|
- [API reference](https://wafertools.github.io/wafermap/api/) — every type, option and return value
|
|
242
248
|
- [Developer guide](https://wafertools.github.io/wafermap/guide/) — worked walkthroughs
|
|
243
249
|
- [Troubleshooting](https://wafertools.github.io/wafermap/troubleshooting/)
|
|
244
|
-
- [Examples](https://wafertools.github.io/wafermap/examples/) —
|
|
250
|
+
- [Examples](https://wafertools.github.io/wafermap/examples/) — 25 runnable pages, also
|
|
245
251
|
[downloadable](https://wafertools.github.io/wafermap/wafermap-examples.zip) to run offline
|
|
246
252
|
|
|
247
253
|
When a rule here and the API reference disagree, the API reference wins — tell the
|
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,135 @@ under `### Breaking`.
|
|
|
24
24
|
|
|
25
25
|
## [Unreleased]
|
|
26
26
|
|
|
27
|
+
## [0.35.1] — 2026-10-09
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Validity limits, and a value filter that excludes values outside a limit set.** A test can carry `validLow`/`validHigh`: the
|
|
32
|
+
range a real measurement lies in. A value outside it is a tester clamp (a range overflow, an open-circuit rail), not a reading.
|
|
33
|
+
`buildWaferMap`'s `valueFilter` option chooses which limit set a value must lie inside: `'validity'` (the default, which only
|
|
34
|
+
affects tests that have validity limits), `'spec'` or `'test'` to keep only values inside the specification or test limits, or
|
|
35
|
+
`'none'`. An excluded value is no value for that test on that die, in the map, the statistics and every chart, and a derived test
|
|
36
|
+
is computed from the filtered values. Bins and each die's recorded verdict are the tester's own and are unchanged.
|
|
37
|
+
- **Excluded values are counted and shown.** `WaferMapResult.valueFilter` gives the limit set and, per test, how many values were
|
|
38
|
+
excluded, and the result's warnings carry a `values-excluded` line. The tooltip on a grey die names the excluded value and the
|
|
39
|
+
limit set. The Summary panel (a total beside N and an Excl. column), its CSV export, the summary report, the Plot footnote, the
|
|
40
|
+
histogram and boxplot captions and the capability tooltip and caption state the count. `CapabilityDatum.excluded` carries it;
|
|
41
|
+
`n` does not include excluded values.
|
|
42
|
+
|
|
43
|
+
- **`StatsSummary.stats.testFailures`: the dies each test fails.** Per test number, the failing dies' keys (outside its limits for a
|
|
44
|
+
parametric test, failing for a functional one) and `lostDies`, how many of them also fail the wafer's yield. Absent when no test fails
|
|
45
|
+
a die.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- **"What stands out" items are rows that act, every one the same way.** Each item, the further items below it and each Watch line is a
|
|
50
|
+
row that shows its dies on the map when clicked, marked by a wafer icon at its end: a region or wafer its finding, a test the test's
|
|
51
|
+
values with the dies it fails selected. The sentences themselves no longer contain links. The leading item's parts (its fail bins,
|
|
52
|
+
with their legend colours, the spatial pattern, and tests failing on the same dies) are chips under its sentence, each showing that
|
|
53
|
+
part alone.
|
|
54
|
+
- **A test is costed by the dies it fails that also fail yield.** Dies outside a test's limits but binned as passing cost no yield, so
|
|
55
|
+
they no longer rank the test; the item says how many there are, and past one yield point they are a Watch line ("Voltage is outside
|
|
56
|
+
its limits on 432 dies binned as passing"). A test whose failing dies lie mostly on a region item's dies (at least half of them, and
|
|
57
|
+
at least twice the region's share of the dies) is said in that region's item and shown as one of its chips, rather than ranked
|
|
58
|
+
against it as a second item over the same dies.
|
|
59
|
+
- **A lot of one wafer is described from that wafer.** Its "What stands out" is the wafer's own.
|
|
60
|
+
- **With a single pass bin, a fall in that bin is a region's pass rate.** Data with soft bins only has no separate yield
|
|
61
|
+
finding, and its region items are now costed by the pass bin's fall (the whole shortfall), with the fail bins as its parts.
|
|
62
|
+
- **When nothing costs a yield point but a finding below is marked Unusual**, "What stands out" says so instead of "Nothing stands
|
|
63
|
+
out".
|
|
64
|
+
- **A map of soft-bin-only data opens in soft-bin mode.** Without a `plotMode` from the host, `renderWaferMap` and
|
|
65
|
+
`renderWaferGallery` open on hard bins when the dies carry any, otherwise soft bins. `WaferMapResult.plotMode` is `'softBin'`
|
|
66
|
+
for such data.
|
|
67
|
+
- **An outlier wafer is named by its ID** in its finding, "What stands out" and the report's per-wafer findings ("W05 yield is 16.1
|
|
68
|
+
points below the lot median"), or as "Wafer 5 (no ID)" when it has none, as every other surface names it.
|
|
69
|
+
- **The single map's auto-mounted Summary panel shows a clicked finding or row as selected**, and its findings filters apply, as the
|
|
70
|
+
placed panel's do.
|
|
71
|
+
- **Bins are said to "account for" a region's shortfall only when together they fit within it.** When other fail bins fell in the
|
|
72
|
+
region, the named bins are given as points higher instead. A test is said as part of a region's item only when it fails on at
|
|
73
|
+
least 1% of the dies, the floor for listing it on its own; the dies counted "in" the region are the named region's own.
|
|
74
|
+
- **The spatial pattern classifier finds scratches at any angle and donuts by their radial profile.** A scratch is a thin line
|
|
75
|
+
of failing dies along its own principal axis, whatever its angle: at most 0.8 die pitches across, at least 8 pitches and 0.3 of
|
|
76
|
+
the radius long, reaching in from the rim, with the fragments that continue it along the same line counted as one line. A donut
|
|
77
|
+
is a band of failures at mid-radius, at least 15 points above both the centre and the rim, read from the fail rate in five rings
|
|
78
|
+
of equal width. A symmetric pattern on the centre that is not a donut is a centre cluster. On WM-811K, recall and precision are
|
|
79
|
+
now: scratch 40.7% / 87.4%, donut 77.5% / 68.6%, centre 84.5% / 88.1%, edge-local 68.2% / 52.2%, random 60.4% / 51.6%; edge-ring
|
|
80
|
+
and near-full are unchanged; exact match 71.1%. `PatternFeatures` gains `lineWidth`, `lineLength`, `lineSize`,
|
|
81
|
+
`lineMinDistNorm`, `lineMaxDistNorm` and `radialFailRates`. Pattern labels, the spatial-pattern finding and "What stands out"
|
|
82
|
+
change accordingly.
|
|
83
|
+
- **A region holds only against the regions that are not themselves deviant.** The significant findings for one variable and region
|
|
84
|
+
family are re-tested against each other: a loss is taken before a gain, each must hold against the rest without the regions that
|
|
85
|
+
stand, and a gain is compared only with the regions that do not lean towards a loss. A failing block of rings is reported as the
|
|
86
|
+
block ("Rings 2–3 lower pass rate"), not as the rings either side of it being better, and a failing quadrant brings no "lower"
|
|
87
|
+
finding from the sectors opposite it: on synthetic lots with a failing quadrant, no wafer or lot reports one. Findings on the
|
|
88
|
+
opposite side of a strong pattern are no longer reported, and "What stands out" and its "also seen as" lists change accordingly.
|
|
89
|
+
- **An item is costed by its largest loss.** Findings on the same dies are one item, led by the finding that loses the most dies, or
|
|
90
|
+
by its own region's pass rate when there is one. A small edge arc or cluster on an edge ring's dies is "also seen as" under the
|
|
91
|
+
ring's item, which costs the ring's loss.
|
|
92
|
+
- **One false-discovery family per analysis.** Benjamini–Hochberg now adjusts every rate comparison on a wafer together (yield,
|
|
93
|
+
hard and soft bins, functional tests and limit fail rates, in every region family) and every regional comparison of a lot
|
|
94
|
+
together. Findings that rested on weak evidence are no longer reported, and severities, `adjustedPValue`,
|
|
95
|
+
`hasNotableFindings` and "What stands out" change accordingly.
|
|
96
|
+
- **Rates with small expected counts are tested exactly.** A region's rate is compared with Fisher's exact test when any expected
|
|
97
|
+
count of its 2×2 table is under 5, and with the two-proportion z-test otherwise; `stats.method` is `'fisher-exact'` or
|
|
98
|
+
`'two-proportion-z'`.
|
|
99
|
+
- **A cluster or edge arc is tested by its size against random placement.** A group of failing dies is found because it fails,
|
|
100
|
+
so its fail rate is no evidence of a cluster. The wafer's fails are scattered at random over the same dies (up to 99 times, seeded
|
|
101
|
+
from the layout and fail count so a wafer always gets the same answer) and a group is reported when random placement rarely
|
|
102
|
+
makes one that large: `stats.method` is `'permutation'`, the smallest p-value is 0.01, and `adjustedPValue` equals `pValue`
|
|
103
|
+
(the comparison with the largest group is already family-wise). Random failures no longer read as clusters: on synthetic
|
|
104
|
+
wafers of random failures, the share reporting any regional finding is 2.7% at a 2% fail rate, 5.5% at 5%, 5.3% at 10% and 1–2%
|
|
105
|
+
from 20% up (see Detection analysis). Faint patterns that show only as a contiguous group are found less often: on WM-811K the
|
|
106
|
+
regional analysis rescues 90.3% of the patterns the classifier misses, and combined detection is 98.7%. Cluster p-values,
|
|
107
|
+
severities and the edge arcs listed under an edge ring change accordingly.
|
|
108
|
+
- **Small p-values are exact to double precision.** Every z-based p-value reads the normal tail from W. J. Cody's erfc (about
|
|
109
|
+
1e-15 relative), so a p-value below 1e-7 is a number rather than rounding noise or 0. The gates are unchanged, but where two
|
|
110
|
+
very strong findings are weighed against each other (a sector run against the quadrant over the same angle, the smaller p-value
|
|
111
|
+
kept), the stronger one is now the one kept: on the bin-rich sample a Vmin pattern reads as the NE quadrant, not Sectors E–N.
|
|
112
|
+
- **An edge arc across due east is an edge arc.** Its angular span is measured round the circle, so an arc from 355° to 5° spans
|
|
113
|
+
10°, as an arc anywhere else does.
|
|
114
|
+
- **Quadrants are quarter turns of equal share.** A die is in the quadrant whose quarter turn, counted counter-clockwise from
|
|
115
|
+
east, holds its angle: NE holds the positive x axis, NW the positive y axis, SW the negative x axis and SE the negative y axis, as
|
|
116
|
+
sectors are bucketed. On a die grid with a centre row and column each quadrant now holds the same number of dies (the centre die
|
|
117
|
+
is NE). Quadrant yields, quadrant findings and the Ring | Quadrant region tables change for such data, by up to two points on a
|
|
118
|
+
wafer of a few hundred dies.
|
|
119
|
+
- **A pass bin's finding is shown as its region.** Clicking a finding or row about a pass bin that fell in a region highlights the
|
|
120
|
+
region's dies, as a yield finding does, without picking out the passing dies.
|
|
121
|
+
- **A sector is compared with the other sectors** in "What stands out" ("below the other sectors"), as its finding is: sectors leave
|
|
122
|
+
out the dies near the centre.
|
|
123
|
+
- **Showing a finding keeps the map's bin mode.** A finding that is not about one bin (a yield region, a spatial pattern) is shown
|
|
124
|
+
in the bin mode the map is in, or from another mode in a bin type the dies carry, never one the data lacks. Clicking the same
|
|
125
|
+
finding or "What stands out" row again restores the plot mode and test in use before it was first clicked.
|
|
126
|
+
- **"Also seen as" counts a long family** ("9 edge arcs") instead of naming each, and the compact list's heading reads "Also, each
|
|
127
|
+
costing at least 1% of the dies".
|
|
128
|
+
- **Gallery cards fill the width they are given.** In auto layout, when there are more cards than columns, the columns share the whole
|
|
129
|
+
row: width too narrow for another column (the Summary panel closing, a wider window) enlarges the cards instead of leaving an empty
|
|
130
|
+
band beside them. The size cap applies while every card fits in one row, so a few wafers still do not stretch across a wide screen.
|
|
131
|
+
- **The Summary panel opens from a labelled Summary button and closes from its own header.** The button sits in the row above the map,
|
|
132
|
+
just before Map | Insights (above the panel it opens), and shows as pressed while the panel is open; its icon takes the findings colour
|
|
133
|
+
while the panel is closed and a finding is notable. It replaces the toolbar's Summary icon and the "◂ Summary" tab on the edge of the
|
|
134
|
+
map area, so a closed panel leaves no column behind. The panel's title ends with a close button pointing to the edge it folds into (▸
|
|
135
|
+
for a panel on the right), and the title stays at the top while the panel scrolls. A map without a toolbar, which has no Summary
|
|
136
|
+
button, shows no close button. For half a second after the panel closes, a click where its close button was goes nowhere:
|
|
137
|
+
closing widens the map or the gallery, which moves an Expand button under the pointer, and a quick second click would
|
|
138
|
+
otherwise open it.
|
|
139
|
+
- **The Findings section's controls are its severity chips.** The header says how many findings are unusual or notable ("1 unusual,
|
|
140
|
+
2 notable"), also while the section is collapsed. Every finding row ends with the wafer icon of the rows that show their dies on the
|
|
141
|
+
map, and a spatial pattern has a "Show 3 supporting findings" line under it that opens the regional findings it explains (open from
|
|
142
|
+
the start when the finding on the map is one of them). The Kind and Region dropdowns and the Detail modal are gone: the list is
|
|
143
|
+
grouped by region, and the Summary report holds the findings at length.
|
|
144
|
+
- **In the reports, every item links to its evidence**: a finding to its row in the Findings table, a test to the Test Values or
|
|
145
|
+
Functional Tests section. The leading item ends with a "See" line naming its region and its parts. Links are drawn in a link colour.
|
|
146
|
+
|
|
147
|
+
### Docs
|
|
148
|
+
|
|
149
|
+
- **Validity limits and the value filter are documented** in the API reference (`TestDef.validLow`/`validHigh`, `valueFilter`, `WaferMapResult.valueFilter`, the `values-excluded` warning),
|
|
150
|
+
the developer guide, the user guide and the glossary, with a new **Validity limits** example in which tester clamps are kept out of the map and statistics and counted. The RF analog
|
|
151
|
+
sample data carries validity limits and a few clamped readings.
|
|
152
|
+
- **A Plots, tables and attributes example and guide section.** It shows `insights.plots` and `onPlotsChange` keeping the reader's plots, the Data tab, drilldown, whole-wafer picks and Select on every wafer,
|
|
153
|
+
and `attributes` naming wafer attributes. The reticle guide and example explain reticle cell and shot and the Reticle cell yield card; the derived-tests example reads a die's own fields
|
|
154
|
+
(`hbin()`); the retests example shows `supersedes`; `findingsNotice` and `setFindingsNotice` are in the API reference.
|
|
155
|
+
|
|
27
156
|
## [0.35.0] — 2026-10-06
|
|
28
157
|
|
|
29
158
|
### Added
|
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 ~70 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
|
|
|
@@ -26,7 +26,7 @@ Discussions](https://github.com/wafertools/.github/discussions).
|
|
|
26
26
|
|
|
27
27
|
## Overview
|
|
28
28
|
|
|
29
|
-
wafermap renders interactive wafer maps from semiconductor prober output. Hard bins, soft bins, test values, retest runs, edge exclusion, and spec limits are native inputs.
|
|
29
|
+
wafermap renders interactive wafer maps from semiconductor prober output. Hard bins, soft bins, test values, retest runs, edge exclusion, and spec and validity limits are native inputs.
|
|
30
30
|
|
|
31
31
|
- Geometry inference — pass full physical dimensions or raw prober step positions; die pitch, wafer diameter, and coordinate origin are resolved automatically
|
|
32
32
|
- `renderWaferMap` — interactive canvas map with toolbar, zoom/pan, tooltips, die selection, and summary panel
|
|
@@ -35,6 +35,9 @@ wafermap renders interactive wafer maps from semiconductor prober output. Hard b
|
|
|
35
35
|
- Derived tests (`derivedTests`) — tests computed per die from other tests (`abs(t[1020] - t[1010])`), which then work everywhere a measured test does, marked † as not measured
|
|
36
36
|
- Parametric sweeps (plots with `chart: 'sweep'`, edited on the Plot tab) — an ordered run of tests read as a response curve, with the crossing and widths between two curves measured; x values given directly or read from the test names, on a linear or log axis
|
|
37
37
|
- Drilldown — right-click selected dies, a wafer card or a wafer's bar to chart just that population, with the population stated on the chart
|
|
38
|
+
- Plot tab and Data tab — a chart builder (scatter, histogram, box, bar, line, sweep over any test, die field or wafer attribute) whose saved plots your app keeps with `insights.plots` and `onPlotsChange`, and the lot as sortable tables (statistics, dies, wafers) with CSV export
|
|
39
|
+
- Validity limits (`TestDef.validLow` / `validHigh`, `valueFilter`) — tester clamps and open-circuit readings are kept out of the map, statistics and charts, and counted wherever a population is shown
|
|
40
|
+
- Reticle and multi-project wafers — stepper-field overlay, reticle cell and shot as die fields to colour, split and chart by, reticle-position findings, and a compact layout for sparse multi-project reticles
|
|
38
41
|
- `analyzeWaferMap` / `analyzeWaferLot` — spatial analysis across rings, quadrants, sectors, and reticle positions; failure cluster detection; lot trend series
|
|
39
42
|
- Pure ES modules, no server, no runtime dependencies — works in React, Svelte, Vue, plain HTML, or a Web Worker
|
|
40
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildTestBoxplotData as rt}from"../../stats/boxplot.js";import{SPACE as
|
|
1
|
+
import{buildTestBoxplotData as rt}from"../../stats/boxplot.js";import{SPACE as De,fontPx as _,FONT as ct,CLR as ft}from"../toolbar.js";import{fmt as ge}from"../../renderer/fmt.js";import{fitTicks as ut}from"../../renderer/axisTicks.js";import{QUANTITY as Ee}from"./palette.js";import{cardShell as mt,observeResize as dt,makeTooltip as xt,positionChartTooltip as pt,makeBackButton as ht,makeLinkedTestSelect as gt,makeToggle as bt,makeLinkedAxisPrefs as wt,renderEmptyState as Oe,fitRowsHeight as yt,setChartGrow as Tt,resolveChartCanvasColors as vt,makeAxisFormat as We,horizontalTickSpacing as kt,resolveAxisRange as Mt,shouldIncludeLimitsByDefault as Lt,drawOffAxisLimits as Ct,limitLabelSide as At,limitLines as Pe,limitExtent as $t,hasBothLimitKinds as St,stackLabelRows as It,strokeLimitLine as Bt,PADDING as L,VALUE_WIDTH as Rt,WAFER_MENU_HINT as Ht,prepareCanvas as Dt}from"./chartShell.js";import{escHtml as C,maxOf as Et,minOf as Ot}from"../../core/utils.js";import{excludedNote as Wt}from"../../renderer/valueFilter.js";const A=24,$=5,_e=110,Pt=12,Ne=20;export function renderBoxplotPanel(u){const{title:ne="Test value distribution",items:Ge,testDefs:be,onSaveImage:Xe,groups:g,groupLabelText:oe="group",onOpen:Q}=u,qe=u.openActionLabel??"open that wafer",Ye=u.openActionLabel??"open this wafer",{card:a,heading:ze,body:x,controlsRow:U}=mt(ne,Xe,u.ownerDocument);Tt(a,"rows"),a.style.flex="0 0 auto",x.style.flex="0 0 auto",a.style.alignSelf="start";const ie=be.filter(i=>i.testNumber!==void 0);let b=u.selectedTestNumber??ie[0]?.testNumber??null,le=!1,F=0,w=null,D=null,se=null,we=null;function ye(){const i=!g||g.length===0?"":w??"\0overview";if(se&&we===i)return se;const p=!g||g.length===0?Ge:w!==null?g.find(k=>k.key===w)?.items??[]:g.map(k=>({label:k.key,dies:k.items.flatMap(T=>T.dies??[])}));return se=p,we=i,p}function Te(){w!==null&&!D?(D=ht(()=>{ve(null),u.onGroupChange?.(null)},a.ownerDocument),U.appendChild(D)):w===null&&D&&(D.remove(),D=null),ze.textContent=w!==null?`${ne} \u2014 ${oe}: ${w}`:ne}function ve(i){return w===i||i!==null&&!(g??[]).some(p=>p.key===i)?!1:(w=i,Te(),j(),S(),!0)}const ke=gt(ie,b,i=>{b=i,S(),u.onTestChange?.(i)},{maxWidth:"240px",emptyText:"No parametric tests",ownerDocument:a.ownerDocument}),Qe=ke.el;U.appendChild(Qe),U.appendChild(bt("Log scale",le,i=>{le=i,S()},a.ownerDocument,"Draw the value axis on a logarithmic scale"));const ae=a.ownerDocument.createElement("span");Object.assign(ae.style,{display:"inline-flex",gap:De.lg,alignItems:"center"}),U.appendChild(ae);const re=wt(ae,u.axisPrefs,i=>{u.onAxisPrefsChange?.(i),S()},a.ownerDocument),V=a.ownerDocument.createElement("div");V.dataset.wmapCaption="1",Object.assign(V.style,{color:ft.label,fontSize:ct.body,marginBottom:De.sm}),a.insertBefore(V,x);function j(){const i=!!g&&g.length>0&&w===null,p=[];i?p.push(`click a ${oe}'s box to see it by wafer`):Q&&p.push(`click a box to ${qe}`);const k=p.length?`${p[0][0].toUpperCase()}${p[0].slice(1)} \xB7 `:"";V.textContent=`${k}box = Q1\u2013Q3, line = median, whiskers = min/max \xB7 value shown is the median`+(F?` \xB7 axis clipped, ${F} value${F===1?"":"s"} outside`:"")+(b!==null?Wt(ye().flatMap(T=>T.dies??[]),b):"")}j(),Te();const E=xt(a);let ce=null;function S(){const{includeLimits:i,clipOutliers:p,limits:k}=re.get();if(j(),x.innerHTML="",ie.length===0||b===null){Oe(x,"No parametric test data available for box plots.");return}const T=ye(),h=rt(T,b),K=be.find(t=>t.testNumber===b),O=K?.unit,fe=Pe(K,k),{lo:Ve,hi:je}=$t(fe);if(h.every(t=>t.count===0)){Oe(x,"No parametric test data available for box plots.");return}const m=a.ownerDocument.createElement("canvas");m.style.display="block",m.style.cursor="default",x.appendChild(m);const Me=L*2+Math.min(h.length,Pt)*(A+$)+Ne;x.style.maxHeight=`${Me}px`,x.style.overflowY="auto",x.style.scrollbarGutter="stable";let N=-1;const ue=h.filter(t=>t.count>0),Le=Ot(ue.map(t=>t.min)),Ce=Et(ue.map(t=>t.max)),Ae=i??Lt(Le,Ce,Ve,je);re.sync(Ae,Pe(K).length>0,St(K));const G=Mt({dataMin:Le,dataMax:Ce,limits:fe,includeLimits:Ae,clipOutliers:p,values:ue.flatMap(t=>[t.min,t.q1,t.median,t.q3,t.max])});F=G.clippedCount,j();const W=G.lo,J=G.hi,Ke=J-W||1,Z=le&&W>0,me=Z?Math.log10(W):0,$e=(Z?Math.log10(J):0)-me||1,de=Math.max(Math.abs(W),Math.abs(J));function Je(){const t=L+_e,s=m.clientWidth-t-Rt-L;return{plotX:t,plotMaxWidth:Math.max(10,s)}}function I(t,s,n){return Z?s+(Math.log10(t)-me)/$e*n:s+(t-W)/Ke*n}function Ze(t,s){if(Z){const d=[];for(let e=0;e<=4;e++)d.push(Math.pow(10,me+$e*e/4));return{ticks:d,axis:We(de,O)}}const n=ut(W,J,s,kt(t,de,O));return{ticks:n.ticks,axis:We(de,O,n.step||void 0)}}function ee(){const t=vt(a),s=L*2+h.length*(A+$)+Ne;x.style.maxHeight=`${yt(a,x,Me,s)}px`;const n=x.clientWidth,d=Dt(m,a,n,s);if(!d)return;const{ctx:e}=d;e.font=`${_(-1)}px system-ui, sans-serif`,e.textBaseline="middle";const{plotX:l,plotMaxWidth:c}=Je();h.forEach((o,f)=>{const y=L+f*(A+$),r=y+A/2;f===N&&(e.fillStyle=t.bgHover,e.fillRect(0,y-$/2,n,A+$)),e.fillStyle=t.text,e.textAlign="right";const te=o.label.length>16?`${o.label.slice(0,15)}\u2026`:o.label;if(e.fillText(te,L+_e-8,r),o.count===0){e.fillStyle=t.textMuted,e.textAlign="left",e.fillText("no data",l,r);return}const it=l+c,q=at=>Math.min(it,Math.max(l,at)),Be=I(o.min,l,c),Re=I(o.max,l,c),B=q(Be),Y=q(I(o.q1,l,c)),He=q(I(o.median,l,c)),he=q(I(o.q3,l,c)),R=q(Re),lt=Be<B,st=Re>R,H=y+3,z=y+A-3;e.strokeStyle=t.textMuted,e.lineWidth=1,e.beginPath(),e.moveTo(B,r),e.lineTo(Y,r),e.moveTo(he,r),e.lineTo(R,r);const M=3;lt?(e.moveTo(B+M,r-M),e.lineTo(B,r),e.lineTo(B+M,r+M)):(e.moveTo(B,H),e.lineTo(B,z)),st?(e.moveTo(R-M,r-M),e.lineTo(R,r),e.lineTo(R-M,r+M)):(e.moveTo(R,H),e.lineTo(R,z)),e.stroke(),e.fillStyle=Ee,e.globalAlpha=.35,e.fillRect(Y,H,Math.max(1,he-Y),z-H),e.globalAlpha=1,e.strokeStyle=Ee,e.strokeRect(Y,H,Math.max(1,he-Y),z-H),e.strokeStyle=t.text,e.lineWidth=2,e.beginPath(),e.moveTo(He,H),e.lineTo(He,z),e.stroke(),e.lineWidth=1,e.fillStyle=t.textMuted,e.textAlign="left",e.fillText(ge(o.median,O,"engineering"),l+c+10,r)});const v=L+h.length*(A+$);e.font=`${_(-1)}px system-ui, sans-serif`,Ct(e,G.offAxis,{left:l,right:l+c,top:0,bottom:v},"horizontal",t.limitLine,o=>ge(o,O,"engineering"));const et=new Set(G.offAxis.map(o=>o.value)),Ie=fe.filter(o=>!et.has(o.value)).map(o=>{const f=I(o.value,l,c),y=e.measureText(o.label).width,r=At(f,y,l,l+c,o.end==="lo"),te=r<0?f-3-y:f+3;return{l:o,x:f,dir:r,start:te,end:te+y}}),tt=It(Ie),nt=_(-1)+2;Ie.forEach(({l:o,x:f,dir:y},r)=>{Bt(e,o,t.limitLine,f,0,f,v),e.fillStyle=t.limitLine,e.textAlign=y<0?"right":"left",e.textBaseline="bottom",e.fillText(o.label,f+y*3,v-1-tt[r]*nt)}),e.font=`${_(-1)}px system-ui, sans-serif`,e.strokeStyle=t.border,e.lineWidth=1,e.beginPath(),e.moveTo(l,v),e.lineTo(l+c,v),e.stroke(),e.fillStyle=t.textMuted,e.textAlign="center",e.textBaseline="top";const{ticks:ot,axis:pe}=Ze(e,c);for(const o of ot){const f=I(o,l,c);e.beginPath(),e.moveTo(f,v),e.lineTo(f,v+4),e.stroke(),e.fillText(pe.tick(o),f,v+6)}pe.unitLabel&&(e.textAlign="left",e.font=`${_(-1)}px system-ui, sans-serif`,e.fillText(`(${pe.unitLabel})`,l+c+22,v+6),e.font=`${_(-1)}px system-ui, sans-serif`),e.textBaseline="middle"}function xe(t){const s=Math.floor((t-L+$/2)/(A+$));return s>=0&&s<h.length?s:-1}function X(t){return ge(t,O,"engineering")}const P=!!g&&g.length>0&&w===null,Se=t=>!P&&!!Q&&T[t]?.waferIndex!==void 0;m.addEventListener("mousemove",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top),d=n>=0&&h[n].count>0&&(P||Se(n));if(n!==N&&(N=n,m.style.cursor=d?"pointer":"default",ee()),n>=0&&h[n].count>0){const e=h[n],l=P?`<br><em>click to see this ${C(oe)} by wafer</em>`:Se(n)?`<br><em>click to ${C(Ye)}</em>`:"",c=!P&&u.onWaferContextMenu&&T[n]?.waferIndex!==void 0?Ht:"";E.innerHTML=`<strong>${C(e.label)}</strong> (${e.count} dies)<br>max ${C(X(e.max))}<br>q3 ${C(X(e.q3))}<br>median ${C(X(e.median))}<br>q1 ${C(X(e.q1))}<br>min ${C(X(e.min))}${l}${c}`,E.style.display="block",pt(E,a,t.clientX,t.clientY)}else E.style.display="none"}),m.addEventListener("mouseleave",()=>{N!==-1&&(N=-1,ee()),E.style.display="none"}),m.addEventListener("click",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top);if(n===-1||h[n].count===0)return;if(P){const e=h[n].label;ve(e),u.onGroupChange?.(e);return}const d=T[n]?.waferIndex;Q&&d!==void 0&&b!==null&&Q(d,b)}),m.addEventListener("contextmenu",t=>{const s=m.getBoundingClientRect(),n=xe(t.clientY-s.top),d=n===-1?void 0:T[n]?.waferIndex;P||d===void 0||!u.onWaferContextMenu||(E.style.display="none",u.onWaferContextMenu(d,b??void 0,t))}),ce?.disconnect(),ce=dt(a,()=>ee()),ee()}S();function Ue(i){ke.set(i)&&(b=i,S())}function Fe(i){re.set(i)&&S()}return{card:a,setTest:Ue,setAxisPrefs:Fe,destroy:()=>ce?.disconnect()}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCapabilityData as
|
|
1
|
+
import{buildCapabilityData as Se}from"../../stats/capability.js";import{capabilityColor as G}from"./palette.js";import{LEADING as $e,SPACE as M,fontPx as Z,FONT as ee,CLR as j}from"../toolbar.js";import{cardShell as Me,isExpandedCard as Te,chartFillHeight as Ce,applyCanvasFlow as Le,observeResize as ke,makeTooltip as Pe,positionChartTooltip as Ee,renderEmptyState as we,resolveChartCanvasColors as De,chartSwatchCss as Ae,prepareCanvas as We,chartDpr as Ne}from"./chartShell.js";import{fmt as Ie}from"../../renderer/fmt.js";import{limitSetName as ae}from"../../renderer/valueFilter.js";import{escHtml as q}from"../../core/utils.js";import{DERIVED_MARK as te,DERIVED_KEY as re}from"../../renderer/testLabel.js";function I(v){return v==="spec"?{lo:"LSL",hi:"USL",noun:"spec limits"}:{lo:"Lo limit",hi:"Hi limit",noun:"test limits"}}function ce(v){let w;for(const X of v){if(!X.hasSpec)continue;const D=X.limitBasis??"test";if(w===void 0)w=D;else if(w!==D)return"mixed"}return w}const Be=30,me=160,de=90,pe=28,L=42;function z(v){return v===null?"\u2014":v.toFixed(2)}export function renderCapabilityPanel(v){const{title:w="Process capability",items:X,testDefs:D,onSaveImage:fe,onSelectTest:F}=v;let K=v.selectedTestNumber??null;const{card:p,body:k}=Me(w,fe,v.ownerDocument),he=D.some(t=>t.testNumber!==void 0);k.style.overflowX="auto";function ue(){return X}const A=p.ownerDocument.createElement("div");Object.assign(A.style,{display:"flex",flexDirection:"column",gap:M.xs,marginBottom:M.sm}),p.insertBefore(A,k);const B=Pe(p);let U=()=>{};function be(t,s,S,T,f,a){A.innerHTML="";const c=p.ownerDocument.createElement("span");Object.assign(c.style,{display:"inline-flex",alignItems:"center",gap:M.sm,color:j.value,fontSize:ee.body,fontWeight:"500"});const b=S-t,$=(s>0?` \xB7 ${s} without both limits`:"")+(a?` \xB7 ${a.total.toLocaleString("en-GB")} values outside ${ae(a.limitSet)} excluded`:""),C=p.ownerDocument.createElement("span");C.dataset.wmapCaption="1",C.textContent=b>0?`${t} of ${S} tests shown${$} \xB7 ${b} excluded (no recorded values)`:`${t} test${t!==1?"s":""} shown${$}`,c.appendChild(C),A.appendChild(c);const x=s>=t,W=p.ownerDocument.createElement("div");W.dataset.wmapCaption="1",W.textContent=x?"No test has both limits, so each is normalised to its own observed range (min = 0, max = 1) and sorted most-variable first. Ppk needs limits, so none is shown.":(f==="mixed"?"Normalised to each test's spec limits (LSL = 0, USL = 1), or its test limits (Lo limit = 0, Hi limit = 1) where it has no spec limits, worst Ppk first. ":`Normalised to ${I(f).noun} (${I(f).lo} = 0, ${I(f).hi} = 1), worst Ppk first. `)+"Tests without both limits are normalised to their own observed range and drawn muted/dashed.",Object.assign(W.style,{color:j.label,fontSize:ee.body,lineHeight:$e.base,marginTop:M.xs,maxWidth:"78ch"}),A.appendChild(W),A.appendChild(xe(p.ownerDocument,s>0,x,T>0))}function xe(t,s,S=!1,T=!1){const f=t.createElement("div");Object.assign(f.style,{display:"flex",flexWrap:"wrap",alignItems:"center",gap:`${M.xs} ${M.xl}`,marginTop:M.xl,marginBottom:M.xs,fontSize:ee.body,color:j.label});const a=S?[]:[{color:G(2),label:"Capable \xB7 Ppk \u2265 1.33"},{color:G(1.1),label:"Marginal \xB7 Ppk \u2265 1.0"},{color:G(.5),label:"Poor \xB7 Ppk < 1.0"}];s&&a.push({color:j.label,label:"No limits \xB7 no Ppk",dashed:!0});for(const c of a){const b=t.createElement("span");Object.assign(b.style,{display:"inline-flex",alignItems:"center",gap:M.sm});const $=t.createElement("span");$.style.cssText=Ae(c.color,c.dashed?"outline":"solid");const C=t.createElement("span");C.textContent=c.label,b.append($,C),f.appendChild(b)}if(T){const c=t.createElement("span");Object.assign(c.style,{display:"inline-flex",alignItems:"center",gap:M.sm});const b=t.createElement("span");b.textContent=te,Object.assign(b.style,{color:j.value,fontWeight:"600"});const $=t.createElement("span");$.textContent=re,c.append(b,$),f.appendChild(c)}return f}function ye(t){if(k.innerHTML="",t.length===0)return we(k,"No parametric tests have any recorded values.",{maxWidth:"480px"}),()=>{};const s=p.ownerDocument.createElement("canvas");s.style.display="block",s.style.cursor="default",k.appendChild(s);const S=t.length,T=Math.min(0,...t.map(n=>n.min)),f=Math.max(1,...t.map(n=>n.max)),a=(f-T)*.05||.1,c=T-a,$=f+a-c||1;function C(n){const o=Math.floor(n/S);return Math.max(Be,Te(p)?o:Math.min(me,o))}function x(n,o,i){return o+(1-(n-c)/$)*i}function W(n,o,i,l,P){const y=t.filter(g=>g.hasSpec).length,N=y===t.length,h=y===0,E=ce(t),e=E==="mixed"?{lo:"Lo",hi:"Hi",noun:"limits"}:I(E),u=h?"max":E==="spec"?e.hi:"Hi",r=h?"min":E==="spec"?e.lo:"Lo",R=N?`normalised to ${e.noun}`:h?"normalised to range":"normalised (per test)";n.font=`${Z(-1)}px system-ui, sans-serif`,n.textAlign="right",n.textBaseline="middle";for(const[g,m]of[[1,u],[0,r]]){const d=x(g,i,l);d<i-1||d>i+l+1||(n.strokeStyle=o.limitLine,n.lineWidth=1,n.beginPath(),n.moveTo(L-5,d),n.lineTo(L,d),n.stroke(),n.fillStyle=o.textMuted,n.fillText(m,L-8,d))}n.save(),n.translate(9,i+l/2),n.rotate(-Math.PI/2),n.textAlign="center",n.fillStyle=o.textMuted,n.fillText(R,0,0),n.restore()}let H=-1;function Q(){Le(s);const n=k.clientWidth,o=C(n-L),i=o*S,l=pe,P=L+i,y=Ce(p,k,s,pe+200+de),N=Math.max(l+60,y-de),h=N-l,E=We(s,p,P,y);if(!E)return;const{ctx:e}=E,u=De(p);t.forEach((r,R)=>{const g=L+R*o,m=g+o/2,d=Math.max(4,Math.min(o,me)*.55);if(R===H&&(e.fillStyle=u.bgHover,e.fillRect(g,l,o,N-l)),t[R].testNumber===K&&(e.fillStyle=u.accent,e.fillRect(g,N-2,o,2)),r.hasSpec){const le=x(0,l,h),se=x(1,l,h);e.strokeStyle=u.limitLine,e.setLineDash([3,3]),e.lineWidth=1,e.beginPath(),e.moveTo(g,le),e.lineTo(g+o,le),e.moveTo(g,se),e.lineTo(g+o,se),e.stroke(),e.setLineDash([])}const V=r.hasSpec?G(r.ppk):u.textMuted,Y=x(r.min,l,h),O=x(r.q1,l,h),ie=x(r.median,l,h),_=x(r.q3,l,h),J=x(r.max,l,h);e.strokeStyle=u.textMuted,e.lineWidth=1,e.beginPath(),e.moveTo(m,Y),e.lineTo(m,O),e.moveTo(m,_),e.lineTo(m,J),e.moveTo(m-d/4,Y),e.lineTo(m+d/4,Y),e.moveTo(m-d/4,J),e.lineTo(m+d/4,J),e.stroke(),e.fillStyle=V,e.globalAlpha=.5,e.fillRect(m-d/2,Math.min(O,_),d,Math.max(1,Math.abs(_-O))),e.globalAlpha=1,e.strokeStyle=V,r.hasSpec||e.setLineDash([4,2]),e.strokeRect(m-d/2,Math.min(O,_),d,Math.max(1,Math.abs(_-O))),e.setLineDash([]),e.strokeStyle=u.text,e.lineWidth=2,e.beginPath(),e.moveTo(m-d/2,ie),e.lineTo(m+d/2,ie),e.stroke(),e.lineWidth=1,e.font=`${Z(-1)}px system-ui, sans-serif`,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=r.hasSpec?V:u.textMuted,e.fillText(r.hasSpec?z(r.ppk):"\u2014",m,l-8);const oe=r.label.length>12?`${r.label.slice(0,11)}\u2026`:r.label;e.save(),e.translate(m,N+6),e.rotate(-Math.PI/4),e.textAlign="right",e.textBaseline="middle",e.font=`${Z(-1)}px system-ui, sans-serif`,e.fillStyle=u.textMuted,e.fillText(oe,0,0),r.derived&&(e.fillStyle=u.text,e.fillText(`${te} `,-e.measureText(oe).width,0)),e.restore()}),e.strokeStyle=u.border,e.lineWidth=1,e.strokeRect(L,l,i,h),W(e,u,l,h,i)}function ne(n){const o=s.getBoundingClientRect(),i=k.clientWidth,l=C(i-L),P=(n.clientX-o.left)*(s.width/Ne(s)/o.width)-L,y=Math.floor(P/l);return y>=0&&y<S?y:-1}return s.addEventListener("mousemove",n=>{const o=ne(n);if(o!==H&&(H=o,Q()),o===-1){B.style.display="none";return}const i=t[o],l=y=>q(Ie(y,i.unit)),P=i.derived?`<em>${te} ${q(re)}</em>`+(i.expression?`<br><code>${q(i.expression)}</code>`:"")+"<br>":"";B.innerHTML=`<strong>${q(i.label)}</strong> (n=${i.n}${i.excluded?`, ${i.excluded.count} outside ${ae(i.excluded.limitSet)} excluded`:""})<br>${P}`+(i.hasSpec?`${I(i.limitBasis).lo} ${l(i.lsl)} \xB7 ${I(i.limitBasis).hi} ${l(i.usl)}<br>mean ${l(i.mean)}<br>Cp ${z(i.cp)} \xB7 Cpk ${z(i.cpk)}<br>Pp ${z(i.pp)} \xB7 Ppk ${z(i.ppk)}`:`<em>No limits \u2014 sorted by variability</em><br>mean ${l(i.mean)} \xB7 stddev ${l(i.stdOverall)}`)+(F?"<br><em>click to view in boxplot</em>":""),B.style.display="block",Ee(B,p,n.clientX,n.clientY),s.style.cursor=F?"pointer":"default"}),s.addEventListener("mouseleave",()=>{H!==-1&&(H=-1,Q()),B.style.display="none"}),s.addEventListener("click",n=>{if(!F)return;const o=ne(n);o!==-1&&F(t[o].testNumber)}),Q}function ge(){const t=Se(ue(),D),s=D.filter(a=>a.testNumber!==void 0).length,S=t.filter(a=>!a.hasSpec).length,T=t.reduce((a,c)=>a+(c.excluded?.count??0),0),f=t.find(a=>a.excluded)?.excluded?.limitSet;be(t.length,S,s,t.filter(a=>a.derived).length,ce(t),T>0&&f?{total:T,limitSet:f}:void 0),U=ye(t),U()}const ve=ke(p,()=>U());return ge(),{card:p,hasData:he,setTest:t=>{K!==t&&(K=t,U())},destroy:()=>ve.disconnect()}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildTestHistogramData as Zt,collectTestValues as Ct,buildTestHistogramSeries as te,testValueExtent as Bt,diesInBucket as At}from"../../stats/histogram.js";import{SPACE as lt,fontPx as N,FONT as $t,CLR as Et}from"../toolbar.js";import{fmt as xt}from"../../renderer/fmt.js";import{niceStep as ee,fitTicks as Wt}from"../../renderer/axisTicks.js";import{QUANTITY as ne,categorical as ie}from"./palette.js";import{cardShell as oe,observeResize as Dt,makeTooltip as se,attachChartTip as le,positionChartTooltip as It,makeLinkedTestSelect as ae,makeWaferSelect as re,makeLinkedAxisPrefs as ce,renderEmptyState as kt,chartFillHeight as Pt,applyCanvasFlow as Rt,makeAxisFormat as Tt,horizontalTickSpacing as Kt,PADDING as mt,robustFence as Nt,shouldIncludeLimitsByDefault as Ot,drawOffAxisLimits as ue,resolveAxisRange as de,limitLines as Ft,limitExtent as me,hasBothLimitKinds as he,stackLabelRows as fe,strokeLimitLine as ge,chartSwatchCss as pe,makeSeriesLegendItem as xe,prepareCanvas as zt}from"./chartShell.js";import{escHtml as wt,maxOf as be}from"../../core/utils.js";const Mt=230,Gt=36,ye=18;function Vt(n){const $=new Set(n.map(E=>E.kind)).size;return ye+Math.max(0,$-1)*(N(-1)+2)}function jt(n,$,E,V,et,S,l){n.font=`${N(-1)}px system-ui, sans-serif`;const x=$.filter(i=>!E.has(i.value)).map(i=>{const k=V(i.value),W=n.measureText(i.label).width;return{l:i,x:k,start:k-W/2,end:k+W/2}}),U=fe(x),nt=N(-1)+2;x.forEach(({l:i,x:k},W)=>{ge(n,i,l,k,et,k,S),n.fillStyle=l,n.textAlign="center",n.textBaseline="bottom",n.fillText(i.label,k,et-2-U[W]*nt)})}function Xt(n,$,E,V,et,S,l,x=4){const U=Math.max(1,ee(S/x)),nt=V-E;n.save(),n.font=`${N(-1)}px system-ui, sans-serif`,n.textAlign="right",n.textBaseline="middle";for(let i=0;i<=S+1e-9;i+=U){const k=V-i/(S||1)*nt;n.strokeStyle=l.grid,n.lineWidth=1,n.beginPath(),n.moveTo($,k),n.lineTo($+et,k),n.stroke(),n.fillStyle=l.text,n.fillText(String(Math.round(i)),$-4,k)}n.strokeStyle=l.axis,n.lineWidth=1,n.beginPath(),n.moveTo($,E),n.lineTo($,V),n.stroke(),n.restore()}export function renderHistogramPanel(n){const{title:$="Test value distribution",items:E,testDefs:V,onSaveImage:et,groups:S}=n,{card:l,body:x,controlsRow:U}=oe($,et,n.ownerDocument),nt=V.filter(c=>c.testNumber!==void 0);let i=n.selectedTestNumber??nt[0]?.testNumber??null,k=null,W=0,ht;const vt=ae(nt,i,c=>{i=c,q(),n.onTestChange?.(c)},{maxWidth:"200px",ownerDocument:l.ownerDocument}),_t=vt.el;U.appendChild(_t);const ft=E.length>1?re(E,k,c=>{k=c,q()},{ownerDocument:l.ownerDocument}):null;ft&&U.appendChild(ft);function Yt(c){return b===c||c!==null&&!(S??[]).some(L=>L.key===c)?!1:(b=c,q(),!0)}const bt=l.ownerDocument.createElement("span");Object.assign(bt.style,{display:"inline-flex",gap:lt.lg,alignItems:"center"}),U.appendChild(bt);const at=ce(bt,n.axisPrefs,c=>{n.onAxisPrefsChange?.(c),q()},l.ownerDocument),C=se(l);let rt=null,b=null;function it(c){const L=V.find(I=>I.testNumber===c),j=Ft(L,at.get().limits),{lo:T,hi:w}=me(j);return{unit:L?.unit,lines:j,limitLow:T,limitHigh:w,hasLimits:Ft(L).length>0,hasBothKinds:he(L)}}function q(){const{includeLimits:c,clipOutliers:L}=at.get();if(rt?.disconnect(),rt=null,x.innerHTML="",i===null){kt(x,"No parametric test data available for a histogram.");return}const j=!!S&&S.length>0;let T=!1,w;if(j){const{limitLow:u,limitHigh:m}=it(i),g=S.flatMap(r=>r.items),{min:e,max:p}=Bt(g,i);if(T=c??Ot(e,p,u,m),L){const r=Ct(g,i),h=Nt(r);h&&(w={lo:Math.max(e,h.lo),hi:Math.min(p,h.hi)},W=r.reduce((Z,K)=>Z+(K<w.lo||K>w.hi?1:0),0))}w||(W=0),ht=w}const I=j?te(S,i,16,T?it(i).limitLow:void 0,T?it(i).limitHigh:void 0,w):null;if(ft&&(ft.style.display=I?"none":""),I){const{hasLimits:u,hasBothKinds:m}=it(i);if(at.sync(T,u,m),I.series.length===0){kt(x,"No parametric test data available for a histogram.");return}Qt(I);return}const O=k!==null?[E[k]]:E,{unit:D,lines:X,limitLow:M,limitHigh:_,hasLimits:ct,hasBothKinds:gt}=it(i),ut=Ct(O,i),{min:dt,max:pt}=Bt(O,i),P=c??Ot(dt,pt,M,_);at.sync(P,ct,gt);const ot=L?Nt(ut):null,R=ot?{lo:Math.max(dt,ot.lo),hi:Math.min(pt,ot.hi)}:void 0;W=R?ut.filter(u=>u<R.lo||u>R.hi).length:0,ht=R;const y=Zt(O,i,16,P?M:void 0,P?_:void 0,R);if(y.length===0){kt(x,"No parametric test data available for a histogram.");return}const o=Math.max(be(y.map(u=>u.count)),1),d=l.ownerDocument.createElement("div");d.dataset.wmapCaption="1",Object.assign(d.style,{fontSize:$t.body,color:Et.label,marginBottom:lt.xxs}),d.textContent=`max ${o} dies/bucket`+(W?` \xB7 ${W} value${W===1?"":"s"} outside clipped range`:"")+(n.onSelectBucket?" \xB7 click a bar to chart or tabulate its dies":""),x.appendChild(d);const s=l.ownerDocument.createElement("canvas");s.style.display="block",s.style.cursor="default",x.appendChild(s);let t=-1;const a=y[0].rangeLow,f=y[y.length-1].rangeHigh,H=f-a||1,F=Math.max(Math.abs(a),Math.abs(f));function J(u){const m=mt+36,g=s.clientWidth-m-mt,e=Vt(X),p=u-Gt-e;return{plotX:m,plotMaxWidth:Math.max(10,g),plotMaxHeight:p,plotTop:e}}function v(u){const{plotX:m,plotMaxWidth:g}=J(Mt);if(u<m||u>m+g)return-1;const e=Math.floor((u-m)/g*y.length);return e>=0&&e<y.length?e:-1}function A(){Rt(s,d);const u=x.clientWidth,m=Pt(l,x,s,Mt),g=zt(s,l,u,m);if(!g)return;const{ctx:e,theme:p}=g,{plotX:r,plotMaxWidth:h,plotMaxHeight:Z,plotTop:K}=J(m),B=K+Z,tt=h/y.length;Xt(e,r,K,B,h,o,{text:p.textMuted,axis:p.border,grid:p.grid}),y.forEach((G,Q)=>{const St=G.count/o*Z,Lt=r+Q*tt,Ht=B-St;e.fillStyle=Q===t?p.text:ne,e.globalAlpha=Q===t?1:.7,e.fillRect(Lt+1,Ht,Math.max(1,tt-2),St),e.globalAlpha=1,Q===t&&(e.fillStyle=p.text,e.textAlign="center",e.textBaseline="bottom",e.fillText(`${G.count}`,Lt+tt/2,Ht-2))});const st=G=>r+(G-a)/H*h;e.font=`${N(-1)}px system-ui, sans-serif`;const{offAxis:z}=de({dataMin:a,dataMax:f,limits:X,includeLimits:!1});ue(e,z,{left:r,right:r+h,top:K,bottom:B},"horizontal",p.limitLine,Tt(F,D).tick),jt(e,X,new Set(z.map(G=>G.value)),st,K,B,p.limitLine),e.font=`${N(-1)}px system-ui, sans-serif`,e.strokeStyle=p.border,e.lineWidth=1,e.beginPath(),e.moveTo(r,B),e.lineTo(r+h,B),e.stroke(),e.fillStyle=p.textMuted,e.textAlign="center",e.textBaseline="top";const{ticks:Y,step:Jt}=Wt(a,f,h,Kt(e,F,D)),yt=Tt(F,D,Jt||void 0);for(const G of Y){const Q=r+(G-a)/H*h;e.beginPath(),e.moveTo(Q,B),e.lineTo(Q,B+4),e.stroke(),e.fillText(yt.tick(G),Q,B+6)}yt.unitLabel&&(e.save(),e.font=`${N(-1)}px system-ui, sans-serif`,e.fillStyle=p.textMuted,e.textAlign="right",e.textBaseline="top",e.fillText(`(${yt.unitLabel})`,r+h,B+20),e.restore())}s.addEventListener("mousemove",u=>{const m=s.getBoundingClientRect(),g=v(u.clientX-m.left);if(g!==t&&(t=g,A()),g>=0){const e=y[g];C.innerHTML=`<strong>${wt(`${xt(e.rangeLow,D,"engineering")} \u2013 ${xt(e.rangeHigh,D,"engineering")}`)}</strong><br>${e.count} dies`+(n.onSelectBucket&&e.count>0?"<br><em>click to chart or tabulate these dies</em>":""),C.style.display="block",It(C,l,u.clientX,u.clientY)}else C.style.display="none"}),s.addEventListener("mouseleave",()=>{t!==-1&&(t=-1,A()),C.style.display="none"}),n.onSelectBucket&&(s.style.cursor="pointer",s.addEventListener("click",u=>{const m=v(u.clientX-s.getBoundingClientRect().left);if(m<0||i===null||y[m].count===0)return;const g=At(O,i,y,m,ht);g.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:y[m].rangeLow,high:y[m].rangeHigh,items:g},u))})),rt=Dt(l,()=>A()),A()}function Qt(c){const{unit:L,lines:j}=it(i),T=c.ranges,w=c.series,I=ie;b&&!w.some(o=>o.groupKey===b)&&(b=null);const O=Math.max(1,...w.flatMap(o=>o.counts)),D=l.ownerDocument.createElement("div");D.dataset.wmapCaption="1",Object.assign(D.style,{fontSize:$t.body,color:Et.label,marginBottom:lt.xxs}),D.textContent=`${w.length} groups \xB7 max ${O} dies/bucket`+(n.onSelectBucket?" \xB7 click a column to chart or tabulate its dies":""),x.appendChild(D);const X=l.ownerDocument.createElement("div");Object.assign(X.style,{display:"flex",flexWrap:"wrap",gap:lt.sm,marginTop:lt.md,marginBottom:lt.xl}),w.forEach((o,d)=>{const s=xe(o.groupKey,I(d),l.ownerDocument),t=s.el;le(t,l,C,`${o.groupKey} \u2014 click to emphasize (dim the rest)`),s.setState({selected:b===o.groupKey,dimmed:b!==null&&b!==o.groupKey}),t.addEventListener("click",()=>{const a=b===o.groupKey?null:o.groupKey;Yt(a),n.onGroupChange?.(a)}),X.appendChild(t)}),x.appendChild(X);const M=l.ownerDocument.createElement("canvas");M.style.display="block",M.style.cursor="default",x.appendChild(M);const _=T[0].rangeLow,ct=T[T.length-1].rangeHigh,gt=ct-_||1,ut=Math.max(Math.abs(_),Math.abs(ct)),dt=o=>{const d=(o.ownerDocument.defaultView??window).getComputedStyle(o);return o.offsetHeight+(parseFloat(d.marginTop)||0)+(parseFloat(d.marginBottom)||0)},pt=()=>dt(D)+dt(X);let P=-1,ot={plotX:mt+36,plotMaxWidth:10,barWidth:10};function R(){Rt(M,pt());const o=x.clientWidth,d=Pt(l,x,M,Mt),s=zt(M,l,o,d);if(!s)return;const{ctx:t,theme:a}=s,f=mt+36,H=Math.max(10,o-f-mt),F=Vt(j),J=d-Gt-F,v=F+J,A=H/T.length;ot={plotX:f,plotMaxWidth:H,barWidth:A},Xt(t,f,F,v,H,O,{text:a.textMuted,axis:a.border,grid:a.grid}),P>=0&&(t.fillStyle=a.bgHover,t.globalAlpha=.5,t.fillRect(f+P*A,F,A,J),t.globalAlpha=1);const u=w.map((r,h)=>({s:r,i:h})).sort((r,h)=>(r.s.groupKey===b?1:0)-(h.s.groupKey===b?1:0));for(const{s:r,i:h}of u){const Z=b===r.groupKey,K=b!==null&&!Z,B=I(h);t.strokeStyle=B,t.fillStyle=B,t.lineWidth=Z?2:1,t.globalAlpha=K?.12:b?.32:.22,t.beginPath(),t.moveTo(f,v),r.counts.forEach((tt,st)=>{const z=f+st*A,Y=v-tt/O*J;t.lineTo(z,Y),t.lineTo(z+A,Y)}),t.lineTo(f+H,v),t.closePath(),t.fill(),t.globalAlpha=K?.3:1,t.beginPath(),r.counts.forEach((tt,st)=>{const z=f+st*A,Y=v-tt/O*J;st===0?t.moveTo(z,Y):t.lineTo(z,Y),t.lineTo(z+A,Y)}),t.stroke()}t.globalAlpha=1;const m=r=>f+(r-_)/gt*H;t.font=`${N(-1)}px system-ui, sans-serif`,jt(t,j,new Set,m,F,v,a.limitLine),t.font=`${N(-1)}px system-ui, sans-serif`,t.strokeStyle=a.border,t.lineWidth=1,t.beginPath(),t.moveTo(f,v),t.lineTo(f+H,v),t.stroke(),t.fillStyle=a.textMuted,t.textAlign="center",t.textBaseline="top";const{ticks:g,step:e}=Wt(_,ct,H,Kt(t,ut,L)),p=Tt(ut,L,e||void 0);for(const r of g){const h=f+(r-_)/gt*H;t.beginPath(),t.moveTo(h,v),t.lineTo(h,v+4),t.stroke(),t.fillText(p.tick(r),h,v+6)}p.unitLabel&&(t.save(),t.font=`${N(-1)}px system-ui, sans-serif`,t.fillStyle=a.textMuted,t.textAlign="right",t.textBaseline="top",t.fillText(`(${p.unitLabel})`,f+H,v+20),t.restore())}function y(o){const{plotX:d,plotMaxWidth:s,barWidth:t}=ot;if(o<d||o>d+s)return-1;const a=Math.floor((o-d)/t);return a>=0&&a<T.length?a:-1}M.addEventListener("mousemove",o=>{const d=M.getBoundingClientRect(),s=y(o.clientX-d.left);if(s!==P&&(P=s,R()),s>=0){const t=T[s],a=w.map((f,H)=>`<span style="${pe(I(H))};margin-right:4px"></span>${wt(`${f.groupKey}: ${f.counts[s]}`)}`).join("<br>");C.innerHTML=`<strong>${wt(`${xt(t.rangeLow,L,"engineering")} \u2013 ${xt(t.rangeHigh,L,"engineering")}`)}</strong><br>${a}`,C.style.display="block",It(C,l,o.clientX,o.clientY)}else C.style.display="none"}),M.addEventListener("mouseleave",()=>{P!==-1&&(P=-1,R()),C.style.display="none"}),n.onSelectBucket&&S&&(M.style.cursor="pointer",M.addEventListener("click",o=>{const d=y(o.clientX-M.getBoundingClientRect().left);if(d<0||i===null)return;const s=b?S.filter(a=>a.key===b):S,t=At(s.flatMap(a=>a.items),i,T,d,ht);t.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:T[d].rangeLow,high:T[d].rangeHigh,items:t,...b?{group:b}:{}},o))})),rt=Dt(l,()=>R()),R()}q();function Ut(c){vt.set(c)&&(i=c,q())}function qt(c){at.set(c)&&q()}return{card:l,setTest:Ut,setAxisPrefs:qt,destroy:()=>rt?.disconnect()}}
|
|
1
|
+
import{buildTestHistogramData as ee,collectTestValues as Bt,buildTestHistogramSeries as ne,testValueExtent as At,diesInBucket as $t}from"../../stats/histogram.js";import{excludedNote as Et}from"../../renderer/valueFilter.js";import{SPACE as at,fontPx as K,FONT as Wt,CLR as Dt}from"../toolbar.js";import{fmt as bt}from"../../renderer/fmt.js";import{niceStep as ie,fitTicks as It}from"../../renderer/axisTicks.js";import{QUANTITY as oe,categorical as se}from"./palette.js";import{cardShell as le,observeResize as Pt,makeTooltip as ae,attachChartTip as re,positionChartTooltip as Rt,makeLinkedTestSelect as ce,makeWaferSelect as ue,makeLinkedAxisPrefs as de,renderEmptyState as Tt,chartFillHeight as Kt,applyCanvasFlow as Nt,makeAxisFormat as Mt,horizontalTickSpacing as Ot,PADDING as ht,robustFence as Ft,shouldIncludeLimitsByDefault as zt,drawOffAxisLimits as me,resolveAxisRange as he,limitLines as Gt,limitExtent as fe,hasBothLimitKinds as ge,stackLabelRows as pe,strokeLimitLine as xe,chartSwatchCss as be,makeSeriesLegendItem as ye,prepareCanvas as Vt}from"./chartShell.js";import{escHtml as wt,maxOf as ke}from"../../core/utils.js";const vt=230,jt=36,Te=18;function Xt(n){const E=new Set(n.map(A=>A.kind)).size;return Te+Math.max(0,E-1)*(K(-1)+2)}function _t(n,E,A,V,et,k,a){n.font=`${K(-1)}px system-ui, sans-serif`;const x=E.filter(i=>!A.has(i.value)).map(i=>{const S=V(i.value),N=n.measureText(i.label).width;return{l:i,x:S,start:S-N/2,end:S+N/2}}),U=pe(x),nt=K(-1)+2;x.forEach(({l:i,x:S},N)=>{xe(n,i,a,S,et,S,k),n.fillStyle=a,n.textAlign="center",n.textBaseline="bottom",n.fillText(i.label,S,et-2-U[N]*nt)})}function Yt(n,E,A,V,et,k,a,x=4){const U=Math.max(1,ie(k/x)),nt=V-A;n.save(),n.font=`${K(-1)}px system-ui, sans-serif`,n.textAlign="right",n.textBaseline="middle";for(let i=0;i<=k+1e-9;i+=U){const S=V-i/(k||1)*nt;n.strokeStyle=a.grid,n.lineWidth=1,n.beginPath(),n.moveTo(E,S),n.lineTo(E+et,S),n.stroke(),n.fillStyle=a.text,n.fillText(String(Math.round(i)),E-4,S)}n.strokeStyle=a.axis,n.lineWidth=1,n.beginPath(),n.moveTo(E,A),n.lineTo(E,V),n.stroke(),n.restore()}export function renderHistogramPanel(n){const{title:E="Test value distribution",items:A,testDefs:V,onSaveImage:et,groups:k}=n,{card:a,body:x,controlsRow:U}=le(E,et,n.ownerDocument),nt=V.filter(s=>s.testNumber!==void 0);let i=n.selectedTestNumber??nt[0]?.testNumber??null;const S=()=>(k?k.flatMap(s=>s.items):A).flatMap(s=>s.dies??[]);let N=null,it=0,ft;const St=ce(nt,i,s=>{i=s,q(),n.onTestChange?.(s)},{maxWidth:"200px",ownerDocument:a.ownerDocument}),Qt=St.el;U.appendChild(Qt);const gt=A.length>1?ue(A,N,s=>{N=s,q()},{ownerDocument:a.ownerDocument}):null;gt&&U.appendChild(gt);function Ut(s){return b===s||s!==null&&!(k??[]).some(L=>L.key===s)?!1:(b=s,q(),!0)}const yt=a.ownerDocument.createElement("span");Object.assign(yt.style,{display:"inline-flex",gap:at.lg,alignItems:"center"}),U.appendChild(yt);const rt=de(yt,n.axisPrefs,s=>{n.onAxisPrefsChange?.(s),q()},a.ownerDocument),C=ae(a);let ct=null,b=null;function ot(s){const L=V.find(D=>D.testNumber===s),j=Gt(L,rt.get().limits),{lo:T,hi:M}=fe(j);return{unit:L?.unit,lines:j,limitLow:T,limitHigh:M,hasLimits:Gt(L).length>0,hasBothKinds:ge(L)}}function q(){const{includeLimits:s,clipOutliers:L}=rt.get();if(ct?.disconnect(),ct=null,x.innerHTML="",i===null){Tt(x,"No parametric test data available for a histogram.");return}const j=!!k&&k.length>0;let T=!1,M;if(j){const{limitLow:u,limitHigh:m}=ot(i),g=k.flatMap(c=>c.items),{min:e,max:p}=At(g,i);if(T=s??zt(e,p,u,m),L){const c=Bt(g,i),h=Ft(c);h&&(M={lo:Math.max(e,h.lo),hi:Math.min(p,h.hi)},it=c.reduce((Z,R)=>Z+(R<M.lo||R>M.hi?1:0),0))}M||(it=0),ft=M}const D=j?ne(k,i,16,T?ot(i).limitLow:void 0,T?ot(i).limitHigh:void 0,M):null;if(gt&&(gt.style.display=D?"none":""),D){const{hasLimits:u,hasBothKinds:m}=ot(i);if(rt.sync(T,u,m),D.series.length===0){Tt(x,"No parametric test data available for a histogram.");return}qt(D);return}const O=N!==null?[A[N]]:A,{unit:W,lines:X,limitLow:w,limitHigh:_,hasLimits:ut,hasBothKinds:pt}=ot(i),dt=Bt(O,i),{min:mt,max:xt}=At(O,i),I=s??zt(mt,xt,w,_);rt.sync(I,ut,pt);const st=L?Ft(dt):null,P=st?{lo:Math.max(mt,st.lo),hi:Math.min(xt,st.hi)}:void 0;it=P?dt.filter(u=>u<P.lo||u>P.hi).length:0,ft=P;const y=ee(O,i,16,I?w:void 0,I?_:void 0,P);if(y.length===0){Tt(x,"No parametric test data available for a histogram.");return}const o=Math.max(ke(y.map(u=>u.count)),1),d=a.ownerDocument.createElement("div");d.dataset.wmapCaption="1",Object.assign(d.style,{fontSize:Wt.body,color:Dt.label,marginBottom:at.xxs}),d.textContent=`max ${o} dies/bucket`+Et(S(),i)+(it?` \xB7 ${it} value${it===1?"":"s"} outside clipped range`:"")+(n.onSelectBucket?" \xB7 click a bar to chart or tabulate its dies":""),x.appendChild(d);const l=a.ownerDocument.createElement("canvas");l.style.display="block",l.style.cursor="default",x.appendChild(l);let t=-1;const r=y[0].rangeLow,f=y[y.length-1].rangeHigh,H=f-r||1,F=Math.max(Math.abs(r),Math.abs(f));function J(u){const m=ht+36,g=l.clientWidth-m-ht,e=Xt(X),p=u-jt-e;return{plotX:m,plotMaxWidth:Math.max(10,g),plotMaxHeight:p,plotTop:e}}function v(u){const{plotX:m,plotMaxWidth:g}=J(vt);if(u<m||u>m+g)return-1;const e=Math.floor((u-m)/g*y.length);return e>=0&&e<y.length?e:-1}function $(){Nt(l,d);const u=x.clientWidth,m=Kt(a,x,l,vt),g=Vt(l,a,u,m);if(!g)return;const{ctx:e,theme:p}=g,{plotX:c,plotMaxWidth:h,plotMaxHeight:Z,plotTop:R}=J(m),B=R+Z,tt=h/y.length;Yt(e,c,R,B,h,o,{text:p.textMuted,axis:p.border,grid:p.grid}),y.forEach((G,Q)=>{const Lt=G.count/o*Z,Ht=c+Q*tt,Ct=B-Lt;e.fillStyle=Q===t?p.text:oe,e.globalAlpha=Q===t?1:.7,e.fillRect(Ht+1,Ct,Math.max(1,tt-2),Lt),e.globalAlpha=1,Q===t&&(e.fillStyle=p.text,e.textAlign="center",e.textBaseline="bottom",e.fillText(`${G.count}`,Ht+tt/2,Ct-2))});const lt=G=>c+(G-r)/H*h;e.font=`${K(-1)}px system-ui, sans-serif`;const{offAxis:z}=he({dataMin:r,dataMax:f,limits:X,includeLimits:!1});me(e,z,{left:c,right:c+h,top:R,bottom:B},"horizontal",p.limitLine,Mt(F,W).tick),_t(e,X,new Set(z.map(G=>G.value)),lt,R,B,p.limitLine),e.font=`${K(-1)}px system-ui, sans-serif`,e.strokeStyle=p.border,e.lineWidth=1,e.beginPath(),e.moveTo(c,B),e.lineTo(c+h,B),e.stroke(),e.fillStyle=p.textMuted,e.textAlign="center",e.textBaseline="top";const{ticks:Y,step:te}=It(r,f,h,Ot(e,F,W)),kt=Mt(F,W,te||void 0);for(const G of Y){const Q=c+(G-r)/H*h;e.beginPath(),e.moveTo(Q,B),e.lineTo(Q,B+4),e.stroke(),e.fillText(kt.tick(G),Q,B+6)}kt.unitLabel&&(e.save(),e.font=`${K(-1)}px system-ui, sans-serif`,e.fillStyle=p.textMuted,e.textAlign="right",e.textBaseline="top",e.fillText(`(${kt.unitLabel})`,c+h,B+20),e.restore())}l.addEventListener("mousemove",u=>{const m=l.getBoundingClientRect(),g=v(u.clientX-m.left);if(g!==t&&(t=g,$()),g>=0){const e=y[g];C.innerHTML=`<strong>${wt(`${bt(e.rangeLow,W,"engineering")} \u2013 ${bt(e.rangeHigh,W,"engineering")}`)}</strong><br>${e.count} dies`+(n.onSelectBucket&&e.count>0?"<br><em>click to chart or tabulate these dies</em>":""),C.style.display="block",Rt(C,a,u.clientX,u.clientY)}else C.style.display="none"}),l.addEventListener("mouseleave",()=>{t!==-1&&(t=-1,$()),C.style.display="none"}),n.onSelectBucket&&(l.style.cursor="pointer",l.addEventListener("click",u=>{const m=v(u.clientX-l.getBoundingClientRect().left);if(m<0||i===null||y[m].count===0)return;const g=$t(O,i,y,m,ft);g.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:y[m].rangeLow,high:y[m].rangeHigh,items:g},u))})),ct=Pt(a,()=>$()),$()}function qt(s){const{unit:L,lines:j}=ot(i),T=s.ranges,M=s.series,D=se;b&&!M.some(o=>o.groupKey===b)&&(b=null);const O=Math.max(1,...M.flatMap(o=>o.counts)),W=a.ownerDocument.createElement("div");W.dataset.wmapCaption="1",Object.assign(W.style,{fontSize:Wt.body,color:Dt.label,marginBottom:at.xxs}),W.textContent=`${M.length} groups \xB7 max ${O} dies/bucket`+Et(S(),i)+(n.onSelectBucket?" \xB7 click a column to chart or tabulate its dies":""),x.appendChild(W);const X=a.ownerDocument.createElement("div");Object.assign(X.style,{display:"flex",flexWrap:"wrap",gap:at.sm,marginTop:at.md,marginBottom:at.xl}),M.forEach((o,d)=>{const l=ye(o.groupKey,D(d),a.ownerDocument),t=l.el;re(t,a,C,`${o.groupKey} \u2014 click to emphasize (dim the rest)`),l.setState({selected:b===o.groupKey,dimmed:b!==null&&b!==o.groupKey}),t.addEventListener("click",()=>{const r=b===o.groupKey?null:o.groupKey;Ut(r),n.onGroupChange?.(r)}),X.appendChild(t)}),x.appendChild(X);const w=a.ownerDocument.createElement("canvas");w.style.display="block",w.style.cursor="default",x.appendChild(w);const _=T[0].rangeLow,ut=T[T.length-1].rangeHigh,pt=ut-_||1,dt=Math.max(Math.abs(_),Math.abs(ut)),mt=o=>{const d=(o.ownerDocument.defaultView??window).getComputedStyle(o);return o.offsetHeight+(parseFloat(d.marginTop)||0)+(parseFloat(d.marginBottom)||0)},xt=()=>mt(W)+mt(X);let I=-1,st={plotX:ht+36,plotMaxWidth:10,barWidth:10};function P(){Nt(w,xt());const o=x.clientWidth,d=Kt(a,x,w,vt),l=Vt(w,a,o,d);if(!l)return;const{ctx:t,theme:r}=l,f=ht+36,H=Math.max(10,o-f-ht),F=Xt(j),J=d-jt-F,v=F+J,$=H/T.length;st={plotX:f,plotMaxWidth:H,barWidth:$},Yt(t,f,F,v,H,O,{text:r.textMuted,axis:r.border,grid:r.grid}),I>=0&&(t.fillStyle=r.bgHover,t.globalAlpha=.5,t.fillRect(f+I*$,F,$,J),t.globalAlpha=1);const u=M.map((c,h)=>({s:c,i:h})).sort((c,h)=>(c.s.groupKey===b?1:0)-(h.s.groupKey===b?1:0));for(const{s:c,i:h}of u){const Z=b===c.groupKey,R=b!==null&&!Z,B=D(h);t.strokeStyle=B,t.fillStyle=B,t.lineWidth=Z?2:1,t.globalAlpha=R?.12:b?.32:.22,t.beginPath(),t.moveTo(f,v),c.counts.forEach((tt,lt)=>{const z=f+lt*$,Y=v-tt/O*J;t.lineTo(z,Y),t.lineTo(z+$,Y)}),t.lineTo(f+H,v),t.closePath(),t.fill(),t.globalAlpha=R?.3:1,t.beginPath(),c.counts.forEach((tt,lt)=>{const z=f+lt*$,Y=v-tt/O*J;lt===0?t.moveTo(z,Y):t.lineTo(z,Y),t.lineTo(z+$,Y)}),t.stroke()}t.globalAlpha=1;const m=c=>f+(c-_)/pt*H;t.font=`${K(-1)}px system-ui, sans-serif`,_t(t,j,new Set,m,F,v,r.limitLine),t.font=`${K(-1)}px system-ui, sans-serif`,t.strokeStyle=r.border,t.lineWidth=1,t.beginPath(),t.moveTo(f,v),t.lineTo(f+H,v),t.stroke(),t.fillStyle=r.textMuted,t.textAlign="center",t.textBaseline="top";const{ticks:g,step:e}=It(_,ut,H,Ot(t,dt,L)),p=Mt(dt,L,e||void 0);for(const c of g){const h=f+(c-_)/pt*H;t.beginPath(),t.moveTo(h,v),t.lineTo(h,v+4),t.stroke(),t.fillText(p.tick(c),h,v+6)}p.unitLabel&&(t.save(),t.font=`${K(-1)}px system-ui, sans-serif`,t.fillStyle=r.textMuted,t.textAlign="right",t.textBaseline="top",t.fillText(`(${p.unitLabel})`,f+H,v+20),t.restore())}function y(o){const{plotX:d,plotMaxWidth:l,barWidth:t}=st;if(o<d||o>d+l)return-1;const r=Math.floor((o-d)/t);return r>=0&&r<T.length?r:-1}w.addEventListener("mousemove",o=>{const d=w.getBoundingClientRect(),l=y(o.clientX-d.left);if(l!==I&&(I=l,P()),l>=0){const t=T[l],r=M.map((f,H)=>`<span style="${be(D(H))};margin-right:4px"></span>${wt(`${f.groupKey}: ${f.counts[l]}`)}`).join("<br>");C.innerHTML=`<strong>${wt(`${bt(t.rangeLow,L,"engineering")} \u2013 ${bt(t.rangeHigh,L,"engineering")}`)}</strong><br>${r}`,C.style.display="block",Rt(C,a,o.clientX,o.clientY)}else C.style.display="none"}),w.addEventListener("mouseleave",()=>{I!==-1&&(I=-1,P()),C.style.display="none"}),n.onSelectBucket&&k&&(w.style.cursor="pointer",w.addEventListener("click",o=>{const d=y(o.clientX-w.getBoundingClientRect().left);if(d<0||i===null)return;const l=b?k.filter(r=>r.key===b):k,t=$t(l.flatMap(r=>r.items),i,T,d,ft);t.length!==0&&(C.style.display="none",n.onSelectBucket({testNumber:i,low:T[d].rangeLow,high:T[d].rangeHigh,items:t,...b?{group:b}:{}},o))})),ct=Pt(a,()=>P()),P()}q();function Jt(s){St.set(s)&&(i=s,q())}function Zt(s){rt.set(s)&&q()}return{card:a,setTest:Jt,setAxisPrefs:Zt,destroy:()=>ct?.disconnect()}}
|