nv.interactiveGuideline=function(){"use strict";var tooltip=nv.models.tooltip();var width=null,height=null,margin={left:0,top:0},xScale=d3.scale.linear(),yScale=d3.scale.linear(),dispatch=d3.dispatch('elementMousemove','elementMouseout','elementDblclick'),showGuideLine=true,svgContainer=null;var isMSIE=navigator.userAgent.indexOf("MSIE")!==-1;function layer(selection){selection.each(function(data){var container=d3.select(this);var availableWidth=(width||960),availableHeight=(height||400);var wrap=container.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([data]);var wrapEnter=wrap.enter().append("g").attr("class"," nv-wrap nv-interactiveLineLayer");wrapEnter.append("g").attr("class","nv-interactiveGuideLine");if(!svgContainer){return;}
function mouseHandler(){var d3mouse=d3.mouse(this);var mouseX=d3mouse[0];var mouseY=d3mouse[1];var subtractMargin=true;var mouseOutAnyReason=false;if(isMSIE){mouseX=d3.event.offsetX;mouseY=d3.event.offsetY;if(d3.event.target.tagName!=="svg")
subtractMargin=false;if(d3.event.target.className.baseVal.match("nv-legend"))
mouseOutAnyReason=true;}
if(subtractMargin){mouseX-=margin.left;mouseY-=margin.top;}
if(mouseX<0||mouseY<0||mouseX>availableWidth||mouseY>availableHeight||(d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined)||mouseOutAnyReason)
{if(isMSIE){if(d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined&&d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass)){return;}}
dispatch.elementMouseout({mouseX:mouseX,mouseY:mouseY});layer.renderGuideLine(null);return;}
var pointXValue=xScale.invert(mouseX);dispatch.elementMousemove({mouseX:mouseX,mouseY:mouseY,pointXValue:pointXValue});if(d3.event.type==="dblclick"){dispatch.elementDblclick({mouseX:mouseX,mouseY:mouseY,pointXValue:pointXValue});}}
svgContainer.on("mousemove",mouseHandler,true).on("mouseout",mouseHandler,true).on("dblclick",mouseHandler);layer.renderGuideLine=function(x){if(!showGuideLine)return;var line=wrap.select(".nv-interactiveGuideLine").selectAll("line").data((x!=null)?[nv.utils.NaNtoZero(x)]:[],String);line.enter().append("line").attr("class","nv-guideline").attr("x1",function(d){return d;}).attr("x2",function(d){return d;}).attr("y1",availableHeight).attr("y2",0);line.exit().remove();}});}
layer.dispatch=dispatch;layer.tooltip=tooltip;layer.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!='undefined'?_.top:margin.top;margin.left=typeof _.left!='undefined'?_.left:margin.left;return layer;};layer.width=function(_){if(!arguments.length)return width;width=_;return layer;};layer.height=function(_){if(!arguments.length)return height;height=_;return layer;};layer.xScale=function(_){if(!arguments.length)return xScale;xScale=_;return layer;};layer.showGuideLine=function(_){if(!arguments.length)return showGuideLine;showGuideLine=_;return layer;};layer.svgContainer=function(_){if(!arguments.length)return svgContainer;svgContainer=_;return layer;};return layer;};nv.interactiveBisect=function(values,searchVal,xAccessor){"use strict";if(!values instanceof Array)return null;if(typeof xAccessor!=='function')xAccessor=function(d,i){return d.x;}
var bisect=d3.bisector(xAccessor).left;var index=d3.max([0,bisect(values,searchVal)- 1]);var currentValue=xAccessor(values[index],index);if(typeof currentValue==='undefined')currentValue=index;if(currentValue===searchVal)return index;var nextIndex=d3.min([index+1,values.length- 1]);var nextValue=xAccessor(values[nextIndex],nextIndex);if(typeof nextValue==='undefined')nextValue=nextIndex;if(Math.abs(nextValue- searchVal)>=Math.abs(currentValue- searchVal))
return index;else
return nextIndex};nv.nearestValueIndex=function(values,searchVal,threshold){"use strict";var yDistMax=Infinity,indexToHighlight=null;values.forEach(function(d,i){var delta=Math.abs(searchVal- d);if(delta<=yDistMax&&delta<threshold){yDistMax=delta;indexToHighlight=i;}});return indexToHighlight;};