recalculate width and height
janwillemtulp opened this issue · comments
Jan Willem Tulp commented
It would be nice to have a function to update for instance the totalHeight or totalWidth on the conventions object, and so that the width and height are recalculated. Right now this is done for the initialization, but if you want to update these settings, this calculation is not done automatically
Adam Pearce commented
These functions would change the height
variable and attribute on the svg while leaving elements drawn at the old size intact? I'm not sure I understand the use case.
Typically we blow away the whole chart on resize:
drawChart()
d3.select(window).on('resize', drawChart)
function drawChart(){
var c = d3.conventions({parentSel: d3.select('#graph').html('')})
c.svg.appendMany(data, 'text')
.text(d => d.text)
.translate(d => [c.x(d.x), c.y(d.y)])
}
It'd be nicer to have smarter ways of updating... but it gets complicated pretty quick.