diff --git a/.gitignore b/.gitignore index 514f751..79d1ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Random Files # ################ *.swp +*~ *.log diff --git a/nv.d3.js b/nv.d3.js index 93b1651..68afa48 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -86,7 +86,7 @@ }; })(jQuery); -(function(d3, window){ +(function(){ var nv = {version: "0.0.1"}; window.nv = nv; @@ -1901,4 +1901,4 @@ nv.models.sparkline = function() { return chart; } -})(d3, window); +})(); diff --git a/nv.d3.min.js b/nv.d3.min.js index dda85c2..e6457ff 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,3 +1,3 @@ /***** * A no frills tooltip implementation. - *****/(function(a){var b=window.nvtooltip={};b.show=function(b,c,d,e){var f=a('
');d=d||"s",e=e||20,f.html(c).css({left:-1e3,top:-1e3,opacity:0}).appendTo("body");var g=f.height()+parseInt(f.css("padding-top"))+parseInt(f.css("padding-bottom")),h=f.width()+parseInt(f.css("padding-left"))+parseInt(f.css("padding-right")),i=a(window).width(),j=a(window).height(),k=a("body").scrollTop(),l=a("body").scrollLeft(),m,n;switch(d){case"e":m=b[0]-h-e,n=b[1]-g/2,mk+j&&(n=k-g-5);break;case"w":m=b[0]+e,n=b[1]-g/2,m+h>i&&(m=b[0]-h-e),nk+j&&(n=k-g-5);break;case"n":m=b[0]-h/2,n=b[1]+e,mi&&(m=i-h-5),n+g>k+j&&(n=b[1]-g-e);break;case"s":m=b[0]-h/2,n=b[1]-g-e,mi&&(m=i-h-5),k>n&&(n=b[1]+20)}f.css({left:m,top:n,opacity:1});return f},b.cleanup=function(){var b=a(".nvtooltip");b.css({"transition-delay":"0 !important","-moz-transition-delay":"0 !important","-webkit-transition-delay":"0 !important"}),b.css("opacity",0),setTimeout(function(){b.remove()},500)}})(jQuery),function(a,b){var c={version:"0.0.1"};b.nv=c,c.models={},c.graphs=[],c.log={},c.dispatch=a.dispatch("render_start","render_end"),b.log=function(a){typeof b.console=="object"&&typeof b.console.log=="function"&&console.log.apply(console,arguments);return a},c.dispatch.on("render_start",function(a){c.log.startTime=+(new Date)}),c.dispatch.on("render_end",function(a){c.log.endTime=+(new Date),c.log.totalTime=c.log.endTime-c.log.startTime,log("total",c.log.totalTime)}),c.render=function a(b){var d=b||1;a.active=!0,c.dispatch.render_start(),setTimeout(function(){var b;for(var e=0;e0?setTimeout(arguments.callee,0):(c.render.active=!1,c.dispatch.render_end())},0)},c.render.queue=[],c.addGraph=function(a){typeof arguments[0]=="function"&&(a={generate:arguments[0],callback:arguments[1]}),c.render.queue.push(a),c.render.active||c.render()},c.strip=function(a){return a.replace(/(\s|&)/g,"")},c.models.legend=function(){function g(h){h.each(function(g){var h=a.select(this).selectAll("g.legend").data([g]),i=h.enter().append("g").attr("class","legend").append("g"),j=h.select("g").attr("transform","translate("+b.left+","+b.top+")"),k=j.selectAll(".series").data(function(a){return a}),l=k.enter().append("g").attr("class","series").on("mouseover",function(a,b){f.legendMouseover(a,b)}).on("mouseout",function(a,b){f.legendMouseout(a,b)}).on("click",function(a,b){f.legendClick(a,b)});l.append("circle").style("fill",function(a,b){return a.color||e[b%20]}).style("stroke",function(a,b){return a.color||e[b%20]}).style("stroke-width",2).attr("r",5),l.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),k.classed("disabled",function(a){return a.disabled}),k.exit().remove();var m=5,n=5,o=0,p;k.attr("transform",function(d,e){var f=a.select(this).select("text").node().getComputedTextLength()+28;p=n,co&&(o=n);return"translate("+p+","+m+")"}),j.attr("transform","translate("+(c-b.right-o)+","+b.top+")"),d=b.top+b.bottom+m+15});return g}var b={top:5,right:0,bottom:5,left:10},c=400,d=20,e=a.scale.category10().range(),f=a.dispatch("legendClick","legendMouseover","legendMouseout");g.dispatch=f,g.margin=function(a){if(!arguments.length)return b;b=a;return g},g.width=function(a){if(!arguments.length)return c;c=a;return g},g.height=function(a){if(!arguments.length)return d;d=a;return g};return g},c.models.xaxis=function(){function g(h){h.each(function(g){e.domain(b).range(c);var h=a.select(this).selectAll("text.axislabel").data([d||null]);h.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("x",c[1]/2).attr("y",25),h.exit().remove(),h.text(function(a){return a}),a.transition(a.select(this)).call(f),a.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return g}var b=[0,1],c=[0,1],d=!1,e=a.scale.linear(),f=a.svg.axis().scale(e).orient("bottom");g.domain=function(a){if(!arguments.length)return b;b=a;return g},g.range=function(a){if(!arguments.length)return c;c=a;return g},g.axisLabel=function(a){if(!arguments.length)return d;d=a;return g},a.rebind(g,f,"scale","orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat");return g},c.models.yaxis=function(){function g(h){h.each(function(g){e.domain(b).range(c);var h=a.select(this).selectAll("text.axislabel").data([d||null]);h.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("text-anchor","middle").attr("y",-40),h.exit().remove(),h.attr("x",-c[0]/2).text(function(a){return a}),a.transition(a.select(this)).call(f),a.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return g}var b=[0,1],c=[0,1],d=!1,e=a.scale.linear(),f=a.svg.axis().scale(e).orient("left");g.domain=function(a){if(!arguments.length)return b;b=a;return g},g.range=function(a){if(!arguments.length)return c;c=a;return g},g.axisLabel=function(a){if(!arguments.length)return d;d=a;return g},a.rebind(g,f,"scale","orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat");return g},c.models.bar=function(){function j(k){k.each(function(j){f.domain(["One","Two","Three","Four","Five"]).rangeRoundBands([0,c-b.left-b.right],.1),g.domain([0,a.max(j,function(a){return a.y})]).range([d-b.top-b.bottom,0]),h.ticks(c/100),i.ticks(d/36).tickSize(-(c-b.right-b.left),0),i.tickSize(-(c-b.right-b.left),0);var k=a.select(this).selectAll("g.wrap").data([j]),l=k.enter().append("g").attr("class","wrap").append("g");l.append("g").attr("class","x axis"),l.append("g").attr("class","y axis"),l.append("g").attr("class","bars"),k.attr("width",c).attr("height",d);var m=k.select("g").attr("transform","translate("+b.left+","+b.top+")"),n=k.select(".bars").selectAll(".bar").data(function(a){return a});n.exit().remove();var o=n.enter().append("g").attr("class","bar").on("mouseover",function(b,c){a.select(this).classed("hover",!0)}).on("mouseout",function(b,c){a.select(this).classed("hover",!1)});o.append("rect").attr("y",function(a){return g(0)}),o.append("text").attr("text-anchor","middle").attr("dy","-4px"),n.attr("transform",function(a,b){return"translate("+f(a.label)+",0)"}),n.selectAll("rect").order().attr("width",f.rangeBand).transition().duration(e).attr("x",0).attr("y",function(a){return g(a.y)}).attr("height",function(a){return g.range()[0]-g(a.y)}),n.selectAll("text").attr("x",0).attr("y",function(a){return g(a.y)}).attr("dx",f.rangeBand()/2).text(function(a){return a.y}),m.select(".x.axis").attr("transform","translate(0,"+g.range()[0]+")").call(h),m.select(".y.axis").call(i)});return j}var b={top:20,right:10,bottom:20,left:60},c=960,d=500,e=500,f=a.scale.ordinal(),g=a.scale.linear(),h=a.svg.axis().scale(f).orient("bottom").ticks(5),i=a.svg.axis().scale(g).orient("left");j.margin=function(a){if(!arguments.length)return b;b=a;return j},j.width=function(a){if(!arguments.length)return c;b.left+b.right+20>a?c=b.left+b.right+20:c=a;return j},j.height=function(a){if(!arguments.length)return d;b.top+b.bottom+20>a?d=b.top+b.bottom+20:d=a;return j},j.animate=function(a){if(!arguments.length)return e;e=a;return j},j.xaxis={},a.rebind(j.xaxis,h,"tickFormat"),j.yaxis={},a.rebind(j.yaxis,i,"tickFormat");return j},c.models.line=function(){function r(s){s.each(function(r){var s=r.map(function(a){return a.values});p=p||m,q=q||n,m.domain(k||a.extent(a.merge(s),h)).range([0,c-b.left-b.right]),n.domain(l||a.extent(a.merge(s),i)).range([d-b.top-b.bottom,0]);var t=a.select(this).selectAll("g.d3line").data([r]),u=t.enter().append("g").attr("class","d3line"),v=u.append("g");v.append("g").attr("class","lines");var w=t.select("g").attr("transform","translate("+b.left+","+b.top+")");u.append("defs").append("clipPath").attr("id","chart-clip-path-"+g).append("rect"),t.select("#chart-clip-path-"+g+" rect").attr("width",c-b.left-b.right).attr("height",d-b.top-b.bottom),v.attr("clip-path","url(#chart-clip-path-"+g+")");var z=v.append("g").attr("class","shiftWrap");if(j){z.append("g").attr("class","point-clips"),z.append("g").attr("class","point-paths");var A=a.merge(r.map(function(a,b){return a.values.map(function(a,c){return[m(h(a)),n(i(a)),b,c]})})),B=t.select(".point-clips").selectAll(".clip-path").data(A);B.enter().append("clipPath").attr("class","clip-path").append("circle").attr("r",25),B.exit().remove(),B.attr("id",function(a,b){return"clip-"+g+"-"+a[2]+"-"+a[3]}).attr("transform",function(a){return"translate("+a[0]+","+a[1]+")"});var C=a.geom.voronoi(A).map(function(a,b){return{data:a,series:A[b][2],point:A[b][3]}}),D=t.select(".point-paths").selectAll("path").data(C);D.enter().append("path").attr("class",function(a,b){return"path-"+b}).style("fill-opacity",0),D.exit().remove(),D.attr("clip-path",function(a,b){return"url(#clip-"+g+"-"+a.series+"-"+a.point+")"}).attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("mouseover",function(a){var c=r[a.series],d=c.values[a.point];o.pointMouseover({point:d,series:c,pos:[m(h(d))+b.left,n(i(d))+b.top],seriesIndex:a.series,pointIndex:a.point})}).on("mouseout",function(a,b){o.pointMouseout({point:r[a.series].values[a.point],series:r[a.series],seriesIndex:a.series,pointIndex:a.point})}),o.on("pointMouseover.point",function(a){t.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),o.on("pointMouseout.point",function(a){t.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1)})}var E=t.select(".lines").selectAll(".line").data(function(a){return a},function(a){return a.key});E.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),a.transition(E.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),E.attr("class",function(a,b){return"line series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return f[b%20]}).style("stroke",function(a,b){return f[b%20]}),a.transition(E).style("stroke-opacity",1).style("fill-opacity",.5);var F=E.selectAll("path").data(function(a,b){return[a.values]});F.enter().append("path").attr("d",a.svg.line().x(function(a){return p(h(a))}).y(function(a){return q(i(a))})),F.exit().remove(),a.transition(F).attr("d",a.svg.line().x(function(a){return m(h(a))}).y(function(a){return n(i(a))}));var G=E.selectAll("circle.point").data(function(a){return a.values});G.enter().append("circle").attr("cx",function(a){return p(h(a))}).attr("cy",function(a){return q(i(a))}),G.exit().remove(),G.attr("class",function(a,b){return"point point-"+b}),a.transition(G).attr("cx",function(a){return m(h(a))}).attr("cy",function(a){return n(i(a))}).attr("r",e),p=m.copy(),q=n.copy()});return r}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=function(){return 2.5},f=a.scale.category10().range(),g=Math.floor(Math.random()*1e4),h=function(a){return a.x},i=function(a){return a.y},j=!0,k,l,m=a.scale.linear(),n=a.scale.linear(),o=a.dispatch("pointMouseover","pointMouseout"),p,q;r.dispatch=o,r.x=function(a){if(!arguments.length)return h;h=a;return r},r.y=function(a){if(!arguments.length)return i;i=a;return r},r.margin=function(a){if(!arguments.length)return b;b=a;return r},r.width=function(a){if(!arguments.length)return c;c=a;return r},r.height=function(a){if(!arguments.length)return d;d=a;return r},r.xDomain=function(a){if(!arguments.length)return k;k=a;return r},r.yDomain=function(a){if(!arguments.length)return l;l=a;return r},r.interactive=function(a){if(!arguments.length)return j;j=a;return r},r.dotRadius=function(b){if(!arguments.length)return e;e=a.functor(b);return r},r.color=function(a){if(!arguments.length)return f;f=a;return r},r.id=function(a){if(!arguments.length)return g;g=a;return r};return r},c.models.lineWithLegend=function(){function I(){m.domain(z.empty()?o.domain():z.extent()),x.xDomain(m.domain()),D.call(x),A.select(".x.axis").call(s)}function H(c){c.each(function(i){var k=i.filter(function(a){return!a.disabled}).map(function(a){return a.values});o.domain(a.extent(a.merge(k),q)).range([0,e-b.left-b.right]),p.domain(a.extent(a.merge(k),r)).range([h-d.top-d.bottom,0]),m.domain(z.empty()?o.domain():z.extent()).range([0,e-b.left-b.right]),n.domain(p.domain()).range([g-b.top-b.bottom,0]),x.width(e-b.left-b.right).height(g-b.top-b.bottom).color(i.map(function(a,b){return a.color||j[b%10]}).filter(function(a,b){return!i[b].disabled})),y.width(e-b.left-b.right).height(h-d.top-d.bottom).color(i.map(function(a,b){return a.color||j[b%10]}).filter(function(a,b){return!i[b].disabled})),A=a.select(this).selectAll("g.wrap").data([i]),B=A.enter().append("g").attr("class","wrap d3lineWithFocus").append("g"),B.append("g").attr("class","focus"),B.append("g").attr("class","context"),B.append("g").attr("class","legendWrap"),C=A.select("g"),w.width(e/2-b.right),C.select(".legendWrap").datum(i).attr("transform","translate("+(e/2-b.left)+",0)").call(w),b.top=w.height(),F=C.select(".focus").attr("transform","translate("+b.left+","+b.top+")"),B.select(".focus").append("g").attr("class","x axis"),B.select(".focus").append("g").attr("class","y axis"),B.select(".focus").append("g").attr("class","focusLines"),D=C.select(".focusLines").datum(i.filter(function(a){return!a.disabled})),a.transition(D).call(x),s.domain(m.domain()).range(m.range()).ticks(e/100).tickSize(-(g-b.top-b.bottom),0),C.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),a.transition(C.select(".x.axis")).call(s),t.domain(n.domain()).range(n.range()).ticks(f/36).tickSize(-(e-b.right-b.left),0),a.transition(C.select(".y.axis")).call(t),E=C.select(".context").attr("transform","translate("+d.left+","+g+")"),B.select(".context").append("g").attr("class","x2 axis"),B.select(".context").append("g").attr("class","y2 axis"),B.select(".context").append("g").attr("class","contextLines"),B.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(z).selectAll("rect").attr("y",-5).attr("height",h+4),G=E.select(".contextLines").datum(i.filter(function(a){return!a.disabled})),a.transition(G).call(y),u.domain(o.domain()).range(o.range()).ticks(e/100).tickSize(-(h-d.top-d.bottom),0),E.select(".x2.axis").attr("transform","translate(0,"+p.range()[0]+")"),a.transition(E.select(".x2.axis")).call(u),v.domain(p.domain()).range(p.range()).ticks((h-d.top-d.bottom)/24).tickSize(-(e-d.right-d.left),0),E.select(".y2.axis"),a.transition(E.select(".y2.axis")).call(v),w.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,i.filter(function(a){return!a.disabled}).length||i.map(function(a){a.disabled=!1,A.selectAll(".series").classed("disabled",!1);return a}),c.transition().call(H)}),w.dispatch.on("legendMouseover",function(a,b){a.hover=!0,c.transition().call(H)}),w.dispatch.on("legendMouseout",function(a,b){a.hover=!1,c.transition().call(H)}),x.dispatch.on("pointMouseover.tooltip",function(a){l.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),x.dispatch.on("pointMouseout.tooltip",function(a){l.tooltipHide(a)})});return H}var b={top:30,right:20,bottom:30,left:60},d={top:0,right:20,bottom:20,left:60},e=960,f=500,g=400,h=100,i=function(){return 2.5},j=a.scale.category10().range(),k=Math.floor(Math.random()*1e4),l=a.dispatch("tooltipShow","tooltipHide"),m=a.scale.linear(),n=a.scale.linear(),o=a.scale.linear(),p=a.scale.linear(),q=function(a){return a.x},r=function(a){return a.y},s=c.models.xaxis().scale(m),t=c.models.yaxis().scale(n),u=c.models.xaxis().scale(o),v=c.models.yaxis().scale(p),w=c.models.legend().height(30),x=c.models.line(),y=c.models.line().dotRadius(.1).interactive(!1),z=a.svg.brush().x(o).on("brush",I),A,B,C,x,D,E,F,G;H.dispatch=l,H.x=function(a){if(!arguments.length)return q;q=a,x.x(a),y.x(a);return H},H.y=function(a){if(!arguments.length)return r;r=a,x.y(a),y.y(a);return H},H.margin=function(a){if(!arguments.length)return b;b=a;return H},H.width=function(a){if(!arguments.length)return e;e=a;return H},H.height=function(a){if(!arguments.length)return f;f=a,g=a-h;return H},H.contextHeight=function(a){if(!arguments.length)return h;h=a,g=f-a;return H},H.dotRadius=function(b){if(!arguments.length)return i;i=a.functor(b),x.dotRadius=b;return H},H.id=function(a){if(!arguments.length)return k;k=a;return H},H.xTickFormat=function(a){if(!arguments.length)return m.tickFormat();s.tickFormat(a),u.tickFormat(a);return H},H.yTickFormat=function(a){if(!arguments.length)return n.tickFormat();t.tickFormat(a),v.tickFormat(a);return H},H.xAxis=s,H.yAxis=t;return H},c.models.lineWithLegend=function(){function q(c){c.each(function(f){var r=f.filter(function(a){return!a.disabled}).map(function(a){return a.values});i.domain(a.extent(a.merge(r),k)).range([0,d-b.left-b.right]),j.domain(a.extent(a.merge(r),l)).range([e-b.top-b.bottom,0]),p.width(d-b.left-b.right).height(e-b.top-b.bottom).color(f.map(function(a,b){return a.color||g[b%10]}).filter(function(a,b){return!f[b].disabled}));var s=a.select(this).selectAll("g.wrap").data([f]),t=s.enter().append("g").attr("class","wrap d3lineWithLegend").append("g");t.append("g").attr("class","x axis"),t.append("g").attr("class","y axis"),t.append("g").attr("class","linesWrap"),t.append("g").attr("class","legendWrap"),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,s.selectAll(".series").classed("disabled",!1);return a}),c.transition().call(q)}),o.dispatch.on("legendMouseover",function(a,b){a.hover=!0,c.transition().call(q)}),o.dispatch.on("legendMouseout",function(a,b){a.hover=!1,c.transition().call(q)}),p.dispatch.on("pointMouseover.tooltip",function(a){h.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),p.dispatch.on("pointMouseout.tooltip",function(a){h.tooltipHide(a)}),b.top=o.height();var u=s.select("g").attr("transform","translate("+b.left+","+o.height()+")");o.width(d/2-b.right),u.select(".legendWrap").datum(f).attr("transform","translate("+(d/2-b.left)+","+ -o.height()+")").call(o);var v=u.select(".linesWrap").datum(f.filter(function(a){return!a.disabled}));a.transition(v).call(p),m.domain(i.domain()).range(i.range()).ticks(d/100).tickSize(-(e-b.top-b.bottom),0),u.select(".x.axis").attr("transform","translate(0,"+j.range()[0]+")"),a.transition(u.select(".x.axis")).call(m),n.domain(j.domain()).range(j.range()).ticks(e/36).tickSize(-(d-b.right-b.left),0),a.transition(u.select(".y.axis")).call(n)});return q}var b={top:30,right:20,bottom:50,left:60},d=960,e=500,f=function(){return 2.5},g=a.scale.category10().range(),h=a.dispatch("tooltipShow","tooltipHide"),i=a.scale.linear(),j=a.scale.linear(),k=function(a){return a.x},l=function(a){return a.y},m=c.models.xaxis().scale(i),n=c.models.yaxis().scale(j),o=c.models.legend().height(30),p=c.models.line();q.dispatch=h,q.x=function(a){if(!arguments.length)return k;k=a,p.x(a);return q},q.y=function(a){if(!arguments.length)return l;l=a,p.y(a);return q},q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return d;d=a;return q},q.height=function(a){if(!arguments.length)return e;e=a;return q},q.dotRadius=function(b){if(!arguments.length)return f;f=a.functor(b),p.dotRadius=b;return q},q.xAxis=m,q.yAxis=n;return q},c.models.scatter=function(){function s(t){t.each(function(s){var t=s.map(function(a){return a.values});o=o||g,p=p||h,q=q||i,s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a}),g.domain(a.extent(a.merge(t).map(j).concat(m))).range([0,c-b.left-b.right]),h.domain(a.extent(a.merge(t).map(k).concat(n))).range([d-b.top-b.bottom,0]),i.domain(a.extent(a.merge(t),l)).range([2,10]);var u=a.merge(s.map(function(a,b){return a.values.map(function(a,c){return[g(j(a)),h(k(a)),b,c]})})),v=a.select(this).selectAll("g.d3scatter").data([s]),w=v.enter().append("g").attr("class","d3scatter").append("g");w.append("g").attr("class","groups"),w.append("g").attr("class","point-clips"),w.append("g").attr("class","point-paths"),w.append("g").attr("class","distribution");var A=v.select("g").attr("transform","translate("+b.left+","+b.top+")"),B=w.append("g").attr("class","voronoi-clip").append("clipPath").attr("id","voronoi-clip-path-"+f).append("rect");v.select(".voronoi-clip rect").attr("x",-10).attr("y",-10).attr("width",c-b.left-b.right+20).attr("height",d-b.top-b.bottom+20),v.select(".point-paths").attr("clip-path","url(#voronoi-clip-path-"+f+")");var C=v.select(".point-clips").selectAll(".clip-path").data(u);C.enter().append("clipPath").attr("class","clip-path").append("circle").attr("r",25),C.exit().remove(),C.attr("id",function(a,b){return"clip-"+f+"-"+a[2]+"-"+a[3]}).attr("transform",function(a){return"translate("+a[0]+","+a[1]+")"});var D=a.geom.voronoi(u).map(function(a,b){return{data:a,series:u[b][2],point:u[b][3]}}),E=v.select(".point-paths").selectAll("path").data(D);E.enter().append("path").attr("class",function(a,b){return"path-"+b}),E.exit().remove(),E.attr("clip-path",function(a,b){return"url(#clip-"+f+"-"+a.series+"-"+a.point+")"}).attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("mouseover",function(a){r.pointMouseover({point:s[a.series].values[a.point],series:s[a.series],pos:[g(j(s[a.series].values[a.point]))+b.left,h(k(s[a.series].values[a.point]))+b.top],seriesIndex:a.series,pointIndex:a.point})}).on("mouseout",function(a,b){r.pointMouseout({point:s[a.series].values[a.point],series:s[a.series],seriesIndex:a.series,pointIndex:a.point})});var F=v.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),a.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&&!a.disabled}),a.transition(F).style("fill",function(a,b){return e[b%10]}).style("stroke",function(a,b){return e[b%10]}).style("stroke-opacity",1).style("fill-opacity",.5);var G=F.selectAll("circle.point").data(function(a){return a.values});G.enter().append("circle").attr("cx",function(a){return o(j(a))}).attr("cy",function(a){return p(k(a))}).attr("r",function(a){return q(l(a))}),G.exit().remove(),G.attr("class",function(a,b){return"point point-"+b}),a.transition(G).attr("cx",function(a){return g(j(a))}).attr("cy",function(a){return h(k(a))}).attr("r",function(a){return i(l(a))});var H=F.selectAll("line.distX").data(function(a){return a.values});H.enter().append("line").attr("x1",function(a){return o(j(a))}).attr("x2",function(a){return o(j(a))}),H.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",h.range()[0]).attr("y2",h.range()[0]+8),a.transition(H).attr("x1",function(a){return g(j(a))}).attr("x2",function(a){return g(j(a))}),H.exit().remove();var I=F.selectAll("line.distY").data(function(a){return a.values});I.enter().append("line").attr("y1",function(a){return p(k(a))}).attr("y2",function(a){return p(k(a))}),I.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",g.range()[0]).attr("x2",g.range()[0]-8),a.transition(I).attr("y1",function(a){return h(k(a))}).attr("y2",function(a){return h(k(a))}),I.exit().remove(),r.on("pointMouseover.point",function(a){v.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0),v.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]-b.top),v.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0]-b.left)}),r.on("pointMouseout.point",function(a){v.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1),v.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",h.range()[0]),v.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",g.range()[0])}),o=g.copy(),p=h.copy(),q=i.copy()});return s}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=a.scale.category10().range(),f=Math.floor(Math.random()*1e5),g=a.scale.linear(),h=a.scale.linear(),i=a.scale.sqrt(),j=function(a){return a.x},k=function(a){return a.y},l=function(a){return a.size},m=[],n=[],o,p,q,r=a.dispatch("pointMouseover","pointMouseout");s.dispatch=r,s.margin=function(a){if(!arguments.length)return b;b=a;return s},s.width=function(a){if(!arguments.length)return c;c=a;return s},s.height=function(a){if(!arguments.length)return d;d=a;return s},s.x=function(b){if(!arguments.length)return j;j=a.functor(b);return s},s.y=function(b){if(!arguments.length)return k;k=a.functor(b);return s},s.size=function(b){if(!arguments.length)return l;l=a.functor(b);return s},s.forceX=function(a){if(!arguments.length)return m;m=a;return s},s.forceY=function(a){if(!arguments.length)return n;n=a;return s},s.color=function(a){if(!arguments.length)return e;e=a;return s},s.id=function(a){if(!arguments.length)return f;f=a;return s};return s},c.models.scatterWithLegend=function(){function x(c){c.each(function(g){var h=g.filter(function(a){return!a.disabled}).map(function(a){return a.values});r.domain(a.extent(a.merge(h).map(l).concat(o))).range([0,d-b.left-b.right]),s.domain(a.extent(a.merge(h).map(m).concat(p))).range([e-b.top-b.bottom,0]),w.width(d-b.left-b.right).height(e-b.top-b.bottom).color(g.map(function(a,b){return a.color||k[b%20]}).filter(function(a,b){return!g[b].disabled})),t.ticks(d/100).tickSize(-(e-b.top-b.bottom),0),u.ticks(e/36).tickSize(-(d-b.right-b.left),0);var i=a.select(this).selectAll("g.wrap").data([g]),j=i.enter().append("g").attr("class","wrap d3lineWithLegend").append("g");j.append("g").attr("class","legendWrap"),j.append("g").attr("class","x axis"),j.append("g").attr("class","y axis"),j.append("g").attr("class","scatterWrap"),v.dispatch.on("legendClick",function(a,b,d){a.disabled=!a.disabled,g.filter(function(a){return!a.disabled}).length||g.map(function(a){a.disabled=!1,i.selectAll(".series").classed("disabled",!1);return a}),c.transition(f).call(x)}),v.dispatch.on("legendMouseover",function(a,b){a.hover=!0,c.transition().call(x)}),v.dispatch.on("legendMouseout",function(a,b){a.hover=!1,c.transition().call(x)}),w.dispatch.on("pointMouseover.tooltip",function(a){q.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),w.dispatch.on("pointMouseout.tooltip",function(a){q.tooltipHide(a)}),v.width(d/2-b.right),i.select(".legendWrap").datum(g).attr("transform","translate("+(d/2-b.left)+","+ -v.height()+")").call(v),b.top=v.height();var n=i.select("g").attr("transform","translate("+b.left+","+b.top+")"),z=i.select(".scatterWrap").datum(g.filter(function(a){return!a.disabled}));a.transition(z).call(w),t.domain(r.domain()).range(r.range()).ticks(d/100).tickSize(-(e-b.top-b.bottom),0),n.select(".x.axis").attr("transform","translate(0,"+s.range()[0]+")"),a.transition(n.select(".x.axis")).call(t),u.domain(s.domain()).range(s.range()).ticks(e/36).tickSize(-(d-b.right-b.left),0),a.transition(n.select(".y.axis")).call(u)});return x}var b={top:30,right:20,bottom:50,left:60},d=960,e=500,f=500,g=!0,h=!0,i=!1,j=!1,k=a.scale.category10().range(),l=function(a){return a.x},m=function(a){return a.y},n=function(a){return a.size},o=[],p=[],q=a.dispatch("tooltipShow","tooltipHide"),r=a.scale.linear(),s=a.scale.linear(),t=c.models.xaxis().scale(r).tickPadding(10),u=c.models.yaxis().scale(s).tickPadding(10),v=c.models.legend().height(30),w=c.models.scatter();x.dispatch=q,x.margin=function(a){if(!arguments.length)return b;b=a;return x},x.width=function(a){if(!arguments.length)return d;d=a;return x},x.height=function(a){if(!arguments.length)return e;e=a;return x},x.forceX=function(a){if(!arguments.length)return o;o=a,w.forceX(a);return x},x.forceY=function(a){if(!arguments.length)return p;p=a,w.forceY(a);return x},x.animate=function(a){if(!arguments.length)return f;f=a;return x},x.xAxis=t,x.yAxis=u;return x},c.models.sparkline=function(){function i(e){e.each(function(e){g.domain(a.extent(e,function(a){return a.x})).range([0,c-b.left-b.right]),h.domain(a.extent(e,function(a){return a.y})).range([d-b.top-b.bottom,0]);var i=a.select(this).selectAll("svg").data([e]),j=i.enter().append("svg").append("g");j.append("g").attr("class","sparkline").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||f[b*2%20]}),i.attr("width",c).attr("height",d);var k=j.select(".sparkline").selectAll("path").data(function(a){return[a]});k.enter().append("path"),k.exit().remove(),k.attr("d",a.svg.line().x(function(a){return g(a.x)}).y(function(a){return h(a.y)}));var l=j.select(".sparkline").selectAll("circle.point").data(function(a){return a.filter(function(a){return h.domain().indexOf(a.y)!=-1})});l.enter().append("circle").attr("class","point"),l.exit().remove(),l.attr("cx",function(a){return g(a.x)}).attr("cy",function(a){return h(a.y)}).attr("r",2).style("stroke",function(a,b){return a.y==h.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.y==h.domain()[0]?"#d62728":"#2ca02c"})});return i}var b={top:3,right:3,bottom:3,left:3},c=200,d=20,e=!0,f=a.scale.category20().range(),g=a.scale.linear(),h=a.scale.linear();i.margin=function(a){if(!arguments.length)return b;b=a;return i},i.width=function(a){if(!arguments.length)return c;c=a;return i},i.height=function(a){if(!arguments.length)return d;d=a;return i},i.animate=function(a){if(!arguments.length)return e;e=a;return i};return i}}(d3,window) \ No newline at end of file + *****/(function(a){var b=window.nvtooltip={};b.show=function(b,c,d,e){var f=a('
');d=d||"s",e=e||20,f.html(c).css({left:-1e3,top:-1e3,opacity:0}).appendTo("body");var g=f.height()+parseInt(f.css("padding-top"))+parseInt(f.css("padding-bottom")),h=f.width()+parseInt(f.css("padding-left"))+parseInt(f.css("padding-right")),i=a(window).width(),j=a(window).height(),k=a("body").scrollTop(),l=a("body").scrollLeft(),m,n;switch(d){case"e":m=b[0]-h-e,n=b[1]-g/2,mk+j&&(n=k-g-5);break;case"w":m=b[0]+e,n=b[1]-g/2,m+h>i&&(m=b[0]-h-e),nk+j&&(n=k-g-5);break;case"n":m=b[0]-h/2,n=b[1]+e,mi&&(m=i-h-5),n+g>k+j&&(n=b[1]-g-e);break;case"s":m=b[0]-h/2,n=b[1]-g-e,mi&&(m=i-h-5),k>n&&(n=b[1]+20)}f.css({left:m,top:n,opacity:1});return f},b.cleanup=function(){var b=a(".nvtooltip");b.css({"transition-delay":"0 !important","-moz-transition-delay":"0 !important","-webkit-transition-delay":"0 !important"}),b.css("opacity",0),setTimeout(function(){b.remove()},500)}})(jQuery),function(){var a={version:"0.0.1"};window.nv=a,a.models={},a.graphs=[],a.log={},a.dispatch=d3.dispatch("render_start","render_end"),window.log=function(a){typeof window.console=="object"&&typeof window.console.log=="function"&&console.log.apply(console,arguments);return a},a.dispatch.on("render_start",function(b){a.log.startTime=+(new Date)}),a.dispatch.on("render_end",function(b){a.log.endTime=+(new Date),a.log.totalTime=a.log.endTime-a.log.startTime,log("total",a.log.totalTime)}),a.render=function b(c){var d=c||1;b.active=!0,a.dispatch.render_start(),setTimeout(function(){var c;for(var e=0;e0?setTimeout(arguments.callee,0):(a.render.active=!1,a.dispatch.render_end())},0)},a.render.queue=[],a.addGraph=function(b){typeof arguments[0]=="function"&&(b={generate:arguments[0],callback:arguments[1]}),a.render.queue.push(b),a.render.active||a.render()},a.strip=function(a){return a.replace(/(\s|&)/g,"")},a.models.legend=function(){function f(g){g.each(function(f){var g=d3.select(this).selectAll("g.legend").data([f]),h=g.enter().append("g").attr("class","legend").append("g"),i=g.select("g").attr("transform","translate("+a.left+","+a.top+")"),j=i.selectAll(".series").data(function(a){return a}),k=j.enter().append("g").attr("class","series").on("mouseover",function(a,b){e.legendMouseover(a,b)}).on("mouseout",function(a,b){e.legendMouseout(a,b)}).on("click",function(a,b){e.legendClick(a,b)});k.append("circle").style("fill",function(a,b){return a.color||d[b%20]}).style("stroke",function(a,b){return a.color||d[b%20]}).style("stroke-width",2).attr("r",5),k.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),j.classed("disabled",function(a){return a.disabled}),j.exit().remove();var l=5,m=5,n=0,o;j.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;o=m,bn&&(n=m);return"translate("+o+","+l+")"}),i.attr("transform","translate("+(b-a.right-n)+","+a.top+")"),c=a.top+a.bottom+l+15});return f}var a={top:5,right:0,bottom:5,left:10},b=400,c=20,d=d3.scale.category10().range(),e=d3.dispatch("legendClick","legendMouseover","legendMouseout");f.dispatch=e,f.margin=function(b){if(!arguments.length)return a;a=b;return f},f.width=function(a){if(!arguments.length)return b;b=a;return f},f.height=function(a){if(!arguments.length)return c;c=a;return f};return f},a.models.xaxis=function(){function f(g){g.each(function(f){d.domain(a).range(b);var g=d3.select(this).selectAll("text.axislabel").data([c||null]);g.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("x",b[1]/2).attr("y",25),g.exit().remove(),g.text(function(a){return a}),d3.transition(d3.select(this)).call(e),d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return f}var a=[0,1],b=[0,1],c=!1,d=d3.scale.linear(),e=d3.svg.axis().scale(d).orient("bottom");f.domain=function(b){if(!arguments.length)return a;a=b;return f},f.range=function(a){if(!arguments.length)return b;b=a;return f},f.axisLabel=function(a){if(!arguments.length)return c;c=a;return f},d3.rebind(f,e,"scale","orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat");return f},a.models.yaxis=function(){function f(g){g.each(function(f){d.domain(a).range(b);var g=d3.select(this).selectAll("text.axislabel").data([c||null]);g.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("text-anchor","middle").attr("y",-40),g.exit().remove(),g.attr("x",-b[0]/2).text(function(a){return a}),d3.transition(d3.select(this)).call(e),d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return f}var a=[0,1],b=[0,1],c=!1,d=d3.scale.linear(),e=d3.svg.axis().scale(d).orient("left");f.domain=function(b){if(!arguments.length)return a;a=b;return f},f.range=function(a){if(!arguments.length)return b;b=a;return f},f.axisLabel=function(a){if(!arguments.length)return c;c=a;return f},d3.rebind(f,e,"scale","orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat");return f},a.models.bar=function(){function i(j){j.each(function(i){e.domain(["One","Two","Three","Four","Five"]).rangeRoundBands([0,b-a.left-a.right],.1),f.domain([0,d3.max(i,function(a){return a.y})]).range([c-a.top-a.bottom,0]),g.ticks(b/100),h.ticks(c/36).tickSize(-(b-a.right-a.left),0),h.tickSize(-(b-a.right-a.left),0);var j=d3.select(this).selectAll("g.wrap").data([i]),k=j.enter().append("g").attr("class","wrap").append("g");k.append("g").attr("class","x axis"),k.append("g").attr("class","y axis"),k.append("g").attr("class","bars"),j.attr("width",b).attr("height",c);var l=j.select("g").attr("transform","translate("+a.left+","+a.top+")"),m=j.select(".bars").selectAll(".bar").data(function(a){return a});m.exit().remove();var n=m.enter().append("g").attr("class","bar").on("mouseover",function(a,b){d3.select(this).classed("hover",!0)}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1)});n.append("rect").attr("y",function(a){return f(0)}),n.append("text").attr("text-anchor","middle").attr("dy","-4px"),m.attr("transform",function(a,b){return"translate("+e(a.label)+",0)"}),m.selectAll("rect").order().attr("width",e.rangeBand).transition().duration(d).attr("x",0).attr("y",function(a){return f(a.y)}).attr("height",function(a){return f.range()[0]-f(a.y)}),m.selectAll("text").attr("x",0).attr("y",function(a){return f(a.y)}).attr("dx",e.rangeBand()/2).text(function(a){return a.y}),l.select(".x.axis").attr("transform","translate(0,"+f.range()[0]+")").call(g),l.select(".y.axis").call(h)});return i}var a={top:20,right:10,bottom:20,left:60},b=960,c=500,d=500,e=d3.scale.ordinal(),f=d3.scale.linear(),g=d3.svg.axis().scale(e).orient("bottom").ticks(5),h=d3.svg.axis().scale(f).orient("left");i.margin=function(b){if(!arguments.length)return a;a=b;return i},i.width=function(c){if(!arguments.length)return b;a.left+a.right+20>c?b=a.left+a.right+20:b=c;return i},i.height=function(b){if(!arguments.length)return c;a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b;return i},i.animate=function(a){if(!arguments.length)return d;d=a;return i},i.xaxis={},d3.rebind(i.xaxis,g,"tickFormat"),i.yaxis={},d3.rebind(i.yaxis,h,"tickFormat");return i},a.models.line=function(){function q(r){r.each(function(q){var r=q.map(function(a){return a.values});o=o||l,p=p||m,l.domain(j||d3.extent(d3.merge(r),g)).range([0,b-a.left-a.right]),m.domain(k||d3.extent(d3.merge(r),h)).range([c-a.top-a.bottom,0]);var s=d3.select(this).selectAll("g.d3line").data([q]),t=s.enter().append("g").attr("class","d3line"),u=t.append("g");u.append("g").attr("class","lines");var v=s.select("g").attr("transform","translate("+a.left+","+a.top+")");t.append("defs").append("clipPath").attr("id","chart-clip-path-"+f).append("rect"),s.select("#chart-clip-path-"+f+" rect").attr("width",b-a.left-a.right).attr("height",c-a.top-a.bottom),u.attr("clip-path","url(#chart-clip-path-"+f+")");var w=u.append("g").attr("class","shiftWrap");if(i){w.append("g").attr("class","point-clips"),w.append("g").attr("class","point-paths");var z=d3.merge(q.map(function(a,b){return a.values.map(function(a,c){return[l(g(a)),m(h(a)),b,c]})})),A=s.select(".point-clips").selectAll(".clip-path").data(z);A.enter().append("clipPath").attr("class","clip-path").append("circle").attr("r",25),A.exit().remove(),A.attr("id",function(a,b){return"clip-"+f+"-"+a[2]+"-"+a[3]}).attr("transform",function(a){return"translate("+a[0]+","+a[1]+")"});var B=d3.geom.voronoi(z).map(function(a,b){return{data:a,series:z[b][2],point:z[b][3]}}),C=s.select(".point-paths").selectAll("path").data(B);C.enter().append("path").attr("class",function(a,b){return"path-"+b}).style("fill-opacity",0),C.exit().remove(),C.attr("clip-path",function(a,b){return"url(#clip-"+f+"-"+a.series+"-"+a.point+")"}).attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("mouseover",function(b){var c=q[b.series],d=c.values[b.point];n.pointMouseover({point:d,series:c,pos:[l(g(d))+a.left,m(h(d))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){n.pointMouseout({point:q[a.series].values[a.point],series:q[a.series],seriesIndex:a.series,pointIndex:a.point})}),n.on("pointMouseover.point",function(a){s.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),n.on("pointMouseout.point",function(a){s.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1)})}var D=s.select(".lines").selectAll(".line").data(function(a){return a},function(a){return a.key});D.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(D.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),D.attr("class",function(a,b){return"line series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(D).style("stroke-opacity",1).style("fill-opacity",.5);var E=D.selectAll("path").data(function(a,b){return[a.values]});E.enter().append("path").attr("d",d3.svg.line().x(function(a){return o(g(a))}).y(function(a){return p(h(a))})),E.exit().remove(),d3.transition(E).attr("d",d3.svg.line().x(function(a){return l(g(a))}).y(function(a){return m(h(a))}));var F=D.selectAll("circle.point").data(function(a){return a.values});F.enter().append("circle").attr("cx",function(a){return o(g(a))}).attr("cy",function(a){return p(h(a))}),F.exit().remove(),F.attr("class",function(a,b){return"point point-"+b}),d3.transition(F).attr("cx",function(a){return l(g(a))}).attr("cy",function(a){return m(h(a))}).attr("r",d),o=l.copy(),p=m.copy()});return q}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=function(){return 2.5},e=d3.scale.category10().range(),f=Math.floor(Math.random()*1e4),g=function(a){return a.x},h=function(a){return a.y},i=!0,j,k,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.dispatch("pointMouseover","pointMouseout"),o,p;q.dispatch=n,q.x=function(a){if(!arguments.length)return g;g=a;return q},q.y=function(a){if(!arguments.length)return h;h=a;return q},q.margin=function(b){if(!arguments.length)return a;a=b;return q},q.width=function(a){if(!arguments.length)return b;b=a;return q},q.height=function(a){if(!arguments.length)return c;c=a;return q},q.xDomain=function(a){if(!arguments.length)return j;j=a;return q},q.yDomain=function(a){if(!arguments.length)return k;k=a;return q},q.interactive=function(a){if(!arguments.length)return i;i=a;return q},q.dotRadius=function(a){if(!arguments.length)return d;d=d3.functor(a);return q},q.color=function(a){if(!arguments.length)return e;e=a;return q},q.id=function(a){if(!arguments.length)return f;f=a;return q};return q},a.models.lineWithLegend=function(){function H(){l.domain(y.empty()?n.domain():y.extent()),w.xDomain(l.domain()),C.call(w),z.select(".x.axis").call(r)}function G(a){a.each(function(h){var j=h.filter(function(a){return!a.disabled}).map(function(a){return a.values});n.domain(d3.extent(d3.merge(j),p)).range([0,d-b.left-b.right]),o.domain(d3.extent(d3.merge(j),q)).range([g-c.top-c.bottom,0]),l.domain(y.empty()?n.domain():y.extent()).range([0,d-b.left-b.right]),m.domain(o.domain()).range([f-b.top-b.bottom,0]),w.width(d-b.left-b.right).height(f-b.top-b.bottom).color(h.map(function(a,b){return a.color||i[b%10]}).filter(function(a,b){return!h[b].disabled})),x.width(d-b.left-b.right).height(g-c.top-c.bottom).color(h.map(function(a,b){return a.color||i[b%10]}).filter(function(a,b){return!h[b].disabled})),z=d3.select(this).selectAll("g.wrap").data([h]),A=z.enter().append("g").attr("class","wrap d3lineWithFocus").append("g"),A.append("g").attr("class","focus"),A.append("g").attr("class","context"),A.append("g").attr("class","legendWrap"),B=z.select("g"),v.width(d/2-b.right),B.select(".legendWrap").datum(h).attr("transform","translate("+(d/2-b.left)+",0)").call(v),b.top=v.height(),E=B.select(".focus").attr("transform","translate("+b.left+","+b.top+")"),A.select(".focus").append("g").attr("class","x axis"),A.select(".focus").append("g").attr("class","y axis"),A.select(".focus").append("g").attr("class","focusLines"),C=B.select(".focusLines").datum(h.filter(function(a){return!a.disabled})),d3.transition(C).call(w),r.domain(l.domain()).range(l.range()).ticks(d/100).tickSize(-(f-b.top-b.bottom),0),B.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(B.select(".x.axis")).call(r),s.domain(m.domain()).range(m.range()).ticks(e/36).tickSize(-(d-b.right-b.left),0),d3.transition(B.select(".y.axis")).call(s),D=B.select(".context").attr("transform","translate("+c.left+","+f+")"),A.select(".context").append("g").attr("class","x2 axis"),A.select(".context").append("g").attr("class","y2 axis"),A.select(".context").append("g").attr("class","contextLines"),A.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(y).selectAll("rect").attr("y",-5).attr("height",g+4),F=D.select(".contextLines").datum(h.filter(function(a){return!a.disabled})),d3.transition(F).call(x),t.domain(n.domain()).range(n.range()).ticks(d/100).tickSize(-(g-c.top-c.bottom),0),D.select(".x2.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(D.select(".x2.axis")).call(t),u.domain(o.domain()).range(o.range()).ticks((g-c.top-c.bottom)/24).tickSize(-(d-c.right-c.left),0),D.select(".y2.axis"),d3.transition(D.select(".y2.axis")).call(u),v.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,h.filter(function(a){return!a.disabled}).length||h.map(function(a){a.disabled=!1,z.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(G)}),v.dispatch.on("legendMouseover",function(b,c){b.hover=!0,a.transition().call(G)}),v.dispatch.on("legendMouseout",function(b,c){b.hover=!1,a.transition().call(G)}),w.dispatch.on("pointMouseover.tooltip",function(a){k.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),w.dispatch.on("pointMouseout.tooltip",function(a){k.tooltipHide(a)})});return G}var b={top:30,right:20,bottom:30,left:60},c={top:0,right:20,bottom:20,left:60},d=960,e=500,f=400,g=100,h=function(){return 2.5},i=d3.scale.category10().range(),j=Math.floor(Math.random()*1e4),k=d3.dispatch("tooltipShow","tooltipHide"),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=d3.scale.linear(),p=function(a){return a.x},q=function(a){return a.y},r=a.models.xaxis().scale(l),s=a.models.yaxis().scale(m),t=a.models.xaxis().scale(n),u=a.models.yaxis().scale(o),v=a.models.legend().height(30),w=a.models.line(),x=a.models.line().dotRadius(.1).interactive(!1),y=d3.svg.brush().x(n).on("brush",H),z,A,B,w,C,D,E,F;G.dispatch=k,G.x=function(a){if(!arguments.length)return p;p=a,w.x(a),x.x(a);return G},G.y=function(a){if(!arguments.length)return q;q=a,w.y(a),x.y(a);return G},G.margin=function(a){if(!arguments.length)return b;b=a;return G},G.width=function(a){if(!arguments.length)return d;d=a;return G},G.height=function(a){if(!arguments.length)return e;e=a,f=a-g;return G},G.contextHeight=function(a){if(!arguments.length)return g;g=a,f=e-a;return G},G.dotRadius=function(a){if(!arguments.length)return h;h=d3.functor(a),w.dotRadius=a;return G},G.id=function(a){if(!arguments.length)return j;j=a;return G},G.xTickFormat=function(a){if(!arguments.length)return l.tickFormat();r.tickFormat(a),t.tickFormat(a);return G},G.yTickFormat=function(a){if(!arguments.length)return m.tickFormat();s.tickFormat(a),u.tickFormat(a);return G},G.xAxis=r,G.yAxis=s;return G},a.models.lineWithLegend=function(){function p(a){a.each(function(e){var q=e.filter(function(a){return!a.disabled}).map(function(a){return a.values});h.domain(d3.extent(d3.merge(q),j)).range([0,c-b.left-b.right]),i.domain(d3.extent(d3.merge(q),k)).range([d-b.top-b.bottom,0]),o.width(c-b.left-b.right).height(d-b.top-b.bottom).color(e.map(function(a,b){return a.color||f[b%10]}).filter(function(a,b){return!e[b].disabled}));var r=d3.select(this).selectAll("g.wrap").data([e]),s=r.enter().append("g").attr("class","wrap d3lineWithLegend").append("g");s.append("g").attr("class","x axis"),s.append("g").attr("class","y axis"),s.append("g").attr("class","linesWrap"),s.append("g").attr("class","legendWrap"),n.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){a.disabled=!1,r.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(p)}),n.dispatch.on("legendMouseover",function(b,c){b.hover=!0,a.transition().call(p)}),n.dispatch.on("legendMouseout",function(b,c){b.hover=!1,a.transition().call(p)}),o.dispatch.on("pointMouseover.tooltip",function(a){g.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),o.dispatch.on("pointMouseout.tooltip",function(a){g.tooltipHide(a)}),b.top=n.height();var t=r.select("g").attr("transform","translate("+b.left+","+n.height()+")");n.width(c/2-b.right),t.select(".legendWrap").datum(e).attr("transform","translate("+(c/2-b.left)+","+ -n.height()+")").call(n);var u=t.select(".linesWrap").datum(e.filter(function(a){return!a.disabled}));d3.transition(u).call(o),l.domain(h.domain()).range(h.range()).ticks(c/100).tickSize(-(d-b.top-b.bottom),0),t.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(t.select(".x.axis")).call(l),m.domain(i.domain()).range(i.range()).ticks(d/36).tickSize(-(c-b.right-b.left),0),d3.transition(t.select(".y.axis")).call(m)});return p}var b={top:30,right:20,bottom:50,left:60},c=960,d=500,e=function(){return 2.5},f=d3.scale.category10().range(),g=d3.dispatch("tooltipShow","tooltipHide"),h=d3.scale.linear(),i=d3.scale.linear(),j=function(a){return a.x},k=function(a){return a.y},l=a.models.xaxis().scale(h),m=a.models.yaxis().scale(i),n=a.models.legend().height(30),o=a.models.line();p.dispatch=g,p.x=function(a){if(!arguments.length)return j;j=a,o.x(a);return p},p.y=function(a){if(!arguments.length)return k;k=a,o.y(a);return p},p.margin=function(a){if(!arguments.length)return b;b=a;return p},p.width=function(a){if(!arguments.length)return c;c=a;return p},p.height=function(a){if(!arguments.length)return d;d=a;return p},p.dotRadius=function(a){if(!arguments.length)return e;e=d3.functor(a),o.dotRadius=a;return p},p.xAxis=l,p.yAxis=m;return p},a.models.scatter=function(){function r(s){s.each(function(r){var s=r.map(function(a){return a.values});n=n||f,o=o||g,p=p||h,r=r.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a}),f.domain(d3.extent(d3.merge(s).map(i).concat(l))).range([0,b-a.left-a.right]),g.domain(d3.extent(d3.merge(s).map(j).concat(m))).range([c-a.top-a.bottom,0]),h.domain(d3.extent(d3.merge(s),k)).range([2,10]);var t=d3.merge(r.map(function(a,b){return a.values.map(function(a,c){return[f(i(a)),g(j(a)),b,c]})})),u=d3.select(this).selectAll("g.d3scatter").data([r]),v=u.enter().append("g").attr("class","d3scatter").append("g");v.append("g").attr("class","groups"),v.append("g").attr("class","point-clips"),v.append("g").attr("class","point-paths"),v.append("g").attr("class","distribution");var w=u.select("g").attr("transform","translate("+a.left+","+a.top+")"),A=v.append("g").attr("class","voronoi-clip").append("clipPath").attr("id","voronoi-clip-path-"+e).append("rect");u.select(".voronoi-clip rect").attr("x",-10).attr("y",-10).attr("width",b-a.left-a.right+20).attr("height",c-a.top-a.bottom+20),u.select(".point-paths").attr("clip-path","url(#voronoi-clip-path-"+e+")");var B=u.select(".point-clips").selectAll(".clip-path").data(t);B.enter().append("clipPath").attr("class","clip-path").append("circle").attr("r",25),B.exit().remove(),B.attr("id",function(a,b){return"clip-"+e+"-"+a[2]+"-"+a[3]}).attr("transform",function(a){return"translate("+a[0]+","+a[1]+")"});var C=d3.geom.voronoi(t).map(function(a,b){return{data:a,series:t[b][2],point:t[b][3]}}),D=u.select(".point-paths").selectAll("path").data(C);D.enter().append("path").attr("class",function(a,b){return"path-"+b}),D.exit().remove(),D.attr("clip-path",function(a,b){return"url(#clip-"+e+"-"+a.series+"-"+a.point+")"}).attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("mouseover",function(b){q.pointMouseover({point:r[b.series].values[b.point],series:r[b.series],pos:[f(i(r[b.series].values[b.point]))+a.left,g(j(r[b.series].values[b.point]))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){q.pointMouseout({point:r[a.series].values[a.point],series:r[a.series],seriesIndex:a.series,pointIndex:a.point})});var E=u.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});E.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(E.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),E.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover&&!a.disabled}),d3.transition(E).style("fill",function(a,b){return d[b%10]}).style("stroke",function(a,b){return d[b%10]}).style("stroke-opacity",1).style("fill-opacity",.5);var F=E.selectAll("circle.point").data(function(a){return a.values});F.enter().append("circle").attr("cx",function(a){return n(i(a))}).attr("cy",function(a){return o(j(a))}).attr("r",function(a){return p(k(a))}),F.exit().remove(),F.attr("class",function(a,b){return"point point-"+b}),d3.transition(F).attr("cx",function(a){return f(i(a))}).attr("cy",function(a){return g(j(a))}).attr("r",function(a){return h(k(a))});var G=E.selectAll("line.distX").data(function(a){return a.values});G.enter().append("line").attr("x1",function(a){return n(i(a))}).attr("x2",function(a){return n(i(a))}),G.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",g.range()[0]).attr("y2",g.range()[0]+8),d3.transition(G).attr("x1",function(a){return f(i(a))}).attr("x2",function(a){return f(i(a))}),G.exit().remove();var H=E.selectAll("line.distY").data(function(a){return a.values});H.enter().append("line").attr("y1",function(a){return o(j(a))}).attr("y2",function(a){return o(j(a))}),H.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",f.range()[0]).attr("x2",f.range()[0]-8),d3.transition(H).attr("y1",function(a){return g(j(a))}).attr("y2",function(a){return g(j(a))}),H.exit().remove(),q.on("pointMouseover.point",function(b){u.select(".series-"+b.seriesIndex+" .point-"+b.pointIndex).classed("hover",!0),u.select(".series-"+b.seriesIndex+" .distX-"+b.pointIndex).attr("y1",b.pos[1]-a.top),u.select(".series-"+b.seriesIndex+" .distY-"+b.pointIndex).attr("x1",b.pos[0]-a.left)}),q.on("pointMouseout.point",function(a){u.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1),u.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",g.range()[0]),u.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",f.range()[0])}),n=f.copy(),o=g.copy(),p=h.copy()});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category10().range(),e=Math.floor(Math.random()*1e5),f=d3.scale.linear(),g=d3.scale.linear(),h=d3.scale.sqrt(),i=function(a){return a.x},j=function(a){return a.y},k=function(a){return a.size},l=[],m=[],n,o,p,q=d3.dispatch("pointMouseover","pointMouseout");r.dispatch=q,r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.x=function(a){if(!arguments.length)return i;i=d3.functor(a);return r},r.y=function(a){if(!arguments.length)return j;j=d3.functor(a);return r},r.size=function(a){if(!arguments.length)return k;k=d3.functor(a);return r},r.forceX=function(a){if(!arguments.length)return l;l=a;return r},r.forceY=function(a){if(!arguments.length)return m;m=a;return r},r.color=function(a){if(!arguments.length)return d;d=a;return r},r.id=function(a){if(!arguments.length)return e;e=a;return r};return r},a.models.scatterWithLegend=function(){function w(a){a.each(function(f){var g=f.filter(function(a){return!a.disabled}).map(function(a){return a.values});q.domain(d3.extent(d3.merge(g).map(k).concat(n))).range([0,c-b.left-b.right]),r.domain(d3.extent(d3.merge(g).map(l).concat(o))).range([d-b.top-b.bottom,0]),v.width(c-b.left-b.right).height(d-b.top-b.bottom).color(f.map(function(a,b){return a.color||j[b%20]}).filter(function(a,b){return!f[b].disabled})),s.ticks(c/100).tickSize(-(d-b.top-b.bottom),0),t.ticks(d/36).tickSize(-(c-b.right-b.left),0);var h=d3.select(this).selectAll("g.wrap").data([f]),i=h.enter().append("g").attr("class","wrap d3lineWithLegend").append("g");i.append("g").attr("class","legendWrap"),i.append("g").attr("class","x axis"),i.append("g").attr("class","y axis"),i.append("g").attr("class","scatterWrap"),u.dispatch.on("legendClick",function(b,c,d){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,h.selectAll(".series").classed("disabled",!1);return a}),a.transition(e).call(w)}),u.dispatch.on("legendMouseover",function(b,c){b.hover=!0,a.transition().call(w)}),u.dispatch.on("legendMouseout",function(b,c){b.hover=!1,a.transition().call(w)}),v.dispatch.on("pointMouseover.tooltip",function(a){p.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),v.dispatch.on("pointMouseout.tooltip",function(a){p.tooltipHide(a)}),u.width(c/2-b.right),h.select(".legendWrap").datum(f).attr("transform","translate("+(c/2-b.left)+","+ -u.height()+")").call(u),b.top=u.height();var m=h.select("g").attr("transform","translate("+b.left+","+b.top+")"),z=h.select(".scatterWrap").datum(f.filter(function(a){return!a.disabled}));d3.transition(z).call(v),s.domain(q.domain()).range(q.range()).ticks(c/100).tickSize(-(d-b.top-b.bottom),0),m.select(".x.axis").attr("transform","translate(0,"+r.range()[0]+")"),d3.transition(m.select(".x.axis")).call(s),t.domain(r.domain()).range(r.range()).ticks(d/36).tickSize(-(c-b.right-b.left),0),d3.transition(m.select(".y.axis")).call(t)});return w}var b={top:30,right:20,bottom:50,left:60},c=960,d=500,e=500,f=!0,g=!0,h=!1,i=!1,j=d3.scale.category10().range(),k=function(a){return a.x},l=function(a){return a.y},m=function(a){return a.size},n=[],o=[],p=d3.dispatch("tooltipShow","tooltipHide"),q=d3.scale.linear(),r=d3.scale.linear(),s=a.models.xaxis().scale(q).tickPadding(10),t=a.models.yaxis().scale(r).tickPadding(10),u=a.models.legend().height(30),v=a.models.scatter();w.dispatch=p,w.margin=function(a){if(!arguments.length)return b;b=a;return w},w.width=function(a){if(!arguments.length)return c;c=a;return w},w.height=function(a){if(!arguments.length)return d;d=a;return w},w.forceX=function(a){if(!arguments.length)return n;n=a,v.forceX(a);return w},w.forceY=function(a){if(!arguments.length)return o;o=a,v.forceY(a);return w},w.animate=function(a){if(!arguments.length)return e;e=a;return w},w.xAxis=s,w.yAxis=t;return w},a.models.sparkline=function(){function h(d){d.each(function(d){f.domain(d3.extent(d,function(a){return a.x})).range([0,b-a.left-a.right]),g.domain(d3.extent(d,function(a){return a.y})).range([c-a.top-a.bottom,0]);var h=d3.select(this).selectAll("svg").data([d]),i=h.enter().append("svg").append("g");i.append("g").attr("class","sparkline").attr("transform","translate("+a.left+","+a.top+")").style("stroke",function(a,b){return a.color||e[b*2%20]}),h.attr("width",b).attr("height",c);var j=i.select(".sparkline").selectAll("path").data(function(a){return[a]});j.enter().append("path"),j.exit().remove(),j.attr("d",d3.svg.line().x(function(a){return f(a.x)}).y(function(a){return g(a.y)}));var k=i.select(".sparkline").selectAll("circle.point").data(function(a){return a.filter(function(a){return g.domain().indexOf(a.y)!=-1})});k.enter().append("circle").attr("class","point"),k.exit().remove(),k.attr("cx",function(a){return f(a.x)}).attr("cy",function(a){return g(a.y)}).attr("r",2).style("stroke",function(a,b){return a.y==g.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.y==g.domain()[0]?"#d62728":"#2ca02c"})});return h}var a={top:3,right:3,bottom:3,left:3},b=200,c=20,d=!0,e=d3.scale.category20().range(),f=d3.scale.linear(),g=d3.scale.linear();h.margin=function(b){if(!arguments.length)return a;a=b;return h},h.width=function(a){if(!arguments.length)return b;b=a;return h},h.height=function(a){if(!arguments.length)return c;c=a;return h},h.animate=function(a){if(!arguments.length)return d;d=a;return h};return h}}() \ No newline at end of file diff --git a/src/intro.js b/src/intro.js index d299963..af50383 100644 --- a/src/intro.js +++ b/src/intro.js @@ -1 +1 @@ -(function(d3, window){ +(function(){ diff --git a/src/outro.js b/src/outro.js index 8049d7f..0319a0f 100644 --- a/src/outro.js +++ b/src/outro.js @@ -1 +1 @@ -})(d3, window); +})();