liprec / powerbi-d3jsvisual

Home of the code of my Power BI Custom Visual: D3JS Visual
MIT License
57 stars 20 forks source link

SVG not resizing with the PBI visual #1

Closed rdg27 closed 6 years ago

rdg27 commented 6 years ago

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")

liprec commented 6 years ago

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.

liprec commented 6 years ago

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