bachelor-thesis/pgBadger/pgreport_querycache/12/pgbadger.min.js
2024-11-03 14:37:21 +01:00

2 lines
5.3 KiB
JavaScript

function create_download_button(a,b){if(b==undefined){b="btn btn-info"}document.writeln('<button type="button" id="download'+a+'" class="'+b+'">Download</button>')}function add_download_button_event(a,b){jQuery("#download"+a).click(function(){$("#pgbadgerModal img").attr("src",$("#"+b).jqplotToImageStr({}));$("#pgbadgerModal").modal("toggle")})}function create_linegraph(e,c,d,a,b){return $.jqplot(e,b,{seriesColors:["#6e9dc9","#f4ab3a","#ac7fa8","#8dbd0f","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc"],seriesDefaults:{markerOptions:{show:false},lineWidth:1},grid:{borderWidth:1,background:"#ffffff"},title:c,series:a,axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer,tickOptions:{angle:-30,textColor:"#333"}},yaxis:{renderer:$.jqplot.LogAxisRenderer,labelRenderer:$.jqplot.CanvasAxisLabelRenderer,tickRenderer:$.jqplot.CanvasAxisTickRenderer,tickOptions:{textColor:"#333",formatter:function(g,f){return pretty_print_number(f,0,d)}}}},legend:{show:true,location:"nw"},cursor:{show:true,zoom:true,showTooltip:false,looseZoom:true,followMouse:true},highlighter:{show:true,tooltipContentEditor:function(m,f,j,k){var h=new Date(k.data[f][j][0]);var l="<div>On "+h.toString();for(var g=0;g<k.data.length;g++){l+='<br><span class="mfigure">'+pretty_print_number(k.data[g][j][1],2,k.series[g].label)+" <small>"+k.series[g].label+"</small></span>"}l+="</div>";return l}}})}function create_piechart(c,b,a){return $.jqplot(c,[a],{seriesColors:["#6e9dc9","#f4ab3a","#ac7fa8","#8dbd0f","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc","#4bb2c5","#c5b47f","#EAA228","#579575","#839557","#498991","#C08840","#9F9274","#546D61","#646C4A","#6F6621","#6E3F5F","#4F64B0","#A89050","#C45923","#187399","#945381","#959E5C","#C7AF7B","#478396","#907294"],grid:{borderWidth:1,background:"#ffffff"},title:b,seriesDefaults:{renderer:$.jqplot.PieRenderer,rendererOptions:{showDataLabels:true}},legend:{show:true,location:"e"},highlighter:{show:true,tooltipLocation:"sw",useAxesFormatters:false,tooltipContentEditor:function(h,d,e,f){var g="<div>";g+='<span class="mfigure">'+format_number(f.data[0][e][1])+" <small>"+f.data[0][e][0]+"</small></span>";g+="</div>";return g}}})}function create_bargraph(e,d,a,c,b){return $.jqplot(e,c,{grid:{borderWidth:1,background:"#ffffff"},title:d,seriesDefaults:{rendererOptions:{barPadding:4,barMargin:5}},seriesColors:["#6e9dc9","#8dbd0f","#f4ab3a","#ac7fa8","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc"],series:[{renderer:$.jqplot.BarRenderer,label:a},{yaxis:"y2axis",label:b,markerOptions:{show:false},lineWidth:1}],axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer,drawMajorGridlines:false,drawMajorTickMarks:false,tickRenderer:$.jqplot.CanvasAxisTickRenderer,tickOptions:{angle:-30,textColor:"#333",formatString:"%H:%M",fontFamily:"Helvetica",fontSize:"8pt"}},yaxis:{autoscale:true,labelRenderer:$.jqplot.CanvasAxisLabelRenderer,tickOptions:{textColor:"#333"},tickRenderer:$.jqplot.CanvasAxisTickRenderer,tickOptions:{textColor:"#333",formatter:function(g,f){return pretty_print_number(f,1,a)},fontFamily:"Helvetica",fontSize:"8pt"},label:a},y2axis:{autoscale:true,labelRenderer:$.jqplot.CanvasAxisLabelRenderer,tickRenderer:$.jqplot.CanvasAxisTickRenderer,tickOptions:{textColor:"#8dbd0f",formatter:function(g,f){return pretty_print_number(f,1,b)},fontFamily:"Helvetica",fontSize:"8pt"},rendererOptions:{alignTicks:true},label:b}},highlighter:{show:true,tooltipLocation:"ne",useAxesFormatters:false,tooltipContentEditor:function(l,f,h,j){var k='<div style="z-index: 99;">At '+j.data[0][h][0];for(var g=0;g<j.data.length;g++){k+='<br><span class="mfigure">'+pretty_print_number(j.data[g][h][1],2,j.series[g].label)+" <small>"+j.series[g].label+"</small></span>"}k+="</div>";return k}}})}function pretty_print_number(c,b,a){if((b==undefined)||((b==0)&&(c!=0))){b=1}if(a!=undefined){a=a.toLowerCase();if(a.search("size")>=0){if(Math.abs(c)>=1125899906842624){c=(c/1125899906842624);return c.toFixed(b)+" PiB"}else{if(Math.abs(c)>=1099511627776){c=(c/1099511627776);return c.toFixed(b)+" TiB"}else{if(Math.abs(c)>=1073741824){c=(c/1073741824);return c.toFixed(b)+" GiB"}else{if(Math.abs(c)>=1048576){c=(c/1048576);return c.toFixed(b)+" MiB"}else{if(Math.abs(c)>=1024){c=(c/1024);return c.toFixed(b)+" KiB"}else{return c+" B"}}}}}}else{if(a.search("duration")>=0){if(Math.abs(c)>=1000){c=(c/1000);return c.toFixed(b)+" sec"}else{return c.toFixed(b)+" ms"}}else{if(Math.abs(c)>=1000000000000000){c=(c/1000000000000000);return c.toFixed(b)+" P"}else{if(Math.abs(c)>=1000000000000){c=(c/1000000000000);return c.toFixed(b)+" T"}else{if(Math.abs(c)>=1000000000){c=(c/1000000000);return c.toFixed(b)+" G"}else{if(Math.abs(c)>=1000000){c=(c/1000000);return c.toFixed(b)+" M"}else{if(Math.abs(c)>=1000){c=(c/1000);return c.toFixed(b)+" K"}}}}}}}}return c.toFixed(b)}function format_number(a){var f=2;var h=",";var k=Math.round(Math.pow(10,f)*(Math.abs(a)-Math.floor(Math.abs(a))));a=Math.floor(Math.abs(a));if((f==0)||(k==Math.pow(10,f))){k=0}var c=a+"";var g=c.length;for(var e=1;e<4;e++){if(a>=Math.pow(10,(3*e))){c=c.substring(0,g-(3*e))+h+c.substring(g-(3*e))}}if(f>0){var b="";for(var d=0;d<(f-k.toString().length);d++){b+="0"}k=b+k.toString();if(k>0){c=c+"."+k}}if(parseFloat(a)<0){c="-"+c}return c}function draw_charts(){window.charts=$.grep(window.charts,function(c){var a=c.slice();var b=a.shift();var d=c[1];if($("#"+d).is(":visible")){window["create_"+b].apply(null,a);return false}return true})};