Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda