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

4 lines
118 KiB
JavaScript

(function(){function c(a,b,c){return function(d,e,f){var g=a(d),h=[];g<d&&b(g);if(f>1)while(g<e){var i=new Date(+g);c(i)%f===0&&h.push(i),b(g)}else while(g<e)h.push(new Date(+g)),b(g);return h}}function b(a,b){return(new Date(b,a+1,0)).getDate()}var a={version:"0.0.1a",dev:!0};window.nv=a,a.tooltip={},a.utils={},a.models={},a.charts={},a.graphs=[],a.logs={},a.dispatch=d3.dispatch("render_start","render_end"),a.dev&&(a.dispatch.on("render_start",function(b){a.logs.startTime=+(new Date)}),a.dispatch.on("render_end",function(b){a.logs.endTime=+(new Date),a.logs.totalTime=a.logs.endTime-a.logs.startTime,a.log("total",a.logs.totalTime)})),a.log=function(){a.dev&&console.log&&console.log.apply(console,arguments);return arguments[arguments.length-1]},a.render=function b(c){c=c||1,b.active=!0,a.dispatch.render_start(),setTimeout(function(){var d;for(var e=0;e<c&&(graph=b.queue[e]);e++)d=graph.generate(),typeof graph.callback==typeof Function&&graph.callback(d),a.graphs.push(d);b.queue.splice(0,e),b.queue.length?setTimeout(arguments.callee,0):(a.render.active=!1,a.dispatch.render_end())},0)},a.render.queue=[],a.addGraph=function(b){typeof arguments[0]==typeof Function&&(b={generate:arguments[0],callback:arguments[1]}),a.render.queue.push(b),a.render.active||a.render()},a.identity=function(a){return a},a.strip=function(a){return a.replace(/(\s|&)/g,"")},d3.time.monthEnd=function(a){return new Date(a.getFullYear(),a.getMonth(),0)},d3.time.monthEnds=c(d3.time.monthEnd,function(a){a.setUTCDate(a.getUTCDate()+1),a.setDate(b(a.getMonth()+1,a.getFullYear()))},function(a){return a.getMonth()}),function(){var b=window.nv.tooltip={};b.show=function(b,c,d,e,f,g){var h=document.createElement("div");h.className="nvtooltip "+(g?g:"xy-tooltip"),d=d||"s",e=e||20;var i=f?f:document.getElementsByTagName("body")[0];h.innerHTML=c,h.style.left=0,h.style.top=0,h.style.opacity=0,i.appendChild(h);var j=parseInt(h.offsetHeight),k=parseInt(h.offsetWidth),l=a.utils.windowSize().width,m=a.utils.windowSize().height,n=i.scrollTop,o=i.scrollLeft,p,q;switch(d){case"e":p=b[0]-k-e,q=b[1]-j/2,p<o&&(p=b[0]+e),q<n&&(q=n+5),q+j>n+m&&(q=n-j-5);break;case"w":p=b[0]+e,q=b[1]-j/2,p+k>l&&(p=b[0]-k-e),q<n&&(q=n+5),q+j>n+m&&(q=n-j-5);break;case"n":p=b[0]-k/2,q=b[1]+e,p<o&&(p=o+5),p+k>l&&(p=l-k-5),q+j>n+m&&(q=b[1]-j-e);break;case"s":p=b[0]-k/2,q=b[1]-j-e,p<o&&(p=o+5),p+k>l&&(p=l-k-5),n>q&&(q=b[1]+20)}h.style.left=p+"px",h.style.top=q+"px",h.style.opacity=1,h.style.position="absolute",h.style.pointerEvents="none";return h},b.cleanup=function(){var a=document.getElementsByClassName("nvtooltip"),b=[];while(a.length)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){while(b.length){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight);return a},a.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.utils.getColor=function(a){return Object.prototype.toString.call(a)==="[object Array]"?function(b,c){return b.color||a[c%a.length]}:a},a.utils.defaultColor=function(){var a=d3.scale.category20().range();return function(b,c){return a[c%a.length]}},a.models.axis=function(){function j(b){b.each(function(b){var j=d3.select(this),k=j.selectAll("g.nv-wrap.nv-axis").data([b]),l=k.enter().append("g").attr("class","nvd3 nv-wrap nv-axis"),m=l.append("g"),n=k.select("g");(h.orient()=="top"||h.orient()=="bottom")&&h.ticks(Math.abs(c.range()[1]-c.range()[0])/100),d3.transition(n).call(h),i=i||h.scale();var o=n.selectAll("text.nv-axislabel").data([d||null]);o.exit().remove();switch(h.orient()){c
arguments.length)return d;d=a;return k},k.getData=function(a){if(!arguments.length)return f;f=d3.functor(a);return k},k.scale=function(a){if(!arguments.length)return i;i=a;return k},k.color=function(b){if(!arguments.length)return g;g=a.utils.getColor(b);return k};return k},a.models.indentedTree=function(){function j(a){a.each(function(e){function B(a){var b=a.values||a._values;return b&&b.length}function A(a){return a._values&&a._values.length}function z(a){return a._values&&a._values.length?iconOpen:a.values&&a.values.length?iconClose:""}function y(a,b,c){d3.event.stopPropagation();if(d3.event.shiftKey&&!c){d3.event.shiftKey=!1,a.values&&a.values.forEach(function(a){(a.values||a._values)&&y(a,0,!0)});return!0}if(!B(a))return!0;a.values?(a._values=a.values,a.values=null):(a.values=a._values,a._values=null),j.update()}var f=c-b.left-b.right,k=d-b.top-b.bottom;j.update=function(){a.transition().call(j)};var l=0,m=1,n=d3.layout.tree().children(function(a){return a.values}).size([d,childIndent]);e[0].key||(e[0].key=h);var o=n.nodes(e[0]),p=d3.select(this).selectAll("div").data([[o]]),q=p.enter().append("div").attr("class","nvd3 nv-wrap nv-indentedtree"),r=q.append("table"),s=p.select("table").attr("width","100%").attr("class",tableClass);if(g){var t=r.append("thead"),u=t.append("tr");columns.forEach(function(a){u.append("th").attr("width",a.width?a.width:"10%").style("text-align",a.type=="numeric"?"right":"left").append("span").text(a.label)})}var v=s.selectAll("tbody").data(function(a){return a});v.enter().append("tbody"),m=d3.max(o,function(a){return a.depth}),n.size([d,m*childIndent]);var w=v.selectAll("tr").data(function(a){return a},function(a){return a.id||a.id==++l});w.exit().remove(),w.select("img.nv-treeicon").attr("src",z).classed("folded",A);var x=w.enter().append("tr");columns.forEach(function(a,b){var c=x.append("td").style("padding-left",function(a){return(b?0:a.depth*childIndent+12+(z(a)?0:16))+"px"},"important").style("text-align",a.type=="numeric"?"right":"left");b==0&&c.append("img").classed("nv-treeicon",!0).classed("nv-folded",A).attr("src",z).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(a){return z(a)?"inline-block":"none"}).on("click",y),c.append("span").attr("class",d3.functor(a.classes)).text(function(b){return a.format?a.format(b):b[a.key]||"-"}),a.showCount&&c.append("span").attr("class","nv-childrenCount").text(function(a){return a.values&&a.values.length||a._values&&a._values.length?"("+(a.values&&a.values.length||a._values&&a._values.length)+")":""}),a.click&&c.select("span").on("click",a.click)}),w.order().on("click",function(a){i.elementClick({row:this,data:a,pos:[a.x,a.y]})}).on("dblclick",function(a){i.elementDblclick({row:this,data:a,pos:[a.x,a.y]})}).on("mouseover",function(a){i.elementMouseover({row:this,data:a,pos:[a.x,a.y]})}).on("mouseout",function(a){i.elementMouseout({row:this,data:a,pos:[a.x,a.y]})})});return j}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=a.utils.defaultColor(),f=Math.floor(Math.random()*1e4),g=!0,h="No Results found.";childIndent=20,columns=[{key:"key",label:"Name",type:"text"}],tableClass=null,iconOpen="images/grey-plus.png",iconClose="images/grey-minus.png";var i=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout");j.margin=function(a){if(!arguments.length)return b;b=a;return j},j.width=function(a){if(!arguments.length)return c;c=a;return j},j.height=function(a){if(!arguments.length)return d;d=a;return j},j.color=function(b){if(!arguments.length)return e;e=a.utils.getColor(b),scatter.color(e);return j},j.id=function(a){if(!arguments.length)return f;f=a;return j},j.header=function(a){if(!arguments.length)return g;g=a;return j},j.noResultsText=function(a){if(!arguments.length)return h;h=a;return j},j.columns=function(a){if(!arguments.length)return columns;columns=a;return j},j.tableClass=function(a){if(!arguments.length)return tableClass;tableClass=a;return j},j.iconOpen=function(a){if(!arguments.length)return iconOpen;iconOpen=a;return j},j.iconClose=function(a){if(!arguments.le
c+" on "+b+"</p>"},k,l,m=a.models.multiBar().stacked(!1),n=a.models.axis().orient("bottom").highlightZero(!1).showMaxMin(!1),o=a.models.axis().orient("left"),p=a.models.legend().height(30),q=a.models.legend().height(30),r=d3.dispatch("tooltipShow","tooltipHide");n.tickFormat(function(a){return a}),o.tickFormat(d3.format(",.1f"));var s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=n.tickFormat()(m.x()(b.point,b.pointIndex)),g=o.tickFormat()(m.y()(b.point,b.pointIndex)),h=j(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};m.dispatch.on("elementMouseover.tooltip2",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],r.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){r.tooltipHide(a)}),r.on("tooltipHide",function(){i&&a.tooltip.cleanup()}),t.dispatch=r,t.legend=p,t.xAxis=n,t.yAxis=o,d3.rebind(t,m,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked","delay"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return c;c=a;return t},t.height=function(a){if(!arguments.length)return d;d=a;return t},t.color=function(b){if(!arguments.length)return e;e=a.utils.getColor(b),p.color(e);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.reduceXTicks=function(a){if(!arguments.length)return h;h=a;return t},t.tooltips=function(a){if(!arguments.length)return i;i=a;return t},t.tooltipContent=function(a){if(!arguments.length)return j;j=a;return t};return t},a.models.multiBarHorizontal=function(){function v(a){a.each(function(e){var p=c-b.left-b.right,w=d-b.top-b.bottom;l&&(e=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(i)(e)),e=e.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var z=q&&r?[]:e.map(function(a){return a.values.map(function(a,b){return{x:h(a,b),y:i(a,b),y0:a.y0}})});f.domain(q||d3.merge(z).map(function(a){return a.x})).rangeBands([0,w],.1),g.domain(r||d3.extent(d3.merge(z).map(function(a){return a.y+(l?a.y0:0)}).concat(j))),m&&!l?g.range([g.domain()[0]<0?n:0,p-(g.domain()[1]>0?n:0)]):g.range([0,p]),s=s||f,t=t||d3.scale.linear().domain(g.domain()).range([g(0),g(0)]);var A=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([e]),B=A.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal"),C=B.append("defs"),D=B.append("g");D.append("g").attr("class","nv-groups");var E=A.select("g");A.attr("transform","translate("+b.left+","+b.top+")");var F=A.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});F.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(F.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),F.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return k(a,b)}).style("stroke",function(a,b){return k(a,b)}),d3.transition(F).style("stroke-opacity",1).style("fill-opacity",.75);var G=F.selectAll("g.nv-bar").data(function(a){return a.values});G.exit().remove();var H=G.enter().append("g").attr("transform",function(a,b,c){return"translate("+t(l?a.y0:0)+","+(l?0:c*f.rangeBand()/e.length+f(h(a,b)))+")"});H.append("rect").attr("width",0).attr("height",f.rangeBand()/(l?1:e.length)),G.on("mouseover",function(a,b){d3.select(this).classed("hover",!0),u.elementMouseover({value:i(a,b),point:a,series:e[a.series],pos:[g(i(a,b)+(l?a.y0:0)),f(h(a,b))+f.rangeBand()*(l?e.length/2:a.series+.5)/e.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),u.elementMouseout({value:i(a,b),point:a,series:e[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){u.elementClick({value:i(a,b),point:a,series:e[a.series],pos:[f(h(a,b))+f.rangeBand()*(l?e.length/2:a.series+.5)/e.length,g(i(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.s
).attr("transform",function(a,b){return"translate("+A(j(a,b))+","+B(k(a,b))+")"}).attr("d",d3.svg.symbol().type(m).size(function(a,b){return i(l(a,b))})),d3.transition(O.exit().selectAll("path.nv-point")).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).remove(),P.attr("class",function(a,b){return"nv-point nv-point-"+b}),d3.transition(P).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).attr("d",d3.svg.symbol().type(m).size(function(a,b){return i(l(a,b))})),clearTimeout(D),D=setTimeout(N,1e3),A=g.copy(),B=h.copy(),C=i.copy()});return E}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=a.utils.defaultColor(),f=Math.floor(Math.random()*1e5),g=d3.scale.linear(),h=d3.scale.linear(),i=d3.scale.linear(),j=function(a){return a.x},k=function(a){return a.y},l=function(a){return a.size},m=function(a){return a.shape||"circle"},n=[],o=[],p=[],q=!0,r=function(a){return!a.notActive},s=!1,t=!0,u=function(){return 25},v=null,w=null,x=null,y=!1,z=d3.dispatch("elementClick","elementMouseover","elementMouseout"),A,B,C,D;z.on("elementMouseover.point",function(a){q&&d3.select(".nv-chart-"+f+" .nv-series-"+a.seriesIndex+" .nv-point-"+a.pointIndex).classed("hover",!0)}),z.on("elementMouseout.point",function(a){q&&d3.select(".nv-chart-"+f+" .nv-series-"+a.seriesIndex+" .nv-point-"+a.pointIndex).classed("hover",!1)}),E.dispatch=z,E.x=function(a){if(!arguments.length)return j;j=d3.functor(a);return E},E.y=function(a){if(!arguments.length)return k;k=d3.functor(a);return E},E.size=function(a){if(!arguments.length)return l;l=d3.functor(a);return E},E.margin=function(a){if(!arguments.length)return b;b=a;return E},E.width=function(a){if(!arguments.length)return c;c=a;return E},E.height=function(a){if(!arguments.length)return d;d=a;return E},E.xScale=function(a){if(!arguments.length)return g;g=a;return E},E.yScale=function(a){if(!arguments.length)return h;h=a;return E},E.zScale=function(a){if(!arguments.length)return i;i=a;return E},E.xDomain=function(a){if(!arguments.length)return v;v=a;return E},E.yDomain=function(a){if(!arguments.length)return w;w=a;return E},E.sizeDomain=function(a){if(!arguments.length)return x;x=a;return E},E.forceX=function(a){if(!arguments.length)return n;n=a;return E},E.forceY=function(a){if(!arguments.length)return o;o=a;return E},E.forceSize=function(a){if(!arguments.length)return p;p=a;return E},E.interactive=function(a){if(!arguments.length)return q;q=a;return E},E.pointActive=function(a){if(!arguments.length)return r;r=a;return E},E.clipEdge=function(a){if(!arguments.length)return s;s=a;return E},E.clipVoronoi=function(a){if(!arguments.length)return t;t=a;return E},E.clipRadius=function(a){if(!arguments.length)return u;u=a;return E},E.color=function(b){if(!arguments.length)return e;e=a.utils.getColor(b);return E},E.shape=function(a){if(!arguments.length)return m;m=a;return E},E.id=function(a){if(!arguments.length)return f;f=a;return E},E.singlePoint=function(a){if(!arguments.length)return y;y=a;return E};return E},a.models.scatterChart=function(){function D(a){a.each(function(h){function I(){if(m){H.select(".nv-point-paths").style("pointer-events","all");return!1}H.select(".nv-point-paths").style("pointer-events","none");var a=d3.mouse(this);f.distortion(l).focus(a[0]),g.distortion(l).focus(a[1]),H.select(".nv-scatterWrap").datum(h.filter(function(a){return!a.disabled})).call(r),H.select(".nv-x.nv-axis").call(s),H.select(".nv-y.nv-axis").call(t),H.select(".nv-distributionX").datum(h.filter(function(a){return!a.disabled})).call(w),H.select(".nv-distributionY").datum(h.filter(function(a){return!a.disabled})).call(x)}var i=d3.select(this),o=this,p=(c||parseInt(i.style("width"))||960)-b.left-b.right,q=(d||parseInt(i.style("height"))||400)-b.top-b.bottom;f=r.xScale(),g=r.yScale(),z=z||f,A=A||g;var E=i.selectAll("g.nv-wrap.nv-scatterChart").data([h]),F=E.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+r.id()),G=F.append("g"),H=E.select("g");G.append("rect").attr("class","nvd3 nv-background"),G.append("g").attr("class","nv-x nv-axis"),G.app