You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvd3/nv.d3.min.js

8 lines
223 KiB
JavaScript

11 years ago
(function(){var nv=window.nv||{};nv.version="0.0.1a";nv.dev=true;window.nv=nv;nv.tooltip={};nv.utils={};nv.models={};nv.charts={};nv.graphs=[];nv.logs={};nv.dispatch=d3.dispatch("render_start","render_end");if(nv.dev){nv.dispatch.on("render_start",function(e){nv.logs.startTime=+new Date});nv.dispatch.on("render_end",function(e){nv.logs.endTime=+new Date;nv.logs.totalTime=nv.logs.endTime-nv.logs.startTime;nv.log("total",nv.logs.totalTime)})}nv.log=function(){if(nv.dev&&console.log&&console.log.apply)console.log.apply(console,arguments);else if(nv.dev&&console.log&&Function.prototype.bind){var log=Function.prototype.bind.call(console.log,console);log.apply(console,arguments)}return arguments[arguments.length-1]};nv.render=function render(step){step=step||1;nv.render.active=true;nv.dispatch.render_start();setTimeout(function(){var chart,graph;for(var i=0;i<step&&(graph=nv.render.queue[i]);i++){chart=graph.generate();if(typeof graph.callback==typeof Function)graph.callback(chart);nv.graphs.push(chart)}nv.render.queue.splice(0,i);if(nv.render.queue.length)setTimeout(arguments.callee,0);else{nv.render.active=false;nv.dispatch.render_end()}},0)};nv.render.active=false;nv.render.queue=[];nv.addGraph=function(obj){if(typeof arguments[0]===typeof Function)obj={generate:arguments[0],callback:arguments[1]};nv.render.queue.push(obj);if(!nv.render.active)nv.render()};nv.identity=function(d){return d};nv.strip=function(s){return s.replace(/(\s|&)/g,"")};function daysInMonth(month,year){return new Date(year,month+1,0).getDate()}function d3_time_range(floor,step,number){return function(t0,t1,dt){var time=floor(t0),times=[];if(time<t0)step(time);if(dt>1){while(time<t1){var date=new Date(+time);if(number(date)%dt===0)times.push(date);step(time)}}else{while(time<t1){times.push(new Date(+time));step(time)}}return times}}d3.time.monthEnd=function(date){return new Date(date.getFullYear(),date.getMonth(),0)};d3.time.monthEnds=d3_time_range(d3.time.monthEnd,function(date){date.setUTCDate(date.getUTCDate()+1);date.setDate(daysInMonth(date.getMonth()+1,date.getFullYear()))},function(date){return date.getMonth()});(function(){var nvtooltip=window.nv.tooltip={};nvtooltip.show=function(pos,content,gravity,dist,parentContainer,classes){var container=document.createElement("div");container.className="nvtooltip "+(classes?classes:"xy-tooltip");gravity=gravity||"s";dist=dist||20;var body=parentContainer;if(!parentContainer||parentContainer.tagName.match(/g|svg/i)){body=document.getElementsByTagName("body")[0]}container.innerHTML=content;container.style.left=0;container.style.top=0;container.style.opacity=0;body.appendChild(container);var height=parseInt(container.offsetHeight),width=parseInt(container.offsetWidth),windowWidth=nv.utils.windowSize().width,windowHeight=nv.utils.windowSize().height,scrollTop=window.scrollY,scrollLeft=window.scrollX,left,top;windowHeight=window.innerWidth>=document.body.scrollWidth?windowHeight:windowHeight-16;windowWidth=window.innerHeight>=document.body.scrollHeight?windowWidth:windowWidth-16;var tooltipTop=function(Elem){var offsetTop=top;do{if(!isNaN(Elem.offsetTop)){offsetTop+=Elem.offsetTop}}while(Elem=Elem.offsetParent);return offsetTop};var tooltipLeft=function(Elem){var offsetLeft=left;do{if(!isNaN(Elem.offsetLeft)){offsetLeft+=Elem.offsetLeft}}while(Elem=Elem.offsetParent);return offsetLeft};switch(gravity){case"e":left=pos[0]-width-dist;top=pos[1]-height/2;var tLeft=tooltipLeft(container);var tTop=tooltipTop(container);if(tLeft<scrollLeft)left=pos[0]+dist>scrollLeft?pos[0]+dist:scrollLeft-tLeft+left;if(tTop<scrollTop)top=scrollTop-tTop+top;if(tTop+height>scrollTop+windowHeight)top=scrollTop+windowHeight-tTop+top-height;break;case"w":left=pos[0]+dist;top=pos[1]-height/2;if(tLeft+width>windowWidth)left=pos[0]-width-dist;if(tTop<scrollTop)top=scrollTop+5;if(tTop+height>scrollTop+windowHeight)top=scrollTop-height-5;break;case"n":left=pos[0]-width/2-5;top=pos[1]+dist;var tLeft=tooltipLeft(container);var tTop=tooltipTop(container);if(tLeft<scrollLeft)left=scrollLeft+5;if(tLeft+width>windowWidth)left=left-width/2+5;if(tT
index.i=Math.round(dx.invert(index.x));state.index=index.i;dispatch.stateChange(state);updateZero()});lines.dispatch.on("elementClick",function(e){index.i=e.pointIndex;index.x=dx(index.i);state.index=index.i;dispatch.stateChange(state);updateZero()});controls.dispatch.on("legendClick",function(d,i){d.disabled=!d.disabled;rescaleY=!d.disabled;state.rescaleY=rescaleY;dispatch.stateChange(state);chart.update()});legend.dispatch.on("legendClick",function(d,i){d.disabled=!d.disabled;if(!data.filter(function(d){return!d.disabled}).length){data.map(function(d){d.disabled=false;wrap.selectAll(".nv-series").classed("disabled",false);return d})}state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});legend.dispatch.on("legendDblclick",function(d){data.forEach(function(d){d.disabled=true});d.disabled=false;state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});dispatch.on("tooltipShow",function(e){if(tooltips)showTooltip(e,that.parentNode)});dispatch.on("changeState",function(e){if(typeof e.disabled!=="undefined"){data.forEach(function(series,i){series.disabled=e.disabled[i]});state.disabled=e.disabled}if(typeof e.index!=="undefined"){index.i=e.index;index.x=dx(index.i);state.index=e.index;indexLine.data([index])}if(typeof e.rescaleY!=="undefined"){rescaleY=e.rescaleY}chart.update()})});return chart}lines.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});lines.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.lines=lines;chart.legend=legend;chart.xAxis=xAxis;chart.yAxis=yAxis;d3.rebind(chart,lines,"defined","isArea","x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id");chart.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!="undefined"?_.top:margin.top;margin.right=typeof _.right!="undefined"?_.right:margin.right;margin.bottom=typeof _.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof _.left!="undefined"?_.left:margin.left;return chart};chart.width=function(_){if(!arguments.length)return width;width=_;return chart};chart.height=function(_){if(!arguments.length)return height;height=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);legend.color(color);return chart};chart.rescaleY=function(_){if(!arguments.length)return rescaleY;rescaleY=_;return rescaleY};chart.showControls=function(_){if(!arguments.length)return showControls;showControls=_;return chart};chart.showLegend=function(_){if(!arguments.length)return showLegend;showLegend=_;return chart};chart.showXAxis=function(_){if(!arguments.length)return showXAxis;showXAxis=_;return chart};chart.showYAxis=function(_){if(!arguments.length)return showYAxis;showYAxis=_;return chart};chart.rightAlignYAxis=function(_){if(!arguments.length)return rightAlignYAxis;rightAlignYAxis=_;yAxis.orient(_?"right":"left");return chart};chart.tooltips=function(_){if(!arguments.length)return tooltips;tooltips=_;return chart};chart.tooltipContent=function(_){if(!arguments.length)return tooltip;tooltip=_;return chart};chart.state=function(_){if(!arguments.length)return state;state=_;return chart};chart.defaultState=function(_){if(!arguments.length)return defaultState;defaultState=_;return chart};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};chart.average=function(_){if(!arguments.length)return average;average=_;return chart};function indexify(idx,data){return data.map(function(line,i){if(!line.values){return line}var v=lines.y()(line.values[idx],idx);if(v<-.95){line.tempDisabled=true;return line}line.tempDisabled=false;line.values=line.values.map(function(point,pointIndex){point.display={y:(lines.y()(point,pointIndex)-v)/(1+v)};return point});return line})}return chart};nv.models.discreteBar=function(){var margin={top:0,right:0,bottom:0,left:0},
})}if(column.click)nodeName.select("span").on("click",column.click)});node.order().on("click",function(d){dispatch.elementClick({row:this,data:d,pos:[d.x,d.y]})}).on("dblclick",function(d){dispatch.elementDblclick({row:this,data:d,pos:[d.x,d.y]})}).on("mouseover",function(d){dispatch.elementMouseover({row:this,data:d,pos:[d.x,d.y]})}).on("mouseout",function(d){dispatch.elementMouseout({row:this,data:d,pos:[d.x,d.y]})});function click(d,_,unshift){d3.event.stopPropagation();if(d3.event.shiftKey&&!unshift){d3.event.shiftKey=false;d.values&&d.values.forEach(function(node){if(node.values||node._values){click(node,0,true)}});return true}if(!hasChildren(d)){return true}if(d.values){d._values=d.values;d.values=null}else{d.values=d._values;d._values=null}chart.update()}function icon(d){return d._values&&d._values.length?iconOpen:d.values&&d.values.length?iconClose:""}function folded(d){return d._values&&d._values.length}function hasChildren(d){var values=d.values||d._values;return values&&values.length}});return chart}chart.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!="undefined"?_.top:margin.top;margin.right=typeof _.right!="undefined"?_.right:margin.right;margin.bottom=typeof _.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof _.left!="undefined"?_.left:margin.left;return chart};chart.width=function(_){if(!arguments.length)return width;width=_;return chart};chart.height=function(_){if(!arguments.length)return height;height=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);scatter.color(color);return chart};chart.id=function(_){if(!arguments.length)return id;id=_;return chart};chart.header=function(_){if(!arguments.length)return header;header=_;return chart};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};chart.filterZero=function(_){if(!arguments.length)return filterZero;filterZero=_;return chart};chart.columns=function(_){if(!arguments.length)return columns;columns=_;return chart};chart.tableClass=function(_){if(!arguments.length)return tableClass;tableClass=_;return chart};chart.iconOpen=function(_){if(!arguments.length)return iconOpen;iconOpen=_;return chart};chart.iconClose=function(_){if(!arguments.length)return iconClose;iconClose=_;return chart};return chart};nv.models.legend=function(){var margin={top:5,right:0,bottom:5,left:0},width=400,height=20,getKey=function(d){return d.key},color=nv.utils.defaultColor(),align=true,dispatch=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");function chart(selection){selection.each(function(data){var availableWidth=width-margin.left-margin.right,container=d3.select(this);var wrap=container.selectAll("g.nv-legend").data([data]);var gEnter=wrap.enter().append("g").attr("class","nvd3 nv-legend").append("g");var g=wrap.select("g");wrap.attr("transform","translate("+margin.left+","+margin.top+")");var series=g.selectAll(".nv-series").data(function(d){return d});var seriesEnter=series.enter().append("g").attr("class","nv-series").on("mouseover",function(d,i){dispatch.legendMouseover(d,i)}).on("mouseout",function(d,i){dispatch.legendMouseout(d,i)}).on("click",function(d,i){dispatch.legendClick(d,i)}).on("dblclick",function(d,i){dispatch.legendDblclick(d,i)});seriesEnter.append("circle").style("stroke-width",2).attr("r",5);seriesEnter.append("text").attr("text-anchor","start").attr("dy",".32em").attr("dx","8");series.classed("disabled",function(d){return d.disabled});series.exit().remove();series.select("circle").style("fill",function(d,i){return d.color||color(d,i)}).style("stroke",function(d,i){return d.color||color(d,i)});series.select("text").text(getKey);if(align){var seriesWidths=[];series.each(function(d,i){var legendText=d3.select(this).select("text");var svgComputedTextLength=legendText.node().getComputedTextLength()||nv.utils.calcApproxTextWidth(legendText);seriesWidths.push(svgComputedTextLength+28)});var seriesPerRow=0;var legendWidth=0;var columnWidths=[];while(legendWidth<availableWidth&&seriesPerRow<seriesWidths.leng
})}}));d3.transition(focusLinesWrap).call(lines);d3.transition(g.select(".nv-focus .nv-x.nv-axis")).call(xAxis);d3.transition(g.select(".nv-focus .nv-y.nv-axis")).call(yAxis)}});return chart}lines.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});lines.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.legend=legend;chart.lines=lines;chart.lines2=lines2;chart.xAxis=xAxis;chart.yAxis=yAxis;chart.x2Axis=x2Axis;chart.y2Axis=y2Axis;d3.rebind(chart,lines,"defined","isArea","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id");chart.x=function(_){if(!arguments.length)return lines.x;lines.x(_);lines2.x(_);return chart};chart.y=function(_){if(!arguments.length)return lines.y;lines.y(_);lines2.y(_);return chart};chart.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!="undefined"?_.top:margin.top;margin.right=typeof _.right!="undefined"?_.right:margin.right;margin.bottom=typeof _.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof _.left!="undefined"?_.left:margin.left;return chart};chart.margin2=function(_){if(!arguments.length)return margin2;margin2=_;return chart};chart.width=function(_){if(!arguments.length)return width;width=_;return chart};chart.height=function(_){if(!arguments.length)return height;height=_;return chart};chart.height2=function(_){if(!arguments.length)return height2;height2=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);legend.color(color);return chart};chart.showLegend=function(_){if(!arguments.length)return showLegend;showLegend=_;return chart};chart.tooltips=function(_){if(!arguments.length)return tooltips;tooltips=_;return chart};chart.tooltipContent=function(_){if(!arguments.length)return tooltip;tooltip=_;return chart};chart.interpolate=function(_){if(!arguments.length)return lines.interpolate();lines.interpolate(_);lines2.interpolate(_);return chart};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};chart.xTickFormat=function(_){if(!arguments.length)return xAxis.tickFormat();xAxis.tickFormat(_);x2Axis.tickFormat(_);return chart};chart.yTickFormat=function(_){if(!arguments.length)return yAxis.tickFormat();yAxis.tickFormat(_);y2Axis.tickFormat(_);return chart};return chart};nv.models.linePlusBarWithFocusChart=function(){var lines=nv.models.line(),lines2=nv.models.line(),bars=nv.models.historicalBar(),bars2=nv.models.historicalBar(),xAxis=nv.models.axis(),x2Axis=nv.models.axis(),y1Axis=nv.models.axis(),y2Axis=nv.models.axis(),y3Axis=nv.models.axis(),y4Axis=nv.models.axis(),legend=nv.models.legend(),brush=d3.svg.brush();var margin={top:30,right:30,bottom:30,left:60},margin2={top:0,right:30,bottom:20,left:60},width=null,height=null,height2=100,getX=function(d){return d.x},getY=function(d){return d.y},color=nv.utils.defaultColor(),showLegend=true,extent,brushExtent=null,tooltips=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" at "+x+"</p>"},x,x2,y1,y2,y3,y4,noData="No Data Available.",dispatch=d3.dispatch("tooltipShow","tooltipHide","brush");lines.clipEdge(true);lines2.interactive(false);xAxis.orient("bottom").tickPadding(5);y1Axis.orient("left");y2Axis.orient("right");x2Axis.orient("bottom").tickPadding(5);y3Axis.orient("left");y4Axis.orient("right");var showTooltip=function(e,offsetElement){if(extent){e.pointIndex+=Math.ceil(extent[0])}var left=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(lines.x()(e.point,e.pointIndex)),y=(e.series.bar?y1Axis:y2Axis).tickFormat()(lines.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,e.value<0?"n":"s",null,offsetElement)};function chart(selection){selection.each(function(data){var container=d3.select(this),that=this;var availableWidth=(width||parseInt(container.style("width"))|
if(stacked)data=d3.layout.stack().offset("zero").values(function(d){return d.values}).y(getY)(data);data=data.map(function(series,i){series.values=series.values.map(function(point){point.series=i;return point});return series});if(stacked)data[0].values.map(function(d,i){var posBase=0,negBase=0;data.map(function(d){var f=d.values[i];f.size=Math.abs(f.y);if(f.y<0){f.y1=negBase-f.size;negBase=negBase-f.size}else{f.y1=posBase;posBase=posBase+f.size}})});var seriesData=xDomain&&yDomain?[]:data.map(function(d){return d.values.map(function(d,i){return{x:getX(d,i),y:getY(d,i),y0:d.y0,y1:d.y1}})});x.domain(xDomain||d3.merge(seriesData).map(function(d){return d.x})).rangeBands([0,availableHeight],.1);y.domain(yDomain||d3.extent(d3.merge(seriesData).map(function(d){return stacked?d.y>0?d.y1+d.y:d.y1:d.y}).concat(forceY)));if(showValues&&!stacked)y.range([y.domain()[0]<0?valuePadding:0,availableWidth-(y.domain()[1]>0?valuePadding:0)]);else y.range([0,availableWidth]);x0=x0||x;y0=y0||d3.scale.linear().domain(y.domain()).range([y(0),y(0)]);var wrap=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([data]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal");var defsEnter=wrapEnter.append("defs");var gEnter=wrapEnter.append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-groups");wrap.attr("transform","translate("+margin.left+","+margin.top+")");var groups=wrap.select(".nv-groups").selectAll(".nv-group").data(function(d){return d},function(d){return d.key});groups.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6);d3.transition(groups.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove();groups.attr("class",function(d,i){return"nv-group nv-series-"+i}).classed("hover",function(d){return d.hover}).style("fill",function(d,i){return color(d,i)}).style("stroke",function(d,i){return color(d,i)});d3.transition(groups).style("stroke-opacity",1).style("fill-opacity",.75);var bars=groups.selectAll("g.nv-bar").data(function(d){return d.values});bars.exit().remove();var barsEnter=bars.enter().append("g").attr("transform",function(d,i,j){return"translate("+y0(stacked?d.y0:0)+","+(stacked?0:j*x.rangeBand()/data.length+x(getX(d,i)))+")"});barsEnter.append("rect").attr("width",0).attr("height",x.rangeBand()/(stacked?1:data.length));bars.on("mouseover",function(d,i){d3.select(this).classed("hover",true);dispatch.elementMouseover({value:getY(d,i),point:d,series:data[d.series],pos:[y(getY(d,i)+(stacked?d.y0:0)),x(getX(d,i))+x.rangeBand()*(stacked?data.length/2:d.series+.5)/data.length],pointIndex:i,seriesIndex:d.series,e:d3.event})}).on("mouseout",function(d,i){d3.select(this).classed("hover",false);dispatch.elementMouseout({value:getY(d,i),point:d,series:data[d.series],pointIndex:i,seriesIndex:d.series,e:d3.event})}).on("click",function(d,i){dispatch.elementClick({value:getY(d,i),point:d,series:data[d.series],pos:[x(getX(d,i))+x.rangeBand()*(stacked?data.length/2:d.series+.5)/data.length,y(getY(d,i)+(stacked?d.y0:0))],pointIndex:i,seriesIndex:d.series,e:d3.event});d3.event.stopPropagation()}).on("dblclick",function(d,i){dispatch.elementDblClick({value:getY(d,i),point:d,series:data[d.series],pos:[x(getX(d,i))+x.rangeBand()*(stacked?data.length/2:d.series+.5)/data.length,y(getY(d,i)+(stacked?d.y0:0))],pointIndex:i,seriesIndex:d.series,e:d3.event});d3.event.stopPropagation()});barsEnter.append("text");if(showValues&&!stacked){bars.select("text").attr("text-anchor",function(d,i){return getY(d,i)<0?"end":"start"}).attr("y",x.rangeBand()/(data.length*2)).attr("dy",".32em").text(function(d,i){return valueFormat(getY(d,i))});d3.transition(bars).select("text").attr("x",function(d,i){return getY(d,i)<0?-4:y(getY(d,i))-y(0)+4})}else{bars.selectAll("text").text("")}bars.attr("class",function(d,i){return getY(d,i)<0?"nv-bar negative":"nv-bar positive"});if(barColor){if(!disabled)disabled=data.map(function(){return true});bars.style("fill",function(d,i,j){return d3.rgb(barColor(d,i)).darker(disabled.map(function(d,i){return i}).filter(function(d,i){retur
});var slices=wrap.select(".nv-pie").selectAll(".nv-slice").data(pie);slices.exit().remove();var ae=slices.enter().append("g").attr("class","nv-slice").on("mouseover",function(d,i){d3.select(this).classed("hover",true);dispatch.elementMouseover({label:getX(d.data),value:getY(d.data),point:d.data,pointIndex:i,pos:[d3.event.pageX,d3.event.pageY],id:id})}).on("mouseout",function(d,i){d3.select(this).classed("hover",false);dispatch.elementMouseout({label:getX(d.data),value:getY(d.data),point:d.data,index:i,id:id})}).on("click",function(d,i){dispatch.elementClick({label:getX(d.data),value:getY(d.data),point:d.data,index:i,pos:d3.event,id:id});d3.event.stopPropagation()}).on("dblclick",function(d,i){dispatch.elementDblClick({label:getX(d.data),value:getY(d.data),point:d.data,index:i,pos:d3.event,id:id});d3.event.stopPropagation()});slices.attr("fill",function(d,i){return color(d,i)}).attr("stroke",function(d,i){return color(d,i)});var paths=ae.append("path").each(function(d){this._current=d});d3.transition(slices.select("path")).attr("d",arc).attrTween("d",arcTween);if(showLabels){var labelsArc=d3.svg.arc().innerRadius(0);if(pieLabelsOutside){labelsArc=arc}if(donutLabelsOutside){labelsArc=d3.svg.arc().outerRadius(arc.outerRadius())}ae.append("g").classed("nv-label",true).each(function(d,i){var group=d3.select(this);group.attr("transform",function(d){if(labelSunbeamLayout){d.outerRadius=arcRadius+10;d.innerRadius=arcRadius+15;var rotateAngle=(d.startAngle+d.endAngle)/2*(180/Math.PI);if((d.startAngle+d.endAngle)/2<Math.PI){rotateAngle-=90}else{rotateAngle+=90}return"translate("+labelsArc.centroid(d)+") rotate("+rotateAngle+")"}else{d.outerRadius=radius+10;d.innerRadius=radius+15;return"translate("+labelsArc.centroid(d)+")"}});group.append("rect").style("stroke","#fff").style("fill","#fff").attr("rx",3).attr("ry",3);group.append("text").style("text-anchor",labelSunbeamLayout?(d.startAngle+d.endAngle)/2<Math.PI?"start":"end":"middle").style("fill","#000")});slices.select(".nv-label").transition().attr("transform",function(d){if(labelSunbeamLayout){d.outerRadius=arcRadius+10;d.innerRadius=arcRadius+15;var rotateAngle=(d.startAngle+d.endAngle)/2*(180/Math.PI);if((d.startAngle+d.endAngle)/2<Math.PI){rotateAngle-=90}else{rotateAngle+=90}return"translate("+labelsArc.centroid(d)+") rotate("+rotateAngle+")"}else{d.outerRadius=radius+10;d.innerRadius=radius+15;return"translate("+labelsArc.centroid(d)+")"}});slices.each(function(d,i){var slice=d3.select(this);slice.select(".nv-label text").style("text-anchor",labelSunbeamLayout?(d.startAngle+d.endAngle)/2<Math.PI?"start":"end":"middle").text(function(d,i){var percent=(d.endAngle-d.startAngle)/(2*Math.PI);return d.value&&percent>labelThreshold?getX(d.data):""});var textBox=slice.select("text").node().getBBox();slice.select(".nv-label rect").attr("width",textBox.width+10).attr("height",textBox.height+10).attr("transform",function(){return"translate("+[textBox.x-5,textBox.y-5]+")"})})}function angle(d){var a=(d.startAngle+d.endAngle)*90/Math.PI-90;return a>90?a-180:a}function arcTween(a){a.endAngle=isNaN(a.endAngle)?0:a.endAngle;a.startAngle=isNaN(a.startAngle)?0:a.startAngle;if(!donut)a.innerRadius=0;var i=d3.interpolate(this._current,a);this._current=i(0);return function(t){return arc(i(t))}}function tweenPie(b){b.innerRadius=0;var i=d3.interpolate({startAngle:0,endAngle:0},b);return function(t){return arc(i(t))}}});return chart}chart.dispatch=dispatch;chart.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!="undefined"?_.top:margin.top;margin.right=typeof _.right!="undefined"?_.right:margin.right;margin.bottom=typeof _.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof _.left!="undefined"?_.left:margin.left;return chart};chart.width=function(_){if(!arguments.length)return width;width=_;return chart};chart.height=function(_){if(!arguments.length)return height;height=_;return chart};chart.values=function(_){if(!arguments.length)return getValues;getValues=_;return chart};chart.x=function(_){if(!arguments.length)return getX;getX=_;return chart};chart.y=f
return chart};chart.width=function(_){if(!arguments.length)return width;width=_;return chart};chart.height=function(_){if(!arguments.length)return height;height=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);legend.color(color);distX.color(color);distY.color(color);return chart};chart.showDistX=function(_){if(!arguments.length)return showDistX;showDistX=_;return chart};chart.showDistY=function(_){if(!arguments.length)return showDistY;showDistY=_;return chart};chart.showControls=function(_){if(!arguments.length)return showControls;showControls=_;return chart};chart.showLegend=function(_){if(!arguments.length)return showLegend;showLegend=_;return chart};chart.showXAxis=function(_){if(!arguments.length)return showXAxis;showXAxis=_;return chart};chart.showYAxis=function(_){if(!arguments.length)return showYAxis;showYAxis=_;return chart};chart.rightAlignYAxis=function(_){if(!arguments.length)return rightAlignYAxis;rightAlignYAxis=_;yAxis.orient(_?"right":"left");return chart};chart.fisheye=function(_){if(!arguments.length)return fisheye;fisheye=_;return chart};chart.xPadding=function(_){if(!arguments.length)return xPadding;xPadding=_;return chart};chart.yPadding=function(_){if(!arguments.length)return yPadding;yPadding=_;return chart};chart.tooltips=function(_){if(!arguments.length)return tooltips;tooltips=_;return chart};chart.tooltipContent=function(_){if(!arguments.length)return tooltip;tooltip=_;return chart};chart.tooltipXContent=function(_){if(!arguments.length)return tooltipX;tooltipX=_;return chart};chart.tooltipYContent=function(_){if(!arguments.length)return tooltipY;tooltipY=_;return chart};chart.state=function(_){if(!arguments.length)return state;state=_;return chart};chart.defaultState=function(_){if(!arguments.length)return defaultState;defaultState=_;return chart};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};return chart};nv.models.scatterPlusLineChart=function(){var scatter=nv.models.scatter(),xAxis=nv.models.axis(),yAxis=nv.models.axis(),legend=nv.models.legend(),controls=nv.models.legend(),distX=nv.models.distribution(),distY=nv.models.distribution();var margin={top:30,right:20,bottom:50,left:75},width=null,height=null,color=nv.utils.defaultColor(),x=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):scatter.xScale(),y=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):scatter.yScale(),showDistX=false,showDistY=false,showLegend=true,showXAxis=true,showYAxis=true,rightAlignYAxis=false,showControls=!!d3.fisheye,fisheye=0,pauseFisheye=false,tooltips=true,tooltipX=function(key,x,y){return"<strong>"+x+"</strong>"},tooltipY=function(key,x,y){return"<strong>"+y+"</strong>"},tooltip=function(key,x,y,date){return"<h3>"+key+"</h3>"+"<p>"+date+"</p>"},state={},defaultState=null,dispatch=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),noData="No Data Available.";scatter.xScale(x).yScale(y);xAxis.orient("bottom").tickPadding(10);yAxis.orient(rightAlignYAxis?"right":"left").tickPadding(10);distX.axis("x");distY.axis("y");var x0,y0;var showTooltip=function(e,offsetElement){var left=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),leftX=e.pos[0]+(offsetElement.offsetLeft||0),topX=y.range()[0]+margin.top+(offsetElement.offsetTop||0),leftY=x.range()[0]+margin.left+(offsetElement.offsetLeft||0),topY=e.pos[1]+(offsetElement.offsetTop||0),xVal=xAxis.tickFormat()(scatter.x()(e.point,e.pointIndex)),yVal=yAxis.tickFormat()(scatter.y()(e.point,e.pointIndex));if(tooltipX!=null)nv.tooltip.show([leftX,topX],tooltipX(e.series.key,xVal,yVal,e,chart),"n",1,offsetElement,"x-nvtooltip");if(tooltipY!=null)nv.tooltip.show([leftY,topY],tooltipY(e.series.key,xVal,yVal,e,chart),"e",1,offsetElement,"y-nvtooltip");if(tooltip!=null)nv.tooltip.show([left,top],tooltip(e.series.key,xVal,yVal,e.point.tooltip,e,chart),e.value<0?"n":"s",null,offsetElement)};var controlsData=[{key:"Magnify",disabled:true}];function chart(selection){selection.each(function(data){var container=d3.select(this),that=t
g.select(".nv-x.nv-axis").attr("transform","translate(0,"+availableHeight+")");g.select(".nv-x.nv-axis").transition().duration(0).call(xAxis)}if(showYAxis){yAxis.scale(y).ticks(stacked.offset()=="wiggle"?0:availableHeight/36).tickSize(-availableWidth,0).setTickFormat(stacked.offset()=="expand"?d3.format("%"):yAxisTickFormat);g.select(".nv-y.nv-axis").transition().duration(0).call(yAxis)}stacked.dispatch.on("areaClick.toggle",function(e){if(data.filter(function(d){return!d.disabled}).length===1)data=data.map(function(d){d.disabled=false;return d});else data=data.map(function(d,i){d.disabled=i!=e.seriesIndex;return d});state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});legend.dispatch.on("legendClick",function(d,i){d.disabled=!d.disabled;if(!data.filter(function(d){return!d.disabled}).length){data.map(function(d){d.disabled=false;return d})}state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});legend.dispatch.on("legendDblclick",function(d){data.forEach(function(d){d.disabled=true});d.disabled=false;state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});controls.dispatch.on("legendClick",function(d,i){if(!d.disabled)return;controlsData=controlsData.map(function(s){s.disabled=true;return s});d.disabled=false;switch(d.key){case"Stacked":stacked.style("stack");break;case"Stream":stacked.style("stream");break;case"Expanded":stacked.style("expand");break}state.style=stacked.style();dispatch.stateChange(state);chart.update()});dispatch.on("tooltipShow",function(e){if(tooltips)showTooltip(e,that.parentNode)});dispatch.on("changeState",function(e){if(typeof e.disabled!=="undefined"){data.forEach(function(series,i){series.disabled=e.disabled[i]});state.disabled=e.disabled}if(typeof e.style!=="undefined"){stacked.style(e.style)}chart.update()})});return chart}stacked.dispatch.on("tooltipShow",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top],dispatch.tooltipShow(e)});stacked.dispatch.on("tooltipHide",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.stacked=stacked;chart.legend=legend;chart.controls=controls;chart.xAxis=xAxis;chart.yAxis=yAxis;d3.rebind(chart,stacked,"x","y","size","xScale","yScale","xDomain","yDomain","sizeDomain","interactive","offset","order","style","clipEdge","forceX","forceY","forceSize","interpolate");chart.margin=function(_){if(!arguments.length)return margin;margin.top=typeof _.top!="undefined"?_.top:margin.top;margin.right=typeof _.right!="undefined"?_.right:margin.right;margin.bottom=typeof _.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof _.left!="undefined"?_.left:margin.left;return chart};chart.width=function(_){if(!arguments.length)return getWidth;width=_;return chart};chart.height=function(_){if(!arguments.length)return getHeight;height=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);legend.color(color);stacked.color(color);return chart};chart.showControls=function(_){if(!arguments.length)return showControls;showControls=_;return chart};chart.showLegend=function(_){if(!arguments.length)return showLegend;showLegend=_;return chart};chart.showXAxis=function(_){if(!arguments.length)return showXAxis;showXAxis=_;return chart};chart.showYAxis=function(_){if(!arguments.length)return showYAxis;showYAxis=_;return chart};chart.rightAlignYAxis=function(_){if(!arguments.length)return rightAlignYAxis;rightAlignYAxis=_;yAxis.orient(_?"right":"left");return chart};chart.tooltip=function(_){if(!arguments.length)return tooltip;tooltip=_;return chart};chart.tooltips=function(_){if(!arguments.length)return tooltips;tooltips=_;return chart};chart.tooltipContent=function(_){if(!arguments.length)return tooltip;tooltip=_;return chart};chart.state=function(_){if(!arguments.length)return state;state=_;return chart};chart.defaultState=function(_){if(!arguments.length)return defaultState;defaultState=_;return chart};ch