Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
refactoring d3 js code from v5.16 to v6.6.2, d3.event breaking change

New to d3 and fixing an error. I am working with a js file using the d3 library. The following line of code does not error out in v5.16:

    function br(d) {
        let s = d3.event.selection || xScaleSelector.range()
        let extent = s.map(xScaleSelector.invert, xScaleSelector);
        let window = data.filter(d => d.date >= extent[0] && d.date <= extent[1])
        update(window)
    }

However, when migrating to v6.6.2 and above, I get an error. The error I am getting is on line: let s = d3.event.selection || xScaleSelector.range() with the following error: Uncaught TypeError: Cannot read properties of undefined (reading 'selection').

The origin of the error, according to https://github.com/d3/d3/releases/tag/v6.0.0, v6.0.0 has removed the d3.event. (d3.event is undefined in v6). Can someone help suggest what changes I can make to fix this error when migrating to >= v6?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Please try:

function br(d) {
    let s = d.selection || xScaleSelector.range()
    let extent = s.map(xScaleSelector.invert, xScaleSelector);
    let window = data.filter(d => d.date >= extent[0] && d.date <= extent[1])
    update(window)
}

Per the migration guide here

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!