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
238 KiB
JavaScript

(function(){var nv=window.nv||{};nv.version="1.0.0b";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()});nv.interactiveGuideline=function(){var tooltip=nv.models.tooltip();var width=null,height=null,xScale=d3.scale.linear(),yScale=d3.scale.linear(),dispatch=d3.dispatch("elementMousemove","elementMouseout"),showGuideLine=true;var previousXCoordinate=null;isMSIE=navigator.userAgent.indexOf("MSIE")!==-1;function findFirstSVGParent(Elem){while(Elem.tagName.match(/^svg$/i)===null){Elem=Elem.parentNode}return Elem}function layer(selection){selection.each(function(data){var container=d3.select(this);var offsetParent=findFirstSVGParent(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");wrapEnter.append("rect").attr("class","nv-mouseMoveLayer");wrap.select(".nv-mouseMoveLayer").attr("width",availableWidth).attr("height",availableHeight).attr("opacity",0).on("mousemove",function(){var d3mouse=d3.mouse(this);var mouseX=d3mouse[0];var mouseY=d3mouse[1];if(isMSIE){mouseX=d3.event.offsetX;mouseY=d3.event.offsetY}var pointXValue=xScale.invert(mouseX);dispatch.elementMousemove({mouseX:mouseX,mouseY:mouseY,pointXValue:pointXValue})}).on("mouseout",function(){var d3mouse=d3.mouse(this);var mouseX=d3mouse[0];var mouseY=d3mouse[1];if(isMSIE){var rTarget=d3.event.relatedTarget;if(rTarget){while(rTarget&&rTarget.id!==tooltip.id()){rTarget=rTarget.parentNode}if(rTarget&&tooltip.id()===rTarget.id){return}}}dispatch.elementMouseout({mouseX:mouseX,mouseY:mouseY});layer.renderGuideLine(null)});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.
orient=x;reverse=orient=="right"||orient=="bottom";return chart};chart.ranges=function(x){if(!arguments.length)return ranges;ranges=x;return chart};chart.markers=function(x){if(!arguments.length)return markers;markers=x;return chart};chart.measures=function(x){if(!arguments.length)return measures;measures=x;return chart};chart.width=function(x){if(!arguments.length)return width;width=x;return chart};chart.height=function(x){if(!arguments.length)return height;height=x;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.tickFormat=function(x){if(!arguments.length)return tickFormat;tickFormat=x;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.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};return chart};nv.models.cumulativeLineChart=function(){var lines=nv.models.line(),xAxis=nv.models.axis(),yAxis=nv.models.axis(),legend=nv.models.legend(),controls=nv.models.legend(),interactiveLayer=nv.interactiveGuideline();var margin={top:30,right:30,bottom:50,left:60},color=nv.utils.defaultColor(),width=null,height=null,showLegend=true,showXAxis=true,showYAxis=true,rightAlignYAxis=false,tooltips=true,showControls=true,useInteractiveGuideline=false,rescaleY=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" at "+x+"</p>"},x,y,id=lines.id(),state={index:0,rescaleY:rescaleY},defaultState=null,noData="No Data Available.",average=function(d){return d.average},dispatch=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");xAxis.orient("bottom").tickPadding(7);yAxis.orient(rightAlignYAxis?"right":"left");var dx=d3.scale.linear(),index={i:0,x:0};var showTooltip=function(e,offsetElement){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=yAxis.tickFormat()(lines.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,null,null,offsetElement)};function chart(selection){selection.each(function(data){var container=d3.select(this).classed("nv-chart-"+id,true),that=this;var availableWidth=(width||parseInt(container.style("width"))||960)-margin.left-margin.right,availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom;chart.update=function(){container.transition().call(chart)};chart.container=this;state.disabled=data.map(function(d){return!!d.disabled});if(!defaultState){var key;defaultState={};for(key in state){if(state[key]instanceof Array)defaultState[key]=state[key].slice(0);else defaultState[key]=state[key]}}var indexDrag=d3.behavior.drag().on("dragstart",dragStart).on("drag",dragMove).on("dragend",dragEnd);function dragStart(d,i){d3.select(chart.container).style("cursor","ew-resize")}function dragMove(d,i){index.x=d3.event.x;index.i=Math.round(dx.invert(index.x));updateZero()}function dragEnd(d,i){d3.select(chart.container).style("cursor","auto");state.index=index.i;dispatch.stateChange(state)}if(!data||!data.length||!data.filter(function(d){return d.values.length}).length){var noDataText=container.selectAll(".nv-noData").data([noData]);noDataText.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle");noDataText.attr("x",margin.left+availableWidth/2).attr("y",margin.top+availableHeight/2).text(function(d){return d});return chart}else{container.selectAll(".nv-noData").remove()}x=lines.xScale();y=lines.yScale();if(!rescaleY){var seriesDomains=data.filter(function(series){return!series.disabled}).map(function(series,i){var initialDomain=d3.extent(series.values,lines.y());if(initialDomain[0]<-.95)initialDomain[0]=-.95;return[(initial
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.xScale=function(_){if(!arguments.length)return x;x=_;return chart};chart.yScale=function(_){if(!arguments.length)return y;y=_;return chart};chart.xDomain=function(_){if(!arguments.length)return xDomain;xDomain=_;return chart};chart.yDomain=function(_){if(!arguments.length)return yDomain;yDomain=_;return chart};chart.forceX=function(_){if(!arguments.length)return forceX;forceX=_;return chart};chart.forceY=function(_){if(!arguments.length)return forceY;forceY=_;return chart};chart.padData=function(_){if(!arguments.length)return padData;padData=_;return chart};chart.clipEdge=function(_){if(!arguments.length)return clipEdge;clipEdge=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);return chart};chart.id=function(_){if(!arguments.length)return id;id=_;return chart};chart.interactive=function(_){if(!arguments.length)return interactive;interactive=false;return chart};return chart};nv.models.historicalBarChart=function(){var bars=nv.models.historicalBar(),xAxis=nv.models.axis(),yAxis=nv.models.axis(),legend=nv.models.legend();var margin={top:30,right:90,bottom:50,left:90},color=nv.utils.defaultColor(),width=null,height=null,showLegend=false,showXAxis=true,showYAxis=true,rightAlignYAxis=false,tooltips=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" at "+x+"</p>"},x,y,state={},defaultState=null,noData="No Data Available.",dispatch=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");xAxis.orient("bottom").tickPadding(7);yAxis.orient(rightAlignYAxis?"right":"left");var showTooltip=function(e,offsetElement){if(offsetElement){var svg=d3.select(offsetElement).select("svg");var viewBox=svg.node()?svg.attr("viewBox"):null;if(viewBox){viewBox=viewBox.split(" ");var ratio=parseInt(svg.style("width"))/viewBox[2];e.pos[0]=e.pos[0]*ratio;e.pos[1]=e.pos[1]*ratio}}var left=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(bars.x()(e.point,e.pointIndex)),y=yAxis.tickFormat()(bars.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,null,null,offsetElement)};function chart(selection){selection.each(function(data){var container=d3.select(this),that=this;var availableWidth=(width||parseInt(container.style("width"))||960)-margin.left-margin.right,availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom;chart.update=function(){chart(selection)};chart.container=this;state.disabled=data.map(function(d){return!!d.disabled});if(!defaultState){var key;defaultState={};for(key in state){if(state[key]instanceof Array)defaultState[key]=state[key].slice(0);else defaultState[key]=state[key]}}if(!data||!data.length||!data.filter(function(d){return d.values.length}).length){var noDataText=container.selectAll(".nv-noData").data([noData]);noDataText.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle");noDataText.attr("x",margin.left+availableWidth/2).attr("y",margin.top+availableHeight/2).text(function(d){return d});return chart}else{container.selectAll(".nv-noData").remove()}x=bars.xScale();y=bars.yScale();var wrap=container.selectAll("g.nv-wrap.nv-historicalBarChart").data([data]);var gEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBarChart").append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-x nv-axis");gEnter.append("g").attr("class","nv-y nv-axis");gEnter.append("g").attr("class","nv-barsWrap");gEnter.append("g").attr("class","nv-legendWrap");if(showLegend){legend.width(availableWidth);g.select(".nv-legendWrap").datum(data).call(legend);if(margin.top!=legend.height()){margin.t
chart.update=function(){container.transition().call(chart)};state.disabled=data.map(function(d){return!!d.disabled});if(!defaultState){var key;defaultState={};for(key in state){if(state[key]instanceof Array)defaultState[key]=state[key].slice(0);else defaultState[key]=state[key]}}if(!data||!data.length||!data.filter(function(d){return d.values.length}).length){var noDataText=container.selectAll(".nv-noData").data([noData]);noDataText.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle");noDataText.attr("x",margin.left+availableWidth/2).attr("y",margin.top+availableHeight/2).text(function(d){return d});return chart}else{container.selectAll(".nv-noData").remove()}var dataBars=data.filter(function(d){return!d.disabled&&d.bar});var dataLines=data.filter(function(d){return!d.bar});x=dataLines.filter(function(d){return!d.disabled}).length&&dataLines.filter(function(d){return!d.disabled})[0].values.length?lines.xScale():bars.xScale();y1=bars.yScale();y2=lines.yScale();var wrap=d3.select(this).selectAll("g.nv-wrap.nv-linePlusBar").data([data]);var gEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-x nv-axis");gEnter.append("g").attr("class","nv-y1 nv-axis");gEnter.append("g").attr("class","nv-y2 nv-axis");gEnter.append("g").attr("class","nv-barsWrap");gEnter.append("g").attr("class","nv-linesWrap");gEnter.append("g").attr("class","nv-legendWrap");if(showLegend){legend.width(availableWidth/2);g.select(".nv-legendWrap").datum(data.map(function(series){series.originalKey=series.originalKey===undefined?series.key:series.originalKey;series.key=series.originalKey+(series.bar?" (left axis)":" (right axis)");return series})).call(legend);if(margin.top!=legend.height()){margin.top=legend.height();availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom}g.select(".nv-legendWrap").attr("transform","translate("+availableWidth/2+","+-margin.top+")")}wrap.attr("transform","translate("+margin.left+","+margin.top+")");lines.width(availableWidth).height(availableHeight).color(data.map(function(d,i){return d.color||color(d,i)}).filter(function(d,i){return!data[i].disabled&&!data[i].bar}));bars.width(availableWidth).height(availableHeight).color(data.map(function(d,i){return d.color||color(d,i)}).filter(function(d,i){return!data[i].disabled&&data[i].bar}));var barsWrap=g.select(".nv-barsWrap").datum(dataBars.length?dataBars:[{values:[]}]);var linesWrap=g.select(".nv-linesWrap").datum(dataLines[0]&&!dataLines[0].disabled?dataLines:[{values:[]}]);d3.transition(barsWrap).call(bars);d3.transition(linesWrap).call(lines);xAxis.scale(x).ticks(availableWidth/100).tickSize(-availableHeight,0);g.select(".nv-x.nv-axis").attr("transform","translate(0,"+y1.range()[0]+")");d3.transition(g.select(".nv-x.nv-axis")).call(xAxis);y1Axis.scale(y1).ticks(availableHeight/36).tickSize(-availableWidth,0);d3.transition(g.select(".nv-y1.nv-axis")).style("opacity",dataBars.length?1:0).call(y1Axis);y2Axis.scale(y2).ticks(availableHeight/36).tickSize(dataBars.length?0:-availableWidth,0);g.select(".nv-y2.nv-axis").style("opacity",dataLines.length?1:0).attr("transform","translate("+availableWidth+",0)");d3.transition(g.select(".nv-y2.nv-axis")).call(y2Axis);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[
}).filter(function(d,i){return!disabled[i]})[j]).toString()}).style("stroke",function(d,i,j){return d3.rgb(barColor(d,i)).darker(disabled.map(function(d,i){return i}).filter(function(d,i){return!disabled[i]})[j]).toString()})}if(stacked)bars.transition().delay(function(d,i){return i*delay/data[0].values.length}).attr("y",function(d,i){return y(stacked?d.y1:0)}).attr("height",function(d,i){return Math.max(Math.abs(y(d.y+(stacked?d.y0:0))-y(stacked?d.y0:0)),1)}).each("end",function(){d3.select(this).transition().duration(drawTime).attr("x",function(d,i){return stacked?0:d.series*x.rangeBand()/data.length}).attr("width",x.rangeBand()/(stacked?1:data.length))});else d3.transition(bars).duration(drawTime).delay(function(d,i){return i*delay/data[0].values.length}).attr("x",function(d,i){return d.series*x.rangeBand()/data.length}).attr("width",x.rangeBand()/data.length).each("end",function(){d3.select(this).transition().duration(drawTime).attr("y",function(d,i){return getY(d,i)<0?y(0):y(0)-y(getY(d,i))<1?y(0)-1:y(getY(d,i))||0}).attr("height",function(d,i){return Math.max(Math.abs(y(getY(d,i))-y(0)),1)||0})});x0=x.copy();y0=y.copy()});return chart}chart.dispatch=dispatch;chart.x=function(_){if(!arguments.length)return getX;getX=_;return chart};chart.y=function(_){if(!arguments.length)return getY;getY=_;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.xScale=function(_){if(!arguments.length)return x;x=_;return chart};chart.yScale=function(_){if(!arguments.length)return y;y=_;return chart};chart.xDomain=function(_){if(!arguments.length)return xDomain;xDomain=_;return chart};chart.yDomain=function(_){if(!arguments.length)return yDomain;yDomain=_;return chart};chart.forceY=function(_){if(!arguments.length)return forceY;forceY=_;return chart};chart.stacked=function(_){if(!arguments.length)return stacked;stacked=_;return chart};chart.clipEdge=function(_){if(!arguments.length)return clipEdge;clipEdge=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);return chart};chart.barColor=function(_){if(!arguments.length)return barColor;barColor=nv.utils.getColor(_);return chart};chart.disabled=function(_){if(!arguments.length)return disabled;disabled=_;return chart};chart.id=function(_){if(!arguments.length)return id;id=_;return chart};chart.hideable=function(_){if(!arguments.length)return hideable;hideable=_;return chart};chart.delay=function(_){if(!arguments.length)return delay;delay=_;return chart};chart.drawTime=function(_){if(!arguments.length)return drawTime;drawTime=_;return chart};return chart};nv.models.multiBarChart=function(){var multibar=nv.models.multiBar(),xAxis=nv.models.axis(),yAxis=nv.models.axis(),legend=nv.models.legend(),controls=nv.models.legend();var margin={top:30,right:20,bottom:50,left:60},width=null,height=null,color=nv.utils.defaultColor(),showControls=true,showLegend=true,showXAxis=true,showYAxis=true,rightAlignYAxis=false,reduceXTicks=true,staggerLabels=false,rotateLabels=0,tooltips=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" on "+x+"</p>"},x,y,state={stacked:false},defaultState=null,noData="No Data Available.",dispatch=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),controlWidth=function(){return showControls?180:0};multibar.stacked(false);xAxis.orient("bottom").tickPadding(7).highlightZero(true).showMaxMin(false).tickFormat(function(d){return d});yAxis.orient(rightAlignYAxis?"right":"left").tickFormat(d3.format(",.1f"));var showTooltip=function(e,offsetElement){var left=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(mul
}));g.attr("transform","translate("+margin.left+","+margin.top+")");var lines1Wrap=g.select(".lines1Wrap").datum(dataLines1);var bars1Wrap=g.select(".bars1Wrap").datum(dataBars1);var stack1Wrap=g.select(".stack1Wrap").datum(dataStack1);var lines2Wrap=g.select(".lines2Wrap").datum(dataLines2);var bars2Wrap=g.select(".bars2Wrap").datum(dataBars2);var stack2Wrap=g.select(".stack2Wrap").datum(dataStack2);var extraValue1=dataStack1.length?dataStack1.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(aVal,i){return{x:aVal.x,y:aVal.y+b[i].y}})}).concat([{x:0,y:0}]):[];var extraValue2=dataStack2.length?dataStack2.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(aVal,i){return{x:aVal.x,y:aVal.y+b[i].y}})}).concat([{x:0,y:0}]):[];yScale1.domain(yDomain1||d3.extent(d3.merge(series1).concat(extraValue1),function(d){return d.y})).range([0,availableHeight]);yScale2.domain(yDomain2||d3.extent(d3.merge(series2).concat(extraValue2),function(d){return d.y})).range([0,availableHeight]);lines1.yDomain(yScale1.domain());bars1.yDomain(yScale1.domain());stack1.yDomain(yScale1.domain());lines2.yDomain(yScale2.domain());bars2.yDomain(yScale2.domain());stack2.yDomain(yScale2.domain());if(dataStack1.length){d3.transition(stack1Wrap).call(stack1)}if(dataStack2.length){d3.transition(stack2Wrap).call(stack2)}if(dataBars1.length){d3.transition(bars1Wrap).call(bars1)}if(dataBars2.length){d3.transition(bars2Wrap).call(bars2)}if(dataLines1.length){d3.transition(lines1Wrap).call(lines1)}if(dataLines2.length){d3.transition(lines2Wrap).call(lines2)}xAxis.ticks(availableWidth/100).tickSize(-availableHeight,0);g.select(".x.axis").attr("transform","translate(0,"+availableHeight+")");d3.transition(g.select(".x.axis")).call(xAxis);yAxis1.ticks(availableHeight/36).tickSize(-availableWidth,0);d3.transition(g.select(".y1.axis")).call(yAxis1);yAxis2.ticks(availableHeight/36).tickSize(-availableWidth,0);d3.transition(g.select(".y2.axis")).call(yAxis2);g.select(".y2.axis").style("opacity",series2.length?1:0).attr("transform","translate("+x.range()[1]+",0)");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(".series").classed("disabled",false);return d})}chart.update()});dispatch.on("tooltipShow",function(e){if(tooltips)showTooltip(e,that.parentNode)})});return chart}lines1.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});lines1.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});lines2.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});lines2.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});bars1.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});bars1.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});bars2.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});bars2.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});stack1.dispatch.on("tooltipShow",function(e){if(!Math.round(stack1.y()(e.point)*100)){setTimeout(function(){d3.selectAll(".point.hover").classed("hover",false)},0);return false}e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top],dispatch.tooltipShow(e)});stack1.dispatch.on("tooltipHide",function(e){dispatch.tooltipHide(e)});stack2.dispatch.on("tooltipShow",function(e){if(!Math.round(stack2.y()(e.point)*100)){setTimeout(function(){d3.selectAll(".point.hover").classed("hover",false)},0);return false}e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top],dispatch.tooltipShow(e)});stack2.dispatch.on("tooltipHide",function(e){dispatch.tooltipHide(e)});lines1.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});lines1.dispatc
};chart.highlightPoint=function(seriesIndex,pointIndex,isHoverOver){d3.select(".nv-chart-"+id+" .nv-series-"+seriesIndex+" .nv-point-"+pointIndex).classed("hover",isHoverOver)};dispatch.on("elementMouseover.point",function(d){if(interactive)chart.highlightPoint(d.seriesIndex,d.pointIndex,true)});dispatch.on("elementMouseout.point",function(d){if(interactive)chart.highlightPoint(d.seriesIndex,d.pointIndex,false)});chart.dispatch=dispatch;chart.x=function(_){if(!arguments.length)return getX;getX=d3.functor(_);return chart};chart.y=function(_){if(!arguments.length)return getY;getY=d3.functor(_);return chart};chart.size=function(_){if(!arguments.length)return getSize;getSize=d3.functor(_);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.xScale=function(_){if(!arguments.length)return x;x=_;return chart};chart.yScale=function(_){if(!arguments.length)return y;y=_;return chart};chart.zScale=function(_){if(!arguments.length)return z;z=_;return chart};chart.xDomain=function(_){if(!arguments.length)return xDomain;xDomain=_;return chart};chart.yDomain=function(_){if(!arguments.length)return yDomain;yDomain=_;return chart};chart.sizeDomain=function(_){if(!arguments.length)return sizeDomain;sizeDomain=_;return chart};chart.sizeRange=function(_){if(!arguments.length)return sizeRange;sizeRange=_;return chart};chart.forceX=function(_){if(!arguments.length)return forceX;forceX=_;return chart};chart.forceY=function(_){if(!arguments.length)return forceY;forceY=_;return chart};chart.forceSize=function(_){if(!arguments.length)return forceSize;forceSize=_;return chart};chart.interactive=function(_){if(!arguments.length)return interactive;interactive=_;return chart};chart.pointKey=function(_){if(!arguments.length)return pointKey;pointKey=_;return chart};chart.pointActive=function(_){if(!arguments.length)return pointActive;pointActive=_;return chart};chart.padData=function(_){if(!arguments.length)return padData;padData=_;return chart};chart.padDataOuter=function(_){if(!arguments.length)return padDataOuter;padDataOuter=_;return chart};chart.clipEdge=function(_){if(!arguments.length)return clipEdge;clipEdge=_;return chart};chart.clipVoronoi=function(_){if(!arguments.length)return clipVoronoi;clipVoronoi=_;return chart};chart.useVoronoi=function(_){if(!arguments.length)return useVoronoi;useVoronoi=_;if(useVoronoi===false){clipVoronoi=false}return chart};chart.clipRadius=function(_){if(!arguments.length)return clipRadius;clipRadius=_;return chart};chart.color=function(_){if(!arguments.length)return color;color=nv.utils.getColor(_);return chart};chart.shape=function(_){if(!arguments.length)return getShape;getShape=_;return chart};chart.onlyCircles=function(_){if(!arguments.length)return onlyCircles;onlyCircles=_;return chart};chart.id=function(_){if(!arguments.length)return id;id=_;return chart};chart.singlePoint=function(_){if(!arguments.length)return singlePoint;singlePoint=_;return chart};return chart};nv.models.scatterChart=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(),xPadding=0,yPadding=0,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>"
gEnter.append("g").attr("class","nv-valueWrap");gEnter.append("g").attr("class","nv-hoverArea");wrap.attr("transform","translate("+margin.left+","+margin.top+")");var sparklineWrap=g.select(".nv-sparklineWrap");sparkline.width(availableWidth).height(availableHeight);sparklineWrap.call(sparkline);var valueWrap=g.select(".nv-valueWrap");var value=valueWrap.selectAll(".nv-currentValue").data([currentValue]);value.enter().append("text").attr("class","nv-currentValue").attr("dx",rightAlignValue?-8:8).attr("dy",".9em").style("text-anchor",rightAlignValue?"end":"start");value.attr("x",availableWidth+(rightAlignValue?margin.right:0)).attr("y",alignValue?function(d){return y(d)}:0).style("fill",sparkline.color()(data[data.length-1],data.length-1)).text(yTickFormat(currentValue));gEnter.select(".nv-hoverArea").append("rect").on("mousemove",sparklineHover).on("click",function(){paused=!paused}).on("mouseout",function(){index=[];updateValueLine()});g.select(".nv-hoverArea rect").attr("transform",function(d){return"translate("+-margin.left+","+-margin.top+")"}).attr("width",availableWidth+margin.left+margin.right).attr("height",availableHeight+margin.top);function updateValueLine(){if(paused)return;var hoverValue=g.selectAll(".nv-hoverValue").data(index);var hoverEnter=hoverValue.enter().append("g").attr("class","nv-hoverValue").style("stroke-opacity",0).style("fill-opacity",0);hoverValue.exit().transition().duration(250).style("stroke-opacity",0).style("fill-opacity",0).remove();hoverValue.attr("transform",function(d){return"translate("+x(sparkline.x()(data[d],d))+",0)"}).transition().duration(250).style("stroke-opacity",1).style("fill-opacity",1);if(!index.length)return;hoverEnter.append("line").attr("x1",0).attr("y1",-margin.top).attr("x2",0).attr("y2",availableHeight);hoverEnter.append("text").attr("class","nv-xValue").attr("x",-6).attr("y",-margin.top).attr("text-anchor","end").attr("dy",".9em");g.select(".nv-hoverValue .nv-xValue").text(xTickFormat(sparkline.x()(data[index[0]],index[0])));hoverEnter.append("text").attr("class","nv-yValue").attr("x",6).attr("y",-margin.top).attr("text-anchor","start").attr("dy",".9em");g.select(".nv-hoverValue .nv-yValue").text(yTickFormat(sparkline.y()(data[index[0]],index[0])))}function sparklineHover(){if(paused)return;var pos=d3.mouse(this)[0]-margin.left;function getClosestIndex(data,x){var distance=Math.abs(sparkline.x()(data[0],0)-x);var closestIndex=0;for(var i=0;i<data.length;i++){if(Math.abs(sparkline.x()(data[i],i)-x)<distance){distance=Math.abs(sparkline.x()(data[i],i)-x);closestIndex=i}}return closestIndex}index=[getClosestIndex(data,Math.round(x.invert(pos)))];updateValueLine()}});return chart}chart.sparkline=sparkline;d3.rebind(chart,sparkline,"x","y","xScale","yScale","color");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.xTickFormat=function(_){if(!arguments.length)return xTickFormat;xTickFormat=_;return chart};chart.yTickFormat=function(_){if(!arguments.length)return yTickFormat;yTickFormat=_;return chart};chart.showValue=function(_){if(!arguments.length)return showValue;showValue=_;return chart};chart.alignValue=function(_){if(!arguments.length)return alignValue;alignValue=_;return chart};chart.rightAlignValue=function(_){if(!arguments.length)return rightAlignValue;rightAlignValue=_;return chart};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};return chart};nv.models.stackedArea=function(){var margin={top:0,right:0,bottom:0,left:0},width=960,height=500,color=nv.utils.defaultColor(),id=Math.floor(Math.random()*1e5),getX=function(d){return d.x},getY=function(d){return d.y},style="stack",offset="zero",order="default