misc_pterodactyl-panel/public/themes/default/js/vendor/metricsgraphics/metricsgraphics.min.js

6 lines
102 KiB
JavaScript
Raw Normal View History

// v2.10.1
!function(t,e){"function"==typeof define&&define.amd?define(["d3"],e):"object"==typeof exports?module.exports=e(require("d3")):t.MG=e(t.d3)}(this,function(t){function e(){return"undefined"!=typeof jQuery||"undefined"!=typeof $}function r(t){var e;switch(t.processed.x_time_frame){case"millis":e=MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S.%L");break;case"seconds":e=MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S");break;case"less-than-a-day":e=MG.time_format(t.utc_time,"%b %e, %Y %I:%M%p");break;case"four-days":e=MG.time_format(t.utc_time,"%b %e, %Y %I:%M%p");break;default:e=MG.time_format(t.utc_time,"%b %e, %Y")}return e}function a(t,e){return t[e.x_accessor]>=e.processed.min_x&&t[e.x_accessor]<=e.processed.max_x&&t[e.y_accessor]>=e.processed.min_y&&t[e.y_accessor]<=e.processed.max_y}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function o(t){return"[object Function]"===Object.prototype.toString.call(t)}function i(t){return n(t)&&0===t.length}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function c(e){var r=e.map(function(t){return n(t)===!0&&t.length>0});return t.sum(r)===e.length}function l(e){var r=e.map(function(t){return s(t)===!0});return t.sum(r)===e.length}function u(t){return i(t)||l(t)}function f(t,e){return t.map(function(t){return t[e]})}function d(t){return t.reduce(function(t,e){return t[e]=t[e]+1||1,t},{})}function p(t){return t.height-t.bottom}function _(t){return p(t)-t.buffer}function m(t){return t.top}function g(t){return m(t)+t.buffer}function h(t){return t.left}function x(t){return h(t)+t.buffer}function y(t){return t.width-t.right}function v(t){return y(t)-t.buffer}function b(t){t.exit().remove()}function w(t,e){t.selectAll(e).remove()}function k(t,e){return t.append("g").classed(e,!0)}function M(t,e){var r=R(t.target),a=Y(t.data),n=r.selectAll("line."+e).data(a);return n.enter().append("line").attr("class",e).attr("opacity",.3),b(n),b(n),n}function G(t,e,r){e.color_accessor?(t.attr("stroke",e.scalefns.colorf),t.classed(r,!1)):(t.attr("stroke",null),t.classed(r,!0))}function A(e,r){r&&e.attr({dy:0,transform:function(){var e=t.select(this);return"rotate("+r+" "+e.attr("x")+","+e.attr("y")+")"}})}function D(t){if(t=t.node(),!t)return!1;for(var e=0;e<t.length;e++)if(C(t[e],t))return!0;return!1}function O(e,r){if(e&&1!=e.length)for(var a=0;a<e.length;a++)if(C(e[a],e)){var n=t.select(e[a]),o=+n.attr("y");o+8>=r.top&&(o=r.top-16),n.attr("y",o)}}function F(e,r){if(e&&1!=e.length){e.sort(function(e,r){return t.select(r).attr("y")-t.select(e).attr("y")}),e.reverse();for(var a,n,o,i=0;i<e.length;i++){n=t.select(e[i]).text();for(var s=0;s<e.length;s++)if(o=t.select(e[s]).text(),a=z(e[i],e[s]),a!==!1&&n!==o){var c=t.select(e[i]),l=+c.attr("y");l+=a,c.attr("y",l)}}}}function z(t,e){var r=t.getBoundingClientRect(),a=e.getBoundingClientRect();return r.top<=a.bottom&&r.top>=a.top&&a.bottom-r.top}function C(t,e){for(var r=t.getBoundingClientRect(),a=0;a<e.length;a++)if(e[a]!=t){var n=e[a].getBoundingClientRect();if(r.top===n.top&&!(n.left>r.right||n.right<r.left))return!0}return!1}function T(t,e){var r=Y(t.data);return r=r[0][t[e+"_accessor"]],"string"==typeof r?"categorical":"numerical"}function R(e){return t.select(e).select("svg")}function Y(t){var e=[];return e.concat.apply(e,t)}function E(){return"undefined"==typeof MG._next_elem_id&&(MG._next_elem_id=0),"mg-"+MG._next_elem_id++}function P(t){return"string"==typeof t?L(t):t instanceof HTMLElement?(target_ref=t.getAttribute("data-mg-uid"),target_ref||(target_ref=E(),t.setAttribute("data-mg-uid",target_ref)),target_ref):(console.warn("The specified target should be a string or an HTMLElement.",t),L(t))}function L(t){return t.replace(/[^a-zA-Z0-9 _-]+/g,"").replace(/ +?/g,"")}function X(e,r){return Number(t.select(e).style(r).replace(/px/g,""))}function S(t){return X(t,"width")}function j(t){return X(t,"height")}function U(t){return Cr(Array.prototype.slice.call(arguments,1),function(e){if(e)for(var r in e)void 0===t[r]&&(t[r]=e[r])}),t}function B(t,e){var r,a=[],n=[];for(r=0;r<e.length;r++)a[e[r]]=!0;for(
t.append("defs").attr("class","mg-clip-path").append("clipPath").attr("id","mg-plot-window-"+P(e.target)).append("svg:rect").attr("x",h(e)).attr("y",m(e)).attr("width",e.width-e.left-e.right-e.buffer).attr("height",e.height-e.top-e.bottom-e.buffer+1)}function ye(t,e){e.width!==Number(t.attr("width"))&&t.attr("width",e.width),e.height!==Number(t.attr("height"))&&t.attr("height",e.height)}function ve(t,e){t.attr("viewBox","0 0 "+e.width+" "+e.height),(e.full_width||e.full_height)&&t.attr("preserveAspectRatio","xMinYMin meet")}function be(t){t.classed("mg-missing",!1),t.selectAll(".mg-missing-text").remove(),t.selectAll(".mg-missing-pane").remove()}function we(t,e){var r=0;if(t.selectAll(".mg-main-line").nodes().length>=e.data.length)if(e.custom_line_color_map.length>0){var a=function(t){for(var e=new Array(t),r=0;r<e.length;r++)e[r]=r+1;return e},n=B(a(e.max_data_size),e.custom_line_color_map);for(r=0;r<n.length;r++)t.selectAll(".mg-main-line.mg-line"+n[r]+"-color").remove()}else{var o=e.data.length,i=t.selectAll(".mg-main-line").nodes()?t.selectAll(".mg-main-line").nodes().length:0;for(r=i;r>o;r--)t.selectAll(".mg-main-line.mg-line"+r+"-color").remove()}}function ke(t,e){if(t.empty())return void console.warn('The specified target element "'+e.target+'" could not be found in the page. The chart will not be rendered.')}function Me(t,e){var r="x"===e?t.width:t.height;Ge(t,e),Ae(t,e),De(t,e,r),r&&Oe(t,e)}function Ge(e,r){var a=r+"group_accessor",n=e[a];if(e.categorical_groups=[],n){var o=e.data[0];e.categorical_groups=t.set(o.map(function(t){return t[n]})).values()}}function Ae(e,r){var a=r+"group_accessor",n=e[a];if(e.total_bars=e.data[0].length,n){var o=d(f(e.data[0],n));o=t.max(Object.keys(o).map(function(t){return o[t]})),e.bars_per_group=o}else e.bars_per_group=e.data[0].length}function De(t,e,r){var a=e+"group_height";if(r){var n="y"===e?(t.height-t.top-t.bottom-2*t.buffer)/(t.categorical_groups.length||1):(t.width-t.left-t.right-2*t.buffer)/(t.categorical_groups.length||1);t[a]=n}else{var o=(1+t[e+"_padding_percentage"])*t.bar_thickness;t[a]=t.bars_per_group*o+2*t[e+"_outer_padding_percentage"]*o}}function Oe(t,e){var r=t[e+"group_height"]/(t.bars_per_group+t[e+"_outer_padding_percentage"]);t.bar_thickness=r-r*t[e+"_padding_percentage"]}function Fe(t,e){var r=t[e+"group_height"]*(t.categorical_groups.length||1),a="y"===e?t.top+t.bottom+2*t.buffer:t.left+t.right+2*t.buffer;return r+a+t.categorical_groups.length*t[e+"group_height"]*(t[e+"group_padding_percentage"]+t[e+"group_outer_padding_percentage"])}function ze(e){"use strict";e=arguments[0],e=de(e);var r=t.select(e.target);ke(r,e);var a=r.selectAll("svg");return"categorical"===e.y_axis_type&&Me(e,"y"),"categorical"===e.x_axis_type&&Me(e,"x"),pe(e),_e(e),me(e),ge(a,e),a=he(a,e),xe(a,e),ye(a,e),ve(a,e),be(a),V(e),we(a,e),this}function Ce(t){return t.label}function Te(t){t.selectAll(".mg-markers").remove(),t.selectAll(".mg-baselines").remove()}function Re(t){return function(e){return t.scales.X(e[t.x_accessor])>x(t)&&t.scales.X(e[t.x_accessor])<v(t)}}function Ye(t){return function(e){return t.scales.X(e[t.x_accessor])}}function $e(t){var e=Ye(t);return function(t){return e(t).toFixed(2)}}function Ee(t){var e=t.scales.Y;return function(t){return e(t.value).toFixed(2)}}function Pe(t,e,r,a,n,o){var i;t&&(i=a.append("g").attr("class",e),n(i,r),o(i,r))}function Le(t,e){Pe(t.markers,"mg-markers",t,e,Se,je)}function Xe(t,e){Pe(t.baselines,"mg-baselines",t,e,Ue,Be)}function Se(t,e){var r=$e(e);t.selectAll(".mg-markers").data(e.markers.filter(Re(e))).enter().append("line").attr("x1",r).attr("x2",r).attr("y1",e.top).attr("y2",_(e)).attr("class",function(t){return t.lineclass}).attr("stroke-dasharray","3,1")}function je(e,r){e.selectAll(".mg-markers").data(r.markers.filter(Re(r))).enter().append("text").attr("class",function(t){return t.textclass||""}).classed("mg-marker-text",!0).attr("x",Ye(r)).attr("y","bottom"===r.x_axis_position?.95*m(r):p(r)+r.buffer).attr("text-anchor","middle").text(Ce).each(function(e){e.click&&t.select(this).style("cursor","pointer").on("click",e.click)
n.trigger("focus").attr("aria-expanded","true"),o.toggleClass("open").trigger("shown.bs.dropdown",s)}return!1}},i.prototype.keydown=function(e){if(/(38|40|27|32)/.test(e.which)&&!/input|textarea/i.test(e.target.tagName)){var a=t(this);if(e.preventDefault(),e.stopPropagation(),!a.is(".disabled, :disabled")){var n=r(a),i=n.hasClass("open");if(!i&&27!=e.which||i&&27==e.which)return 27==e.which&&n.find(o).trigger("focus"),a.trigger("click");var s=" li:not(.divider):visible a",c=n.find('[role="menu"]'+s+', [role="listbox"]'+s);if(c.length){var l=c.index(e.target);38==e.which&&l>0&&l--,40==e.which&&l<c.length-1&&l++,~l||(l=0),c.eq(l).trigger("focus")}}}};var s=t.fn.dropdown;t.fn.dropdown=a,t.fn.dropdown.Constructor=i,t.fn.dropdown.noConflict=function(){return t.fn.dropdown=s,this},t(document).on("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",o,i.prototype.toggle).on("keydown.bs.dropdown.data-api",o,i.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="menu"]',i.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="listbox"]',i.prototype.keydown)}(jQuery),MG.button_layout=function(t){"use strict";return this.target=t,this.feature_set={},this.public_name={},this.sorters={},this.manual=[],this.manual_map={},this.manual_callback={},this._strip_punctuation=function(t){var e=t.replace(/[^a-zA-Z0-9 _]+/g,""),r=e.replace(/ +?/g,"");return r},this.data=function(t){return this._data=t,this},this.manual_button=function(t,e,r){return this.feature_set[t]=e,this.manual_map[this._strip_punctuation(t)]=t,this.manual_callback[t]=r,this},this.button=function(t){return arguments.length>1&&(this.public_name[t]=arguments[1]),arguments.length>2&&(this.sorters[t]=arguments[2]),this.feature_set[t]=[],this},this.callback=function(t){return this._callback=t,this},this.display=function(){var t,e,r,a,n=this._callback,o=this.manual_callback,i=this.manual_map;r=Object.keys(this.feature_set);var s,c=function(e){return t[e]};for(s=0;s<this._data.length;s++){t=this._data[s],e=r.map(c);for(var l=0;l<r.length;l++)a=r[l],this.feature_set[a].indexOf(e[l])===-1&&this.feature_set[a].push(e[l])}for(a in this.feature_set)this.sorters.hasOwnProperty(a)&&this.feature_set[a].sort(this.sorters[a]);$(this.target).empty(),$(this.target).append("<div class='col-lg-12 segments text-center'></div>");var u=function(){var t,e=$(this).data("key"),r=$(this).data("feature");return $("."+r+"-btns button.btn span.title").html(e),i.hasOwnProperty(r)?(t=i[r],o[t](e)):n(r,e),!1};for(var f in this.feature_set){for(r=this.feature_set[f],$(this.target+" div.segments").append('<div class="btn-group '+this._strip_punctuation(f)+'-btns text-left"><button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown"><span class=\'which-button\'>'+(this.public_name.hasOwnProperty(f)?this.public_name[f]:f)+"</span><span class='title'>"+(this.manual_callback.hasOwnProperty(f)?this.feature_set[f][0]:"all")+'</span><span class="caret"></span></button><ul class="dropdown-menu" role="menu">'+(this.manual_callback.hasOwnProperty(f)?"":'<li><a href="#" data-feature="'+f+'" data-key="all">All</a></li>')+(this.manual_callback.hasOwnProperty(f)?"":'<li class="divider"></li>')+"</ul></div>"),s=0;s<r.length;s++)"all"!==r[s]&&void 0!==r[s]&&$(this.target+" div."+this._strip_punctuation(f)+"-btns ul.dropdown-menu").append('<li><a href="#" data-feature="'+this._strip_punctuation(f)+'" data-key="'+r[s]+'">'+r[s]+"</a></li>");$("."+this._strip_punctuation(f)+"-btns .dropdown-menu li a").on("click",u)}return this},this},function(){"use strict";function e(t,e,r){t.classed("mg-hover-line"+e.line_id+"-color",null===r.colors).attr("fill",null===r.colors?"":r.colors[e.line_id-1])}function i(t,e,r){u(t,e),c(t,e),l(t,e),s(t,e,r)}function s(e,r,a){r.existing_band=a.selectAll(".mg-confidence-band").nodes(),e.show_confidence_band&&(r.confidence_area=t.area().defined(r.line.defined()).x(e.scalefns.xf).y0(function(t){var r=e.show_confidence_band[0];return void 0!=t[r]?e.scales.Y(t[r]):e.
}),"horizontal"==a.orientation&&(r="width",n="height",o=a.x_axis_type,i=a.y_axis_type,s="x",c="y",l="categorical"==o?a.scalefns.xoutf:a.scalefns.xf,u="categorical"==i?a.scalefns.youtf:a.scalefns.yf,f=a.scales.X,d=a.scales.Y,p=a.x_accessor,_=a.y_accessor,m=function(t){var e;return e=f(0)},h=function(t){return a.width-a.left-a.right-2*a.buffer});var x,y;"right"===a.rollover_align?(x=a.width-a.right,y="end"):"left"===a.rollover_align?(x=a.left,y="start"):(x=(a.width-a.left-a.right)/2+a.left,y="middle"),e.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",x).attr("y",.75*a.top).attr("dy",".35em").attr("text-anchor",y),t=e.append("g").attr("class","mg-rollover-rect");var v=t.selectAll(".mg-bar-rollover").data(a.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return v.attr("opacity",0).attr(s,m).attr(c,function(t){var e;return"categorical"==i?e=u(t):(e=d(0),t[_]<0&&(e=u(t))),e-=a.bar_thickness/2}),v.attr(r,h),v.attr(n,function(t){return a.bar_thickness}),v.on("mouseover",this.rolloverOn(a)).on("mouseout",this.rolloverOff(a)).on("mousemove",this.rolloverMove(a)),this},this.rolloverOn=function(e){var r=R(e.target);this.is_vertical?e.x_accessor:e.y_accessor,this.is_vertical?e.y_accessor:e.x_accessor,this.is_vertical?e.yax_units:e.xax_units;return function(a,n){var o=(MG.time_format(e.utc_time,"%b %e, %Y"),kr(e),r.selectAll("g.mg-barplot .mg-bar").filter(function(t,e){return e===n}).classed("active",!0));if(e.scales.hasOwnProperty("COLOR")?o.attr("fill",t.rgb(e.scalefns.colorf(a)).darker()):o.classed("default-active",!0),e.show_rollover_text){var i=Ze(e,{svg:r}),s=i.mouseover_row();e.ygroup_accessor&&s.text(a[e.ygroup_accessor]+" ").bold(),s.text(Gr(e,a)),s.text(e.y_accessor+": "+a[e.y_accessor]),(e.predictor_accessor||e.baseline_accessor)&&(s=i.mouseover_row(),e.predictor_accessor&&s.text(Mr(e,a,null,e.predictor_accessor,!1)),e.baseline_accessor&&s.text(Mr(e,a,null,e.baseline_accessor,!1)))}e.mouseover&&e.mouseover(a,n)}},this.rolloverOff=function(t){var e=R(t.target);return function(r,a){var n=e.selectAll("g.mg-barplot .mg-bar.active").classed("active",!1);t.scales.hasOwnProperty("COLOR")?n.attr("fill",t.scalefns.colorf(r)):n.classed("default-active",!1),e.select(".mg-active-datapoint").text(""),Ie(e),t.mouseout&&t.mouseout(r,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Ke(this.args),this},this.init(a)}var n={y_padding_percentage:.05,y_outer_padding_percentage:.2,ygroup_padding_percentage:0,ygroup_outer_padding_percentage:0,x_padding_percentage:.05,x_outer_padding_percentage:.2,xgroup_padding_percentage:0,xgroup_outer_padding_percentage:0,buffer:16,y_accessor:"factor",x_accessor:"value",secondary_label_accessor:null,color_accessor:null,color_type:"category",color_domain:null,legend:!0,legend_target:null,mouseover_align:"right",baseline_accessor:null,predictor_accessor:null,predictor_proportion:5,show_bar_zero:!0,binned:!0,truncate_x_labels:!0,truncate_y_labels:!0};MG.register("bar",a,n)}.call(this),MG.data_table=function(r){"use strict";return this.args=r,this.args.standard_col={width:150,font_size:12,font_weight:"normal"},this.args.columns=[],this.formatting_options=[["color","color"],["font-weight","font_weight"],["font-style","font_style"],["font-size","font_size"]],this._strip_punctuation=function(t){var e=t.replace(/[^a-zA-Z0-9 _]+/g,""),r=e.replace(/ +?/g,"");return r},this._format_element=function(t,e,r){this.formatting_options.forEach(function(a){var n=a[0],o=a[1];r[o]&&t.style(n,"string"==typeof r[o]||"number"==typeof r[o]?r[o]:r[o](e))})},this._add_column=function(t,e){var r=this.args.standard_col,a=U(MG.clone(t),MG.clone(r));a.type=e,this.args.columns.push(a)},this.target=function(){var t=arguments[0];return this.args.target=t,this},this.title=function(){return this._add_column(arguments[0],"title"),this},this.text=function(){return this._add_column(arguments[0],"text"),this},this.bullet=function(){return this},this.sparkline=function(){return this},this.number=function(){return th