diff options
Diffstat (limited to 'priv/static/js/metricsgraphics.min.js')
-rw-r--r-- | priv/static/js/metricsgraphics.min.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/priv/static/js/metricsgraphics.min.js b/priv/static/js/metricsgraphics.min.js new file mode 100644 index 0000000..19e96b7 --- /dev/null +++ b/priv/static/js/metricsgraphics.min.js @@ -0,0 +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(E){"use strict";var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function k(){return"undefined"!=typeof jQuery||"undefined"!=typeof $}function i(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 u(t){return"[object Array]"===Object.prototype.toString.call(t)}function a(t){var e=t.map(function(t){return!0===u(t)&&0<t.length});return E.sum(e)===t.length}function n(t){var e=t.map(function(t){return!0==(e=t,"[object Object]"===Object.prototype.toString.call(e));var e});return E.sum(e)===t.length}function e(t){return u(e=t)&&0===e.length||n(t);var e}function w(t){return t.height-t.bottom}function v(t){return w(t)-t.buffer}function M(t){return t.top}function b(t){return M(t)+t.buffer}function G(t){return t.left}function Y(t){return G(t)+t.buffer}function A(t){return t.width-t.right}function P(t){return A(t)-t.buffer}function _(t){t.exit().remove()}function D(t,e){t.selectAll(e).remove()}function S(t,e){return t.append("g").classed(e,!0)}function r(t,e){var r=O(t.target),a=h(t.data),n=r.selectAll("line."+e).data(a);return n.enter().append("line").attr("class",e).attr("opacity",.3),_(n),_(n),n}function m(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 l(t,e){e&&t.attr({dy:0,transform:function(){var t=E.select(this);return"rotate("+e+" "+t.attr("x")+","+t.attr("y")+")"}})}function g(t){if(!(t=t.node()))return!1;for(var e=0;e<t.length;e++)if(o(t[e],t))return!0;return!1}function o(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 s(t,e){var r=h(t.data);return"string"==typeof(r=r[0][t[e+"_accessor"]])?"categorical":"numerical"}function O(t){return E.select(t).select("svg")}function h(t){var e=[];return e.concat.apply(e,t)}function z(t){if("string"==typeof t)return F(t);if(t instanceof window.HTMLElement){var e=t.getAttribute("data-mg-uid");return e||(void 0===MG._next_elem_id&&(MG._next_elem_id=0),e="mg-"+MG._next_elem_id++,t.setAttribute("data-mg-uid",e)),e}return console.warn("The specified target should be a string or an HTMLElement.",t),F(t)}function F(t){return t.replace(/[^a-zA-Z0-9 _-]+/g,"").replace(/ +?/g,"")}function d(t,e){return Number(E.select(t).style(e).replace(/px/g,""))}function f(t){return d(t,"width")}("undefined"==typeof window?global:window).MG={version:"2.11"},MG.convert={},MG.convert.date=function(t,e,r){r=void 0===r?"%Y-%m-%d":r;var a=E.timeParse(r);return t=t.map(function(t){return t[e]=a(t[e].trim()),t})},MG.convert.number=function(t,e){return t=t.map(function(t){return t[e]=Number(t[e]),t})},MG.time_format=function(t,e){return t?E.utcFormat(e):E.timeFormat(e)};var t=function(t,e,r){var a={};if(null===t)return t;if(Array.prototype.forEach&&t.forEach===Array.prototype.forEach)t.forEach(e,r);else if(t.length===+t.length){for(var n=0,o=t.length;n<o;n++)if(e.call(r,t[n],n,t)===a)return}else for(var i in t)if(e.call(r,t[i],i,t)===a)return;return t};function p(r){return t(Array.prototype.slice.call(arguments,1),function(t){if(t)for(var e in t)void 0===r[e]&&(r[e]=t[e])}),r}function x(t){return"[object Date]"===Object.prototype.toString.call(t)}function y(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}function C(t){return"[object Function]"===Object.prototype.toString.call(t)}function T(t,e){var r,a=[],n=[];for(r=0;r<e.length;r++)a[e[r]]=!0;for(r=0;r<t.length;r++)a[t[r]]||n.push(t[r]);return n}function R(t,e){console.warn("Deprecation: "+t+(e?". This feature will be removed in "+e+".":" the near future.")),console.trace()}function L(t,e,r){var a,n=0;for(t.textContent=e,a=t.getBBox();a.width>r&&(t.textContent=e.slice(0,--n)+"...",a=t.getBBox(),"..."!==t.textContent););}function j(t){var e=O(t.target);if(e.select(".mg-header").remove(),t.target&&t.title){var r=e.insert("text").attr("class","mg-header").attr("x",t.center_title_full_width?t.width/2:(t.width+t.left-t.right)/2).attr("y",t.title_y_position).attr("text-anchor","middle").attr("dy","0.55em");if(r.append("tspan").attr("class","mg-chart-title").text(t.title),t.show_tooltips&&t.description&&k()){r.append("tspan").attr("class","mg-chart-description").attr("dx","0.3em").text("");var a=$(r.node());a.popover({html:!0,animation:!1,placement:"top",content:t.description,container:t.target,trigger:"manual",template:'<div class="popover mg-popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'}).on("mouseenter",function(){E.selectAll(t.target).selectAll(".mg-popover").remove(),$(this).popover("show"),$(E.select(t.target).select(".popover").node()).on("mouseleave",function(){a.popover("hide")})}).on("mouseleave",function(){setTimeout(function(){$(".popover:hover").length||a.popover("hide")},120)})}else t.show_tooltips&&t.description&&"undefined"==typeof $&&(t.error="In order to enable tooltips, please make sure you include jQuery.")}t.error&&Xe(t)}function X(e,t,r,a,n){e.scalefns[t]=function(t){return void 0===n?e.scales[r](t[a]):e.scales[r](t[a])+n}}function U(t,e){return"bottom"===t||"top"===t?[Y(e),P(e)]:"left"===t||"right"===t?[v(e),e.top]:void 0}function N(t,e){return E.set(t.map(function(t){return t[e]})).values()}function B(e){var t;return null===e.color_domain?"number"===e.color_type?t=E.extent(e.data[0],function(t){return t[e.color_accessor]}):"category"===e.color_type&&(t=N(e.data[0],e.color_accessor)):t=e.color_domain,t}function I(t){return null===t.color_range?"number"===t.color_type?["blue","red"]:null:t.color_range}function H(t,e,r){var a=xt(t),n=a.secondary(t.processed.min_x,t.processed.max_x);0===n.length&&(n=[t.scales.X.ticks(t.xax_count)[0]]);var o,i,s,c=S(r,"mg-year-marker");"default"===a.timeframe&&t.show_year_markers&&(o=t,i=c,s=n,a.yformat,i.selectAll(".mg-year-marker").data(s).enter().append("line").attr("x1",function(t){return o.scales.X(t).toFixed(2)}).attr("x2",function(t){return o.scales.X(t).toFixed(2)}).attr("y1",M(o)).attr("y2",w(o))),"years"!=a.tick_diff_timeframe&&function(t,e,r,a,n){var o,i,s,c,l,u=e.position,d=e.namespace,f=t.scales[d.toUpperCase()],p=E.select(t.target).select(".mg-x-axis text").node().getBoundingClientRect();"top"===u&&(o=function(t,e){return f(t).toFixed(2)},i=M(t)-7*t.xax_tick_length/3-p.height,s=".50em",c="middle",l=function(t){return n(new Date(t))});"bottom"===u&&(o=function(t,e){return f(t).toFixed(2)},i=w(t)+7*t.xax_tick_length/3+.8*p.height,s=".50em",c="middle",l=function(t){return n(new Date(t))});r.selectAll(".mg-year-marker").data(a).enter().append("text").attr("x",o).attr("y",i).attr("dy",s).attr("text-anchor",c).text(l)}(t,e,c,n,a.yformat)}function q(t,a,e){var r,n,o,i,s,c,l,u=e.namespace,d=(r=a,o=(n=e).position,i=n.namespace,s=r[i+"ax_tick_length"],c=r.scales[i.toUpperCase()],l={},"left"===o&&(l.x=G(r)-3*s/2,l.y=function(t){return c(t).toFixed(2)},l.dx=-3,l.dy=".35em",l.textAnchor="end",l.text=function(t){return J(r)(t)}),"right"===o&&(l.x=A(r)+3*s/2,l.y=function(t){return c(t).toFixed(2)},l.dx=3,l.dy=".35em",l.textAnchor="start",l.text=function(t){return J(r)(t)}),"top"===o&&(l.x=function(t){return c(t).toFixed(2)},l.y=(M(r)-7*s/3).toFixed(2),l.dx=0,l.dy="0em",l.textAnchor="middle",l.text=function(t){return ht(r)(t)}),"bottom"===o&&(l.x=function(t){return c(t).toFixed(2)},l.y=(w(r)+7*s/3).toFixed(2),l.dx=0,l.dy=".50em",l.textAnchor="middle",l.text=function(t){return ht(r)(t)}),l),f=a.processed[u+"_ticks"],p=t.selectAll(".mg-yax-labels").data(f).enter().append("text").attr("x",d.x).attr("dx",d.dx).attr("y",d.y).attr("dy",d.dy).attr("text-anchor",d.textAnchor).text(d.text);("x"==u&&(a.time_series&&a.european_clock?(p.append("tspan").classed("mg-european-hours",!0).text(function(t,e){var r=new Date(t);return 0===e?E.timeFormat("%H")(r):""}),p.append("tspan").classed("mg-european-minutes-seconds",!0).text(function(t,e){var r=new Date(t);return":"+a.processed.xax_format(r)})):p.text(function(t){return a.xax_units+a.processed.xax_format(t)}),a.time_series&&(a.show_years||a.show_secondary_x_label)&&H(a,e,t)),g(p))&&(p.filter(function(t,e){return(e+1)%2==0}).remove(),O(a.target).selectAll(".mg-"+u+"ax-ticks").filter(function(t,e){return(e+1)%2==0}).remove())}function V(t,e,r){var a,n,o,i,s,c,l,u,d=r.namespace,f=e.processed[d+"_ticks"].length,p=(a=e,o=(n=r).namespace,i=n.position,s=a.processed[o+"_ticks"].length,c=a.processed[o+"_ticks"],l=a.scales[o.toUpperCase()],u={},"left"===i&&(u.x1=G(a),u.x2=G(a),u.y1=l(c[0]).toFixed(2),u.y2=l(c[s-1]).toFixed(2)),"right"===i&&(u.x1=A(a),u.x2=A(a),u.y1=l(c[0]).toFixed(2),u.y2=l(c[s-1]).toFixed(2)),"top"===i&&(u.x1=G(a),u.x2=A(a),u.y1=M(a),u.y2=M(a)),"bottom"===i&&(u.x1=G(a),u.x2=A(a),u.y1=w(a),u.y2=w(a)),"left"!==i&&"right"!==i||(a.axes_not_compact?(u.y1=w(a),u.y2=M(a)):s&&(u.y1=l(c[0]).toFixed(2),u.y2=l(c[s-1]).toFixed(2))),u);e[d+"_extended_ticks"]||e[d+"_extended_ticks"]||!f||t.append("line").attr("x1",p.x1).attr("x2",p.x2).attr("y1",p.y1).attr("y2",p.y2)}function W(t,e){t.rug_buffer_size="point"===t.chart_type?t.buffer/2:2*t.buffer/3;var r,a,n,o,i,s,c,l,u,d,f=(r=t,a="mg-"+e.namespace+"-rug",n=O(r.target),o=h(r.data),(i=n.selectAll("line."+a).data(o)).enter().append("svg:line").attr("class",a).attr("opacity",.3),_(i),_(i),i),p=(s=t,l=(c=e).position,u=c.namespace,d={},"left"===l&&(d.x1=G(s)+1,d.x2=G(s)+s.rug_buffer_size,d.y1=s.scalefns[u+"f"],d.y2=s.scalefns[u+"f"]),"right"===l&&(d.x1=A(s)-1,d.x2=A(s)-s.rug_buffer_size,d.y1=s.scalefns[u+"f"],d.y2=s.scalefns[u+"f"]),"top"===l&&(d.x1=s.scalefns[u+"f"],d.x2=s.scalefns[u+"f"],d.y1=M(s)+1,d.y2=M(s)+s.rug_buffer_size),"bottom"===l&&(d.x1=s.scalefns[u+"f"],d.x2=s.scalefns[u+"f"],d.y1=w(s)-1,d.y2=w(s)-s.rug_buffer_size),d);f.attr("x1",p.x1).attr("x2",p.x2).attr("y1",p.y1).attr("y2",p.y2),m(f,t,"mg-"+e.namespace+"-rug-mono")}function Q(p,_){var m=_.namespace,t="mg-"+m+"-axis",g=p.scales[m.toUpperCase()],e=p.scales[(m+"group").toUpperCase()],h=m+"group_accessor",r=O(p.target);D(r,"."+t);var x,y=S(r,t);(e.domain&&e.domain()?e.domain():["1"]).forEach(function(t){var e,r,a,n,o,i,s,c,l,u,d=(e=p,a=t,n=(r=_).namespace,o=r.position,i=e.scales[n.toUpperCase()],s=e.scales[(n+"group").toUpperCase()],c={cat:{},group:{}},"left"===o&&(c.cat.x=Y(e)-e.buffer,c.cat.y=function(t){return s(a)+i(t)+i.bandwidth()/2},c.cat.dy=".35em",c.cat.textAnchor="end",c.group.x=Y(e)-e.buffer,c.group.y=s(a)+(s.bandwidth?s.bandwidth()/2:0),c.group.dy=".35em",c.group.textAnchor=(e["rotate_"+n+"_labels"],"end")),"right"===o&&(c.cat.x=P(e)-e.buffer,c.cat.y=function(t){return s(a)+i(t)+i.bandwidth()/2},c.cat.dy=".35em",c.cat.textAnchor="start",c.group.x=P(e)-e.buffer,c.group.y=s(a)+(s.bandwidth?s.bandwidth()/2:0),c.group.dy=".35em",c.group.textAnchor="start"),"top"===o&&(c.cat.x=function(t){return s(a)+i(t)+i.bandwidth()/2},c.cat.y=b(e)+e.buffer,c.cat.dy=".35em",c.cat.textAnchor=e["rotate_"+n+"_labels"]?"start":"middle",c.group.x=s(a)+(s.bandwidth?s.bandwidth()/2:0),c.group.y=b(e)+e.buffer,c.group.dy=".35em",c.group.textAnchor=e["rotate_"+n+"_labels"]?"start":"middle"),"bottom"===o&&(c.cat.x=function(t){return s(a)+i(t)+i.bandwidth()/2},c.cat.y=v(e)+e.buffer,c.cat.dy=".35em",c.cat.textAnchor=e["rotate_"+n+"_labels"]?"start":"middle",c.group.x=s(a)+(s.bandwidth?s.bandwidth()/2-i.bandwidth()/2:0),c.group.y=v(e)+e.buffer,c.group.dy=".35em",c.group.textAnchor=e["rotate_"+n+"_labels"]?"start":"middle"),c);if(x=S(y,"mg-group-"+F(t)),null!==p[h])var f=x.append("text").classed("mg-barplot-group-label",!0).attr("x",d.group.x).attr("y",d.group.y).attr("dy",d.group.dy).attr("text-anchor",d.group.textAnchor).text(t);else f=x.selectAll("text").data(g.domain()).enter().append("text").attr("x",d.cat.x).attr("y",d.cat.y).attr("dy",d.cat.dy).attr("text-anchor",d.cat.textAnchor).text(String);p["rotate_"+m+"_labels"]&&(l=f,(u=p["rotate_"+m+"_labels"])&&l.attr("transform",function(){var t=E.select(this);return"rotate("+u+" "+t.attr("x")+","+t.attr("y")+")"}))})}MG.merge_with_defaults=p,MG.clone=function(t){var e,r;if(null===t||"object"!==(void 0===t?"undefined":c(t)))return t;if(x(t))return(e=new Date).setTime(t.getTime()),e;if(y(t)){e=[];for(var a=0,n=t.length;a<n;a++)e[a]=MG.clone(t[a]);return e}if(r=t,"[object Object]"===Object.prototype.toString.call(r)){for(var o in e={},t)t.hasOwnProperty(o)&&(e[o]=MG.clone(t[o]));return e}throw new Error("Unable to copy obj! Its type isn't supported.")},MG.arr_diff=T,MG.warn_deprecation=R,MG.truncate_text=L,MG.wrap_text=function(t,i,s,c){t.each(function(){for(var t,e=E.select(this),r=e.text().split(s||/\s+/).reverse(),a=[],n=0,o=(e.attr("y"),e.text(null).append("tspan").attr("x",0).attr("y","0em").attr(c||{}));t=r.pop();)a.push(t),o.text(a.join(" ")),(null===i||o.node().getComputedTextLength()>i)&&(a.pop(),o.text(a.join(" ")),a=[t],o=e.append("tspan").attr("x",0).attr("y",1.1*++n+0+"em").attr(c||{}).text(t))})},MG.register=function(t,e,r){MG.charts[t]={descriptor:e,defaults:r||{}}},MG._hooks={},MG.add_hook=function(t,e,r){var a;if(MG._hooks[t]||(MG._hooks[t]=[]),0<(a=MG._hooks[t]).filter(function(t){return t.func===e}).length)throw"That function is already registered.";a.push({func:e,context:r})},MG.call_hook=function(t){var r,e=MG._hooks[t],a=[].slice.apply(arguments,[1]);return e&&e.forEach(function(t){if(t.func){var e=r||a;e&&e.constructor!==Array&&(e=[e]),e=[].concat.apply([],e),r=t.func.apply(t.context,e)}}),r||a},MG.globals={},MG.deprecations={rollover_callback:{replacement:"mouseover",version:"2.0"},rollout_callback:{replacement:"mouseout",version:"2.0"},x_rollover_format:{replacement:"x_mouseover",version:"2.10"},y_rollover_format:{replacement:"y_mouseover",version:"2.10"},show_years:{replacement:"show_secondary_x_label",version:"2.1"},xax_start_at_min:{replacement:"axes_not_compact",version:"2.7"},interpolate_tension:{replacement:"interpolate",version:"2.10"}},MG.globals.link=!1,MG.globals.version="1.1",MG.charts={},MG.data_graphic=function(t){var e={missing_is_zero:!1,missing_is_hidden:!1,missing_is_hidden_accessor:null,legend:"",legend_target:"",error:"",animate_on_load:!1,top:65,title_y_position:10,center_title_full_width:!1,bottom:45,right:10,left:50,buffer:8,width:350,height:220,full_width:!1,full_height:!1,small_height_threshold:120,small_width_threshold:160,xax_count:6,xax_tick_length:5,axes_not_compact:!0,yax_count:3,yax_tick_length:5,x_extended_ticks:!1,y_extended_ticks:!1,y_scale_type:"linear",max_x:null,max_y:null,min_x:null,min_y:null,min_y_from_data:!1,point_size:2.5,active_point_on_lines:!1,active_point_accessor:"active",active_point_size:2,points_always_visible:!1,x_accessor:"date",xax_units:"",x_label:"",x_sort:!0,x_axis:!0,y_axis:!0,x_axis_position:"bottom",y_axis_position:"left",x_axis_type:null,y_axis_type:null,ygroup_accessor:null,xgroup_accessor:null,y_padding_percentage:.05,y_outer_padding_percentage:.1,ygroup_padding_percentage:.25,ygroup_outer_padding_percentage:0,x_padding_percentage:.05,x_outer_padding_percentage:.1,xgroup_padding_percentage:.25,xgroup_outer_padding_percentage:0,y_categorical_show_guides:!1,x_categorical_show_guide:!1,rotate_x_labels:0,rotate_y_labels:0,y_accessor:"value",y_label:"",yax_units:"",yax_units_append:!1,x_rug:!1,y_rug:!1,mouseover_align:"right",x_mouseover:null,y_mouseover:null,transition_on_update:!0,mouseover:null,click:null,show_rollover_text:!0,show_confidence_band:null,xax_format:null,area:!0,flip_area_under_y_value:null,chart_type:"line",data:[],decimals:2,format:"count",inflator:10/9,linked:!1,linked_format:"%Y-%m-%d",list:!1,baselines:null,markers:null,scalefns:{},scales:{},utc_time:!1,european_clock:!1,show_year_markers:!1,show_secondary_x_label:!0,target:"#viz",interpolate:E.curveCatmullRom.alpha(0),custom_line_color_map:[],colors:null,max_data_size:null,aggregate_rollover:!1,show_tooltips:!0,showActivePoint:!0,brush:null,zoom_target:null,brushing_selection_changed:null};MG.call_hook("global.defaults",e),t||(t={});var r=MG.charts[t.chart_type||e.chart_type];for(var a in p(t,r.defaults,e),t.list&&(t.x_accessor=0,t.y_accessor=1),MG.deprecations)if(t.hasOwnProperty(a)){var n=MG.deprecations[a],o="Use of `args."+a+"` has been deprecated",i=n.replacement;if(i&&(t[i]?o+=". The replacement - `args."+i+"` - has already been defined. This definition will be discarded.":t[i]=t[a]),n.warned)continue;n.warned=!0,i&&(o+=" in favor of `args."+i+"`"),R(o,n.version)}return MG.call_hook("global.before_init",t),new r.descriptor(t),t.data},k()&&(function(m){var g=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};g.VERSION="3.3.5",g.TRANSITION_DURATION=150,g.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},g.prototype.init=function(t,e,r){if(this.enabled=!0,this.type=t,this.$element=m(e),this.options=this.getOptions(r),this.$viewport=this.options.viewport&&m(m.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var a=this.options.trigger.split(" "),n=a.length;n--;){var o=a[n];if("click"==o)this.$element.on("click."+this.type,this.options.selector,m.proxy(this.toggle,this));else if("manual"!=o){var i="hover"==o?"mouseenter":"focusin",s="hover"==o?"mouseleave":"focusout";this.$element.on(i+"."+this.type,this.options.selector,m.proxy(this.enter,this)),this.$element.on(s+"."+this.type,this.options.selector,m.proxy(this.leave,this))}}this.options.selector?this._options=m.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},g.prototype.getDefaults=function(){return g.DEFAULTS},g.prototype.getOptions=function(t){return(t=m.extend({},this.getDefaults(),this.$element.data(),t)).delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t},g.prototype.getDelegateOptions=function(){var r={},a=this.getDefaults();return this._options&&m.each(this._options,function(t,e){a[t]!=e&&(r[t]=e)}),r},g.prototype.enter=function(t){var e=t instanceof this.constructor?t:m(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),m(t.currentTarget).data("bs."+this.type,e)),t instanceof m.Event&&(e.inState["focusin"==t.type?"focus":"hover"]=!0),e.tip().hasClass("in")||"in"==e.hoverState)e.hoverState="in";else{if(clearTimeout(e.timeout),e.hoverState="in",!e.options.delay||!e.options.delay.show)return e.show();e.timeout=setTimeout(function(){"in"==e.hoverState&&e.show()},e.options.delay.show)}},g.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},g.prototype.leave=function(t){var e=t instanceof this.constructor?t:m(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),m(t.currentTarget).data("bs."+this.type,e)),t instanceof m.Event&&(e.inState["focusout"==t.type?"focus":"hover"]=!1),!e.isInStateTrue()){if(clearTimeout(e.timeout),e.hoverState="out",!e.options.delay||!e.options.delay.hide)return e.hide();e.timeout=setTimeout(function(){"out"==e.hoverState&&e.hide()},e.options.delay.hide)}},g.prototype.show=function(){var t=m.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(t);var e=m.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(t.isDefaultPrevented()||!e)return;var r=this,a=this.tip(),n=this.getUID(this.type);this.setContent(),a.attr("id",n),this.$element.attr("aria-describedby",n),this.options.animation&&a.addClass("fade");var o="function"==typeof this.options.placement?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,s=i.test(o);s&&(o=o.replace(i,"")||"top"),a.detach().css({top:0,left:0,display:"block"}).addClass(o).data("bs."+this.type,this),this.options.container?a.appendTo(this.options.container):a.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var c=this.getPosition(),l=a[0].offsetWidth,u=a[0].offsetHeight;if(s){var d=o,f=this.getPosition(this.$viewport);o="bottom"==o&&c.bottom+u>f.bottom?"top":"top"==o&&c.top-u<f.top?"bottom":"right"==o&&c.right+l>f.width?"left":"left"==o&&c.left-l<f.left?"right":o,a.removeClass(d).addClass(o)}var p=this.getCalculatedOffset(o,c,l,u);this.applyPlacement(p,o);var _=function(){var t=r.hoverState;r.$element.trigger("shown.bs."+r.type),r.hoverState=null,"out"==t&&r.leave(r)};m.support.transition&&this.$tip.hasClass("fade")?a.one("bsTransitionEnd",_).emulateTransitionEnd(g.TRANSITION_DURATION):_()}},g.prototype.applyPlacement=function(t,e){var r=this.tip(),a=r[0].offsetWidth,n=r[0].offsetHeight,o=parseInt(r.css("margin-top"),10),i=parseInt(r.css("margin-left"),10);isNaN(o)&&(o=0),isNaN(i)&&(i=0),t.top+=o,t.left+=i,m.offset.setOffset(r[0],m.extend({using:function(t){r.css({top:Math.round(t.top),left:Math.round(t.left)})}},t),0),r.addClass("in");var s=r[0].offsetWidth,c=r[0].offsetHeight;"top"==e&&c!=n&&(t.top=t.top+n-c);var l=this.getViewportAdjustedDelta(e,t,s,c);l.left?t.left+=l.left:t.top+=l.top;var u=/top|bottom/.test(e),d=u?2*l.left-a+s:2*l.top-n+c,f=u?"offsetWidth":"offsetHeight";r.offset(t),this.replaceArrow(d,r[0][f],u)},g.prototype.replaceArrow=function(t,e,r){this.arrow().css(r?"left":"top",50*(1-t/e)+"%").css(r?"top":"left","")},g.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find(".tooltip-inner")[this.options.html?"html":"text"](e),t.removeClass("fade in top bottom left right")},g.prototype.hide=function(t){var e=this,r=m(this.$tip),a=m.Event("hide.bs."+this.type);function n(){"in"!=e.hoverState&&r.detach(),e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),t&&t()}if(this.$element.trigger(a),!a.isDefaultPrevented())return r.removeClass("in"),m.support.transition&&r.hasClass("fade")?r.one("bsTransitionEnd",n).emulateTransitionEnd(g.TRANSITION_DURATION):n(),this.hoverState=null,this},g.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},g.prototype.hasContent=function(){return this.getTitle()},g.prototype.getPosition=function(t){var e=(t=t||this.$element)[0],r="BODY"==e.tagName,a=e.getBoundingClientRect();null==a.width&&(a=m.extend({},a,{width:a.right-a.left,height:a.bottom-a.top}));var n=r?{top:0,left:0}:t.offset(),o={scroll:r?document.documentElement.scrollTop||document.body.scrollTop:t.scrollTop()},i=r?{width:m(window).width(),height:m(window).height()}:null;return m.extend({},a,o,i,n)},g.prototype.getCalculatedOffset=function(t,e,r,a){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-r/2}:"top"==t?{top:e.top-a,left:e.left+e.width/2-r/2}:"left"==t?{top:e.top+e.height/2-a/2,left:e.left-r}:{top:e.top+e.height/2-a/2,left:e.left+e.width}},g.prototype.getViewportAdjustedDelta=function(t,e,r,a){var n={top:0,left:0};if(!this.$viewport)return n;var o=this.options.viewport&&this.options.viewport.padding||0,i=this.getPosition(this.$viewport);if(/right|left/.test(t)){var s=e.top-o-i.scroll,c=e.top+o-i.scroll+a;s<i.top?n.top=i.top-s:c>i.top+i.height&&(n.top=i.top+i.height-c)}else{var l=e.left-o,u=e.left+o+r;l<i.left?n.left=i.left-l:u>i.right&&(n.left=i.left+i.width-u)}return n},g.prototype.getTitle=function(){var t=this.$element,e=this.options;return t.attr("data-original-title")||("function"==typeof e.title?e.title.call(t[0]):e.title)},g.prototype.getUID=function(t){for(;t+=~~(1e6*Math.random()),document.getElementById(t););return t},g.prototype.tip=function(){if(!this.$tip&&(this.$tip=m(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},g.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},g.prototype.enable=function(){this.enabled=!0},g.prototype.disable=function(){this.enabled=!1},g.prototype.toggleEnabled=function(){this.enabled=!this.enabled},g.prototype.toggle=function(t){var e=this;t&&((e=m(t.currentTarget).data("bs."+this.type))||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),m(t.currentTarget).data("bs."+this.type,e))),t?(e.inState.click=!e.inState.click,e.isInStateTrue()?e.enter(e):e.leave(e)):e.tip().hasClass("in")?e.leave(e):e.enter(e)},g.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null})};var t=m.fn.tooltip;m.fn.tooltip=function(a){return this.each(function(){var t=m(this),e=t.data("bs.tooltip"),r="object"==(void 0===a?"undefined":c(a))&&a;!e&&/destroy|hide/.test(a)||(e||t.data("bs.tooltip",e=new g(this,r)),"string"==typeof a&&e[a]())})},m.fn.tooltip.Constructor=g,m.fn.tooltip.noConflict=function(){return m.fn.tooltip=t,this}}(jQuery),function(n){var o=function(t,e){this.init("popover",t,e)};if(!n.fn.tooltip)throw new Error("Popover requires tooltip.js");o.VERSION="3.3.5",o.DEFAULTS=n.extend({},n.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),((o.prototype=n.extend({},n.fn.tooltip.Constructor.prototype)).constructor=o).prototype.getDefaults=function(){return o.DEFAULTS},o.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),r=this.getContent();t.find(".popover-title")[this.options.html?"html":"text"](e),t.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof r?"html":"append":"text"](r),t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},o.prototype.hasContent=function(){return this.getTitle()||this.getContent()},o.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},o.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var t=n.fn.popover;n.fn.popover=function(a){return this.each(function(){var t=n(this),e=t.data("bs.popover"),r="object"==(void 0===a?"undefined":c(a))&&a;!e&&/destroy|hide/.test(a)||(e||t.data("bs.popover",e=new o(this,r)),"string"==typeof a&&e[a]())})},n.fn.popover.Constructor=o,n.fn.popover.noConflict=function(){return n.fn.popover=t,this}}(jQuery)),MG.chart_title=j,MG.scale_factory=function(o){var i={use_inflator:!1,zero_bottom:!1,scaleType:"numerical"};return this.namespace=function(t){return i.namespace=t,i.namespace_accessor_name=i.namespace+"_accessor",i.scale_name=i.namespace.toUpperCase(),i.scalefn_name=i.namespace+"f",this},this.scaleName=function(t){return i.scale_name=t.toUpperCase(),i.scalefn_name=t+"f",this},this.inflateDomain=function(t){return i.use_inflator=t,this},this.zeroBottom=function(t){return i.zero_bottom=t,this},this.numericalDomainFromData=function(){var t,e=[];0<arguments.length&&(e=arguments);for(var r=0;r<o.data.length;r++)0<o.data[r].length&&(t=o.data[r]);i.is_time_series=!!x(t[0][o[i.namespace_accessor_name]]),X(o,i.scalefn_name,i.scale_name,o[i.namespace_accessor_name]),function(t,e,r){var a=e.namespace,n=e.namespace_accessor_name,o=e.use_inflator,i=e.zero_bottom,s=t[n],c=h(t.data).map(function(t){return t[s]}).concat(h(r));"log"===t[a+"_scale_type"]&&(c=c.filter(function(t){return 0<t}));var l=E.extent(c),u=l[0],d=l[1];i&&!t["min_"+a+"_from_data"]&&0<u&&!e.is_time_series&&(u="log"===t[a+"_scale_type"]?1:0),"log"!==t[a+"_scale_type"]&&u<0&&!e.is_time_series&&(u-=(u-u*t.inflator)*o),e.is_time_series||(d=d<0?d+(d-d*t.inflator)*o:d*(o?t.inflator:1)),u=null!=t["min_"+a]?t["min_"+a]:u,d=null!=t["max_"+a]?t["max_"+a]:d,u===d&&null==t["min_"+a]&&null==t["max_"+a]&&(x(u)?d=new Date(MG.clone(u).setDate(u.getDate()+1)):"number"==typeof u&&(d=u+1,t.xax_count=2)),t.processed["min_"+a]=u,t.processed["max_"+a]=d,t.processed["zoom_"+a]&&(t.processed["min_"+a]=t.processed["zoom_"+a][0],t.processed["max_"+a]=t.processed["zoom_"+a][1]),MG.call_hook("x_axis.process_min_max",t,t.processed.min_x,t.processed.max_x),MG.call_hook("y_axis.process_min_max",t,t.processed.min_y,t.processed.max_y)}(o,i,e,i.use_inflator);var a=o.utc_time?E.scaleUtc():E.scaleTime();return o.scales[i.scale_name]=i.is_time_series?a:C(o[i.namespace+"_scale_type"])?o.y_scale_type():"log"===o[i.namespace+"_scale_type"]?E.scaleLog():E.scaleLinear(),o.scales[i.scale_name].domain([o.processed["min_"+i.namespace],o.processed["max_"+i.namespace]]),i.scaleType="numerical",this},this.categoricalDomain=function(t){return o.scales[i.scale_name]=E.scaleOrdinal().domain(t),X(o,i.scalefn_name,i.scale_name,o[i.namespace_accessor_name]),this},this.categoricalDomainFromData=function(){var t=h(o.data);return i.categoricalVariables=E.set(t.map(function(t){return t[o[i.namespace_accessor_name]]})).values(),o.scales[i.scale_name]=E.scaleBand().domain(i.categoricalVariables),i.scaleType="categorical",this},this.numericalRange=function(t){return"string"==typeof t?o.scales[i.scale_name].range(U(t,o)):o.scales[i.scale_name].range(t),this},this.categoricalRangeBands=function(t,e){void 0===e&&(e=!1);var r=i.namespace,a=o[r+"_padding_percentage"],n=o[r+"_outer_padding_percentage"];return"string"==typeof t?o.scales[i.scale_name].range(U(t,o)).paddingInner(a).paddingOuter(n):o.scales[i.scale_name].range(t).paddingInner(a).paddingOuter(n),X(o,i.scalefn_name,i.scale_name,o[i.namespace_accessor_name],e?o.scales[i.scale_name].bandwidth()/2:0),this},this.categoricalRange=function(t){return o.scales[i.scale_name].range(t),X(o,i.scalefn_name,i.scale_name,o[i.namespace_accessor_name]),this},this.categoricalColorRange=function(){return o.scales[i.scale_name]=10<o.scales[i.scale_name].domain().length?E.scaleOrdinal(E.schemeCategory20):E.scaleOrdinal(E.schemeCategory10),o.scales[i.scale_name].domain(i.categoricalVariables),X(o,i.scalefn_name,i.scale_name,o[i.namespace_accessor_name]),this},this.clamp=function(t){return o.scales[i.scale_name].clamp(t),this},this};var Z={};function K(t){if(t.y_rug){t.rug_buffer_size="point"===t.chart_type?t.buffer/2:2*t.buffer/3;var e=r(t,"mg-y-rug");e.attr("x1",t.left+1).attr("x2",t.left+t.rug_buffer_size).attr("y1",t.scalefns.yf).attr("y2",t.scalefns.yf),m(e,t,"mg-y-rug-mono")}}function J(r){var t=r.yax_format;if(!t){var a=r.decimals;"count"===r.format?(1<r.processed.y_ticks.length&&(a=Math.max(0,-Math.floor(Math.log(Math.abs(r.processed.y_ticks[1]-r.processed.y_ticks[0]))/Math.LN10))),t=function(t){var e;return e=0!==a?E.format(",."+a+"f"):t<1e3?E.format(",.0f"):E.format(",.2s"),r.yax_units_append?e(t)+r.yax_units:r.yax_units+e(t)}):t=function(t){return E.format(".0%")(t)}}return t}function tt(t){var e=O(t.target),r=t.scales.X.domain();if(r[0]<=0&&0<=r[1]){var a=t.scales.Y.range(),n=t.categorical_groups.length?t.scales.YGROUP(t.categorical_groups[t.categorical_groups.length-1]):t.scales.YGROUP();e.append("svg:line").attr("x1",t.scales.X(0)).attr("x2",t.scales.X(0)).attr("y1",a[0]+b(t)).attr("y2",a[a.length-1]+n).attr("stroke","black").attr("opacity",.2)}}function et(t,e){e.y_label&&t.append("text").attr("class","label").attr("x",function(){return-1*(b(e)+(v(e)-b(e))/2)}).attr("y",function(){return e.left/2}).attr("dy","-1.2em").attr("text-anchor","middle").text(function(t){return e.y_label}).attr("transform",function(t){return"rotate(-90)"})}function rt(t){t.processed||(t.processed={});var e=O(t.target);if(MG.call_hook("y_axis.process_min_max",t,t.processed.min_y,t.processed.max_y),D(e,".mg-y-axis"),!t.y_axis)return this;var r,a,n,o,i,s,c,l,u,d=S(e,"mg-y-axis");return et(d,t),ke(t,"y"),r=d,i=(a=t).processed.y_ticks.length,a.x_extended_ticks||a.y_extended_ticks||!i||(a.axes_not_compact&&"bar"!==a.chart_type?(n=a.height-a.bottom,o=a.top):i?(n=a.scales.Y(a.processed.y_ticks[0]).toFixed(2),o=a.scales.Y(a.processed.y_ticks[i-1]).toFixed(2)):o=n=0,r.append("line").attr("x1",a.left).attr("x2",a.left).attr("y1",n).attr("y2",o)),s=t,d.selectAll(".mg-yax-ticks").data(s.processed.y_ticks).enter().append("line").classed("mg-extended-yax-ticks",s.y_extended_ticks).attr("x1",s.left).attr("x2",function(){return s.y_extended_ticks?s.width-s.right:s.left-s.yax_tick_length}).attr("y1",function(t){return s.scales.Y(t).toFixed(2)}).attr("y2",function(t){return s.scales.Y(t).toFixed(2)}),c=d,u=J(l=t),c.selectAll(".mg-yax-labels").data(l.processed.y_ticks).enter().append("text").attr("x",l.left-3*l.yax_tick_length/2).attr("dx",-3).attr("y",function(t){return l.scales.Y(t).toFixed(2)}).attr("dy",".35em").attr("text-anchor","end").text(function(t){return u(t)}),t.y_rug&&K(t),this}function at(o){var t=O(o.target);D(t,".mg-y-axis");var i,s=S(t,"mg-y-axis");(o.categorical_groups.length?o.categorical_groups:["1"]).forEach(function(t){var e,r,a,n;(i=S(s,"mg-group-"+F(t)),null!==o.ygroup_accessor)?(a=t,n=o,i.append("svg:text").classed("mg-barplot-group-label",!0).attr("x",n.left-n.buffer).attr("y",n.scales.YGROUP(a)+n.scales.YGROUP.bandwidth()/2).attr("dy",".35em").attr("text-anchor","end").text(a)):l((e=t,r=o,i.selectAll("text").data(r.scales.Y.domain()).enter().append("svg:text").attr("x",r.left-r.buffer).attr("y",function(t){return r.scales.YGROUP(e)+r.scales.Y(t)+r.scales.Y.bandwidth()/2}).attr("dy",".35em").attr("text-anchor","end").text(String)),o.rotate_y_labels)})}function nt(t){if(t.x_rug){t.rug_buffer_size="point"===t.chart_type?t.buffer/2:t.buffer;var e=r(t,"mg-x-rug");e.attr("x1",t.scalefns.xf).attr("x2",t.scalefns.xf).attr("y1",t.height-t.bottom-t.rug_buffer_size).attr("y2",t.height-t.bottom),m(e,t,"mg-x-rug-mono")}}function ot(t){var e,r,a,n=O(t.target);if((e=t).processed||(e.processed={}),a=(r=t).chart_type,r.processed.xax_format||(r.xax_format?r.processed.xax_format=r.xax_format:"line"===a||"point"===a||"histogram"===a?r.processed.xax_format=ht(r):"bar"===a&&(r.processed.xax_format=ct(r))),D(n,".mg-x-axis"),!t.x_axis)return this;var o,i,s,c,l,u,d,f,p,_,m=S(n,"mg-x-axis");return o=m,ke(i=t,"x"),l=o,u=(c=i).scales.X.ticks(c.xax_count).length-1,c.x_extended_ticks||l.append("line").attr("x1",function(){return 0===c.xax_count?Y(c):c.axes_not_compact&&"bar"!==c.chart_type?c.left:c.scales.X(c.scales.X.ticks(c.xax_count)[0]).toFixed(2)}).attr("x2",function(){return 0===c.xax_count||c.axes_not_compact&&"bar"!==c.chart_type?A(c):c.scales.X(c.scales.X.ticks(c.xax_count)[u]).toFixed(2)}).attr("y1",c.height-c.bottom).attr("y2",c.height-c.bottom),s=i,o.selectAll(".mg-xax-ticks").data(s.processed.x_ticks).enter().append("line").attr("x1",function(t){return s.scales.X(t).toFixed(2)}).attr("x2",function(t){return s.scales.X(t).toFixed(2)}).attr("y1",s.height-s.bottom).attr("y2",function(){return s.x_extended_ticks?s.top:s.height-s.bottom+s.xax_tick_length}).attr("class",function(){if(s.x_extended_ticks)return"mg-extended-xax-ticks"}).classed("mg-xax-ticks",!0),function(a,t){var e=t.selectAll(".mg-xax-labels").data(a.processed.x_ticks).enter().append("text").attr("x",function(t){return a.scales.X(t).toFixed(2)}).attr("y",(a.height-a.bottom+7*a.xax_tick_length/3).toFixed(2)).attr("dy",".50em").attr("text-anchor","middle");if(a.time_series&&a.european_clock?(e.append("tspan").classed("mg-european-hours",!0).text(function(t,e){var r=new Date(t);return 0===e?E.timeFormat("%H")(r):""}),e.append("tspan").classed("mg-european-minutes-seconds",!0).text(function(t,e){var r=new Date(t);return":"+a.processed.xax_format(r)})):e.text(function(t){return a.xax_units+a.processed.xax_format(t)}),g(e)){e.filter(function(t,e){return(e+1)%2==0}).remove();var r=O(a.target);r.selectAll(".mg-xax-ticks").filter(function(t,e){return(e+1)%2==0}).remove()}}(f=t,d=m),_=d,(p=f).time_series&&(p.show_years||p.show_secondary_x_label)&&function(t,e){var r=xt(t),a=r.secondary(t.processed.min_x,t.processed.max_x);if(0===a.length){var n=t.scales.X.ticks(t.xax_count)[0];a=[n]}var o,i,s,c,l,u,d,f=S(e,"mg-year-marker");"default"===r.timeframe&&t.show_year_markers&&(o=t,i=f,s=a,r.yformat,i.selectAll(".mg-year-marker").data(s).enter().append("line").attr("x1",function(t){return o.scales.X(t).toFixed(2)}).attr("x2",function(t){return o.scales.X(t).toFixed(2)}).attr("y1",M(o)).attr("y2",w(o))),"years"!=r.tick_diff_time_frame&&(c=t,l=f,u=a,d=r.yformat,l.selectAll(".mg-year-marker").data(u).enter().append("text").attr("x",function(t,e){return c.scales.X(t).toFixed(2)}).attr("y",function(){var t=E.select(c.target).select(".mg-x-axis text").node().getBoundingClientRect();return w(c)+7*c.xax_tick_length/3+.8*t.height}).attr("dy",".50em").attr("text-anchor","middle").text(function(t){return d(new Date(t))}))}(p,_),t.x_label&&st(m,t),t.x_rug&&nt(t),this}function B(e){var t;return null===e.color_domain?"number"===e.color_type?t=E.extent(e.data[0],function(t){return t[e.color_accessor]}):"category"===e.color_type&&(t=E.set(e.data[0].map(function(t){return t[e.color_accessor]})).values()).sort():t=e.color_domain,t}function I(t){return null===t.color_range?"number"===t.color_type?["blue","red"]:null:t.color_range}function it(t){return null===t.size_range?[1,5]:t.size_range}function st(t,e){e.x_label&&t.append("text").attr("class","label").attr("x",function(){return Y(e)+(P(e)-Y(e))/2}).attr("dx",null!=e.x_label_nudge_x?e.x_label_nudge_x:0).attr("y",function(){var t=E.select(e.target).select(".mg-x-axis text").node().getBoundingClientRect();return w(e)+e.xax_tick_length*(7/3)+.8*t.height+10}).attr("dy",".5em").attr("text-anchor","middle").text(function(t){return e.x_label})}function ct(r){return function(t){if(t<1&&-1<t&&0!==t)return r.xax_units+t.toFixed(r.decimals);var e=E.format(",.0f");return r.xax_units+e(t)}}function lt(t){var e;return ut(t)?e="millis":dt(t)?e="seconds":ft(t)?e="less-than-a-day":pt(t)?e="four-days":_t(t)?e="many-days":mt(t)?e="many-months":e=365<=t/86400?"years":"default",e}function ut(t){return t<1}function dt(t){return t<60}function ft(t){return t/3600<24}function pt(t){return t/3600<96}function _t(t){return t/86400<60}function mt(t){return t/86400<365}function gt(t){if(t.time_series){var e=(t.processed.max_x-t.processed.min_x)/1e3,r=(t.processed.x_ticks[1]-t.processed.x_ticks[0])/1e3;t.processed.x_time_frame=lt(e),t.processed.x_tick_diff_time_frame=lt(r),t.processed.main_x_time_format=(a=t.utc_time,ut(n=r)?MG.time_format(a,"%M:%S.%L"):dt(n)?MG.time_format(a,"%M:%S"):ft(n)?MG.time_format(a,"%H:%M"):pt(n)||_t(n)?MG.time_format(a,"%b %d"):mt(n)?MG.time_format(a,"%b"):MG.time_format(a,"%Y"))}var a,n}function ht(r){if(r.xax_format)return r.xax_format;var t=h(r.processed.original_data||r.data)[0],a=t[r.processed.original_x_accessor||r.x_accessor];return void 0===a&&(a=t),function(t){return gt(r),x(a)?r.processed.main_x_time_format(new Date(t)):"number"==typeof a?(e=t%1!=0?E.format(",."+r.decimals+"f"):t<1e3?E.format(",.0f"):E.format(",.2s"),r.xax_units+e(t)):r.xax_units+t;var e}}function xt(t){var e={timeframe:t.processed.x_time_frame,tick_diff_timeframe:t.processed.x_tick_diff_time_frame};switch(e.timeframe){case"millis":case"seconds":e.secondary=E.timeDays,t.european_clock?e.yformat=MG.time_format(t.utc_time,"%b %d"):e.yformat=MG.time_format(t.utc_time,"%I %p");break;case"less-than-a-day":case"four-days":e.secondary=E.timeDays,e.yformat=MG.time_format(t.utc_time,"%b %d");break;case"many-days":case"many-months":e.secondary=E.timeYears,e.yformat=MG.time_format(t.utc_time,"%Y");break;default:e.secondary=E.timeYears,e.yformat=MG.time_format(t.utc_time,"%Y")}return e}function yt(t){var e=parseInt(t.width);t.full_width&&(e=f(t.target)),"categorical"===t.x_axis_type&&null===e&&(e=Dt(t,"x")),t.width=e}function vt(t){var e=parseInt(t.height);t.full_height&&(e=d(t.target,"height")),"categorical"===t.y_axis_type&&null===e&&(e=Dt(t,"y")),t.height=e}function bt(t,e){(!t.selectAll(".mg-main-line").empty()&&"line"!==e.chart_type||!t.selectAll(".mg-points").empty()&&"point"!==e.chart_type||!t.selectAll(".mg-histogram").empty()&&"histogram"!==e.chart_type||!t.selectAll(".mg-barplot").empty()&&"bar"!==e.chart_type)&&t.remove()}function wt(t,e){return O(e.target).empty()&&(t=E.select(e.target).append("svg").classed("linked",e.linked).attr("width",e.width).attr("height",e.height)),t}function kt(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 Mt(t,e){t.attr("viewBox","0 0 "+e.width+" "+e.height),(e.full_width||e.full_height)&&t.attr("preserveAspectRatio","xMinYMin meet")}function Gt(t,e){t.empty()&&console.warn('The specified target element "'+e.target+'" could not be found in the page. The chart will not be rendered.')}function At(t,e){var r,a,n,o="x"===e?t.width:t.height;!function(t,e){var r=t[e+"group_accessor"];if(t.categorical_groups=[],r){var a=t.data[0];t.categorical_groups=E.set(a.map(function(t){return t[r]})).values()}}(t,e),function(t,e){var r=t[e+"group_accessor"];if(t.total_bars=t.data[0].length,r){var a=(n=t.data[0],o=r,n.map(function(t){return t[o]}).reduce(function(t,e){return t[e]=t[e]+1||1,t},{}));a=E.max(Object.keys(a).map(function(t){return a[t]})),t.bars_per_group=a}else t.bars_per_group=t.data[0].length;var n,o}(t,e),function(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}}(t,e,o),o&&(n=(r=t)[(a=e)+"group_height"]/(r.bars_per_group+r[a+"_outer_padding_percentage"]),r.bar_thickness=n-n*r[a+"_padding_percentage"])}function Dt(t,e){return t[e+"group_height"]*(t.categorical_groups.length||1)+("y"===e?t.top+t.bottom+2*t.buffer:t.left+t.right+2*t.buffer)+t.categorical_groups.length*t[e+"group_height"]*(t[e+"group_padding_percentage"]+t[e+"group_outer_padding_percentage"])}function Ot(t){var e;(e=t=t)||(e={}),e.processed||(e.processed={}),t=e=p(e,{target:null,title:null,description:null});var r=E.select(t.target);Gt(r,t);var a,n,o,i,s,c,l,u=r.selectAll("svg");return"categorical"===t.y_axis_type&&At(t,"y"),"categorical"===t.x_axis_type&&At(t,"x"),n=(a=t).chart_type,a.processed.xax_format||(a.xax_format?a.processed.xax_format=a.xax_format:"line"===n||"point"===n||"histogram"===n?a.processed.xax_format=ht(a):"bar"===n&&(a.processed.xax_format=ct(a))),i=h((o=t).processed.original_data||o.data)[0],o.time_series=x(i[o.processed.original_x_accessor||o.x_accessor]),yt(t),vt(t),bt(u,t),u=wt(u,t),c=t,(s=u).selectAll(".mg-clip-path").remove(),s.append("defs").attr("class","mg-clip-path").append("clipPath").attr("id","mg-plot-window-"+z(c.target)).append("svg:rect").attr("x",G(c)).attr("y",M(c)).attr("width",c.width-c.left-c.right-c.buffer).attr("height",c.height-c.top-c.bottom-c.buffer+1),kt(u,t),Mt(u,t),(l=u).classed("mg-missing",!1),l.selectAll(".mg-missing-text").remove(),l.selectAll(".mg-missing-pane").remove(),j(t),function(t,e){var r=0;if(t.selectAll(".mg-main-line").nodes().length>=e.data.length)if(0<e.custom_line_color_map.length){var a=T(function(t){for(var e=new Array(t),r=0;r<e.length;r++)e[r]=r+1;return e}(e.max_data_size),e.custom_line_color_map);for(r=0;r<a.length;r++)t.selectAll(".mg-main-line.mg-line"+a[r]+"-color").remove()}else{var n=e.data.length;for(r=t.selectAll(".mg-main-line").nodes()?t.selectAll(".mg-main-line").nodes().length:0;n<r;r--)t.selectAll(".mg-main-line.mg-line"+r+"-color").remove()}}(u,t),this}function zt(t){return t.label}function Ft(e){return function(t){return e.scales.X(t[e.x_accessor])>=Y(e)&&e.scales.X(t[e.x_accessor])<=P(e)}}function Ct(e){return function(t){return e.scales.X(t[e.x_accessor])}}function Tt(t){var e=t.scales.Y;return function(t){return e(t.value).toFixed(2)}}function Rt(t,e,r,a,n,o){var i;t&&(n(i=a.append("g").attr("class",e),r),o(i,r))}function Et(t,e){var r,a=(r=Ct(e),function(t){return r(t).toFixed(2)});t.selectAll(".mg-markers").data(e.markers.filter(Ft(e))).enter().append("line").attr("x1",a).attr("x2",a).attr("y1",e.top).attr("y2",v(e)).attr("class",function(t){return t.lineclass}).attr("stroke-dasharray","3,1")}function Yt(t,e){t.selectAll(".mg-markers").data(e.markers.filter(Ft(e))).enter().append("text").attr("class",function(t){return t.textclass||""}).classed("mg-marker-text",!0).attr("x",Ct(e)).attr("y","bottom"===e.x_axis_position?.95*M(e):w(e)+e.buffer).attr("text-anchor","middle").text(zt).each(function(t){t.click&&E.select(this).style("cursor","pointer").on("click",t.click),t.mouseover&&E.select(this).style("cursor","pointer").on("mouseover",t.mouseover),t.mouseout&&E.select(this).style("cursor","pointer").on("mouseout",t.mouseout)}),function(t,e){if(t&&1!=t.length)for(var r=0;r<t.length;r++)if(o(t[r],t)){var a=E.select(t[r]),n=+a.attr("y");n+8>=e.top&&(n=e.top-16),a.attr("y",n)}}(t.selectAll(".mg-marker-text").nodes(),e)}function $t(t,e){var r=Tt(e);t.selectAll(".mg-baselines").data(e.baselines).enter().append("line").attr("x1",Y(e)).attr("x2",P(e)).attr("y1",r).attr("y2",r)}function Pt(t,e){var r=Tt(e);t.selectAll(".mg-baselines").data(e.baselines).enter().append("text").attr("x",P(e)).attr("y",r).attr("dy",-3).attr("text-anchor","end").text(zt)}function St(t){var e,r,a,n,o,i=O(t.target);return(e=i).selectAll(".mg-markers").remove(),e.selectAll(".mg-baselines").remove(),a=i,Rt((r=t).markers,"mg-markers",r,a,Et,Yt),o=i,Rt((n=t).baselines,"mg-baselines",n,o,$t,Pt),this}function Lt(t){t.selectAll(".mg-active-datapoint-container").selectAll("*").remove()}function jt(t,e){t.select(".mg-active-datapoint").remove();var r,a="right"===e.mouseover_align?"end":"left"===e.mouseover_align?"start":"middle",n="right"===e.mouseover_align?P(e):"left"===e.mouseover_align?Y(e):(e.width-e.left-e.right)/2+e.left,o=t.select(".mg-active-datapoint-container").append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("text-anchor",a),i=.75,s="bottom"===e.x_axis_position?M(e)*i:w(e)+3*e.buffer;e.markers&&t.selectAll(".mg-marker-text").each(function(){r?r!==E.select(this).attr("y")&&(i=.56):r=E.select(this).attr("y")});o.attr("transform","translate("+n+","+s+")")}function Xt(t,e){jt(e.svg,t);var r,a,o={row_number:0,rargs:e,mouseover_row:function(t){return o.row_number+=1,e=o.row_number,r=o.text_container,a=t,n=r.append("tspan").attr("x",0).attr("y",1.1*e+"em"),{rargs:a,text:function(t){return e=t,{bold:function(){return r.attr("font-weight","bold")},font_size:function(t){return r.attr("font-size",t)},x:function(t){return r.attr("x",t)},y:function(t){return r.attr("y",t)},elem:r=n.append("tspan").text(e)};var e,r}};var e,r,a,n},text_container:(r=e.svg,a=r.select(".mg-active-datapoint"),a.selectAll("*").remove(),a)};return o}Z.categorical=function(t,e){e.namespace;Q(t,e),function(d,t){var f,p,_,m,e=t.namespace,g=(d.scalefns[e+"f"],d.scalefns[e+"groupf"],d.scales[(e+"group").toUpperCase()]),h=d.scales[e.toUpperCase()],x=t.position,r=O(d.target),a=g.domain&&g.domain()?g.domain():[null];D(r,".mg-category-guides");var y=S(r,"mg-category-guides");a.forEach(function(e){h.domain().forEach(function(t){"left"!==x&&"right"!==x||(f=Y(d),p=P(d),_=h(t)+g(e)+h.bandwidth()/2,m=h(t)+g(e)+h.bandwidth()/2),"top"!==x&&"bottom"!==x||(f=h(t)+g(e)+h.bandwidth()/2*(null===e),p=h(t)+g(e)+h.bandwidth()/2*(null===e),_=v(d),m=b(d)),y.append("line").attr("x1",f).attr("x2",p).attr("y1",_).attr("y2",m).attr("stroke-dasharray","2,1")});var t,r,a,n,o,i,s,c,l=g(e)+h(h.domain()[0])+h.bandwidth()/2*(null===e||"top"!==x&&"bottom"!=x),u=g(e)+h(h.domain()[h.domain().length-1])+h.bandwidth()/2*(null===e||"top"!==x&&"bottom"!=x);"left"!==x&&"right"!==x||(t=Y(d),r=Y(d),a=l,n=u,o=P(d),i=P(d),s=l,c=u),"bottom"!==x&&"top"!==x||(t=l,r=u,a=v(d),n=v(d),o=l,i=u,s=b(d),c=b(d)),y.append("line").attr("x1",t).attr("x2",r).attr("y1",a).attr("y2",n).attr("stroke-dasharray","2,1"),y.append("line").attr("x1",o).attr("x2",i).attr("y1",s).attr("y2",c).attr("stroke-dasharray","2,1")})}(t,e)},Z.numerical=function(t,e){var r=e.namespace,a=r+"_axis",n="mg-"+r+"-axis",o=O(t.target);if(D(o,"."+n),!t[a])return this;var i,s,c,l,u,d,f,p,_,m,g,h,x,y,v,b=S(o,n);return function(t,e){var r=t[e+"_accessor"],a=t.scales[e.toUpperCase()].ticks(t[e+"ax_count"]),n=t.processed["max_"+e];function o(t){return 1e3===t?3:1e6===t?7:Math.log(t)/Math.LN10}"log"===t[e+"_scale_type"]&&(a=a.filter(function(t){return Math.abs(o(t))%1<1e-6||Math.abs(o(t))%1>1-1e-6}));var i=a.length,s=!0;t.data.forEach(function(t,e){t.forEach(function(t,e){if(t[r]%1!=0)return s=!1})}),s&&n<i&&"count"===t.format&&(a=a.filter(function(t){return t%1==0})),t.processed[e+"_ticks"]=a}(t,r),V(b,t,e),i=b,s=t,p=(c=e).namespace,_=c.position,m=s.scales[p.toUpperCase()],g=s.processed[p+"_ticks"],h="mg-"+p+"ax-ticks",x="mg-extended-"+p+"ax-ticks",y=s[p+"_extended_ticks"],v=s[p+"ax_tick_length"],"left"===_&&(l=G(s),u=y?A(s):G(s)-v,d=function(t){return m(t).toFixed(2)},f=function(t){return m(t).toFixed(2)}),"right"===_&&(l=A(s),u=y?G(s):A(s)+v,d=function(t){return m(t).toFixed(2)},f=function(t){return m(t).toFixed(2)}),"top"===_&&(l=function(t){return m(t).toFixed(2)},u=function(t){return m(t).toFixed(2)},d=M(s),f=y?w(s):M(s)-v),"bottom"===_&&(l=function(t){return m(t).toFixed(2)},u=function(t){return m(t).toFixed(2)},d=w(s),f=y?M(s):w(s)+v),i.selectAll("."+h).data(g).enter().append("line").classed(x,y).attr("x1",l).attr("x2",u).attr("y1",d).attr("y2",f),q(b,t,e),t[r+"_label"]&&e.label(o.select(".mg-"+r+"-axis"),t),t[r+"_rug"]&&W(t,e),t.show_bar_zero&&tt(t),this},MG.axis_factory=function(t){var e={type:"numerical"};return this.namespace=function(t){return e.namespace=t,this},this.rug=function(t){return e.rug=t,this},this.label=function(t){return e.label=t,this},this.type=function(t){return e.type=t,this},this.position=function(t){return e.position=t,this},this.zeroLine=function(t){return e.zeroLine=t,this},this.draw=function(){return Z[e.type](t,e),this},this},MG.y_rug=K,MG.y_axis=rt,MG.y_axis_categorical=function(t){return t.y_axis&&(at(t),t.show_bar_zero&&tt(t),t.ygroup_accessor&&(r=O((e=t).target),(a=e.scales.YGROUP.domain())[0],a[a.length-1],r.select(".mg-category-guides").selectAll("mg-group-lines").data(a).enter().append("line").attr("x1",Y(e)).attr("x2",Y(e)).attr("y1",function(t){return e.scales.YGROUP(t)}).attr("y2",function(t){return e.scales.YGROUP(t)+e.ygroup_height}).attr("stroke-width",1)),t.y_categorical_show_guides&&(o=O((n=t).target),i=[],n.data[0].forEach(function(t){-1===i.indexOf(t[n.y_accessor])&&o.select(".mg-category-guides").append("line").attr("x1",Y(n)).attr("x2",P(n)).attr("y1",n.scalefns.yf(t)+n.scalefns.ygroupf(t)).attr("y2",n.scalefns.yf(t)+n.scalefns.ygroupf(t)).attr("stroke-dasharray","2,1")}))),this;var e,r,a,n,o,i},MG.x_rug=nt,MG.x_axis=ot,MG.x_axis_categorical=function(t){var e=O(t.target),r=0;"bar"===t.chart_type&&(r=t.buffer+5),mg_add_categorical_scale(t,"X",t.categorical_variables.reverse(),t.left,P(t)-r),X(t,"xf","X","value"),D(e,".mg-x-axis");var a=S(e,"mg-x-axis");return t.x_axis&&(n=a,o=t,i=r,s=n.selectAll("text").data(o.categorical_variables).enter().append("text"),s.attr("x",function(t){return o.scales.X(t)+o.scales.X.bandwidth()/2+o.buffer*o.bar_outer_padding_percentage+i/2}).attr("y",v(o)).attr("dy",".35em").attr("text-anchor","middle").text(String),o.truncate_x_labels&&s.each(function(t,e){var r=o.scales.X.bandwidth();L(this,t,r)}),l(s,o.rotate_x_labels)),this;var n,o,i,s},MG.init=Ot,MG.markers=St;var Ut=function(n,o){return function(a){return["x","y"].every(function(t){return!(t in o)||(e=a[n[t+"_accessor"]],r=o[t],e>Math.min(r[0],r[1])&&e<Math.max(r[0],r[1]));var e,r})}},Nt=function(e,r){var t=e.processed.raw_data||e.data;"raw_data"in e.processed||(e.processed.raw_domain={x:e.scales.X.domain(),y:e.scales.Y.domain()},e.processed.raw_data=t),"point"===e.chart_type&&(a(t)?e.data=t.map(function(t){return t.filter(Ut(e,r))}):e.data=t.filter(Ut(e,r))),["x","y"].forEach(function(t){t in r?e.processed["zoom_"+t]=r[t]:delete e.processed["zoom_"+t]}),e.processed.subplot&&(r!==e.processed.raw_domain?MG.create_brushing_pattern(e.processed.subplot,It(e.processed.subplot,r)):MG.remove_brushing_pattern(e.processed.subplot)),new MG.charts[e.chart_type||defaults.chart_type].descriptor(e)},Bt=function(r,a){return["x","y"].reduce(function(t,e){return e in a&&(t[e]=a[e].map(function(t){return+r.scales[e.toUpperCase()].invert(t)}),"y"===e&&t[e].reverse()),t},{})},It=function(r,a){return["x","y"].reduce(function(t,e){return e in a&&(t[e]=a[e].map(function(t){return+r.scales[e.toUpperCase()](t)}),"y"===e&&t[e].reverse()),t},{})};MG.convert_range_to_domain=Bt,MG.zoom_to_data_domain=Nt,MG.zoom_to_data_range=function(t,e){var r=Bt(t,e);Nt(t,r)},MG.zoom_to_raw_range=function(t){"raw_domain"in t.processed&&(Nt(t,t.processed.raw_domain),delete t.processed.raw_domain,delete t.processed.raw_data)};var Ht=function(t){return E.select(t.target).select(".mg-extent").size()?E.select(t.target).select(".mg-extent"):E.select(t.target).select(".mg-rollover-rect, .mg-voronoi").insert("g","*").classed("mg-brush",!0).append("rect").classed("mg-extent",!0)},qt=function(t,e){var r=e.x[0],a=e.x[1]-e.x[0],n=e.y[0],o=e.y[1]-e.y[0];Ht(t).attr("x",r).attr("width",a).attr("y",n).attr("height",o).attr("opacity",1)},Vt=function(t){Ht(t).attr("width",0).attr("height",0).attr("opacity",0)};MG.add_brush_function=function(t){if("categorical"===t.x_axis_type||"categorical"===t.y_axis_type)return console.warn('The option "brush" does not support axis type "categorical" currently.');t.zoom_target||(t.zoom_target=t),t.zoom_target!==t&&(t.zoom_target.processed.subplot=t);var i,r,s,a,e,c,n,o,l,u,d=void 0;switch(t.brush){case"x":d={x:!0,y:!1};break;case"y":d={x:!1,y:!0};break;case"xy":d={x:!0,y:!0};break;default:d={x:!0,y:!0}}r=(i=t).zoom_target,s=d,a=E.select(i.target).select("svg"),e=a.select(".mg-rollover-rect, .mg-voronoi"),c=e.node(),o=n=!1,l=[],u=function(){var t=i.left,e=i.width-i.right-i.buffer,r=i.top,a=i.height-i.bottom-i.buffer,n=E.mouse(c),o={};return o.x=s.x?[Math.max(t,Math.min(l[0],n[0])),Math.min(e,Math.max(l[0],n[0]))]:[t,e],o.y=s.y?[Math.max(r,Math.min(l[1],n[1])),Math.min(a,Math.max(l[1],n[1]))]:[r,a],o},e.classed("mg-brush-container",!0),e.on("mousedown."+i.target,function(){n=!(o=!0),l=E.mouse(c),a.classed("mg-brushed",!1),a.classed("mg-brushing-in-progress",!0),Vt(i)}),E.select(document).on("mousemove."+i.target,function(){o&&(n=!0,e.classed("mg-brushing",!0),qt(i,u()))}),E.select(document).on("mouseup."+i.target,function(){if(o){o=!1,a.classed("mg-brushing-in-progress",!1);var t=u();if(n)if(n=!1,r===i)MG.zoom_to_data_range(r,t),a.select(".mg-rollover-rect, .mg-voronoi").classed("mg-brushed",!0);else{var e=MG.convert_range_to_domain(i,t);MG.zoom_to_data_domain(r,e)}else MG.zoom_to_raw_range(r);C(i.brushing_selection_changed)&&i.brushing_selection_changed(i,t)}})},MG.create_brushing_pattern=qt,MG.remove_brushing_pattern=Vt;var Wt=new function(){var t,i=[];function s(){i.forEach(function(t){var e=E.select(t).select("svg");if(!e.empty()&&(0<e.node().parentNode.offsetWidth||0<e.node().parentNode.offsetHeight)){var r=0!==e.attr("width")?e.attr("height")/e.attr("width"):0,a=f(t);e.attr("width",a),e.attr("height",r*a)}})}return"undefined"!=typeof MutationObserver?t=MutationObserver:"undefined"!=typeof WebKitMutationObserver&&(t=WebKitMutationObserver),{add_target:function(n){if(0===i.length&&window.addEventListener("resize",s,!0),-1===i.indexOf(n)&&(i.push(n),t)){var o=new t(function(t){var e,r,a=E.select(n).node();a&&!t.some(function(t){for(var e=0;e<t.removedNodes.length;e++)if(t.removedNodes[e]===a)return!0})||(o.disconnect(),e=n,-1!==(r=i.indexOf(e))&&i.splice(r,1),0===i.length&&window.removeEventListener("resize",s,!0))});o.observe(E.select(n).node().parentNode,{childList:!0})}}}};function Qt(t){var e;((e=t).full_width||e.full_height)&&Wt.add_target(e.target)}k()&&function(s){if("function"==typeof s().dropdown)return;var c='[data-toggle="dropdown"]',a=function(t){s(t).on("click.bs.dropdown",this.toggle)};function o(a){a&&3===a.which||(s(".dropdown-backdrop").remove(),s(c).each(function(){var t=s(this),e=l(t),r={relatedTarget:this};e.hasClass("open")&&(e.trigger(a=s.Event("hide.bs.dropdown",r)),a.isDefaultPrevented()||(t.attr("aria-expanded","false"),e.removeClass("open").trigger("hidden.bs.dropdown",r)))}))}function l(t){var e=t.attr("data-target");e||(e=(e=t.attr("href"))&&/#[A-Za-z]/.test(e)&&e.replace(/.*(?=#[^\s]*$)/,""));var r=e&&s(e);return r&&r.length?r:t.parent()}a.VERSION="3.3.1",a.prototype.toggle=function(t){var e=s(this);if(!e.is(".disabled, :disabled")){var r=l(e),a=r.hasClass("open");if(o(),!a){"ontouchstart"in document.documentElement&&!r.closest(".navbar-nav").length&&s('<div class="dropdown-backdrop"/>').insertAfter(s(this)).on("click",o);var n={relatedTarget:this};if(r.trigger(t=s.Event("show.bs.dropdown",n)),t.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),r.toggleClass("open").trigger("shown.bs.dropdown",n)}return!1}},a.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var e=s(this);if(t.preventDefault(),t.stopPropagation(),!e.is(".disabled, :disabled")){var r=l(e),a=r.hasClass("open");if(!a&&27!=t.which||a&&27==t.which)return 27==t.which&&r.find(c).trigger("focus"),e.trigger("click");var n=" li:not(.divider):visible a",o=r.find('[role="menu"]'+n+', [role="listbox"]'+n);if(o.length){var i=o.index(t.target);38==t.which&&0<i&&i--,40==t.which&&i<o.length-1&&i++,~i||(i=0),o.eq(i).trigger("focus")}}}};var t=s.fn.dropdown;s.fn.dropdown=function(r){return this.each(function(){var t=s(this),e=t.data("bs.dropdown");e||t.data("bs.dropdown",e=new a(this)),"string"==typeof r&&e[r].call(t)})},s.fn.dropdown.Constructor=a,s.fn.dropdown.noConflict=function(){return s.fn.dropdown=t,this},s(document).on("click.bs.dropdown.data-api",o).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",c,a.prototype.toggle).on("keydown.bs.dropdown.data-api",c,a.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="menu"]',a.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="listbox"]',a.prototype.keydown)}(jQuery),MG.button_layout=function(t){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){return t.replace(/[^a-zA-Z0-9 _]+/g,"").replace(/ +?/g,"")},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 1<arguments.length&&(this.public_name[t]=arguments[1]),2<arguments.length&&(this.sorters[t]=arguments[2]),this.feature_set[t]=[],this},this.callback=function(t){return this._callback=t,this},this.display=function(){var e,t,r,a,n=this._callback,o=this.manual_callback,i=this.manual_map;r=Object.keys(this.feature_set);var s,c=function(t){return e[t]};for(s=0;s<this._data.length;s++){e=this._data[s],t=r.map(c);for(var l=0;l<r.length;l++)a=r[l],-1===this.feature_set[a].indexOf(t[l])&&this.feature_set[a].push(t[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 d in this.feature_set){for(r=this.feature_set[d],$(this.target+" div.segments").append('<div class="btn-group '+this._strip_punctuation(d)+'-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(d)?this.public_name[d]:d)+"</span><span class='title'>"+(this.manual_callback.hasOwnProperty(d)?this.feature_set[d][0]:"all")+'</span><span class="caret"></span></button><ul class="dropdown-menu" role="menu">'+(this.manual_callback.hasOwnProperty(d)?"":'<li><a href="#" data-feature="'+d+'" data-key="all">All</a></li>')+(this.manual_callback.hasOwnProperty(d)?"":'<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(d)+"-btns ul.dropdown-menu").append('<li><a href="#" data-feature="'+this._strip_punctuation(d)+'" data-key="'+r[s]+'">'+r[s]+"</a></li>");$("."+this._strip_punctuation(d)+"-btns .dropdown-menu li a").on("click",u)}return this},this};var Zt=function(t,e,r){var a=e.line_id,n=r.color,o=r.colors;t.classed("mg-hover-line-color",null===n).classed("mg-hover-line"+a+"-color",null===o).attr("fill",null===o?"":o[a-1])},Kt=function(r,t,e){t.existing_band=e.selectAll(".mg-confidence-band").nodes(),r.show_confidence_band&&(t.confidence_area=E.area().defined(t.line.defined()).x(r.scalefns.xf).y0(function(t){var e=r.show_confidence_band[0];return null!=t[e]?r.scales.Y(t[e]):r.scales.Y(t[r.y_accessor])}).y1(function(t){var e=r.show_confidence_band[1];return null!=t[e]?r.scales.Y(t[e]):r.scales.Y(t[r.y_accessor])}).curve(r.interpolate))},Jt=function(t,e){var r=t.scalefns,a=t.scales,n=t.interpolate,o=t.flip_area_under_y_value,i=Number.isFinite(o)?a.Y(o):a.Y.range()[0];e.area=E.area().defined(e.line.defined()).x(r.xf).y0(function(){return i}).y1(r.yf).curve(n)},te=function(t,e){var r=t.y_accessor,a=t.scalefns,n=t.scales,o=t.interpolate;e.flat_line=E.line().defined(function(t){return(void 0===t._missing||!0!==t._missing)&&null!==t[r]}).x(a.xf).y(function(){return n.Y(e.data_median)}).curve(o)},ee=function(t,e){var r=t.scalefns,a=t.interpolate,n=t.missing_is_zero,o=t.y_accessor;e.line=E.line().x(r.xf).y(r.yf).curve(a),n||(e.line=e.line.defined(function(t){return(void 0===t._missing||!0!==t._missing)&&null!==t[o]}))},re=function(t,e,r,a){var n=t.show_confidence_band,o=t.transition_on_update,i=t.data,s=t.target;if(n){r.select(".mg-confidence-band-"+a).empty()&&r.append("path").attr("class","mg-confidence-band mg-confidence-band-"+a),r.select(".mg-confidence-band-"+a).transition().duration(function(){return o?1e3:0}).attr("d",e.confidence_area(i[a-1])).attr("clip-path","url(#mg-plot-window-"+z(s)+")")}},ae=function(t,e,r,a,n){var o=t.data,i=t.target,s=t.colors,c=r.selectAll(".mg-main-area.mg-area"+n);e.display_area?c.empty()?r.append("path").classed("mg-main-area",!0).classed("mg-area"+n,!0).classed("mg-area-color",null===s).classed("mg-area"+n+"-color",null===s).attr("d",e.area(o[a])).attr("fill",null===s?"":s[n-1]).attr("clip-path","url(#mg-plot-window-"+z(i)+")"):(r.node().appendChild(c.node()),c.transition().duration(e.update_transition_duration).attr("d",e.area(o[a])).attr("clip-path","url(#mg-plot-window-"+z(i)+")")):c.empty()||c.remove()},ne=function(t,e){t.classed("mg-line-color",!0).classed("mg-line"+e+"-color",!0)},oe=function(t,e,r,a,n,o){if(a.empty()){var i=r.append("path").attr("class","mg-main-line mg-line"+o);g=i,h=n,x=o,(y=t.colors)&&y.constructor===Array?(g.attr("stroke",y[h]),y.length<h+1&&ne(g,x)):ne(g,x),l=e,u=i,d=n,f=(c=t).animate_on_load,p=c.data,_=c.y_accessor,m=c.target,f?(l.data_median=E.median(p[d],function(t){return t[_]}),u.attr("d",l.flat_line(p[d])).transition().duration(1e3).attr("d",l.line(p[d])).attr("clip-path","url(#mg-plot-window-"+z(m)+")")):u.attr("d",l.line(p[d])).attr("clip-path","url(#mg-plot-window-"+z(m)+")")}else{r.node().appendChild(a.node());var s=a.transition().duration(e.update_transition_duration);e.display_area||!t.transition_on_update||t.missing_is_hidden?s.attr("d",e.line(t.data[n])):s.attrTween("d",je(e.line(t.data[n]),4))}var c,l,u,d,f,p,_,m,g,h,x,y},ie=function(t,e,r,a){var n,o=void 0;if(t.legend)if(u(t.legend)?o=t.legend[r]:(n=t.legend,"[object Function]"===Object.prototype.toString.call(n)&&(o=t.legend(t.data[r]))),t.legend_target)t.colors&&t.colors.constructor===Array?e.legend_text="<span style='color:"+t.colors[r]+"'>— "+o+" </span>"+e.legend_text:e.legend_text="<span class='mg-line"+a+"-legend-color'>— "+o+" </span>"+e.legend_text;else{var i=void 0,s=void 0,c=void 0;"left"===t.y_axis_position?(i=t.data[r][t.data[r].length-1],s="start",c=t.buffer):(i=t.data[r][0],s="end",c=-t.buffer);var l=e.legend_group.append("svg:text").attr("x",t.scalefns.xf(i)).attr("dx",c).attr("y",t.scalefns.yf(i)).attr("dy",".35em").attr("font-size",10).attr("text-anchor",s).attr("font-weight","300").text(o);t.colors&&t.colors.constructor===Array?t.colors.length<r+1?l.classed("mg-line"+a+"-legend-color",!0):l.attr("fill",t.colors[r]):l.classed("mg-line-legend-color",!0).classed("mg-line"+a+"-legend-color",!0),function(t,e){if(t&&1!=t.length){var r,a,n;t.sort(function(t,e){return E.select(e).attr("y")-E.select(t).attr("y")}),t.reverse();for(var o=0;o<t.length;o++){a=E.select(t[o]).text();for(var i=0;i<t.length;i++)if(n=E.select(t[i]).text(),!1!==(l=t[o],u=t[i],void 0,d=l.getBoundingClientRect(),f=u.getBoundingClientRect(),r=d.top<=f.bottom&&d.top>=f.top&&f.bottom-d.top)&&a!==n){var s=E.select(t[o]),c=+s.attr("y");c+=r,s.attr("y",c)}}}var l,u,d,f}(e.legend_group.selectAll(".mg-line-legend text").nodes())}},se=function(e,t,r,a,n,o){var i,s,c,l=E.voronoi().x(function(t){return e.scales.X(t[e.x_accessor]).toFixed(2)}).y(function(t){return e.scales.Y(t[e.y_accessor]).toFixed(2)}).extent([[e.buffer,e.buffer+(e.title?e.title_y_position:0)],[e.width-e.buffer,e.height-e.buffer]]);S(t,"mg-voronoi").selectAll("path").data(l.polygons((s=e,c=s.data,E.merge(c)))).enter().append("path").filter(function(t){return void 0!==t&&0<t.length}).attr("d",function(t){return null==t?null:"M"+t.join("L")+"Z"}).datum(function(t){return null==t?null:t.data}).attr("class",(i=e,function(t){var e=void 0;if(i.linked){var r=t[i.x_accessor],a=MG.time_format(i.utc_time,i.linked_format);return e="roll_"+("number"==typeof r?t.line_id-1:a(r))+" mg-line"+t.line_id,null===i.color&&(e+=" mg-line"+t.line_id+"-color"),e}return e="mg-line"+t.line_id,null===i.color&&(e+=" mg-line"+t.line_id+"-color"),e})).on("click",o).on("mouseover",r).on("mouseout",a).on("mousemove",n),le(e,t)},ce=function(a,t,e,r,n,o){var i,s,c,l,u,d=(s=(i=a).x_accessor,c=i.data,l=i.x_sort,(u=E.nest().key(function(t){return t[s]}).entries(E.merge(c))).forEach(function(t){var e=t.values[0];t.key=e[s]}),l?u.sort(function(t,e){return new Date(t.key)-new Date(e.key)}):u),f=d.map(function(t){var e=t.key;return a.scales.X(e)});t.append("g").attr("class","mg-rollover-rect").selectAll(".mg-rollover-rects").data(d).enter().append("rect").attr("x",function(t,e){return 1===f.length?Y(a):0===e?f[e].toFixed(2):((f[e-1]+f[e])/2).toFixed(2)}).attr("y",a.top).attr("width",function(t,e){return 1===f.length?P(a):0===e?((f[e+1]-f[e])/2).toFixed(2):e===f.length-1?((f[e]-f[e-1])/2).toFixed(2):((f[e+1]-f[e-1])/2).toFixed(2)}).attr("class",function(t){var e=t.values,r=e.map(function(t){var e=t.line_id,r=ue(e);return null===a.colors&&(r+=" "+de(e)),r}).join(" ");return a.linked&&0<e.length&&(r+=" "+fe(pe(e[0],a))),r}).attr("height",a.height-a.bottom-a.top-a.buffer).attr("opacity",0).on("click",o).on("mouseover",e).on("mouseout",r).on("mousemove",n),_e(a,t)},le=function(t,e){for(var r=t.data,a=t.custom_line_color_map,n=0;n<r.length;n++){var o=n+1;0<a.length&&void 0!==a[n]&&(o=a[n]),1!==r[n].length||e.selectAll(".mg-voronoi .mg-line"+o).empty()||(e.selectAll(".mg-voronoi .mg-line"+o).on("mouseover")(r[n][0],0),e.selectAll(".mg-voronoi .mg-line"+o).on("mouseout")(r[n][0],0))}},ue=function(t){return"mg-line"+t},de=function(t){return"mg-line"+t+"-color"},fe=function(t){return"roll_"+t},pe=function(t,e){var r=e.x_accessor,a=e.utc_time,n=e.linked_format,o=t[r],i=MG.time_format(a,n);return"number"==typeof o?o.toString().replace(".","_"):i(o)},_e=function(t,e){var r=t.data,a=e.selectAll(".mg-rollover-rect rect"),n=a.nodes()[0][0]||a.nodes()[0];0<r.filter(function(t){return 1===t.length}).length&&a.on("mouseover")(n.__data__,0)},me=function(t){var e=t.data;return 1===e.length&&1===e[0].length},ge=function(t,e){var r=t.existing_band;r[0]&&r[0].length>e.selectAll(".mg-main-line").node().length&&e.selectAll(".mg-confidence-band").remove()},he=function(t){var e,r,a,n,o,i,s,c={},l=O(t.target);D(l,".mg-line-legend"),e=c,r=l,t.legend&&(e.legend_group=S(r,"mg-line-legend")),c.data_median=0,c.update_transition_duration=t.transition_on_update?1e3:0,c.display_area=t.area&&!t.use_data_y_min&&t.data.length<=1&&!1===t.aggregate_rollover||Array.isArray(t.area)&&0<t.area.length,c.legend_text="",o=l,ee(a=t,n=c),Jt(a,n),te(a,n),Kt(a,n,o),c.existing_band=l.selectAll(".mg-confidence-band").nodes(),!1!==MG.call_hook("line.before_all_series",[t])&&function(e,t,r){ge(t,r),e.active_point_on_lines&&r.selectAll("circle.mg-shown-active-point").remove();for(var a=e.data.length-1;0<=a;a--){var n=e.data[a];MG.call_hook("line.before_each_series",[n,e]);var o=a+1;if(0<e.custom_line_color_map.length&&(o=e.custom_line_color_map[a]),e.data[a].line_id=o,e.active_point_on_lines&&r.selectAll("circle-"+o).data(e.data[a]).enter().filter(function(t){return t[e.active_point_accessor]}).append("circle").attr("class","mg-area"+o+"-color mg-shown-active-point").attr("cx",e.scalefns.xf).attr("cy",e.scalefns.yf).attr("r",function(){return e.active_point_size}),0!==n.length){var i=r.select("path.mg-main-line.mg-line"+o);re(e,t,r,o),Array.isArray(e.area)?e.area[o-1]&&ae(e,t,r,a,o):ae(e,t,r,a,o),oe(e,t,r,i,a,o),ie(e,t,a,o),MG.call_hook("line.after_each_series",[n,i,e])}}}(t,c,l),i=t.legend_target,s=c.legend_text,i&&E.select(i).html(s)},xe=function(t,e){var r,a,n,o,i,s,c,l,u,d,f,p,_=O(t.target);t.showActivePoint&&0===_.selectAll(".mg-active-datapoint-container").nodes().length&&S(_,"mg-active-datapoint-container"),D(r=_,".mg-rollover-rect"),D(r,".mg-voronoi"),D(r,".mg-active-datapoint"),D(r,".mg-line-rollover-circle"),n=_,o=(a=t).data,i=a.colors,s=n.selectAll(".mg-line-rollover-circle").data(o).enter().append("circle").attr("cx",0).attr("cy",0).attr("r",0),i&&i.constructor===Array?s.attr("class",function(t){return"mg-line"+t.line_id}).attr("fill",function(t,e){return i[e]}).attr("stroke",function(t,e){return i[e]}):s.attr("class",function(t,e){var r=t.line_id;return["mg-line"+r,"mg-line"+r+"-color","mg-area"+r+"-color"].join(" ")}),s.classed("mg-line-rollover-circle",!0),function(t){for(var e=t.data,r=t.custom_line_color_map,a=0;a<e.length;a++)for(var n=0;n<e[a].length;n++)e[a][n].index=a+1,0<r.length?e[a][n].line_id=r[a]:e[a][n].line_id=a+1}(t),f=(d=t).data,p=d.aggregate_rollover,1<f.length&&!p?se(t,_,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t),e.rolloverClick(t)):(l=(c=t).data,u=c.aggregate_rollover,1<l.length&&u?ce(t,_,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t),e.rolloverClick(t)):function(a,t,e,r,n,o){var i=1;0<a.custom_line_color_map.length&&(i=a.custom_line_color_map[0]);var s,c,l=t.append("g").attr("class","mg-rollover-rect"),u=a.data[0].map(a.scalefns.xf);l.selectAll(".mg-rollover-rects").data(a.data[0]).enter().append("rect").attr("class",function(t,e){var r=de(i)+" "+ue(t.line_id);return a.linked&&(r+=r+" "+fe(pe(t,a))),r}).attr("x",function(t,e){return 1===u.length?Y(a):0===e?u[e].toFixed(2):((u[e-1]+u[e])/2).toFixed(2)}).attr("y",function(t,e){return 1<a.data.length?a.scalefns.yf(t)-6:a.top}).attr("width",function(t,e){return 1===u.length?P(a):0===e?((u[e+1]-u[e])/2).toFixed(2):e===u.length-1?((u[e]-u[e-1])/2).toFixed(2):((u[e+1]-u[e-1])/2).toFixed(2)}).attr("height",function(t,e){return 1<a.data.length?12:a.height-a.bottom-a.top-a.buffer}).attr("opacity",0).on("click",o).on("mouseover",e).on("mouseout",r).on("mousemove",n),me(a)&&(s=t,c=a.data,s.select(".mg-rollover-rect rect").on("mouseover")(c[0][0],0))}(t,_,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t),e.rolloverClick(t)))},ye=function(t,e,r){var a=t.scales,n=t.x_accessor,o=t.y_accessor,i=t.point_size;e.select("circle.mg-line-rollover-circle.mg-line"+r.line_id).attr("cx",a.X(r[n]).toFixed(2)).attr("cy",a.Y(r[o]).toFixed(2)).attr("r",i).style("opacity",1)},ve=function(t,e,r){var a=t.scales,n=t.x_accessor,o=t.y_accessor,i=t.point_size;e.selectAll("circle.mg-line-rollover-circle.mg-line"+r.line_id).classed("mg-line-rollover-circle",!0).attr("cx",function(){return a.X(r[n]).toFixed(2)}).attr("cy",function(){return a.Y(r[o]).toFixed(2)}).attr("r",i).style("opacity",1)};MG.register("line",function(t){this.init=function(e){if(!(this.args=e).data||0===e.data.length)return e.internal_error="No data was supplied",t=e,console.error("INTERNAL ERROR : ",t.target," : ",t.internal_error),this;var t;e.internal_error=void 0,Me(e),Ae(e),MG.call_hook("line.before_destroy",this),Ot(e),new MG.scale_factory(e).namespace("x").numericalDomainFromData().numericalRange("bottom");var r=(e.baselines||[]).map(function(t){return t[e.y_accessor]});return new MG.scale_factory(e).namespace("y").zeroBottom(!0).inflateDomain(!0).numericalDomainFromData(r).numericalRange("left"),e.x_axis&&new MG.axis_factory(e).namespace("x").type("numerical").position(e.x_axis_position).rug(nt(e)).label(st).draw(),e.y_axis&&new MG.axis_factory(e).namespace("y").type("numerical").position(e.y_axis_position).rug(K(e)).label(et).draw(),this.markers(),this.mainPlot(),this.rollover(),this.windowListeners(),e.brush&&MG.add_brush_function(e),MG.call_hook("line.after_init",this),this},this.mainPlot=function(){return he(t),this},this.markers=function(){return St(t),this},this.rollover=function(){return xe(t,this),MG.call_hook("line.after_rollover",t),this},this.rolloverClick=function(r){return function(t,e){r.click&&r.click(t,e)}},this.rolloverOn=function(n){var o=O(n.target);return function(r,t){if(function(a,n,t){if(a.aggregate_rollover&&1<a.data.length)n.selectAll("circle.mg-line-rollover-circle").style("opacity",0),t.values.forEach(function(t,e,r){a.missing_is_hidden&&r[e]._missing||i(t,a)&&ye(a,n,t)});else{if(a.missing_is_hidden&&t._missing||null===t[a.y_accessor])return;i(t,a)&&ve(a,n,t)}}(n,o,r),function(t,e,r){if(t.linked&&!MG.globals.link&&(MG.globals.link=!0,!t.aggregate_rollover||void 0!==e[t.y_accessor]||e.values&&0<e.values.length)){var a=e.values?e.values[0]:e,n=pe(a,t);E.selectAll("."+ue(a.line_id)+"."+fe(n)).each(function(t){E.select(this).on("mouseover")(t,r)})}}(n,r,t),o.selectAll("text").filter(function(t,e){return r===t}).attr("opacity",.3),n.show_rollover_text&&!(n.missing_is_hidden&&r._missing||null===r[n.y_accessor])){var e=Xt(n,{svg:o}),a=e.mouseover_row();n.aggregate_rollover&&a.text((n.aggregate_rollover&&1<n.data.length?function(t,e){return Pe(t,e,t.x_mouseover,"key",t.time_series)}:Se)(n,r)),(n.aggregate_rollover&&1<n.data.length?r.values:[r]).forEach(function(t){n.aggregate_rollover&&(a=e.mouseover_row()),n.legend&&Zt(a.text(n.legend[t.index-1]+" ").bold(),t,n),Zt(a.text("— ").elem,t,n),n.aggregate_rollover||a.text(Se(n,t)),a.text(Le(n,t,n.time_series))})}n.mouseover&&n.mouseover(r,t)}},this.rolloverOff=function(c){var l=O(c.target);return function(t,e){var r,a,n,o,i,s;!function(t,e,a){var r=t.linked,n=t.utc_time,o=t.linked_format,i=t.x_accessor;if(r&&MG.globals.link){MG.globals.link=!1;var s=MG.time_format(n,o);(e.values?e.values:[e]).forEach(function(t){var e=t[i],r="number"==typeof e?a:s(e);E.selectAll(".roll_"+r).each(function(t){E.select(this).on("mouseout")(t)})})}}(c,t,e),c.aggregate_rollover?l.selectAll("circle.mg-line-rollover-circle").filter(function(t){return 1<t.length}).style("opacity",0):(a=l,n=t,o=(r=c).custom_line_color_map,i=r.data,s=n.line_id,a.selectAll("circle.mg-line-rollover-circle.mg-line"+s).style("opacity",function(){var t=s-1;return 0<o.length&&void 0!==o.indexOf(s)&&(t=o.indexOf(s)),1===i[t].length?1:0})),1<c.data[0].length&&Lt(l),c.mouseout&&c.mouseout(t,e)}},this.rolloverMove=function(r){return function(t,e){r.mousemove&&r.mousemove(t,e)}},this.windowListeners=function(){return Qt(this.args),this},this.init(t)});function be(t,e,r){var a,n,o,i,s,c=Xt(t,{svg:e}).mouseover_row();if(null!==t.color_accessor&&"category"===t.color_type){var l=r[t.color_accessor];c.text(l+" ").bold().attr("fill",t.scalefns.colorf(r))}a=t,n=c.text("● ").elem,o=r,i=a.color_accessor,s=a.scalefns,null!==i?(n.attr("fill",s.colorf(o)),n.attr("stroke",s.colorf(o))):n.classed("mg-points-mono",!0),c.text(Se(t,r)),c.text(Le(t,r,t.time_series))}MG.register("histogram",function(r){var a=this;this.init=function(e){Me(a.args=e),De(e),Ot(e),new MG.scale_factory(e).namespace("x").numericalDomainFromData().numericalRange("bottom");var t=(e.baselines||[]).map(function(t){return t[e.y_accessor]});return new MG.scale_factory(e).namespace("y").zeroBottom(!0).inflateDomain(!0).numericalDomainFromData(t).numericalRange("left"),ot(e),rt(e),a.mainPlot(),a.markers(),a.rollover(),a.windowListeners(),a},this.mainPlot=function(){var t=O(r.target);return t.selectAll(".mg-histogram").remove(),t.append("g").attr("class","mg-histogram").selectAll(".mg-bar").data(r.data[0]).enter().append("g").attr("class","mg-bar").attr("transform",function(t){return"translate("+r.scales.X(t[r.x_accessor]).toFixed(2)+","+r.scales.Y(t[r.y_accessor]).toFixed(2)+")"}).append("rect").attr("x",1).attr("width",function(t,e){return 1===r.data[0].length?(r.scalefns.xf(r.data[0][0])-r.bar_margin).toFixed(0):e!==r.data[0].length-1?(r.scalefns.xf(r.data[0][e+1])-r.scalefns.xf(t)).toFixed(0):(r.scalefns.xf(r.data[0][1])-r.scalefns.xf(r.data[0][0])).toFixed(0)}).attr("height",function(t){return 0===t[r.y_accessor]?0:(r.height-r.bottom-r.buffer-r.scales.Y(t[r.y_accessor])).toFixed(2)}),a},this.markers=function(){return St(r),a},this.rollover=function(){var t=O(r.target);return 0===t.selectAll(".mg-active-datapoint-container").nodes().length&&S(t,"mg-active-datapoint-container"),t.selectAll(".mg-rollover-rect").remove(),t.selectAll(".mg-active-datapoint").remove(),t.append("g").attr("class","mg-rollover-rect").selectAll(".mg-bar").data(r.data[0]).enter().append("g").attr("class",function(t,e){return r.linked?"mg-rollover-rects roll_"+e:"mg-rollover-rects"}).attr("transform",function(t){return"translate("+r.scales.X(t[r.x_accessor])+",0)"}).append("rect").attr("x",1).attr("y",r.buffer+(r.title?r.title_y_position:0)).attr("width",function(t,e){return 1===r.data[0].length?(r.scalefns.xf(r.data[0][0])-r.bar_margin).toFixed(0):e!==r.data[0].length-1?(r.scalefns.xf(r.data[0][e+1])-r.scalefns.xf(t)).toFixed(0):(r.scalefns.xf(r.data[0][1])-r.scalefns.xf(r.data[0][0])).toFixed(0)}).attr("height",function(t){return r.height}).attr("opacity",0).on("mouseover",a.rolloverOn(r)).on("mouseout",a.rolloverOff(r)).on("mousemove",a.rolloverMove(r)),a},this.rolloverOn=function(e){var n=O(e.target);return function(r,a){if(n.selectAll("text").filter(function(t,e){return r===t}).attr("opacity",.3),e.processed.xax_format||MG.time_format(e.utc_time,"%b %e, %Y"),Ee(e),n.selectAll(".mg-bar rect").filter(function(t,e){return e===a}).classed("active",!0),e.linked&&!MG.globals.link&&(MG.globals.link=!0,E.selectAll(".mg-rollover-rects.roll_"+a+" rect").each(function(t){E.select(this).on("mouseover")(t,a)})),e.show_rollover_text){var t=Xt(e,{svg:n}).mouseover_row();t.text("▟ ").elem.classed("hist-symbol",!0),t.text(Se(e,r)),t.text(Le(e,r,e.time_series))}e.mouseover&&(jt(n,e),e.mouseover(r,a))}},this.rolloverOff=function(r){var a=O(r.target);return function(t,e){r.linked&&MG.globals.link&&(MG.globals.link=!1,E.selectAll(".mg-rollover-rects.roll_"+e+" rect").each(function(t){E.select(this).on("mouseout")(t,e)})),a.selectAll(".mg-bar rect").classed("active",!1),Lt(a),r.mouseout&&r.mouseout(t,e)}},this.rolloverMove=function(r){return function(t,e){r.mousemove&&r.mousemove(t,e)}},this.windowListeners=function(){return Qt(a.args),a},this.init(r)},{binned:!1,bins:null,processed_x_accessor:"x",processed_y_accessor:"y",processed_dx_accessor:"dx",bar_margin:1});var we=function(t,e){var r=e.x_accessor,a=e.y_accessor;return t.filter(function(t){return(null===e.min_x||t[r]>=e.min_x)&&(null===e.max_x||t[r]<=e.max_x)&&(null===e.min_y||t[a]>=e.min_y)&&(null===e.max_y||t[a]<=e.max_y)})};MG.register("point",function(a){var o=this;this.init=function(e){if((this.args=e).x_axis_type=s(e,"x"),e.y_axis_type=s(e,"y"),Me(e),Oe(e),Ot(e),"categorical"===e.x_axis_type?(MG.scale_factory(e).namespace("x").categoricalDomainFromData().categoricalRangeBands([0,e.xgroup_height],null===e.xgroup_accessor),e.xgroup_accessor?new MG.scale_factory(e).namespace("xgroup").categoricalDomainFromData().categoricalRangeBands("bottom"):(e.scales.XGROUP=function(){return Y(e)},e.scalefns.xgroupf=function(){return Y(e)}),e.scalefns.xoutf=function(t){return e.scalefns.xf(t)+e.scalefns.xgroupf(t)}):(MG.scale_factory(e).namespace("x").inflateDomain(!0).zeroBottom("categorical"===e.y_axis_type).numericalDomainFromData((e.baselines||[]).map(function(t){return t[e.x_accessor]})).numericalRange("bottom"),e.scalefns.xoutf=e.scalefns.xf),"categorical"===e.y_axis_type)MG.scale_factory(e).namespace("y").zeroBottom(!0).categoricalDomainFromData().categoricalRangeBands([0,e.ygroup_height],!0),e.ygroup_accessor?new MG.scale_factory(e).namespace("ygroup").categoricalDomainFromData().categoricalRangeBands("left"):(e.scales.YGROUP=function(){return b(e)},e.scalefns.ygroupf=function(){return b(e)}),e.scalefns.youtf=function(t){return e.scalefns.yf(t)+e.scalefns.ygroupf(t)};else{var t=(e.baselines||[]).map(function(t){return t[e.y_accessor]});MG.scale_factory(e).namespace("y").inflateDomain(!0).zeroBottom("categorical"===e.x_axis_type).numericalDomainFromData(t).numericalRange("left"),e.scalefns.youtf=function(t){return e.scalefns.yf(t)}}if(null!==e.color_accessor){var r=MG.scale_factory(e).namespace("color");"number"===e.color_type?r.numericalDomainFromData(B(e)).numericalRange(I(e)).clamp(!0):e.color_domain?r.categoricalDomain(e.color_domain).categoricalRange(e.color_range):r.categoricalDomainFromData().categoricalColorRange()}return e.size_accessor&&new MG.scale_factory(e).namespace("size").numericalDomainFromData().numericalRange(it(e)).clamp(!0),new MG.axis_factory(e).namespace("x").type(e.x_axis_type).zeroLine("categorical"===e.y_axis_type).position(e.x_axis_position).rug(nt(e)).label(st).draw(),new MG.axis_factory(e).namespace("y").type(e.y_axis_type).zeroLine("categorical"===e.x_axis_type).position(e.y_axis_position).rug(K(e)).label(et).draw(),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),e.brush&&MG.add_brush_function(e),this},this.markers=function(){return St(a),a.least_squares&&ze(a),this},this.mainPlot=function(){var t=O(a.target),e=we(a.data[0],a);t.selectAll(".mg-points").remove();var r=t.append("g").classed("mg-points",!0).selectAll("circle").data(e).enter().append("circle").attr("class",function(t,e){return"path-"+e}).attr("cx",a.scalefns.xoutf).attr("cy",function(t){return a.scalefns.youtf(t)});return null!==a.color_accessor?(r.attr("fill",a.scalefns.colorf),r.attr("stroke",a.scalefns.colorf)):r.classed("mg-points-mono",!0),null!==a.size_accessor?r.attr("r",a.scalefns.sizef):r.attr("r",a.point_size),this},this.rollover=function(){var t=O(a.target);0===t.selectAll(".mg-active-datapoint-container").nodes().length&&S(t,"mg-active-datapoint-container"),t.selectAll(".mg-voronoi").remove();var e=E.voronoi().x(a.scalefns.xoutf).y(a.scalefns.youtf).extent([[a.buffer,a.buffer+(a.title?a.title_y_position:0)],[a.width-a.buffer,a.height-a.buffer]]);return t.append("g").attr("class","mg-voronoi").selectAll("path").data(e.polygons(we(a.data[0],a))).enter().append("path").attr("d",function(t){return null==t?null:"M"+t.join(",")+"Z"}).attr("class",function(t,e){return"path-"+e}).style("fill-opacity",0).on("mouseover",this.rolloverOn(a)).on("mouseout",this.rolloverOff(a)).on("mousemove",this.rolloverMove(a)),1===a.data[0].length&&be(a,t,a.data[0][0]),this},this.rolloverOn=function(a){var n=O(a.target);return function(t,e){n.selectAll(".mg-points circle").classed("selected",!1);var r=n.selectAll(".mg-points circle.path-"+e).classed("selected",!0);a.size_accessor?r.attr("r",function(t){return a.scalefns.sizef(t)+a.active_point_size_increase}):r.attr("r",a.point_size+a.active_point_size_increase),a.linked&&!MG.globals.link&&(MG.globals.link=!0,E.selectAll(".mg-voronoi .path-"+e).each(function(){E.select(o).on("mouseover")(t,e)})),a.show_rollover_text&&be(a,n,t.data),a.mouseover&&a.mouseover(t,e)}},this.rolloverOff=function(a){var n=O(a.target);return function(t,e){a.linked&&MG.globals.link&&(MG.globals.link=!1,E.selectAll(".mg-voronoi .path-"+e).each(function(){E.select(o).on("mouseout")(t,e)}));var r=n.selectAll(".mg-points circle").classed("unselected",!1).classed("selected",!1);a.size_accessor?r.attr("r",a.scalefns.sizef):r.attr("r",a.point_size),1<a.data[0].length&&Lt(n),a.mouseout&&a.mouseout(t,e)}},this.rolloverMove=function(r){return function(t,e){r.mousemove&&r.mousemove(t,e)}},this.update=function(t){return this},this.windowListeners=function(){return Qt(this.args),this},this.init(a)},{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,y_categorical_show_guides:!0,x_categorical_show_guides:!0,buffer:16,ls:!1,lowess:!1,point_size:2.5,label_accessor:null,size_accessor:null,color_accessor:null,size_range:null,color_range:null,size_domain:null,color_domain:null,active_point_size_increase:1,color_type:"number"});MG.register("bar",function(M){var G=this;this.args=M,this.init=function(e){if((G.args=e).x_axis_type=s(e,"x"),e.y_axis_type=s(e,"y"),"categorical"==e.x_axis_type?e.orientation="vertical":"categorical"==e.y_axis_type?e.orientation="horizontal":"categorical"!=e.x_axis_type&&"categorical"!=e.y_axis_type&&(e.orientation="vertical"),Me(e),Oe(e),Ot(e),"categorical"===e.x_axis_type?(MG.scale_factory(e).namespace("x").categoricalDomainFromData().categoricalRangeBands([0,e.xgroup_height],null===e.xgroup_accessor),e.xgroup_accessor?new MG.scale_factory(e).namespace("xgroup").categoricalDomainFromData().categoricalRangeBands("bottom"):(e.scales.XGROUP=function(t){return Y(e)},e.scalefns.xgroupf=function(t){return Y(e)}),e.scalefns.xoutf=function(t){return e.scalefns.xf(t)+e.scalefns.xgroupf(t)}):(MG.scale_factory(e).namespace("x").inflateDomain(!0).zeroBottom("categorical"===e.y_axis_type).numericalDomainFromData((e.baselines||[]).map(function(t){return t[e.x_accessor]})).numericalRange("bottom"),e.scalefns.xoutf=e.scalefns.xf),"categorical"===e.y_axis_type)MG.scale_factory(e).namespace("y").zeroBottom(!0).categoricalDomainFromData().categoricalRangeBands([0,e.ygroup_height],!0),e.ygroup_accessor?new MG.scale_factory(e).namespace("ygroup").categoricalDomainFromData().categoricalRangeBands("left"):(e.scales.YGROUP=function(){return b(e)},e.scalefns.ygroupf=function(t){return b(e)}),e.scalefns.youtf=function(t){return e.scalefns.yf(t)+e.scalefns.ygroupf(t)};else{var t=(e.baselines||[]).map(function(t){return t[e.y_accessor]});MG.scale_factory(e).namespace("y").inflateDomain(!0).zeroBottom("categorical"===e.x_axis_type).numericalDomainFromData(t).numericalRange("left"),e.scalefns.youtf=function(t){return e.scalefns.yf(t)}}return null!==e.ygroup_accessor&&(e.ycolor_accessor=e.y_accessor,MG.scale_factory(e).namespace("ycolor").scaleName("color").categoricalDomainFromData().categoricalColorRange()),null!==e.xgroup_accessor&&(e.xcolor_accessor=e.x_accessor,MG.scale_factory(e).namespace("xcolor").scaleName("color").categoricalDomainFromData().categoricalColorRange()),new MG.axis_factory(e).namespace("x").type(e.x_axis_type).zeroLine("categorical"===e.y_axis_type).position(e.x_axis_position).draw(),new MG.axis_factory(e).namespace("y").type(e.y_axis_type).zeroLine("categorical"===e.x_axis_type).position(e.y_axis_position).draw(),G.mainPlot(),G.markers(),G.rollover(),G.windowListeners(),G},this.mainPlot=function(){var t=O(M.target),e=M.data[0],r=t.select("g.mg-barplot"),a=r.empty(),n=void 0;a&&M.animate_on_load||M.transition_on_update,M.transition_duration,a&&(r=t.append("g").classed("mg-barplot",!0)),n=r.selectAll(".mg-bar").data(e).enter().append("rect").classed("mg-bar",!0).classed("default-bar",!M.scales.hasOwnProperty("COLOR"));var o=void 0,i=void 0,s=void 0,c=void 0,l=void 0,u=void 0,d=void 0,f=void 0,p=void 0,_=void 0,m=void 0,g=void 0,h=void 0,x=void 0,y=void 0,v=void 0;if("vertical"==M.orientation&&(o="height",i="width",s=M.y_axis_type,c=M.x_axis_type,l="y",u="x",d="categorical"==s?M.scalefns.youtf:M.scalefns.yf,f="categorical"==c?M.scalefns.xoutf:M.scalefns.xf,p=M.scales.Y,_=M.scales.X,m=M.y_accessor,g=M.x_accessor,h=function(t){var e=void 0;return e=d(t),t[m]<0&&(e=p(0)),e},x=function(t){return Math.abs(d(t)-p(0))},y=function(t){return Math.abs(p(t[M.reference_accessor])-p(0))},v=function(t){return p(t[M.reference_accessor])}),"horizontal"==M.orientation&&(o="width",i="height",s=M.x_axis_type,c=M.y_axis_type,l="x",u="y",d="categorical"==s?M.scalefns.xoutf:M.scalefns.xf,f="categorical"==c?M.scalefns.youtf:M.scalefns.yf,p=M.scales.X,_=M.scales.Y,m=M.x_accessor,g=M.y_accessor,h=function(t){return p(0)},x=function(t){return Math.abs(d(t)-p(0))},y=function(t){return Math.abs(p(t[M.reference_accessor])-p(0))},v=function(t){return p(0)}),n.attr(l,h),n.attr(u,function(t){var e=void 0;return"categorical"==c?e=f(t):(e=_(0),t[g]<0&&(e=f(t))),e-=M.bar_thickness/2}),M.scales.COLOR&&n.attr("fill",M.scalefns.colorf),n.attr(o,x).attr(i,function(t){return M.bar_thickness}),null!==M.reference_accessor){var b=e.filter(function(t){return t.hasOwnProperty(M.reference_accessor)});r.selectAll(".mg-categorical-reference").data(b).enter().append("rect").attr(l,v).attr(u,function(t){return f(t)-M.reference_thickness/2}).attr(o,y).attr(i,M.reference_thickness)}if(null!==M.comparison_accessor){var w=null;w=null===M.comparison_thickness?M.bar_thickness/2:M.comparison_thickness;var k=e.filter(function(t){return t.hasOwnProperty(M.comparison_accessor)});r.selectAll(".mg-categorical-comparison").data(k).enter().append("line").attr(l+"1",function(t){return p(t[M.comparison_accessor])}).attr(l+"2",function(t){return p(t[M.comparison_accessor])}).attr(u+"1",function(t){return f(t)-w/2}).attr(u+"2",function(t){return f(t)+w/2}).attr("stroke","black").attr("stroke-width",M.comparison_width)}return(M.legend||null!==M.color_accessor&&M.ygroup_accessor!==M.color_accessor)&&(M.legend_target?function(t){var e=t.legend_target,r=t.orientation,a=t.scales;if(e){var n=E.select(e).append("div").classed("mg-bar-target-legend",!0);("horizontal"==r?a.Y.domain():a.X.domain()).forEach(function(t){var e=n.append("span").classed("mg-bar-target-element",!0);e.append("span").classed("mg-bar-target-legend-shape",!0).style("color",a.COLOR(t)).text("◼ "),e.append("span").classed("mg-bar-target-legend-text",!0).text(t)})}}(M):function(t,r){var e=void 0;e="horizontal"==r.orientation?r.scales.Y.domain():r.scales.X.domain();var a=0,n=t.append("g").classed("mg-bar-legend",!0).append("text");n.selectAll("*").remove(),n.attr("width",r.right).attr("height",100).attr("text-anchor","start"),e.forEach(function(t){var e=n.append("tspan").attr("x",P(r)).attr("y",r.height/2).attr("dy",1.1*a+"em");e.append("tspan").text("■ ").attr("fill",r.scales.COLOR(t)).attr("font-size",20),e.append("tspan").text(t).attr("font-weight",300).attr("font-size",10),a++})}(t,M)),G},this.markers=function(){return St(M),G},this.rollover=function(){var t=O(M.target);0===t.selectAll(".mg-active-datapoint-container").nodes().length&&S(t,"mg-active-datapoint-container"),t.selectAll(".mg-rollover-rect").remove(),t.selectAll(".mg-active-datapoint").remove();var e=void 0,r=void 0,a=void 0,n=void 0,o=void 0,i=void 0,s=void 0,c=void 0,l=void 0,u=void 0,d=void 0,f=void 0;"vertical"==M.orientation&&(e="height",r="width",a=M.y_axis_type,n=M.x_axis_type,o="y",i="x","categorical"==a?M.scalefns.youtf:M.scalefns.yf,s="categorical"==n?M.scalefns.xoutf:M.scalefns.xf,c=M.scales.Y,l=M.scales.X,M.y_accessor,u=M.x_accessor,d=function(t){return b(M)},f=function(t){return M.height-M.top-M.bottom-2*M.buffer}),"horizontal"==M.orientation&&(e="width",r="height",a=M.x_axis_type,n=M.y_axis_type,o="x",i="y","categorical"==a?M.scalefns.xoutf:M.scalefns.xf,s="categorical"==n?M.scalefns.youtf:M.scalefns.yf,c=M.scales.X,l=M.scales.Y,M.x_accessor,u=M.y_accessor,d=function(t){return c(0)},f=function(t){return M.width-M.left-M.right-2*M.buffer});var p=void 0,_=void 0;"right"===M.rollover_align?(p=M.width-M.right,_="end"):"left"===M.rollover_align?(p=M.left,_="start"):(p=(M.width-M.left-M.right)/2+M.left,_="middle"),t.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",p).attr("y",.75*M.top).attr("dy",".35em").attr("text-anchor",_);var m=t.append("g").attr("class","mg-rollover-rect").selectAll(".mg-bar-rollover").data(M.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return m.attr("opacity",0).attr(o,d).attr(i,function(t){var e=void 0;return"categorical"==n?e=s(t):(e=l(0),t[u]<0&&(e=s(t))),e-=M.bar_thickness/2}),m.attr(e,f),m.attr(r,function(t){return M.bar_thickness}),m.on("mouseover",G.rolloverOn(M)).on("mouseout",G.rolloverOff(M)).on("mousemove",G.rolloverMove(M)),G},this.rolloverOn=function(o){var i=O(o.target);return G.is_vertical?o.x_accessor:o.y_accessor,G.is_vertical?o.y_accessor:o.x_accessor,G.is_vertical?o.yax_units:o.xax_units,function(t,r){MG.time_format(o.utc_time,"%b %e, %Y"),Ee(o);var e=i.selectAll("g.mg-barplot .mg-bar").filter(function(t,e){return e===r}).classed("active",!0);if(o.scales.hasOwnProperty("COLOR")?e.attr("fill",E.rgb(o.scalefns.colorf(t)).darker()):e.classed("default-active",!0),o.show_rollover_text){var a=Xt(o,{svg:i}),n=a.mouseover_row();o.ygroup_accessor&&n.text(t[o.ygroup_accessor]+" ").bold(),n.text(Se(o,t)),n.text(o.y_accessor+": "+t[o.y_accessor]),(o.predictor_accessor||o.baseline_accessor)&&(n=a.mouseover_row(),o.predictor_accessor&&n.text(Pe(o,t,null,o.predictor_accessor,!1)),o.baseline_accessor&&n.text(Pe(o,t,null,o.baseline_accessor,!1)))}o.mouseover&&o.mouseover(t,r)}},this.rolloverOff=function(a){var n=O(a.target);return function(t,e){var r=n.selectAll("g.mg-barplot .mg-bar.active").classed("active",!1);a.scales.hasOwnProperty("COLOR")?r.attr("fill",a.scalefns.colorf(t)):r.classed("default-active",!1),n.select(".mg-active-datapoint").text(""),Lt(n),a.mouseout&&a.mouseout(t,e)}},this.rolloverMove=function(r){return function(t,e){r.mousemove&&r.mousemove(t,e)}},this.windowListeners=function(){return Qt(G.args),G},this.init(M)},{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",reference_accessor:null,comparison_accessor:null,secondary_label_accessor:null,color_accessor:null,color_type:"category",color_domain:null,reference_thickness:1,comparison_width:3,comparison_thickness:null,legend:!1,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.data_table=function(t){return this.args=t,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){return t.replace(/[^a-zA-Z0-9 _]+/g,"").replace(/ +?/g,"")},this._format_element=function(a,n,o){this.formatting_options.forEach(function(t){var e=t[0],r=t[1];o[r]&&a.style(e,"string"==typeof o[r]||"number"==typeof o[r]?o[r]:o[r](n))})},this._add_column=function(t,e){var r=this.args.standard_col,a=p(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 this._add_column(arguments[0],"number"),this},this.display=function(){var t=this.args;j(t);var e,r,a,n,o,i,s,c,l,u,d,f,p=t.target,_=E.select(p).append("table").classed("mg-data-table",!0),m=_.append("colgroup"),g=_.append("thead"),h=_.append("tbody");for(a=g.append("tr"),f=0;f<t.columns.length;f++){var x=t.columns[f];i=x.type,c=void 0===(c=x.label)?"":c,n=a.append("th").style("width",x.width).style("text-align","title"===i?"left":"right").text(c),t.show_tooltips&&x.description&&k()&&(n.append("i").classed("fa",!0).classed("fa-question-circle",!0).classed("fa-inverse",!0),$(n.node()).popover({html:!0,animation:!1,content:x.description,trigger:"hover",placement:"top",container:$(n.node())}))}for(f=0;f<t.columns.length;f++)d=m.append("col"),"number"===t.columns[f].type&&d.attr("align","char").attr("char",".");for(var y=0;y<t.data.length;y++){a=h.append("tr");for(var v=0;v<t.columns.length;v++){if(o=(e=t.columns[v]).accessor,s=l=t.data[y][o],"number"===(i=e.type)){if(e.hasOwnProperty("round")&&!e.hasOwnProperty("format")&&(l=E.format("0,."+e.round+"f")(l)),e.hasOwnProperty("value_formatter")&&(l=e.value_formatter(l)),e.hasOwnProperty("format")){e.round&&(l=Math.round(l,e.round));var b,w=e.format;"percentage"===w&&(b=E.format(".0%")),"count"===w&&(b=E.format(",.0f")),"temperature"===w&&(b=function(t){return t+"°"}),l=b(l)}e.hasOwnProperty("currency")&&(l=e.currency+l)}u=a.append("td").classed("table-"+i,!0).classed("table-"+i+"-"+this._strip_punctuation(o),!0).attr("data-value",s).style("width",e.width).style("text-align","title"===i||"text"===i?"left":"right"),this._format_element(u,s,e),"title"===i?(r=u.append("div").text(l),this._format_element(r,l,e),t.columns[v].hasOwnProperty("secondary_accessor")&&u.append("div").text(t.data[y][t.columns[v].secondary_accessor]).classed("secondary-title",!0)):u.text(l)}}return this},this};function ke(t,e){var r,a,n;function o(t){return 1e3===t?3:1e6===t?7:Math.log(t)/Math.LN10}"x"===e?(r=t.x_accessor,a=t.scales.X.ticks(t.xax_count),n=t.processed.max_x):"y"===e&&(r=t.y_accessor,a=t.scales.Y.ticks(t.yax_count),n=t.processed.max_y),("x"===e&&"log"===t.x_scale_type||"y"===e&&"log"===t.y_scale_type)&&(a=a.filter(function(t){return Math.abs(o(t))%1<1e-6||Math.abs(o(t))%1>1-1e-6}));var i=a.length,s=!0;t.data.forEach(function(t,e){t.forEach(function(t,e){if(t[r]%1!=0)return s=!1})}),s&&n<i&&"count"===t.format&&(a=a.filter(function(t){return t%1==0})),"x"===e?t.processed.x_ticks=a:"y"===e&&(t.processed.y_ticks=a)}function Me(r){if(r.data=MG.clone(r.data),r.single_object=!1,r.array_of_objects=!1,r.array_of_arrays=!1,r.nested_array_of_arrays=!1,r.nested_array_of_objects=!1,a(r.data)?(r.nested_array_of_objects=r.data.map(function(t){return e(t)}),r.nested_array_of_arrays=r.data.map(function(t){return a(t)})):(r.array_of_objects=n(r.data),r.array_of_arrays=a(r.data)),"line"===r.chart_type?(r.array_of_objects||r.array_of_arrays)&&(r.data=[r.data]):y(r.data[0])||(r.data=[r.data]),Ge(r,"x_accessor"),Ge(r,"y_accessor"),void 0!==r.color&&(r.colors=r.color),null!==r.colors&&"string"==typeof r.colors&&(r.colors=[r.colors]),"line"===r.chart_type&&!0===r.x_sort)for(var t=0;t<r.data.length;t++)r.data[t].sort(function(t,e){return t[r.x_accessor]-e[r.x_accessor]});return this}function Ge(e,r){y(e[r])&&(e.data=e.data.map(function(t){return e[r].map(function(e){return t.map(function(t){if(void 0!==(t=MG.clone(t))[e])return t["multiline_"+r]=t[e],t}).filter(function(t){return void 0!==t})})})[0],e[r]="multiline_"+r)}function Ae(r){var t,e=0<E.sum(r.data.map(function(t){return 0<t.length&&x(t[0][r.x_accessor])}));if((r.missing_is_zero||r.missing_is_hidden)&&"line"===r.chart_type&&e)for(var a=0;a<r.data.length;a++)if(!(r.data[a].length<=1)){var n=r.data[a][0],o=r.data[a][r.data[a].length-1],i=[],s=MG.clone(n[r.x_accessor]).setDate(n[r.x_accessor].getDate()+1),c=r.min_x?r.min_x:s,l=r.max_x?r.max_x:o[r.x_accessor];if(t=lt((l-c)/1e3),-1!==["four-days","many-days","many-months","years","default"].indexOf(t)&&null===r.missing_is_hidden_accessor)for(var u=new Date(c);u<=l;u.setDate(u.getDate()+1)){var d={};u.setHours(0,0,0,0),Date.parse(u)===Date.parse(new Date(s))&&i.push(MG.clone(r.data[a][0]));var f=null;r.data[a].forEach(function(t,e){if(Date.parse(t[r.x_accessor])===Date.parse(new Date(u)))return f=t,!1}),f?((f[r.missing_is_hidden_accessor]||null===f[r.y_accessor])&&(f._missing=!0),i.push(f)):(d[r.x_accessor]=new Date(u),d[r.y_accessor]=0,d._missing=!0,i.push(d))}else for(var p=0;p<r.data[a].length;p+=1){var _=MG.clone(r.data[a][p]);_._missing=r.data[a][p][r.missing_is_hidden_accessor],i.push(_)}r.data[a]=i}return this}function De(e){var t,r=e.data[0];if(!1===e.binned){if("object"===c(r[0]))t=r.map(function(t){return t[e.x_accessor]});else{if("number"!=typeof r[0])return void console.log("TypeError: expected an array of numbers, found "+c(r[0]));t=r}var a=E.histogram();e.bins&&a.thresholds(e.bins);var n=a(t);e.processed_data=n.map(function(t){return{x:t.x0,y:t.length}})}else{var o,i;e.processed_data=r.map(function(t){return{x:t[e.x_accessor],y:t[e.y_accessor]}});for(var s=0;s<e.processed_data.length;s++)o=e.processed_data[s],s===e.processed_data.length-1?o.dx=e.processed_data[s-1].dx:(i=e.processed_data[s+1],o.dx=i.x-o.x)}return e.processed||(e.processed={}),e.processed.original_data=e.data,e.processed.original_x_accessor=e.x_accessor,e.processed.original_y_accessor=e.y_accessor,e.data=[e.processed_data],e.x_accessor=e.processed_x_accessor,e.y_accessor=e.processed_y_accessor,this}function Oe(e){var t=e.data[0],r=t.map(function(t){return t[e.x_accessor]}),a=t.map(function(t){return t[e.y_accessor]});return e.least_squares&&(e.ls_line=Fe(r,a)),this}function ze(e){var t=O(e.target),r=e.data[0],a=E.min(r,function(t){return t[e.x_accessor]}),n=E.max(r,function(t){return t[e.x_accessor]});E.select(e.target).selectAll(".mg-least-squares-line").remove(),t.append("svg:line").attr("x1",e.scales.X(a)).attr("x2",e.scales.X(n)).attr("y1",e.scales.Y(e.ls_line.fit(a))).attr("y2",e.scales.Y(e.ls_line.fit(n))).attr("class","mg-least-squares-line")}function Fe(t,e){var r,a,n;t.length;r=x(t[0])?t.map(function(t){return t.getTime()}):t,a=x(e[0])?e.map(function(t){return t.getTime()}):e;for(var o=E.mean(r),i=E.mean(a),s=0,c=0,l=0;l<r.length;l++)s+=((n=r[l])-o)*(a[l]-i),c+=(n-o)*(n-o);var u=s/c,d=i-u*o;return{x0:d,beta:u,fit:function(t){return d+t*u}}}function Ce(t,e){return 0<=t&&t<=1?Math.pow(1-Math.pow(t,e),e):0}function Te(t){var e,r,a,n,o,i,s,c=(a=t,n=E.sum(a.map(function(t){return t.w})),{xbar:E.sum(a.map(function(t){return t.w*t.x}))/n,ybar:E.sum(a.map(function(t){return t.w*t.y}))/n}),l=(o=t,i=r=c.xbar,s=e=c.ybar,E.sum(o.map(function(t){return Math.pow(t.w,2)*(t.x-i)*(t.y-s)}))/E.sum(o.map(function(t){return Math.pow(t.w,2)*Math.pow(t.x-i,2)})));return{beta:l,xbar:r,ybar:e,x0:e-l*r}}function Re(t,e,r,a,n){var o=Math.floor(t.length*r),i=t.slice();i.sort(function(t,e){return t<e?-1:e<t?1:0});for(var s,c,l,u,d,f=E.quantile(i,.98),p=E.quantile(i,.02),_=E.zip(t,e,n).sort(),m=Math.abs(f-p)/a,g=p,h=f,x=E.range(g,h,m),y=[],v=0;v<x.length;v+=1){c=x[v],s=_.map(function(t){return[Math.abs(t[0]-c),t[0],t[1],t[2]]}).sort().slice(0,o),d=E.max(s)[0];var b=Te(s=s.map(function(t){return{w:(e=t[0]/d,Ce(e,3)*t[3]),x:t[1],y:t[2]};var e}));u=b.x0,l=b.beta,y.push(u+l*c)}return{x:x,y:y}}function Ee(r){return"count"===r.format?function(t){var e;return e=t%1!=0?E.format(",."+r.decimals+"f"):E.format(",.0f"),r.yax_units_append?e(t)+r.yax_units:r.yax_units+e(t)}:function(t){var e=(r.decimals?"."+r.decimals:"")+"%";return E.format(e)(t)}}MG.register("missing-data",function(t){var R=this;this.init=function(t){yt(R.args=t),vt(t);var e=E.select(t.target);Gt(e,t);var r,a,n,o,i,s,c,l,u,d,f,p,_,m,g,h,x,y,v,b,w,k,M,G,A,D,O,z,F,C=e.selectAll("svg");if(bt(C,t),kt(C=wt(C,t),t),Mt(C,t),r=t.target,E.select(r).selectAll("svg *").remove(),C.classed("mg-missing",!0),(a=t.legend_target)&&E.select(a).html(""),j(t),t.show_missing_background){!function(t){for(var e=[],r=1;r<=50;r++)e.push({x:r,y:Math.random()-.03*r});t.data=e}(t),(G=t).scales.X=E.scaleLinear().domain([0,G.data.length]).range([Y(G),P(G)]),G.scalefns.yf=function(t){var e=t.y;return G.scales.Y(e)},(M=t).scales.Y=E.scaleLinear().domain([-2,2]).range([M.height-M.bottom-2*M.buffer,M.top]),M.scalefns.xf=function(t){var e=t.x;return M.scales.X(e)};var T=S(C,"mg-missing-pane");h=T,y=(x=t).title,v=x.buffer,b=x.title_y_position,w=x.width,k=x.height,h.append("svg:rect").classed("mg-missing-background",!0).attr("x",v).attr("y",v+2*(y?b:0)).attr("width",w-2*v).attr("height",k-2*v-2*(y?b:0)).attr("rx",15).attr("ry",15),d=T,p=(f=t).scalefns,_=f.interpolate,m=f.data,g=E.line().x(p.xf).y(p.yf).curve(_),d.append("path").attr("class","mg-main-line mg-line1-color").attr("d",g(m)),n=T,i=(o=t).scalefns,s=o.scales,c=o.interpolate,l=o.data,u=E.area().x(i.xf).y0(s.Y.range()[0]).y1(i.yf).curve(c),n.append("path").attr("class","mg-main-area mg-area1-color").attr("d",u(l))}return A=C,O=(D=t).missing_text,z=D.width,F=D.height,A.selectAll(".mg-missing-text").data([O]).enter().append("text").attr("class","mg-missing-text").attr("x",z/2).attr("y",F/2).attr("dy",".50em").attr("text-anchor","middle").text(O),R.windowListeners(),R},this.windowListeners=function(){return Qt(R.args),R},this.init(t)},{top:40,bottom:30,right:10,left:0,buffer:8,legend_target:"",width:350,height:220,missing_text:"Data currently missing or unavailable",scalefns:{},scales:{},show_tooltips:!0,show_missing_background:!0}),MG.raw_data_transformation=Me,MG.process_line=Ae,MG.process_histogram=De,MG.process_categorical_variables=function(t){return"vertical"===t.bar_orientation?t.x_accessor:t.y_accessor,"vertical"===t.bar_orientation?t.y_accessor:t.x_accessor,this},MG.process_point=Oe,MG.add_ls=ze,MG.add_lowess=function(e){var t=O(e.target),r=e.lowess_line,a=E.svg.line().x(function(t){return e.scales.X(t.x)}).y(function(t){return e.scales.Y(t.y)}).interpolate(e.interpolate);t.append("path").attr("d",a(r)).attr("class","mg-lowess-line")},MG.lowess_robust=function(t,e,r,a){var n,o,i=[];for(E.mean(e),o=0;o<t.length;o+=1)i.push(1);var s=(n=Re(t,e,r,a,i)).x,c=n.y;for(o=0;o<100;o+=1){i=E.zip(c,e).map(function(t){return Math.abs(t[1]-t[0])});var l=E.quantile(i.sort(),.5);s=(n=Re(t,e,r,a,i=i.map(function(t){return Ce(t/(6*l),2)}))).x,c=n.y}return E.zip(s,c).map(function(t){var e={};return e.x=t[0],e.y=t[1],e})},MG.lowess=function(t,e,r,a){for(var n=[],o=0;o<t.length;o+=1)n.push(1);Re(t,e,r,a,n)},MG.least_squares=Fe;var Ye=function(t,e,r,a){return"string"==typeof t?MG.time_format(a,t)(e[r]):"function"==typeof t?t(e):e[r]},$e=function(t,e,r){return"string"==typeof t?E.format("s")(e[r]):"function"==typeof t?t(e):e[r]};function Pe(t,e,r,a,n){var o,i=function(t){if(t.rollover_time_format)return MG.time_format(t.utc_time,t.rollover_time_format);switch(t.processed.x_time_frame){case"millis":return MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S.%L");case"seconds":return MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S");case"less-than-a-day":case"four-days":return MG.time_format(t.utc_time,"%b %e, %Y %I:%M%p")}return MG.time_format(t.utc_time,"%b %e, %Y")}(t);return o="string"==typeof e[a]?function(t){return t}:Ee(t),null!==r?n?Ye(r,e,a,t.utc):$e(r,e,a):n?i(new Date(+e[a]))+" ":(t.time_series?"":a+": ")+o(e[a])+" "}function Se(t,e){return Pe(t,e,t.x_mouseover,t.x_accessor,t.time_series)}function Le(t,e){return Pe(t,e,t.y_mouseover,t.y_accessor,!1)}function je(c,l){return function(){for(var a=this,n=a.cloneNode(),o=a.getTotalLength()||0,i=(n.setAttribute("d",c),n).getTotalLength()||0,t=[0],e=0,r=l/Math.max(o,i);(e+=r)<1;)t.push(e);t.push(1);var s=t.map(function(t){var e=a.getPointAtLength(t*o),r=n.getPointAtLength(t*i);return E.interpolate([e.x,e.y],[r.x,r.y])});return function(e){return e<1?"M"+s.map(function(t){return t(e)}).join("L"):c}}}function Xe(t){console.error("ERROR : ",t.target," : ",t.error),E.select(t.target).select(".mg-chart-title").append("tspan").attr("class","fa fa-x fa-exclamation-circle mg-warning").attr("dx","0.3em").text("")}return MG.format_rollover_number=Ee,MG.path_tween=je,MG.render_markup=function(t){switch("undefined"==typeof window?"undefined":c(window)){case"undefined":return function(t){var e,r=MG.virtual_window,a=E.select(r.document),n=r.document.createElement("div"),o=global.d3,i=global.window,s=global.document;global.d3=a,global.window=r,global.document=r.document;try{t(n)}catch(t){e=t}if(global.d3=o,global.window=i,global.document=s,e)throw e;return a.select(function(){return n}).html()}(t);default:return e=t,r=document.createElement("div"),e(r),E.select(r).html()}var e,r},MG.init_virtual_window=function(t,e){if(!MG.virtual_window||e){var r=t.jsdom({html:"",features:{QuerySelector:!0}});MG.virtual_window=r.defaultView}},MG.error=Xe,MG});
\ No newline at end of file |