user3063604
user3063604

Reputation: 41

Adding scrollbar to see full contents of SVG d3.js

I start learning d3.js recently. I am facing the problem that my graph is out of the assigned SVG and it is being cut off. I have tried style my graph-div with overflow:auto/overflow:scroll property but it does not seem to work

Is there any different ways to dynamically resize the SVG so I can scroll down the page too see full contents?Could anyone please provide any hints?

Regards

Upvotes: 1

Views: 1981

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

You can resize the SVG by setting its height and width:

svg.attr("height", newHeight).attr("width", newWidth);

You have to compute the dimensions of the SVG yourself though. That is, D3 doesn't provide any functionality to fit the size of a container to its contents.

Upvotes: 1

Related Questions