liprec/powerbi-d3jsvisual

SVG not resizing with the PBI visual

Closed this issue · 2 comments

rdg27 commented

Loving this, but my visual wasn't resizing when the PBI visual was resized. It would be great if this happened automatically rather than having to be handled in the js.

My fix was just to add a couple of attributes to the #chart svg i.e.

d3.select("#chart")
.attr("viewBox", "0 0 " + width +" " + height)
.attr("preserveAspectRatio", "xMidYMid meet")

At this moment it is by design. The demo script I am using have the width and height assignment in the original D3.js code:

var svg = d3.select("#chart")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)

But it would make a nice enhancement.

I added the width and height to the SVG element during rendering.
This is now included in release v1.1.0