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

178
Views
D3 Js resize svg from exisiting example

I want to create an D3 Js gantt chart for the first time. I found a pretty good example which fits my expectations https://dk8996.github.io/Gantt-Chart/ (Example2). But I have problem resizing the svg. I want to fit the example into my d3 container which has a fixed height and width. The buttons of the example can just be copy/pasted into my code. But the SVG is always generated at the bottom of my code/site.

<div class="Card-body">
  <div id="d3-container">
    //HERE
  </div>  
</div>

I tried a few things but I just dont know how to do this. The example is always taking the whole screen. How can I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The SVG by your Gantt chart library is always added to the document body element. If you want to change that you would need to replace line 16 and additional two lines (22 and 23) in https://github.com/dk8996/Gantt-Chart/blob/master/gantt-chart-d3.js file - e.g. download it to your computer and reference it from your index.html file locally, not from Gannt-Chart library URL - to

var selector = '#d3-container';
...
var height = document.getElementById("d3-container").clientHeight - margin.top - margin.bottom-5;
var width = document.getElementById("d3-container").clientWidth - margin.right - margin.left-5;

so that SVG will then be created in your DIV container.

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