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