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

255
Vistas
d3.select element gives null when accessing in vuejs

I am trying to re-write below code in vuejs.

var tooltipLine = d3.select('#groupG').append('line')

var x = d3.time.scale().range([0, that.width]);
x.domain([that.graphData[0].soldOn, that.graphData[that.graphData.length - 1].soldOn]);

const date = x.invert(d3.mouse(tooltipBox.node())[0]);
            
tooltipLine.attr('stroke', 'black')
    .attr('x1', (Math.ceil(x(date)/that.barWidth) * (that.barWidth/2)) + (Math.floor(x(date)/that.barWidth) * (that.barWidth/2)))
    .attr('x2', (Math.ceil(x(date)/that.barWidth) * (that.barWidth/2)) + (Math.floor(x(date)/that.barWidth) * (that.barWidth/2)))
    .attr('y1', 0)
    .attr('y2', that.height);

In Vuejs (in template section)

<line stroke="none" id="tooltip-line" :x1="x1" :x2="x2" y1="0" :y2="height"></line>

computed: {
    x1() {
        var x = d3.time.scale().range([0, this.width]);
        x.domain([this.graphData[0].soldOn, this.graphData[this.graphData.length - 1].soldOn]);
        
        console.log("Tooltip Line", this.tooltipLine); //this leads to null
        const date = x.invert(d3.mouse(this.tooltipRect.node())[0]);
        return (Math.ceil(x(date)/this.barWidth) * (this.barWidth/2)) + (Math.floor(x(date)/this.barWidth) * (this.barWidth/2));
    }
}

Please check below output:

Tooltip in vuejs d3.select('#tooltip-line') gives null Tooltip in vuejs

Tooltip in JS d3.select('#groupG').append('line') gives line object Tooltip in JS

about 4 years ago · Juan Pablo Isaza
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