refactor: use idiomatic D3 selections for series rendering#262
Closed
nponeccop wants to merge 2 commits into
Closed
refactor: use idiomatic D3 selections for series rendering#262nponeccop wants to merge 2 commits into
nponeccop wants to merge 2 commits into
Conversation
Replace imperative DOM manipulation with declarative D3 selection methods to make the codebase more idiomatic and maintainable. Changes: - Series interface now stores D3 Selection objects instead of raw DOM nodes - SeriesRenderer uses selection.attr() instead of element.setAttribute() - Performance optimizations maintained (WeakMap caching still prevents redundant DOM updates) - All dependent code updated to call .node() when raw DOM access is needed - Tests updated to work with D3 selections Benefits: - More idiomatic D3 code that follows standard patterns - Better maintainability for developers familiar with D3 - Type-safe selection operations throughout - Consistent API using D3 methods - Performance characteristics preserved Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Deploy Preview for endearing-pothos-ca88dc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
The updateNode function expects raw DOM elements, not D3 selections. Updated test expectations to call .node() on selections before passing to updateNode mock. Also added url option to JSDOM constructor to enable localStorage support, which is required by d3-zoom. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors series rendering to use idiomatic D3 selection methods instead of imperative DOM manipulation, making the codebase more maintainable while preserving all performance optimizations.
Changes
Selectionobjects instead of raw DOM nodespath: SVGPathElement→path: Selection<SVGPathElement, ...>view: SVGGElement→view: Selection<SVGGElement, ...>selection.attr()instead ofelement.setAttribute().node()when raw DOM access is neededBenefits
✅ More idiomatic D3 code following standard patterns
✅ Better maintainability for developers familiar with D3
✅ Type-safe selection operations throughout
✅ Consistent API using D3 methods
✅ Performance characteristics preserved (60 FPS target maintained)
Test Results
render.refresh.test.ts(localStorage issue unrelated to changes)Files Modified
svg-time-series/src/chart/render.ts- Updated Series interfacesvg-time-series/src/chart/render/utils.ts- Updated createSeriesNodessvg-time-series/src/chart/seriesRenderer.ts- Changed to use.attr()methodsvg-time-series/test/chart/seriesRenderer.test.ts- Updated for selectionssvg-time-series/test/chart/render.test.ts- Updated for selectionssvg-time-series/test/chart/render.integration.test.ts- Fixed test assertionssamples/test/LegendController.test.ts- Updated for selections🤖 Generated with Claude Code