[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BKP8HC740QZ2W39BAXH9SS":3,"skill-same:01M7BKP8HC740QZ2W39BAXH9SS":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BKP8HC740QZ2W39BAXH9SS","d3-visualization",null,"Build deterministic, verifiable data visualizations with D3.js (v6). Generate standalone HTML\u002FSVG (and optional PNG) from local data files without external network dependencies. Use when tasks require charts, plots, axes\u002Fscales, legends, tooltips, or data-driven SVG output.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: d3-visualization\ndescription: Build deterministic, verifiable data visualizations with D3.js (v6). Generate standalone HTML\u002FSVG (and optional PNG) from local data files without external network dependencies. Use when tasks require charts, plots, axes\u002Fscales, legends, tooltips, or data-driven SVG output.\n---\n\n# D3.js Visualization Skill\n\nUse this skill to turn structured data (CSV\u002FTSV\u002FJSON) into **clean, reproducible** visualizations using **D3.js**. The goal is to produce **stable outputs** that can be verified by diffing files or hashing.\n\n## When to use\n\nActivate this skill when the user asks for any of the following:\n\n- “Make a chart\u002Fplot\u002Fgraph\u002Fvisualization”\n- bar\u002Fline\u002Fscatter\u002Farea\u002Fhistogram\u002Fbox\u002Fviolin\u002Fheatmap\n- timelines, small multiples, faceting\n- axis ticks, scales, legends, tooltips\n- data-driven SVG output for a report or web page\n- converting data to a static SVG or HTML visualization\n\nIf the user only needs a quick table or summary, **don’t** use D3—use a spreadsheet or plain markdown instead.\n\n---\n\n## Inputs you should expect\n\n- One or more local data files: `*.csv`, `*.tsv`, `*.json`\n- A chart intent:\n  - chart type (or you infer the best type)\n  - x\u002Fy fields and aggregation rules\n  - sorting\u002Ffiltering rules\n  - dimensions (width\u002Fheight) and margins\n  - color rules (categorical \u002F sequential)\n  - any labeling requirements (title, axis labels, units)\n- Output constraints:\n  - “static only”, “no animation”, “must be deterministic”, “offline”, etc.\n\nIf details are missing, **make reasonable defaults** and document them in comments near the top of the output file.\n\n---\n\n## Outputs you should produce\n\nPrefer producing **all of** the following when feasible:\n\n1. `dist\u002Fchart.html` — standalone HTML that renders the visualization\n2. `dist\u002Fchart.svg` — exported SVG (stable and diff-friendly)\n3. (Optional) `dist\u002Fchart.png` — if the task explicitly needs a raster image\n\nAlways keep outputs in a predictable folder (default: `dist\u002F`), unless the task specifies paths.\n\n---\n\n## Determinism rules (non-negotiable)\n\nTo keep results stable across runs and machines:\n\n### Data determinism\n- **Sort** input rows deterministically before binding to marks (e.g., by x then by category).\n- Use stable grouping order (explicit `Array.from(grouped.keys()).sort()`).\n- Avoid locale-dependent formatting unless fixed (use `d3.format`, `d3.timeFormat` with explicit formats).\n\n### Rendering determinism\n- **No randomness**: do not use `Math.random()` or `d3-random`.\n- **No transitions\u002Fanimations** by default (transitions can introduce timing variance).\n- **Fixed** `width`, `height`, `margin`, `viewBox`.\n- Use **explicit tick counts** only when needed; otherwise rely on D3 defaults but keep domains fixed.\n- Avoid layout algorithms with non-deterministic iteration unless you control seeds\u002Fiterations (e.g., force simulation). If a force layout is required:\n  - fix the tick count,\n  - fix initial positions deterministically (e.g., sorted nodes placed on a grid),\n  - run exactly N ticks and stop.\n\n### Offline + dependency determinism\n- Do **not** load D3 from a CDN.\n- Pin D3 to a specific version that matches the task requirement (default: **D3 v6**, e.g. **d3@6.7.0**).\n- Prefer vendoring a minified D3 bundle (e.g., `vendor\u002Fd3.v6.min.js` or `vendor\u002Fd3.v6.7.0.min.js`) or bundling with a lockfile.\n\n### File determinism\n- Stable SVG output:\n  - Avoid auto-generated IDs that may change.\n  - If you must use IDs (clipPath, gradients), derive them from stable strings (e.g., `\"clip-plot\"`).\n- Use LF line endings.\n- Keep numeric precision consistent (e.g., round to 2–4 decimals if needed).\n\n---\n\n## Recommended project layout\n\nIf the task doesn't specify an existing structure, use:\n\n```\ndist\u002F\n  chart.html        # standalone HTML with inline or linked JS\u002FCSS\n  chart.svg         # exported SVG (optional but nice)\n  chart.png         # rasterized (optional)\nvendor\u002F\n  d3.v6.min.js      # pinned D3 v6 library (or d3.v6.x.y.min.js)\n```\n\n---\n\n## Legends (categorical color scales)\n\nTasks that color marks by a categorical field (e.g., sector, category, group) should include a **legend that lists every category present in the bound data**.\n\n### Legend rules for correctness + determinism\n\n- Build the legend entries from the **same domain** used by your color scale (usually `colorScale.domain()`).\n- Derive the categorical domain from the **full dataset** (before filtering for size\u002Ftooltip\u002Fvisibility). Example pitfall: if you size bubbles only for rows with `marketCap`, you must still include rows without `marketCap` when computing the sector list so the legend stays complete.\n- Ensure the domain includes **all rows**, including items that may have missing values for other fields (e.g., points without a size metric still have a category and should still be shown in the legend).\n- If some rows have missing\u002Fblank category values, map them to a stable placeholder (e.g., `\"Unknown\"`) so they still render deterministically and are accounted for.\n- Make the domain order deterministic:\n  - `Array.from(new Set(values)).sort(d3.ascending)`\n- If the number of categories exceeds a fixed palette (e.g., 10), use a palette generator (e.g., `d3.quantize(d3.interpolateRainbow, n)`) so the legend can still list all categories.\n- Keep legend labels as the **raw category strings** (avoid adding counts or abbreviations) unless the task explicitly asks for that.\n\n### Minimal categorical legend pattern\n\nUse stable class names so downstream checks\u002Ftests can reliably locate the legend.\n\n```js\n\u002F\u002F categories MUST match the color scale domain exactly.\nconst categories = colorScale.domain();\n\nconst legend = svg.append('g')\n  .attr('class', 'legend')\n  .attr('transform', 'translate(20,20)');\n\nlegend.append('text')\n  .attr('class', 'legend-title')\n  .attr('x', 0)\n  .attr('y', 0)\n  .attr('dy', '0.8em')\n  .style('font-weight', '600')\n  .text('Category');\n\nconst items = legend.selectAll('g.legend-item')\n  .data(categories, d => d)\n  .join('g')\n  .attr('class', 'legend-item')\n  .attr('transform', (d, i) => `translate(0, ${20 + i * 16})`);\n\nitems.append('rect')\n  .attr('class', 'legend-swatch')\n  .attr('width', 12)\n  .attr('height', 12)\n  .attr('rx', 2)\n  .attr('ry', 2)\n  .attr('fill', d => colorScale(d));\n\nitems.append('text')\n  .attr('class', 'legend-label')\n  .attr('x', 16)\n  .attr('y', 6)\n  .attr('dy', '0.35em')\n  .style('font-size', '12px')\n  .text(d => d);\n```\n\n#### Legend acceptance checklist (manual)\n\n- The legend exists and is visible without scrolling the page.\n- The legend has **one entry per unique category in the data** (no “top N” truncation).\n- Categories are not accidentally dropped because other fields are missing.\n- The swatch color matches the marks’ fill color.\n\n---\n\n## Interactive features (tooltips, click handlers, hover effects)\n\nWhen the task requires interactivity (e.g., tooltips on hover, click to highlight):\n\n### Tooltip pattern (recommended)\n\n1. **Create a tooltip element** in HTML:\n```html\n\u003Cdiv id=\"tooltip\" class=\"tooltip\">\u003C\u002Fdiv>\n```\n\n2. **Style with CSS** using `.visible` class for show\u002Fhide:\n```css\n.tooltip {\n    position: absolute;\n    padding: 10px;\n    background: rgba(0, 0, 0, 0.8);\n    color: white;\n    border-radius: 4px;\n    pointer-events: none;  \u002F* Prevent mouse interference *\u002F\n    opacity: 0;\n    transition: opacity 0.2s;\n    z-index: 1000;\n}\n\n.tooltip.visible {\n    opacity: 1;  \u002F* Show when .visible class is added *\u002F\n}\n```\n\n3. **Add event handlers** to SVG elements:\n```javascript\nsvg.selectAll('circle')\n    .on('mouseover', function(event, d) {\n        d3.select('#tooltip')\n            .classed('visible', true)  \u002F\u002F Add .visible class\n            .html(`\u003Cstrong>${d.name}\u003C\u002Fstrong>\u003Cbr\u002F>${d.value}`)\n            .style('left', (event.pageX + 10) + 'px')\n            .style('top', (event.pageY - 10) + 'px');\n    })\n    .on('mouseout', function() {\n        d3.select('#tooltip').classed('visible', false);  \u002F\u002F Remove .visible class\n    });\n```\n\n**Key points:**\n- Use `opacity: 0` by default (not `display: none`) for smooth transitions\n- Use `.classed('visible', true\u002Ffalse)` to toggle visibility\n- `pointer-events: none` prevents tooltip from blocking mouse events\n- Position tooltip relative to mouse with `event.pageX\u002FpageY`\n\n### Click handlers for selection\u002Fhighlighting\n\n```javascript\n\u002F\u002F Add 'selected' class on click\nsvg.selectAll('.bar')\n    .on('click', function(event, d) {\n        \u002F\u002F Remove previous selection\n        d3.selectAll('.bar').classed('selected', false);\n        \u002F\u002F Add to clicked element\n        d3.select(this).classed('selected', true);\n    });\n```\n\nCSS for highlighting:\n```css\n.bar.selected {\n    stroke: #000;\n    stroke-width: 3px;\n}\n```\n\n#### Composite marks (e.g., bubble + label): keep clicks\u002Fhover working\n\nIf you draw a **shape** (e.g., `\u003Ccircle>`) and then a **text label** on top, the label can accidentally block mouse events **or** become unclickable depending on how you handle pointer events.\n\nPrefer solutions that make **both** the shape and the label reliably interactive (this matters for automated checks that click the label element).\n\nTwo safe patterns:\n\n**Pattern A — attach the same handlers to both shape and label** (max compatibility):\n```javascript\nfunction onSelect(event, d) {\n  setSelected(d.id);\n}\n\nconst node = svg.selectAll('g.node')\n  .data(data, d => d.id)\n  .join('g')\n  .attr('class', 'node')\n  .style('cursor', 'pointer');\n\nnode.append('circle')\n  .attr('r', d => d.r)\n  .on('click', onSelect);\n\nnode.append('text')\n  .text(d => d.label)\n  .attr('text-anchor', 'middle')\n  .attr('dy', '0.35em')\n  .on('click', onSelect);\n```\n\n**Pattern B — attach handlers to the parent `\u003Cg>`** (clean) and keep the label clickable:\n```javascript\nconst node = svg.selectAll('g.node')\n  .data(data, d => d.id)\n  .join('g')\n  .attr('class', 'node')\n  .style('cursor', 'pointer');\n\n\u002F\u002F Use bubbling events like click\u002Fmouseover so events from the circle\u002Ftext reach the \u003Cg>.\nnode.on('click', (event, d) => setSelected(d.id));\n```\n\nIf you use `mouseenter`\u002F`mouseleave` (which do **not** bubble), attach them to the actual interactive element(s) (e.g., the circle and text) or use `mouseover`\u002F`mouseout` on the parent `\u003Cg>`.\n\nAvoid relying solely on `pointer-events: none` for labels when the requirement says “click the label”, because some test runners will attempt to click the label element directly.\n\n#### Two-way linking (chart ↔ table) with a single selection state\n\nWhen a task requires **bidirectional selection** (click bubble → highlight row, click row → highlight bubble), use **one shared selection key** and update both views from one place.\n\nMinimal pattern:\n```javascript\nlet selectedId = null;\n\nfunction setSelected(id) {\n  selectedId = id;\n  bubbles.classed('selected', d => d.id === selectedId);\n  rows.classed('selected', d => d.id === selectedId);\n}\n\nbubbles.on('click', (event, d) => setSelected(d.id));\nrows.on('click', (event, d) => setSelected(d.id));\n```\n\nEvent-bus pattern (useful when chart and table live in different files):\n```javascript\nvar SELECTION_EVENT = 'd3vis:selected'; \u002F\u002F shared event type across files (use `var` in non-module scripts to avoid redeclare errors)\n\nfunction emitSelect(id) {\n  window.dispatchEvent(new CustomEvent(SELECTION_EVENT, { detail: { id } }));\n}\n\nwindow.addEventListener(SELECTION_EVENT, (e) => {\n  const id = e.detail?.id;\n  bubbles.classed('selected', d => d.id === id);\n  rows.classed('selected', d => d.id === id);\n});\n\nbubbles.on('click', (event, d) => emitSelect(d.id));\nrows.on('click', (event, d) => emitSelect(d.id));\n```\n\n#### Interactivity acceptance checklist (manual)\n\nBefore shipping, verify these behaviors in the browser:\n- Clicking **the shape or its label text** selects the item (label overlay must not block clicks).\n- Exactly one item is selected at a time (previous selection clears).\n- Selecting in the chart highlights the corresponding table row **immediately**, and selecting in the table highlights the corresponding chart mark.\n- Interactive marks use `cursor: pointer` and selection styling is visible (e.g., stroke on bubbles, background on rows).\n\n### Conditional interactivity\n\nSometimes only certain elements should be interactive:\n```javascript\n.on('mouseover', function(event, d) {\n    \u002F\u002F Example: Don't show tooltip for certain categories\n    if (d.category === 'excluded') {\n        return;  \u002F\u002F Exit early, no tooltip\n    }\n    \u002F\u002F Show tooltip for others\n    showTooltip(event, d);\n})\n```\n\n---\n","# D3.js Visualization Skill\n\nUse this skill to turn structured data (CSV\u002FTSV\u002FJSON) into **clean, reproducible** visualizations using **D3.js**. The goal is to produce **stable outputs** that can be verified by diffing files or hashing.\n\n## When to use\n\nActivate this skill when the user asks for any of the following:\n\n- “Make a chart\u002Fplot\u002Fgraph\u002Fvisualization”\n- bar\u002Fline\u002Fscatter\u002Farea\u002Fhistogram\u002Fbox\u002Fviolin\u002Fheatmap\n- timelines, small multiples, faceting\n- axis ticks, scales, legends, tooltips\n- data-driven SVG output for a report or web page\n- converting data to a static SVG or HTML visualization\n\nIf the user only needs a quick table or summary, **don’t** use D3—use a spreadsheet or plain markdown instead.\n\n---\n\n## Inputs you should expect\n\n- One or more local data files: `*.csv`, `*.tsv`, `*.json`\n- A chart intent:\n  - chart type (or you infer the best type)\n  - x\u002Fy fields and aggregation rules\n  - sorting\u002Ffiltering rules\n  - dimensions (width\u002Fheight) and margins\n  - color rules (categorical \u002F sequential)\n  - any labeling requirements (title, axis labels, units)\n- Output constraints:\n  - “static only”, “no animation”, “must be deterministic”, “offline”, etc.\n\nIf details are missing, **make reasonable defaults** and document them in comments near the top of the output file.\n\n---\n\n## Outputs you should produce\n\nPrefer producing **all of** the following when feasible:\n\n1. `dist\u002Fchart.html` — standalone HTML that renders the visualization\n2. `dist\u002Fchart.svg` — exported SVG (stable and diff-friendly)\n3. (Optional) `dist\u002Fchart.png` — if the task explicitly needs a raster image\n\nAlways keep outputs in a predictable folder (default: `dist\u002F`), unless the task specifies paths.\n\n---\n\n## Determinism rules (non-negotiable)\n\nTo keep results stable across runs and machines:\n\n### Data determinism\n- **Sort** input rows deterministically before binding to marks (e.g., by x then by category).\n- Use stable grouping order (explicit `Array.from(grouped.keys()).sort()`).\n- Avoid locale-dependent formatting unless fixed (use `d3.format`, `d3.timeFormat` with explicit formats).\n\n### Rendering determinism\n- **No randomness**: do not use `Math.random()` or `d3-random`.\n- **No transitions\u002Fanimations** by default (transitions can introduce timing variance).\n- **Fixed** `width`, `height`, `margin`, `viewBox`.\n- Use **explicit tick counts** only when needed; otherwise rely on D3 defaults but keep domains fixed.\n- Avoid layout algorithms with non-deterministic iteration unless you control seeds\u002Fiterations (e.g., force simulation). If a force layout is required:\n  - fix the tick count,\n  - fix initial positions deterministically (e.g., sorted nodes placed on a grid),\n  - run exactly N ticks and stop.\n\n### Offline + dependency determinism\n- Do **not** load D3 from a CDN.\n- Pin D3 to a specific version that matches the task requirement (default: **D3 v6**, e.g. **d3@6.7.0**).\n- Prefer vendoring a minified D3 bundle (e.g., `vendor\u002Fd3.v6.min.js` or `vendor\u002Fd3.v6.7.0.min.js`) or bundling with a lockfile.\n\n### File determinism\n- Stable SVG output:\n  - Avoid auto-generated IDs that may change.\n  - If you must use IDs (clipPath, gradients), derive them from stable strings (e.g., `\"clip-plot\"`).\n- Use LF line endings.\n- Keep numeric precision consistent (e.g., round to 2–4 decimals if needed).\n\n---\n\n## Recommended project layout\n\nIf the task doesn't specify an existing structure, use:\n\n```\ndist\u002F\n  chart.html        # standalone HTML with inline or linked JS\u002FCSS\n  chart.svg         # exported SVG (optional but nice)\n  chart.png         # rasterized (optional)\nvendor\u002F\n  d3.v6.min.js      # pinned D3 v6 library (or d3.v6.x.y.min.js)\n```\n\n---\n\n## Legends (categorical color scales)\n\nTasks that color marks by a categorical field (e.g., sector, category, group) should include a **legend that lists every category present in the bound data**.\n\n### Legend rules for correctness + determinism\n\n- Build the legend entries from the **same domain** used by your color scale (usually `colorScale.domain()`).\n- Derive the categorical domain from the **full dataset** (before filtering for size\u002Ftooltip\u002Fvisibility). Example pitfall: if you size bubbles only for rows with `marketCap`, you must still include rows without `marketCap` when computing the sector list so the legend stays complete.\n- Ensure the domain includes **all rows**, including items that may have missing values for other fields (e.g., points without a size metric still have a category and should still be shown in the legend).\n- If some rows have missing\u002Fblank category values, map them to a stable placeholder (e.g., `\"Unknown\"`) so they still render deterministically and are accounted for.\n- Make the domain order deterministic:\n  - `Array.from(new Set(values)).sort(d3.ascending)`\n- If the number of categories exceeds a fixed palette (e.g., 10), use a palette generator (e.g., `d3.quantize(d3.interpolateRainbow, n)`) so the legend can still list all categories.\n- Keep legend labels as the **raw category strings** (avoid adding counts or abbreviations) unless the task explicitly asks for that.\n\n### Minimal categorical legend pattern\n\nUse stable class names so downstream checks\u002Ftests can reliably locate the legend.\n\n```js\n\u002F\u002F categories MUST match the color scale domain exactly.\nconst categories = colorScale.domain();\n\nconst legend = svg.append('g')\n  .attr('class', 'legend')\n  .attr('transform', 'translate(20,20)');\n\nlegend.append('text')\n  .attr('class', 'legend-title')\n  .attr('x', 0)\n  .attr('y', 0)\n  .attr('dy', '0.8em')\n  .style('font-weight', '600')\n  .text('Category');\n\nconst items = legend.selectAll('g.legend-item')\n  .data(categories, d => d)\n  .join('g')\n  .attr('class', 'legend-item')\n  .attr('transform', (d, i) => `translate(0, ${20 + i * 16})`);\n\nitems.append('rect')\n  .attr('class', 'legend-swatch')\n  .attr('width', 12)\n  .attr('height', 12)\n  .attr('rx', 2)\n  .attr('ry', 2)\n  .attr('fill', d => colorScale(d));\n\nitems.append('text')\n  .attr('class', 'legend-label')\n  .attr('x', 16)\n  .attr('y', 6)\n  .attr('dy', '0.35em')\n  .style('font-size', '12px')\n  .text(d => d);\n```\n\n#### Legend acceptance checklist (manual)\n\n- The legend exists and is visible without scrolling the page.\n- The legend has **one entry per unique category in the data** (no “top N” truncation).\n- Categories are not accidentally dropped because other fields are missing.\n- The swatch color matches the marks’ fill color.\n\n---\n\n## Interactive features (tooltips, click handlers, hover effects)\n\nWhen the task requires interactivity (e.g., tooltips on hover, click to highlight):\n\n### Tooltip pattern (recommended)\n\n1. **Create a tooltip element** in HTML:\n```html\n\u003Cdiv id=\"tooltip\" class=\"tooltip\">\u003C\u002Fdiv>\n```\n\n2. **Style with CSS** using `.visible` class for show\u002Fhide:\n```css\n.tooltip {\n    position: absolute;\n    padding: 10px;\n    background: rgba(0, 0, 0, 0.8);\n    color: white;\n    border-radius: 4px;\n    pointer-events: none;  \u002F* Prevent mouse interference *\u002F\n    opacity: 0;\n    transition: opacity 0.2s;\n    z-index: 1000;\n}\n\n.tooltip.visible {\n    opacity: 1;  \u002F* Show when .visible class is added *\u002F\n}\n```\n\n3. **Add event handlers** to SVG elements:\n```javascript\nsvg.selectAll('circle')\n    .on('mouseover', function(event, d) {\n        d3.select('#tooltip')\n            .classed('visible', true)  \u002F\u002F Add .visible class\n            .html(`\u003Cstrong>${d.name}\u003C\u002Fstrong>\u003Cbr\u002F>${d.value}`)\n            .style('left', (event.pageX + 10) + 'px')\n            .style('top', (event.pageY - 10) + 'px');\n    })\n    .on('mouseout', function() {\n        d3.select('#tooltip').classed('visible', false);  \u002F\u002F Remove .visible class\n    });\n```\n\n**Key points:**\n- Use `opacity: 0` by default (not `display: none`) for smooth transitions\n- Use `.classed('visible', true\u002Ffalse)` to toggle visibility\n- `pointer-events: none` prevents tooltip from blocking mouse events\n- Position tooltip relative to mouse with `event.pageX\u002FpageY`\n\n### Click handlers for selection\u002Fhighlighting\n\n```javascript\n\u002F\u002F Add 'selected' class on click\nsvg.selectAll('.bar')\n    .on('click', function(event, d) {\n        \u002F\u002F Remove previous selection\n        d3.selectAll('.bar').classed('selected', false);\n        \u002F\u002F Add to clicked element\n        d3.select(this).classed('selected', true);\n    });\n```\n\nCSS for highlighting:\n```css\n.bar.selected {\n    stroke: #000;\n    stroke-width: 3px;\n}\n```\n\n#### Composite marks (e.g., bubble + label): keep clicks\u002Fhover working\n\nIf you draw a **shape** (e.g., `\u003Ccircle>`) and then a **text label** on top, the label can accidentally block mouse events **or** become unclickable depending on how you handle pointer events.\n\nPrefer solutions that make **both** the shape and the label reliably interactive (this matters for automated checks that click the label element).\n\nTwo safe patterns:\n\n**Pattern A — attach the same handlers to both shape and label** (max compatibility):\n```javascript\nfunction onSelect(event, d) {\n  setSelected(d.id);\n}\n\nconst node = svg.selectAll('g.node')\n  .data(data, d => d.id)\n  .join('g')\n  .attr('class', 'node')\n  .style('cursor', 'pointer');\n\nnode.append('circle')\n  .attr('r', d => d.r)\n  .on('click', onSelect);\n\nnode.append('text')\n  .text(d => d.label)\n  .attr('text-anchor', 'middle')\n  .attr('dy', '0.35em')\n  .on('click', onSelect);\n```\n\n**Pattern B — attach handlers to the parent `\u003Cg>`** (clean) and keep the label clickable:\n```javascript\nconst node = svg.selectAll('g.node')\n  .data(data, d => d.id)\n  .join('g')\n  .attr('class', 'node')\n  .style('cursor', 'pointer');\n\n\u002F\u002F Use bubbling events like click\u002Fmouseover so events from the circle\u002Ftext reach the \u003Cg>.\nnode.on('click', (event, d) => setSelected(d.id));\n```\n\nIf you use `mouseenter`\u002F`mouseleave` (which do **not** bubble), attach them to the actual interactive element(s) (e.g., the circle and text) or use `mouseover`\u002F`mouseout` on the parent `\u003Cg>`.\n\nAvoid relying solely on `pointer-events: none` for labels when the requirement says “click the label”, because some test runners will attempt to click the label element directly.\n\n#### Two-way linking (chart ↔ table) with a single selection state\n\nWhen a task requires **bidirectional selection** (click bubble → highlight row, click row → highlight bubble), use **one shared selection key** and update both views from one place.\n\nMinimal pattern:\n```javascript\nlet selectedId = null;\n\nfunction setSelected(id) {\n  selectedId = id;\n  bubbles.classed('selected', d => d.id === selectedId);\n  rows.classed('selected', d => d.id === selectedId);\n}\n\nbubbles.on('click', (event, d) => setSelected(d.id));\nrows.on('click', (event, d) => setSelected(d.id));\n```\n\nEvent-bus pattern (useful when chart and table live in different files):\n```javascript\nvar SELECTION_EVENT = 'd3vis:selected'; \u002F\u002F shared event type across files (use `var` in non-module scripts to avoid redeclare errors)\n\nfunction emitSelect(id) {\n  window.dispatchEvent(new CustomEvent(SELECTION_EVENT, { detail: { id } }));\n}\n\nwindow.addEventListener(SELECTION_EVENT, (e) => {\n  const id = e.detail?.id;\n  bubbles.classed('selected', d => d.id === id);\n  rows.classed('selected', d => d.id === id);\n});\n\nbubbles.on('click', (event, d) => emitSelect(d.id));\nrows.on('click', (event, d) => emitSelect(d.id));\n```\n\n#### Interactivity acceptance checklist (manual)\n\nBefore shipping, verify these behaviors in the browser:\n- Clicking **the shape or its label text** selects the item (label overlay must not block clicks).\n- Exactly one item is selected at a time (previous selection clears).\n- Selecting in the chart highlights the corresponding table row **immediately**, and selecting in the table highlights the corresponding chart mark.\n- Interactive marks use `cursor: pointer` and selection styling is visible (e.g., stroke on bubbles, background on rows).\n\n### Conditional interactivity\n\nSometimes only certain elements should be interactive:\n```javascript\n.on('mouseover', function(event, d) {\n    \u002F\u002F Example: Don't show tooltip for certain categories\n    if (d.category === 'excluded') {\n        return;  \u002F\u002F Exit early, no tooltip\n    }\n    \u002F\u002F Show tooltip for others\n    showTooltip(event, d);\n})\n```\n\n---\n",{"name":5,"description":7},"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","controlled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill d3-visualization",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill d3-visualization",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill d3-visualization","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002FSKILL.md",true,[45,51,55,59],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"scripts\u002Fbubble_chart_example.js","SCRIPT","脚本",7907,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002Fscripts\u002Fbubble_chart_example.js",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"scripts\u002Fcheck_tooltip.js",1752,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002Fscripts\u002Fcheck_tooltip.js",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"scripts\u002Finteractive_table_example.js",5047,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002Fscripts\u002Finteractive_table_example.js",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"scripts\u002Ftooltip_handler.js",5919,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fcontrolled-skill-repair-experiments\u002Fresult\u002Fskillhone-gpt5.2-xhigh\u002Fcandidates\u002Flocation-data-to-d3\u002Fround-4\u002Fskills\u002Fd3-visualization\u002Fscripts\u002Ftooltip_handler.js",[64,71,78,85,90,95],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":86,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":91,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":96,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]