First, this: Resize svg when window is resized in d3.js is not what I'm looking for.
My graph width is defined as the following few functions:
var element = document.getElementById('front'),
style = window.getComputedStyle(element),
divWidth = parseInt(style.getPropertyValue('width'), 10),
divHeight = parseInt(style.getPropertyValue('height'), 10);
window.onresize = function() {
divWidth = parseInt(style.getPropertyValue('width'), 10),
divHeight = parseInt(style.getPropertyValue('height'), 10);
};
var margin = {top: 20, right: 40, bottom: 90, left: 40},
width = divWidth - margin.left - margin.right,
height = divHeight - margin.top - margin.bottom;
Which works perfectly when the page is generated. As you can see, the variable is dynamically updated as the screen gets shifted. What I want to know is how to update the width of the chart at the same time as the variable gets reassigned.
Link and source for the project: Cards
An additional question after reading up some more: What is the best way to do the alternative to window.resize
with a div in place of the window.
EDIT: Found a great div resize tool: http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/