");var d=function(){var t,r=e(this).data("key"),a=e(this).data("feature");return e("."+a+"-btns button.btn span.title").html(r),i.hasOwnProperty(a)?(t=i[a],o[t](r)):s(a,r),!1};for(var f in this.feature_set){for(a=this.feature_set[f],e(this.target+" div.segments").append('"),l=0;l'+a[l]+"");e("."+this._strip_punctuation(f)+"-btns .dropdown-menu li a").on("click",d)}return this},this},G.line=function(r){return this.args=r,this.init=function(t){return w(t),k(t),v(t),i(t),n(t),this},this.mainPlot=function(){var a,n=t.select(e(r.target).find("svg").get(0)),s=0,o=r.transition_on_update?1e3:0,i=function(t){return t[r.y_accessor]},l=t.svg.area().x(r.scalefns.xf).y0(r.scales.Y.range()[0]).y1(r.scalefns.yf).interpolate(r.interpolate),c=e(r.target).find(".mg-confidence-band");c.length>0&&c.remove(),r.show_confidence_band&&(a=t.svg.area().x(r.scalefns.xf).y0(function(t){var e=r.show_confidence_band[0];return r.scales.Y(t[e])}).y1(function(t){var e=r.show_confidence_band[1];return r.scales.Y(t[e])}).interpolate(r.interpolate));for(var u,d=t.svg.line().x(r.scalefns.xf).y(r.scalefns.yf).interpolate(r.interpolate),f=t.svg.line().x(r.scalefns.xf).y(function(){return r.scales.Y(s)}).interpolate(r.interpolate),p="",h=r.data.length-1;h>=0;h--){u=r.data[h];var g=h+1;r.custom_line_color_map.length>0&&(g=r.custom_line_color_map[h]),r.data[h].line_id=g,r.show_confidence_band&&n.append("path").attr("class","mg-confidence-band").attr("d",a(r.data[h])).attr("clip-path","url(#mg-plot-window-"+T(r.target)+")");var m=e(r.target).find("svg path.mg-area"+g+"-color");r.area&&!r.use_data_y_min&&!r.y_axis_negative&&r.data.length<=1?m.length>0?(e(n.node()).find(".mg-y-axis").after(m.detach()),t.select(m.get(0)).transition().duration(o).attr("d",l(r.data[h])).attr("clip-path","url(#mg-plot-window)")):n.append("path").attr("class","mg-main-area mg-area"+g+"-color").attr("d",l(r.data[h])).attr("clip-path","url(#mg-plot-window-"+T(r.target)+")"):m.length>0&&m.remove();var _=e(r.target).find("svg path.mg-main-line.mg-line"+g+"-color").first();_.length>0?(e(n.node()).find(".mg-y-axis").after(_.detach()),t.select(_.get(0)).transition().duration(o).attr("d",d(r.data[h]))):r.animate_on_load?(s=t.median(r.data[h],i),n.append("path").attr("class","mg-main-line mg-line"+g+"-color").attr("d",f(r.data[h])).transition().duration(1e3).attr("d",d(r.data[h])).attr("clip-path","url(#mg-plot-window-"+T(r.target)+")")):n.append("path").attr("class","mg-main-line mg-line"+g+"-color").attr("d",d(r.data[h])).attr("clip-path","url(#mg-plot-window-"+T(r.target)+")"),r.legend&&(p="— "+r.legend[h]+" "+p)}return r.legend&&e(r.legend_target).html(p),this},this.markers=function(){return x(r),this},this.rollover=function(){var a,n=t.select(e(r.target).find("svg").get(0)),s=e(e(r.target).find("svg").get(0));s.find(".mg-rollover-rect").remove(),s.find(".mg-voronoi").remove(),s.find(".mg-active-datapoint").remove(),s.find(".mg-line-rollover-circle").remove(),n.append("g").attr("class","mg-active-datapoint-container").attr("transform","translate("+(r.width-r.right)+","+r.top/2+")").append("text").attr("class","mg-active-datapoint").classed("mg-active-datapoint-small",r.use_small_class).attr("xml:space","preserve").attr("text-anchor","end"),n.selectAll(".mg-line-rollover-circle").data(r.data).enter().append("circle").attr({"class":function(t){return["mg-line-rollover-circle","mg-line"+t.line_id+"-color","mg-area"+t.line_id+"-color"].join(" ")},cx:0,cy:0,r:0});for(var o=1,i=0;i0?r.custom_line_color_map[i]:o;o++}var c,u;if(r.data.length>1&&!r.aggregate_rollover){var d=t.geom.voronoi().x(function(t){return r.scales.X(t[r.x_accessor]).toFixed(2)}).y(function(t){return r.scales.Y(t[r.y_accessor]).toFixed(2)}).clipExtent([[r.buffer,r.buffer],[r.width-r.buffer,r.height-r.buffer]]);a=n.append("g").attr("class","mg-voronoi"),c=t.nest().key(function(t){return r.scales.X(t[r.x_accessor])+","+r.scales.Y(t[r.y_accessor])}).rollup(function(t){return t[0]}).entries(t.merge(r.data.map(function(t){return t}))).map(function(t){return t.values}),a.selectAll("path").data(d(c)).enter().append("path").attr("d",function(t){return"M"+t.join("L")+"Z"}).datum(function(t){return t.point}).attr("class",function(e){if(r.linked){var a=e[r.x_accessor],n=t.time.format(r.linked_format),s="number"==typeof a?i:n(a);return"mg-line"+e.line_id+"-color roll_"+s}return"mg-line"+e.line_id+"-color"}).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r))}else r.data.length>1&&r.aggregate_rollover?(c=t.nest().key(function(t){return t[r.x_accessor]}).entries(t.merge(r.data)),u=c.map(function(t){return r.scales.X(new Date(t.key))}),a=n.append("g").attr("class","mg-rollover-rect"),a.selectAll(".mg-rollover-rects").data(c).enter().append("rect").attr("x",function(t,e){return 1===u.length?r.left+r.buffer:0===e?u[e].toFixed(2):((u[e-1]+u[e])/2).toFixed(2)}).attr("y",r.top).attr("width",function(t,e){return 1===u.length?r.width-r.right-r.buffer: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",r.height-r.bottom-r.top-r.buffer).attr("opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r))):(o=1,r.custom_line_color_map.length>0&&(o=r.custom_line_color_map[0]),a=n.append("g").attr("class","mg-rollover-rect"),u=r.data[0].map(r.scalefns.xf),a.selectAll(".mg-rollover-rects").data(r.data[0]).enter().append("rect").attr("class",function(e,a){if(r.linked){var n=e[r.x_accessor],s=t.time.format(r.linked_format),i="number"==typeof n?a:s(n);return"mg-line"+o+"-color roll_"+i}return"mg-line"+o+"-color"}).attr("x",function(t,e){return 1===u.length?r.left+r.buffer:0===e?u[e].toFixed(2):((u[e-1]+u[e])/2).toFixed(2)}).attr("y",function(t){return r.data.length>1?r.scalefns.yf(t)-6:r.top}).attr("width",function(t,e){return 1===u.length?r.width-r.right-r.buffer: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(){return r.data.length>1?12:r.height-r.bottom-r.top-r.buffer}).attr("opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r)));return 1==r.data.length&&1==r.data[0].length&&t.select(".mg-rollover-rect .mg-line1-color").on("mouseover")(r.data[0][0],0),this},this.rolloverOn=function(r){var a,n=t.select(e(r.target).find("svg").get(0));switch(r.processed.x_time_frame){case"seconds":a=t.time.format("%b %e, %Y %H:%M:%S");break;case"less-than-a-day":a=t.time.format("%b %e, %Y %I:%M%p");break;case"four-days":a=t.time.format("%b %e, %Y %I:%M%p");break;default:a=t.time.format("%b %e, %Y")}return function(e,s){if(r.aggregate_rollover&&r.data.length>1)n.selectAll("circle.mg-line-rollover-circle").style("opacity",0),e.values.forEach(function(t){if(t[r.x_accessor]>=r.processed.min_x&&t[r.x_accessor]<=r.processed.max_x&&t[r.y_accessor]>=r.processed.min_y&&t[r.y_accessor]<=r.processed.max_y){n.select("circle.mg-line"+t.line_id+"-color").attr({cx:function(){return r.scales.X(t[r.x_accessor]).toFixed(2)},cy:function(){return r.scales.Y(t[r.y_accessor]).toFixed(2)},r:r.point_size}).style("opacity",1)}});else if(e[r.x_accessor]>=r.processed.min_x&&e[r.x_accessor]<=r.processed.max_x&&e[r.y_accessor]>=r.processed.min_y&&e[r.y_accessor]<=r.processed.max_y&&n.selectAll("circle.mg-line-rollover-circle").attr("class","").attr("class","mg-area"+e.line_id+"-color").classed("mg-line-rollover-circle",!0).attr("cx",function(){return r.scales.X(e[r.x_accessor]).toFixed(2)}).attr("cy",function(){return r.scales.Y(e[r.y_accessor]).toFixed(2)}).attr("r",r.point_size).style("opacity",1),r.linked&&!MG.globals.link){MG.globals.link=!0;var o=e[r.x_accessor],i=t.time.format(r.linked_format),l="number"==typeof o?s:i(o);t.selectAll(".mg-line"+e.line_id+"-color.roll_"+l).each(function(e,r){t.select(this).on("mouseover")(e,r)})}n.selectAll("text").filter(function(t){return e===t}).attr("opacity",.3);var c;if(c="count"===r.format?function(e){var a=e%1!==0,n=t.format("0,000");return e=a?t.round(e,r.decimals):e,n(e)}:function(e){var a=(r.decimals?"."+r.decimals:"")+"%",n=t.format(a);return n(e)},r.show_rollover_text){var u=n.select(".mg-active-datapoint"),d=0,f=1.1;if(u.select("*").remove(),r.aggregate_rollover&&r.data.length>1){if(r.time_series){var p=new Date(e.key);u.append("tspan").text((a(p)+" "+r.yax_units).trim()),d=1,e.values.forEach(function(t){var e=u.append("tspan").attr({x:0,y:d*f+"em"}).text(c(t[r.y_accessor]));u.append("tspan").attr({x:-e.node().getComputedTextLength(),y:d*f+"em"}).text("— ").classed("mg-hover-line"+t.line_id+"-color",!0).style("font-weight","bold"),d++}),u.append("tspan").attr("x",0).attr("y",d*f+"em").text(" ")}else e.values.forEach(function(t){var e=u.append("tspan").attr({x:0,y:d*f+"em"}).text(r.x_accessor+": "+t[r.x_accessor]+", "+r.y_accessor+": "+r.yax_units+c(t[r.y_accessor]));u.append("tspan").attr({x:-e.node().getComputedTextLength(),y:d*f+"em"}).text("— ").classed("mg-hover-line"+t.line_id+"-color",!0).style("font-weight","bold"),d++});u.append("tspan").attr("x",0).attr("y",d*f+"em").text(" ")}else if(r.time_series){var h=new Date(+e[r.x_accessor]);h.setDate(h.getDate()),u.append("tspan").text(a(h)+" "+r.yax_units+c(e[r.y_accessor]))}else u.append("tspan").text(r.x_accessor+": "+e[r.x_accessor]+", "+r.y_accessor+": "+r.yax_units+c(e[r.y_accessor]))}r.mouseover&&r.mouseover(e,s)}},this.rolloverOff=function(r){var a=t.select(e(r.target).find("svg").get(0));return function(e,n){if(r.linked&&MG.globals.link){MG.globals.link=!1;var s=e[r.x_accessor],o=t.time.format(r.linked_format),i="number"==typeof s?n:o(s);t.selectAll(".roll_"+i).each(function(e){t.select(this).on("mouseout")(e)})}a.selectAll("circle.mg-line-rollover-circle").style("opacity",function(){return 1==r.data.length&&1==r.data[0].length?1:0}),a.select(".mg-active-datapoint").text(""),r.mouseout&&r.mouseout(e,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return y(this.args),this},this.init(r),this},G.histogram=function(r){return this.args=r,this.init=function(t){return w(t),A(t),v(t),i(t),n(t),this},this.mainPlot=function(){var a=t.select(e(r.target).find("svg").get(0)),n=e(e(r.target).find("svg").get(0));n.find(".mg-histogram").remove();var s=a.append("g").attr("class","mg-histogram"),o=s.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 o.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 x(r),this},this.rollover=function(){var a=t.select(e(r.target).find("svg").get(0)),n=e(e(r.target).find("svg").get(0));n.find(".mg-rollover-rect").remove(),n.find(".mg-active-datapoint").remove(),a.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r.width-r.right).attr("y",r.top/2).attr("text-anchor","end");var s=a.append("g").attr("class","mg-rollover-rect"),o=s.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 o.append("rect").attr("x",1).attr("y",0).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(r){{var a=t.select(e(r.target).find("svg").get(0));t.time.format("%Y-%m-%d")}return function(n,s){a.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3);var o,i=t.time.format("%b %e, %Y");o="count"===r.format?function(e){var a=e%1!==0,n=t.format("0,000");return e=a?t.round(e,r.decimals):e,n(e)}:function(e){var a=(r.decimals?"."+r.decimals:"")+"%",n=t.format(a);return n(e)},t.selectAll(e(r.target).find(" svg .mg-bar :eq("+s+")")).classed("active",!0),r.linked&&!MG.globals.link&&(MG.globals.link=!0,t.selectAll(".mg-rollover-rects.roll_"+s+" rect").each(function(e){t.select(this).on("mouseover")(e,s)})),r.show_rollover_text&&a.select(".mg-active-datapoint").text(function(){if(r.time_series){var t=new Date(+n[r.x_accessor]);return t.setDate(t.getDate()),i(t)+" "+r.yax_units+o(n[r.y_accessor])}return r.x_accessor+": "+o(n[r.x_accessor])+", "+r.y_accessor+": "+r.yax_units+o(n[r.y_accessor])}),r.mouseover&&r.mouseover(n,s)}},this.rolloverOff=function(r){var a=t.select(e(r.target).find("svg").get(0));return function(n,s){r.linked&&MG.globals.link&&(MG.globals.link=!1,t.selectAll(".mg-rollover-rects.roll_"+s+" rect").each(function(e){t.select(this).on("mouseout")(e,s)})),t.selectAll(e(r.target).find("svg .mg-bar :eq("+s+")")).classed("active",!1),a.select(".mg-active-datapoint").text(""),r.mouseout&&r.mouseout(n,s)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return y(this.args),this},this.init(r),this},G.point=function(r){return this.args=r,this.init=function(t){return w(t),M(t),v(t),i(t),n(t),this},this.markers=function(){return x(r),r.least_squares&&O(r),this},this.mainPlot=function(){var a,n=t.select(e(r.target).find("svg").get(0)),s=e(e(r.target).find("svg").get(0));s.find(".mg-points").remove(),a=n.append("g").classed("mg-points",!0);var o=a.selectAll("circle").data(r.data[0]).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 a=t.select(e(r.target).find("svg").get(0)),n=e(e(r.target).find("svg").get(0));n.find(".mg-voronoi").remove(),n.find(".mg-active-datapoint").remove(),a.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r.width-r.right).attr("y",r.top/2).attr("text-anchor","end");var s=t.geom.voronoi().x(r.scalefns.xf).y(r.scalefns.yf).clipExtent([[r.buffer,r.buffer],[r.width-r.buffer,r.height-r.buffer]]),o=a.append("g").attr("class","mg-voronoi");return o.selectAll("path").data(s(r.data[0])).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)),this},this.rolloverOn=function(r){var a=t.select(e(r.target).find("svg").get(0));return function(e,n){a.selectAll(".mg-points circle").classed("selected",!1);var s=a.selectAll(".mg-points circle.path-"+n).classed("selected",!0);r.size_accessor?s.attr("r",function(t){return r.scalefns.size(t)+1}):s.attr("r",r.point_size),r.linked&&!globals.link&&(globals.link=!0,t.selectAll(".mg-voronoi .path-"+n).each(function(){t.select(this).on("mouseover")(e,n)}));var o,i=t.time.format("%b %e, %Y");o="count"===r.format?function(e){var a=e%1!==0,n=t.format("0,000");return e=a?t.round(e,r.decimals):e,n(e)}:function(e){var a=(r.decimals?"."+r.decimals:"")+"%",n=t.format(a);return n(e)},r.show_rollover_text&&a.select(".mg-active-datapoint").text(function(){if(r.time_series){var t=new Date(+e.point[r.x_accessor]);return t.setDate(t.getDate()),i(t)+" "+r.yax_units+o(e.point[r.y_accessor])}return r.x_accessor+": "+o(e.point[r.x_accessor])+", "+r.y_accessor+": "+r.yax_units+o(e.point[r.y_accessor])}),r.mouseover&&r.mouseover(e,n)}},this.rolloverOff=function(r){var a=t.select(e(r.target).find("svg").get(0));return function(e,n){r.linked&&globals.link&&(globals.link=!1,t.selectAll(".mg-voronoi .path-"+n).each(function(){t.select(this).on("mouseout")(e,n)}));var s=a.selectAll(".mg-points circle").classed("unselected",!1).classed("selected",!1);r.size_accessor?s.attr("r",r.scalefns.size):s.attr("r",r.point_size),a.select(".mg-active-datapoint").text(""),r.mouseout&&r.mouseout(e,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.update=function(){return this},this.windowListeners=function(){return y(this.args),this},this.init(r),this},G.bar=function(r){return this.args=r,this.is_vertical=!0,this.init=function(t){return w(t),D(t),v(t),this.is_vertical="vertical"===t.bar_orientation,this.is_vertical?(l(t),n(t)):(i(t),s(t)),this},this.mainPlot=function(){var a,n,s,o,i,l=t.select(r.target).select("svg"),c=r.data[0],u=l.select(".mg-barplot"),d=u.empty(),f=d&&r.animate_on_load,p=f||r.transition_on_update,h=r.transition_duration||1e3;d?(u=l.append("g").classed("mg-barplot",!0),a=u.selectAll(".mg-bar").data(c).enter().append("rect").classed("mg-bar",!0),r.predictor_accessor&&(n=u.selectAll(".mg-bar-prediction").data(c).enter().append("rect").classed("mg-bar-prediction",!0)),r.baseline_accessor&&(i=u.selectAll(".mg-bar-baseline").data(c).enter().append("line").classed("mg-bar-baseline",!0))):(u=l.select("g.mg-barplot"),e(l.node()).find(".mg-y-axis").after(e(u.node()).detach()),a=u.selectAll("rect.mg-bar"),r.predictor_accessor&&(n=u.selectAll(".mg-bar-prediction")),r.baseline_accessor&&(i=u.selectAll(".mg-bar-baseline")));var g;return this.is_vertical?(g=r.scales.X.rangeBand()/1.5,f&&a.attr("height",0).attr("y",r.scales.Y(0)),p&&(a=a.transition().duration(h)),a.attr("y",function(t){return r.scales.Y(0)-(r.scales.Y(0)-r.scalefns.yf(t))}).attr("x",function(t){return r.scalefns.xf(t)+g/2}).attr("width",g).attr("height",function(t){return 0-(r.scalefns.yf(t)-r.scales.Y(0))}),r.predictor_accessor&&(s=r.predictor_proportion,o=s-1,f&&n.attr("height",0).attr("y",r.scales.Y(0)),p&&(n=n.transition().duration(h)),n.attr("y",function(t){return r.scales.Y(0)-(r.scales.Y(0)-r.scales.Y(t[r.predictor_accessor]))}).attr("x",function(t){return r.scalefns.xf(t)+o*g/(2*s)+g/2}).attr("width",g/s).attr("height",function(t){return 0-(r.scales.Y(t[r.predictor_accessor])-r.scales.Y(0))})),r.baseline_accessor&&(s=r.predictor_proportion,f&&i.attr({y1:r.scales.Y(0),y2:r.scales.Y(0)}),p&&(i=i.transition().duration(h)),i.attr("x1",function(t){return r.scalefns.xf(t)+g/2-g/s+g/2}).attr("x2",function(t){return r.scalefns.xf(t)+g/2+g/s+g/2}).attr("y1",function(t){return r.scales.Y(t[r.baseline_accessor])}).attr("y2",function(t){return r.scales.Y(t[r.baseline_accessor])}))):(g=r.scales.Y.rangeBand()/1.5,f&&a.attr("width",0),p&&(a=a.transition().duration(h)),a.attr("x",r.scales.X(0)).attr("y",function(t){return r.scalefns.yf(t)+g/2}).attr("height",g).attr("width",function(t){return r.scalefns.xf(t)-r.scales.X(0)}),r.predictor_accessor&&(s=r.predictor_proportion,o=s-1,f&&n.attr("width",0),p&&(n=n.transition().duration(h)),n.attr("x",r.scales.X(0)).attr("y",function(t){return r.scalefns.yf(t)+o*g/(2*s)+g/2}).attr("height",g/s).attr("width",function(t){return r.scales.X(t[r.predictor_accessor])-r.scales.X(0)})),r.baseline_accessor&&(s=r.predictor_proportion,f&&i.attr({x1:r.scales.X(0),x2:r.scales.X(0)}),p&&(i=i.transition().duration(h)),i.attr("x1",function(t){return r.scales.X(t[r.baseline_accessor])}).attr("x2",function(t){return r.scales.X(t[r.baseline_accessor])}).attr("y1",function(t){return r.scalefns.yf(t)+g/2-g/s+g/2}).attr("y2",function(t){return r.scalefns.yf(t)+g/2+g/s+g/2}))),this},this.markers=function(){return x(r),this},this.rollover=function(){var a,n=t.select(e(r.target).find("svg").get(0)),s=e(e(r.target).find("svg").get(0));s.find(".mg-rollover-rect").remove(),s.find(".mg-active-datapoint").remove(),n.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r.width-r.right).attr("y",r.top/2).attr("dy",".35em").attr("text-anchor","end"),a=n.append("g").attr("class","mg-rollover-rect");var o=a.selectAll(".mg-bar-rollover").data(r.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return this.is_vertical?o.attr("x",r.scalefns.xf).attr("y",function(){return r.scales.Y(0)-r.height}).attr("width",r.scales.X.rangeBand()).attr("height",r.height).attr("opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r)):o.attr("x",r.scales.X(0)).attr("y",r.scalefns.yf).attr("width",r.width).attr("height",r.scales.Y.rangeBand()+2).attr("opacity",0).on("mouseover",this.rolloverOn(r)).on("mouseout",this.rolloverOff(r)).on("mousemove",this.rolloverMove(r)),this},this.rolloverOn=function(r){var a=t.select(e(r.target).find("svg").get(0)),n=this.is_vertical?r.x_accessor:r.y_accessor,s=this.is_vertical?r.y_accessor:r.x_accessor,o=this.is_vertical?r.yax_units:r.xax_units;return function(i,l){a.selectAll("text").filter(function(t){return i===t}).attr("opacity",.3);var c,u=t.time.format("%b %e, %Y");c="count"===r.format?function(e){var a=e%1!==0,n=t.format("0,000");return e=a?t.round(e,r.decimals):e,n(e)}:function(e){var a=(r.decimals?"."+r.decimals:"")+"%",n=t.format(a);return n(e)},t.selectAll(e(r.target+" svg g.mg-barplot .mg-bar:eq("+l+")")).classed("active",!0),r.show_rollover_text&&a.select(".mg-active-datapoint").text(function(){if(r.time_series){var t=new Date(+i[s]);return t.setDate(t.getDate()),u(t)+" "+o+c(i[n])}return i[n]+": "+c(i[s])}),r.mouseover&&r.mouseover(i,l)}},this.rolloverOff=function(r){var a=t.select(e(r.target).find("svg").get(0));return function(n,s){t.selectAll(e(r.target).find("svg g.mg-barplot .mg-bar:eq("+s+")")).classed("active",!1),a.select(".mg-active-datapoint").text(""),r.mouseout&&r.mouseout(n,s)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return y(this.args),this},this.init(r),this},MG.data_table=function(a){return this.args=a,this.args.standard_col={width:150,font_size:12,font_weight:"normal"},this.args.columns=[],this.formatting_options=[["color","color"],["font-weight","font_weight"],["font-style","font_style"],["font-size","font_size"]],this._strip_punctuation=function(t){var e=t.replace(/[^a-zA-Z0-9 _]+/g,""),r=e.replace(/ +?/g,"");return r},this._format_element=function(t,e,r){this.formatting_options.forEach(function(a){var n=a[0],s=a[1];r[s]&&t.style(n,"string"==typeof r[s]||"number"==typeof r[s]?r[s]:r[s](e))})},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 a=this.args;r(a);var n,s,o,i,l,c,u,d,f,p,h,g,m=a.target,_=t.select(m).append("table").classed("mg-data-table",!0),v=_.append("colgroup"),x=_.append("thead"),y=_.append("tbody");for(o=x.append("tr"),g=0;g=o;o++)s.push({x:o,y:Math.random()-.03*o});a.scales.X=t.scale.linear().domain([0,s.length]).range([a.left+a.buffer,a.width-a.right-a.buffer]),a.scales.Y=t.scale.linear().domain([-2,2]).range([a.height-a.bottom-2*a.buffer,a.top]),a.scalefns.xf=function(t){return a.scales.X(t.x)},a.scalefns.yf=function(t){return a.scales.Y(t.y)};var i=t.svg.line().x(a.scalefns.xf).y(a.scalefns.yf).interpolate(a.interpolate),l=t.svg.area().x(a.scalefns.xf).y0(a.scales.Y.range()[0]).y1(a.scalefns.yf).interpolate(a.interpolate),c=n.append("g").attr("class","mg-missing-pane");c.append("svg:rect").classed("mg-missing-background",!0).attr("x",a.buffer).attr("y",a.buffer).attr("width",a.width-2*a.buffer).attr("height",a.height-2*a.buffer).attr("rx",15).attr("ry",15),c.append("path").attr("class","mg-main-line mg-line1-color").attr("d",i(s)),c.append("path").attr("class","mg-main-area mg-area1-color").attr("d",l(s))}return n.selectAll(".mg-missing-text").data([a.missing_text]).enter().append("text").attr("class","mg-missing-text").attr("x",a.width/2).attr("y",a.height/2).attr("dy",".50em").attr("text-anchor","middle").text(a.missing_text),this},this.init(a),this},MG.convert={},MG.convert.date=function(e,r,a){return a="undefined"==typeof a?"%Y-%m-%d":a,e=e.map(function(e){var n=t.time.format(a);return e[r]=n.parse(e[r]),e})},MG.convert.number=function(t,e){return t=t.map(function(t){return t[e]=Number(t[e]),t})};var S=function(t,e,r){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,n=t.length;n>a;a++)if(e.call(r,t[a],a,t)===breaker)return}else for(var s in t)if(e.call(r,t[s],s,t)===breaker)return;return t};return 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,a=t.length;a>r;r++)e[r]=MG.clone(t[r]);return e}if(t instanceof Object){e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=MG.clone(t[n]));return e}throw new Error("Unable to copy obj! Its type isn't supported.")},MG})}).call(this);