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

127
Vistas
how to create DOM structure in d3

I am very new to d3, JS I need to create below DOM structure as part of assignment <svg id="svg1"> <g id= "container"> containing plot elements <g id="bars"> containing bars < g id ="x_axis"> x axis I wrote something like below code and not able to pass the test case

Any suggestions on what am I doing wrong in created required DOM structure

var svg = d3.select("body").append("svg")
.attr("id","svg1")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);

var g = svg.append("g")
.attr("id","container")
.attr("transform","translate(" + margin.left + "," + margin.top + ")")

var bars = g.append("bar")
.attr("id","bars")
.attr("transform","translate(" + margin.left + "," + margin.top + ")");


g.selectAll("rect")
.data(dataset)
.enter()
.append("rect")
.attr("id","rects")
.attr("class", "bar")
.style("fill", function(d){ return d.tot})
.attr("x", function(d) { return x(d.Year); })
.attr("y", function(d) { return y(d.tot); })
.attr("width", (wi`enter code here`dth/dataset.length)*0.5-0.4)
.attr("height", function(d) { return height - y(d.tot); });
`
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