diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2016-12-29 12:12:32 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2016-12-29 12:12:32 +0300 |
commit | db0c081520951f9ed9289773c7f592e044e4ae05 (patch) | |
tree | a8036dbfa62c7eb16b4d07787e5d376f2a8d45b6 /interface/js | |
parent | 9a7415db597d624938a8730d25eff7db9fbfe82d (diff) | |
download | rspamd-db0c081520951f9ed9289773c7f592e044e4ae05.tar.gz rspamd-db0c081520951f9ed9289773c7f592e044e4ae05.zip |
[WebUI] Update D3Evolution to 0.0.1
Diffstat (limited to 'interface/js')
-rw-r--r-- | interface/js/d3evolution.min.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/interface/js/d3evolution.min.js b/interface/js/d3evolution.min.js index 09b0c6575..6bc4bebaf 100644 --- a/interface/js/d3evolution.min.js +++ b/interface/js/d3evolution.min.js @@ -1,7 +1,5 @@ -/* - * Copyright (c) 2016, Alexander Moisseev - * BSD 2 clause - * https://github.com/moisseev/D3Evolution - * version: aeb1663e36e09bf98315bc9a2cf16a0f24c0def1 +/*! + * D3Evolution 0.0.1 (https://github.com/moisseev/D3Evolution) + * Copyright (c) 2016, Alexander Moisseev, BSD 2-Clause */ -function D3Evolution(a,b){"use strict";var d,e,f,c=$.extend(!0,{title:"",width:800,height:400,margin:{top:80,right:60,bottom:40,left:60},yAxisLabel:"",type:"line",duration:1250,interpolate:"linear",legend:{buttonRadius:7,space:130,entries:[]}},b),g=c.width-c.margin.left-c.margin.right,h=c.height-c.margin.top-c.margin.bottom,i=d3.time.scale().range([0,g]),j=d3.scale.linear().range([h,0]),k=d3.svg.axis().scale(i),l=d3.svg.axis().scale(j).orient("left").ticks(5),m=d3.svg.axis().tickFormat("").scale(i).tickSize(-h,0),n=d3.svg.axis().tickFormat("").scale(j).orient("left").tickSize(-g,0),o=d3.scale.quantize().range([h,0]),p=d3.svg.area().x(function(a){return i(a.x)}).y0(function(a){return h}).y1(function(a){return o(null==a.y)}).interpolate("step"),q=d3.svg.line().defined(function(a){return null!=a.y}).x(function(a){return i(a.x)}).y(function(a){return j(a.y)}).interpolate(c.interpolate),r=d3.svg.area().defined(function(a){return null!=a.y}).x(function(a){return i(a.x)}).y0(function(a){return j(a.y0)}).y1(function(a){return j(a.y0+a.y)}).interpolate(c.interpolate),s=function(){var a;"area"===c.type?(d3.layout.stack()(d),a=d3.extent(d3.merge(d),function(a){return a.y0+a.y})):a=d3.extent(d3.merge(d),function(a){return a.y}),j.domain([a[0]>0?0:a[0],a[1]]),d3.transition().duration(c.duration).each(function(){A.select(".y.grid").call(n.scale(j)),A.select(".y.axis").call(l.scale(j))})},t=d3.scale.category10(),u=function(a){return void 0!==c.legend.entries[a]&&void 0!==c.legend.entries[a].color?c.legend.entries[a].color:t(a)},v=function(a){return void 0!==c.legend.entries[a]&&void 0!==c.legend.entries[a].label?c.legend.entries[a].label:"path_"+a},w=function(a){var b=a.reduce(function(a,b){return b.map(function(b,c){return b.y+(a[c]?a[c]:0)})},[]),c=$.extend(!0,[],a);return c.forEach(function(a){a.forEach(function(a,c){b[c]&&(a.y/=b[c])})}),c},x=function(){"percentage"===c.convert?(l.tickFormat(d3.format(".0%")),B.transition().duration(c.duration).style("opacity",0),d=w(e)):(l.tickFormat(null),B.transition().duration(c.duration).style("opacity",1),d=e),s()},y=d3.select("#"+a).append("svg").classed("d3evolution",!0).attr("width",c.width).attr("height",c.height),z=y.append("g").attr("class","legend"),A=y.append("g").attr("width",g).attr("height",h).attr("transform","translate("+c.margin.left+", "+c.margin.top+")");A.append("g").attr("class","x grid").attr("transform","translate(0,"+h+")").call(m),A.append("g").attr("class","y grid").attr("transform","translate(0,0)").call(n),A.append("g").attr("class","x axis").attr("transform","translate(0,"+h+")").call(k),A.append("g").attr("class","y axis").attr("transform","translate(0,0)").call(l);var B=A.append("text").attr("class","y label").attr("x",20-c.margin.left).attr("y",-20).text(c.yAxisLabel);y.append("svg:text").attr("class","chart-title").attr("x",c.width/2).attr("y",c.margin.top/3).attr("text-anchor","middle").text(c.title),this.data=function(a){e=a;var b=[];f=c.width-c.margin.right-c.legend.space*e.length,e.forEach(function(a){a.forEach(function(a){a.x*=1e3})});var g=d3.extent(d3.merge(e),function(a){return a.x});i.domain([g[0],g[1]]);var h=A.selectAll("path.path-null").data(e);h.enter().append("path").attr("class","path-null"),h.transition().duration(c.duration/2).style("opacity",0).each("end",function(){h.attr("d",p).transition().duration(c.duration/2).style("opacity",1)}),h.exit().remove(),x();var j=A.selectAll("path.path").data(d);j.enter().append("path").attr("class","path").attr("id",function(a,b){return"path_"+b}).on("click",function(a,b){l(b)}).on("mouseover",function(a,b){n(b)}).on("mouseout",function(a,b){n(b,!1)}).style("area"===c.type?{fill:function(a,b){return u(b)},stroke:"none","fill-opacity":function(a,c){return b[c]}}:{fill:"none",stroke:function(a,b){return u(b)},opacity:function(a,c){return b[c]}}),j.transition().duration(c.duration).attr("d","area"===c.type?r:q),j.exit().remove(),d3.transition().duration(c.duration).each(function(){A.select(".x.grid").call(m.scale(i)),A.select(".x.axis").call(k.scale(i))});var l=function(a){b[a]=0!=b[a]?0:1,d3.select("#circle_"+a).transition().duration(c.duration).style("fill-opacity",b[a]+.2),d3.select("#path_"+a).transition().duration(c.duration).style("opacity",b[a])};const n=function(a,d){d3.select("#circle_"+a).attr("r",c.legend.buttonRadius*(d===!1?1:1.3));const e=function(c){return d===!1?b[c]:c===a?1:0==b[c]?0:.4};A.selectAll("path.path").style("opacity",function(a,b){return e(b)}).style("fill-opacity",function(a,b){return e(b)})};var o=z.selectAll("circle").data(d);o.enter().append("circle").attr("id",function(a,b){return"circle_"+b}).attr("cy",2*c.margin.top/3).attr("r",c.legend.buttonRadius).style("fill",function(a,b){return u(b)}).style("stroke",function(a,b){return u(b)}).style("fill-opacity",function(a,c){return b[c]+.2}).on("click",function(a,b){l(b)}).on("mouseover",function(a,b){n(b)}).on("mouseout",function(a,b){n(b,!1)}),o.exit().remove(),o.transition().duration(c.duration).attr("cx",function(a,b){return f+c.legend.space*b});var s=z.selectAll("text").data(d);return s.enter().append("text").attr("y",2*c.margin.top/3).attr("dy","0.3em").text(function(a,b){return v(b)}).on("click",function(a,b){l(b)}).on("mouseover",function(a,b){n(b)}).on("mouseout",function(a,b){n(b,!1)}),s.exit().remove(),s.transition().duration(c.duration).attr("x",function(a,b){return f+c.legend.space*b+2*c.legend.buttonRadius}),this},this.legend=function(a){return $.extend(!0,c.legend,a),z.selectAll("circle").transition().duration(c.duration).attr("cx",function(a,b){return f+c.legend.space*b}).attr("r",c.legend.buttonRadius).style("fill",function(a,b){return u(b)}).style("stroke",function(a,b){return u(b)}),z.selectAll("text").text(function(a,b){return v(b)}).transition().duration(c.duration).attr("x",function(a,b){return f+c.legend.space*b+2*c.legend.buttonRadius}),A.selectAll("path.path").transition().duration(c.duration).style("fill","area"===c.type?function(a,b){return u(b)}:"none").style("stroke","area"!==c.type?function(a,b){return u(b)}:"none"),this},this.convert=function(a){return c.convert=a,x(),A.selectAll("path.path").data(d).transition().duration(c.duration).attr("d","area"===c.type?r:q),this},this.interpolate=function(a){return c.interpolate=a,r.interpolate(c.interpolate),q.interpolate(c.interpolate),A.selectAll("path.path").attr("d","area"===c.type?r:q),this},this.type=function(a){return c.type=a,s(),A.selectAll("path.path").style("stroke","area"!==c.type?function(a,b){return u(b)}:"none").style("fill","area"===c.type?function(a,b){return u(b)}:"none").transition().duration(c.duration).attr("d","area"===c.type?r:q),this},this.destroy=function(){d3.select("svg").remove()}}
\ No newline at end of file +;function D3Evolution(r,e){var n=$.extend(true,{title:"",width:800,height:400,margin:{top:80,right:60,bottom:40,left:60},yAxisLabel:"",type:"line",duration:1250,interpolate:"linear",legend:{buttonRadius:7,space:130,entries:[]}},e);var A;var y;var k;var s=n.width-n.margin.left-n.margin.right;var q=n.height-n.margin.top-n.margin.bottom;var C=d3.time.scale().range([0,s]);var d=d3.scale.linear().range([q,0]);var i=d3.svg.axis().scale(C);var a=d3.svg.axis().scale(d).orient("left").ticks(5);var m=d3.svg.axis().tickFormat("").scale(C).tickSize(-q,0);var D=d3.svg.axis().tickFormat("").scale(d).orient("left").tickSize(-s,0);var l=d3.scale.quantize().range([q,0]);var o=d3.svg.area().x(function(g){return C(g.x)}).y0(function(g){return q}).y1(function(g){return l(g.y==null)}).interpolate("step");var j=d3.svg.line().defined(function(g){return g.y!=null}).x(function(g){return C(g.x)}).y(function(g){return d(g.y)}).interpolate(n.interpolate);var x=d3.svg.area().defined(function(g){return g.y!=null}).x(function(g){return C(g.x)}).y0(function(g){return d(g.y0)}).y1(function(g){return d(g.y0+g.y)}).interpolate(n.interpolate);var h=function(){var g;if(n.type==="area"){d3.layout.stack()(A);g=d3.extent(d3.merge(A),function(E){return E.y0+E.y})}else{g=d3.extent(d3.merge(A),function(E){return E.y})}d.domain([(g[0]>0)?0:g[0],g[1]]);d3.transition().duration(n.duration).each(function(){w.select(".y.grid").call(D.scale(d));w.select(".y.axis").call(a.scale(d))})};var z=d3.scale.category10();var b=function(g){return(n.legend.entries[g]!==undefined&&n.legend.entries[g].color!==undefined)?n.legend.entries[g].color:z(g)};var v=function(g){return(n.legend.entries[g]!==undefined&&n.legend.entries[g].label!==undefined)?n.legend.entries[g].label:"path_"+g};var f=function(g){var F=g.reduce(function(G,H){return H.map(function(J,I){return J.y+(G[I]?G[I]:0)})},[]);var E=$.extend(true,[],g);E.forEach(function(G){G.forEach(function(I,H){if(F[H]){I.y/=F[H]}})});return E};var u=function(){if(n.convert==="percentage"){a.tickFormat(d3.format(".0%"));t.transition().duration(n.duration).style("opacity",0);A=f(y)}else{a.tickFormat(null);t.transition().duration(n.duration).style("opacity",1);A=y}h()};var p=d3.select("#"+r).append("svg").classed("d3evolution",true).attr("width",n.width).attr("height",n.height);var c=p.append("g").attr("class","legend");var w=p.append("g").attr("width",s).attr("height",q).attr("transform","translate("+n.margin.left+", "+n.margin.top+")");w.append("g").attr("class","x grid").attr("transform","translate(0,"+q+")").call(m);w.append("g").attr("class","y grid").attr("transform","translate(0,0)").call(D);w.append("g").attr("class","x axis").attr("transform","translate(0,"+q+")").call(i);w.append("g").attr("class","y axis").attr("transform","translate(0,0)").call(a);var t=w.append("text").attr("class","y label").attr("x",20-n.margin.left).attr("y",-20).style("opacity",(n.convert==="percentage")?0:1).text(n.yAxisLabel);var B=p.append("svg:text").attr("x",(n.width/2)).attr("y",(n.margin.top/3)).attr("text-anchor","middle");B.append("tspan").attr("class","chart-title").text(n.title+" ");B.timeRange=B.append("tspan");this.data=function(I){y=$.extend(true,[],I);var F=[];k=n.width-n.margin.right-n.legend.space*y.length;y.forEach(function(N){N.forEach(function(O){O.x*=1000})});var J=d3.extent(d3.merge(y),function(N){return N.x});C.domain([J[0],J[1]]);const M=function(N){return d3.time.format("%Y-%m-%d %H:%M:%S")(new Date(N))};B.timeRange.text("[ "+M(J[0])+" / "+M(J[1])+" ]");var K=w.selectAll("path.path-null").data(y);K.enter().append("path").attr("class","path-null");K.transition().duration(n.duration/2).style("opacity",0).each("end",function(){K.attr("d",o).transition().duration(n.duration/2).style("opacity",1)});K.exit().remove();u();var L=w.selectAll("path.path").data(A);L.enter().append("path").attr("class","path").attr("id",function(O,N){return"path_"+N}).on("click",function(O,N){H(N)}).on("mouseover",function(O,N){g(N)}).on("mouseout",function(O,N){g(N,false)}).style((n.type==="area")?{fill:function(O,N){return b(N)},stroke:"none","fill-opacity":function(O,N){return F[N]}}:{fill:"none",stroke:function(O,N){return b(N)},opacity:function(O,N){return F[N]}});L.transition().duration(n.duration).attr("d",(n.type==="area")?x:j);L.exit().remove();d3.transition().duration(n.duration).each(function(){w.select(".x.grid").call(m.scale(C));w.select(".x.axis").call(i.scale(C))});var H=function(N){F[N]=(F[N]!=0)?0:1;d3.select("#circle_"+N).transition().duration(n.duration).style("fill-opacity",F[N]+0.2);d3.select("#path_"+N).transition().duration(n.duration).style("opacity",F[N])};const g=function(O,N){d3.select("#circle_"+O).attr("r",n.legend.buttonRadius*(N===false?1:1.3));const P=function(Q){if(N===false){return F[Q]}return(Q===O)?1:(F[Q]==0)?0:0.4};w.selectAll("path.path").style("opacity",function(R,Q){return P(Q)}).style("fill-opacity",function(R,Q){return P(Q)})};var G=c.selectAll("circle").data(A);G.enter().append("circle").attr("id",function(O,N){return"circle_"+N}).attr("cy",n.margin.top*2/3).attr("r",n.legend.buttonRadius).style("fill",function(O,N){return b(N)}).style("stroke",function(O,N){return b(N)}).style("fill-opacity",function(O,N){return F[N]+0.2}).on("click",function(O,N){H(N)}).on("mouseover",function(O,N){g(N)}).on("mouseout",function(O,N){g(N,false)});G.exit().remove();G.transition().duration(n.duration).attr("cx",function(O,N){return k+n.legend.space*N});var E=c.selectAll("text").data(A);E.enter().append("text").attr("y",n.margin.top*2/3).attr("dy","0.3em").text(function(O,N){return v(N)}).on("click",function(O,N){H(N)}).on("mouseover",function(O,N){g(N)}).on("mouseout",function(O,N){g(N,false)});E.exit().remove();E.transition().duration(n.duration).attr("x",function(O,N){return k+n.legend.space*N+2*n.legend.buttonRadius});return this};this.legend=function(g){$.extend(true,n.legend,g);c.selectAll("circle").transition().duration(n.duration).attr("cx",function(F,E){return k+n.legend.space*E}).attr("r",n.legend.buttonRadius).style("fill",function(F,E){return b(E)}).style("stroke",function(F,E){return b(E)});c.selectAll("text").text(function(F,E){return v(E)}).transition().duration(n.duration).attr("x",function(F,E){return k+n.legend.space*E+2*n.legend.buttonRadius});w.selectAll("path.path").transition().duration(n.duration).style("fill",(n.type==="area")?function(F,E){return b(E)}:"none").style("stroke",(n.type!=="area")?function(F,E){return b(E)}:"none");return this};this.convert=function(g){n.convert=g;u();w.selectAll("path.path").data(A).transition().duration(n.duration).attr("d",(n.type==="area")?x:j);return this};this.interpolate=function(g){n.interpolate=g;x.interpolate(n.interpolate);j.interpolate(n.interpolate);w.selectAll("path.path").attr("d",(n.type==="area")?x:j);return this};this.type=function(g){n.type=g;h();w.selectAll("path.path").style("stroke",(n.type!=="area")?function(F,E){return b(E)}:"none").style("fill",(n.type==="area")?function(F,E){return b(E)}:"none").transition().duration(n.duration).attr("d",(n.type==="area")?x:j);return this};this.destroy=function(){d3.select("svg").remove()}};
\ No newline at end of file |