Skip to content

refactor: use D3 .raise() for element reordering#263

Merged
streamcode9 merged 1 commit into
streamcode9:masterfrom
nponeccop:refactor/idiomatic-d3-raise-method
Feb 10, 2026
Merged

refactor: use D3 .raise() for element reordering#263
streamcode9 merged 1 commit into
streamcode9:masterfrom
nponeccop:refactor/idiomatic-d3-raise-method

Conversation

@nponeccop

@nponeccop nponeccop commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace vanilla appendChild() calls with idiomatic D3 .raise() method
  • Improves code clarity by using declarative D3 API instead of mixing D3 selections with DOM manipulation

Changes

Updated svg-time-series/src/draw.ts in the resetData() method:

  • Replaced svgNode.appendChild() calls with .raise() on D3 selections
  • Removed intermediate DOM node variable and null checks
  • Net reduction: 3 lines of code

Benefits

  • More idiomatic D3: Uses D3's built-in .raise() method for z-order management
  • Better expresses intent: "Bring to front" vs "append to parent"
  • Same performance: .raise() internally performs the same operation
  • Continues refactoring trend: Builds on recent commits (#521450a, #29a245b) toward more idiomatic D3 patterns

Testing

✅ All 233 tests pass (43 test files)
✅ TypeScript type checking passes
✅ Lint and format checks pass

Test plan

  • Run full test suite: npm test
  • Manual verification: Start dev server and test resetZoom functionality in demo1.html/demo2.html
  • Verify zoom and brush interactions still work after reset

🤖 Generated with Claude Code

Replace vanilla appendChild() calls with idiomatic D3 .raise() method
when reordering zoom overlay and brush layer elements after resetData().

This change:
- Uses D3's declarative API instead of mixing D3 selections with DOM APIs
- Better expresses intent (bring to front vs append)
- Maintains same performance and behavior
- Continues refactoring toward more idiomatic D3 patterns

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Feb 9, 2026

Copy link
Copy Markdown

Deploy Preview for endearing-pothos-ca88dc ready!

Name Link
🔨 Latest commit c22b4ab
🔍 Latest deploy log https://app.netlify.com/projects/endearing-pothos-ca88dc/deploys/698a51995a90be0007a9a433
😎 Deploy Preview https://deploy-preview-263--endearing-pothos-ca88dc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@streamcode9 streamcode9 merged commit 5326c1c into streamcode9:master Feb 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants