nv.utils.windowSize=function(){var size={width:640,height:480};if(document.body&&document.body.offsetWidth){size.width=document.body.offsetWidth;size.height=document.body.offsetHeight;}
if(document.compatMode=='CSS1Compat'&&document.documentElement&&document.documentElement.offsetWidth){size.width=document.documentElement.offsetWidth;size.height=document.documentElement.offsetHeight;}
if(window.innerWidth&&window.innerHeight){size.width=window.innerWidth;size.height=window.innerHeight;}
return(size);};nv.utils.windowResize=function(fun){if(fun===undefined)return;var oldresize=window.onresize;window.onresize=function(e){if(typeof oldresize=='function')oldresize(e);fun(e);}}
nv.utils.getColor=function(color){if(!arguments.length)return nv.utils.defaultColor();if(Object.prototype.toString.call(color)==='[object Array]')
return function(d,i){return d.color||color[i%color.length];};else
return color;}
nv.utils.defaultColor=function(){var colors=d3.scale.category20().range();return function(d,i){return d.color||colors[i%colors.length]};}
nv.utils.customTheme=function(dictionary,getKey,defaultColors){getKey=getKey||function(series){return series.key};defaultColors=defaultColors||d3.scale.category20().range();var defIndex=defaultColors.length;return function(series,index){var key=getKey(series);if(!defIndex)defIndex=defaultColors.length;if(typeof dictionary[key]!=="undefined")
return(typeof dictionary[key]==="function")?dictionary[key]():dictionary[key];else
return defaultColors[--defIndex];}}
nv.utils.pjax=function(links,content){d3.selectAll(links).on("click",function(){history.pushState(this.href,this.textContent,this.href);load(this.href);d3.event.preventDefault();});function load(href){d3.html(href,function(fragment){var target=d3.select(content).node();target.parentNode.replaceChild(d3.select(fragment).select(content).node(),target);nv.utils.pjax(links,content);});}
d3.select(window).on("popstate",function(){if(d3.event.state)load(d3.event.state);});}
nv.utils.calcApproxTextWidth=function(svgTextElem){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 0;};nv.utils.NaNtoZero=function(n){if(typeof n!=='number'||isNaN(n)||n===null||n===Infinity)return 0;return n;};nv.utils.optionsFunc=function(args){if(args){d3.map(args).forEach((function(key,value){if(typeof this[key]==="function"){this[key](value);}}).bind(this));}
return this;};