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

!function(){var nv=window.nv||{};nv.version="1.1.14b";nv.dev=true;window.nv=nv;nv.tooltip=nv.tooltip||{};nv.utils=nv.utils||{};nv.models=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&&typeof console.log=="function"&&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.dispatch.render_end();nv.render.active=false}},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(){"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.renderG
if(!d||!ranges.call(this,d,i)){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",18+margin.top+availableHeight/2).text(function(d){return d});return chart}else{container.selectAll(".nv-noData").remove()}var rangez=ranges.call(this,d,i).slice().sort(d3.descending),markerz=markers.call(this,d,i).slice().sort(d3.descending),measurez=measures.call(this,d,i).slice().sort(d3.descending);var wrap=container.selectAll("g.nv-wrap.nv-bulletChart").data([d]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-bulletChart");var gEnter=wrapEnter.append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-bulletWrap");gEnter.append("g").attr("class","nv-titles");wrap.attr("transform","translate("+margin.left+","+margin.top+")");var x1=d3.scale.linear().domain([0,Math.max(rangez[0],markerz[0],measurez[0])]).range(reverse?[availableWidth,0]:[0,availableWidth]);var x0=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(x1.range());this.__chart__=x1;var w0=function(d){return Math.abs(x0(d)-x0(0))},w1=function(d){return Math.abs(x1(d)-x1(0))};var title=gEnter.select(".nv-titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(height-margin.top-margin.bottom)/2+")");title.append("text").attr("class","nv-title").text(function(d){return d.title});title.append("text").attr("class","nv-subtitle").attr("dy","1em").text(function(d){return d.subtitle});bullet.width(availableWidth).height(availableHeight);var bulletWrap=g.select(".nv-bulletWrap");d3.transition(bulletWrap).call(bullet);var format=tickFormat||x1.tickFormat(availableWidth/100);var tick=g.selectAll("g.nv-tick").data(x1.ticks(availableWidth/50),function(d){return this.textContent||format(d)});var tickEnter=tick.enter().append("g").attr("class","nv-tick").attr("transform",function(d){return"translate("+x0(d)+",0)"}).style("opacity",1e-6);tickEnter.append("line").attr("y1",availableHeight).attr("y2",availableHeight*7/6);tickEnter.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",availableHeight*7/6).text(format);var tickUpdate=d3.transition(tick).attr("transform",function(d){return"translate("+x1(d)+",0)"}).style("opacity",1);tickUpdate.select("line").attr("y1",availableHeight).attr("y2",availableHeight*7/6);tickUpdate.select("text").attr("y",availableHeight*7/6);d3.transition(tick.exit()).attr("transform",function(d){return"translate("+x1(d)+",0)"}).style("opacity",1e-6).remove();dispatch.on("tooltipShow",function(e){e.key=d.title;if(tooltips)showTooltip(e,that.parentNode)})});d3.timer.flush();return chart}bullet.dispatch.on("elementMouseover.tooltip",function(e){dispatch.tooltipShow(e)});bullet.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.bullet=bullet;d3.rebind(chart,bullet,"color");chart.options=nv.utils.optionsFunc.bind(chart);chart.orient=function(x){if(!arguments.length)return orient;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(_)
11 years ago
var margin={top:0,right:0,bottom:0,left:0},width=960,height=500,id=Math.floor(Math.random()*1e4),x=d3.scale.linear(),y=d3.scale.linear(),getX=function(d){return d.x},getY=function(d){return d.y},forceX=[],forceY=[0],padData=false,clipEdge=true,color=nv.utils.defaultColor(),xDomain,yDomain,xRange,yRange,dispatch=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),interactive=true;function chart(selection){selection.each(function(data){var availableWidth=width-margin.left-margin.right,availableHeight=height-margin.top-margin.bottom,container=d3.select(this);x.domain(xDomain||d3.extent(data[0].values.map(getX).concat(forceX)));if(padData)x.range(xRange||[availableWidth*.5/data[0].values.length,availableWidth*(data[0].values.length-.5)/data[0].values.length]);else x.range(xRange||[0,availableWidth]);y.domain(yDomain||d3.extent(data[0].values.map(getY).concat(forceY))).range(yRange||[availableHeight,0]);if(x.domain()[0]===x.domain()[1])x.domain()[0]?x.domain([x.domain()[0]-x.domain()[0]*.01,x.domain()[1]+x.domain()[1]*.01]):x.domain([-1,1]);if(y.domain()[0]===y.domain()[1])y.domain()[0]?y.domain([y.domain()[0]+y.domain()[0]*.01,y.domain()[1]-y.domain()[1]*.01]):y.domain([-1,1]);var wrap=container.selectAll("g.nv-wrap.nv-historicalBar-"+id).data([data[0].values]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBar-"+id);var defsEnter=wrapEnter.append("defs");var gEnter=wrapEnter.append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-bars");wrap.attr("transform","translate("+margin.left+","+margin.top+")");container.on("click",function(d,i){dispatch.chartClick({data:d,index:i,pos:d3.event,id:id})});defsEnter.append("clipPath").attr("id","nv-chart-clip-path-"+id).append("rect");wrap.select("#nv-chart-clip-path-"+id+" rect").attr("width",availableWidth).attr("height",availableHeight);g.attr("clip-path",clipEdge?"url(#nv-chart-clip-path-"+id+")":"");var bars=wrap.select(".nv-bars").selectAll(".nv-bar").data(function(d){return d},function(d,i){return getX(d,i)});bars.exit().remove();var barsEnter=bars.enter().append("rect").attr("x",0).attr("y",function(d,i){return nv.utils.NaNtoZero(y(Math.max(0,getY(d,i))))}).attr("height",function(d,i){return nv.utils.NaNtoZero(Math.abs(y(getY(d,i))-y(0)))}).attr("transform",function(d,i){return"translate("+(x(getX(d,i))-availableWidth/data[0].values.length*.45)+",0)"}).on("mouseover",function(d,i){if(!interactive)return;d3.select(this).classed("hover",true);dispatch.elementMouseover({point:d,series:data[0],pos:[x(getX(d,i)),y(getY(d,i))],pointIndex:i,seriesIndex:0,e:d3.event})}).on("mouseout",function(d,i){if(!interactive)return;d3.select(this).classed("hover",false);dispatch.elementMouseout({point:d,series:data[0],pointIndex:i,seriesIndex:0,e:d3.event})}).on("click",function(d,i){if(!interactive)return;dispatch.elementClick({value:getY(d,i),data:d,index:i,pos:[x(getX(d,i)),y(getY(d,i))],e:d3.event,id:id});d3.event.stopPropagation()}).on("dblclick",function(d,i){if(!interactive)return;dispatch.elementDblClick({value:getY(d,i),data:d,index:i,pos:[x(getX(d,i)),y(getY(d,i))],e:d3.event,id:id});d3.event.stopPropagation()});bars.attr("fill",function(d,i){return color(d,i)}).attr("class",function(d,i,j){return(getY(d,i)<0?"nv-bar negative":"nv-bar positive")+" nv-bar-"+j+"-"+i}).transition().attr("transform",function(d,i){return"translate("+(x(getX(d,i))-availableWidth/data[0].values.length*.45)+",0)"}).attr("width",availableWidth/data[0].values.length*.9);bars.transition().attr("y",function(d,i){var rval=getY(d,i)<0?y(0):y(0)-y(getY(d,i))<1?y(0)-1:y(getY(d,i));return nv.utils.NaNtoZero(rval)}).attr("height",function(d,i){return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i))-y(0)),1))})});return chart}chart.highlightPoint=function(pointIndex,isHoverOver){d3.select(".nv-historicalBar-"+id).select(".nv-bars .nv-bar-0-"+pointIndex).classed("hover",isHoverOver)};chart.clearHighlights=function(){d3.select(".nv-historicalBar-"+id).select(".nv-bars .nv-bar.hover").classed("hover",false)};chart.dispatch=dispatch;ch
}if(showYAxis){yAxis.scale(y).ticks(availableHeight/36).tickSize(-availableWidth,0);g.select(".nv-y.nv-axis").transition().call(yAxis)}legend.dispatch.on("stateChange",function(newState){state=newState;dispatch.stateChange(state);chart.update()});interactiveLayer.dispatch.on("elementMousemove",function(e){lines.clearHighlights();var singlePoint,pointIndex,pointXLocation,allData=[];data.filter(function(series,i){series.seriesIndex=i;return!series.disabled}).forEach(function(series,i){pointIndex=nv.interactiveBisect(series.values,e.pointXValue,chart.x());lines.highlightPoint(i,pointIndex,true);var point=series.values[pointIndex];if(typeof point==="undefined")return;if(typeof singlePoint==="undefined")singlePoint=point;if(typeof pointXLocation==="undefined")pointXLocation=chart.xScale()(chart.x()(point,pointIndex));allData.push({key:series.key,value:chart.y()(point,pointIndex),color:color(series,series.seriesIndex)})});if(allData.length>2){var yValue=chart.yScale().invert(e.mouseY);var domainExtent=Math.abs(chart.yScale().domain()[0]-chart.yScale().domain()[1]);var threshold=.03*domainExtent;var indexToHighlight=nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold);if(indexToHighlight!==null)allData[indexToHighlight].highlight=true}var xValue=xAxis.tickFormat()(chart.x()(singlePoint,pointIndex));interactiveLayer.tooltip.position({left:pointXLocation+margin.left,top:e.mouseY+margin.top}).chartContainer(that.parentNode).enabled(tooltips).valueFormatter(function(d,i){return yAxis.tickFormat()(d)}).data({value:xValue,series:allData})();interactiveLayer.renderGuideLine(pointXLocation)});interactiveLayer.dispatch.on("elementMouseout",function(e){dispatch.tooltipHide();lines.clearHighlights()});dispatch.on("tooltipShow",function(e){if(tooltips)showTooltip(e,that.parentNode)});dispatch.on("changeState",function(e){if(typeof e.disabled!=="undefined"&&data.length===e.disabled.length){data.forEach(function(series,i){series.disabled=e.disabled[i]});state.disabled=e.disabled}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;chart.interactiveLayer=interactiveLayer;d3.rebind(chart,lines,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id","interpolate");chart.options=nv.utils.optionsFunc.bind(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(_);legend.color(color);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.useInteractiveGuideline=function(_){if(!arguments.length)return useInteractiveGuideline;useInteractiveGuideline=_;if(_===true){chart.interactive(false);chart.useVoronoi(false)}return chart};chart.tooltips=function(_){if(!arguments.length)return tooltips;tooltips=_;return chart};chart.tooltipContent=function(_){if(!arguments.length)return tooltip;
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.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.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};chart.brushExtent=function(_){if(!arguments.length)return brushExtent;brushExtent=_;return chart};return chart};nv.models.multiBar=function(){"use strict";var margin={top:0,right:0,bottom:0,left:0},width=960,height=500,x=d3.scale.ordinal(),y=d3.scale.linear(),id=Math.floor(Math.random()*1e4),getX=function(d){return d.x},getY=function(d){return d.y},forceY=[0],clipEdge=true,stacked=false,stackOffset="zero",color=nv.utils.defaultColor(),hideable=false,barColor=null,disabled,delay=1200,xDomain,yDomain,xRange,yRange,groupSpacing=.1,dispatch=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");var x0,y0;function chart(selection){selection.each(function(data){var availableWidth=width-margin.left-margin.right,availableHeight=height-margin.top-margin.bottom,container=d3.select(this);if(hideable&&data.length)hideable=[{values:data[0].values.map(function(d){return{x:d.x,y:0,series:d.series,size:.01}})}];if(stacked)data=d3.layout.stack().offset(stackOffset).values(function(d){return d.values}).y(getY)(!data.length&&hideable?hideable:data);data.forEach(function(series,i){series.values.forEach(function(point){point.series=i})});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;negBase=negBase-f.size}else{f.y1=f.size+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(xRange||[0,availableWidth],groupSpacing);y.domain(yDomain||d3.extent(d3.merge(seriesData).map(function(d){return stacked?d.y>0?d.y1:d.y1+d.y:d.y}).concat(forceY))).range(yRange||[availableHeight,0]);if(x.domain()[0]===x.domain()[1])x.domain()[0]?x.domain([x.domain()[0]-x.domain()[0]*.01,x.domain()[1]+x.domain()[1]*.01]):x.domain([-1,1]);if(y.domain()[0]===y.domain()[1])y.domain()[0]?y.domain([y.domain()[0]+y.domain()[0]*.01,y.domain()[1]-y.domain()[1]*.01]):y.domain([-1,1]);x0=x0||x;y0=y0||y;var wrap=container.selectAll("g.nv-wrap.nv-multibar").data([data]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar");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+")");defsEnter.append("clipPath").attr("id","nv-edge-clip-"+id).append("rect");wrap.select("#nv-edge-clip-"+id+" rect").attr("width",availableWidth).attr("height",availableHeight);g.attr("clip-path",clipEdge?"url(#nv-edge-clip-"+id+")":"");var groups=wrap.select(".nv-groups").selectAll(".nv-group").data(function(d){return d},function(d,i){return i});groups.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6);groups.exit().transition().selectAll("rect.nv-bar").delay(function(d,i){return i*delay/data[0].values.length}).attr("y",function(d){return stacked?y0(d.y0):y0(0)}).attr("height",0).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)});groups.transition().style("stroke-opacity",1).style("fill-opacity",.75);var ba
dispatch.tooltipShow(e)});multibar.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.multibar=multibar;chart.legend=legend;chart.xAxis=xAxis;chart.yAxis=yAxis;d3.rebind(chart,multibar,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","delay","showValues","showBarLabels","valueFormat","stacked","barColor");chart.options=nv.utils.optionsFunc.bind(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(_);legend.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.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};chart.noData=function(_){if(!arguments.length)return noData;noData=_;return chart};chart.transitionDuration=function(_){if(!arguments.length)return transitionDuration;transitionDuration=_;return chart};return chart};nv.models.multiChart=function(){"use strict";var margin={top:30,right:20,bottom:50,left:60},color=d3.scale.category20().range(),width=null,height=null,showLegend=true,tooltips=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" at "+x+"</p>"},x,y,yDomain1,yDomain2;var x=d3.scale.linear(),yScale1=d3.scale.linear(),yScale2=d3.scale.linear(),lines1=nv.models.line().yScale(yScale1),lines2=nv.models.line().yScale(yScale2),bars1=nv.models.multiBar().stacked(false).yScale(yScale1),bars2=nv.models.multiBar().stacked(false).yScale(yScale2),stack1=nv.models.stackedArea().yScale(yScale1),stack2=nv.models.stackedArea().yScale(yScale2),xAxis=nv.models.axis().scale(x).orient("bottom").tickPadding(5),yAxis1=nv.models.axis().scale(yScale1).orient("left"),yAxis2=nv.models.axis().scale(yScale2).orient("right"),legend=nv.models.legend().height(30),dispatch=d3.dispatch("tooltipShow","tooltipHide");var showTooltip=function(e,offsetElement){var left=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(lines1.x()(e.point,e.pointIndex)),y=(e.series.yAxis==2?yAxis2:yAxis1).tickFormat()(lines1.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,undefined,undefined,offsetElement.offsetParent)};function chart(selection){selection.each(function(data){var container=d3.select(this),that=this;chart.update=function(){container.transition().call(chart)};chart.container=this;var availableWidth=(width||parseInt(container.style("width"))||960)-margin.left-margin.right,availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom;var dataLines1=data.filter(function(d){return!d.disabled&&d.type=="line"&&d.yAxis==1});var dataLines2=data.filter(function(d){return!d.disabled&&d.type=="line"&&d.yAxis==2});var dataBars1=data.filter(function(d){return!d.disabled&&d.type=="bar"&&d.yAxis==1});var dataBars
data.forEach(function(series,i){series.values.forEach(function(point){point.series=i})});var seriesData=xDomain&&yDomain&&sizeDomain?[]:d3.merge(data.map(function(d){return d.values.map(function(d,i){return{x:getX(d,i),y:getY(d,i),size:getSize(d,i)}})}));x.domain(xDomain||d3.extent(seriesData.map(function(d){return d.x}).concat(forceX)));if(padData&&data[0])x.range(xRange||[(availableWidth*padDataOuter+availableWidth)/(2*data[0].values.length),availableWidth-availableWidth*(1+padDataOuter)/(2*data[0].values.length)]);else x.range(xRange||[0,availableWidth]);y.domain(yDomain||d3.extent(seriesData.map(function(d){return d.y}).concat(forceY))).range(yRange||[availableHeight,0]);z.domain(sizeDomain||d3.extent(seriesData.map(function(d){return d.size}).concat(forceSize))).range(sizeRange||[16,256]);if(x.domain()[0]===x.domain()[1]||y.domain()[0]===y.domain()[1])singlePoint=true;if(x.domain()[0]===x.domain()[1])x.domain()[0]?x.domain([x.domain()[0]-x.domain()[0]*.01,x.domain()[1]+x.domain()[1]*.01]):x.domain([-1,1]);if(y.domain()[0]===y.domain()[1])y.domain()[0]?y.domain([y.domain()[0]-y.domain()[0]*.01,y.domain()[1]+y.domain()[1]*.01]):y.domain([-1,1]);if(isNaN(x.domain()[0])){x.domain([-1,1])}if(isNaN(y.domain()[0])){y.domain([-1,1])}x0=x0||x;y0=y0||y;z0=z0||z;var wrap=container.selectAll("g.nv-wrap.nv-scatter").data([data]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+id+(singlePoint?" nv-single-point":""));var defsEnter=wrapEnter.append("defs");var gEnter=wrapEnter.append("g");var g=wrap.select("g");gEnter.append("g").attr("class","nv-groups");gEnter.append("g").attr("class","nv-point-paths");wrap.attr("transform","translate("+margin.left+","+margin.top+")");defsEnter.append("clipPath").attr("id","nv-edge-clip-"+id).append("rect");wrap.select("#nv-edge-clip-"+id+" rect").attr("width",availableWidth).attr("height",availableHeight);g.attr("clip-path",clipEdge?"url(#nv-edge-clip-"+id+")":"");function updateInteractiveLayer(){if(!interactive)return false;var eventElements;var vertices=d3.merge(data.map(function(group,groupIndex){return group.values.map(function(point,pointIndex){var pX=getX(point,pointIndex);var pY=getY(point,pointIndex);return[x(pX)+Math.random()*1e-7,y(pY)+Math.random()*1e-7,groupIndex,pointIndex,point]}).filter(function(pointArray,pointIndex){return pointActive(pointArray[4],pointIndex)})}));if(useVoronoi===true){if(clipVoronoi){var pointClipsEnter=wrap.select("defs").selectAll(".nv-point-clips").data([id]).enter();pointClipsEnter.append("clipPath").attr("class","nv-point-clips").attr("id","nv-points-clip-"+id);var pointClips=wrap.select("#nv-points-clip-"+id).selectAll("circle").data(vertices);pointClips.enter().append("circle").attr("r",clipRadius);pointClips.exit().remove();pointClips.attr("cx",function(d){return d[0]}).attr("cy",function(d){return d[1]});wrap.select(".nv-point-paths").attr("clip-path","url(#nv-points-clip-"+id+")")}if(vertices.length){vertices.push([x.range()[0]-20,y.range()[0]-20,null,null]);vertices.push([x.range()[1]+20,y.range()[1]+20,null,null]);vertices.push([x.range()[0]-20,y.range()[0]+20,null,null]);vertices.push([x.range()[1]+20,y.range()[1]-20,null,null])}var bounds=d3.geom.polygon([[-10,-10],[-10,height+10],[width+10,height+10],[width+10,-10]]);var voronoi=d3.geom.voronoi(vertices).map(function(d,i){return{data:bounds.clip(d),series:vertices[i][2],point:vertices[i][3]}});var pointPaths=wrap.select(".nv-point-paths").selectAll("path").data(voronoi);pointPaths.enter().append("path").attr("class",function(d,i){return"nv-path-"+i});pointPaths.exit().remove();pointPaths.attr("d",function(d){if(d.data.length===0)return"M 0 0";else return"M"+d.data.join("L")+"Z"});var mouseEventCallback=function(d,mDispatch){if(needsUpdate)return 0;var series=data[d.series];if(typeof series==="undefined")return;var point=series.values[d.point];mDispatch({point:point,series:series,pos:[x(getX(point,d.point))+margin.left,y(getY(point,d.point))+margin.top],seriesIndex:d.series,pointIndex:d.point})};pointPaths.on("click",function(d){mouseEventCallback(d,dispa
});dispatch.on("changeState",function(e){if(typeof e.disabled!=="undefined"){data.forEach(function(series,i){series.disabled=e.disabled[i]});state.disabled=e.disabled}chart.update()});x0=x.copy();y0=y.copy()});return chart}scatter.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e);d3.select(".nv-chart-"+scatter.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",0);d3.select(".nv-chart-"+scatter.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",distY.size())});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.scatter=scatter;chart.legend=legend;chart.controls=controls;chart.xAxis=xAxis;chart.yAxis=yAxis;chart.distX=distX;chart.distY=distY;d3.rebind(chart,scatter,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi");chart.options=nv.utils.optionsFunc.bind(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(_);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.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};chart.transitionDuration=function(_){if(!arguments.length)return transitionDuration;transitionDuration=_;return chart};return chart};nv.models.sparkline=function(){"use strict";var margin={top:2,right:0,bottom:2,left:0},width=400,height=32,animate=true,x=d3.scale.linear(),y=d3.scale.linear(),getX=function(d){return d.x},getY=function(d){return d.y},color=nv.utils.getColor(["#000"]),xDomain,yDomain,xRange,yRange;function chart(selection){selection.each(function(data){var availableWidth=width-margin.left-margin.right,availableHeight=height-margin.top-margin.bottom,container=d3.select(this);x.domain(xDomain||d3.extent(data,getX)).range(xRange||[0,availableWidth]);y.domain(yDomain||d3.extent(data,getY)).range(yRange||[availableHeight,0]);var wrap=container.selectAll("g.nv-wrap.nv-sparkline").data([data]);var wrapEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline");var gEnter=wrapEnter.append("g");var g=wrap.select("g");wrap.attr("transform","translat