From bebc9f5d4f3af7622f18b3cefe648aea0733cd65 Mon Sep 17 00:00:00 2001 From: David Souther Date: Fri, 6 Dec 2013 15:57:31 -0500 Subject: [PATCH 1/2] Update nvd3 d3 dependency to ~, so no conflicts with packages who also require d3 at a newer 3.3 version. --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index ae4cdcb..0cdfda2 100644 --- a/bower.json +++ b/bower.json @@ -18,7 +18,7 @@ ], "license": "Apache License, v2.0", "dependencies": { - "d3": "3.3.5" + "d3": "~3.3.5" }, "ignore" : [ "**/.*", From b8b06c75a44ec5c282127d20c3fc70580439104d Mon Sep 17 00:00:00 2001 From: Robin Hu Date: Mon, 16 Dec 2013 13:26:00 -0500 Subject: [PATCH 2/2] Made a fix to calcApproxTextWidth, to fix bug on IE9. --- nv.d3.js | 11 ++++++----- src/utils.js | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nv.d3.js b/nv.d3.js index a1a9dfc..a066df1 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -971,15 +971,16 @@ nv.utils.pjax = function(links, content) { } /* For situations where we want to approximate the width in pixels for an SVG:text element. -Most common instance is when the element is in a display:none; container. +Most common instance is when the element is in a display:none; container. Forumla is : text.length * font-size * constant_factor */ nv.utils.calcApproxTextWidth = function (svgTextElem) { - if (svgTextElem instanceof d3.selection) { + if (typeof svgTextElem.style === 'function' + && typeof svgTextElem.text === 'function') { var fontSize = parseInt(svgTextElem.style("font-size").replace("px","")); var textLength = svgTextElem.text().length; - return textLength * fontSize * 0.5; + return textLength * fontSize * 0.5; } return 0; }; @@ -987,8 +988,8 @@ nv.utils.calcApproxTextWidth = function (svgTextElem) { /* Numbers that are undefined, null or NaN, convert them to zeros. */ nv.utils.NaNtoZero = function(n) { - if (typeof n !== 'number' - || isNaN(n) + if (typeof n !== 'number' + || isNaN(n) || n === null || n === Infinity) return 0; diff --git a/src/utils.js b/src/utils.js index 7b99e1d..13e848f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -105,15 +105,16 @@ nv.utils.pjax = function(links, content) { } /* For situations where we want to approximate the width in pixels for an SVG:text element. -Most common instance is when the element is in a display:none; container. +Most common instance is when the element is in a display:none; container. Forumla is : text.length * font-size * constant_factor */ nv.utils.calcApproxTextWidth = function (svgTextElem) { - if (svgTextElem instanceof d3.selection) { + if (typeof svgTextElem.style === 'function' + && typeof svgTextElem.text === 'function') { var fontSize = parseInt(svgTextElem.style("font-size").replace("px","")); var textLength = svgTextElem.text().length; - return textLength * fontSize * 0.5; + return textLength * fontSize * 0.5; } return 0; }; @@ -121,8 +122,8 @@ nv.utils.calcApproxTextWidth = function (svgTextElem) { /* Numbers that are undefined, null or NaN, convert them to zeros. */ nv.utils.NaNtoZero = function(n) { - if (typeof n !== 'number' - || isNaN(n) + if (typeof n !== 'number' + || isNaN(n) || n === null || n === Infinity) return 0;