Files
galaxy/static/scripts/reports_webapp/run_stats.js
T

1 line
8.7 KiB
JavaScript

define("reports_webapp/run_stats",["exports","../libs/d3"],function(t,e){"use strict";function r(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()-e,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}function a(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()-e,t.getMinutes(),t.getSeconds(),t.getMilliseconds())}function n(){var t=new Date;return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),0,0)}Object.defineProperty(t,"__esModule",{value:!0}),t.create_chart=function(t,i,l,s){var c,p=t,g=[],u=n();for(c=0;c<24;c++)g.push(a(u,c));var d=[];for(c=0;c<30;c++)d.push(r(u,c));var f={top:60,right:30,bottom:50,left:60},h=0;"hours"==l?h=12.5:"days"==l&&(h=10);var x,v=300+f.left+f.right,m=1.75;x=0!==o.max(p)?150/o.max(p):1;var b=150+f.top+f.bottom;$(".charts").css("height",b*m);var y=o.select("#"+i).attr("width",v).attr("height",b).attr("preserveAspectRatio","xMidYMin").attr("viewBox","0 0 "+v+" "+b).on("click",function(){var t=o.select(this).attr("class");t=t.split(" "),o.selectAll("."+t[0]).filter("."+t[1]).style("cursor","zoom-in").transition().duration(750).attr("height",b).attr("width",v),o.select(this).style("cursor","default").transition().duration(750).attr("height",b*m).attr("width",v*m)}),_=y.selectAll("g").data(p).enter().append("g").attr("transform",function(t,e){var r=f.left;return"translate("+(r+=+e*h)+","+f.top+")"}).on("mouseenter",function(t){for(var r=1,a=t;a>=10;)a/=10,r++;var n=4*r+10;o.select(e.event.target.parentElement).select(".tool_tip").select("text").attr("transform","translate( "+(f.left-5)+", "+(150-t*x+f.top+10)+" )").attr("visibility","visible").text(t),o.select(e.event.target.parentElement).select(".tool_tip").attr("width",n+"px").attr("height","15px").select("rect").attr("transform","translate( "+(f.left-n)+", "+(150-t*x+f.top)+" )").attr("width",n+"px").attr("height","15px").attr("fill","#ebd9b2")}).on("mouseleave",function(t){o.select(e.event.target.parentElement).select(".tool_tip").select("text").attr("visibility","hidden"),o.select(e.event.target.parentElement).select(".tool_tip").select("rect").attr("width","0").attr("height","0").attr("fill","").text(t)});y.append("g").append("text").attr("class","title").attr("text-anchor","end").attr("transform",function(){return"translate( 300,15 )"}).text(s),y.append("g").attr("class","axis").append("path").attr("class","x").attr("d",function(){var t=f.left,e=f.top+150;return"M"+t+" "+e+" L "+(t+300)+" "+e});var w=o.scale.linear().range([150,0]),M=o.svg.axis().scale(w).orient("left").tickFormat(function(t){return o.round(t*o.max(p),0)});y.append("g").attr("class","y axis").attr("id","y_"+i).attr("text-anchor","end").attr("transform","translate( "+f.left+","+f.top+")").call(M).select(".domain"),y.append("g").append("text").attr("class","ax_title").attr("transform",function(){var t=o.select("#y_"+i).node();return"translate("+(f.left-t.getBoundingClientRect().width-5)+","+(f.top+t.getBoundingClientRect().height/2-30)+")rotate(-90)"}).text("Number of Jobs"),_.append("rect").attr("y",function(t){return 150-t*x}).attr("height",function(t){return t*x}).attr("width",h-1);var k=!1;if("hours"==l){_.append("line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",3).attr("stroke","black").attr("stroke-width",1).attr("pointer-events","none").attr("transform",function(){return"translate( "+h/2+", 150)"}),_.append("text").attr("fill","rgb(0,0,0)").attr("transform","translate( 10, 160 )").text(function(t,e){return g[e].getHours()<10?"0"+String(g[e].getHours()):g[e].getHours()});var D="";k=!1,_.append("line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",function(t,e){var r=0;return g[e].getDate()!=D&&(k?r=20:(r=27,k=!0),D=g[e].getDate()),r}).attr("stroke","black").attr("stroke-width",1).attr("pointer-events","none").attr("transform",function(){return"translate( 0, 150)"}),D="";var B="";k=!1,_.append("text").attr("fill","rgb(0,0,0)").attr("pointer-events","none").text(function(t,e){var r="";return g[e].getDate()!=B&&(r=String(g[e].toLocaleString("en-us",{month:"long"})),r+=" "+String(g[e].getDate()),B=g[e].getDate()),r}).attr("transform",function(t,e){var r=150,a=o.select(this).node().getBBox().width;return g[e].getDate()!=D&&(k?r+=18:(r+=26,k=!0),D=g[e].getDate()),"translate( "+(a+2)+", "+r+" )"})}else if("days"==l){_.append("line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",3).attr("stroke","black").attr("stroke-width",1).attr("pointer-events","none").attr("transform",function(){return"translate( "+h/2+", 150)"}),_.append("text").attr("fill","rgb(0,0,0)").attr("transform","translate( 9, 160 )").text(function(t,e){return d[e].getDate()<10?"0"+String(d[e].getDate()):d[e].getDate()});var C="";k=!1,_.append("line").attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",function(t,e){var r=0;return d[e].getMonth()!=C&&(k?r=20:(r=27,k=!0),C=d[e].getMonth()),r}).attr("stroke","black").attr("stroke-width",1).attr("pointer-events","none").attr("transform",function(){return"translate( 0, 150)"}),C="";var S="";k=!1,_.append("text").attr("fill","rgb(0,100,0)").attr("pointer-events","none").text(function(t,e){var r="";return d[e].getMonth()!=S&&(r=String(d[e].toLocaleString("en-us",{month:"long"})),r+=" "+String(d[e].getFullYear()),S=d[e].getMonth()),r}).attr("transform",function(t,e){var r=150,a=o.select(this).node().getBBox().width;return d[e].getMonth()!=C&&(k?r+=18:(r+=26,k=!0),C=d[e].getMonth()),"translate( "+(a+2)+", "+r+" )"})}y.append("g").attr("class","tool_tip").append("rect"),y.select(".tool_tip").append("text"),"jc_dy_chart"!=i&&"jc_hr_chart"!=i||o.select("#"+i).attr("height",b*m).attr("width",v*m).style("cursor","default")},t.create_histogram=function(t,r,a){var n=t,i=1.75,l={top:60,right:30,bottom:50,left:60},s=150+l.top+l.bottom,c=300+l.left+l.right,p=o.scale.linear().domain([0,o.max(n)]).range([0,300]);n=o.layout.histogram().bins(p.ticks(20))(n);for(var g=[],u=0;u<n.length;u++)g.push(n[u].length);var d;d=0!==o.max(n)?150/o.max(g):1;var f=o.scale.linear().domain([0,o.max(n,function(t){return t.y})]).range([150,0]),h=o.select("#"+r).attr("viewBox","0 0 "+c+" "+s).attr("width",c).attr("height",s).attr("preserveAspectRatio","xMidYMin").on("click",function(){var t=o.select(this).attr("class");t=t.split(" "),o.selectAll("."+t[0]).filter("."+t[1]).style("cursor","zoom-in").transition().duration(750).attr("height",s).attr("width",c),o.select(this).style("cursor","default").transition().duration(750).attr("height",s*i).attr("width",c*i)});h.append("g").append("text").attr("class","title").attr("transform",function(){return"translate( 300,15 )"}).text(a);var x,v=h.selectAll(".bar").data(n).enter().append("g").attr("class","bar").attr("transform",function(t){return"translate("+(+p(t.x)+l.left)+","+(+f(t.y)+l.top)+")"}).on("mouseenter",function(t){for(var r=0,a=t.length;a>=1;)a/=10,r++;var n=4*r+10;o.select(e.event.target.parentElement).select(".tool_tip").select("text").attr("transform","translate( "+(l.left-5)+", "+(150-t.length*d+l.top+10)+" )").attr("visibility","visible").text(t.length),o.select(e.event.target.parentElement).select(".tool_tip").attr("width",n+"px").attr("height","15px").select("rect").attr("transform","translate( "+(l.left-n)+", "+(150-t.length*d+l.top)+" )").attr("width",n+"px").attr("height","15px").attr("fill","#ebd9b2")}).on("mouseleave",function(){o.select(e.event.target.parentElement).select(".tool_tip").select("text").attr("visibility","hidden"),o.select(e.event.target.parentElement).select(".tool_tip").select("rect").attr("width","0").attr("height","0").attr("fill","")});x=void 0===n[0]?1:p(n[0].dx),v.append("rect").attr("x",1).attr("width",x-1).attr("height",function(t){return 150-f(t.y)});var m=o.svg.axis().scale(p).orient("bottom").tickFormat(function(t){var e=Math.floor(t/60),r=Math.floor(t-60*e);return e<10&&(e="0"+e),r<10&&(r="0"+r),e+":"+r});h.append("g").attr("class","x axis").attr("id","x_"+r).attr("transform","translate( "+l.left+","+(150+l.top)+")").call(m),h.append("g").append("text").attr("class","ax_title").attr("transform",function(){var t=o.select("#x_"+r).node();return"translate("+(l.left+t.getBoundingClientRect().width/2+30)+","+(l.top+150+t.getBoundingClientRect().height+10)+")"}).text("ETA - hrs:mins");var b=o.svg.axis().scale(f).orient("left");h.append("g").attr("class","y axis").attr("id","y_"+r).attr("transform","translate( "+l.left+","+l.top+")").call(b),h.append("g").append("text").attr("class","ax_title").attr("transform",function(){var t=o.select("#y_"+r).node();return"translate("+(l.left-t.getBoundingClientRect().width-5)+","+(l.top+t.getBoundingClientRect().height/2-30)+")rotate(-90)"}).text("Number of Jobs"),h.append("g").attr("class","tool_tip").append("rect"),h.select(".tool_tip").append("text")};var o=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(e)});