Skip to content

Commit

Permalink
issue #12 exploration
Browse files Browse the repository at this point in the history
  • Loading branch information
cakey committed Oct 7, 2012
1 parent 26aed0c commit 0dcf831
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions infro.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ var infro = (function () {

["height", "width"].forEach(function(dim){
/* returns the height or width value set for the selection, and removes 'px' */
d3.selection.prototype[dim] = function() {
try{
return Number(this.empty()?0:(this[0][0].style.getPropertyValue(dim).slice(0,-2)) );
} catch(e){
d3.selection.prototype[dim] = function() {
if (this.empty()){
return 0;
}
for (var sel=0; sel<this.length; sel++){
if (this[sel].length > 0){
return this[sel][0].style.getPropertyValue(dim).slice(0, -2);
}
}
return 0;
};
});

Expand Down

0 comments on commit 0dcf831

Please sign in to comment.