feat: add D3.js charting library support via maidr/d3 binder#551
feat: add D3.js charting library support via maidr/d3 binder#551jooyoungseo wants to merge 3 commits intomainfrom
Conversation
Add a JavaScript binder that extracts data from D3.js-rendered SVG charts and generates the MAIDR JSON schema for accessible chart interaction. Supported chart types: - Bar charts (bindD3Bar) - Line charts, single and multi-line (bindD3Line) - Scatter plots (bindD3Scatter) - Heatmaps (bindD3Heatmap) - Box plots (bindD3Box) - Histograms (bindD3Histogram) The binder leverages D3's __data__ property on DOM elements to extract bound data, and generates CSS selectors for SVG highlighting. Available as both ES module (maidr/d3) and UMD script tag (dist/d3.js). Closes #537 https://claude.ai/code/session_01XrcqYMsCcxfUwhLDpzEwr3
PR Review: D3.js Binder (#551)This is a well-conceived feature — bridging D3.js charts to MAIDR's accessibility layer fills an important gap. The documentation and examples are excellent. Below is a structured review of the issues I found. Critical Issues1.
|
- Fix resolveAccessor to throw on missing properties instead of returning undefined - Add resolveAccessorOptional for optional fields (outliers, fill, volume) - Remove extractBarDataFromDOM fallback that used pixel values as data - Fix bindLine pointSelector scoping bug with element deduplication Set - Fix heatmap: use nested Maps instead of composite string keys, throw on missing cells - Fix bindBox: use resolveAccessorOptional for outliers instead of try-catch - Standardize selectors format to string across all binders - Remove unused path aliases from vite.d3.config.ts - Add bindD3Candlestick for candlestick/OHLC charts - Add bindD3Segmented for stacked, dodged, and normalized bar charts - Add bindD3Smooth for smooth/regression curves - Add example HTML files for all new chart types https://claude.ai/code/session_01XrcqYMsCcxfUwhLDpzEwr3
PR Review: feat: add D3.js charting library support via maidr/d3 binderThis is a substantial and well-documented addition. The architecture is clean — a separate entry point ( That said, there are several issues ranging from potential bugs to missing coverage that should be addressed before merging. Bugs / Correctness1.
|
| Area | Status |
|---|---|
| Architecture / API design | Good |
| Documentation and examples | Good |
| Multi-line chart extraction | Bug — fix before merge |
| Empty selector handling | Missing guard |
| D3 stack layout compatibility | Needs clarification or fix |
| ID generation | Fragile — prefer crypto.randomUUID() |
| SSR / Node.js portability | CSS.escape issue |
| Test coverage | None — add before merge |
| Repeated axes helper | Minor refactor opportunity |
- Fix multi-line extraction: replace processedPoints Set with parent-based grouping (Pattern A: distinct parents) and fill-based grouping (Pattern B: shared parent) to correctly extract all lines - Fix generateSelector edge case: return tag name when element equals container instead of empty string - Add groupSelector option to bindD3Segmented for d3.stack() layouts where series live in <g> groups with .key datum property - Add empty selector guard: all binders now throw descriptive errors when CSS selector matches zero elements - Fix ID collision: use crypto.randomUUID() when available, with improved fallback using multiple random segments - Fix CSS.escape SSR compatibility: add cssEscape() wrapper that falls back to regex-based escaping in Node.js environments - Extract buildAxes() helper to eliminate duplicated axes construction pattern across all nine binders https://claude.ai/code/session_01XrcqYMsCcxfUwhLDpzEwr3
PR Review: feat: add D3.js charting library support via maidr/d3 binderThis is a well-structured, well-documented feature that fills an important gap for D3.js users. The architecture is consistent across all binders, the JSDoc is excellent, and the error messages are helpful. Here is a detailed review with findings organized by severity. Architecture & DesignStrengths:
Concern:
Bugs & IssuesMedium — Legend extraction in
|
| Category | Status |
|---|---|
| Code structure and API design | Good |
| Documentation and JSDoc | Excellent |
| Error messages | Good |
| Type safety | Minor gaps (outlier validation, group key coercion) |
| Edge case handling | Legend extraction, NaN yMax |
| Test coverage | Missing |
| Build configuration | Good (one minor question) |
The implementation is solid and ready for integration with a few targeted fixes. The missing tests are the most pressing concern — the binders have enough conditional logic paths (line chart Pattern A/B, box plot child fallback, segmented flat vs grouped) that regressions could go undetected without them.
Add a JavaScript binder that extracts data from D3.js-rendered SVG charts
and generates the MAIDR JSON schema for accessible chart interaction.
Supported chart types:
The binder leverages D3's data property on DOM elements to extract
bound data, and generates CSS selectors for SVG highlighting. Available
as both ES module (maidr/d3) and UMD script tag (dist/d3.js).
Closes #537
https://claude.ai/code/session_01XrcqYMsCcxfUwhLDpzEwr3