]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Use local copy of d3evolution
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 2 Jul 2016 20:24:28 +0000 (21:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 2 Jul 2016 20:24:28 +0000 (21:24 +0100)
interface/css/d3evolution.css [new file with mode: 0644]
interface/index.html
interface/js/d3evolution.min.js [new file with mode: 0644]

diff --git a/interface/css/d3evolution.css b/interface/css/d3evolution.css
new file mode 100644 (file)
index 0000000..49082e3
--- /dev/null
@@ -0,0 +1,22 @@
+.d3evolution svg {
+    background-color: white;
+}
+.d3evolution .chart-title {
+    font-size: 17px;
+}
+.d3evolution .grid .tick {
+    stroke: lightgrey;
+    shape-rendering: crispEdges;
+}
+.d3evolution .axis,
+.d3evolution .legend {
+    font-size: 13px;
+}
+.d3evolution .axis path,
+.d3evolution .axis line {
+    fill: none;
+    stroke: grey;
+}
+.d3evolution .legend circle {
+    stroke-width: 2px;
+}
index cef29803f032e48d83ece48808b8bbd4c079ee2a..e155e6894270c43105e6cfdd0c7fa09ce5501089 100644 (file)
@@ -8,7 +8,7 @@
        <meta name="author" content="">
        <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="./css/datatables.min.css"/>
-       <link rel="stylesheet" type="text/css" href="//cdn.rawgit.com/moisseev/D3Evolution/fb6ea62c43e26e728b48a43012fb796c5ab6689c/d3evolution.css">
+       <link rel="stylesheet" type="text/css" href="./css/d3evolution.css">
        <link href="./css/rspamd.css" rel="stylesheet">
 </head>
 
 <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
 <script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
 <script src="./js/d3pie.min.js"></script>
-<script src="//cdn.rawgit.com/moisseev/D3Evolution/7789381ae8108690fc9903ddbcb74cfa562a9e13/d3evolution.js"></script>
+<script src="./js/d3evolution.min.js"></script>
 <script src="./js/humanize.min.js"></script>
+<script src="./js/datatables.min.js"></script>
 <script src="./js/rspamd.js"></script>
-<script type="text/javascript" src="./js/datatables.min.js"></script>
-
 </body>
 </html>
diff --git a/interface/js/d3evolution.min.js b/interface/js/d3evolution.min.js
new file mode 100644 (file)
index 0000000..cfcc917
--- /dev/null
@@ -0,0 +1 @@
+function D3Evolution(t,e){"use strict";var n,r,a=$.extend(!0,{title:"",width:800,height:400,margin:{top:80,right:60,bottom:40,left:60},type:"line",duration:1250,interpolate:"linear",legend:{buttonRadius:7,space:130,entries:[]}},e),i=a.width-a.margin.left-a.margin.right,l=a.height-a.margin.top-a.margin.bottom,o=d3.time.scale().range([0,i]),c=d3.scale.linear().range([l,0]),s=d3.svg.axis().scale(o),u=d3.svg.axis().scale(c).orient("left").ticks(5),d=d3.svg.axis().tickFormat("").scale(o).tickSize(-l,0),p=d3.svg.axis().tickFormat("").scale(c).orient("left").tickSize(-i,0),f=d3.svg.line().x(function(t){return o(t.x)}).y(function(t){return c(t.y)}).interpolate(a.interpolate),g=d3.svg.area().x(function(t){return o(t.x)}).y0(function(t){return c(t.y0)}).y1(function(t){return c(t.y0+t.y)}).interpolate(a.interpolate),y=d3.layout.stack(),h=d3.scale.category10(),m=function(t){return void 0!==a.legend.entries[t]&&void 0!==a.legend.entries[t].color?a.legend.entries[t].color:h(t)},x=function(t){return void 0!==a.legend.entries[t]&&void 0!==a.legend.entries[t].label?a.legend.entries[t].label:"path_"+t},v=d3.select("#"+t).append("svg").classed("d3evolution",!0).attr("width",a.width).attr("height",a.height),k=v.append("g").attr("class","legend"),b=v.append("g").attr("width",i).attr("height",l).attr("transform","translate("+a.margin.left+", "+a.margin.top+")");b.append("g").attr("class","x grid").attr("transform","translate(0,"+l+")").call(d),b.append("g").attr("class","y grid").attr("transform","translate(0,0)").call(p),b.append("g").attr("class","x axis").attr("transform","translate(0,"+l+")").call(s),b.append("g").attr("class","y axis").attr("transform","translate(0,0)").call(u),v.append("svg:text").attr("class","chart-title").attr("x",a.width/2).attr("y",a.margin.top/3).attr("text-anchor","middle").text(a.title),this.data=function(t){n=t;var e=[];r=a.width-a.margin.right-a.legend.space*n.length,n.forEach(function(t){t.forEach(function(t){t.x*=1e3})});var i,l=d3.extent(d3.merge(n),function(t){return t.x});"area"===a.type?(y(n),i=[0,d3.max(d3.merge(n),function(t){return t.y0+t.y})]):i=d3.extent(d3.merge(n),function(t){return t.y}),o.domain([l[0],l[1]]),c.domain([i[0]>0?0:i[0],i[1]]);var h=b.selectAll("path.path").data(n);h.enter().append("path").attr("class","path").attr("id",function(t,e){return"path_"+e}).style("area"===a.type?{fill:function(t,e){return m(e)},stroke:"none","fill-opacity":function(t,n){return e[n]}}:{fill:"none",stroke:function(t,e){return m(e)},opacity:function(t,n){return e[n]}}),h.transition().duration(a.duration).attr("d","area"===a.type?g:f),h.exit().remove(),d3.transition().duration(a.duration).each(function(){b.select(".x.grid").call(d.scale(o)),b.select(".y.grid").call(p.scale(c)),b.select(".x.axis").call(s.scale(o)),b.select(".y.axis").call(u.scale(c))});var v=function(t){e[t]=0!=e[t]?0:1,d3.select("#circle_"+t).transition().duration(a.duration).style("fill-opacity",e[t]+.2),d3.select("#path_"+t).transition().duration(a.duration).style("opacity",e[t])},_=function(t){d3.select("#circle_"+t).attr("r",1.3*a.legend.buttonRadius),d3.select("#path_"+t).style("opacity",.4).style("fill-opacity",.4)},A=function(t){d3.select("#circle_"+t).attr("r",a.legend.buttonRadius),d3.select("#path_"+t).style("opacity",e[t]).style("fill-opacity",e[t])},w=k.selectAll("circle").data(n);w.enter().append("circle").attr("id",function(t,e){return"circle_"+e}).attr("cy",2*a.margin.top/3).attr("r",a.legend.buttonRadius).style("fill",function(t,e){return m(e)}).style("stroke",function(t,e){return m(e)}).style("fill-opacity",function(t,n){return e[n]+.2}).on("click",function(t,e){v(e)}).on("mouseover",function(t,e){_(e)}).on("mouseout",function(t,e){A(e)}),w.exit().remove(),w.transition().duration(a.duration).attr("cx",function(t,e){return r+a.legend.space*e});var R=k.selectAll("text").data(n);return R.enter().append("text").attr("y",2*a.margin.top/3).attr("dy","0.3em").text(function(t,e){return x(e)}).on("click",function(t,e){v(e)}).on("mouseover",function(t,e){_(e)}).on("mouseout",function(t,e){A(e)}),R.exit().remove(),R.transition().duration(a.duration).attr("x",function(t,e){return r+a.legend.space*e+2*a.legend.buttonRadius}),this},this.legend=function(t){return $.extend(!0,a.legend.entries,t),k.selectAll("circle").attr("cx",function(t,e){return r+a.legend.space*e}).transition().duration(a.duration).style("fill",function(t,e){return m(e)}).style("stroke",function(t,e){return m(e)}),k.selectAll("text").text(function(t,e){return x(e)}),b.selectAll("path.path").transition().duration(a.duration).style("fill","area"===a.type?function(t,e){return m(e)}:"none").style("stroke","area"!==a.type?function(t,e){return m(e)}:"none"),this},this.interpolate=function(t){return a.interpolate=t,g.interpolate(a.interpolate),f.interpolate(a.interpolate),b.selectAll("path.path").attr("d","area"===a.type?g:f),this},this.type=function(t){a.type=t;var e;return"area"===a.type?(y(n),e=[0,d3.max(d3.merge(n),function(t){return t.y0+t.y})]):e=d3.extent(d3.merge(n),function(t){return t.y}),c.domain([e[0]>0?0:e[0],e[1]]),b.selectAll("path.path").style("stroke","area"!==a.type?function(t,e){return m(e)}:"none").style("fill","area"===a.type?function(t,e){return m(e)}:"none").transition().duration(a.duration).attr("d","area"===a.type?g:f),d3.transition().duration(a.duration).each(function(){b.select(".y.grid").call(p.scale(c)),b.select(".y.axis").call(u.scale(c))}),this},this.destroy=function(){d3.select("svg").remove()}}
\ No newline at end of file