Skip to content

Instantly share code, notes, and snippets.

@carolina-vallejo
Created May 30, 2017 16:59
Show Gist options
  • Save carolina-vallejo/ca8ef3c2cfeddcb496ccdc9810724c84 to your computer and use it in GitHub Desktop.
Save carolina-vallejo/ca8ef3c2cfeddcb496ccdc9810724c84 to your computer and use it in GitHub Desktop.
get width in d3
console.log('<br>Computed style width as pixels: ');
console.log(node.style('width'));
console.log('<br>Computed style width as a number: ');
console.log(parseFloat(node.style('width')));
console.log('<br>As a percent: ');
console.log(node.node().style.width);
console.log('<br>Actual width as number: ');
console.log(node.node().offsetWidth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment