1
2
3
|
!function(t,e){"function"==typeof define&&define.amd?define(["d3","jquery"],e):"object"==typeof exports?module.exports=e(require("d3"),require("jquery")):t.MG=e(t.d3,t.jQuery)}(this,function(t,e){function r(t,e,r){MG.charts[t]={descriptor:e,defaults:r||{}}}function n(r){"use strict";var n=un(r.target);if(n.select(".mg-header").remove(),r.target&&r.title){var a=n.insert("text").attr("class","mg-header").attr("x",(r.width+r.left-r.right)/2).attr("y",r.title_y_position).attr("text-anchor","middle").attr("dy","0.55em");if(a.append("tspan").attr("class","mg-chart-title").text(r.title),r.show_tooltips&&r.description){a.append("tspan").attr("class","mg-chart-description").attr("dx","0.3em").text("");var o=e(a.node());o.popover({html:!0,animation:!1,placement:"top",content:r.description,container:r.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(){t.selectAll(r.target).selectAll(".mg-popover").remove(),e(this).popover("show"),e(r.target).select(".popover").on("mouseleave",function(){o.popover("hide")})}).on("mouseleave",function(){setTimeout(function(){e(".popover:hover").length||o.popover("hide")},120)})}}r.error&&kn(r)}function a(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:2*t.buffer/3;var e=Jr(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),en(e,t,"mg-y-rug-mono")}function o(e,r){return"bar"===e.chart_type&&(r.min=0,r.max=t.max(e.data[0],function(t){var r=[];return r.push(t[e.y_accessor]),null!==e.baseline_accessor&&r.push(t[e.baseline_accessor]),null!==e.predictor_accessor&&r.push(t[e.predictor_accessor]),Math.max.apply(null,r)})),r}function i(e){var r=e.yax_format;return r||("count"===e.format?(e.processed.max_y<1e-4?e.decimals=6:e.processed.max_y<.1&&(e.decimals=4),r=function(r){if(1>r)return e.yax_units+t.round(r,e.decimals);var n=t.formatPrefix(r);return e.yax_units+n.scale(r)+n.symbol}):r=function(e){var r=t.format(".2p");return r(e)}),r}function s(t){var e=un(t.target),r=t.scales.X.domain();if(0>=r[0]&&r[1]>=0){var n=t.scales.Y_ingroup.range(),a=t.categorical_groups.length?t.scales.Y_outgroup(t.categorical_groups[t.categorical_groups.length-1]):t.scales.Y_outgroup();e.append("svg:line").attr("x1",t.scales.X(0)).attr("x2",t.scales.X(0)).attr("y1",n[0]+qr(t)).attr("y2",n[n.length-1]+a+t.scales.Y_ingroup.rangeBand()).attr("stroke","black").attr("opacity",.2)}}function l(e){var r=fn(e.data);"log"===e.y_scale_type&&(r=r.filter(function(t){return t[e.y_accessor]>0})),e.baselines&&(r=r.concat(e.baselines));var n=t.extent(r,function(t){return t[e.y_accessor]}),a={};if(a.min=n[0],a.max=n[1],a.min>=0&&!e.min_y&&!e.min_y_from_data&&(a.min=0),o(e,a),a.min=null!==e.min_y?e.min_y:a.min,a.max=null!==e.max_y?e.max_y:a.max<0?a.max+(a.max-a.max*e.inflator):a.max*e.inflator,"log"!==e.y_scale_type&&a.min<0&&(a.min=a.min-(a.min-a.min*e.inflator)),!e.min_y&&e.min_y_from_data){var i=.01*(a.max-a.min);a.min=n[0]-i,a.max=n[1]+i}e.processed.min_y=a.min,e.processed.max_y=a.max}function c(t,e){return e.domain([t.processed.min_y,t.processed.max_y]).range([Ir(t),t.top]),e}function u(e){var r="log"===e.y_scale_type?t.scale.log():t.scale.linear();"log"===e.y_scale_type&&("histogram"===e.chart_type?e.processed.min_y=.2:e.processed.min_y<=0&&(e.processed.min_y=1)),e.scales.Y=c(e,r),e.scales.Y.clamp("log"===e.y_scale_type),e.scales.Y_axis=c(e,t.scale.linear())}function f(t,e){e.y_label&&t.append("text").attr("class","label").attr("x",function(){return-1*(qr(e)+(Ir(e)-qr(e))/2)}).attr("y",function(){return e.left/2}).attr("dy","0.4em").attr("text-anchor","middle").text(function(){return e.y_label}).attr("transform",function(){return"rotate(-90)"})}function d(t,e){var r=e.processed.y_ticks.length;if(!e.x_extended_ticks&&!e.y_extended_ticks&&r){var n,a;e.axes_not_compact&&"bar"!==e.chart_type?(n=e.height-e.bottom,a=e.top):r?(n=e.scales.Y(e.processed.y_ticks[0]).toFixed(2),a=e.scales.Y(e.processed.y_ticks[r-1]).toFixed(2)):(n=0,a=0),t.append("line").attr("x1",e.left).attr("x2",e.left).attr("y1",n).attr("y2",a)}}function p(t,e){t.selectAll(".mg-yax-ticks").data(e.processed.y_ticks).enter().append("line").classed("mg-extended-y-ticks",e.y_extended_ticks).attr("x1",e.left).attr("x2",function(){return e.y_extended_ticks?e.width-e.right:e.left-e.yax_tick_length}).attr("y1",function(t){return e.scales.Y(t).toFixed(2)}).attr("y2",function(t){return e.scales.Y(t).toFixed(2)})}function m(t,e){var r=i(e);t.selectAll(".mg-yax-labels").data(e.processed.y_ticks).enter().append("text").attr("x",e.left-3*e.yax_tick_length/2).attr("dx",-3).attr("y",function(t){return e.scales.Y(t).toFixed(2)}).attr("dy",".35em").attr("text-anchor","end").text(function(t){var e=r(t);return e})}function _(t){t.processed||(t.processed={});var e=un(t.target);if(l(t),MG.call_hook("y_axis.process_min_max",t,t.processed.min_y,t.processed.max_y),u(t),tn(t,"yf","Y",t.y_accessor),Vr(e,".mg-y-axis"),!t.y_axis)return this;var r=Kr(e,"mg-y-axis");return f(r,t),ar(t,"y"),d(r,t),p(r,t),m(r,t),t.y_rug&&a(t),this}function h(t){var e=un(t.target);Vr(e,".mg-y-axis");var r,n=Kr(e,"mg-y-axis");(t.categorical_groups.length?t.categorical_groups:["1"]).forEach(function(e){if(r=Kr(n,"mg-group-"+mn(e)),t.group_accessor)v(r,e,t);else{var a=g(r,e,t);nn(a,t.rotate_y_labels)}})}function g(t,e,r){return t.selectAll("text").data(r.categorical_variables).enter().append("svg:text").attr("x",r.left-r.buffer).attr("y",function(t){return r.scales.Y_outgroup(e)+r.scales.Y_ingroup(t)+r.scales.Y_ingroup.rangeBand()/2}).attr("dy",".35em").attr("text-anchor","end").text(String)}function v(t,e,r){t.append("svg:text").classed("mg-barplot-group-label",!0).attr("x",r.left-r.buffer).attr("y",r.scales.Y_outgroup(e)+r.scales.Y_outgroup.rangeBand()/2).attr("dy",".35em").attr("text-anchor","end").text(e)}function x(t){return rn(t,"Y_ingroup",t.categorical_variables,0,t.group_height,t.bar_padding_percentage,t.bar_outer_padding_percentage),tn(t,"yf_in","Y_ingroup",t.y_accessor),t.group_accessor?(rn(t,"Y_outgroup",t.categorical_groups,qr(t),Ir(t),t.group_padding_percentage,t.group_outer_padding_percentage),tn(t,"yf_out","Y_outgroup",t.group_accessor)):(t.scales.Y_outgroup=function(){return qr(t)},t.scalefns.yf_out=function(){return qr(t)}),t.y_axis?(h(t),t.show_bar_zero&&s(t),this):this}function y(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:t.buffer;var e=Jr(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),en(e,t,"mg-x-rug-mono")}function b(t){t.processed||(t.processed={})}function w(e){tn(e,"xf","X",e.x_accessor),ce(e);var r=e.utc_time?t.time.scale.utc():t.time.scale();e.scales.X=e.time_series?r:"log"===e.x_scale_type?t.scale.log():t.scale.linear(),e.scales.X.domain([e.processed.min_x,e.processed.max_x]).range([Ur(e),Wr(e)-e.additional_buffer]),e.scales.X.clamp("log"===e.x_scale_type)}function k(t){"use strict";var e=un(t.target);if(b(t),w(t),"point"===t.chart_type&&(G(t),Y(t)),Vr(e,".mg-x-axis"),!t.x_axis)return this;var r=Kr(e,"mg-x-axis");return q(r,t),Q(r,t),t.x_label&&E(r,t),t.x_rug&&y(t),this}function M(t){var e=un(t.target),r=0;"bar"===t.chart_type&&(r=t.buffer+5),rn(t,"X",t.categorical_variables.reverse(),t.left,Wr(t)-r),tn(t,"xf","X","value"),Vr(e,".mg-x-axis");var n=Kr(e,"mg-x-axis");return t.x_axis?(A(n,t,r),this):this}function A(t,e,r){var n=t.selectAll("text").data(e.categorical_variables).enter().append("svg:text");n.attr("x",function(t){return e.scales.X(t)+e.scales.X.rangeBand()/2+e.buffer*e.bar_outer_padding_percentage+r/2}).attr("y",Ir(e)).attr("dy",".35em").attr("text-anchor","middle").text(String),e.truncate_x_labels&&n.each(function(t){var r=this,n=e.scales.X.rangeBand();bn(r,t,n)}),nn(n,e.rotate_x_labels)}function G(e){var r,n;null!==e.color_accessor&&(r=O(e),n=T(e),"number"===e.color_type?e.scales.color=t.scale.linear().domain(r).range(n).clamp(!0):(e.scales.color=null!==e.color_range?t.scale.ordinal().range(n):r.length>10?t.scale.category20():t.scale.category10(),e.scales.color.domain(r)),tn(e,"color","color",e.color_accessor))}function O(e){var r;return null===e.color_domain?"number"===e.color_type?r=t.extent(e.data[0],function(t){return t[e.color_accessor]}):"category"===e.color_type&&(r=t.set(e.data[0].map(function(t){return t[e.color_accessor]})).values(),r.sort()):r=e.color_domain,r}function T(t){var e;return e=null===t.color_range?"number"===t.color_type?["blue","red"]:null:t.color_range}function Y(e){var r,n;null!==e.size_accessor&&(r=D(e),n=z(e),e.scales.size=t.scale.linear().domain(r).range(n).clamp(!0),tn(e,"size","size",e.size_accessor))}function D(e){return null===e.size_domain?t.extent(e.data[0],function(t){return t[e.size_accessor]}):e.size_domain}function z(t){var e;return e=null===t.size_range?[1,5]:t.size_range}function E(e,r){e.append("text").attr("class","label").attr("x",function(){return Ur(r)+(Wr(r)-Ur(r))/2}).attr("dx",null!=r.x_label_nudge_x?r.x_label_nudge_x:0).attr("y",function(){var e=t.select(r.target).select(".mg-x-axis text").node().getBoundingClientRect();return Br(r)+r.xax_tick_length*(7/3)+.8*e.height+10}).attr("dy",".5em").attr("text-anchor","middle").text(function(){return r.x_label})}function C(e){return function(r){if(1>r)return e.xax_units+t.round(r,e.decimals);var n=t.formatPrefix(r);return e.xax_units+n.scale(r)+n.symbol}}function X(t){var e;return e=P(t)?"millis":F(t)?"seconds":j(t)?"less-than-a-day":$(t)?"four-days":S(t)?"many-days":N(t)?"many-months":L(t)?"years":"default"}function P(t){return 10>t}function F(t){return 60>t}function j(t){return 24>=t/3600}function $(t){return 96>=t/3600}function S(t){return 93>=t/86400}function N(t){return 730>t/86400}function L(t){return t/86400>=730}function B(t,e){var r;return r=P(e)?MG.time_format(t,"%M:%S.%L"):F(e)?MG.time_format(t,"%M:%S"):j(e)?MG.time_format(t,"%H:%M"):$(e)?MG.time_format(t,"%H:%M"):S(e)?MG.time_format(t,"%b %d"):N(e)?MG.time_format(t,"%b"):MG.time_format(t,"%Y")}function I(t){var e,r,n;t.time_series&&(e=(t.processed.max_x-t.processed.min_x)/1e3,n=X(e),r=B(t.utc_time,e)),t.processed.main_x_time_format=r,t.processed.x_time_frame=n}function R(e){if(e.xax_format)return e.xax_format;var r=e.processed.original_data||e.data,n=fn(r)[0][e.processed.original_x_accessor||e.x_accessor];return function(r){I(e);var a=t.formatPrefix(r);return n instanceof Date?e.processed.main_x_time_format(new Date(r)):"number"==typeof n?1>r?e.xax_units+t.round(r,e.decimals):(a=t.formatPrefix(r),e.xax_units+a.scale(r)+a.symbol):r}}function q(t,e){ar(e,"x"),H(e,t),U(e,t)}function H(t,e){var r=(t.processed.x_ticks.length,t.scales.X.ticks(t.xax_count).length-1);t.x_extended_ticks||e.append("line").attr("x1",function(){return 0===t.xax_count?Ur(t):t.axes_not_compact&&"bar"!==t.chart_type?t.left:t.scales.X(t.scales.X.ticks(t.xax_count)[0]).toFixed(2)}).attr("x2",function(){return 0===t.xax_count||t.axes_not_compact&&"bar"!==t.chart_type?Wr(t):t.scales.X(t.scales.X.ticks(t.xax_count)[r]).toFixed(2)}).attr("y1",t.height-t.bottom).attr("y2",t.height-t.bottom)}function U(t,e){e.selectAll(".mg-xax-ticks").data(t.processed.x_ticks).enter().append("line").attr("x1",function(e){return t.scales.X(e).toFixed(2)}).attr("x2",function(e){return t.scales.X(e).toFixed(2)}).attr("y1",t.height-t.bottom).attr("y2",function(){return t.x_extended_ticks?t.top:t.height-t.bottom+t.xax_tick_length}).attr("class",function(){return t.x_extended_ticks?"mg-extended-x-ticks":void 0}).classed("mg-xax-ticks",!0)}function Q(t,e){W(e,t),Z(e,t)}function W(e,r){var n=r.selectAll(".mg-xax-labels").data(e.processed.x_ticks).enter().append("text").attr("x",function(t){return e.scales.X(t).toFixed(2)}).attr("y",(e.height-e.bottom+7*e.xax_tick_length/3).toFixed(2)).attr("dy",".50em").attr("text-anchor","middle");if(e.time_series&&e.european_clock?(n.append("tspan").classed("mg-european-hours",!0).text(function(e,r){var n=new Date(e);return 0===r?t.time.format("%H")(n):""}),n.append("tspan").classed("mg-european-minutes-seconds",!0).text(function(t){var r=new Date(t);return":"+e.processed.xax_format(r)})):n.text(function(t){return e.xax_units+e.processed.xax_format(t)}),an(n)){n.filter(function(t,e){return(e+1)%2===0}).remove();var a=un(e.target);a.selectAll(".mg-xax-ticks").filter(function(t,e){return(e+1)%2===0}).remove()}}function Z(t,e){if(t.time_series&&(t.show_years||t.show_secondary_x_label)){var r=V(t);K(t,e,r.timeframe,r.yformat,r.secondary)}}function V(e){var r={};switch(r.timeframe=e.processed.x_time_frame,r.timeframe){case"millis":case"seconds":r.secondary=t.time.days,r.yformat=e.european_clock?MG.time_format(e.utc_time,"%b %d"):MG.time_format(e.utc_time,"%I %p");break;case"less-than-a-day":r.secondary=t.time.days,r.yformat=MG.time_format(e.utc_time,"%b %d");break;case"four-days":r.secondary=t.time.days,r.yformat=MG.time_format(e.utc_time,"%b %d");break;case"many-days":r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%Y");break;case"many-months":r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%Y");break;default:r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%Y")}return r}function K(t,e,r,n,a){var o=a(t.processed.min_x,t.processed.max_x);if(0===o.length){var i=t.scales.X.ticks(t.xax_count)[0];o=[i]}var s=Kr(e,"mg-year-marker");"default"===r&&t.show_year_markers&&J(t,s,o,n),"years"!=r&&te(t,s,o,n)}function J(t,e,r){e.selectAll(".mg-year-marker").data(r).enter().append("line").attr("x1",function(e){return t.scales.X(e).toFixed(2)}).attr("x2",function(e){return t.scales.X(e).toFixed(2)}).attr("y1",Rr(t)).attr("y2",Br(t))}function te(e,r,n,a){r.selectAll(".mg-year-marker").data(n).enter().append("text").attr("x",function(t){return e.scales.X(t).toFixed(2)}).attr("y",function(){var r=t.select(e.target).select(".mg-x-axis text").node().getBoundingClientRect();return Br(e)+7*e.xax_tick_length/3+.8*r.height}).attr("dy",".50em").attr("text-anchor","middle").text(function(t){return a(new Date(t))})}function ee(e,r,n){var a=t.extent(n,function(t){return t[r.x_accessor]});e.min=a[0],e.max=a[1]}function re(e,r,n){return e.min=t.min(n,function(t){var e=[t[r.x_accessor],t[r.baseline_accessor]?t[r.baseline_accessor]:0,t[r.predictor_accessor]?t[r.predictor_accessor]:0];return Math.min.apply(null,e)}),e.min>0&&(e.min=0),e.max=t.max(n,function(t){var e=[t[r.x_accessor],t[r.baseline_accessor]?t[r.baseline_accessor]:0,t[r.predictor_accessor]?t[r.predictor_accessor]:0];return Math.max.apply(null,e)}),e}function ne(t){var e=MG.clone(t.min).setDate(t.min.getDate()-1),r=MG.clone(t.min).setDate(t.min.getDate()+1);t.min=e,t.max=r}function ae(t){t.min=t.min-1,t.max=t.max+1}function oe(t){t.min=Number(t.min)-1,t.max=Number(t.max)+1}function ie(t){t.xax_count=2}function se(t,e,r){"line"===e.chart_type||"point"===e.chart_type||"histogram"===e.chart_type?ee(t,e,r):"bar"===e.chart_type&&re(t,e,r),t.min!==t.max||e.min_x&&e.max_x||(t.min instanceof Date?ne(t):"number"==typeof min_x?ae(t):"string"==typeof min_x&&oe(t),ie(e))}function le(t){var e=fn(t.data);"log"===t.x_scale_type&&(e=e.filter(function(e){return e[t.x_accessor]>0}));var r={};se(r,t,e),r.min=t.min_x||r.min,r.max=t.max_x||r.max,t.x_axis_negative=!1,t.processed.min_x=r.min,t.processed.max_x=r.max}function ce(t){le(t),ue(t),MG.call_hook("x_axis.process_min_max",t,t.processed.min_x,t.processed.max_x),t.time_series||t.processed.min_x<0&&(t.processed.min_x=t.processed.min_x-t.processed.max_x*(t.inflator-1),t.x_axis_negative=!0),t.additional_buffer="bar"===t.chart_type?5*t.buffer:0}function ue(t){var e=t.chart_type;t.processed.xax_format||(t.xax_format?t.processed.xax_format=t.xax_format:"line"===e||"point"===e||"histogram"===e?t.processed.xax_format=R(t):"bar"===e&&(t.processed.xax_format=C(t)))}function fe(t){if(t.color_accessor!==!1){t.group_accessor&&null===t.color_accessor&&(t.color_accessor=t.y_accessor);var e=O(t);null!==t.color_accessor&&de(t,e,t.color_accessor)}}function de(e,r,n){e.scales.color=t.scale.category20().domain(r),e.scalefns.color=function(t){return e.scales.color(t[n])}}function pe(e,r){return t.set(e.map(function(t){return t[r]})).values()}function O(e){var r;return null===e.color_domain?"number"===e.color_type?r=t.extent(e.data[0],function(t){return t[e.color_accessor]}):"category"===e.color_type&&(r=pe(e.data[0],e.color_accessor)):r=e.color_domain,r}function T(t){var e;return e=null===t.color_range?"number"===t.color_type?["blue","red"]:null:t.color_range}function me(t){var e={target:null,title:null,description:null};return t||(t={}),t.processed||(t.processed={}),t=vn(t,e)}function _e(t){var e=fn(t.processed.original_data||t.data)[0];t.time_series=e[t.processed.original_x_accessor||t.x_accessor]instanceof Date}function he(t){var e=t.width;t.full_width&&(e=hn(t.target)),t.width=e}function ge(t){var e=t.height;t.full_height&&(e=gn(t.target)),"bar"===t.chart_type&&null===e&&(e=ze(t)),t.height=e}function ve(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 xe(e,r){return un(r.target).empty()&&(e=t.select(r.target).append("svg").classed("linked",r.linked).attr("width",r.width).attr("height",r.height)),e}function ye(t,e){t.selectAll(".mg-clip-path").remove(),t.append("defs").attr("class","mg-clip-path").append("clipPath").attr("id","mg-plot-window-"+pn(e.target)).append("svg:rect").attr("x",Hr(e)).attr("y",Rr(e)).attr("width",e.width-e.left-e.right-e.buffer).attr("height",e.height-e.top-e.bottom-e.buffer+1)}function be(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 we(t,e){t.attr("viewBox","0 0 "+e.width+" "+e.height),(e.full_width||e.full_height)&&t.attr("preserveAspectRatio","xMinYMin meet")}function ke(t){t.classed("mg-missing",!1),t.selectAll(".mg-missing-text").remove(),t.selectAll(".mg-missing-pane").remove()}function Me(t,e){var r=0;if(t.selectAll(".mg-main-line")[0].length>=e.data.length)if(e.custom_line_color_map.length>0){var n=function(t){for(var e=new Array(t),r=0;r<e.length;r++)e[r]=r+1;return e},a=xn(n(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 o=e.data.length,i=t.selectAll(".mg-main-line")[0].length;for(r=i;r>o;r--)t.selectAll(".mg-main-line.mg-line"+r+"-color").remove()}}function Ae(t,e){return t.empty()?void console.warn('The specified target element "'+e.target+'" could not be found in the page. The chart will not be rendered.'):void 0}function Ge(t){Oe(t),Te(t),Ye(t),t.height&&De(t)}function Oe(e){if(e.categorical_groups=[],e.group_accessor){var r=e.data[0];e.categorical_groups=t.set(r.map(function(t){return t[e.group_accessor]})).values()}}function Te(e){if(e.total_bars=e.data[0].length,e.group_accessor){var r=Lr(Nr(e.data[0],e.group_accessor));r=t.max(Object.keys(r).map(function(t){return r[t]})),e.bars_per_group=r}else e.bars_per_group=e.data[0].length}function Ye(t){if(t.height)t.group_height=(t.height-t.top-t.bottom-2*t.buffer)/(t.categorical_groups.length||1);else{var e=(1+t.bar_padding_percentage)*t.bar_thickness;t.group_height=t.bars_per_group*e+2*t.bar_outer_padding_percentage*e}}function De(t){var e=t.group_height/(t.bars_per_group+t.bar_outer_padding_percentage);t.bar_thickness=e-e*t.bar_padding_percentage}function ze(t){return t.group_height*(t.categorical_groups.length||1)+t.top+t.bottom+2*t.buffer+t.categorical_groups.length*t.group_height*(t.group_padding_percentage+t.group_outer_padding_percentage)}function Ee(e){"use strict";e=arguments[0],e=me(e);var r=t.select(e.target);Ae(r,e);var a=r.selectAll("svg");return"bar"===e.chart_type&&Ge(e),_e(e),he(e),ge(e),ve(a,e),a=xe(a,e),ye(a,e),be(a,e),we(a,e),ke(a),n(e),Me(a,e),this}function Ce(t){return t.label}function Xe(t){t.selectAll(".mg-markers").remove(),t.selectAll(".mg-baselines").remove()}function Pe(t){return function(e){return t.scales.X(e[t.x_accessor])>Ur(t)&&t.scales.X(e[t.x_accessor])<Wr(t)}}function Fe(t){return function(e){return t.scales.X(e[t.x_accessor])}}function je(t){var e=Fe(t);return function(t){return e(t).toFixed(2)}}function $e(t){var e=t.scales.Y;return function(t){return e(t.value).toFixed(2)}}function Se(t,e,r,n,a,o){var i;t&&(i=n.append("g").attr("class",e),a(i,r),o(i,r))}function Ne(t,e){Se(t.markers,"mg-markers",t,e,Be,Ie)}function Le(t,e){Se(t.baselines,"mg-baselines",t,e,Re,qe)}function Be(t,e){var r=je(e);t.selectAll(".mg-markers").data(e.markers.filter(Pe(e))).enter().append("line").attr("x1",r).attr("x2",r).attr("y1",e.top).attr("y2",Ir(e)).attr("class",function(t){return t.lineclass}).attr("stroke-dasharray","3,1")}function Ie(e,r){e.selectAll(".mg-markers").data(r.markers.filter(Pe(r))).enter().append("text").attr("class",function(t){return t.textclass||""}).classed("mg-marker-text",!0).attr("x",Fe(r)).attr("y",.95*r.top).attr("text-anchor","middle").text(Ce).each(function(e){e.click&&t.select(this).style("cursor","pointer").on("click",e.click)}),on(e.selectAll(".mg-marker-text")[0],r)}function Re(t,e){var r=$e(e);t.selectAll(".mg-baselines").data(e.baselines).enter().append("line").attr("x1",Ur(e)).attr("x2",Wr(e)).attr("y1",r).attr("y2",r)}function qe(t,e){var r=$e(e);t.selectAll(".mg-baselines").data(e.baselines).enter().append("text").attr("x",Wr(e)).attr("y",r).attr("dy",-3).attr("text-anchor","end").text(Ce)}function He(t){"use strict";var e=un(t.target);return Xe(e),Ne(t,e),Le(t,e),this}function Ue(t){t.selectAll(".mg-active-datapoint-container").selectAll("*").remove()}function Qe(e,r){e.select(".mg-active-datapoint").remove();var n="right"===r.mouseover_align?"end":"left"===r.mouseover_align?"start":"middle",a="right"===r.mouseover_align?Wr(r):"left"===r.mouseover_align?Ur(r):(r.width-r.left-r.right)/2+r.left,o=e.select(".mg-active-datapoint-container").append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("text-anchor",n),i=.75;if(r.markers){var s;e.selectAll(".mg-marker-text").each(function(){s?s!==t.select(this).attr("y")&&(i=.56):s=t.select(this).attr("y")})}o.attr("transform","translate("+a+","+Rr(r)*i+")")}function We(t,e){var r="",n=null;return 3===arguments.length&&(n=arguments[2]),r=t.append("tspan").text(e),null!==n&&r.classed(n,!0),this.tspan=r,this.bold=function(){return this.tspan.attr("font-weight","bold"),this},this.font_size=function(t){return this.tspan.attr("font-size",t),this},this.x=function(t){return this.tspan.attr("x",t),this},this.y=function(t){return this.tspan.attr("y",t),this},this.elem=function(){return this.tspan},this}function Ze(t){var e=t.select(".mg-active-datapoint");return e.selectAll("*").remove(),e}function Ve(t,e,r){var n=1.1;this.rargs=r;var a=e.append("tspan").attr("x",0).attr("y",t*n+"em");return this.text=function(t){return We(a,t)},this}function Ke(t,e){return this.row_number=0,this.rargs=e,Qe(e.svg,t),this.text_container=Ze(e.svg),this.mouseover_row=function(t){var e=this,r=Ve(e.row_number,e.text_container,t);return e.row_number+=1,r},this}function Je(){function e(){a.forEach(function(e){var r=t.select(e).select("svg");if(!r.empty()){var n=0!==r.attr("width")?r.attr("height")/r.attr("width"):0,a=hn(e);r.attr("width",a),r.attr("height",n*a)}})}function r(t){var r=a.indexOf(t);-1!==r&&a.splice(r,1),0===a.length&&window.removeEventListener("resize",e,!0)}var n,a=[];return"undefined"!=typeof MutationObserver?n=MutationObserver:"undefined"!=typeof WebKitMutationObserver&&(n=WebKitMutationObserver),{add_target:function(o){if(0===a.length&&window.addEventListener("resize",e,!0),-1===a.indexOf(o)&&(a.push(o),n)){var i=new n(function(e){var n=t.select(o).node();(!n||e.some(function(t){for(var e=0;e<t.removedNodes.length;e++)if(t.removedNodes[e]===n)return!0}))&&(i.disconnect(),r(o))});i.observe(t.select(o).node().parentNode,{childList:!0})}}}}function tr(t){er(t)}function er(t){(t.full_width||t.full_height)&&An.add_target(t.target)}function rr(t,e,r){var n=Ke(t,{svg:e}),a=n.mouseover_row();if(null!==t.color_accessor&&"category"===t.color_type){var o=r[t.color_accessor];a.text(o+" ").bold().elem().attr("fill",t.scalefns.color(r))}nr(t,a.text("● ").elem(),r),a.text(Or(t,r)),a.text(Tr(t,r,t.time_series===!1))}function nr(t,e,r){null!==t.color_accessor?(e.attr("fill",t.scalefns.color(r)),e.attr("stroke",t.scalefns.color(r))):e.classed("mg-points-mono",!0)}function ar(t,e){function r(t){return 1e3===t?3:1e6===t?7:Math.log(t)/Math.LN10}var n,a,o;"x"===e?(n=t.x_accessor,a=t.scales.X.ticks(t.xax_count),o=t.processed.max_x):"y"===e&&(n=t.y_accessor,a=t.scales.Y.ticks(t.yax_count),o=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(r(t))%1<1e-6||Math.abs(r(t))%1>1-1e-6}));var i=a.length,s=!0;t.data.forEach(function(t){t.forEach(function(t){return t[n]%1!==0?(s=!1,!1):void 0})}),s&&i>o&&"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 or(t){"use strict";if(t.data=MG.clone(t.data),t.single_object=!1,t.array_of_objects=!1,t.array_of_arrays=!1,t.nested_array_of_arrays=!1,t.nested_array_of_objects=!1,jr(t.data)?(t.nested_array_of_objects=t.data.map(function(t){return Sr(t)}),t.nested_array_of_arrays=t.data.map(function(t){return jr(t)})):(t.array_of_objects=$r(t.data),t.array_of_arrays=jr(t.data)),"line"===t.chart_type?(t.array_of_objects||t.array_of_arrays)&&(t.data=[t.data]):t.data[0]instanceof Array||(t.data=[t.data]),sr(t),lr(t),void 0!==t.color&&(t.colors=t.color),null!==t.colors&&"string"==typeof t.colors&&(t.colors=[t.colors]),"line"===t.chart_type&&t.x_sort===!0)for(var e=0;e<t.data.length;e++)t.data[e].sort(function(e,r){return e[t.x_accessor]-r[t.x_accessor]});return this}function ir(t,e){t[e]instanceof Array&&(t.data=t.data.map(function(r){return t[e].map(function(t){return r.map(function(r){return r=MG.clone(r),void 0===r[t]?void 0:(r["multiline_"+e]=r[t],r)}).filter(function(t){return void 0!==t})})})[0],t[e]="multiline_"+e)}function sr(t){ir(t,"x_accessor")}function lr(t){ir(t,"y_accessor")}function cr(e){"use strict";var r,n=t.sum(e.data.map(function(t){return t.length>0&&t[0][e.x_accessor]instanceof Date}))>0;if(e.missing_is_hidden&&(e.interpolate="linear"),(e.missing_is_zero||e.missing_is_hidden)&&"line"===e.chart_type&&n)for(var a=0;a<e.data.length;a++)if(!(e.data[a].length<=1)){var o=e.data[a][0],i=e.data[a][e.data[a].length-1],s=[],l=MG.clone(o[e.x_accessor]).setDate(o[e.x_accessor].getDate()+1),c=e.min_x?e.min_x:l,u=e.max_x?e.max_x:i[e.x_accessor];if(r=X((u-c)/1e3),"default"==r&&null===e.missing_is_hidden_accessor)for(var f=new Date(c);u>=f;f.setDate(f.getDate()+1)){var d={};f.setHours(0,0,0,0),Date.parse(f)===Date.parse(new Date(l))&&s.push(MG.clone(e.data[a][0]));var p=null;e.data[a].forEach(function(t){return Date.parse(t[e.x_accessor])===Date.parse(new Date(f))?(p=t,!1):void 0}),p?p[e.missing_is_hidden_accessor]||null===p[e.y_accessor]?(p._missing=!0,s.push(p)):s.push(p):(d[e.x_accessor]=new Date(f),d[e.y_accessor]=0,d._missing=!0,s.push(d))}else for(var m=0;m<e.data[a].length;m+=1){var _=MG.clone(e.data[a][m]);_._missing=e.data[a][m][e.missing_is_hidden_accessor],s.push(_)}e.data[a]=s}return this}function ur(e){"use strict";var r,n=e.data[0];if(e.binned===!1){if("object"==typeof n[0])r=n.map(function(t){return t[e.x_accessor]});else{if("number"!=typeof n[0])return void console.log("TypeError: expected an array of numbers, found "+typeof n[0]);r=n}var a=t.layout.histogram();e.bins&&(a=a.bins(e.bins)),e.processed_data=a(r).map(function(t){return{x:t.x,y:t.y,dx:t.dx}})}else{e.processed_data=n.map(function(t){return{x:t[e.x_accessor],y:t[e.y_accessor]}});for(var o,i,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 fr(e){"use strict";var r,n={},a="vertical"===e.bar_orientation?e.x_accessor:e.y_accessor,o="vertical"===e.bar_orientation?e.y_accessor:e.x_accessor;if(e.binned===!1){e.categorical_variables=[],r="object"==typeof our_data[0]?our_data.map(function(t){return t[a]}):our_data;for(var i,s=0;s<r.length;s++)i=r[s],-1===e.categorical_variables.indexOf(i)&&e.categorical_variables.push(i),n.hasOwnProperty(i)||(n[i]=0),n[i]+=1;n=Object.keys(n).map(function(t){var e={};return e[o]=n[t],e[a]=t,e})}else n=e.data[0],e.categorical_variables=t.set(n.map(function(t){return t[a]})).values(),e.categorical_variables.reverse();return e.data=[n],this}function dr(t){"use strict";var e=t.data[0],r=e.map(function(e){return e[t.x_accessor]}),n=e.map(function(e){return e[t.y_accessor]});return t.least_squares&&(t.ls_line=gr(r,n)),this}function pr(e){var r=un(e.target),n=e.data[0],a=t.min(n,function(t){return t[e.x_accessor]}),o=t.max(n,function(t){return t[e.x_accessor]});t.select(e.target).selectAll(".mg-least-squares-line").remove(),r.append("svg:line").attr("x1",e.scales.X(a)).attr("x2",e.scales.X(o)).attr("y1",e.scales.Y(e.ls_line.fit(a))).attr("y2",e.scales.Y(e.ls_line.fit(o))).attr("class","mg-least-squares-line")}function mr(r){var n=t.select(e(r.target).find("svg").get(0)),a=r.lowess_line,o=t.svg.line().x(function(t){return r.scales.X(t.x)}).y(function(t){return r.scales.Y(t.y)}).interpolate(r.interpolate);n.append("path").attr("d",o(a)).attr("class","mg-lowess-line")}function _r(e,r,n,a){{var o,i,s=[];t.mean(r)}for(i=0;i<e.length;i+=1)s.push(1);o=Mr(e,r,n,a,s);var l=o.x,c=o.y;for(i=0;100>i;i+=1){s=t.zip(c,r).map(function(t){return Math.abs(t[1]-t[0])});var u=t.quantile(s.sort(),.5);s=s.map(function(t){return xr(t/(6*u))}),o=Mr(e,r,n,a,s),l=o.x,c=o.y}return t.zip(l,c).map(function(t){var e={};return e.x=t[0],e.y=t[1],e})}function hr(t,e,r,n){for(var a=[],o=0;o<t.length;o+=1)a.push(1);Mr(t,e,r,n,a)}function gr(e,r){{var n,a,o,i;e.length}n=e[0]instanceof Date?e.map(function(t){return t.getTime()}):e,a=r[0]instanceof Date?r.map(function(t){return t.getTime()}):r;for(var s=t.mean(n),l=t.mean(a),c=0,u=0,f=0;f<n.length;f++)o=n[f],i=a[f],c+=(o-s)*(i-l),u+=(o-s)*(o-s);var d=c/u,p=l-d*s;return{x0:p,beta:d,fit:function(t){return p+t*d}}}function vr(t,e){return t>=0&&1>=t?Math.pow(1-Math.pow(t,e),e):0}function xr(t){return vr(t,2)}function yr(t){return vr(t,3)}function br(e){var r=t.sum(e.map(function(t){return t.w}));return{xbar:t.sum(e.map(function(t){return t.w*t.x}))/r,ybar:t.sum(e.map(function(t){return t.w*t.y}))/r}}function wr(e,r,n){var a=t.sum(e.map(function(t){return Math.pow(t.w,2)*(t.x-r)*(t.y-n)})),o=t.sum(e.map(function(t){return Math.pow(t.w,2)*Math.pow(t.x-r,2)}));return a/o}function kr(t){var e,r,n=br(t);r=n.xbar,e=n.ybar;var a=wr(t,r,e);return{beta:a,xbar:r,ybar:e,x0:e-a*r}}function Mr(e,r,n,a,o){var i=Math.floor(e.length*n),s=e.slice();s.sort(function(t,e){return e>t?-1:t>e?1:0});for(var l,c,u,f,d,p=t.quantile(s,.98),m=t.quantile(s,.02),_=t.zip(e,r,o).sort(),h=Math.abs(p-m)/a,g=m,v=p,x=t.range(g,v,h),y=[],b=0;b<x.length;b+=1){c=x[b],l=_.map(function(t){return[Math.abs(t[0]-c),t[0],t[1],t[2]]}).sort().slice(0,i),d=t.max(l)[0],l=l.map(function(t){return{w:yr(t[0]/d)*t[3],x:t[1],y:t[2]}});var w=kr(l);f=w.x0,u=w.beta,y.push(f+u*c)}return{x:x,y:y}}function Ar(e){var r;return r="count"===e.format?function(r){var n=r%1!==0,a=t.format("0,000");return r=n?t.round(r,e.decimals):r,a(r)}:function(r){var n=(e.decimals?"."+e.decimals:"")+"%",a=t.format(n);return a(r)}}function Gr(t,e,r,n,a){var o,i=MG.time_format(t.utc_time,"%b %e, %Y"),s=Ar(t);return o=null!==r?a?Gn(r,e,n,t.utc):On(r,e,n):a?i(new Date(+e[n]))+" ":(t.time_series?"":n+": ")+s(e[n])+" "
}function Or(t,e){return Gr(t,e,t.x_mouseover,t.x_accessor,t.time_series)}function Tr(t,e){return Gr(t,e,t.y_mouseover,t.y_accessor,!1)}function Yr(t,e){return Gr(t,e,t.x_mouseover,"key",t.time_series)}function Dr(e,r){return function(){for(var n=this,a=n.cloneNode(),o=n.getTotalLength()||0,i=(a.setAttribute("d",e),a).getTotalLength()||0,s=[0],l=0,c=r/Math.max(o,i);(l+=c)<1;)s.push(l);s.push(1);var u=s.map(function(e){var r=n.getPointAtLength(e*o),s=a.getPointAtLength(e*i);return t.interpolate([r.x,r.y],[s.x,s.y])});return function(t){return 1>t?"M"+u.map(function(e){return e(t)}).join("L"):e}}}function zr(t){var e;switch(t.processed.x_time_frame){case"millis":e=MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S.%L");break;case"seconds":e=MG.time_format(t.utc_time,"%b %e, %Y %H:%M:%S");break;case"less-than-a-day":e=MG.time_format(t.utc_time,"%b %e, %Y %I:%M%p");break;case"four-days":e=MG.time_format(t.utc_time,"%b %e, %Y %I:%M%p");break;default:e=MG.time_format(t.utc_time,"%b %e, %Y")}return e}function Er(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 Cr(t){return"[object Array]"===Object.prototype.toString.call(t)}function Xr(t){return"[object Function]"===Object.prototype.toString.call(t)}function Pr(t){return Cr(t)&&0===t.length}function Fr(t){return"[object Object]"===Object.prototype.toString.call(t)}function jr(e){var r=e.map(function(t){return Cr(t)===!0&&t.length>0});return t.sum(r)===e.length}function $r(e){var r=e.map(function(t){return Fr(t)===!0});return t.sum(r)===e.length}function Sr(t){return Pr(t)||$r(t)}function Nr(t,e){return t.map(function(t){return t[e]})}function Lr(t){return t.reduce(function(t,e){return t[e]=t[e]+1||1,t},{})}function Br(t){return t.height-t.bottom}function Ir(t){return Br(t)-t.buffer}function Rr(t){return t.top}function qr(t){return Rr(t)+t.buffer}function Hr(t){return t.left}function Ur(t){return Hr(t)+t.buffer}function Qr(t){return t.width-t.right}function Wr(t){return Qr(t)-t.buffer}function Zr(t){t.exit().remove()}function Vr(t,e){t.selectAll(e).remove()}function Kr(t,e){return t.append("g").classed(e,!0)}function Jr(t,e){var r=un(t.target),n=fn(t.data),a=r.selectAll("line."+e).data(n);return a.enter().append("svg:line").attr("class",e).attr("opacity",.3),Zr(a),Zr(a),a}function tn(t,e,r,n){t.scalefns[e]=function(e){return t.scales[r](e[n])}}function en(t,e,r){e.color_accessor?(t.attr("stroke",e.scalefns.color),t.classed(r,!1)):(t.attr("stroke",null),t.classed(r,!0))}function rn(e,r,n,a,o,i,s){e.scales[r]=t.scale.ordinal().domain(n).rangeBands([a,o],i,s)}function nn(e,r){r&&e.attr({dy:0,transform:function(){var e=t.select(this);return"rotate("+r+" "+e.attr("x")+","+e.attr("y")+")"}})}function an(t){t=t[0];for(var e=0;e<t.length;e++)if(cn(t[e],t))return!0;return!1}function on(e,r){if(e&&1!=e.length)for(var n=0;n<e.length;n++)if(cn(e[n],e)){var a=t.select(e[n]),o=+a.attr("y");o+8>=r.top&&(o=r.top-16),a.attr("y",o)}}function sn(e){if(e&&1!=e.length){e.sort(function(e,r){return t.select(r).attr("y")-t.select(e).attr("y")}),e.reverse();for(var r,n,a,o=0;o<e.length;o++){n=t.select(e[o]).text();for(var i=0;i<e.length;i++)if(a=t.select(e[i]).text(),r=ln(e[o],e[i]),r!==!1&&n!==a){var s=t.select(e[o]),l=+s.attr("y");l+=r,s.attr("y",l)}}}}function ln(t,e){var r=t.getBoundingClientRect(),n=e.getBoundingClientRect();return r.top<=n.bottom&&r.top>=n.top?n.bottom-r.top:!1}function cn(t,e){for(var r=t.getBoundingClientRect(),n=0;n<e.length;n++)if(e[n]!=t){var a=e[n].getBoundingClientRect();if(r.top===a.top&&!(a.left>r.right||a.right<r.left))return!0}return!1}function un(e){return t.select(e).select("svg")}function fn(t){var e=[];return e.concat.apply(e,t)}function dn(){return"undefined"==typeof MG._next_elem_id&&(MG._next_elem_id=0),"mg-"+MG._next_elem_id++}function pn(t){return"string"==typeof t?mn(t):t instanceof HTMLElement?(target_ref=t.getAttribute("data-mg-uid"),target_ref||(target_ref=dn(),t.setAttribute("data-mg-uid",target_ref)),target_ref):(console.warn("The specified target should be a string or an HTMLElement.",t),mn(t))}function mn(t){return t.replace(/[^a-zA-Z0-9 _-]+/g,"").replace(/ +?/g,"")}function _n(e,r){return Number(t.select(e).style(r).replace(/px/g,""))}function hn(t){return _n(t,"width")}function gn(t){return _n(t,"height")}function vn(t){return Tn(Array.prototype.slice.call(arguments,1),function(e){if(e)for(var r in e)void 0===t[r]&&(t[r]=e[r])}),t}function xn(t,e){var r,n=[],a=[];for(r=0;r<e.length;r++)n[e[r]]=!0;for(r=0;r<t.length;r++)n[t[r]]||a.push(t[r]);return a}function yn(t,e){console.warn("Deprecation: "+t+(e?". This feature will be removed in "+e+".":" the near future.")),console.trace()}function bn(t,e,r){var n,a=0;for(t.textContent=e,n=t.getBBox();n.width>r&&(t.textContent=e.slice(0,--a)+"...",n=t.getBBox(),"..."!==t.textContent););}function wn(e,r,n,a){e.each(function(){for(var e,o=t.select(this),i=o.text().split(n||/\s+/).reverse(),s=[],l=0,c=1.1,u=(o.attr("y"),0),f=o.text(null).append("tspan").attr("x",0).attr("y",u+"em").attr(a||{});e=i.pop();)s.push(e),f.text(s.join(" ")),(null===r||f.node().getComputedTextLength()>r)&&(s.pop(),f.text(s.join(" ")),s=[e],f=o.append("tspan").attr("x",0).attr("y",++l*c+u+"em").attr(a||{}).text(e))})}function kn(e){console.log("ERROR : ",e.target," : ",e.error),t.select(e.target).select(".mg-chart-title").append("i").attr("class","fa fa-x fa-exclamation-circle warning")}function Mn(t){console.log("INTERNAL ERROR : ",t.target," : ",t.internal_error)}window.MG={version:"2.8.0"},MG.register=r,MG._hooks={},MG.add_hook=function(t,e,r){var n;MG._hooks[t]||(MG._hooks[t]=[]),n=MG._hooks[t];var a=n.filter(function(t){return t.func===e}).length>0;if(a)throw"That function is already registered.";n.push({func:e,context:r})},MG.call_hook=function(t){var e,r=MG._hooks[t],n=[].slice.apply(arguments,[1]);return r&&r.forEach(function(t){if(t.func){var r=e||n;r&&r.constructor!==Array&&(r=[r]),r=[].concat.apply([],r),e=t.func.apply(t.context,r)}}),e||n},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"}},MG.globals.link=!1,MG.globals.version="1.1",MG.charts={},MG.data_graphic=function(t){"use strict";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,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:5,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,x_accessor:"date",xax_units:"",x_label:"",x_sort:!0,x_axis:!0,y_axis:!0,y_accessor:"value",y_label:"",yax_units:"",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,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:"cardinal",interpolate_tension:.7,custom_line_color_map:[],colors:null,max_data_size:null,aggregate_rollover:!1,show_tooltips:!0};MG.call_hook("global.defaults",e),t||(t={});var r=MG.charts[t.chart_type||e.chart_type];vn(t,r.defaults,e),t.list&&(t.x_accessor=0,t.y_accessor=1);for(var n in MG.deprecations)if(t.hasOwnProperty(n)){var a=MG.deprecations[n],o="Use of `args."+n+"` has been deprecated",i=a.replacement;if(i&&(t[i]?o+=". The replacement - `args."+i+"` - has already been defined. This definition will be discarded.":t[i]=t[n]),a.warned)continue;a.warned=!0,i&&(o+=" in favor of `args."+i+"`"),yn(o,a.version)}return MG.call_hook("global.before_init",t),new r.descriptor(t),t.data},"undefined"!=typeof jQuery&&(+function(t){"use strict";function e(e){return this.each(function(){var n=t(this),a=n.data("bs.tooltip"),o="object"==typeof e&&e;(a||!/destroy|hide/.test(e))&&(a||n.data("bs.tooltip",a=new r(this,o)),"string"==typeof e&&a[e]())})}var r=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)};r.VERSION="3.3.5",r.TRANSITION_DURATION=150,r.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}},r.prototype.init=function(e,r,n){if(this.enabled=!0,this.type=e,this.$element=t(r),this.options=this.getOptions(n),this.$viewport=this.options.viewport&&t(t.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(" "),o=a.length;o--;){var i=a[o];if("click"==i)this.$element.on("click."+this.type,this.options.selector,t.proxy(this.toggle,this));else if("manual"!=i){var s="hover"==i?"mouseenter":"focusin",l="hover"==i?"mouseleave":"focusout";this.$element.on(s+"."+this.type,this.options.selector,t.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,t.proxy(this.leave,this))}}this.options.selector?this._options=t.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},r.prototype.getDefaults=function(){return r.DEFAULTS},r.prototype.getOptions=function(e){return e=t.extend({},this.getDefaults(),this.$element.data(),e),e.delay&&"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),e},r.prototype.getDelegateOptions=function(){var e={},r=this.getDefaults();return this._options&&t.each(this._options,function(t,n){r[t]!=n&&(e[t]=n)}),e},r.prototype.enter=function(e){var r=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return r||(r=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,r)),e instanceof t.Event&&(r.inState["focusin"==e.type?"focus":"hover"]=!0),r.tip().hasClass("in")||"in"==r.hoverState?void(r.hoverState="in"):(clearTimeout(r.timeout),r.hoverState="in",r.options.delay&&r.options.delay.show?void(r.timeout=setTimeout(function(){"in"==r.hoverState&&r.show()},r.options.delay.show)):r.show())},r.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},r.prototype.leave=function(e){var r=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return r||(r=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,r)),e instanceof t.Event&&(r.inState["focusout"==e.type?"focus":"hover"]=!1),r.isInStateTrue()?void 0:(clearTimeout(r.timeout),r.hoverState="out",r.options.delay&&r.options.delay.hide?void(r.timeout=setTimeout(function(){"out"==r.hoverState&&r.hide()},r.options.delay.hide)):r.hide())},r.prototype.show=function(){var e=t.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(e);var n=t.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(e.isDefaultPrevented()||!n)return;var a=this,o=this.tip(),i=this.getUID(this.type);this.setContent(),o.attr("id",i),this.$element.attr("aria-describedby",i),this.options.animation&&o.addClass("fade");var s="function"==typeof this.options.placement?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,l=/\s?auto?\s?/i,c=l.test(s);c&&(s=s.replace(l,"")||"top"),o.detach().css({top:0,left:0,display:"block"}).addClass(s).data("bs."+this.type,this),this.options.container?o.appendTo(this.options.container):o.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var u=this.getPosition(),f=o[0].offsetWidth,d=o[0].offsetHeight;if(c){var p=s,m=this.getPosition(this.$viewport);s="bottom"==s&&u.bottom+d>m.bottom?"top":"top"==s&&u.top-d<m.top?"bottom":"right"==s&&u.right+f>m.width?"left":"left"==s&&u.left-f<m.left?"right":s,o.removeClass(p).addClass(s)}var _=this.getCalculatedOffset(s,u,f,d);this.applyPlacement(_,s);var h=function(){var t=a.hoverState;a.$element.trigger("shown.bs."+a.type),a.hoverState=null,"out"==t&&a.leave(a)};t.support.transition&&this.$tip.hasClass("fade")?o.one("bsTransitionEnd",h).emulateTransitionEnd(r.TRANSITION_DURATION):h()}},r.prototype.applyPlacement=function(e,r){var n=this.tip(),a=n[0].offsetWidth,o=n[0].offsetHeight,i=parseInt(n.css("margin-top"),10),s=parseInt(n.css("margin-left"),10);isNaN(i)&&(i=0),isNaN(s)&&(s=0),e.top+=i,e.left+=s,t.offset.setOffset(n[0],t.extend({using:function(t){n.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0),n.addClass("in");var l=n[0].offsetWidth,c=n[0].offsetHeight;"top"==r&&c!=o&&(e.top=e.top+o-c);var u=this.getViewportAdjustedDelta(r,e,l,c);u.left?e.left+=u.left:e.top+=u.top;var f=/top|bottom/.test(r),d=f?2*u.left-a+l:2*u.top-o+c,p=f?"offsetWidth":"offsetHeight";n.offset(e),this.replaceArrow(d,n[0][p],f)},r.prototype.replaceArrow=function(t,e,r){this.arrow().css(r?"left":"top",50*(1-t/e)+"%").css(r?"top":"left","")},r.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")},r.prototype.hide=function(e){function n(){"in"!=a.hoverState&&o.detach(),a.$element.removeAttr("aria-describedby").trigger("hidden.bs."+a.type),e&&e()}var a=this,o=t(this.$tip),i=t.Event("hide.bs."+this.type);return this.$element.trigger(i),i.isDefaultPrevented()?void 0:(o.removeClass("in"),t.support.transition&&o.hasClass("fade")?o.one("bsTransitionEnd",n).emulateTransitionEnd(r.TRANSITION_DURATION):n(),this.hoverState=null,this)},r.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","")},r.prototype.hasContent=function(){return this.getTitle()},r.prototype.getPosition=function(e){e=e||this.$element;var r=e[0],n="BODY"==r.tagName,a=r.getBoundingClientRect();null==a.width&&(a=t.extend({},a,{width:a.right-a.left,height:a.bottom-a.top}));var o=n?{top:0,left:0}:e.offset(),i={scroll:n?document.documentElement.scrollTop||document.body.scrollTop:e.scrollTop()},s=n?{width:t(window).width(),height:t(window).height()}:null;return t.extend({},a,i,s,o)},r.prototype.getCalculatedOffset=function(t,e,r,n){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-r/2}:"top"==t?{top:e.top-n,left:e.left+e.width/2-r/2}:"left"==t?{top:e.top+e.height/2-n/2,left:e.left-r}:{top:e.top+e.height/2-n/2,left:e.left+e.width}},r.prototype.getViewportAdjustedDelta=function(t,e,r,n){var a={top:0,left:0};if(!this.$viewport)return a;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,l=e.top+o-i.scroll+n;s<i.top?a.top=i.top-s:l>i.top+i.height&&(a.top=i.top+i.height-l)}else{var c=e.left-o,u=e.left+o+r;c<i.left?a.left=i.left-c:u>i.right&&(a.left=i.left+i.width-u)}return a},r.prototype.getTitle=function(){var t,e=this.$element,r=this.options;return t=e.attr("data-original-title")||("function"==typeof r.title?r.title.call(e[0]):r.title)},r.prototype.getUID=function(t){do t+=~~(1e6*Math.random());while(document.getElementById(t));return t},r.prototype.tip=function(){if(!this.$tip&&(this.$tip=t(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},r.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},r.prototype.enable=function(){this.enabled=!0},r.prototype.disable=function(){this.enabled=!1},r.prototype.toggleEnabled=function(){this.enabled=!this.enabled},r.prototype.toggle=function(e){var r=this;e&&(r=t(e.currentTarget).data("bs."+this.type),r||(r=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,r))),e?(r.inState.click=!r.inState.click,r.isInStateTrue()?r.enter(r):r.leave(r)):r.tip().hasClass("in")?r.leave(r):r.enter(r)},r.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 n=t.fn.tooltip;t.fn.tooltip=e,t.fn.tooltip.Constructor=r,t.fn.tooltip.noConflict=function(){return t.fn.tooltip=n,this}}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var n=t(this),a=n.data("bs.popover"),o="object"==typeof e&&e;(a||!/destroy|hide/.test(e))&&(a||n.data("bs.popover",a=new r(this,o)),"string"==typeof e&&a[e]())})}var r=function(t,e){this.init("popover",t,e)};if(!t.fn.tooltip)throw new Error("Popover requires tooltip.js");r.VERSION="3.3.5",r.DEFAULTS=t.extend({},t.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>'}),r.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),r.prototype.constructor=r,r.prototype.getDefaults=function(){return r.DEFAULTS},r.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()},r.prototype.hasContent=function(){return this.getTitle()||this.getContent()},r.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)},r.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var n=t.fn.popover;t.fn.popover=e,t.fn.popover.Constructor=r,t.fn.popover.noConflict=function(){return t.fn.popover=n,this}}(jQuery)),MG.chart_title=n,MG.y_rug=a,MG.y_axis=_,MG.y_axis_categorical=x,MG.x_rug=y,MG.x_axis=k,MG.x_axis_categorical=M,MG.init=Ee,MG.markers=He;var An=new Je;"undefined"!=typeof jQuery&&+function(t){"use strict";function e(e){e&&3===e.which||(t(a).remove(),t(o).each(function(){var n=t(this),a=r(n),o={relatedTarget:this};a.hasClass("open")&&(a.trigger(e=t.Event("hide.bs.dropdown",o)),e.isDefaultPrevented()||(n.attr("aria-expanded","false"),a.removeClass("open").trigger("hidden.bs.dropdown",o)))}))}function r(e){var r=e.attr("data-target");r||(r=e.attr("href"),r=r&&/#[A-Za-z]/.test(r)&&r.replace(/.*(?=#[^\s]*$)/,""));var n=r&&t(r);return n&&n.length?n:e.parent()}function n(e){return this.each(function(){var r=t(this),n=r.data("bs.dropdown");n||r.data("bs.dropdown",n=new i(this)),"string"==typeof e&&n[e].call(r)})}if("function"==typeof t().dropdown)return!0;var a=".dropdown-backdrop",o='[data-toggle="dropdown"]',i=function(e){t(e).on("click.bs.dropdown",this.toggle)};i.VERSION="3.3.1",i.prototype.toggle=function(n){var a=t(this);if(!a.is(".disabled, :disabled")){var o=r(a),i=o.hasClass("open");if(e(),!i){"ontouchstart"in document.documentElement&&!o.closest(".navbar-nav").length&&t('<div class="dropdown-backdrop"/>').insertAfter(t(this)).on("click",e);var s={relatedTarget:this};if(o.trigger(n=t.Event("show.bs.dropdown",s)),n.isDefaultPrevented())return;a.trigger("focus").attr("aria-expanded","true"),o.toggleClass("open").trigger("shown.bs.dropdown",s)}return!1}},i.prototype.keydown=function(e){if(/(38|40|27|32)/.test(e.which)&&!/input|textarea/i.test(e.target.tagName)){var n=t(this);if(e.preventDefault(),e.stopPropagation(),!n.is(".disabled, :disabled")){var a=r(n),i=a.hasClass("open");if(!i&&27!=e.which||i&&27==e.which)return 27==e.which&&a.find(o).trigger("focus"),n.trigger("click");var s=" li:not(.divider):visible a",l=a.find('[role="menu"]'+s+', [role="listbox"]'+s);if(l.length){var c=l.index(e.target);38==e.which&&c>0&&c--,40==e.which&&c<l.length-1&&c++,~c||(c=0),l.eq(c).trigger("focus")}}}};var s=t.fn.dropdown;t.fn.dropdown=n,t.fn.dropdown.Constructor=i,t.fn.dropdown.noConflict=function(){return t.fn.dropdown=s,this},t(document).on("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",o,i.prototype.toggle).on("keydown.bs.dropdown.data-api",o,i.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="menu"]',i.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="listbox"]',i.prototype.keydown)}(jQuery),MG.button_layout=function(t){"use strict";return this.target=t,this.feature_set={},this.public_name={},this.sorters={},this.manual=[],this.manual_map={},this.manual_callback={},this._strip_punctuation=function(t){var e=t.replace(/[^a-zA-Z0-9 _]+/g,""),r=e.replace(/ +?/g,"");return r},this.data=function(t){return this._data=t,this},this.manual_button=function(t,e,r){return this.feature_set[t]=e,this.manual_map[this._strip_punctuation(t)]=t,this.manual_callback[t]=r,this},this.button=function(t){return arguments.length>1&&(this.public_name[t]=arguments[1]),arguments.length>2&&(this.sorters[t]=arguments[2]),this.feature_set[t]=[],this},this.callback=function(t){return this._callback=t,this},this.display=function(){var t,r,n,a,o=this._callback,i=this.manual_callback,s=this.manual_map;n=Object.keys(this.feature_set);var l,c=function(e){return t[e]};for(l=0;l<this._data.length;l++){t=this._data[l],r=n.map(c);for(var u=0;u<n.length;u++)a=n[u],-1===this.feature_set[a].indexOf(r[u])&&this.feature_set[a].push(r[u])}for(a in this.feature_set)this.sorters.hasOwnProperty(a)&&this.feature_set[a].sort(this.sorters[a]);e(this.target).empty(),e(this.target).append("<div class='col-lg-12 segments text-center'></div>");var f=function(){var t,r=e(this).data("key"),n=e(this).data("feature");return e("."+n+"-btns button.btn span.title").html(r),s.hasOwnProperty(n)?(t=s[n],i[t](r)):o(n,r),!1};for(var d in this.feature_set){for(n=this.feature_set[d],e(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>"),l=0;l<n.length;l++)"all"!==n[l]&&void 0!==n[l]&&e(this.target+" div."+this._strip_punctuation(d)+"-btns ul.dropdown-menu").append('<li><a href="#" data-feature="'+this._strip_punctuation(d)+'" data-key="'+n[l]+'">'+n[l]+"</a></li>");e("."+this._strip_punctuation(d)+"-btns .dropdown-menu li a").on("click",f)}return this},this},function(){"use strict";function e(t,e,r){t.classed("mg-hover-line"+e.line_id+"-color",null===r.colors).attr("fill",null===r.colors?"":r.colors[e.line_id-1])}function r(t,e,r){i(t,e),a(t,e),o(t,e),n(t,e,r)}function n(e,r,n){r.existing_band=n.selectAll(".mg-confidence-band"),e.show_confidence_band&&(r.confidence_area=t.svg.area().defined(r.line.defined()).x(e.scalefns.xf).y0(function(t){var r=e.show_confidence_band[0];return e.scales.Y(t[r]?t[r]:t[e.y_accessor])}).y1(function(t){var r=e.show_confidence_band[1];return e.scales.Y(t[r]?t[r]:t[e.y_accessor])}).interpolate(e.interpolate).tension(e.interpolate_tension))}function a(e,r){r.area=t.svg.area().defined(r.line.defined()).x(e.scalefns.xf).y0(e.scales.Y.range()[0]).y1(e.scalefns.yf).interpolate(e.interpolate).tension(e.interpolate_tension)}function o(e,r){r.flat_line=t.svg.line().defined(function(t){return(void 0===t._missing||t._missing!==!0)&&null!==t[e.y_accessor]}).x(e.scalefns.xf).y(function(){return e.scales.Y(r.data_median)}).interpolate(e.interpolate).tension(e.interpolate_tension)}function i(e,r){r.line=t.svg.line().x(e.scalefns.xf).y(e.scalefns.yf).interpolate(e.interpolate).tension(e.interpolate_tension),e.missing_is_zero||(r.line=r.line.defined(function(t){return(void 0===t._missing||t._missing!==!0)&&null!==t[e.y_accessor]}))}function s(t,e,r,n){if(t.show_confidence_band){var a;r.select(".mg-confidence-band-"+n).empty()&&r.append("path").attr("class","mg-confidence-band mg-confidence-band-"+n),a=r.select(".mg-confidence-band-"+n),a.transition().duration(function(){return t.transition_on_update?1e3:0}).attr("d",e.confidence_area(t.data[n-1])).attr("clip-path","url(#mg-plot-window-"+pn(t.target)+")")}}function l(t,e,r,n,a){var o=r.selectAll(".mg-main-area.mg-area"+a);e.display_area?o.empty()?r.append("path").classed("mg-main-area",!0).classed("mg-area"+a,!0).classed("mg-area"+a+"-color",null===t.colors).attr("d",e.area(t.data[n])).attr("fill",null===t.colors?"":t.colors[a-1]).attr("clip-path","url(#mg-plot-window-"+pn(t.target)+")"):(r.node().appendChild(o.node()),o.transition().duration(e.update_transition_duration).attr("d",e.area(t.data[n])).attr("clip-path","url(#mg-plot-window-"+pn(t.target)+")")):o.empty()||o.remove()}function c(t,e){t.classed("mg-line"+e+"-color",!0)}function u(t,e,r,n){t.colors&&t.colors.constructor===Array?(e.attr("stroke",t.colors[r]),t.colors.length<r+1&&c(e,n)):c(e,n)}function f(e,r,n,a){e.animate_on_load?(r.data_median=t.median(e.data[a],function(t){return t[e.y_accessor]}),n.attr("d",r.flat_line(e.data[a])).transition().duration(1e3).attr("d",r.line(e.data[a])).attr("clip-path","url(#mg-plot-window-"+pn(e.target)+")")):n.attr("d",r.line(e.data[a])).attr("clip-path","url(#mg-plot-window-"+pn(e.target)+")")}function d(t,e,r,n,a,o){if(n.empty()){var i=r.append("path").attr("class","mg-main-line mg-line"+o);u(t,i,a,o),f(t,e,i,a)}else{r.node().appendChild(n.node());var s=n.transition().duration(e.update_transition_duration);!e.display_area&&t.transition_on_update?s.attrTween("d",Dr(e.line(t.data[a]),4)):s.attr("d",e.line(t.data[a]))}}function p(t,e,r,n){var a;if(t.legend)if(Cr(t.legend)?a=t.legend[r]:Xr(t.legend)&&(a=t.legend(t.data[r])),t.legend_target)e.legend_text=t.colors&&t.colors.constructor===Array?"<span style='color:"+t.colors[r]+"'>— "+a+" </span>"+e.legend_text:"<span class='mg-line"+n+"-legend-color'>— "+a+" </span>"+e.legend_text;else{var o=t.data[r][t.data[r].length-1],i=e.legend_group.append("svg:text").attr("x",t.scalefns.xf(o)).attr("dx",t.buffer).attr("y",t.scalefns.yf(o)).attr("dy",".35em").attr("font-size",10).attr("font-weight","300").text(a);t.colors&&t.colors.constructor===Array?t.colors.length<r+1?i.classed("mg-line"+n+"-legend-color",!0):i.attr("fill",t.colors[r]):i.classed("mg-line"+n+"-legend-color",!0),sn(e.legend_group.selectAll(".mg-line-legend text")[0],t)}}function m(e,r){e&&t.select(e).html(r)}function h(t,e,r){t.legend&&(e.legend_group=Kr(r,"mg-line-legend"))}function g(t){Vr(t,".mg-rollover-rect"),Vr(t,".mg-voronoi"),Vr(t,".mg-active-datapoint"),Vr(t,".mg-line-rollover-circle")}function v(t,e){var r=e.selectAll(".mg-line-rollover-circle").data(t.data).enter().append("circle").attr({cx:0,cy:0,r:0});t.colors&&t.colors.constructor===Array?r.attr("class",function(t){return"mg-line"+t.line_id}).attr("fill",function(e,r){return t.colors[r]}).attr("stroke",function(e,r){return t.colors[r]}):r.attr("class",function(t){return["mg-line"+t.line_id,"mg-line"+t.line_id+"-color","mg-area"+t.line_id+"-color"].join(" ")}),r.classed("mg-line-rollover-circle",!0)}function x(t){for(var e=1,r=0;r<t.data.length;r++){for(var n=0;n<t.data[r].length;n++)t.data[r][n].line_id=t.custom_line_color_map.length>0?t.custom_line_color_map[r]:e;e++}}function y(e){return t.nest().key(function(t){return e.scales.X(t[e.x_accessor])+","+e.scales.Y(t[e.y_accessor])}).rollup(function(t){return t[0]}).entries(t.merge(e.data.map(function(t){return t}))).map(function(t){return t.values})}function b(t){return function(e){var r;if(t.linked){var n=e[t.x_accessor],a=MG.time_format(t.utc_time,t.linked_format),o="number"==typeof n?e.line_id-1:a(n);return r="roll_"+o+" mg-line"+e.line_id,null===t.color&&(r+=" mg-line"+e.line_id+"-color"),r}return r="mg-line"+e.line_id,null===t.color&&(r+=" mg-line"+e.line_id+"-color"),r}}function w(e,r,n,a,o){var i=t.geom.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)}).clipExtent([[e.buffer,e.buffer+e.title_y_position],[e.width-e.buffer,e.height-e.buffer]]),s=Kr(r,"mg-voronoi");s.selectAll("path").data(i(y(e))).enter().append("path").filter(function(t){return void 0!==t&&t.length>0}).attr("d",function(t){return"M"+t.join("L")+"Z"}).datum(function(t){return t.point}).attr("class",b(e)).on("mouseover",n).on("mouseout",a).on("mousemove",o),O(e,r)}function M(e){var r=t.nest().key(function(t){return t[e.x_accessor]}).entries(t.merge(e.data));return r.forEach(function(t){var r=t.values[0];t.key=r[e.x_accessor]}),e.x_sort?r.sort(function(t,e){return new Date(t.key)-new Date(e.key)}):r}function A(t,e,r,n,a){var o=M(t),i=o.map(function(e){return t.scales.X(e.key)}),s=e.append("g").attr("class","mg-rollover-rect");s.selectAll(".mg-rollover-rects").data(o).enter().append("rect").attr("x",function(e,r){return 1===i.length?Ur(t):0===r?i[r].toFixed(2):((i[r-1]+i[r])/2).toFixed(2)}).attr("y",t.top).attr("width",function(e,r){return 1===i.length?Wr(t):0===r?((i[r+1]-i[r])/2).toFixed(2):r===i.length-1?((i[r]-i[r-1])/2).toFixed(2):((i[r+1]-i[r-1])/2).toFixed(2)}).attr("class",function(e){var r=e.values.map(function(r){var n=T(e.line_id);return null===t.colors&&(n+=" "+Y(r.line_id)),n}).join(" ");return t.linked&&e.values.length>0&&(r+=" "+D(z(e.values[0],0,t))),r}).attr("height",t.height-t.bottom-t.top-t.buffer).attr("opacity",0).on("mouseover",r).on("mouseout",n).on("mousemove",a),C(t,e)}function G(t,e){e.select(".mg-rollover-rect rect").on("mouseover")(t.data[0][0],0)}function O(t,e){for(var r=0;r<t.data.length;r++){var n=r+1;t.custom_line_color_map.length>0&&void 0!==t.custom_line_color_map[r]&&(n=t.custom_line_color_map[r]),1!==t.data[r].length||e.selectAll(".mg-voronoi .mg-line"+n).empty()||(e.selectAll(".mg-voronoi .mg-line"+n).on("mouseover")(t.data[r][0],0),e.selectAll(".mg-voronoi .mg-line"+n).on("mouseout")(t.data[r][0],0))}}function T(t){return"mg-line"+t}function Y(t){return"mg-line"+t+"-color"}function D(t){return"roll_"+t}function z(t,e,r){var n=t[r.x_accessor],a=MG.time_format(r.utc_time,r.linked_format),o="number"==typeof n?e:a(n);return o}function E(t,e,r,n,a){var o=1;t.custom_line_color_map.length>0&&(o=t.custom_line_color_map[0]);var i=e.append("g").attr("class","mg-rollover-rect"),s=t.data[0].map(t.scalefns.xf);i.selectAll(".mg-rollover-rects").data(t.data[0]).enter().append("rect").attr("class",function(e,r){var n=Y(o)+" "+T(e.line_id);return t.linked&&(n+=n+" "+D(z(e,r,t))),n}).attr("x",function(e,r){return 1===s.length?Ur(t):0===r?s[r].toFixed(2):((s[r-1]+s[r])/2).toFixed(2)}).attr("y",function(e){return t.data.length>1?t.scalefns.yf(e)-6:t.top}).attr("width",function(e,r){return 1===s.length?Wr(t):0===r?((s[r+1]-s[r])/2).toFixed(2):r===s.length-1?((s[r]-s[r-1])/2).toFixed(2):((s[r+1]-s[r-1])/2).toFixed(2)
}).attr("height",function(){return t.data.length>1?12:t.height-t.bottom-t.top-t.buffer}).attr("opacity",0).on("mouseover",r).on("mouseout",n).on("mousemove",a),F(t)&&G(t,e)}function C(t,e){var r=e.selectAll(".mg-rollover-rect rect");t.data.filter(function(t){return 1===t.length}).length>0&&r.on("mouseover")(r[0][0].__data__,0)}function X(t){return t.data.length>1&&!t.aggregate_rollover}function P(t){return t.data.length>1&&t.aggregate_rollover}function F(t){return 1===t.data.length&&1===t.data[0].length}function j(t,e,r){$(e,r);for(var n=t.data.length-1;n>=0;n--){var a=t.data[n];MG.call_hook("line.before_each_series",[a,t]);var o=n+1;if(t.custom_line_color_map.length>0&&(o=t.custom_line_color_map[n]),t.data[n].line_id=o,0!==a.length){var i=r.select("path.mg-main-line.mg-line"+o);s(t,e,r,o),l(t,e,r,n,o),d(t,e,r,i,n,o),p(t,e,n,o),MG.call_hook("line.after_each_series",[a,i,t])}}}function $(t,e){t.existing_band[0].length>e.selectAll(".mg-main-line")[0].length&&e.selectAll(".mg-confidence-band").remove()}function S(t){var e={},n=un(t.target);Vr(n,".mg-line-legend"),h(t,e,n),e.data_median=0,e.update_transition_duration=t.transition_on_update?1e3:0,e.display_area=t.area&&!t.use_data_y_min&&t.data.length<=1&&t.aggregate_rollover===!1,e.legend_text="",r(t,e,n),e.existing_band=n.selectAll(".mg-confidence-band");var a=MG.call_hook("line.before_all_series",[t]);a!==!1&&j(t,e,n),m(t.legend_target,e.legend_text)}function N(t,e){var r=un(t.target);Kr(r,"mg-active-datapoint-container"),g(r),v(t,r),x(t),X(t)?w(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):P(t)?A(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):E(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t))}function L(t,e,r){if(t.aggregate_rollover&&t.data.length>1)e.selectAll("circle.mg-line-rollover-circle").style("opacity",0),r.values.forEach(function(r){Er(r,t)&&B(t,e,r)});else{if(t.missing_is_hidden&&r._missing||null===r[t.y_accessor])return;Er(r,t)&&I(t,e,r)}}function B(t,e,r){e.select("circle.mg-line-rollover-circle.mg-line"+r.line_id).attr({cx:function(){return t.scales.X(r[t.x_accessor]).toFixed(2)},cy:function(){return t.scales.Y(r[t.y_accessor]).toFixed(2)},r:t.point_size}).style("opacity",1)}function I(t,e,r){e.selectAll("circle.mg-line-rollover-circle.mg-line"+r.line_id).classed("mg-line-rollover-circle",!0).attr("cx",function(){return t.scales.X(r[t.x_accessor]).toFixed(2)}).attr("cy",function(){return t.scales.Y(r[t.y_accessor]).toFixed(2)}).attr("r",t.point_size).style("opacity",1)}function R(e,r,n){if(e.linked&&!MG.globals.link&&(MG.globals.link=!0,!e.aggregate_rollover||void 0!==r.value||r.values.length>0)){var a=r.values?r.values[0]:r,o=z(a,n,e);t.selectAll("."+T(a.line_id)+"."+D(o)).each(function(e){t.select(this).on("mouseover")(e,n)})}}function q(e,r,n){if(e.linked&&MG.globals.link){MG.globals.link=!1;var a=MG.time_format(e.utc_time,e.linked_format),o=r.values?r.values:[r];o.forEach(function(r){var o=r[e.x_accessor],i="number"==typeof o?n:a(o);t.selectAll(".roll_"+i).each(function(e){t.select(this).on("mouseout")(e)})})}}function H(t,e){e.selectAll("circle.mg-line-rollover-circle").style("opacity",0)}function U(t,e,r){e.selectAll("circle.mg-line-rollover-circle.mg-line"+r.line_id).style("opacity",function(){var e=r.line_id-1;return t.custom_line_color_map.length>0&&void 0!==t.custom_line_color_map.indexOf(r.line_id)&&(e=t.custom_line_color_map.indexOf(r.line_id)),1===t.data[e].length?1:0})}function Q(t){this.init=function(t){return this.args=t,t.data&&0!==t.data.length?(t.internal_error=void 0,or(t),cr(t),Ee(t),k(t),_(t),this.markers(),this.mainPlot(),this.rollover(),this.windowListeners(),MG.call_hook("line.after_init",this),this):(t.internal_error="No data was supplied",Mn(t),this)},this.mainPlot=function(){return S(t),this},this.markers=function(){return He(t),this},this.rollover=function(){var e=this;return N(t,e),MG.call_hook("line.after_rollover",t),this},this.rolloverOn=function(t){{var r=un(t.target);zr(t)}return function(n,a){if(L(t,r,n),R(t,n,a),r.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3),t.show_rollover_text){var o=Ke(t,{svg:r}),i=o.mouseover_row();t.aggregate_rollover&&i.text((t.aggregate_rollover&&t.data.length>1?Yr:Or)(t,n));var s=t.aggregate_rollover&&t.data.length>1?n.values:[n];s.forEach(function(r){t.aggregate_rollover&&(i=o.mouseover_row()),t.legend&&e(i.text(t.legend[r.line_id-1]+" ").bold().elem(),r,t),e(i.text("— ").elem(),r,t),t.aggregate_rollover||i.text(Or(t,r)),i.text(Tr(t,r,t.time_series===!1))})}t.mouseover&&t.mouseover(n,a)}},this.rolloverOff=function(t){var e=un(t.target);return function(r,n){q(t,r,n),t.aggregate_rollover?H(t,e):U(t,e,r),t.data[0].length>1&&Ue(e),t.mouseout&&t.mouseout(r,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return tr(this.args),this},this.init(t)}MG.register("line",Q)}.call(this),function(){"use strict";function r(r){this.init=function(t){return this.args=t,or(t),ur(t),Ee(t),k(t),_(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var t=un(r.target);t.selectAll(".mg-histogram").remove();var e=t.append("g").attr("class","mg-histogram"),n=e.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)+")"});return n.append("rect").attr("x",1).attr("width",function(){return 1===r.data[0].length?(r.scalefns.xf(r.data[0][0])-r.bar_margin).toFixed(2):(r.scalefns.xf(r.data[0][1])-r.scalefns.xf(r.data[0][0])-r.bar_margin).toFixed(2)}).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)}),this},this.markers=function(){return He(r),this},this.rollover=function(){{var t=un(r.target);e(e(r.target).find("svg").get(0))}Kr(t,"mg-active-datapoint-container"),t.selectAll(".mg-rollover-rect").remove(),t.selectAll(".mg-active-datapoint").remove();var n=t.append("g").attr("class","mg-rollover-rect"),a=n.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)"});return a.append("rect").attr("x",1).attr("y",r.buffer+r.title_y_position).attr("width",function(t,e){return 1===r.data[0].length?(r.scalefns.xf(r.data[0][0])-r.bar_margin).toFixed(2):e!==r.data[0].length-1?(r.scalefns.xf(r.data[0][e+1])-r.scalefns.xf(t)).toFixed(2):(r.scalefns.xf(r.data[0][1])-r.scalefns.xf(r.data[0][0])).toFixed(2)}).attr("height",function(){return r.height}).attr("opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r)),this},this.rolloverOn=function(e){var r=un(e.target);return function(n,a){r.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3);e.processed.xax_format||MG.time_format(e.utc_time,"%b %e, %Y"),Ar(e);if(r.selectAll(".mg-bar rect").filter(function(t,e){return e===a}).classed("active",!0),e.linked&&!MG.globals.link&&(MG.globals.link=!0,t.selectAll(".mg-rollover-rects.roll_"+a+" rect").each(function(e){t.select(this).on("mouseover")(e,a)})),e.show_rollover_text){var o=Ke(e,{svg:r}),i=o.mouseover_row();i.text("▟ ").elem().classed("hist-symbol",!0),i.text(Or(e,n)),i.text(Tr(e,n,e.time_series===!1))}e.mouseover&&(Qe(r,e),e.mouseover(n,a))}},this.rolloverOff=function(e){var r=un(e.target);return function(n,a){e.linked&&MG.globals.link&&(MG.globals.link=!1,t.selectAll(".mg-rollover-rects.roll_"+a+" rect").each(function(e){t.select(this).on("mouseout")(e,a)})),r.selectAll(".mg-bar rect").classed("active",!1),Ue(r),e.mouseout&&e.mouseout(n,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return tr(this.args),this},this.init(r)}var n={binned:!1,bins:null,processed_x_accessor:"x",processed_y_accessor:"y",processed_dx_accessor:"dx",bar_margin:1};MG.register("histogram",r,n)}.call(this),function(){"use strict";function e(t,e){var r=e.x_accessor,n=e.y_accessor,a=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[n]>=e.min_y)&&(null===e.max_y||t[n]<=e.max_y)});return a}function r(r){this.init=function(t){return this.args=t,or(t),dr(t),Ee(t),k(t),_(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.markers=function(){return He(r),r.least_squares&&pr(r),this},this.mainPlot=function(){var t,n=un(r.target),a=e(r.data[0],r);n.selectAll(".mg-points").remove(),t=n.append("g").classed("mg-points",!0);var o=t.selectAll("circle").data(a).enter().append("svg:circle").attr("class",function(t,e){return"path-"+e}).attr("cx",r.scalefns.xf).attr("cy",r.scalefns.yf);return null!==r.color_accessor?(o.attr("fill",r.scalefns.color),o.attr("stroke",r.scalefns.color)):o.classed("mg-points-mono",!0),null!==r.size_accessor?o.attr("r",r.scalefns.size):o.attr("r",r.point_size),this},this.rollover=function(){var n=un(r.target);Kr(n,"mg-active-datapoint-container"),n.selectAll(".mg-voronoi").remove();var a=t.geom.voronoi().x(r.scalefns.xf).y(r.scalefns.yf).clipExtent([[r.buffer,r.buffer+r.title_y_position],[r.width-r.buffer,r.height-r.buffer]]),o=n.append("g").attr("class","mg-voronoi");return o.selectAll("path").data(a(e(r.data[0],r))).enter().append("path").attr("d",function(t){return void 0!==t?"M"+t.join(",")+"Z":void 0}).attr("class",function(t,e){return"path-"+e}).style("fill-opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r)),1===r.data[0].length&&rr(r,n,r.data[0][0]),this},this.rolloverOn=function(e){var r=un(e.target);return function(n,a){r.selectAll(".mg-points circle").classed("selected",!1);var o=r.selectAll(".mg-points circle.path-"+a).classed("selected",!0);e.size_accessor?o.attr("r",function(t){return e.scalefns.size(t)+e.active_point_size_increase}):o.attr("r",e.point_size+e.active_point_size_increase),e.linked&&!MG.globals.link&&(MG.globals.link=!0,t.selectAll(".mg-voronoi .path-"+a).each(function(){t.select(this).on("mouseover")(n,a)})),e.show_rollover_text&&rr(e,r,n.point),e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(e){var r=un(e.target);return function(n,a){e.linked&&MG.globals.link&&(MG.globals.link=!1,t.selectAll(".mg-voronoi .path-"+a).each(function(){t.select(this).on("mouseout")(n,a)}));var o=r.selectAll(".mg-points circle").classed("unselected",!1).classed("selected",!1);e.size_accessor?o.attr("r",e.scalefns.size):o.attr("r",e.point_size),e.data[0].length>1&&Ue(r),e.mouseout&&e.mouseout(n,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.update=function(){return this},this.windowListeners=function(){return tr(this.args),this},this.init(r)}var n={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("point",r,n)}.call(this),function(){"use strict";function e(e){if(e.legend_target){var r=t.select(e.legend_target).append("div").classed("mg-bar-target-legend",!0),n=e.categorical_variables;n.forEach(function(t){var n=r.append("span").classed("mg-bar-target-element",!0);n.append("span").classed("mg-bar-target-legend-shape",!0).style("color",e.scales.color(t)).text("◼ "),n.append("span").classed("mg-bar-target-legend-text",!0).text(t)})}}function r(t,e){var r=e.categorical_variables,n=0,a=1.1,o=t.append("g").classed("mg-bar-legend",!0),i=o.append("text");i.selectAll("*").remove(),i.attr("width",e.right).attr("height",100).attr("text-anchor","start"),r.forEach(function(t){var r=i.append("tspan").attr("x",Wr(e)).attr("y",e.height/2).attr("dy",n*a+"em");r.append("tspan").text("■ ").attr("fill",e.scales.color(t)).attr("font-size",20),r.append("tspan").text(t).attr("font-weight",300).attr("font-size",10),n++})}function n(n){this.args=n,this.init=function(t){return this.args=t,or(t),fr(t),Ee(t),this.is_vertical="vertical"===t.bar_orientation,this.is_vertical?(M(t),_(t)):(k(t),x(t)),fe(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var t,a,o,i=un(n.target),s=n.data[0],l=i.select("g.mg-barplot"),c=l.empty(),u=c&&n.animate_on_load,f=u||n.transition_on_update,d=n.transition_duration||1e3;c&&(l=i.append("g").classed("mg-barplot",!0)),t=l.selectAll(".mg-bar").data(s),t.exit().remove(),t.enter().append("rect").classed("mg-bar",!0).classed("default-bar",n.scales.hasOwnProperty("color")?!1:!0),n.predictor_accessor&&(a=l.selectAll(".mg-bar-prediction").data(s.filter(function(t){return t.hasOwnProperty(n.predictor_accessor)})),a.exit().remove(),a.enter().append("rect").classed("mg-bar-prediction",!0)),n.baseline_accessor&&(o=l.selectAll(".mg-bar-baseline").data(s.filter(function(t){return t.hasOwnProperty(n.baseline_accessor)})),o.exit().remove(),o.enter().append("line").classed("mg-bar-baseline",!0));return f&&(t=t.transition().duration(d),a&&(a=a.transition().duration(d)),o&&(o=o.transition().duration(d))),i.select(".mg-y-axis").node().parentNode.appendChild(l.node()),this.is_vertical||(u&&(t.attr("width",0),a&&a.attr("width",0),o&&o.attr({x1:n.scales.X(0),x2:n.scales.X(0)})),t.attr("x",function(t){var e=n.scales.X(0);return t[n.x_accessor]<0&&(e=n.scalefns.xf(t)),e}).attr("y",function(t){return n.scalefns.yf_in(t)+n.scalefns.yf_out(t)}).attr("fill",n.scalefns.color).attr("height",n.scales.Y_ingroup.rangeBand()).attr("width",function(t){return Math.abs(n.scalefns.xf(t)-n.scales.X(0))}),n.predictor_accessor&&a.attr("x",n.scales.X(0)).attr("y",function(t){return n.scalefns.yf_out(t)+n.scalefns.yf_in(t)+n.scales.Y_ingroup.rangeBand()*(7/16)}).attr("height",n.scales.Y_ingroup.rangeBand()/8).attr("width",function(t){return n.scales.X(t[n.predictor_accessor])-n.scales.X(0)}),n.baseline_accessor&&o.attr("x1",function(t){return n.scales.X(t[n.baseline_accessor])}).attr("x2",function(t){return n.scales.X(t[n.baseline_accessor])}).attr("y1",function(t){return n.scalefns.yf_out(t)+n.scalefns.yf_in(t)+n.scales.Y_ingroup.rangeBand()/4}).attr("y2",function(t){return n.scalefns.yf_out(t)+n.scalefns.yf_in(t)+3*n.scales.Y_ingroup.rangeBand()/4})),n.legend&&n.group_accessor&&n.color_accessor!==!1&&n.group_accessor!==n.color_accessor&&(n.legend_target?e(n):r(i,n)),this},this.markers=function(){return He(n),this},this.rollover=function(){var t,e=un(n.target);Kr(e,"mg-active-datapoint-container"),e.selectAll(".mg-rollover-rect").remove(),e.selectAll(".mg-active-datapoint").remove();var r,a;"right"===n.rollover_align?(r=n.width-n.right,a="end"):"left"===n.rollover_align?(r=n.left,a="start"):(r=(n.width-n.left-n.right)/2+n.left,a="middle"),e.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r).attr("y",.75*n.top).attr("dy",".35em").attr("text-anchor",a),t=e.append("g").attr("class","mg-rollover-rect");var o=t.selectAll(".mg-bar-rollover").data(n.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return this.is_vertical||o.attr("x",Ur(n)).attr("y",function(t){return n.scalefns.yf_in(t)+n.scalefns.yf_out(t)}).attr("width",Wr(n)-Ur(n)).attr("height",n.scales.Y_ingroup.rangeBand()).attr("opacity",0).on("mouseover",this.rolloverOn(n)).on("mouseout",this.rolloverOff(n)).on("mousemove",this.rolloverMove(n)),this},this.rolloverOn=function(e){{var r=un(e.target);this.is_vertical?e.x_accessor:e.y_accessor,this.is_vertical?e.y_accessor:e.x_accessor,this.is_vertical?e.yax_units:e.xax_units}return function(n,a){var o=(MG.time_format(e.utc_time,"%b %e, %Y"),Ar(e),r.selectAll("g.mg-barplot .mg-bar").filter(function(t,e){return e===a}).classed("active",!0));if(e.scales.hasOwnProperty("color")?o.attr("fill",t.rgb(e.scalefns.color(n)).darker()):o.classed("default-active",!0),e.show_rollover_text){var i=Ke(e,{svg:r}),s=i.mouseover_row();e.group_accessor&&s.text(n[e.group_accessor]+" ").bold(),s.text(Or(e,n)),s.text(e.y_accessor+": "+n[e.y_accessor]),(e.predictor_accessor||e.baseline_accessor)&&(s=i.mouseover_row(),e.predictor_accessor&&s.text(Gr(e,n,null,e.predictor_accessor,!1)),e.baseline_accessor&&s.text(Gr(e,n,null,e.baseline_accessor,!1)))}e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(t){var e=un(t.target);return function(r,n){var a=e.selectAll("g.mg-barplot .mg-bar.active").classed("active",!1);t.scales.hasOwnProperty("color")?a.attr("fill",t.scalefns.color(r)):a.classed("default-active",!1),e.select(".mg-active-datapoint").text(""),Ue(e),t.mouseout&&t.mouseout(r,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return tr(this.args),this},this.init(n)}var a={y_accessor:"factor",x_accessor:"value",secondary_label_accessor:null,x_extended_ticks:!0,color_accessor:null,color_type:"category",color_domain:null,legend:!0,legend_target:null,mouseover_align:"middle",baseline_accessor:null,predictor_accessor:null,predictor_proportion:5,show_bar_zero:!0,binned:!0,width:480,height:null,bar_padding_percentage:.05,bar_outer_padding_percentage:.1,group_padding_percentage:.25,group_outer_padding_percentage:0,bar_thickness:12,top:45,left:105,right:65,truncate_x_labels:!0,truncate_y_labels:!0,rotate_x_labels:0,rotate_y_labels:0};MG.register("bar",n,a)}.call(this),MG.data_table=function(r){"use strict";return this.args=r,this.args.standard_col={width:150,font_size:12,font_weight:"normal"},this.args.columns=[],this.formatting_options=[["color","color"],["font-weight","font_weight"],["font-style","font_style"],["font-size","font_size"]],this._strip_punctuation=function(t){var e=t.replace(/[^a-zA-Z0-9 _]+/g,""),r=e.replace(/ +?/g,"");return r},this._format_element=function(t,e,r){this.formatting_options.forEach(function(n){var a=n[0],o=n[1];r[o]&&t.style(a,"string"==typeof r[o]||"number"==typeof r[o]?r[o]:r[o](e))})},this._add_column=function(t,e){var r=this.args.standard_col,n=vn(MG.clone(t),MG.clone(r));n.type=e,this.args.columns.push(n)},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 r=this.args;n(r);var a,o,i,s,l,c,u,f,d,p,m,_,h=r.target,g=t.select(h).append("table").classed("mg-data-table",!0),v=g.append("colgroup"),x=g.append("thead"),y=g.append("tbody");for(i=x.append("tr"),_=0;_<r.columns.length;_++){var b=r.columns[_];c=b.type,f=b.label,f=void 0===f?"":f,s=i.append("th").style("width",b.width).style("text-align","title"===c?"left":"right").text(f),r.show_tooltips&&b.description&&(s.append("i").classed("fa",!0).classed("fa-question-circle",!0).classed("fa-inverse",!0),e(s[0]).popover({html:!0,animation:!1,content:b.description,trigger:"hover",placement:"top",container:e(s[0])}))}for(_=0;_<r.columns.length;_++)m=v.append("col"),"number"===r.columns[_].type&&m.attr("align","char").attr("char",".");for(var w=0;w<r.data.length;w++){i=y.append("tr");for(var k=0;k<r.columns.length;k++){if(a=r.columns[k],l=a.accessor,u=d=r.data[w][l],c=a.type,"number"===c){if(a.hasOwnProperty("round")&&!a.hasOwnProperty("format")&&(d=t.format("0,."+a.round+"f")(d)),a.hasOwnProperty("value_formatter")&&(d=a.value_formatter(d)),a.hasOwnProperty("format")){a.round&&(d=t.round(d,a.round));var M,A=a.format;"percentage"===A&&(M=t.format("%p")),"count"===A&&(M=t.format("0,000")),"temperature"===A&&(M=function(t){return t+"°"}),d=M(d)}a.hasOwnProperty("currency")&&(d=a.currency+d)}p=i.append("td").classed("table-"+c,!0).classed("table-"+c+"-"+this._strip_punctuation(l),!0).attr("data-value",u).style("width",a.width).style("text-align","title"===c||"text"===c?"left":"right"),this._format_element(p,u,a),"title"===c?(o=p.append("div").text(d),this._format_element(o,d,a),r.columns[k].hasOwnProperty("secondary_accessor")&&p.append("div").text(r.data[w][r.columns[k].secondary_accessor]).classed("secondary-title",!0)):p.text(d)}}return this},this},function(){"use strict";function e(t,e){t.selectAll(".mg-missing-text").data([e.missing_text]).enter().append("text").attr("class","mg-missing-text").attr("x",e.width/2).attr("y",e.height/2).attr("dy",".50em").attr("text-anchor","middle").text(e.missing_text)}function r(e){e.scales.X=t.scale.linear().domain([0,e.data.length]).range([Ur(e),Wr(e)]),e.scalefns.yf=function(t){return e.scales.Y(t.y)}}function a(e){e.scales.Y=t.scale.linear().domain([-2,2]).range([e.height-e.bottom-2*e.buffer,e.top]),e.scalefns.xf=function(t){return e.scales.X(t.x)}}function o(t){for(var e=[],r=1;50>=r;r++)e.push({x:r,y:Math.random()-.03*r});t.data=e}function i(t,e){t.append("svg:rect").classed("mg-missing-background",!0).attr("x",e.buffer).attr("y",e.buffer).attr("width",e.width-2*e.buffer).attr("height",e.height-2*e.buffer).attr("rx",15).attr("ry",15)}function s(e,r){var n=t.svg.line().x(r.scalefns.xf).y(r.scalefns.yf).interpolate(r.interpolate);e.append("path").attr("class","mg-main-line mg-line1-color").attr("d",n(r.data))}function l(e,r){var n=t.svg.area().x(r.scalefns.xf).y0(r.scales.Y.range()[0]).y1(r.scalefns.yf).interpolate(r.interpolate);e.append("path").attr("class","mg-main-area mg-area1-color").attr("d",n(r.data))}function c(e){t.select(e.target).selectAll("svg *").remove()}function u(e){e.legend_target&&t.select(e.legend_target).html("")}function f(f){this.init=function(f){this.args=f,he(f),ge(f),n(f);var d=t.select(f.target);Ae(d,f);var p=d.selectAll("svg");if(ve(p,f),p=xe(p,f),be(p,f),we(p,f),c(f),p.classed("mg-missing",!0),u(f),f.show_missing_background){o(f),r(f),a(f);var m=Kr(p,"mg-missing-pane");i(m,f),s(m,f),l(m,f)}return e(p,f),this.windowListeners(),this},this.windowListeners=function(){return tr(this.args),this},this.init(f)}var d={top:40,bottom:30,right:10,left:10,buffer:8,legend_target:"",width:350,height:220,missing_text:"Data currently missing or unavailable",scalefns:{},scales:{},show_tooltips:!0,show_missing_background:!0,interpolate:"cardinal"};MG.register("missing-data",f,d)}.call(this),MG.raw_data_transformation=or,MG.process_line=cr,MG.process_histogram=ur,MG.process_categorical_variables=fr,MG.process_point=dr,MG.add_ls=pr,MG.add_lowess=mr,MG.lowess_robust=_r,MG.lowess=hr,MG.least_squares=gr;var Gn=function(t,e,r,n){var a;return a="string"==typeof t?MG.time_format(n,t)(e[r]):"function"==typeof t?t(e):e[r]},On=function(e,r,n){var a;return a="string"==typeof e?t.format(e)(r[n]):"function"==typeof e?e(r):r[n]};MG.format_rollover_number=Ar,MG.path_tween=Dr,MG.convert={},MG.convert.date=function(e,r,n){return n="undefined"==typeof n?"%Y-%m-%d":n,e=e.map(function(e){var a=t.time.format(n);return e[r]=a.parse(e[r]),e})},MG.convert.number=function(t,e){return t=t.map(function(t){return t[e]=Number(t[e]),t})},MG.time_format=function(e,r){return e?t.time.format.utc(r):t.time.format(r)};var Tn=function(t,e,r){var n={};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 a=0,o=t.length;o>a;a++)if(e.call(r,t[a],a,t)===n)return}else for(var i in t)if(e.call(r,t[i],i,t)===n)return;return t};return MG.merge_with_defaults=vn,MG.clone=function(t){var e;if(null===t||"object"!=typeof t)return t;if(t instanceof Date)return e=new Date,e.setTime(t.getTime()),e;if(t instanceof Array){e=[];for(var r=0,n=t.length;n>r;r++)e[r]=MG.clone(t[r]);return e}if(t instanceof Object){e={};for(var a in t)t.hasOwnProperty(a)&&(e[a]=MG.clone(t[a]));return e}throw new Error("Unable to copy obj! Its type isn't supported.")},MG.arr_diff=xn,MG.warn_deprecation=yn,MG.truncate_text=bn,MG.wrap_text=wn,MG.error=kn,MG});
|