Merge branch 'master' into development

master
Robin Hu 11 years ago
commit 37ca61f8d1

@ -18,7 +18,7 @@
],
"license": "Apache License, v2.0",
"dependencies": {
"d3": "3.3.5"
"d3": "~3.3.5"
},
"ignore" : [
"**/.*",

@ -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;

@ -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;

Loading…
Cancel
Save