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
108 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.models.axis=function(){function j(b){b.each(function(b){var j=d3.select(this),k=j.selectAll("g.wrap.axis").data([b]),l=k.enter().append("g").attr("class","wrap 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.axislabel").data([d||null]);o.exit().remove();switch(h.orient()){case"top":o.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0);var p=c.range().length==2?c.range()[1]:c.range()[c.range().length-1]+(c.range()[1]-c.range()[0]);o.attr("x",p/2);if(e){var q=k.selectAll("g.axisMaxMin").data(c.domain()
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),i.update()}var j=b-a.left-a.right,k=c-a.top-a.bottom;i.update=function(){d.transition().call(i)};var l=0,m=1,n=d3.layout.tree().children(function(a){return a.values}).size([c,childIndent]);e[0].key||(e[0].key=g);var o=n.nodes(e[0]),p=d3.select(this).selectAll("div").data([[o]]),q=p.enter().append("div").attr("class","wrap nvd3 indentedtree"),r=q.append("table"),s=p.select("table").attr("width","100%").attr("class",tableClass);if(f){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([c,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.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("treeicon",!0).classed("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","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){h.elementClick({row:this,data:a,pos:[a.x,a.y]})}).on("dblclick",function(a){h.elementDblclick({row:this,data:a,pos:[a.x,a.y]})}).on("mouseover",function(a){h.elementMouseover({row:this,data:a,pos:[a.x,a.y]})}).on("mouseout",function(a){h.elementMouseout({row:this,data:a,pos:[a.x,a.y]})})});return i}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e4),f=!0,g="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 h=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout");i.margin=function(b){if(!arguments.length)return a;a=b;return i},i.width=function(a){if(!arguments.length)return b;b=a;return i},i.height=function(a){if(!arguments.length)return c;c=a;return i},i.color=function(a){if(!arguments.length)return d;d=a,scatter.color(a);return i},i.id=function(a){if(!arguments.length)return e;e=a;return i},i.header=function(a){if(!arguments.length)return f;f=a;return i},i.noResultsText=function(a){if(!arguments.length)return g;g=a;return i},i.columns=function(a){if(!arguments.length)return columns;columns=a;return i},i.tableClass=function(a){if(!arguments.length)return tableClass;tableClass=a;return i},i.iconOpen=function(a){if(!arguments.length)return iconOpen;iconOpen=a;return i},i.iconClose=function(a){if(!arguments.length)return iconClose;iconClose=a;return i};return i},a.models.legend=function(){function h(i){i.each(function(h){var i=b-a.left-a.right,j=d3.select(this).selectAll("g.legend").data([h]),l=j.enter().append("g").attr("class","nvd3 legend").append("g"),m=j.select("g").attr("transform","translate("+a.left+","+a.top+")"),n=m.selectAll(".series").data(function(a){return a}),o=n.enter().append("g").attr("class","series").on("mouseover",function(a,b){g.legendMouseover(a,b)}).on("mouseout",function(a,b){g.legendMouseout(a,b)}).on("click",function(a,b){g.legendClick(a,b)}).on("dblclick",function(a,b){g.legendDblclick(a,b)});o.append("circle").style("fill",function(a,b){return
().offset("zero").values(function(a){return a.values}).y(h)(o)),o=o.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var z=p&&q?[]:o.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(p||d3.merge(z).map(function(a){return a.x})).rangeBands([0,w],.1),f.domain(q||d3.extent(d3.merge(z).map(function(a){return a.y+(k?a.y0:0)}).concat(i))),l&&!k?f.range([f.domain()[0]<0?m:0,v-(f.domain()[1]>0?m:0)]):f.range([0,v]),r=r||e,s=s||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var A=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([o]),B=A.enter().append("g").attr("class","wrap nvd3 multibarHorizontal"),C=B.append("defs"),D=B.append("g");D.append("g").attr("class","groups");var E=A.select("g");A.attr("transform","translate("+a.left+","+a.top+")");var F=A.select(".groups").selectAll(".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"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return j[b%j.length]}).style("stroke",function(a,b){return j[b%j.length]}),d3.transition(F).style("stroke-opacity",1).style("fill-opacity",.75);var G=F.selectAll("g.bar").data(function(a){return a.values});G.exit().remove();var H=G.enter().append("g").attr("transform",function(a,b,c){return"translate("+s(k?a.y0:0)+","+(k?0:c*e.rangeBand()/o.length+e(g(a,b)))+")"});H.append("rect").attr("width",0).attr("height",e.rangeBand()/(k?1:o.length)),G.on("mouseover",function(a,b){d3.select(this).classed("hover",!0),t.elementMouseover({value:h(a,b),point:a,series:o[a.series],pos:[f(h(a,b)+(k?a.y0:0)),e(g(a,b))+e.rangeBand()*(k?o.length/2:a.series+.5)/o.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),t.elementMouseout({value:h(a,b),point:a,series:o[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){t.elementClick({value:h(a,b),point:a,series:o[a.series],pos:[e(g(a,b))+e.rangeBand()*(k?o.length/2:a.series+.5)/o.length,f(h(a,b)+(k?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){t.elementDblClick({value:h(a,b),point:a,series:o[a.series],pos:[e(g(a,b))+e.rangeBand()*(k?o.length/2:a.series+.5)/o.length,f(h(a,b)+(k?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}),l&&!k?(H.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),G.select("text").attr("y",e.rangeBand()/2).attr("dy","-.32em").text(function(a,b){return n(h(a,b))}),d3.transition(G).select("text").attr("x",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):G.selectAll("text").remove(),G.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),k?d3.transition(G).attr("transform",function(a,b){return"translate("+f(a.y0)+","+e(g(a,b))+")"}).select("rect").attr("width",function(a,b){return Math.abs(f(h(a,b)+a.y0)-f(a.y0))}).attr("height",e.rangeBand()):d3.transition(G).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/o.length+e(g(a,b)))+")"}).select("rect").attr("height",e.rangeBand()/o.length).attr("width",function(a,b){return Math.abs(f(h(a,b))-f(0))}),u.update=function(){d.transition().call(u)},r=e.copy(),s=f.copy()});return u}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],j=d3.scale.category20().range(),k=!1,l=!1,m=60,n=d3.format(",.2f"),o=1200,p,q,r,s,t=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");u.dispatch=t,u.x=function(a){if(!arguments.length)return g;g=a;return u},u.y=function(a){if(!arguments.length)return h;h=a;return u},u.margin=function(b){if(!arguments.length)return
).data(function(a){return[a]});p.enter().append("path"),p.exit().remove(),p.attr("d",d3.svg.line().x(function(a,b){return j(e(a,b))}).y(function(a,b){return k(f(a,b))}));var q=o.selectAll("circle.point").data(function(a){return a.filter(function(a,b){return k.domain().indexOf(f(a,b))!=-1||e(a,b)==j.domain()[1]})});q.enter().append("circle").attr("class","point"),q.exit().remove(),q.attr("cx",function(a,b){return j(e(a,b))}).attr("cy",function(a,b){return k(f(a,b))}).attr("r",2).style("stroke",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"})});return l}var a={top:0,right:0,bottom:0,left:0},b=400,c=32,d=!0,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h,i,j=d3.scale.linear(),k=d3.scale.linear();l.margin=function(b){if(!arguments.length)return a;a=b;return l},l.width=function(a){if(!arguments.length)return b;b=a;return l},l.height=function(a){if(!arguments.length)return c;c=a;return l},l.x=function(a){if(!arguments.length)return e;e=d3.functor(a);return l},l.y=function(a){if(!arguments.length)return f;f=d3.functor(a);return l},l.xDomain=function(a){if(!arguments.length)return h;h=a;return l},l.yDomain=function(a){if(!arguments.length)return i;i=a;return l},l.animate=function(a){if(!arguments.length)return d;d=a;return l};return l},a.models.sparklinePlus=function(){function o(a){a.each(function(a){function w(){var c=d3.event.offsetX-b.left;t.attr("x1",c).attr("x2",c),u.attr("transform",function(a){return"translate("+(c-6)+","+ -b.top+")"}).text(j(Math.round(l.invert(c))));var d=function(a,b){var c=Math.abs(f(a[0])-b),d=0;for(var e=0;e<a.length;e++)Math.abs(f(a[e])-b)<c&&(c=Math.abs(f(a[e])-b),d=e);return d};v.attr("transform",function(a){return"translate("+(c+6)+","+ -b.top+")"}).text(k(g(a[d(a,Math.round(l.invert(c)))])))}var e=c-b.left-b.right,i=d-b.top-b.bottom;l.domain(d3.extent(a,f)).range([0,e]),m.domain(d3.extent(a,g)).range([i,0]);var o=d3.select(this).selectAll("g.sparklineplus").data([a]),p=o.enter().append("g"),q=p.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%h.length]});n.xDomain(l.domain()).yDomain(m.domain()),q.call(n);var r=q.append("g").attr("class","hoverValue"),s=q.append("g").attr("class","hoverArea");r.attr("transform",function(a){return"translate("+l(a)+",0)"});var t=r.append("line").attr("x1",l.range()[1]).attr("y1",-b.top).attr("x2",l.range()[1]).attr("y2",d),u=r.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),v=r.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");s.append("rect").attr("width",e).attr("height",i).on("mousemove",w)});return o}var b={top:15,right:40,bottom:3,left:40},c=400,d=50,e=!0,f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=Math.floor(Math.random()*1e5),j=d3.format(",r"),k=d3.format(",.2f"),l=d3.scale.linear(),m=d3.scale.linear(),n=a.models.sparkline();o.margin=function(a){if(!arguments.length)return b;b=a;return o},o.width=function(a){if(!arguments.length)return c;c=a,n.width(a-b.left-b.right);return o},o.height=function(a){if(!arguments.length)return d;d=a,n.height(a-b.top-b.bottom);return o},o.x=function(a){if(!arguments.length)return f;f=d3.functor(a),n.x(a);return o},o.y=function(a){if(!arguments.length)return g;g=d3.functor(a),n.y(a);return o},o.id=function(a){if(!arguments.length)return i;i=a;return o},o.animate=function(a){if(!arguments.length)return e;e=a;return o};return o},a.models.stackedArea=function(){function r(a){a.each(function(a){var i=c-b.left-b.right,o=d-b.top-b.bottom;m=p.xScale(),n=p.yScale(),a=a.map(function(a,b){a.values=a.values.map(function(b,c){b.index=c,b.stackedY=a.disabled?0:h(b,c);return b});return a}),a=d3.layout.stack().order(k).offset(j).values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}})(a);var r=d3.se