@wafertools/wafermap 0.38.0 → 0.40.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 +79 -3
- package/README.md +4 -3
- package/dist/packages/canvas-adapter/cellShade.d.ts +21 -0
- package/dist/packages/canvas-adapter/cellShade.js +1 -0
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +19 -3
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/commonality.js +4 -1
- package/dist/packages/canvas-adapter/charts/correlation.d.ts +11 -0
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +23 -0
- package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -0
- package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
- package/dist/packages/canvas-adapter/charts/palette.d.ts +10 -3
- package/dist/packages/canvas-adapter/charts/palette.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +8 -0
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +1 -0
- package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
- package/dist/packages/canvas-adapter/filterJson.d.ts +25 -0
- package/dist/packages/canvas-adapter/filterJson.js +5 -0
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/pageFilter.js +2 -2
- package/dist/packages/canvas-adapter/plotEditor.js +10 -1
- package/dist/packages/canvas-adapter/plotJsonComplete.d.ts +46 -0
- package/dist/packages/canvas-adapter/plotJsonComplete.js +4 -0
- package/dist/packages/canvas-adapter/plotJsonHistory.d.ts +12 -0
- package/dist/packages/canvas-adapter/plotJsonHistory.js +1 -0
- package/dist/packages/canvas-adapter/plotJsonSuggest.d.ts +16 -0
- package/dist/packages/canvas-adapter/plotJsonSuggest.js +1 -0
- package/dist/packages/canvas-adapter/plotModal.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
- package/dist/packages/canvas-adapter/sweepEditor.js +1 -1
- package/dist/packages/canvas-adapter/toCanvas.d.ts +1 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +81 -43
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/virtualTable.d.ts +2 -0
- package/dist/packages/canvas-adapter/virtualTable.js +1 -1
- package/dist/packages/core/compact.js +2 -2
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/utils.d.ts +6 -0
- package/dist/packages/core/utils.js +1 -1
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/stats/chartCatalogue.js +1 -1
- package/dist/packages/stats/coFailure.d.ts +11 -0
- package/dist/packages/stats/coFailure.js +1 -0
- package/dist/packages/stats/commonality.d.ts +37 -4
- package/dist/packages/stats/commonality.js +1 -1
- package/dist/packages/stats/correlation.d.ts +7 -0
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/dieRegions.d.ts +2 -0
- package/dist/packages/stats/dieRegions.js +1 -1
- package/dist/packages/stats/differenceMap.d.ts +2 -0
- package/dist/packages/stats/differenceMap.js +1 -1
- package/dist/packages/stats/examplePicks.d.ts +6 -0
- package/dist/packages/stats/examplePicks.js +1 -1
- package/dist/packages/stats/groupEffects.d.ts +66 -0
- package/dist/packages/stats/groupEffects.js +1 -0
- package/dist/packages/stats/plotData.d.ts +11 -2
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +31 -2
- package/dist/packages/stats/plotSpec.js +4 -4
- package/dist/packages/stats/plotTable.d.ts +18 -0
- package/dist/packages/stats/plotTable.js +1 -0
- package/dist/packages/stats/renderFindingsReport.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +7 -7
- package/dist/packages/stats/reportHtml.js +18 -13
- package/dist/packages/stats/sweep.d.ts +3 -3
- package/dist/packages/stats/sweepXFromName.js +1 -1
- package/dist/packages/stats/synthesis.d.ts +19 -0
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/testsByWafer.d.ts +11 -0
- package/dist/packages/stats/testsByWafer.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -22,6 +22,82 @@ under `### Breaking`.
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
## [Unreleased]
|
|
26
|
+
|
|
27
|
+
## [0.40.0] — 2026-11-06
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **What stands out compares groups of wafers on yield and on the weakest ring, as well as on tests.** A probe card, a tester or a process recipe that costs yield is listed with its size in yield points and the fail bin most of it is in, and a pattern that is heavier in one group shows as a lower pass rate in its ring on that group's wafers. Each set of groups is read after allowing for the strongest other one (a weak card on wafers that also differ by recipe), and says so. Fields that group the wafers identically (a tester and the handler docked to it) are one item that names them together. A yield item has no map view, so its target is `{ kind: 'group', field }` and its chart is a bar of yield by that field.
|
|
32
|
+
- **What divides yield reads each field after allowing for the strongest other one.** A probe card hidden by a process recipe (wafers that differ by both) is ranked by what is left once the recipe's group means are taken out, with the degrees of freedom those means used charged to the p. The row says "allowing for …", and its Worst and Best groups stay the measure's own means. What stands out, the example plots and this card now share one reading of groups (`stats/groupEffects`).
|
|
33
|
+
- **Worth a look draws a group item once.** An item about groups of wafers (yield by a field) has no Show on map, since it has no place on the map, and its card is left out when Insights is already grouped by that field or one that gives the same groups, whose yield card shows the same bars.
|
|
34
|
+
- **Example plots offer a bar of yield for each lot field that divides the wafers' yield.** The fields are read as What stands out reads them (one set of groups for fields that group the wafers identically, each set read after allowing for the strongest other one), so a probe card hidden by a process recipe is found, and a tester and the handler docked to it each get a bar. The split the test plots use is chosen the same way.
|
|
35
|
+
- **Fields that nearly match are said so.** Where two sets of groups put most wafers in matching groups without being identical (a tester and an operator who mostly go together), an item about one says how many wafers the other agrees on, and What divides yield names the pair. Neither is allowed for in reading the other, since that would remove most of its effect.
|
|
36
|
+
- **A "Possible, not confirmed" list under What stands out.** Groups of wafers that differ on two or more measures with no overlap between the groups, and that account for a real share of a material loss, are listed apart from what stands out when the sample is too small to confirm them once the number of comparisons is allowed for (four wafers against four cannot reach an exact p under 0.014). Each needs a raw p under 0.05, complete separation, agreement in direction between yield and the ring's pass rate, and a set of groups with no confirmed item of its own. `Synthesis.possible` carries them; the Summary panel, the Insights tab and the report show them, and `synthesisText` prints them under their own heading.
|
|
37
|
+
- **The showcase lots carry the equipment and fab fields of their probe sessions.** Each demo CSV has tester, handler, probe card, operator, test program, test date and, where the lot has one, a process split. The parametric lot has twelve wafers, four of each corner, and the cluster lot eight.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- **A click and a right-click agree on every Insights chart.** A right-click on a bar, a histogram bar, a heatmap cell, a ring, quadrant or reticle cell, a sweep level or a point opens the same menu on the dies it counts that a click opens, and on a wafer's own bar or point the menu for that wafer. The heatmaps (yield by ring or quadrant and wafer, re-probed dies, tests by wafer), Yield by site and the charts on Worth a look open it too, and their tooltips say so.
|
|
42
|
+
- **What divides yield shows fields that group the wafers identically as one row.** The row names every field of the set, and its Group by button groups by the first.
|
|
43
|
+
- **What divides yield has one row per field.** Each row shows the field's yield (or a fail bin, when that differs more clearly) as two bars, the worst and the best group's mean, and a sentence giving the gap in points. **Confidence** reads Clear, Possible or Not clear from q (under 0.05, under 0.2), with q, Welch's p and the rank p in its tooltip, and the other measures open under a button on the field. Fields are ordered clear first, then by the size of the difference. How to read the statistics is under **How to read this**.
|
|
44
|
+
- **Axes and legends keep clear of each other.** With axes shown, the tick labels sit beside the map, clear of a left or bottom legend, and stop at a right-hand legend or colorbar. A side legend leaves a 12 px gap to the wafer area. Tick labels name only die positions: they run across the dies and no further, whichever side the legend is on.
|
|
45
|
+
- **The Insights demo lot carries a tester and a probe card.** Its wafers are probed on two testers and three probe cards, one of them weak, so **What divides yield** ranks equipment beside the process split, and a field that moves with another is named as such. `docs/examples/data.js` takes `equipmentForWafer(index)` and a `yieldShift` option for it.
|
|
46
|
+
- **The Chart gallery shows Sweep and Histogram of the dies picked.** Each has a thumbnail and a tile that opens its own page. The sweep, derived-test and name-pattern examples use neutral test names (`LEVEL_12K`, `Cum_share= …`) in the guide, the API reference and the tests.
|
|
47
|
+
|
|
48
|
+
## [0.39.0] — 2026-10-31
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **A JSON view in the Filter window.** A **Conditions | JSON** switch shows the filter as text to edit, paste or copy, with suggestions for its keys, the lot's fields and tests and the values a field takes, undo, and a pasted filters file offering its filters to choose from. The preview follows the text as it is typed; the window's Apply is held, with the reason shown, while the text cannot be read.
|
|
53
|
+
- **Save data as CSV and Copy data in a plot card's ⋯ menu.** The numbers behind a chart: a scatter's points, a histogram's values, a box's five-number summary per category, a bar's or line's values, a heatmap's cells, a control chart's points and limits; a plot of panels names the panel. Copy gives tab-separated text for a spreadsheet.
|
|
54
|
+
- **Yield by site.** An Overview card, drawn when a lot's dies come from two test sites or more: the yield of each site over every wafer, with the median as a line from three sites. A site that is low on every wafer points at the probe card, not the wafers.
|
|
55
|
+
- **Shaded cells in the comparison tables.** A group's or wafer's mean is shaded among its peers (blue below the average, warm above, fading to nothing at the average; a set of means that print the same, or differ by under 1%, is left unshaded) in the Comparison by group table, the new statistics table and the Wafers table; a yield or the share inside limits is tinted red only when it falls a point or more short of its reference (the lot's mean per-wafer yield, or the best group's share), by the summary report's one rule, so a lot with nothing wrong has no tint; a Ppk takes the capable, marginal and poor colours in every statistics table (each group's and the docked panel's); in What divides yield a yield's worst group is tinted by the same rule against the wafers' mean yield, and in the Dies table a reading outside its test's limits is tinted. The numbers are always printed.
|
|
56
|
+
- **Statistics compared across groups.** With Group by on, the Data tab's Statistics view opens with one table of every test for every group (a test's groups side by side, with Ppk and the share inside limits) and its own CSV, above each group's own tables.
|
|
57
|
+
- **Log scale on the Value histogram and the Wafer-to-wafer trend**, and **Clip outliers, Axis includes limits and a log scale for each axis on the Test scatter**, so every value-axis card offers the same axis choices.
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- **The difference map is set up as a gallery map is.** In its card the toolbar is one row of map tools (no view controls or Summary, whose choices would stop it being a difference map) and the map is as wide as the card; expanded, it takes the height the box has left under its note, as the other charts do. Its note reads "…has no value at. How to read this: …".
|
|
62
|
+
- **Choosing a colour in a control chart's legend picks out its wafers.** The chosen colours' points are larger and ringed, and the line between points that are not both chosen is dimmed; the centre and limits, which come from every wafer, stay as they are.
|
|
63
|
+
- **Columns never asks for more columns than there are cards.** The gallery offers up to the wafers on show (at most 5), and the keys 1 to 5 follow. On Insights the count is the most columns a grid uses, for every tab: a tab uses the smaller of it and the cards in its fullest grid, so a tab of two cards is two columns and not two cards in four slots, and a count a host sets on a gallery is kept as it is.
|
|
64
|
+
- **A plot card keeps its size at any display scaling.** Its body never scrolls on its own, so a chart no longer redraws every frame, blurred, at a fractional device pixel ratio (125% scaling, for one), where a scrollbar that appeared and went with a sub-pixel overflow resized it each time.
|
|
65
|
+
- **A heatmap has a line between its cells, a frame and a tick for each row and column.** A pale or empty cell reads as a cell against the card, and each label is tied to its row or column.
|
|
66
|
+
- **A name in capitals is labelled as it is written.** A field called `TEMP` is labelled TEMP; a name is split into words where a word starts (`processSplit` is Process Split, `LOT_ID` is LOT ID), not before every capital letter.
|
|
67
|
+
- **A line over a measured value in ranges says so.** Its title reads "… by range of …", and its note says how many ranges, whether each holds about the same number of dies or the same width, and that a point is drawn at the middle of its range; the band is described as the spread in each range. A test name keeps its own capitals in the note (`vth_n_mV`, not `vth_n_mv`).
|
|
68
|
+
- **Overview leads with Worth a look.** Worth a look, then What divides yield, then the fixed cards; a lot with nothing to show has no Worth a look, so its Overview is the fixed cards as before.
|
|
69
|
+
- **Distributions has one Test picker.** It sits in the Test by test row and sets the test for every card below; a card shows its own picker only while it is expanded.
|
|
70
|
+
- **The Wafers table puts the numbers first.** Wafer, the field Group by divides by, dies, yield and the test means come before the other attributes; attributes that are the same on every wafer are named in a line above the table and kept in the export.
|
|
71
|
+
- **With Group by on, a bar of wafers takes the group's colours.** The per-wafer bar cards in Worth a look draw the wafers under their group on a second level of the X axis, coloured by group, so a pattern that belongs to a group (both low wafers are SS) shows as a colour; the Overview's yield card colours its bars by group as the cards beside it do. With no grouping they are drawn as before.
|
|
72
|
+
- **A colour scale is never stretched over noise.** A heatmap of measured values whose cells are within 1% of their mean has a colour key at least 1% of the mean wide, and the difference map's colours span at least 1% of the level it compares, saying so in its note when no difference is larger; the shaded table cells are left plain when a set of means differ by under 1%.
|
|
73
|
+
- **A field that moves several tests is drawn as a grid in Worth a look.** The chart of "N tests differ by Split" is a heatmap of the field's values by those tests, each cell the mean of its wafers in z-scores.
|
|
74
|
+
- **A heatmap of z-scores runs blue to orange around zero; a yield or pass rate runs orange-red to blue.** A heatmap of rescaled values (z-score or robust z-score) is coloured blue below average, a light neutral at zero and orange above, with the colour bar equally far either side of zero; a heatmap of a yield or pass rate runs orange-red for bad to blue for good on a fixed scale from 50% to 100%, so the same yield is always the same colour. Both stay distinguishable for the common kinds of colour blindness. Each cell's value is dark or white as its colour needs; any other heatmap runs from its lowest cell to its highest.
|
|
75
|
+
- **Axis exponents read as powers of ten.** An axis that needs a shared exponent says ×10³ or ×10⁻⁶ (it said ×10E3), and the Simpson's-paradox warning on the correlation matrix points to the Wafer picker, and to Group by only where one of the mixed fields is in its list.
|
|
76
|
+
- **A line can run along a field put in ranges, and the examples use it.** A line's X can be a measured value or a distance put in ranges: the line is drawn along the middles of the ranges, so a profile across the wafer reads as one line per split instead of a crowd of boxes. Under a split, the examples draw the first test by its partner's ranges and by distance from the centre as lines (median with a ±1 SD band), and the tests with limits as a grid of tests by split.
|
|
77
|
+
- **A control chart can colour its points by a wafer field.** A colour (in Insights, Group by) colours each point by its wafer's value and leaves the line and limits as one series in order, so a pattern that belongs to a group shows as a colour. The Wafer-to-wafer control chart follows Group by.
|
|
78
|
+
- **A heatmap of wafers under Group by sits the wafers with their group.** The columns are ordered by the group first, then by wafer, so a pattern that belongs to a group shows as a block of columns.
|
|
79
|
+
- **Re-probed dies.** A **Re-probed** field (the share of dies probed more than once) is a plot field when a lot has re-probes, and the Overview gains a card of it by ring and wafer (or group), so a hotspot of retests shows.
|
|
80
|
+
- **Fails together on the correlation matrix.** A **Values | Fails together** choice draws the matrix of which tests fail on the same dies: each cell is the share of the dies failing either of two tests that fail both, so two symptoms of one defect show as a pair even when their values do not correlate. Tests without limits, and tests that fail on fewer than two dies, are left out.
|
|
81
|
+
- **Examples are a gallery of their own.** A **My plots | Examples** switch above the list shows one or the other, never both. **Examples** draws one of each chart type from the lot, each marked as an example and not saved, with **Add to my plots**; **Add all** adds the ones that are missing and shows My plots, with an **Undo** that removes only what it added. Looking at the examples does not fill the reader's own list. It replaces **Add examples**, which saved all of them at once.
|
|
82
|
+
- **Cumulative on the Value histogram, By radius on the Test value distribution.** The histogram can be drawn as the cumulative curve of the same values (one curve per colour), and the box plot as a box for each ring from the centre to the edge, so a test that drifts across the wafer shows as a trend of boxes.
|
|
83
|
+
- **Within groups on the correlation matrix.** With Group by on, the matrix offers **Pooled | Within <field>**: within takes each group's mean off every test first, so a difference between groups is not read as a relationship between tests. The mixed-set warning points to it.
|
|
84
|
+
- **Tests by wafer.** A card at the top of Distributions: the twelve tests whose wafers (or groups) differ most, as a grid of z-scores, one row per test, so a block of wafers that moved together across several tests is visible without opening each test. Click a cell for its dies.
|
|
85
|
+
- **Ring and quadrant yield are one card each, with a View choice.** The heatmap by wafer (or group) and the pooled diagram of the same regions share one place in the Overview: **Heatmap | Diagram** in the card's header swaps them, so the Overview has two cards fewer.
|
|
86
|
+
- **Histograms of three or more colours are drawn as outlines.** Each colour is a step line over a faint fill, so overlapping groups no longer blend into one another and each one's shape can be read on its own; one or two colours keep their translucent bars.
|
|
87
|
+
- **The difference map is drawn on the signed scale.** Group A minus group B runs blue where A is lower, a light neutral at zero and orange where it is higher, as every other signed scale does. The scale is also listed as **Blue to orange, around zero** in a map's Value colours menu.
|
|
88
|
+
- **Every signed scale is warm above and blue below.** The correlation matrix draws a positive correlation in orange and a negative one in blue, as a z-score or a difference does, so one colour never means high on one chart and low on the next.
|
|
89
|
+
- **A sweep is a chart type of the plot editor.** **Sweep** sits with the other chart types: choosing it shows the series, title and axes form in Setup and the curve beside it, and choosing another type brings back the plot it was. The JSON tab and its suggestions edit a sweep like any plot. The Plot tab has one **+ New plot** (the separate **+ New sweep** button is gone), and **New sweep…** on a selection's menu opens the same window.
|
|
90
|
+
- **Plots files written with the names `mark` and `encoding`** (before `chart` and `fields`) are read as those plots.
|
|
91
|
+
- **Plot messages say what is wrong and what to do.** A chart or built-in field this version does not know names what it was given, lists what is valid and offers the nearest ("The chart "heatmaps" is not one this version draws (…). Did you mean "heatmap"?"); a field that is not a field says what one looks like; a wafer field no wafer has lists the lot's own and the nearest ("No wafer has a "Split" value. Did you mean "split"?"). A setting or field role this version does not use (`normalise`, `fields.colour`) is still kept, and the reader is now told it does nothing, with the nearest name. A test number written in quotes says to drop them. The JSON tab reports a syntax error with its line and column where the browser gives one, and says before Apply when a plot could not be drawn.
|
|
92
|
+
- **A plot whose test no longer matches the lot's says which is which.** "Test 1050 was "Leakage" when this plot was saved; in these dies it is "Vth". Choose the test again to plot "Vth"" replaces the shorter wording, in the plot, pass-rate and test-set checks alike.
|
|
93
|
+
|
|
94
|
+
### Added
|
|
95
|
+
|
|
96
|
+
- **The colours of a plot are a setting.** A heatmap, or a scatter coloured by a number, has **Colours** and **Reverse colours** in Customise (`colorGradient` and `colorReverse` in the JSON): blue to orange around zero, orange-red to blue for a rating, or any of the map's gradients (Viridis, Cividis, Plasma, Traffic…; Cividis is the colour-blind-safe one). Automatic is blue to orange for values rescaled around zero, orange-red to blue for a yield or pass rate, and the map's gradient for any other. Each heatmap cell's value is dark or white as its colour needs.
|
|
97
|
+
- **A JSON tab in the plot editor.** Beside Setup and Customise, it shows the plot as the JSON of a plots-file entry, which can be copied, edited or replaced by pasted text. **Apply** reads the text with the reader a plots file goes through, so a setting this version does not know is left out and named before it is applied, and text that is not a plot cannot be applied. Suggestions open as you type inside a key or a string, after a comma, brace, colon or bracket, and from the **Suggest** button or **Ctrl/Cmd+Space**: the plot's settings, a chart type, aggregate or other setting that takes a few words, a field's kind, a built-in field, the lot's wafer fields and its test numbers with their names, and accepting one is undone by Ctrl+Z; the words come from the table the reader checks a plot against, so a suggestion is never refused. **Discard edits** drops text not yet applied; changing a test's number leaves its old name out, since the name would no longer match; the window's own Reset and Cancel go back to the plot as it was when the window opened. **Ctrl/Cmd+Z** undoes the text first (typing, an accepted suggestion, a plot chosen from a pasted file, Discard edits) and then each Apply, and **Shift+Ctrl/Cmd+Z** (or **Ctrl/Cmd+Y**) redoes; the editor keeps this history itself, so it is the same in every browser. The text holds the plot without its id, and a plots file or a list of plots can be pasted, the tab listing the plots of a file that holds several to choose from.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
25
101
|
## [0.38.0] — 2026-10-28
|
|
26
102
|
|
|
27
103
|
### Breaking
|
|
@@ -1455,10 +1531,10 @@ under `### Breaking`.
|
|
|
1455
1531
|
|
|
1456
1532
|
- **Sweep x values from test names, an x unit, and a log x axis.** For a
|
|
1457
1533
|
program that records the swept quantity only in the test text — a
|
|
1458
|
-
resistance CDF named `
|
|
1534
|
+
resistance CDF named `Cum_share= LEVEL_12K / …`, one test per
|
|
1459
1535
|
threshold:
|
|
1460
1536
|
- `SweepSeriesSpec.xFromName` reads each test's x from its name with a
|
|
1461
|
-
placeholder pattern, `"
|
|
1537
|
+
placeholder pattern, `"LEVEL_{x}"`: `{x}` reads a number with its SI
|
|
1462
1538
|
prefix (`12K` → 12,000; case-sensitive, `K` accepted as kilo; a letter is a
|
|
1463
1539
|
prefix only alone or before a unit, so `12Kangaroos` reads 12; in an all-capitals
|
|
1464
1540
|
name the unit's case is gone, so `5NS` is 5 ns and `2MV` — milli or mega? — is
|
|
@@ -1693,7 +1769,7 @@ under `### Breaking`.
|
|
|
1693
1769
|
- **Docs and examples brought up to date with this release.** The developer
|
|
1694
1770
|
guide's sweep section no longer says `tests` has no range syntax or that a
|
|
1695
1771
|
sweep has no log option; it covers ranges, `xFromName`, `xUnit`, `xScale` and
|
|
1696
|
-
drilldown. The sweeps example adds a fifth sweep (
|
|
1772
|
+
drilldown. The sweeps example adds a fifth sweep (a resistance
|
|
1697
1773
|
distribution read from test names on a log axis) and gives the output-driver
|
|
1698
1774
|
sweep an x unit; the derived-tests example's sweep uses ranges and a real swept
|
|
1699
1775
|
quantity (pulse amplitude in volts) instead of ordinal steps, and places the †
|
package/README.md
CHANGED
|
@@ -5,16 +5,17 @@
|
|
|
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
|
-
[](https://github.com/sponsors/wafertools)
|
|
11
|
+
[](https://ko-fi.com/wafertools)
|
|
11
12
|
|
|
12
13
|
<img src="docs/images/hero-test-values.png" alt="wafermap demo" style="max-width:640px; display:block; margin:8px 0;" />
|
|
13
14
|
|
|
14
15
|
Browser-first wafer map visualisation for semiconductor test data.
|
|
15
16
|
|
|
16
17
|
**Zero runtime dependencies.** Pure ES modules with TypeScript types — works in React,
|
|
17
|
-
Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~
|
|
18
|
+
Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~85 kB
|
|
18
19
|
min+gz; the interactive renderer is larger, and its chart suite and in-app guide are
|
|
19
20
|
loaded on demand rather than shipped up front — [measured sizes](docs/performance.md).
|
|
20
21
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value among its peers, as a shade: `fraction` is its deviation from their average over the largest deviation among
|
|
3
|
+
* them, from −1 to 1. Blue below, warm above, stronger the further it is, nothing at the average.
|
|
4
|
+
*/
|
|
5
|
+
export declare function signedShade(fraction: number): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The shade of each value among the others of its set, by `signedShade`: the deviation from the set's mean over the
|
|
8
|
+
* set's largest deviation. A set of one, or of equal values, has no shade, and neither has a set whose values print the
|
|
9
|
+
* same (`show`) or differ by under 1% of their mean: a colour must not tell apart numbers the table shows as one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function shadesAmong(values: readonly number[], show?: (v: number) => string): Array<string | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* A yield's shortfall below its reference, in points (yield minus reference, so negative is short), tinted by the summary
|
|
14
|
+
* report's rule: a point or more short is light, two medium, four strong; nothing at or above the reference.
|
|
15
|
+
*/
|
|
16
|
+
export declare function shortfallShade(points: number | null | undefined): string | undefined;
|
|
17
|
+
/** A Ppk as capable (1.33 and over), marginal (1.0 and over) or poor, in the capability chart's colours. */
|
|
18
|
+
export declare function capabilityShade(ppk: number | null | undefined): string | undefined;
|
|
19
|
+
/** A value outside its limits, in the warm hue. */
|
|
20
|
+
export declare function outOfLimitsShade(): string;
|
|
21
|
+
//# sourceMappingURL=cellShade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SIGNED_HIGH as o,SIGNED_LOW as s,capabilityColor as c}from"./charts/palette.js";import{NEGLIGIBLE_SPREAD as h,maxOf as d,minOf as l}from"../core/utils.js";import{shortfallColor as p,shortfallStep as b}from"../stats/presentation.js";const f=n=>[parseInt(n.slice(1,3),16),parseInt(n.slice(3,5),16),parseInt(n.slice(5,7),16)],a=([n,e,t],r)=>`rgba(${Math.round(n)}, ${Math.round(e)}, ${Math.round(t)}, ${r.toFixed(2)})`,S=.42,x=.05;export function signedShade(n){if(!Number.isFinite(n))return;const e=Math.max(-1,Math.min(1,n));if(!(Math.abs(e)<x))return a(f(e<0?s:o),S*Math.abs(e))}export function shadesAmong(n,e){const t=n.filter(Number.isFinite);if(t.length<2)return n.map(()=>{});if(e&&new Set(t.map(e)).size<2)return n.map(()=>{});const r=t.reduce((i,m)=>i+m,0)/t.length,u=d(t.map(i=>Math.abs(i-r)));return u>0?r!==0&&(d(t)-l(t))/Math.abs(r)<h?n.map(()=>{}):n.map(i=>signedShade((i-r)/u)):n.map(()=>{})}export function shortfallShade(n){if(n==null||!Number.isFinite(n))return;const e=b(n);return e?p(e):void 0}export function capabilityShade(n){if(!(n==null||!Number.isFinite(n)))return a(f(c(n)),.3)}export function outOfLimitsShade(){return a(f(o),.3)}
|
|
@@ -345,6 +345,15 @@ export interface SeriesLegendItem {
|
|
|
345
345
|
*/
|
|
346
346
|
export declare function makeSeriesLegendItem(label: string, color: string, ownerDocument?: Document): SeriesLegendItem;
|
|
347
347
|
export declare function cardFrameStyle(): Partial<CSSStyleDeclaration>;
|
|
348
|
+
/**
|
|
349
|
+
* Two cards that are two views of one idea (a heatmap and a diagram of the same regions) as one place in the grid: a
|
|
350
|
+
* View choice in each card's header shows one and hides the other. Each stays a whole card, so its menu, About line and
|
|
351
|
+
* Expand are its own; the first is shown to begin with.
|
|
352
|
+
*/
|
|
353
|
+
export declare function pairCards(views: Array<{
|
|
354
|
+
label: string;
|
|
355
|
+
card: HTMLElement;
|
|
356
|
+
}>, ownerDocument?: Document): HTMLElement;
|
|
348
357
|
export declare function cardShell(title: string, onSaveImage?: SaveImageHandler, ownerDocument?: Document, opts?: CardShellOptions): CardShell;
|
|
349
358
|
/**
|
|
350
359
|
* "How to read this: *Control charts* in the user guide" (no full stop), the title a link that opens the guide at that
|
|
@@ -361,7 +370,9 @@ export declare function makeSegmented(
|
|
|
361
370
|
options: Array<[value: string, label: string, hint?: string]>, current: string, onChange: (value: string) => void, ownerDocument?: Document,
|
|
362
371
|
/** Smaller type/padding for the summary panel's 260px column, where the
|
|
363
372
|
* chart-card sizing overflows a section header. Charts keep the default. */
|
|
364
|
-
compact?: boolean): HTMLElement
|
|
373
|
+
compact?: boolean): HTMLElement & {
|
|
374
|
+
setValue(value: string): void;
|
|
375
|
+
};
|
|
365
376
|
/**
|
|
366
377
|
* A table that lists its first `first` rows, with a button to list every one and back. Listed in full it scrolls inside
|
|
367
378
|
* `scroller` after `ALL_ROWS_MAX_PX`, so a lot of a hundred wafers is a scrolling table in a card of the usual size,
|
|
@@ -544,10 +555,15 @@ export declare function makeWaferSelect(items: readonly WaferSelectItem[], selec
|
|
|
544
555
|
value: string;
|
|
545
556
|
};
|
|
546
557
|
export declare function makeToggle(labelText: string, checked: boolean, onChange: (v: boolean) => void, ownerDocument?: Document, hint?: string): HTMLLabelElement;
|
|
547
|
-
export declare function makeLabeledSelect(labelText: string,
|
|
558
|
+
export declare function makeLabeledSelect(labelText: string,
|
|
559
|
+
/** A getter is read each time the list opens (see `makeListSelect`). */
|
|
560
|
+
options: readonly {
|
|
561
|
+
value: string;
|
|
562
|
+
label: string;
|
|
563
|
+
}[] | (() => readonly {
|
|
548
564
|
value: string;
|
|
549
565
|
label: string;
|
|
550
|
-
}[], selected: string, onChange: (value: string) => void,
|
|
566
|
+
}[]), selected: string, onChange: (value: string) => void,
|
|
551
567
|
/** `hint` is the hover tooltip over the label and its trigger, for a control whose name alone does not say what it does. */
|
|
552
568
|
opts?: {
|
|
553
569
|
maxWidth?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SHADOW as te,LEADING as me,wireTooltip as z,wireControlHover as P,controlStyle as X,SPACE as C,RADIUS as B,fontPx as q,FONT as E,CLR as g,Z_BASE as he,menuLayerFor as ge,wireListNavigation as be,MENU_SEARCH_THRESHOLD as ne,makeMenuSearchBox as xe,markMenuTrigger as V,markNoPrint as G,openCommandMenu as ye,saveImageBlob as we,openReparentedModal as Ce}from"../toolbar.js";import{ICONS as oe}from"../icons.js";import{openGuideAt as ve}from"../guideWindow.js";import{minOf as Se,maxOf as ke}from"../../core/utils.js";import{robustFence as ie}from"../../stats/math.js";import{fmt as Ae,fmtColorbarAxis as Le,nameStatesUnit as Ee}from"../../renderer/fmt.js";import{isTestPinned as $e,toggleTestPinned as Be}from"../pinnedTests.js";import{markedTestLabel as Te,DERIVED_LANE_PAD as Oe}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,t={}){for(const a of e.querySelectorAll('div[style*="position: absolute"]'))a.style.display==="block"&&a.style.pointerEvents==="none"&&(a.style.display="none");const i=e.getAttribute("style")??"",n=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const r=e.querySelector(":scope > div > [data-wmap-card-expand]"),l=a=>{r&&(r.style.display=a?"flex":"none")};l(!1);const s=Ce([e],{title:o,anchor:t.anchor,ownerDocument:e.ownerDocument,boxSize:Re[n],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),t.onClosed?.()}});if(!s)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),null;if(n==="rows"){const a=()=>{const c=Number(e.dataset.wmapChartFullH);if(!c)return;const d=s.box.offsetHeight-s.contentWrap.clientHeight;s.setNaturalHeight(`min(90vh, ${Math.ceil(d+c)}px)`)};a(),(e.ownerDocument.defaultView??window).requestAnimationFrame(a)}return s}const Re={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 t=e.trim();let i,n,r,l=1;const s=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const c=s[1].length===3?s[1].split("").map(d=>d+d).join(""):s[1];[i,n,r]=[0,2,4].map(d=>parseInt(c.slice(d,d+2),16)),c.length===8&&(l=parseInt(c.slice(6,8),16)/255)}else if(a)[i,n,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(${i}, ${n}, ${r}, ${+(l*o).toFixed(3)})`}const Pe={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309",alert:"#7a1c1c"},re={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text",alert:"err-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),t={};for(const i of Object.keys(re)){const n=o.getPropertyValue(`--wmap-${re[i]}`).trim();t[i]=n||Pe[i]}return t.grid=withAlpha(t.border,GRID_ALPHA),t}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const t=e.ownerDocument.defaultView??window;let i=0;const n=new t.ResizeObserver(()=>{i||(i=t.requestAnimationFrame(()=>{i=0,o()}))});return n.observe(e),{disconnect:()=>{i&&t.cancelAnimationFrame(i),i=0,n.disconnect()}}}export function growCardToFitContent(e,o,t){const i=`${K(e,o)+t}px`;e.style.minHeight!==i&&(e.style.minHeight=i)}function K(e,o){const t=e.ownerDocument.defaultView??window,i=t.getComputedStyle(e);let n=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=t.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(n+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return i.boxSizing==="border-box"&&(n+=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0)),n}function le(e,o){const t=e.ownerDocument.defaultView??window;let i=0;for(const n of Array.from(e.children)){if(n===o)continue;const r=n,l=t.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(i+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return i}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,t){const i=e.toLocaleString(),n=e===1?"die":"dies";return t?e===o?`${i} ${n} ${t}`:`${i} of ${o.toLocaleString()} dies ${t} (partial and edge-excluded dies left out)`:`${i} ${n}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,t){const n=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(n.paddingTop)||0)-(parseFloat(n.paddingBottom)||0),l=n.boxSizing==="border-box"?(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0):0;return r-(K(e,o)-l)-(t?le(o,t):0)}export function fitRowsHeight(e,o,t,i,n=0){if(growCardToFitContent(e,o,n+t),e.dataset.wmapChartFullH=String(Math.ceil(K(e,o)+n+i)),!isExpandedCard(e))return t;const r=bodyRoom(e,o)-n;return Math.max(t,Math.min(i,Math.floor(r)))}export function chartFillHeight(e,o,t,i){const n=le(o,t);return growCardToFitContent(e,o,n+i),Math.max(i,o.clientHeight-n)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,t,i){const n=chartDpr(e);e.width=Math.max(1,Math.floor(t*n)),e.height=Math.max(1,Math.floor(i*n)),e.style.width=`${t}px`,e.style.height=`${i}px`;const r=e.getContext("2d");return r?(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,t,i),r.font=`${q(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let t;if(typeof o=="number")t=o;else{const i=(o.ownerDocument.defaultView??window).getComputedStyle(o);t=o.offsetTop+o.offsetHeight+(parseFloat(i.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${t}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:Ae(e,void 0,"engineering"):"\u2014"}function Me(e,o){const t=`${o} (`;return e.startsWith(t)&&e.endsWith(")")?e.slice(t.length,-1):""}export function makeAxisFormat(e,o,t,i){if(!o&&t===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const n=Ee(i,o),{tickFmt:r,axisLabel:l,scaledUnit:s}=Le(e,n?i:null,o,"engineering",t);return{tick:r,tickWithUnit:s?a=>`${r(a)} ${s}`:r,unitLabel:n?Me(l,i):l}}const Ie=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,t){return(i,n)=>{const r=makeAxisFormat(o,t,i).tick;return n.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+Ie}}export function drawAxisUnit(e,o,t,i,n){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${q(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=n,e.fillText(`(${o})`,t,i),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 U=(e,o)=>{for(let t=e;t&&t!==o.parentElement;t=t.parentElement)if(t.style.display==="none")return!1;return!0},Fe=/\s*[▾▼]\s*$/,Y=new WeakMap;export function describeCard(e){const o=[],t=e.querySelector("[data-wmap-controls]");if(t){for(const l of t.querySelectorAll("button[aria-haspopup]")){if(!U(l,t))continue;const s=(l.textContent??"").replace(Fe,"").trim();if(!s)continue;const a=l.closest("label"),d=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(d&&d!==s?`${d}: ${s}`:s)}for(const l of t.querySelectorAll('[role="radiogroup"]')){if(!U(l,t))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of t.querySelectorAll('input[type="checkbox"]:checked')){if(!U(l,t))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const i=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!U(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&i.push(s)}const n=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}const r=Y.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(i.length=0,i.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(n.length=0,n.push(...r.legend))),{controls:o,captions:i,legend:n}}function De(e){const o=describeCard(e),t=Y.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:t?.colorbar}}function se(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const t=o.querySelector(":scope > [data-wmap-print-only]");if(!t)continue;const i=describeCard(o);t.replaceChildren();const n=[i.controls.length?i.controls.join(" \xB7 "):"",...i.captions].filter(Boolean);for(const r of n){const l=e.createElement("div");l.textContent=r,t.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ae=new WeakSet;function He(e){if(ae.has(e))return;ae.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const t=e.defaultView;t?.addEventListener("beforeprint",()=>se(e));try{t?.matchMedia?.("print").addEventListener?.("change",i=>{i.matches&&se(e)})}catch{}}function je(e){const o=e.ownerDocument.defaultView;for(let t=e;t&&o;t=t.parentElement){const i=o.getComputedStyle(t).backgroundColor;if(i&&i!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(i))return i}return"#ffffff"}export function composeChartPng(e,o){const t=e.ownerDocument,i=t.createElement("canvas"),n=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=t.createElement("canvas").getContext("2d"),s=12*n,a=(m,f="400")=>`${f} ${m*n}px system-ui, -apple-system, "Segoe UI", sans-serif`,c=(m,f)=>l?(l.font=f,l.measureText(m).width):m.length*7*n,d=[];let p=0;if(o){p=s,d.push({kind:"text",text:o.title,x:s,y:p+14*n,font:a(16,"600"),alpha:1}),p+=24*n;const m=o.decor,f=[];m?.controls?.length&&f.push({text:m.controls.join(" \xB7 "),alpha:1});for(const w of m?.caption===void 0?[]:typeof m.caption=="string"?[m.caption]:m.caption)f.push({text:w,alpha:.75});const x=a(12);for(const{text:w,alpha:y}of f){let h="";for(const k of w.split(" ")){const T=h?`${h} ${k}`:k;h&&c(T,x)>r-2*s?(d.push({kind:"text",text:h,x:s,y:p+11*n,font:x,alpha:y}),p+=17*n,h=k):h=T}h&&(d.push({kind:"text",text:h,x:s,y:p+11*n,font:x,alpha:y}),p+=17*n)}if(m?.legend?.length){p+=4*n;const w=a(12);let y=s;for(const h of m.legend){const k=14*n+c(h.label,w)+14*n;y>s&&y+k>r-s&&(y=s,p+=18*n),d.push({kind:"dot",x:y+5*n,y:p+7*n,r:5*n,color:h.color}),d.push({kind:"text",text:h.label,x:y+14*n,y:p+11*n,font:w,alpha:1}),y+=k}p+=20*n}if(m?.colorbar){p+=4*n;const w=a(12),y=m.colorbar;let h=s;d.push({kind:"text",text:y.label,x:h,y:p+10*n,font:w,alpha:1}),h+=c(y.label,w)+10*n,d.push({kind:"text",text:y.lo,x:h,y:p+10*n,font:w,alpha:.75}),h+=c(y.lo,w)+6*n,d.push({kind:"strip",x:h,y:p+1*n,w:200*n,h:10*n,color:y.color}),h+=206*n,d.push({kind:"text",text:y.hi,x:h,y:p+10*n,font:w,alpha:.75}),p+=20*n}p+=6*n}i.width=r,i.height=Math.ceil(e.height+p);const u=i.getContext("2d");if(u.fillStyle=o?je(o.card):"#ffffff",u.fillRect(0,0,i.width,i.height),o){const m=t.defaultView,f=m&&m.getComputedStyle(o.card).color||"#222222";u.textBaseline="alphabetic";for(const x of d)if(x.kind==="text")u.font=x.font,u.fillStyle=f,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 w=0;w<x.w;w++)u.fillStyle=x.color(w/Math.max(1,x.w-1)),u.fillRect(x.x+w,x.y,1,x.h)}return u.drawImage(e,0,p),i}export function saveCanvasPng(e,o,t,i){composeChartPng(e,i).toBlob(n=>{n&&we(n,o,t)},"image/png")}const ce="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${ce}`,`height:${ce}`,`border-radius:${B.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Ne="0.35";export function makeSeriesLegendItem(e,o,t=document){const i=t.createElement("button");i.type="button",Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:C.xs,padding:`${C.xs} ${C.md}`,borderRadius:B.pill,border:`1px solid ${g.menuBorder}`,background:"none",cursor:"pointer",fontSize:E.body,color:g.text,whiteSpace:"nowrap"}),P(i,"bare");const n=t.createElement("span");return n.style.cssText=chartSwatchCss(o),i.append(n,t.createTextNode(e)),{el:i,setState({selected:r,dimmed:l}){i.style.borderColor=r?g.iconActive:g.menuBorder,i.style.fontWeight=r?"600":"400",i.style.opacity=l?Ne:"1",i.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:B.container,padding:C.xl,fontVariantNumeric:"tabular-nums"}}function de(e){Object.assign(e.style,{...X("outlined"),color:g.label,padding:"0",width:"22px",height:"22px",lineHeight:me.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),P(e)}export function cardShell(e,o,t=document,i={}){const n=t.createElement("div");n.dataset.wmapChartCard="1",n.dataset.wmapChartTitle=e,Object.assign(n.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const r=n.ownerDocument.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:C.sm,paddingBottom:"6px",marginBottom:C.md,borderBottom:`1px solid ${g.menuBorder}`});const l=n.ownerDocument.createElement("div");l.textContent=e,Object.assign(l.style,{color:g.value,fontSize:E.heading,fontWeight:"600",flex:"1"}),r.appendChild(l);const s=makeTooltip(n),a=n.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=oe.expand,a.dataset.wmapCardExpand="1",de(a),attachChartTip(a,n,s,"Expand"),G(a),a.addEventListener("click",()=>{isExpandedCard(n)||openChartExpandModal(n,l.textContent??e)}),r.appendChild(a);const c=n.ownerDocument.createElement("button");c.type="button",c.setAttribute("aria-label","Chart actions"),c.innerHTML=oe.more,c.dataset.wmapCardMenu="1",de(c),attachChartTip(c,n,s,"Chart actions"),V(c,!1),G(c),r.appendChild(c);const d=n.ownerDocument.createElement("div");d.dataset.wmapCardAbout="1",d.setAttribute("role","note"),Object.assign(d.style,{display:"none",color:g.label,fontSize:E.body,marginBottom:C.md}),G(d);let p;const u=v=>{d.textContent=v?p?.text??"":"",d.style.display=v?"":"none"};let m,f;const x=()=>{const v=m?m():n.querySelector("canvas");v&&saveCanvasPng(v,l.textContent||e,o,{card:n,title:l.textContent||e,decor:De(n)})},w=()=>{const v=[],H=(S,j,N)=>({label:S,active:!1,action:!0,enabled:!N,disabledHint:N,onClick:()=>{y?.(),j()}});i.png!==!1&&(m||n.querySelector("canvas"))&&v.push(H("Save as PNG",x));for(const S of f?.()??[])v.push(H(S.label,S.onClick,S.disabledHint));if(p){const S=d.style.display!=="none";v.push({label:`About this ${p.noun}`,active:S,onClick:()=>{y?.(),u(!S)}})}return v};let y;c.addEventListener("click",()=>{if(c.getAttribute("aria-expanded")==="true"){y?.();return}const v=w();v.length!==0&&(y=ye(c.getBoundingClientRect(),c,v,`${l.textContent||e}: chart actions`,{trigger:c,hook:"wmapCardMenuList"}))}),n.appendChild(r),n.appendChild(d);const h=n.ownerDocument.createElement("div");h.dataset.wmapPrintOnly="1",Object.assign(h.style,{display:"none",color:g.label,fontSize:E.body,marginBottom:C.sm}),n.appendChild(h),He(n.ownerDocument);const k=n.ownerDocument.createElement("div");k.dataset.wmapControls="1",Object.assign(k.style,{display:"flex",gap:C.sm,marginBottom:C.md,flexWrap:"wrap",alignItems:"center"}),G(k),n.appendChild(k);const T=n.ownerDocument.createElement("div");return Object.assign(T.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),n.appendChild(T),{card:n,heading:l,controlsRow:k,body:T,setPngDecor:v=>{Y.set(n,v)},setPngCanvas:v=>{m=v},setAbout:v=>{p=v,u(!!v&&d.style.display!=="none")},setMenuRows:v=>{f=v}}}export function guideCite(e,o,t="How to read this"){const i=e.createElement("span");return i.append(`${t}: `,pe(e,o)," in the user guide"),i}function pe(e,o){const t=e.createElement("button");return t.type="button",t.textContent=o.title,t.dataset.wmapGuideLink=o.id,Object.assign(t.style,{border:"none",background:"none",padding:"0",font:"inherit",color:g.iconActive,textDecoration:"underline",cursor:"pointer"}),P(t),t.addEventListener("click",()=>ve(o.id,t)),t}export function appendGuideCites(e,o){if(o.length===0)return;const t=e.ownerDocument;e.append(" \xB7 how to read this: "),o.forEach((i,n)=>{n>0&&e.append(n===o.length-1?" and ":", "),e.append(pe(t,i))}),e.append(" in the user guide")}export function inputStyle(){return{background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,padding:`${C.xs} ${C.sm}`,fontSize:E.body,fontFamily:E.family,boxSizing:"border-box",minWidth:"0"}}export function makeSegmented(e,o,t,i=document,n=!1){const r=i.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",flexWrap:"wrap",maxWidth:"100%",padding:"1px 0 0 1px"});const l=e.length-1,s=`seg-${Math.random().toString(36).slice(2,9)}`,a=[];return e.forEach(([c,d,p],u)=>{const m=i.createElement("label");p&&z(m,p),Object.assign(m.style,{display:"inline-flex",alignItems:"center",fontSize:E.body,padding:n?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",border:`1px solid ${g.menuBorder}`,margin:"-1px 0 0 -1px",borderTopLeftRadius:u===0?B.control:"0",borderBottomLeftRadius:u===0?B.control:"0",borderTopRightRadius:u===l?B.control:"0",borderBottomRightRadius:u===l?B.control:"0"}),P(m,"bare");const f=i.createElement("input");f.type="radio",f.name=s,f.value=c,f.checked=c===o,Object.assign(f.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const x=()=>{m.style.background=f.checked?g.bgActive:g.menuBg,m.style.color=f.checked?g.iconActive:g.text,m.dataset.on=f.checked?"true":"false"};a.push(x),x(),f.addEventListener("change",()=>{if(f.checked){for(const w of a)w();t(c)}}),m.append(f,i.createTextNode(d)),r.appendChild(m)}),r}const We=360;export function firstRowsToggle(e,o){let t=!1;const i=e.createElement("button");i.type="button",Object.assign(i.style,{...X("outlined"),marginTop:C.sm}),P(i);const n=()=>{o.fill(t),Object.assign(o.scroller.style,{maxHeight:t?`${We}px`:"",overflowY:t?"auto":""}),i.textContent=t?`Show the first ${o.noun}`:`Show all ${o.total} ${o.noun}`,i.style.display=o.total>o.first?"":"none"};return i.addEventListener("click",()=>{t=!t,n()}),n(),i}export function makeBackButton(e,o=document){const t=o.createElement("button");return t.type="button",t.textContent="\u2190 Back",Object.assign(t.style,{...X("outlined"),background:g.menuBg,color:g.label}),P(t),t.addEventListener("click",e),t}export function renderEmptyState(e,o,t){const i=e.ownerDocument.createElement("div");i.textContent=o,Object.assign(i.style,{color:g.label,fontSize:E.body,padding:"8px 0"}),t&&Object.assign(i.style,t),e.appendChild(i)}export function makeListSelect(e,o,t,i={}){const{maxWidth:n="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:c}=i,d=()=>typeof e=="function"?e():e;let p=d(),u=o;const m=S=>p.find(j=>j.value===S)?.label??"",f=r.createElement("button");f.type="button",c&&(f.dataset.wmapSelect=c),l&&f.setAttribute("aria-label",l),Object.assign(f.style,{fontSize:E.body,padding:`${C.xxs} ${C.sm}`,background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,maxWidth:n,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:C.sm,justifyContent:"space-between"}),P(f),V(f,!1);const x=r.createElement("span");Object.assign(x.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const w=r.createElement("span");w.textContent="\u25BE",w.style.flex="0 0 auto",f.append(x,w);const y=()=>{x.textContent=p.length===0?s??"(none)":m(u)||s||"(none)"};if(y(),p.length===0)return f.disabled=!0,f.style.opacity="0.6",f.style.cursor="default",Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}});let h=null;const k=()=>{h&&(h.remove(),h=null,V(f,!1))},T=()=>{k(),f.focus()};function v(){p=d();const S=f.getBoundingClientRect(),j=r.defaultView??window,N=Math.max(S.width,220),ue=Math.min(S.left,Math.max(4,(j.innerWidth??1/0)-N-4));h=r.createElement("div"),h.setAttribute("role","listbox"),h.setAttribute("aria-label",l??"Options"),Object.assign(h.style,{position:"fixed",top:`${S.bottom+4}px`,left:`${ue}px`,background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,boxShadow:te.menu,zIndex:he,minWidth:`${N}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const M=[],_=()=>M.filter(b=>b.row.style.display!=="none").map(b=>b.row),W=[],fe=()=>{for(const b of W)b.el.style.display=M.slice(b.first,b.last+1).some(L=>L.row.style.display!=="none")?"":"none"};if(p.length>ne){const b=xe(L=>{for(const A of M)A.row.style.display=A.label.includes(L)?"":"none";fe()},a,r,_);Object.assign(b.style,{position:"sticky",top:"0",zIndex:"1",background:g.menuBg}),b.addEventListener("keydown",L=>{if(L.key==="Escape"){L.preventDefault(),T();return}L.key==="ArrowDown"&&(L.preventDefault(),_()[0]?.focus())}),h.appendChild(b)}let Z;for(const b of p){if(b.group!==void 0&&b.group!==Z){const $=r.createElement("div");$.textContent=b.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${C.sm} ${C.xl} ${C.xxs}`,fontSize:E.sub,color:g.label,fontWeight:"600"}),h.appendChild($),W.push({el:$,first:M.length,last:M.length})}Z=b.group;const L=b.value===u,A=r.createElement("div"),J=r.createElement("span");if(J.textContent=b.disabled?`${b.label} \u2014 ${b.disabled}`:b.label,A.appendChild(J),A.setAttribute("role","option"),A.setAttribute("aria-selected",L?"true":"false"),b.disabled&&A.setAttribute("aria-disabled","true"),A.tabIndex=-1,Object.assign(A.style,{padding:`${C.sm} ${C.xl}`,fontSize:E.body,cursor:b.disabled?"default":"pointer",color:b.disabled?g.label:L?g.iconActive:g.text,fontWeight:L?"700":"400",opacity:b.disabled?"0.7":"",background:L?g.menuActive:"transparent",whiteSpace:"nowrap",...b.pin?{display:"flex",alignItems:"center",justifyContent:"space-between",gap:C.xl}:{}}),b.pin){const $=b.pin;A.setAttribute("aria-keyshortcuts","P");const O=r.createElement("span"),Q="http://www.w3.org/2000/svg",I=r.createElementNS(Q,"svg");I.setAttribute("viewBox","0 0 24 24"),I.setAttribute("width","14"),I.setAttribute("height","14"),I.setAttribute("aria-hidden","true");const F=r.createElementNS(Q,"path");F.setAttribute("d","M12 2.5l2.9 6.2 6.8.8-5 4.7 1.3 6.7L12 17.5 6 20.9l1.3-6.7-5-4.7 6.8-.8z"),F.setAttribute("fill",$.pinned?"currentColor":"none"),F.setAttribute("stroke","currentColor"),F.setAttribute("stroke-width","2"),F.setAttribute("stroke-linejoin","round"),I.appendChild(F),O.appendChild(I),O.dataset.wmapPin=$.pinned?"pinned":"unpinned",O.setAttribute("role","button"),O.setAttribute("aria-label",`${$.pinned?"Unpin":"Pin"} ${b.label} (or press P on the row)`),Object.assign(O.style,{cursor:"pointer",color:$.pinned?g.iconActive:g.label,flex:"0 0 auto",padding:`0 ${C.xs}`,display:"inline-flex",alignItems:"center"}),P(O,"bare"),z(O,$.pinned?"Unpin this test":"Pin this test to the top of every test list");const ee=R=>{R.preventDefault(),R.stopPropagation(),k(),$.toggle(),v()};O.addEventListener("click",ee),A.addEventListener("keydown",R=>{(R.key==="p"||R.key==="P")&&!R.ctrlKey&&!R.metaKey&&!R.altKey&&ee(R)}),A.appendChild(O)}A.addEventListener("mouseenter",()=>{!L&&!b.disabled&&(A.style.background=g.menuHover)}),A.addEventListener("mouseleave",()=>{L||(A.style.background="transparent")}),A.addEventListener("click",$=>{$.stopPropagation(),!b.disabled&&(u=b.value,y(),T(),t(b.value))}),h.appendChild(A),M.push({row:A,label:b.label.toLowerCase()}),W.length&&(W[W.length-1].last=M.length-1)}if(be(h,_,T),ge(f).appendChild(h),V(f,!0),p.length<=ne){const b=p.findIndex(L=>L.value===u);_()[b>=0?b:0]?.focus()}}f.addEventListener("click",S=>{if(S.stopPropagation(),h){k();return}v()});const H=S=>{if(!f.isConnected){r.removeEventListener("click",H);return}h&&!h.contains(S.target)&&!f.contains(S.target)&&k()};return r.addEventListener("click",H),Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}})}export function testOptionLabels(e){const o=e.some(t=>t.derived);return e.map(t=>(o&&!t.derived?Oe:"")+Te(t,t.testNumber))}export function makeTestSelect(e,o,t,i={}){const{maxWidth:n="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=i,s=testOptionLabels(e);return makeListSelect(()=>{const c=e.map((u,m)=>({item:u,label:s[m],pinned:$e(u.testNumber)})),d=c.some(u=>u.pinned),p=(u,m)=>({value:String(u.item.testNumber),label:u.label,...m?{group:m}:{},pin:{pinned:u.pinned,toggle:()=>Be(u.item.testNumber)}});return d?[...c.filter(u=>u.pinned).map(u=>p(u,"Pinned")),...c.filter(u=>!u.pinned).map(u=>p(u,"All tests"))]:c.map(u=>p(u))},o!==null?String(o):"",c=>t(Number(c)),{maxWidth:n,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,t,i=document){let n=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>t({includeLimits:n,clipOutliers:r,limits:l});return{get:()=>({includeLimits:n,clipOutliers:r,limits:l}),sync(a,c,d=!1){e.innerHTML="",d&&e.appendChild(makeLimitsSelect(l,p=>{l=p,s()},i)),c&&e.appendChild(makeToggle("Axis includes limits",a,p=>{n=p,s()},i,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,p=>{r=p,s()},i,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const c=a.limits??"both";return a.includeLimits===n&&a.clipOutliers===r&&c===l?!1:(n=a.includeLimits,r=a.clipOutliers,l=c,!0)}}}export function makeLinkedTestSelect(e,o,t,i={}){let n=o;const r=makeTestSelect(e,n,l=>{l!==n&&(n=l,t(l))},i);return{el:r,get:()=>n,set(l){return n===l||!e.some(s=>s.testNumber===l)?!1:(n=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,t,i,n={}){let r=t;const l=d=>d??ALL_GROUPS,s=d=>d===ALL_GROUPS?null:d,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(d=>({value:d,label:d}))],l(r),d=>{const p=s(d);p!==r&&(r=p,i(p))},{...n,hook:"group-scope"}),c=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(d){return r===d||d!==null&&!e.includes(d)?!1:(r=d,c&&(c.value=l(d)),!0)}}}export function makeWaferSelect(e,o,t,i={}){const{maxWidth:n="160px",allLabel:r="All wafers",ownerDocument:l=document}=i,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,c)=>({value:String(c),label:a.label??`#${c}`}))],o===null?s:String(o),a=>t(a===s?null:Number(a)),{maxWidth:n,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,t,i=document,n){const r=i.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:C.xs,fontSize:E.body,color:g.label,cursor:"pointer",userSelect:"none"}),P(r,"bare");const l=i.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>t(l.checked)),r.append(l,i.createTextNode(e)),n&&z(r,n),r}export function makeLabeledSelect(e,o,t,i,n={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document,hint:a}=n,c=s.createElement("label");c.textContent=e,Object.assign(c.style,{color:g.label,fontSize:E.body,display:"flex",alignItems:"center",gap:C.xs});const d=makeListSelect(o,t,i,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return c.appendChild(d),a&&z(c,a),c}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(var(--wmap-insights-cols, auto-fit), minmax(var(--wmap-insights-min, 420px), 1fr))",gap:C.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:B.control,padding:`${C.sm} ${C.xl}`,fontSize:E.sub,fontFamily:E.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:te.menu}),e.appendChild(o),o}export function attachChartTip(e,o,t,i){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=i),e.addEventListener("mouseenter",n=>{t.textContent=i,t.style.display="block",positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mousemove",n=>{t.style.display==="block"&&positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{t.style.display="none"}),e.addEventListener("click",()=>{t.style.display="none"}),e.addEventListener("focus",()=>{t.textContent=i,t.style.display="block";const n=e.getBoundingClientRect();positionChartTooltip(t,o,n.left+n.width/2,n.bottom)}),e.addEventListener("blur",()=>{t.style.display="none"})}export function positionChartTooltip(e,o,t,i){const n=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let c=t-n.left+r,d=i-n.top+r;c+s+l>n.width&&(c=t-n.left-r-s),d+a+l>n.height&&(d=i-n.top-r-a),c=Math.max(l,c),d=Math.max(l,d),e.style.left=`${c}px`,e.style.top=`${d}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"},pat:{lo:"PAT lo",hi:"PAT hi"},whatif:{lo:"What-if lo",hi:"What-if hi"},ref:{lo:"",hi:""}},LIMIT_DASH={test:[3,3],spec:[10,4],pat:[1,3],whatif:[8,3,2,3],ref:[6,2,1,2]},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 D(e,o){const[t,i]=o==="test"?[e?.limitLow,e?.limitHigh]:o==="spec"?[e?.specLow,e?.specHigh]:o==="pat"?[e?.patLow,e?.patHigh]:o==="whatif"?[e?.whatIfLow,e?.whatIfHigh]:[void 0,void 0],n=[];return t!==void 0&&Number.isFinite(t)&&n.push({value:t,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),i!==void 0&&Number.isFinite(i)&&n.push({value:i,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),n}export function hasBothLimitKinds(e){return D(e,"test").length>0&&D(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const t=D(e,"test"),i=D(e,"spec"),n=o==="test"?t:o==="spec"?i:[...t,...i];return[...n.length?n:[...t,...i],...D(e,"pat"),...D(e,"whatif")]}export function limitExtent(e){if(!e.length)return{};const o=e.map(t=>t.value);return{lo:Se(o),hi:ke(o)}}export function placeClearOf(e,o,t,i=6){const n=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<i&&n(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+t,y1:r.y1+t};return e.push(r),r}export function stackLabelRows(e,o=4){const t=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),i=[],n=new Array(e.length).fill(0);for(const r of t){let l=i.findIndex(s=>r.start>=s+o);l===-1?(l=i.length,i.push(r.end)):i[l]=r.end,n[r.i]=l}return n}export function fillTextOnHalo(e,o,t,i,n){if(n){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=n,e.fillRect(t-r.actualBoundingBoxLeft-l,i-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,t,i)}export function strokeLimitLine(e,o,t,i,n,r,l){e.save(),e.strokeStyle=t,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(i,n),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,t=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,i=>o(i),{maxWidth:"170px",hook:"limits-shown",ownerDocument:t})}export{ie as robustFence};export function shouldIncludeLimitsByDefault(e,o,t,i,n=1/3){if(t===void 0&&i===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,t??e),s=Math.max(o,i??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=n}export function resolveAxisRange(e){const{dataMin:o,dataMax:t,limits:i=[],includeLimits:n,clipOutliers:r,values:l}=e;let s=o,a=t,c=0;if(r&&l?.length){const p=ie(l);if(p){const u=Math.max(s,p.lo),m=Math.min(a,p.hi);m>u&&(c=l.filter(f=>Number.isFinite(f)&&(f<u||f>m)).length,s=u,a=m)}}if(n)for(const p of i)s=Math.min(s,p.value),a=Math.max(a,p.value);s===a&&(s-=1,a+=1);const d=[];for(const p of i)p.value<s?d.push({value:p.value,label:p.label,side:"lo"}):p.value>a&&d.push({value:p.value,label:p.label,side:"hi"});return{lo:s,hi:a,offAxis:d,clippedCount:c}}export function limitLabelSide(e,o,t,i,n,r=3){const l=n?-1:1;return(l<0?e-r-o>=t:e+r+o<=i)?l:-l}export function limitLabelPlacement(e,o,t,i,n,r,l=[],s=3){const a=r?-1:1;for(const c of[a,-a])for(const d of o){const p=t(d),u=c<0?e-s-p:e+s,m=c<0?e-s:e+s+p;if(!(u<i||m>n)&&!l.some(f=>f>u&&f<m))return{text:d,side:c}}return{text:o[0],side:limitLabelSide(e,t(o[0]),i,n,r,s)}}export function drawOffAxisLimits(e,o,t,i,n,r,l,s){if(!o.length)return;e.save(),e.fillStyle=n,e.font=`${q(-1)}px system-ui, sans-serif`;const a={lo:0,hi:0},c=q(-1)+2;for(const{value:d,label:p,side:u}of o){const m=a[u]++*c,f=i==="horizontal"?u==="lo"?"\u2190":"\u2192":u==="lo"?"\u2193":"\u2191",x=u==="lo"?`${f} ${p} ${r(d)}`:`${p} ${r(d)} ${f}`,w=e.measureText(x).width;if(i==="horizontal"){const y=u==="lo"?t.left+2:t.right-2-w,h={x0:y,x1:y+w,y0:t.top+2+m,y1:t.top+2+m+c},k=s?placeClearOf(s,h,c):h;e.textBaseline="top",e.textAlign=u==="lo"?"left":"right",fillTextOnHalo(e,x,u==="lo"?t.left+2:t.right-2,k.y0,l)}else{const y=u==="lo"?t.bottom-2-m-c:t.top+2+m,h={x0:t.left+4,x1:t.left+4+w,y0:y,y1:y+c},k=s?placeClearOf(s,h,u==="lo"?-c:c):h;e.textBaseline="top",e.textAlign="left",fillTextOnHalo(e,x,t.left+4,k.y0,l)}}e.restore()}
|
|
1
|
+
import{SHADOW as te,LEADING as me,wireTooltip as z,wireControlHover as P,controlStyle as X,SPACE as C,RADIUS as B,fontPx as q,FONT as L,CLR as b,Z_BASE as he,menuLayerFor as ge,wireListNavigation as be,MENU_SEARCH_THRESHOLD as ne,makeMenuSearchBox as xe,markMenuTrigger as V,markNoPrint as G,openCommandMenu as ye,saveImageBlob as we,openReparentedModal as Ce}from"../toolbar.js";import{ICONS as oe}from"../icons.js";import{openGuideAt as ve}from"../guideWindow.js";import{minOf as Se,maxOf as ke}from"../../core/utils.js";import{robustFence as ie}from"../../stats/math.js";import{fmt as Ae,fmtColorbarAxis as Ee,nameStatesUnit as Le}from"../../renderer/fmt.js";import{isTestPinned as $e,toggleTestPinned as Be}from"../pinnedTests.js";import{markedTestLabel as Te,DERIVED_LANE_PAD as Oe}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,t={}){for(const a of e.querySelectorAll('div[style*="position: absolute"]'))a.style.display==="block"&&a.style.pointerEvents==="none"&&(a.style.display="none");const i=e.getAttribute("style")??"",n=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const r=e.querySelector(":scope > div > [data-wmap-card-expand]"),l=a=>{r&&(r.style.display=a?"flex":"none")};l(!1);const s=Ce([e],{title:o,anchor:t.anchor,ownerDocument:e.ownerDocument,boxSize:Re[n],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),t.onClosed?.()}});if(!s)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),null;if(n==="rows"){const a=()=>{const c=Number(e.dataset.wmapChartFullH);if(!c)return;const d=s.box.offsetHeight-s.contentWrap.clientHeight;s.setNaturalHeight(`min(90vh, ${Math.ceil(d+c)}px)`)};a(),(e.ownerDocument.defaultView??window).requestAnimationFrame(a)}return s}const Re={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 t=e.trim();let i,n,r,l=1;const s=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const c=s[1].length===3?s[1].split("").map(d=>d+d).join(""):s[1];[i,n,r]=[0,2,4].map(d=>parseInt(c.slice(d,d+2),16)),c.length===8&&(l=parseInt(c.slice(6,8),16)/255)}else if(a)[i,n,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(${i}, ${n}, ${r}, ${+(l*o).toFixed(3)})`}const Pe={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309",alert:"#7a1c1c"},re={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text",alert:"err-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),t={};for(const i of Object.keys(re)){const n=o.getPropertyValue(`--wmap-${re[i]}`).trim();t[i]=n||Pe[i]}return t.grid=withAlpha(t.border,GRID_ALPHA),t}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const t=e.ownerDocument.defaultView??window;let i=0;const n=new t.ResizeObserver(()=>{i||(i=t.requestAnimationFrame(()=>{i=0,o()}))});return n.observe(e),{disconnect:()=>{i&&t.cancelAnimationFrame(i),i=0,n.disconnect()}}}export function growCardToFitContent(e,o,t){const i=`${K(e,o)+t}px`;e.style.minHeight!==i&&(e.style.minHeight=i)}function K(e,o){const t=e.ownerDocument.defaultView??window,i=t.getComputedStyle(e);let n=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=t.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(n+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return i.boxSizing==="border-box"&&(n+=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0)),n}function le(e,o){const t=e.ownerDocument.defaultView??window;let i=0;for(const n of Array.from(e.children)){if(n===o)continue;const r=n,l=t.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(i+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return i}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,t){const i=e.toLocaleString(),n=e===1?"die":"dies";return t?e===o?`${i} ${n} ${t}`:`${i} of ${o.toLocaleString()} dies ${t} (partial and edge-excluded dies left out)`:`${i} ${n}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,t){const n=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(n.paddingTop)||0)-(parseFloat(n.paddingBottom)||0),l=n.boxSizing==="border-box"?(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0):0;return r-(K(e,o)-l)-(t?le(o,t):0)}export function fitRowsHeight(e,o,t,i,n=0){if(growCardToFitContent(e,o,n+t),e.dataset.wmapChartFullH=String(Math.ceil(K(e,o)+n+i)),!isExpandedCard(e))return t;const r=bodyRoom(e,o)-n;return Math.max(t,Math.min(i,Math.floor(r)))}export function chartFillHeight(e,o,t,i){const n=le(o,t);return growCardToFitContent(e,o,n+i),Math.max(i,o.clientHeight-n)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,t,i){const n=chartDpr(e);e.width=Math.max(1,Math.floor(t*n)),e.height=Math.max(1,Math.floor(i*n)),e.style.width=`${t}px`,e.style.height=`${i}px`;const r=e.getContext("2d");return r?(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,t,i),r.font=`${q(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let t;if(typeof o=="number")t=o;else{const i=(o.ownerDocument.defaultView??window).getComputedStyle(o);t=o.offsetTop+o.offsetHeight+(parseFloat(i.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${t}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:Ae(e,void 0,"engineering"):"\u2014"}function Me(e,o){const t=`${o} (`;return e.startsWith(t)&&e.endsWith(")")?e.slice(t.length,-1):""}export function makeAxisFormat(e,o,t,i){if(!o&&t===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const n=Le(i,o),{tickFmt:r,axisLabel:l,scaledUnit:s}=Ee(e,n?i:null,o,"engineering",t);return{tick:r,tickWithUnit:s?a=>`${r(a)} ${s}`:r,unitLabel:n?Me(l,i):l}}const Ie=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,t){return(i,n)=>{const r=makeAxisFormat(o,t,i).tick;return n.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+Ie}}export function drawAxisUnit(e,o,t,i,n){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${q(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=n,e.fillText(`(${o})`,t,i),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 U=(e,o)=>{for(let t=e;t&&t!==o.parentElement;t=t.parentElement)if(t.style.display==="none")return!1;return!0},Fe=/\s*[▾▼]\s*$/,Y=new WeakMap;export function describeCard(e){const o=[],t=e.querySelector("[data-wmap-controls]");if(t){for(const l of t.querySelectorAll("button[aria-haspopup]")){if(!U(l,t))continue;const s=(l.textContent??"").replace(Fe,"").trim();if(!s)continue;const a=l.closest("label"),d=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(d&&d!==s?`${d}: ${s}`:s)}for(const l of t.querySelectorAll('[role="radiogroup"]')){if(!U(l,t))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of t.querySelectorAll('input[type="checkbox"]:checked')){if(!U(l,t))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const i=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!U(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&i.push(s)}const n=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}const r=Y.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(i.length=0,i.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(n.length=0,n.push(...r.legend))),{controls:o,captions:i,legend:n}}function He(e){const o=describeCard(e),t=Y.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:t?.colorbar}}function se(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const t=o.querySelector(":scope > [data-wmap-print-only]");if(!t)continue;const i=describeCard(o);t.replaceChildren();const n=[i.controls.length?i.controls.join(" \xB7 "):"",...i.captions].filter(Boolean);for(const r of n){const l=e.createElement("div");l.textContent=r,t.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ae=new WeakSet;function je(e){if(ae.has(e))return;ae.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const t=e.defaultView;t?.addEventListener("beforeprint",()=>se(e));try{t?.matchMedia?.("print").addEventListener?.("change",i=>{i.matches&&se(e)})}catch{}}function De(e){const o=e.ownerDocument.defaultView;for(let t=e;t&&o;t=t.parentElement){const i=o.getComputedStyle(t).backgroundColor;if(i&&i!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(i))return i}return"#ffffff"}export function composeChartPng(e,o){const t=e.ownerDocument,i=t.createElement("canvas"),n=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=t.createElement("canvas").getContext("2d"),s=12*n,a=(m,f="400")=>`${f} ${m*n}px system-ui, -apple-system, "Segoe UI", sans-serif`,c=(m,f)=>l?(l.font=f,l.measureText(m).width):m.length*7*n,d=[];let p=0;if(o){p=s,d.push({kind:"text",text:o.title,x:s,y:p+14*n,font:a(16,"600"),alpha:1}),p+=24*n;const m=o.decor,f=[];m?.controls?.length&&f.push({text:m.controls.join(" \xB7 "),alpha:1});for(const w of m?.caption===void 0?[]:typeof m.caption=="string"?[m.caption]:m.caption)f.push({text:w,alpha:.75});const g=a(12);for(const{text:w,alpha:y}of f){let h="";for(const k of w.split(" ")){const T=h?`${h} ${k}`:k;h&&c(T,g)>r-2*s?(d.push({kind:"text",text:h,x:s,y:p+11*n,font:g,alpha:y}),p+=17*n,h=k):h=T}h&&(d.push({kind:"text",text:h,x:s,y:p+11*n,font:g,alpha:y}),p+=17*n)}if(m?.legend?.length){p+=4*n;const w=a(12);let y=s;for(const h of m.legend){const k=14*n+c(h.label,w)+14*n;y>s&&y+k>r-s&&(y=s,p+=18*n),d.push({kind:"dot",x:y+5*n,y:p+7*n,r:5*n,color:h.color}),d.push({kind:"text",text:h.label,x:y+14*n,y:p+11*n,font:w,alpha:1}),y+=k}p+=20*n}if(m?.colorbar){p+=4*n;const w=a(12),y=m.colorbar;let h=s;d.push({kind:"text",text:y.label,x:h,y:p+10*n,font:w,alpha:1}),h+=c(y.label,w)+10*n,d.push({kind:"text",text:y.lo,x:h,y:p+10*n,font:w,alpha:.75}),h+=c(y.lo,w)+6*n,d.push({kind:"strip",x:h,y:p+1*n,w:200*n,h:10*n,color:y.color}),h+=206*n,d.push({kind:"text",text:y.hi,x:h,y:p+10*n,font:w,alpha:.75}),p+=20*n}p+=6*n}i.width=r,i.height=Math.ceil(e.height+p);const u=i.getContext("2d");if(u.fillStyle=o?De(o.card):"#ffffff",u.fillRect(0,0,i.width,i.height),o){const m=t.defaultView,f=m&&m.getComputedStyle(o.card).color||"#222222";u.textBaseline="alphabetic";for(const g of d)if(g.kind==="text")u.font=g.font,u.fillStyle=f,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 w=0;w<g.w;w++)u.fillStyle=g.color(w/Math.max(1,g.w-1)),u.fillRect(g.x+w,g.y,1,g.h)}return u.drawImage(e,0,p),i}export function saveCanvasPng(e,o,t,i){composeChartPng(e,i).toBlob(n=>{n&&we(n,o,t)},"image/png")}const ce="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${ce}`,`height:${ce}`,`border-radius:${B.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Ne="0.35";export function makeSeriesLegendItem(e,o,t=document){const i=t.createElement("button");i.type="button",Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:C.xs,padding:`${C.xs} ${C.md}`,borderRadius:B.pill,border:`1px solid ${b.menuBorder}`,background:"none",cursor:"pointer",fontSize:L.body,color:b.text,whiteSpace:"nowrap"}),P(i,"bare");const n=t.createElement("span");return n.style.cssText=chartSwatchCss(o),i.append(n,t.createTextNode(e)),{el:i,setState({selected:r,dimmed:l}){i.style.borderColor=r?b.iconActive:b.menuBorder,i.style.fontWeight=r?"600":"400",i.style.opacity=l?Ne:"1",i.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:b.menuBg,border:`1px solid ${b.menuBorder}`,borderRadius:B.container,padding:C.xl,fontVariantNumeric:"tabular-nums"}}function de(e){Object.assign(e.style,{...X("outlined"),color:b.label,padding:"0",width:"22px",height:"22px",lineHeight:me.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),P(e)}export function pairCards(e,o=document){const t=o.createElement("div");t.dataset.wmapCardPair="1",Object.assign(t.style,{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",flex:"1 1 0"});const i=e.map(l=>l.card.style.display),n=[],r=l=>{e.forEach((s,a)=>{s.card.style.display=a===l?i[a]:"none"});for(const s of n)s.setValue(String(l))};return e.forEach((l,s)=>{const a=[...l.card.children].find(d=>d.querySelector("[data-wmap-card-expand]")),c=makeSegmented(e.map((d,p)=>[String(p),d.label]),String(s),d=>{r(Number(d))},o);n.push(c),c.dataset.wmapCardView="1",a?.firstElementChild&&a.firstElementChild.after(c),t.appendChild(l.card)}),r(0),t}export function cardShell(e,o,t=document,i={}){const n=t.createElement("div");n.dataset.wmapChartCard="1",n.dataset.wmapChartTitle=e,Object.assign(n.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const r=n.ownerDocument.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:C.sm,paddingBottom:"6px",marginBottom:C.md,borderBottom:`1px solid ${b.menuBorder}`});const l=n.ownerDocument.createElement("div");l.textContent=e,Object.assign(l.style,{color:b.value,fontSize:L.heading,fontWeight:"600",flex:"1"}),r.appendChild(l);const s=makeTooltip(n),a=n.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=oe.expand,a.dataset.wmapCardExpand="1",de(a),attachChartTip(a,n,s,"Expand"),G(a),a.addEventListener("click",()=>{isExpandedCard(n)||openChartExpandModal(n,l.textContent??e)}),r.appendChild(a);const c=n.ownerDocument.createElement("button");c.type="button",c.setAttribute("aria-label","Chart actions"),c.innerHTML=oe.more,c.dataset.wmapCardMenu="1",de(c),attachChartTip(c,n,s,"Chart actions"),V(c,!1),G(c),r.appendChild(c);const d=n.ownerDocument.createElement("div");d.dataset.wmapCardAbout="1",d.setAttribute("role","note"),Object.assign(d.style,{display:"none",color:b.label,fontSize:L.body,marginBottom:C.md}),G(d);let p;const u=v=>{d.textContent=v?p?.text??"":"",d.style.display=v?"":"none"};let m,f;const g=()=>{const v=m?m():n.querySelector("canvas");v&&saveCanvasPng(v,l.textContent||e,o,{card:n,title:l.textContent||e,decor:He(n)})},w=()=>{const v=[],j=(S,D,N)=>({label:S,active:!1,action:!0,enabled:!N,disabledHint:N,onClick:()=>{y?.(),D()}});i.png!==!1&&(m||n.querySelector("canvas"))&&v.push(j("Save as PNG",g));for(const S of f?.()??[])v.push(j(S.label,S.onClick,S.disabledHint));if(p){const S=d.style.display!=="none";v.push({label:`About this ${p.noun}`,active:S,onClick:()=>{y?.(),u(!S)}})}return v};let y;c.addEventListener("click",()=>{if(c.getAttribute("aria-expanded")==="true"){y?.();return}const v=w();v.length!==0&&(y=ye(c.getBoundingClientRect(),c,v,`${l.textContent||e}: chart actions`,{trigger:c,hook:"wmapCardMenuList"}))}),n.appendChild(r),n.appendChild(d);const h=n.ownerDocument.createElement("div");h.dataset.wmapPrintOnly="1",Object.assign(h.style,{display:"none",color:b.label,fontSize:L.body,marginBottom:C.sm}),n.appendChild(h),je(n.ownerDocument);const k=n.ownerDocument.createElement("div");k.dataset.wmapControls="1",Object.assign(k.style,{display:"flex",gap:C.sm,marginBottom:C.md,flexWrap:"wrap",alignItems:"center"}),G(k),n.appendChild(k);const T=n.ownerDocument.createElement("div");return Object.assign(T.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),n.appendChild(T),{card:n,heading:l,controlsRow:k,body:T,setPngDecor:v=>{Y.set(n,v)},setPngCanvas:v=>{m=v},setAbout:v=>{p=v,u(!!v&&d.style.display!=="none")},setMenuRows:v=>{f=v}}}export function guideCite(e,o,t="How to read this"){const i=e.createElement("span");return i.append(`${t}: `,pe(e,o)," in the user guide"),i}function pe(e,o){const t=e.createElement("button");return t.type="button",t.textContent=o.title,t.dataset.wmapGuideLink=o.id,Object.assign(t.style,{border:"none",background:"none",padding:"0",font:"inherit",color:b.iconActive,textDecoration:"underline",cursor:"pointer"}),P(t),t.addEventListener("click",()=>ve(o.id,t)),t}export function appendGuideCites(e,o){if(o.length===0)return;const t=e.ownerDocument;e.append(" \xB7 how to read this: "),o.forEach((i,n)=>{n>0&&e.append(n===o.length-1?" and ":", "),e.append(pe(t,i))}),e.append(" in the user guide")}export function inputStyle(){return{background:b.menuBg,color:b.text,border:`1px solid ${b.menuBorder}`,borderRadius:B.control,padding:`${C.xs} ${C.sm}`,fontSize:L.body,fontFamily:L.family,boxSizing:"border-box",minWidth:"0"}}export function makeSegmented(e,o,t,i=document,n=!1){const r=i.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",flexWrap:"wrap",maxWidth:"100%",padding:"1px 0 0 1px"});const l=e.length-1,s=`seg-${Math.random().toString(36).slice(2,9)}`,a=[],c=[];return e.forEach(([d,p,u],m)=>{const f=i.createElement("label");u&&z(f,u),Object.assign(f.style,{display:"inline-flex",alignItems:"center",fontSize:L.body,padding:n?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",border:`1px solid ${b.menuBorder}`,margin:"-1px 0 0 -1px",borderTopLeftRadius:m===0?B.control:"0",borderBottomLeftRadius:m===0?B.control:"0",borderTopRightRadius:m===l?B.control:"0",borderBottomRightRadius:m===l?B.control:"0"}),P(f,"bare");const g=i.createElement("input");g.type="radio",g.name=s,g.value=d,g.checked=d===o,c.push(g),Object.assign(g.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const w=()=>{f.style.background=g.checked?b.bgActive:b.menuBg,f.style.color=g.checked?b.iconActive:b.text,f.dataset.on=g.checked?"true":"false"};a.push(w),w(),g.addEventListener("change",()=>{if(g.checked){for(const y of a)y();t(d)}}),f.append(g,i.createTextNode(p)),r.appendChild(f)}),Object.assign(r,{setValue(d){for(const p of c)p.checked=p.value===d;for(const p of a)p()}})}const We=360;export function firstRowsToggle(e,o){let t=!1;const i=e.createElement("button");i.type="button",Object.assign(i.style,{...X("outlined"),marginTop:C.sm}),P(i);const n=()=>{o.fill(t),Object.assign(o.scroller.style,{maxHeight:t?`${We}px`:"",overflowY:t?"auto":""}),i.textContent=t?`Show the first ${o.noun}`:`Show all ${o.total} ${o.noun}`,i.style.display=o.total>o.first?"":"none"};return i.addEventListener("click",()=>{t=!t,n()}),n(),i}export function makeBackButton(e,o=document){const t=o.createElement("button");return t.type="button",t.textContent="\u2190 Back",Object.assign(t.style,{...X("outlined"),background:b.menuBg,color:b.label}),P(t),t.addEventListener("click",e),t}export function renderEmptyState(e,o,t){const i=e.ownerDocument.createElement("div");i.textContent=o,Object.assign(i.style,{color:b.label,fontSize:L.body,padding:"8px 0"}),t&&Object.assign(i.style,t),e.appendChild(i)}export function makeListSelect(e,o,t,i={}){const{maxWidth:n="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:c}=i,d=()=>typeof e=="function"?e():e;let p=d(),u=o;const m=S=>p.find(D=>D.value===S)?.label??"",f=r.createElement("button");f.type="button",c&&(f.dataset.wmapSelect=c),l&&f.setAttribute("aria-label",l),Object.assign(f.style,{fontSize:L.body,padding:`${C.xxs} ${C.sm}`,background:b.menuBg,color:b.text,border:`1px solid ${b.menuBorder}`,borderRadius:B.control,maxWidth:n,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:C.sm,justifyContent:"space-between"}),P(f),V(f,!1);const g=r.createElement("span");Object.assign(g.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const w=r.createElement("span");w.textContent="\u25BE",w.style.flex="0 0 auto",f.append(g,w);const y=()=>{g.textContent=p.length===0?s??"(none)":m(u)||s||"(none)"};if(y(),p.length===0)return f.disabled=!0,f.style.opacity="0.6",f.style.cursor="default",Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}});let h=null;const k=()=>{h&&(h.remove(),h=null,V(f,!1))},T=()=>{k(),f.focus()};function v(){p=d();const S=f.getBoundingClientRect(),D=r.defaultView??window,N=Math.max(S.width,220),ue=Math.min(S.left,Math.max(4,(D.innerWidth??1/0)-N-4));h=r.createElement("div"),h.setAttribute("role","listbox"),h.setAttribute("aria-label",l??"Options"),Object.assign(h.style,{position:"fixed",top:`${S.bottom+4}px`,left:`${ue}px`,background:b.menuBg,border:`1px solid ${b.menuBorder}`,borderRadius:B.control,boxShadow:te.menu,zIndex:he,minWidth:`${N}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const M=[],_=()=>M.filter(x=>x.row.style.display!=="none").map(x=>x.row),W=[],fe=()=>{for(const x of W)x.el.style.display=M.slice(x.first,x.last+1).some(E=>E.row.style.display!=="none")?"":"none"};if(p.length>ne){const x=xe(E=>{for(const A of M)A.row.style.display=A.label.includes(E)?"":"none";fe()},a,r,_);Object.assign(x.style,{position:"sticky",top:"0",zIndex:"1",background:b.menuBg}),x.addEventListener("keydown",E=>{if(E.key==="Escape"){E.preventDefault(),T();return}E.key==="ArrowDown"&&(E.preventDefault(),_()[0]?.focus())}),h.appendChild(x)}let Z;for(const x of p){if(x.group!==void 0&&x.group!==Z){const $=r.createElement("div");$.textContent=x.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${C.sm} ${C.xl} ${C.xxs}`,fontSize:L.sub,color:b.label,fontWeight:"600"}),h.appendChild($),W.push({el:$,first:M.length,last:M.length})}Z=x.group;const E=x.value===u,A=r.createElement("div"),J=r.createElement("span");if(J.textContent=x.disabled?`${x.label} \u2014 ${x.disabled}`:x.label,A.appendChild(J),A.setAttribute("role","option"),A.setAttribute("aria-selected",E?"true":"false"),x.disabled&&A.setAttribute("aria-disabled","true"),A.tabIndex=-1,Object.assign(A.style,{padding:`${C.sm} ${C.xl}`,fontSize:L.body,cursor:x.disabled?"default":"pointer",color:x.disabled?b.label:E?b.iconActive:b.text,fontWeight:E?"700":"400",opacity:x.disabled?"0.7":"",background:E?b.menuActive:"transparent",whiteSpace:"nowrap",...x.pin?{display:"flex",alignItems:"center",justifyContent:"space-between",gap:C.xl}:{}}),x.pin){const $=x.pin;A.setAttribute("aria-keyshortcuts","P");const O=r.createElement("span"),Q="http://www.w3.org/2000/svg",I=r.createElementNS(Q,"svg");I.setAttribute("viewBox","0 0 24 24"),I.setAttribute("width","14"),I.setAttribute("height","14"),I.setAttribute("aria-hidden","true");const F=r.createElementNS(Q,"path");F.setAttribute("d","M12 2.5l2.9 6.2 6.8.8-5 4.7 1.3 6.7L12 17.5 6 20.9l1.3-6.7-5-4.7 6.8-.8z"),F.setAttribute("fill",$.pinned?"currentColor":"none"),F.setAttribute("stroke","currentColor"),F.setAttribute("stroke-width","2"),F.setAttribute("stroke-linejoin","round"),I.appendChild(F),O.appendChild(I),O.dataset.wmapPin=$.pinned?"pinned":"unpinned",O.setAttribute("role","button"),O.setAttribute("aria-label",`${$.pinned?"Unpin":"Pin"} ${x.label} (or press P on the row)`),Object.assign(O.style,{cursor:"pointer",color:$.pinned?b.iconActive:b.label,flex:"0 0 auto",padding:`0 ${C.xs}`,display:"inline-flex",alignItems:"center"}),P(O,"bare"),z(O,$.pinned?"Unpin this test":"Pin this test to the top of every test list");const ee=R=>{R.preventDefault(),R.stopPropagation(),k(),$.toggle(),v()};O.addEventListener("click",ee),A.addEventListener("keydown",R=>{(R.key==="p"||R.key==="P")&&!R.ctrlKey&&!R.metaKey&&!R.altKey&&ee(R)}),A.appendChild(O)}A.addEventListener("mouseenter",()=>{!E&&!x.disabled&&(A.style.background=b.menuHover)}),A.addEventListener("mouseleave",()=>{E||(A.style.background="transparent")}),A.addEventListener("click",$=>{$.stopPropagation(),!x.disabled&&(u=x.value,y(),T(),t(x.value))}),h.appendChild(A),M.push({row:A,label:x.label.toLowerCase()}),W.length&&(W[W.length-1].last=M.length-1)}if(be(h,_,T),ge(f).appendChild(h),V(f,!0),p.length<=ne){const x=p.findIndex(E=>E.value===u);_()[x>=0?x:0]?.focus()}}f.addEventListener("click",S=>{if(S.stopPropagation(),h){k();return}v()});const j=S=>{if(!f.isConnected){r.removeEventListener("click",j);return}h&&!h.contains(S.target)&&!f.contains(S.target)&&k()};return r.addEventListener("click",j),Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}})}export function testOptionLabels(e){const o=e.some(t=>t.derived);return e.map(t=>(o&&!t.derived?Oe:"")+Te(t,t.testNumber))}export function makeTestSelect(e,o,t,i={}){const{maxWidth:n="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=i,s=testOptionLabels(e);return makeListSelect(()=>{const c=e.map((u,m)=>({item:u,label:s[m],pinned:$e(u.testNumber)})),d=c.some(u=>u.pinned),p=(u,m)=>({value:String(u.item.testNumber),label:u.label,...m?{group:m}:{},pin:{pinned:u.pinned,toggle:()=>Be(u.item.testNumber)}});return d?[...c.filter(u=>u.pinned).map(u=>p(u,"Pinned")),...c.filter(u=>!u.pinned).map(u=>p(u,"All tests"))]:c.map(u=>p(u))},o!==null?String(o):"",c=>t(Number(c)),{maxWidth:n,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,t,i=document){let n=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>t({includeLimits:n,clipOutliers:r,limits:l});return{get:()=>({includeLimits:n,clipOutliers:r,limits:l}),sync(a,c,d=!1){e.innerHTML="",d&&e.appendChild(makeLimitsSelect(l,p=>{l=p,s()},i)),c&&e.appendChild(makeToggle("Axis includes limits",a,p=>{n=p,s()},i,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,p=>{r=p,s()},i,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const c=a.limits??"both";return a.includeLimits===n&&a.clipOutliers===r&&c===l?!1:(n=a.includeLimits,r=a.clipOutliers,l=c,!0)}}}export function makeLinkedTestSelect(e,o,t,i={}){let n=o;const r=makeTestSelect(e,n,l=>{l!==n&&(n=l,t(l))},i);return{el:r,get:()=>n,set(l){return n===l||!e.some(s=>s.testNumber===l)?!1:(n=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,t,i,n={}){let r=t;const l=d=>d??ALL_GROUPS,s=d=>d===ALL_GROUPS?null:d,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(d=>({value:d,label:d}))],l(r),d=>{const p=s(d);p!==r&&(r=p,i(p))},{...n,hook:"group-scope"}),c=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(d){return r===d||d!==null&&!e.includes(d)?!1:(r=d,c&&(c.value=l(d)),!0)}}}export function makeWaferSelect(e,o,t,i={}){const{maxWidth:n="160px",allLabel:r="All wafers",ownerDocument:l=document}=i,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,c)=>({value:String(c),label:a.label??`#${c}`}))],o===null?s:String(o),a=>t(a===s?null:Number(a)),{maxWidth:n,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,t,i=document,n){const r=i.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:C.xs,fontSize:L.body,color:b.label,cursor:"pointer",userSelect:"none"}),P(r,"bare");const l=i.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>t(l.checked)),r.append(l,i.createTextNode(e)),n&&z(r,n),r}export function makeLabeledSelect(e,o,t,i,n={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document,hint:a}=n,c=s.createElement("label");c.textContent=e,Object.assign(c.style,{color:b.label,fontSize:L.body,display:"flex",alignItems:"center",gap:C.xs});const d=makeListSelect(o,t,i,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return c.appendChild(d),a&&z(c,a),c}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(var(--wmap-insights-cols, auto-fit), minmax(var(--wmap-insights-min, 420px), 1fr))",gap:C.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:B.control,padding:`${C.sm} ${C.xl}`,fontSize:L.sub,fontFamily:L.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:te.menu}),e.appendChild(o),o}export function attachChartTip(e,o,t,i){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=i),e.addEventListener("mouseenter",n=>{t.textContent=i,t.style.display="block",positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mousemove",n=>{t.style.display==="block"&&positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{t.style.display="none"}),e.addEventListener("click",()=>{t.style.display="none"}),e.addEventListener("focus",()=>{t.textContent=i,t.style.display="block";const n=e.getBoundingClientRect();positionChartTooltip(t,o,n.left+n.width/2,n.bottom)}),e.addEventListener("blur",()=>{t.style.display="none"})}export function positionChartTooltip(e,o,t,i){const n=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let c=t-n.left+r,d=i-n.top+r;c+s+l>n.width&&(c=t-n.left-r-s),d+a+l>n.height&&(d=i-n.top-r-a),c=Math.max(l,c),d=Math.max(l,d),e.style.left=`${c}px`,e.style.top=`${d}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"},pat:{lo:"PAT lo",hi:"PAT hi"},whatif:{lo:"What-if lo",hi:"What-if hi"},ref:{lo:"",hi:""}},LIMIT_DASH={test:[3,3],spec:[10,4],pat:[1,3],whatif:[8,3,2,3],ref:[6,2,1,2]},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 H(e,o){const[t,i]=o==="test"?[e?.limitLow,e?.limitHigh]:o==="spec"?[e?.specLow,e?.specHigh]:o==="pat"?[e?.patLow,e?.patHigh]:o==="whatif"?[e?.whatIfLow,e?.whatIfHigh]:[void 0,void 0],n=[];return t!==void 0&&Number.isFinite(t)&&n.push({value:t,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),i!==void 0&&Number.isFinite(i)&&n.push({value:i,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),n}export function hasBothLimitKinds(e){return H(e,"test").length>0&&H(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const t=H(e,"test"),i=H(e,"spec"),n=o==="test"?t:o==="spec"?i:[...t,...i];return[...n.length?n:[...t,...i],...H(e,"pat"),...H(e,"whatif")]}export function limitExtent(e){if(!e.length)return{};const o=e.map(t=>t.value);return{lo:Se(o),hi:ke(o)}}export function placeClearOf(e,o,t,i=6){const n=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<i&&n(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+t,y1:r.y1+t};return e.push(r),r}export function stackLabelRows(e,o=4){const t=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),i=[],n=new Array(e.length).fill(0);for(const r of t){let l=i.findIndex(s=>r.start>=s+o);l===-1?(l=i.length,i.push(r.end)):i[l]=r.end,n[r.i]=l}return n}export function fillTextOnHalo(e,o,t,i,n){if(n){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=n,e.fillRect(t-r.actualBoundingBoxLeft-l,i-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,t,i)}export function strokeLimitLine(e,o,t,i,n,r,l){e.save(),e.strokeStyle=t,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(i,n),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,t=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,i=>o(i),{maxWidth:"170px",hook:"limits-shown",ownerDocument:t})}export{ie as robustFence};export function shouldIncludeLimitsByDefault(e,o,t,i,n=1/3){if(t===void 0&&i===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,t??e),s=Math.max(o,i??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=n}export function resolveAxisRange(e){const{dataMin:o,dataMax:t,limits:i=[],includeLimits:n,clipOutliers:r,values:l}=e;let s=o,a=t,c=0;if(r&&l?.length){const p=ie(l);if(p){const u=Math.max(s,p.lo),m=Math.min(a,p.hi);m>u&&(c=l.filter(f=>Number.isFinite(f)&&(f<u||f>m)).length,s=u,a=m)}}if(n)for(const p of i)s=Math.min(s,p.value),a=Math.max(a,p.value);s===a&&(s-=1,a+=1);const d=[];for(const p of i)p.value<s?d.push({value:p.value,label:p.label,side:"lo"}):p.value>a&&d.push({value:p.value,label:p.label,side:"hi"});return{lo:s,hi:a,offAxis:d,clippedCount:c}}export function limitLabelSide(e,o,t,i,n,r=3){const l=n?-1:1;return(l<0?e-r-o>=t:e+r+o<=i)?l:-l}export function limitLabelPlacement(e,o,t,i,n,r,l=[],s=3){const a=r?-1:1;for(const c of[a,-a])for(const d of o){const p=t(d),u=c<0?e-s-p:e+s,m=c<0?e-s:e+s+p;if(!(u<i||m>n)&&!l.some(f=>f>u&&f<m))return{text:d,side:c}}return{text:o[0],side:limitLabelSide(e,t(o[0]),i,n,r,s)}}export function drawOffAxisLimits(e,o,t,i,n,r,l,s){if(!o.length)return;e.save(),e.fillStyle=n,e.font=`${q(-1)}px system-ui, sans-serif`;const a={lo:0,hi:0},c=q(-1)+2;for(const{value:d,label:p,side:u}of o){const m=a[u]++*c,f=i==="horizontal"?u==="lo"?"\u2190":"\u2192":u==="lo"?"\u2193":"\u2191",g=u==="lo"?`${f} ${p} ${r(d)}`:`${p} ${r(d)} ${f}`,w=e.measureText(g).width;if(i==="horizontal"){const y=u==="lo"?t.left+2:t.right-2-w,h={x0:y,x1:y+w,y0:t.top+2+m,y1:t.top+2+m+c},k=s?placeClearOf(s,h,c):h;e.textBaseline="top",e.textAlign=u==="lo"?"left":"right",fillTextOnHalo(e,g,u==="lo"?t.left+2:t.right-2,k.y0,l)}else{const y=u==="lo"?t.bottom-2-m-c:t.top+2+m,h={x0:t.left+4,x1:t.left+4+w,y0:y,y1:y+c},k=s?placeClearOf(s,h,u==="lo"?-c:c):h;e.textBaseline="top",e.textAlign="left",fillTextOnHalo(e,g,t.left+4,k.y0,l)}}e.restore()}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{rankCommonality as
|
|
1
|
+
import{rankCommonality as se,measureLabel as V,groupCommonalityRows as ae,commonalityConfidence as X,CONFIDENCE_LABEL as ie}from"../../stats/commonality.js";import{formatP as I}from"../../stats/groupCompare.js";import{CLR as m,FONT as N,RADIUS as re,SPACE as c,controlStyle as Y,wireControlHover as z,wireTooltip as g}from"../toolbar.js";import{shortfallShade as le}from"../cellShade.js";import{cardShell as de,firstRowsToggle as ce,guideCite as pe,renderEmptyState as me}from"./chartShell.js";import{GUIDE_SECTIONS as fe}from"../../stats/guideSections.js";import{cardAbout as he}from"./cardAbout.js";const J=8,ue=5,we=110;export function renderCommonalityPanel(h){const s=h.ownerDocument??document,{card:$,body:E,setAbout:K}=de("What divides yield",void 0,s);K(he("commonality")),$.dataset.wmapCommonality="1",$.style.gridColumn="1 / -1",$.style.flex="0 0 auto";const p=se(h.wafers,h.fields,h.curation);if(h.fields.length===0||p.rows.length===0)return me(E,h.fields.length===0?"No wafer field divides these wafers, so there is nothing to compare.":"No wafer field has two groups of two or more wafers, so there is nothing to compare."),{card:$,destroy:()=>{}};const B=ae(p.rows,p.tied),v=e=>`${e.slice(0,-1).map(t=>t.label).join(", ")}${e.length>1?" and ":""}${e[e.length-1].label}`,T=s.createElement("div"),R=[`Each wafer field, compared for yield and for the ${p.bins.length} most common fail bin${p.bins.length===1?"":"s"}, with each wafer as one value. The clearest fields come first. A clear difference is more than wafer-to-wafer noise; it does not say why.`];p.overlapping.length&&R.push(`These fields nearly match, so the wafers cannot fully tell them apart: ${p.overlapping.map(e=>`${v(e.fields)} and ${v(e.with)} put ${e.agree} of ${e.of} wafers in the same groups`).join("; ")}.`),p.untestable.length&&R.push(`Not compared, with no two groups of two or more wafers: ${p.untestable.map(e=>e.label).join(", ")}.`),T.textContent=R.join(" "),Object.assign(T.style,{color:m.label,fontSize:N.body,marginBottom:c.xs}),E.appendChild(T);const W=s.createElement("details"),j=s.createElement("summary");j.textContent="How to read this",Object.assign(j.style,{cursor:"pointer"}),z(j,"bare");const L=s.createElement("div");L.textContent=`Clear means q is under 0.05 and possible under 0.2, where q is Welch\u2019s p adjusted for the ${p.rows.length} comparisons in the table (Benjamini\u2013Hochberg). Hover a word for the p-values. Each field is read after allowing for the strongest other field that explains the same measure and does not contain it, and its row says so. The bars show the worst (in bold) and the best group\u2019s mean, filled from zero on a scale of 0 to 100%; hover a bar for its group\u2019s median, spread and wafers. `,L.append(pe(s,fe.dividesYield),"."),W.append(j,L),Object.assign(W.style,{color:m.label,fontSize:N.body,marginBottom:c.sm}),E.appendChild(W);const O=s.createElement("table");Object.assign(O.style,{borderCollapse:"collapse",width:"100%",fontSize:N.body,fontVariantNumeric:"tabular-nums"});const D=s.createElement("tr"),S=(e,t)=>{const n=s.createElement("th");n.scope="col",n.textContent=e,t&&g(n,t),Object.assign(n.style,{textAlign:"left",padding:`${c.xs} ${c.sm}`,borderBottom:`1px solid ${m.menuBorder}`,color:m.label,fontWeight:"600",whiteSpace:"nowrap"}),D.appendChild(n)};S("Field"),S("Effect","The worst and the best group\u2019s mean over their wafers, and how far apart they are"),S("Confidence","Whether the groups differ by more than wafer-to-wafer noise: clear (q under 0.05), possible (under 0.2), or not clear"),S("");const H=s.createElement("thead");H.appendChild(D),O.appendChild(H);const G=s.createElement("tbody");O.appendChild(G);const y=(e,t,n={})=>{const o=s.createElement("td");return typeof t=="string"?o.textContent=t:o.appendChild(t),n.title&&g(o,n.title),n.shade&&(o.style.background=n.shade),Object.assign(o.style,{padding:`${c.xs} ${c.sm}`,textAlign:"left",borderBottom:`1px solid ${m.menuBorder}`,verticalAlign:"top",fontWeight:n.strong?"700":"400"}),e.appendChild(o),o},A=e=>`${e.toFixed(1)}%`,M=e=>`${e.toFixed(1)} pts`,_=(e,t)=>t.comparison.groups.find(n=>n.key===e)?.n??0,Q=e=>e.comparison.groups.filter(t=>!e.comparison.tooSmall.includes(t.key)&&Number.isFinite(t.mean)),Z=e=>{if(e.measure.kind!=="yield")return;const t=e.comparison.groups.filter(o=>Number.isFinite(o.mean)&&o.n>0),n=t.reduce((o,r)=>o+r.n,0);return n>0?le(e.worst.mean-t.reduce((o,r)=>o+r.mean*r.n,0)/n):void 0},ee=e=>{const t=e.measure.kind==="yield"?`${e.worst.key} is ${M(e.spread)} below ${e.best.key}`:`${V(e.measure)} is ${M(e.spread)} higher in ${e.worst.key} than in ${e.best.key}`,[n,o]=[_(e.worst.key,e),_(e.best.key,e)];return Math.min(n,o)<ue?`${t} (${n} vs ${o} wafers)`:t},te=e=>{const t=Q(e),n=100,o=s.createElement("div");Object.assign(o.style,{display:"flex",flexDirection:"column",gap:"2px",flex:"0 0 auto"});const r=(i,l)=>{const b=s.createElement("div");b.dataset.wmapBar=l,Object.assign(b.style,{display:"flex",alignItems:"center",gap:c.sm});const a=s.createElement("span");a.textContent=i.key,Object.assign(a.style,{width:"72px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.label,fontWeight:l==="worst"?"700":"400"});const d=s.createElement("div");Object.assign(d.style,{width:`${we}px`,height:"10px",border:`1px solid ${m.label}`,boxSizing:"border-box",flex:"0 0 auto"});const C=s.createElement("div");Object.assign(C.style,{width:`${Math.max(0,Math.min(100,i.mean/n*100)).toFixed(1)}%`,height:"100%",background:m.label}),d.appendChild(C);const k=s.createElement("span");return k.textContent=A(i.mean),Object.assign(k.style,{width:"52px",textAlign:"right"}),b.append(a,d,k),g(b,[`${i.key}${l==="worst"?" (worst group)":" (best group)"}`,`mean ${A(i.mean)} \xB7 median ${A(i.median)}`,Number.isFinite(i.sd)?`standard deviation ${i.sd.toFixed(1)} pts between wafers`:"",`${i.n} wafer${i.n===1?"":"s"}`].filter(Boolean).join(`
|
|
2
|
+
`)),b},u=t.find(i=>i.key===e.worst.key),w=t.find(i=>i.key===e.best.key);u&&o.appendChild(r(u,"worst")),w&&o.appendChild(r(w,"best"));const f=t.filter(i=>i!==u&&i!==w);if(f.length){const i=s.createElement("div");i.textContent=`+ ${f.length} other group${f.length===1?"":"s"}`,Object.assign(i.style,{color:m.label}),g(i,f.map(l=>`${l.key}: ${A(l.mean)} (${l.n} wafer${l.n===1?"":"s"})`).join(`
|
|
3
|
+
`)),o.appendChild(i)}return o},ne=e=>{const t=e.adjusted??e.comparison,n=t.kruskal;return[`q ${I(e.pAdjusted)} \xB7 Welch p ${I(t.welch?.p??NaN)} \xB7 rank p ${I(n?.p??NaN)}${n?.approximate?"* (approximate: fewer than five wafers in a group)":""}`,t.issue].filter(Boolean).join(`
|
|
4
|
+
`)},x=new Set;let q=!1;const P=(e,t,n)=>{const o=s.createElement("tr");o.dataset.wmapCommonalityRow=n?"field":"measure";const r=s.createElement("div");if(n){const a=s.createElement("div");a.textContent=v(t.fields),a.style.fontWeight="600",t.fields.length>1&&g(a,"These fields group the wafers identically, so the wafers cannot tell them apart: one row stands for all of them."),r.appendChild(a)}const u=s.createElement("div");if(u.textContent=V(e.measure)+(e.allowedFor?`, allowing for ${e.allowedFor.map(a=>a.label).join(", ")}`:""),Object.assign(u.style,{color:m.label,paddingLeft:n?"0":c.md}),e.allowedFor&&g(u,`Read after allowing for ${e.allowedFor.map(a=>a.label).join(", ")}: each wafer's value less its ${e.allowedFor.length===1?"group\u2019s":"groups\u2019"} mean on ${e.allowedFor.length===1?"that field":"those fields"}, so a difference the other field explains does not hide this one. The bars and the points are the measure's own means.`),r.appendChild(u),n&&t.others.length){const a=t.others.filter(k=>X(k.pAdjusted)!=="none").length,d=s.createElement("button");d.type="button",d.dataset.wmapCommonalityMore=t.field.key;const C=x.has(t.field.key);d.setAttribute("aria-expanded",String(C)),d.textContent=C?"Hide other measures":a?`+${a} other measure${a===1?"":"s"} ${a===1?"differs":"differ"}`:`${t.others.length} other measure${t.others.length===1?"":"s"}`,Object.assign(d.style,{...Y("outlined"),marginTop:c.xs,fontSize:N.body}),z(d),d.addEventListener("click",()=>{x.has(t.field.key)?x.delete(t.field.key):x.add(t.field.key),U(q)}),r.appendChild(d)}y(o,r);const w=s.createElement("div");Object.assign(w.style,{display:"flex",alignItems:"flex-start",gap:c.md});const f=s.createElement("span");f.textContent=ee(e);const i=Z(e);i&&Object.assign(f.style,{background:i,padding:`0 ${c.xs}`,borderRadius:re.control}),f.dataset.wmapSentence="1",w.append(te(e),f),y(o,w);const l=X(e.pAdjusted),b=y(o,ie[l],{strong:l==="clear",title:ne(e)});if(b.dataset.wmapConfidence=l,n)if(t.fields.some(a=>a.key===h.groupedBy))y(o,"Grouped by this");else{const a=s.createElement("button");a.type="button",a.textContent="Group by",a.dataset.wmapCommonalityGroup=t.field.key,g(a,`Group Insights by ${t.field.label}, so every chart compares its groups${t.fields.length>1?`; ${v(t.fields.slice(1))} give the same groups`:""}`),Object.assign(a.style,Y("outlined")),z(a),a.addEventListener("click",()=>h.onGroupBy(t.field.key)),y(o,a)}else y(o,"");G.appendChild(o)};function U(e){q=e,G.replaceChildren();for(const t of e?B:B.slice(0,J))if(P(t.primary,t,!0),x.has(t.field.key))for(const n of t.others)P(n,t,!1)}const F=s.createElement("div");Object.assign(F.style,{overflowX:"auto"}),F.appendChild(O);const oe=ce(s,{total:B.length,first:J,noun:"rows",scroller:F,fill:U});return E.append(F,oe),{card:$,destroy:()=>{}}}
|
|
@@ -23,6 +23,17 @@ export interface CorrelationPanelOptions {
|
|
|
23
23
|
*/
|
|
24
24
|
/** Clicking a non-diagonal cell calls this — the Analysis tab wires it to drive the scatter panel's X/Y in place. */
|
|
25
25
|
onSelectPair?: (xTestNumber: number, yTestNumber: number) => void;
|
|
26
|
+
/**
|
|
27
|
+
* With Group by on (two groups or more), the groups' wafers: the matrix then offers **Within groups**, the correlation
|
|
28
|
+
* left once each group's mean is taken off every test. Not a restriction to one group (see above): the choice is how
|
|
29
|
+
* the same wafers are correlated.
|
|
30
|
+
*/
|
|
31
|
+
groups?: ReadonlyArray<{
|
|
32
|
+
key: string;
|
|
33
|
+
items: CorrelationItem[];
|
|
34
|
+
}>;
|
|
35
|
+
/** The field the groups are values of, for the choice's label. */
|
|
36
|
+
groupLabelText?: string;
|
|
26
37
|
/** Document to build this panel's DOM into. Default `document` — pass the
|
|
27
38
|
* host's own `ownerDocument` when the container might live in a
|
|
28
39
|
* different document (e.g. a gallery card detached into its own popup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCorrelationMatrix as It,filterCorrelationMatrix as Tt,correlationSampleNote as St}from"../../stats/correlation.js";import{maxOf as Dt}from"../../core/utils.js";import{CORRELATION_POSITIVE as st,CORRELATION_NEGATIVE as rt}from"./palette.js";import{buildFacetTable as Rt}from"../../stats/facets.js";import{wireControlHover as At,wireTooltip as ut,controlStyle as kt,SPACE as L,RADIUS as lt,fontPx as ft,FONT as j,CLR as b}from"../toolbar.js";import{exportCsv as _t}from"../tableExport.js";import{attachChartTip as Bt,cardShell as Nt,setChartGrow as Ot,isExpandedCard as Wt,bodyRoom as Ht,observeResize as Xt,makeTooltip as jt,positionChartTooltip as Vt,makeWaferSelect as zt,renderEmptyState as Ft,resolveChartCanvasColors as Pt,prepareCanvas as Yt,chartDpr as pt}from"./chartShell.js";import{escHtml as K}from"../../core/utils.js";import{unmarkedLabel as ht,derivedCsvCell as xt,DERIVED_CSV_HEADER as bt,DERIVED_MARK as Gt,DERIVED_KEY as Ut}from"../../renderer/testLabel.js";import{cardAbout as Kt}from"./cardAbout.js";const it=5,at=100,gt=20;function q(g){const d=g.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(d)return[+d[1],+d[2],+d[3]];const h=g.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 qt(g){const d=q(g);return d?(d[0]*299+d[1]*587+d[2]*114)/1e3>140?"#111":"#fff":"#000"}function yt(g,d,h){const O=q(g);if(!O)return g;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(g){const{title:d="Test correlation matrix",items:h,testDefs:O,onSaveImage:J,onSelectPair:W}=g,{card:l,body:$,controlsRow:Q,setPngDecor:wt,setAbout:Ct}=Nt(d,J,g.ownerDocument);Ct(Kt("correlation")),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))}}}),Ot(l,"square"),$.style.overflowX="auto",l.style.alignSelf="start";let F=gt,V=null;const H=l.ownerDocument.createElement("label");H.textContent="Max tests:",ut(H,`The most tests the matrix shows, from ${it} to ${at}`),Object.assign(H.style,{color:b.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:b.menuBg,color:b.value,border:`1px solid ${b.menuBorder}`,borderRadius:lt.control}),E.addEventListener("change",()=>{const e=Math.max(it,Math.min(at,parseInt(E.value,10)||gt));E.value=String(e),e!==F&&(F=e,tt())}),H.appendChild(E),Q.appendChild(H),h.length>1&&Q.appendChild(zt(h,V,e=>{V=e,tt()},{ownerDocument:l.ownerDocument}));function Mt(){return V!==null?h[V]?[h[V]]:[]:h}if(g.onSaveText){const e=l.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",ut(e,"Save the correlation coefficients as a CSV file, one row per pair of tests"),Object.assign(e.style,{...kt("outlined"),color:b.text}),At(e),e.addEventListener("click",()=>{const o=ct;if(!o)return;const m=o.tests.some(s=>s.derived),u=[];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&&u.push({x:o.tests[a],y:o.tests[s],r:y.r,n:y.n})}_t([{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 ${bt.toLowerCase()}`,get:s=>xt(s.x)},{header:`Test Y ${bt.toLowerCase()}`,get:s=>xt(s.y)}]:[]],u,"test-correlation.csv",g.onSaveText)}),Q.appendChild(e)}const _=l.ownerDocument.createElement("div");Object.assign(_.style,{display:"flex",flexDirection:"column",gap:L.xs,marginBottom:L.sm}),l.insertBefore(_,$);const I=jt(l);Bt(H,l,I,"Cap on how many tests the matrix includes (strongest correlations kept first)");let Z=()=>{};function Et(e,o,m,u,s,a,y,x){_.innerHTML="";const T=St(y);if(T){const f=l.ownerDocument.createElement("div");f.dataset.wmapCaption="1",f.textContent=y.sample?`${T} \u2014 r is an estimate, not the whole population.`:`${T}.`,Object.assign(f.style,{color:b.label,fontSize:j.body}),_.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:b.warnText,background:b.warnBg,border:`1px solid ${b.warnBorder}`,borderRadius:lt.control,padding:`${L.xs} ${L.md}`,fontSize:j.body}),_.appendChild(f)}const C=l.ownerDocument.createElement("span");Object.assign(C.style,{display:"inline-flex",alignItems:"center",gap:L.sm,color:b.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?` ${Gt} ${Ut} \xB7`:""),C.appendChild(B);const i=l.ownerDocument.createElement("span");Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:L.xs});const S=l.ownerDocument.createElement("span");S.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 ${b.menuBorder}`,background:`linear-gradient(to right, ${rt}, ${b.menuBg}, ${st})`});const z=l.ownerDocument.createElement("span");z.textContent="+1",i.append(S,P,z),C.appendChild(i),_.appendChild(C);const v=l.ownerDocument.createElement("span");if(v.dataset.wmapCaption="1",Object.assign(v.style,{color:b.value,fontSize:j.body,fontWeight:"500"}),e===0&&o===0)v.textContent=u?`No significant correlations found \u2014 strongest pair: ${u.xLabel} \u2194 ${u.yLabel} (r = ${u.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}_.appendChild(v)}function vt(e){if($.innerHTML="",e.tests.length<2)return Ft($,"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,u=r=>r.label.split(" (#")[0],s=Math.min(14,Dt(e.tests.map(r=>u(r).length))),a=s*6.5+8,y=10,x=Math.round(y*6.5*Math.sin(Math.PI/4))+14,T=14,C=28,B=44;let i=-1,S=-1;const P=96;function z(r){const c=Math.max(0,r-a),p=Math.floor(c/m);if(!Wt(l))return Math.max(T,Math.min(B,p));const n=Math.floor((Ht(l,$,o)-x-4)/m);return Math.max(T,Math.min(P,p,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=Pt(l),c=q(r.bg)??[255,255,255],p=$.clientWidth,n=z(p),X=n*m,D=x+n*m+4,R=a+X,A=Yt(o,l,R,D);if(!A)return;const{ctx:t}=A;t.font=`${ft(-1)}px system-ui, sans-serif`,t.fillStyle=r.text,e.tests.forEach((k,w)=>{const M=u(k),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((k,w)=>{const M=u(k),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===S?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,$t=nt===i&&w===S,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=qt(ot),t.textAlign="center",t.textBaseline="middle",t.fillText(U.toFixed(2),G+n/2,N+n/2)),$t&&(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 k=0;k<=m;k++){const w=a+k*n;t.beginPath(),t.moveTo(w,x),t.lineTo(w,x+m*n),t.stroke();const M=x+k*n;t.beginPath(),t.moveTo(a,M),t.lineTo(a+m*n,M),t.stroke()}}function Y(r){const c=o.getBoundingClientRect(),p=$.clientWidth,n=z(p),X=(r.clientX-c.left)*(o.width/pt(o)/c.width),D=(r.clientY-c.top)*(o.height/pt(o)/c.height),R=Math.floor((X-a)/n),A=Math.floor((D-x)/n);return R>=0&&R<m&&A>=0&&A<m?{xi:R,yi:A}:null}return o.addEventListener("mousemove",r=>{const c=Y(r);if(!c){I.style.display="none",o.style.cursor="default";return}const{xi:p,yi:n}=c,X=p===n;o.style.cursor=X||!W?"default":"pointer";const D=e.cells.find(t=>t.xIndex===p&&t.yIndex===n),R=e.tests[p].label,A=e.tests[n].label;X?I.innerHTML=`<strong>${K(R)}</strong>`:D?.r!==null&&D?.r!==void 0?I.innerHTML=`<strong>${K(u(e.tests[n]))}</strong> (#${e.tests[n].testNumber}) vs <strong>${K(u(e.tests[p]))}</strong> (#${e.tests[p].testNumber})<br>r = ${D.r.toFixed(4)} \xB7 n = ${D.n.toLocaleString()}${W?"<br><em>click to view in scatter</em>":""}`:I.innerHTML=`${K(`${A} vs ${R}`)}<br><em>insufficient data</em>`,I.style.display="block",Vt(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:p,yi:n}=c;p!==n&&(i=p,S=n,f(),W(e.tests[p].testNumber,e.tests[n].testNumber))}),f}let ct=null;function tt(){const e=Mt(),o=e.flatMap(i=>i.dies??[]),m=It(o,O),{matrix:u,strongPairs:s,moderatePairs:a,hiddenWeakPairs:y,strongestPair:x}=Tt(m,{minTests:6,maxTests:F}),T=Rt(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),C=u.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,S)=>i-S),B=C.length?C[Math.floor(C.length/2)]:null;ct=u,Et(s,a,y,x,T,B,m,u.tests.some(i=>i.derived)),Z=vt(u),Z()}const Lt=Xt(l,()=>Z());return tt(),{card:l,destroy:()=>Lt.disconnect()}}
|
|
1
|
+
import{buildCoFailureMatrix as De}from"../../stats/coFailure.js";import{buildCorrelationMatrix as Re,demeanWithinGroups as ke,filterCorrelationMatrix as Ae,correlationSampleNote as _e}from"../../stats/correlation.js";import{maxOf as We}from"../../core/utils.js";import{CORRELATION_POSITIVE as Q,CORRELATION_NEGATIVE as re}from"./palette.js";import{buildFacetTable as Be}from"../../stats/facets.js";import{wireControlHover as Oe,wireTooltip as me,controlStyle as Ne,SPACE as I,RADIUS as ie,fontPx as pe,FONT as z,CLR as x}from"../toolbar.js";import{exportCsv as He}from"../tableExport.js";import{attachChartTip as Xe,cardShell as je,makeSegmented as ge,setChartGrow as Fe,isExpandedCard as Ve,bodyRoom as ze,observeResize as Ye,makeTooltip as Ge,positionChartTooltip as Pe,makeWaferSelect as Ke,renderEmptyState as Ue,resolveChartCanvasColors as qe,prepareCanvas as Je,chartDpr as be}from"./chartShell.js";import{escHtml as Z}from"../../core/utils.js";import{unmarkedLabel as xe,derivedCsvCell as ye,DERIVED_CSV_HEADER as we,DERIVED_MARK as Qe,DERIVED_KEY as Ze}from"../../renderer/testLabel.js";import{cardAbout as et}from"./cardAbout.js";const ae=5,ce=100,Ce=20;function ee(d){const h=d.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);if(h)return[+h[1],+h[2],+h[3]];const g=d.trim().replace("#","");return g.length===6?[parseInt(g.slice(0,2),16),parseInt(g.slice(2,4),16),parseInt(g.slice(4,6),16)]:null}function tt(d){const h=ee(d);return h?(h[0]*299+h[1]*587+h[2]*114)/1e3>140?"#111":"#fff":"#000"}function $e(d,h,g){const v=ee(d);if(!v)return d;const te=Math.round(h[0]+(v[0]-h[0])*g),X=Math.round(h[1]+(v[1]-h[1])*g),l=Math.round(h[2]+(v[2]-h[2])*g);return`rgb(${te},${X},${l})`}export function renderCorrelationPanel(d){const{title:h="Test correlation matrix",items:g,testDefs:v,onSaveImage:te,onSelectPair:X}=d,{card:l,body:D,controlsRow:Y,setPngDecor:Me,setAbout:Le}=je(h,te,d.ownerDocument);Le(et("correlation")),Me(()=>{const e=ee(l.ownerDocument.defaultView?.getComputedStyle(l).backgroundColor??"")??[255,255,255];return{colorbar:{label:"Pearson r",lo:"\u22121",hi:"+1",color:n=>$e(n<.5?re:Q,e,Math.abs(2*n-1))}}}),Fe(l,"square"),D.style.overflowX="auto",l.style.alignSelf="start";let K=Ce,j=null;const F=l.ownerDocument.createElement("label");F.textContent="Max tests:",me(F,`The most tests the matrix shows, from ${ae} to ${ce}`),Object.assign(F.style,{color:x.label,fontSize:z.body,display:"flex",alignItems:"center",gap:I.xs});const E=l.ownerDocument.createElement("input");E.type="number",E.min=String(ae),E.max=String(ce),E.value=String(K),Object.assign(E.style,{width:"52px",fontSize:z.body,padding:`${I.xxs} ${I.xs}`,background:x.menuBg,color:x.value,border:`1px solid ${x.menuBorder}`,borderRadius:ie.control}),E.addEventListener("change",()=>{const e=Math.max(ae,Math.min(ce,parseInt(E.value,10)||Ce));E.value=String(e),e!==K&&(K=e,G())}),F.appendChild(E),Y.appendChild(F),g.length>1&&Y.appendChild(Ke(g,j,e=>{j=e,G()},{ownerDocument:l.ownerDocument}));let de=!1,y=!1;if(v.filter(e=>e.limitLow!==void 0||e.limitHigh!==void 0).length>=2){const e=ge([["values","Values","How the tests\u2019 values move together (Pearson r)"],["fails","Fails together","Which tests fail on the same dies: the share of the dies failing either of two tests that fail both"]],"values",n=>{y=n==="fails",G()},l.ownerDocument);e.dataset.wmapCorrelationKind="1",Y.appendChild(e)}if(d.groups&&d.groups.length>=2){const e=ge([["pooled","Pooled"],["within",`Within ${d.groupLabelText??"groups"}`,"The correlation left once each group\u2019s mean is taken off every test, so a difference between groups is not read as a relationship between tests"]],"pooled",n=>{de=n==="within",G()},l.ownerDocument);e.dataset.wmapCorrelationMode="1",Y.appendChild(e)}function ve(){return j!==null?g[j]?[g[j]]:[]:g}if(d.onSaveText){const e=l.ownerDocument.createElement("button");e.type="button",e.textContent="Correlation CSV",me(e,"Save the correlation coefficients as a CSV file, one row per pair of tests"),Object.assign(e.style,{...Ne("outlined"),color:x.text}),Oe(e),e.addEventListener("click",()=>{const n=fe;if(!n)return;const u=n.tests.some(o=>o.derived),a=[];for(let o=0;o<n.tests.length;o++)for(let c=o+1;c<n.tests.length;c++){const w=n.cells.find(b=>b.xIndex===c&&b.yIndex===o);w&&a.push({x:n.tests[c],y:n.tests[o],r:w.r,n:w.n})}He([{header:"Test X",get:o=>xe(o.x.label)},{header:"Test X number",get:o=>o.x.testNumber},{header:"Test Y",get:o=>xe(o.y.label)},{header:"Test Y number",get:o=>o.y.testNumber},{header:y?"Share failing both":"r",get:o=>o.r===null?"":o.r.toFixed(6)},{header:y?"Dies failing either":"n",get:o=>o.n},...u?[{header:`Test X ${we.toLowerCase()}`,get:o=>ye(o.x)},{header:`Test Y ${we.toLowerCase()}`,get:o=>ye(o.y)}]:[]],a,"test-correlation.csv",d.onSaveText)}),Y.appendChild(e)}const N=l.ownerDocument.createElement("div");Object.assign(N.style,{display:"flex",flexDirection:"column",gap:I.xs,marginBottom:I.sm}),l.insertBefore(N,D);const R=Ge(l);Xe(F,l,R,"Cap on how many tests the matrix includes (strongest correlations kept first)");let ne=()=>{};function Ee(e,n,u,a,o,c,w,b){N.innerHTML="";const k=_e(w);if(k){const m=l.ownerDocument.createElement("div");m.dataset.wmapCaption="1",m.textContent=w.sample?`${k} \u2014 r is an estimate, not the whole population.`:`${k}.`,Object.assign(m.style,{color:x.label,fontSize:z.body}),N.appendChild(m)}if(o.length>0){const m=l.ownerDocument.createElement("div");m.dataset.wmapCaption="1",m.textContent=`\u26A0 Mixed ${o.join(", ")} within this set \u2014 correlations may be misleading (Simpson's paradox). ${d.groups&&d.groups.length>=2?`Choose Within ${d.groupLabelText??"groups"} to take the groups\u2019 differences out, or use the Wafer picker`:"Use the Wafer picker to narrow to a like-for-like set, or Group by one of these fields where it is in the list"}.`,Object.assign(m.style,{color:x.warnText,background:x.warnBg,border:`1px solid ${x.warnBorder}`,borderRadius:ie.control,padding:`${I.xs} ${I.md}`,fontSize:z.body}),N.appendChild(m)}const A=l.ownerDocument.createElement("span");Object.assign(A.style,{display:"inline-flex",alignItems:"center",gap:I.sm,color:x.label,fontSize:z.body,flexWrap:"wrap"});const S=l.ownerDocument.createElement("span");S.dataset.wmapCaption="1",S.textContent=y?`Share of the dies failing either that fail both${c!==null?` \xB7 ${c.toLocaleString()} failing dies per pair (median)`:""} \xB7 click a cell to view that pair in scatter \xB7`:(c!==null?`Pearson r \xB7 n \u2248 ${c.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")+(b?` ${Qe} ${Ze} \xB7`:""),A.appendChild(S);const T=l.ownerDocument.createElement("span");Object.assign(T.style,{display:"inline-flex",alignItems:"center",gap:I.xs});const i=l.ownerDocument.createElement("span");i.textContent=y?"0":"\u22121";const _=l.ownerDocument.createElement("span");Object.assign(_.style,{display:"inline-block",width:"64px",height:"8px",borderRadius:ie.control,border:`1px solid ${x.menuBorder}`,background:y?`linear-gradient(to right, ${x.menuBg}, ${Q})`:`linear-gradient(to right, ${re}, ${x.menuBg}, ${Q})`});const P=l.ownerDocument.createElement("span");P.textContent=y?"1":"+1",T.append(i,_,P),A.appendChild(T),N.appendChild(A);const $=l.ownerDocument.createElement("span");if($.dataset.wmapCaption="1",Object.assign($.style,{color:x.value,fontSize:z.body,fontWeight:"500"}),y)$.textContent=a&&a.r>0?`Most shared failures: ${a.xLabel} \u2194 ${a.yLabel} (${Math.round(100*a.r)}% of the dies failing either fail both)`:"No two tests fail on the same dies";else if(e===0&&n===0)$.textContent=a?`No significant correlations found \u2014 strongest pair: ${a.xLabel} \u2194 ${a.yLabel} (r = ${a.r.toFixed(2)})`:"No significant correlations found";else{const m=[];e>0&&m.push(`${e} strong (|r| \u2265 0.7)`),n>0&&m.push(`${n} moderate (0.4\u20130.7)`);const U=e+n;let r=m.join(", ")+` pair${U!==1?"s":""} found`;u>0&&(r+=` \xB7 ${u} weak pair${u!==1?"s":""} not shown`),$.textContent=r}N.appendChild($)}function Se(e){if(D.innerHTML="",e.tests.length<2)return Ue(D,"Need at least two parametric tests for a correlation matrix."),()=>{};const n=l.ownerDocument.createElement("canvas");n.style.display="block",n.style.cursor="default",D.appendChild(n);const u=e.tests.length,a=r=>r.label.split(" (#")[0],o=Math.min(14,We(e.tests.map(r=>a(r).length))),c=o*6.5+8,w=10,b=Math.round(w*6.5*Math.sin(Math.PI/4))+14,k=14,A=28,S=44;let T=-1,i=-1;const _=96;function P(r){const f=Math.max(0,r-c),p=Math.floor(f/u);if(!Ve(l))return Math.max(k,Math.min(S,p));const s=Math.floor((ze(l,D,n)-b-4)/u);return Math.max(k,Math.min(_,p,s))}const $=new Map;for(const r of e.cells){let f=$.get(r.yIndex);f||(f=[],$.set(r.yIndex,f)),f.push(r)}function m(){const r=qe(l),f=ee(r.bg)??[255,255,255],p=D.clientWidth,s=P(p),V=s*u,M=b+s*u+4,W=c+V,B=Je(n,l,W,M);if(!B)return;const{ctx:t}=B;t.font=`${pe(-1)}px system-ui, sans-serif`,t.fillStyle=r.text,e.tests.forEach((O,C)=>{const L=a(O),H=L.length>w?`${L.slice(0,w-1)}\u2026`:L,oe=c+C*s+s/2;t.save(),t.translate(oe,b-4),t.rotate(-Math.PI/4),t.textAlign="left",t.textBaseline="bottom",t.fillStyle=C===T?r.text:r.textMuted,t.fillText(H,0,0),t.restore()}),e.tests.forEach((O,C)=>{const L=a(O),H=b+C*s,oe=H+s/2;t.font=`${pe(-1)}px system-ui, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=C===i?r.text:r.textMuted,t.fillText(L.length>o?`${L.slice(0,o-1)}\u2026`:L,c-4,oe),($.get(C)??[]).forEach(he=>{const se=he.xIndex,q=c+se*s,Ie=se===T&&C===i,ue=se===C,J=he.r;if(J===null){t.fillStyle=r.border,t.globalAlpha=.4,t.fillRect(q+1,H+1,s-2,s-2),t.globalAlpha=1;return}let le=r.bgHover;ue?t.fillStyle=r.bgHover:(le=$e(J>=0?Q:re,f,Math.abs(J)),t.fillStyle=le),t.fillRect(q+1,H+1,s-2,s-2),s>=A&&!ue&&(t.font=`${Math.min(10,s*.35)}px system-ui, sans-serif`,t.fillStyle=tt(le),t.textAlign="center",t.textBaseline="middle",t.fillText(J.toFixed(2),q+s/2,H+s/2)),Ie&&(t.strokeStyle=r.text,t.lineWidth=2,t.strokeRect(q+1,H+1,s-2,s-2),t.lineWidth=1)})}),t.strokeStyle=r.bg,t.lineWidth=1;for(let O=0;O<=u;O++){const C=c+O*s;t.beginPath(),t.moveTo(C,b),t.lineTo(C,b+u*s),t.stroke();const L=b+O*s;t.beginPath(),t.moveTo(c,L),t.lineTo(c+u*s,L),t.stroke()}}function U(r){const f=n.getBoundingClientRect(),p=D.clientWidth,s=P(p),V=(r.clientX-f.left)*(n.width/be(n)/f.width),M=(r.clientY-f.top)*(n.height/be(n)/f.height),W=Math.floor((V-c)/s),B=Math.floor((M-b)/s);return W>=0&&W<u&&B>=0&&B<u?{xi:W,yi:B}:null}return n.addEventListener("mousemove",r=>{const f=U(r);if(!f){R.style.display="none",n.style.cursor="default";return}const{xi:p,yi:s}=f,V=p===s;n.style.cursor=V||!X?"default":"pointer";const M=e.cells.find(t=>t.xIndex===p&&t.yIndex===s),W=e.tests[p].label,B=e.tests[s].label;V?R.innerHTML=`<strong>${Z(W)}</strong>`:M?.r!==null&&M?.r!==void 0?R.innerHTML=`<strong>${Z(a(e.tests[s]))}</strong> (#${e.tests[s].testNumber}) vs <strong>${Z(a(e.tests[p]))}</strong> (#${e.tests[p].testNumber})<br>${y?`${(100*M.r).toFixed(0)}% of the dies failing either fail both \xB7 ${M.n.toLocaleString()} fail either`:`r = ${M.r.toFixed(4)} \xB7 n = ${M.n.toLocaleString()}`}${X?"<br><em>click to view in scatter</em>":""}`:R.innerHTML=`${Z(`${B} vs ${W}`)}<br><em>insufficient data</em>`,R.style.display="block",Pe(R,l,r.clientX,r.clientY)}),n.addEventListener("mouseleave",()=>{R.style.display="none"}),n.addEventListener("click",r=>{const f=U(r);if(!f||!X)return;const{xi:p,yi:s}=f;p!==s&&(T=p,i=s,m(),X(e.tests[p].testNumber,e.tests[s].testNumber))}),m}let fe=null;function G(){const e=ve(),n=!y&&de&&j===null&&!!d.groups,u=n?ke(d.groups.map(i=>i.items.flatMap(_=>_.dies??[])),v):e.flatMap(i=>i.dies??[]),a=y?De(u,v):Re(u,v),{matrix:o,strongPairs:c,moderatePairs:w,hiddenWeakPairs:b,strongestPair:k}=Ae(a,{minTests:6,maxTests:K}),A=n||y?[]:Be(e,{facetableOnly:!0}).filter(i=>i.splittable).map(i=>i.label),S=o.cells.filter(i=>i.xIndex!==i.yIndex).map(i=>i.n).sort((i,_)=>i-_),T=S.length?S[Math.floor(S.length/2)]:null;fe=o,Ee(c,w,b,k,A,T,a,o.tests.some(i=>i.derived)),ne=Se(o),ne()}const Te=Ye(l,()=>ne());return G(),{card:l,destroy:()=>Te.disconnect()}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Rgb = [number, number, number];
|
|
2
|
+
/** The colour at `t` in [0, 1] on the signed scale (blue below, warm above), where 0.5 is zero. */
|
|
3
|
+
export declare const divergingRgb: (t: number) => Rgb;
|
|
4
|
+
export declare const divergingColor: (t: number) => string;
|
|
5
|
+
/** The colour at `t` on the rating scale (vermillion for bad to blue for good). */
|
|
6
|
+
export declare const ratingRgb: (t: number) => Rgb;
|
|
7
|
+
/** The gradients only a plot offers, beside the map's own (`listValueColorSchemes`). */
|
|
8
|
+
export declare const PLOT_GRADIENTS: ReadonlyArray<{
|
|
9
|
+
name: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* The colour of a value at `t` in [0, 1] of a plot's key. `scheme` is a name from `PLOT_GRADIENTS` or a map gradient;
|
|
14
|
+
* unset, a value rescaled around zero (`diverging`) takes the signed scale, a rating (a yield, a pass rate) the rating
|
|
15
|
+
* scale, and any other the map's default. `reversed` flips the key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function plotGradient(scheme: string | undefined, reversed: boolean | undefined, diverging: boolean | undefined, rating?: boolean): (t: number) => string;
|
|
18
|
+
/** Whether dark text reads better than white on `rgb` (WCAG relative luminance: the crossover of the two contrasts). */
|
|
19
|
+
export declare const darkTextOn: (rgb: Rgb) => boolean;
|
|
20
|
+
/** Whether dark text reads better on a CSS colour (`rgb(...)` or `#rgb`/`#rrggbb`); white when the colour cannot be read. */
|
|
21
|
+
export declare function darkTextOnColor(color: string): boolean;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=divergingScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{registerValueColorScheme as f,resolveValueColorFn as b}from"../../renderer/colorSchemes.js";import{SIGNED_HIGH as x,SIGNED_LOW as p}from"./palette.js";const c=n=>[parseInt(n.slice(1,3),16),parseInt(n.slice(3,5),16),parseInt(n.slice(5,7),16)],s=[247,247,247],l=(n,e,r)=>[n[0]+(e[0]-n[0])*r,n[1]+(e[1]-n[1])*r,n[2]+(e[2]-n[2])*r],g=c(p),u=c(x),I=[g,l(g,s,.5),s,l(u,s,.5),u],h=[[213,94,0],[230,159,0],[240,228,66],[86,180,233],[0,114,178]];function d(n,e){const r=Math.min(1,Math.max(0,Number.isFinite(e)?e:.5))*(n.length-1),t=Math.min(n.length-2,Math.floor(r)),i=r-t,o=n[t],a=n[t+1];return[o[0]+(a[0]-o[0])*i,o[1]+(a[1]-o[1])*i,o[2]+(a[2]-o[2])*i]}const m=([n,e,r])=>`rgb(${Math.round(n)}, ${Math.round(e)}, ${Math.round(r)})`;export const divergingRgb=n=>d(I,n),divergingColor=n=>m(divergingRgb(n)),ratingRgb=n=>d(h,n),PLOT_GRADIENTS=[{name:"diverging",label:"Blue to orange, around zero"},{name:"rating",label:"Rating: orange-red to blue (colour-blind safe)"}];f("diverging",{label:PLOT_GRADIENTS[0].label,forValue:divergingColor});export function plotGradient(n,e,r,t){const i=n??(r?"diverging":t?"rating":void 0),o=i==="diverging"?divergingColor:i==="rating"?a=>m(ratingRgb(a)):b(i);return e?a=>o(1-a):o}function N([n,e,r]){const t=i=>{const o=i/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*t(n)+.7152*t(e)+.0722*t(r)}export const darkTextOn=n=>N(n)>.179;export function darkTextOnColor(n){const e=/^rgba?\(\s*(\d+(?:\.\d+)?)[ ,]+(\d+(?:\.\d+)?)[ ,]+(\d+(?:\.\d+)?)/i.exec(n);if(e)return darkTextOn([Number(e[1]),Number(e[2]),Number(e[3])]);const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n.trim());if(!r)return!1;const t=r[1].length===3?[...r[1]].map(i=>i+i).join(""):r[1];return darkTextOn([parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)])}
|