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

121
Views
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
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!