changing the size of the graph doesn't change the size of the SVG
See original GitHub issueDescribe the bug
Hi! This bug relates to the flamegraph.width
function [0].
In our application we added a resize
function to change the size of the flamegraph based on the size of its container. We’re using the flamegraph.width
function [0] and giving it a value based on the width of the container. What I’m noticing however is that if the graph is initialized at one size, and then the window size is increased, the graph gets cut off.
From a bit of debugging, it seems that the issue is the svg width is never updated after initialization. When the width is changed and the chart is redrawn, this line [1] gets hit, but because the svg exists already the following code that updates the dimensions is never reached. So if I opened a window at 800px width, resized it to 1000px, the graph displays at 1000px width but is cutoff because the svg is only 800px.
I can get around this by changing the svg width to be 100% from a stylesheet, but figured I’d bring this up anyways.
[0] https://github.com/spiermar/d3-flame-graph#width [1] https://github.com/spiermar/d3-flame-graph/blob/2.0.3/src/flamegraph.js#L489
To Reproduce Steps to reproduce the behavior:
Pre-req: needs an onresize
function that updates the flamegraph width via flamegraph.width()
with the new width of the container
- Draw a flamegraph
- Increase the size of the browser via dragging/etc.
- Notice that the chart is clipped
Expected behavior The svg width should update when the graph width is updated.
Screenshots In this image, the body is cyan, and the chart div is light green. After resizing larger, the frame is cutoff by the old width of the svg.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top GitHub Comments
@pradyunsg the change above implements both suggestions you made. Thank you.
Awesome. Thanks @spiermar! ^>^