gka / d3-jetpack

🚀 Nifty convenience wrappers that speed up your daily work with d3.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

recalculate width and height

janwillemtulp opened this issue · comments

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

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.