diff --git a/dist/metricsgraphics.js b/dist/metricsgraphics.js index d8d4f0a9db..190c658fee 100644 --- a/dist/metricsgraphics.js +++ b/dist/metricsgraphics.js @@ -3105,6 +3105,320 @@ MG.button_layout = function(target) { } + + function mg_update_rollover_circle(args, svg, d) { + if (args.aggregate_rollover && args.data.length > 1) { + // hide the circles in case a non-contiguous series is present + svg.selectAll('circle.mg-line-rollover-circle') + .style('opacity', 0); + + d.values.forEach(function (datum) { + if (mg_data_in_plot_bounds(datum, args)) mg_update_aggregate_rollover_circle(args, svg, datum); + }); + } else if ((args.missing_is_hidden && d['_missing']) + || d[args.y_accessor] == null + ) { + // disable rollovers for hidden parts of the line + // recall that hidden parts are missing data ranges and possibly also + // data points that have been explicitly identified as missing + return; + } else { + // show circle on mouse-overed rect + if (mg_data_in_plot_bounds(d, args)) { + mg_update_generic_rollover_circle(args, svg, d); + } + } + } + + function mg_update_aggregate_rollover_circle(args, svg, datum) { + var circle = svg.select('circle.mg-line-rollover-circle.mg-line' + datum.line_id) + .attr({ + 'cx': function () { + return args.scales.X(datum[args.x_accessor]).toFixed(2); + }, + 'cy': function () { + return args.scales.Y(datum[args.y_accessor]).toFixed(2); + }, + 'r': args.point_size + }) + .style('opacity', 1); + } + + function mg_update_generic_rollover_circle(args, svg, d) { + var circle = svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) + .classed('mg-line-rollover-circle', true) + .attr('cx', function () { + return args.scales.X(d[args.x_accessor]).toFixed(2); + }) + .attr('cy', function () { + return args.scales.Y(d[args.y_accessor]).toFixed(2); + }) + .attr('r', args.point_size) + .style('opacity', 1); + } + + function mg_trigger_linked_mouseovers(args, d, i) { + if (args.linked && !MG.globals.link) { + MG.globals.link = true; + if (!args.aggregate_rollover || d.value !== undefined || d.values.length > 0) { + var datum = d.values ? d.values[0] : d; + var id = mg_rollover_format_id(datum, i, args); + // trigger mouseover on matching line in .linked charts + d3.selectAll('.' + mg_line_class(datum.line_id) + '.' + mg_rollover_id_class(id)) + .each(function (d) { + d3.select(this).on('mouseover')(d, i); + }); + } + } + } + + var time_rollover_format = function (f, d, accessor, utc) { + var fd; + if (typeof f === 'string') { + fd = MG.time_format(utc, f)(d[accessor]); + } else if (typeof f === 'function') { + fd = f(d); + } else { + fd = d[accessor]; + } + return fd; + }; + + // define our rollover format for numbers + var number_rollover_format = function (f, d, accessor) { + var fd; + if (typeof f === 'string') { + fd = d3.format(f)(d[accessor]); + } else if (typeof f === 'function') { + fd = f(d); + } else { + fd = d[accessor]; + } + return fd; + }; + + function mg_format_y_rollover(args, num, d) { + var formatted_y; + if (args.y_rollover_format !== null) { + if (args.aggregate_rollover) { + formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor);; + } else { + formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor); + } + } else { + if (args.time_series) { + if (args.aggregate_rollover) { + formatted_y = num(d[args.y_accessor]);//number_rollover_format(args.y_rollover_format, d, args.y_accessor); + } else { + formatted_y = args.yax_units + num(d[args.y_accessor]); + } + } + else formatted_y = args.y_accessor + ': ' + args.yax_units + num(d[args.y_accessor]); + } + return formatted_y; + } + + + function mg_format_x_rollover(args, fmt, d) { + var formatted_x; + if (args.x_rollover_format !== null) { + if (args.time_series) { + if (args.aggregate_rollover) { + formatted_x = time_rollover_format(args.x_rollover_format, d, 'key', args.utc); + } else { + formatted_x = time_rollover_format(args.x_rollover_format, d, args.x_accessor, args.utc); + } + } else { + formatted_x = number_rollover_format(args.x_rollover_format, d, args.x_accessor); + } + } else { + if (args.time_series) { + if (args.aggregate_rollover && args.data.length > 1) { + var date = new Date(d.key); + } else { + var date = new Date(+d[args.x_accessor]); + date.setDate(date.getDate()); + } + + formatted_x = fmt(date) + ' '; + } else { + formatted_x = args.x_accessor + ': ' + d[args.x_accessor] + ', '; + } + } + return formatted_x; + } + + function mg_append_aggregate_rollover_timeseries (args, textContainer, formatted_x, d, num) { + var lineCount = 0; + var lineHeight = 1.1; + var formatted_y; + textContainer.append('tspan') + .text(formatted_x.trim()); + + lineCount = 1; + var fy; + + d.values.forEach(function (datum) { + formatted_y = mg_format_y_rollover(args, num, datum); + + var label = textContainer.append('tspan') + .attr({ + x: 0, + y: (lineCount * lineHeight) + 'em' + }) + .text(formatted_y); + + textContainer.append('tspan') + .attr({ + x: -label.node().getComputedTextLength(), + y: (lineCount * lineHeight) + 'em' + }) + .text('\u2014 ') // mdash + .classed('mg-hover-line' + datum.line_id + '-color', args.colors === null) + .attr('fill', args.colors === null ? '' : args.colors[datum.line_id - 1]) + .style('font-weight', 'bold'); + + lineCount++; + }); + + textContainer.append('tspan') + .attr('x', 0) + .attr('y', (lineCount * lineHeight) + 'em') + .text('\u00A0'); + } + + function mg_append_aggregate_rollover_text(args, textContainer, formatted_x, d, num) { + var lineCount = 0; + var lineHeight = 1.1; + d.values.forEach(function (datum) { + formatted_y = mg_format_y_rollover(args, num, datum); + + if (args.y_rollover_format != null) { + formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); + } else { + formatted_y = args.yax_units + num(datum[args.y_accessor]); + } + + var label = textContainer.append('tspan') + .attr({ + x: 0, + y: (lineCount * lineHeight) + 'em' + }) + .text(formatted_x + ' ' + formatted_y); + + textContainer.append('tspan') + .attr({ + x: -label.node().getComputedTextLength(), + y: (lineCount * lineHeight) + 'em' + }) + .text('\u2014 ') // mdash + .classed('mg-hover-line' + datum.line_id + '-color', true) + .style('font-weight', 'bold'); + + lineCount++; + }); + } + + + function mg_format_aggregate_rollover_text(args, svg, textContainer, formatted_x, formatted_y, num, fmt, d, i) { + var lineCount = 0; + var lineHeight = 1.1; + if (args.time_series) { + mg_append_aggregate_rollover_timeseries(args, textContainer, formatted_x, d, num); + + } else { + mg_append_aggregate_rollover_text(args, textContainer, formatted_x, d, num); + } + + // append an blank ( ) line to mdash positioning + textContainer.append('tspan') + .attr('x', 0) + .attr('y', (lineCount * lineHeight) + 'em') + .text('\u00A0'); + } + + function mg_update_line_rollover_text(args, svg, fmt, d, i) { + var num = format_rollover_number(args); + var textContainer = svg.select('.mg-active-datapoint'); + + textContainer + .selectAll('*') + .remove(); + + var formatted_x, formatted_y; + + var formatted_y = mg_format_y_rollover(args, num, d); + var formatted_x = mg_format_x_rollover(args, fmt, d); + + // rollover text when aggregate_rollover is enabled + if (args.aggregate_rollover && args.data.length > 1) { + mg_format_aggregate_rollover_text(args, svg, textContainer, formatted_x, formatted_y, num, fmt, d, i); + } else { + // rollover text when aggregate_rollover is not enabled + if (args.time_series) { + textContainer.select('*').remove(); + textContainer.append('tspan') + .classed('mg-x-rollover-text', true) + .text(formatted_x); + textContainer.append('tspan') + .classed('mg-y-rollover-text', true) + .text(formatted_y); + } else { + textContainer.append('tspan') + .text(formatted_x); + textContainer.append('tspan') + .text(formatted_y); + } + } + } + + function mg_trigger_linked_mouseouts(args, d, i) { + if (args.linked && MG.globals.link) { + MG.globals.link = false; + + var formatter = MG.time_format(args.utc_time, args.linked_format); + var datums = d.values ? d.values : [d]; + datums.forEach(function (datum) { + var v = datum[args.x_accessor]; + var id = (typeof v === 'number') ? i : formatter(v); + + // trigger mouseout on matching line in .linked charts + d3.selectAll('.roll_' + id) + .each(function (d) { + d3.select(this).on('mouseout')(d); + }); + }); + } + } + + function mg_remove_active_data_points_for_aggregate_rollover(args, svg) { + svg.selectAll('circle.mg-line-rollover-circle').style('opacity', 0); + } + + function mg_remove_active_data_points_for_generic_rollover(args, svg, d) { + svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) + .style('opacity', function () { + var id = d.line_id - 1; + + if (args.custom_line_color_map.length > 0 + && args.custom_line_color_map.indexOf(d.line_id) !== undefined + ) { + id = args.custom_line_color_map.indexOf(d.line_id); + } + + if (args.data[id].length == 1) { + // if (args.data.length === 1 && args.data[0].length === 1) { + return 1; + } else { + return 0; + } + }); + } + + function mg_remove_active_text(svg) { + svg.select('.mg-active-datapoint').text(''); + } + function lineChart (args) { this.init = function (args) { this.args = args; @@ -3155,90 +3469,11 @@ MG.button_layout = function(target) { this.rolloverOn = function (args) { var svg = mg_get_svg_child_of(args.target); - var fmt; - switch (args.processed.x_time_frame) { - case 'millis': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S.%L'); - break; - case 'seconds': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S'); - break; - case 'less-than-a-day': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); - break; - case 'four-days': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); - break; - default: - fmt = MG.time_format(args.utc_time, '%b %e, %Y'); - } + var fmt = mg_get_rollover_time_format(args); return function (d, i) { - if (args.aggregate_rollover && args.data.length > 1) { - // hide the circles in case a non-contiguous series is present - svg.selectAll('circle.mg-line-rollover-circle') - .style('opacity', 0); - - d.values.forEach(function (datum) { - if (datum[args.x_accessor] >= args.processed.min_x && - datum[args.x_accessor] <= args.processed.max_x && - datum[args.y_accessor] >= args.processed.min_y && - datum[args.y_accessor] <= args.processed.max_y - ) { - var circle = svg.select('circle.mg-line-rollover-circle.mg-line' + datum.line_id) - .attr({ - 'cx': function () { - return args.scales.X(datum[args.x_accessor]).toFixed(2); - }, - 'cy': function () { - return args.scales.Y(datum[args.y_accessor]).toFixed(2); - }, - 'r': args.point_size - }) - .style('opacity', 1); - } - }); - } else if ((args.missing_is_hidden && d['_missing']) - || d[args.y_accessor] == null - ) { - // disable rollovers for hidden parts of the line - // recall that hidden parts are missing data ranges and possibly also - // data points that have been explicitly identified as missing - return; - } else { - // show circle on mouse-overed rect - if (d[args.x_accessor] >= args.processed.min_x && - d[args.x_accessor] <= args.processed.max_x && - d[args.y_accessor] >= args.processed.min_y && - d[args.y_accessor] <= args.processed.max_y - ) { - var circle = svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) - .classed('mg-line-rollover-circle', true) - .attr('cx', function () { - return args.scales.X(d[args.x_accessor]).toFixed(2); - }) - .attr('cy', function () { - return args.scales.Y(d[args.y_accessor]).toFixed(2); - }) - .attr('r', args.point_size) - .style('opacity', 1); - } - } - - // trigger mouseover on all rects for this date in .linked charts - if (args.linked && !MG.globals.link) { - MG.globals.link = true; - - if (!args.aggregate_rollover || d.value !== undefined || d.values.length > 0) { - var datum = d.values ? d.values[0] : d; - var id = mg_rollover_format_id(datum, i, args); - // trigger mouseover on matching line in .linked charts - d3.selectAll('.' + mg_line_class(datum.line_id) + '.' + mg_rollover_id_class(id)) - .each(function (d) { - d3.select(this).on('mouseover')(d, i); - }); - } - } + mg_update_rollover_circle(args, svg, d); + mg_trigger_linked_mouseovers(args, d, i); svg.selectAll('text') .filter(function (g, j) { @@ -3246,180 +3481,9 @@ MG.button_layout = function(target) { }) .attr('opacity', 0.3); - var num = format_rollover_number(args); - // update rollover text if (args.show_rollover_text) { - var textContainer = svg.select('.mg-active-datapoint'), - lineCount = 0, - lineHeight = 1.1; - - textContainer - .selectAll('*') - .remove(); - - var formatted_x, formatted_y; - - // define our rollover format for time - var time_rollover_format = function (f, d, accessor, utc) { - var fd; - if (typeof f === 'string') { - fd = MG.time_format(utc, f)(d[accessor]); - } else if (typeof f === 'function') { - fd = f(d); - } else { - fd = d[accessor]; - } - return fd; - }; - - // define our rollover format for numbers - var number_rollover_format = function (f, d, accessor) { - var fd; - if (typeof f === 'string') { - fd = d3.format(f)(d[accessor]); - } else if (typeof f === 'function') { - fd = f(d); - } else { - fd = d[accessor]; - } - return fd; - }; - - // format the y-accessor value to show - if (args.y_rollover_format !== null) { - if (args.aggregate_rollover) { - formatted_y = ''; - } else { - formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor); - } - } else { - if (args.time_series) { - if (args.aggregate_rollover) { - formatted_y = ''; - } else { - formatted_y = args.yax_units + num(d[args.y_accessor]); - } - } - else formatted_y = args.y_accessor + ': ' + args.yax_units + num(d[args.y_accessor]); - } - - // format the x-accessor value to show - if (args.x_rollover_format !== null) { - if (args.time_series) { - if (args.aggregate_rollover) { - formatted_x = time_rollover_format(args.x_rollover_format, d, 'key', args.utc); - } else { - formatted_x = time_rollover_format(args.x_rollover_format, d, args.x_accessor, args.utc); - } - } else { - formatted_x = number_rollover_format(args.x_rollover_format, d, args.x_accessor); - } - } else { - if (args.time_series) { - if (args.aggregate_rollover && args.data.length > 1) { - var date = new Date(d.key); - } else { - var date = new Date(+d[args.x_accessor]); - date.setDate(date.getDate()); - } - - formatted_x = fmt(date) + ' '; - } else { - formatted_x = args.x_accessor + ': ' + d[args.x_accessor] + ', '; - } - } - - // rollover text when aggregate_rollover is enabled - if (args.aggregate_rollover && args.data.length > 1) { - if (args.time_series) { - textContainer.append('tspan') - .text(formatted_x.trim()); - - lineCount = 1; - var fy; - - d.values.forEach(function (datum) { - if (args.y_rollover_format != null) { - formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); - } else { - formatted_y = num(datum[args.y_accessor]); - } - - var label = textContainer.append('tspan') - .attr({ - x: 0, - y: (lineCount * lineHeight) + 'em' - }) - .text(formatted_y); - - textContainer.append('tspan') - .attr({ - x: -label.node().getComputedTextLength(), - y: (lineCount * lineHeight) + 'em' - }) - .text('\u2014 ') // mdash - .classed('mg-hover-line' + datum.line_id + '-color', args.colors === null) - .attr('fill', args.colors === null ? '' : args.colors[datum.line_id - 1]) - .style('font-weight', 'bold'); - - lineCount++; - }); - - textContainer.append('tspan') - .attr('x', 0) - .attr('y', (lineCount * lineHeight) + 'em') - .text('\u00A0'); - } else { - d.values.forEach(function (datum) { - if (args.y_rollover_format != null) { - formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); - } else { - formatted_y = args.yax_units + num(datum[args.y_accessor]); - } - - var label = textContainer.append('tspan') - .attr({ - x: 0, - y: (lineCount * lineHeight) + 'em' - }) - .text(formatted_x + ' ' + formatted_y); - - textContainer.append('tspan') - .attr({ - x: -label.node().getComputedTextLength(), - y: (lineCount * lineHeight) + 'em' - }) - .text('\u2014 ') // mdash - .classed('mg-hover-line' + datum.line_id + '-color', true) - .style('font-weight', 'bold'); - - lineCount++; - }); - } - - // append an blank ( ) line to mdash positioning - textContainer.append('tspan') - .attr('x', 0) - .attr('y', (lineCount * lineHeight) + 'em') - .text('\u00A0'); - } else { - // rollover text when aggregate_rollover is not enabled - if (args.time_series) { - textContainer.select('*').remove(); - textContainer.append('tspan') - .classed('mg-x-rollover-text', true) - .text(formatted_x); - textContainer.append('tspan') - .classed('mg-y-rollover-text', true) - .text(formatted_y); - } else { - textContainer.append('tspan') - .text(formatted_x); - textContainer.append('tspan') - .text(formatted_y); - } - } + mg_update_line_rollover_text(args, svg, fmt, d, i); } if (args.mouseover) { @@ -3432,52 +3496,15 @@ MG.button_layout = function(target) { var svg = mg_get_svg_child_of(args.target); return function (d, i) { - if (args.linked && MG.globals.link) { - MG.globals.link = false; - - var formatter = MG.time_format(args.utc_time, args.linked_format); - var datums = d.values ? d.values : [d]; - datums.forEach(function (datum) { - var v = datum[args.x_accessor]; - var id = (typeof v === 'number') ? i : formatter(v); - - // trigger mouseout on matching line in .linked charts - d3.selectAll('.roll_' + id) - .each(function (d) { - d3.select(this).on('mouseout')(d); - }); - }); - } - // remove all active data points when aggregate_rollover is enabled + mg_trigger_linked_mouseouts(args, d, i); if (args.aggregate_rollover) { - svg.selectAll('circle.mg-line-rollover-circle') - .style('opacity', function () { - return 0; - }); - // remove active data point text on mouse out, except if we have a single point + mg_remove_active_data_points_for_aggregate_rollover(args, svg); } else { - svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) - .style('opacity', function () { - var id = d.line_id - 1; - - if (args.custom_line_color_map.length > 0 - && args.custom_line_color_map.indexOf(d.line_id) !== undefined - ) { - id = args.custom_line_color_map.indexOf(d.line_id); - } - - if (args.data[id].length == 1) { - // if (args.data.length === 1 && args.data[0].length === 1) { - return 1; - } else { - return 0; - } - }); + mg_remove_active_data_points_for_generic_rollover(args, svg, d); } - svg.select('.mg-active-datapoint') - .text(''); + mg_remove_active_text(svg); if (args.mouseout) { args.mouseout(d, i); @@ -5429,6 +5456,34 @@ MG.time_format = function(utc, specifier) { return utc ? d3.time.format.utc(specifier) : d3.time.format(specifier); }; +function mg_get_rollover_time_format(args) { + var fmt; + switch (args.processed.x_time_frame) { + case 'millis': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S.%L'); + break; + case 'seconds': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S'); + break; + case 'less-than-a-day': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); + break; + case 'four-days': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); + break; + default: + fmt = MG.time_format(args.utc_time, '%b %e, %Y'); + } + return fmt; +} + +function mg_data_in_plot_bounds (datum, args) { + return datum[args.x_accessor] >= args.processed.min_x && + datum[args.x_accessor] <= args.processed.max_x && + datum[args.y_accessor] >= args.processed.min_y && + datum[args.y_accessor] <= args.processed.max_y +} + function is_array(thing){ return Object.prototype.toString.call(thing) === '[object Array]'; } diff --git a/dist/metricsgraphics.min.js b/dist/metricsgraphics.min.js index 0a4219b821..5e358c1be7 100644 --- a/dist/metricsgraphics.min.js +++ b/dist/metricsgraphics.min.js @@ -1,3 +1,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(t,e){t.select(e).remove()}function a(r){"use strict";var a=zr(r.target);if(n(a,".mg-header"),r.target&&r.title){var o=a.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(o.append("tspan").attr("class","mg-chart-title").text(r.title),r.show_tooltips&&r.description){o.append("tspan").attr("class","mg-chart-description").attr("dx","0.3em").text("");var i=e(o.node());i.popover({html:!0,animation:!1,placement:"top",content:r.description,container:r.target,trigger:"manual",template:'

'}).on("mouseenter",function(){t.selectAll(r.target).selectAll(".mg-popover").remove(),e(this).popover("show"),e(r.target).select(".popover").on("mouseleave",function(){i.popover("hide")})}).on("mouseleave",function(){setTimeout(function(){e(".popover:hover").length||i.popover("hide")},120)})}}r.error&&Hr(r)}function o(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:2*t.buffer/3;var e=kr(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),Ar(e,t,"mg-y-rug-mono")}function s(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 l(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 c(e){var r=Fr(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={};a.min=n[0],a.max=n[1],a.min>=0&&!e.min_y&&!e.min_y_from_data&&(a.min=0),s(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&&(a.min=a.min/e.inflator),e.processed.min_y=a.min,e.processed.max_y=a.max}function u(t,e){return e.domain([t.processed.min_y,t.processed.max_y]).range([pr(t),t.top]),e}function f(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=u(e,r),e.scales.Y.clamp("log"===e.y_scale_type),e.scales.Y_axis=u(e,t.scale.linear())}function d(t,e){e.y_label&&t.append("text").attr("class","label").attr("x",function(){return-1*(hr(e)+(pr(e)-hr(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 p(t){function e(t){return 1e3===t?3:1e6===t?7:Math.log(t)/Math.LN10}var r=t.scales.Y.ticks(t.yax_count);"log"===t.y_scale_type&&(r=r.filter(function(t){return Math.abs(e(t))%1<1e-6||Math.abs(e(t))%1>1-1e-6}));var n=t.scales.Y.ticks(t.yax_count).length,a=!0;t.data.forEach(function(e){e.forEach(function(e){return e[t.y_accessor]%1!==0?(a=!1,!1):void 0})}),a&&n>t.processed.max_y&&"count"===t.format&&(r=r.filter(function(t){return t%1===0})),t.processed.y_ticks=r}function m(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 h(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 _(t,e){var r=l(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 g(t){t.processed||(t.processed={});var e=zr(t.target);if(c(t),MG.call_hook("y_axis.process_min_max",t,t.processed.min_y,t.processed.max_y),f(t),Mr(t,"yf","Y",t.y_accessor),br(e,".mg-y-axis"),!t.y_axis)return this;var r=wr(e,"mg-y-axis");return d(r,t),p(t),m(r,t),h(r,t),_(r,t),t.y_rug&&o(t),this}function v(t){var e=zr(t.target);br(e,".mg-y-axis");var r=wr(e,"mg-y-axis"),n=r.selectAll("text").data(t.categorical_variables).enter().append("svg:text").attr("x",t.left).attr("y",function(e){return t.scales.Y(e)+t.scales.Y.rangeBand()/2+t.buffer*t.outer_padding_percentage}).attr("dy",".35em").attr("text-anchor","end").text(String);Dr(n,t.rotate_y_labels)}function x(t){return Gr(t,"Y",t.categorical_variables,pr(t),t.top,t.padding_percentage,t.outer_padding_percentage),Mr(t,"yf","Y",t.y_accessor),t.y_axis?(v(t),this):this}function y(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:t.buffer;var e=kr(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),Ar(e,t,"mg-x-rug-mono")}function b(t){t.processed||(t.processed={})}function w(e){Mr(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:t.scale.linear(),e.scales.X.domain([e.processed.min_x,e.processed.max_x]).range([gr(e),xr(e)-e.additional_buffer])}function k(t){"use strict";var e=zr(t.target);if(b(t),w(t),"point"===t.chart_type&&(G(t),O(t)),br(e,".mg-x-axis"),!t.x_axis)return this;var r=wr(e,"mg-x-axis");return t.x_label&&E(r,t),q(r,t),Q(r,t),t.x_rug&&y(t),this}function M(t){var e=zr(t.target),r=0;"bar"===t.chart_type&&(r=t.buffer+5),Gr(t,"X",t.categorical_variables.reverse(),t.left,xr(t)-r),Mr(t,"xf","X",t.x_accessor),br(e,".mg-x-axis");var n=wr(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.outer_padding_percentage+r/2}).attr("y",pr(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();Br(r,t,n)}),Dr(n,e.rotate_x_labels)}function G(e){var r,n;null!==e.color_accessor&&(r=D(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)),Mr(e,"color","color",e.color_accessor))}function D(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 O(e){var r,n;null!==e.size_accessor&&(r=Y(e),n=C(e),e.scales.size=t.scale.linear().domain(r).range(n).clamp(!0),Mr(e,"size","size",e.size_accessor))}function Y(e){return null===e.size_domain?t.extent(e.data[0],function(t){return t[e.size_accessor]}):e.size_domain}function C(t){var e;return e=null===t.size_range?[1,5]:t.size_range}function E(t,e){t.append("text").attr("class","label").attr("x",function(){return(e.left+e.width-e.right)/2}).attr("y",(e.height-e.bottom/2).toFixed(2)).attr("dy",".50em").attr("text-anchor","middle").text(function(){return e.x_label})}function z(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 F(t){var e;return e=X(t)?"millis":P(t)?"seconds":$(t)?"less-than-a-day":S(t)?"four-days":j(t)?"many-days":L(t)?"many-months":N(t)?"years":"default"}function X(t){return 10>t}function P(t){return 60>t}function $(t){return 24>=t/3600}function S(t){return 96>=t/3600}function j(t){return 93>=t/86400}function L(t){return 730>t/86400}function N(t){return t/86400>=730}function I(t,e){var r;return r=X(e)?MG.time_format(t,"%M:%S.%L"):P(e)?MG.time_format(t,"%M:%S"):$(e)?MG.time_format(t,"%H:%M"):S(e)?MG.time_format(t,"%H:%M"):j(e)?MG.time_format(t,"%b %d"):L(e)?MG.time_format(t,"%b"):MG.time_format(t,"%Y")}function R(t){var e,r,n;t.time_series&&(e=(t.processed.max_x-t.processed.min_x)/1e3,n=F(e),r=I(t.utc_time,e)),t.processed.main_x_time_format=r,t.processed.x_time_frame=n}function B(e){if(e.xax_format)return e.xax_format;var r=e.processed.original_data||e.data,n=Fr(r)[0][e.processed.original_x_accessor||e.x_accessor];return function(r){R(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){"bar"===e.chart_type||e.y_extended_ticks||(H(e,t),U(e,t))}function H(t,e){var r=t.scales.X.ticks(t.xax_count).length-1;t.x_extended_ticks||e.append("line").attr("x1",function(){return 0===t.xax_count?gr(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?xr(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){var r=t.scales.X.ticks(t.xax_count);e.selectAll(".mg-xax-ticks").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",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){Z(e,t),V(e,t)}function Z(e,r){var n=e.scales.X.ticks(e.xax_count),a=r.selectAll(".mg-xax-labels").data(n).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?(a.append("tspan").classed("mg-european-hours",!0).text(function(e,r){var n=new Date(e);return 0===r?t.time.format("%H")(n):""}),a.append("tspan").classed("mg-european-minutes-seconds",!0).text(function(t){var r=new Date(t);return":"+e.processed.xax_format(r)})):a.text(function(t){return e.xax_units+e.processed.xax_format(t)}),Tr(a)){a.filter(function(t,e){return(e+1)%2==0}).remove();var o=zr(e.target),n=o.selectAll(".mg-xax-ticks").filter(function(t,e){return(e+1)%2==0}).remove()}}function V(t,e){if(t.time_series&&(t.show_years||t.show_secondary_x_label)){var r=W(t);J(t,e,r.timeframe,r.yformat,r.secondary)}}function W(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");case"many-months":r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%b");default:r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%Y")}return r}function J(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=wr(e,"mg-year-marker");"default"===r&&t.show_year_markers&&K(t,s,o,n),"years"!=r&&te(t,s,o,n)}function K(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",mr(t)).attr("y2",dr(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 dr(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){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)})}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=Fr(t.data),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=B(t):"bar"===e&&(t.processed.xax_format=z(t)))}function fe(t){var e={target:null,title:null,description:null};return t||(t={}),t.processed||(t.processed={}),t=Nr(t,e)}function de(t){var e=Fr(t.processed.original_data||t.data)[0];t.time_series=e[t.processed.original_x_accessor||t.x_accessor]instanceof Date}function pe(t){var e=t.width;t.full_width&&(e=jr(t.target)),t.width=e}function me(t){var e=t.height;t.full_height&&(e=Lr(t.target)),"bar"===t.chart_type&&null===e&&(e=t.height=t.data[0].length*t.bar_height+t.top+t.bottom),t.height=e}function he(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 _e(e,r){return zr(r.target).empty()&&(e=t.select(r.target).append("svg").classed("linked",r.linked).attr("width",r.width).attr("height",r.height)),e}function ge(t,e){t.selectAll(".mg-clip-path").remove(),t.append("defs").attr("class","mg-clip-path").append("clipPath").attr("id","mg-plot-window-"+Pr(e.target)).append("svg:rect").attr("x",e.left).attr("y",e.top).attr("width",e.width-e.left-e.right-e.buffer).attr("height",e.height-e.top-e.bottom-e.buffer+1)}function ve(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 xe(t,e){t.attr("viewBox","0 0 "+e.width+" "+e.height),(e.full_width||e.full_height)&&t.attr("preserveAspectRatio","xMinYMin meet")}function ye(t){t.classed("mg-missing",!1),t.selectAll(".mg-missing-text").remove(),t.selectAll(".mg-missing-pane").remove()}function be(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;ro;r--)t.selectAll(".mg-main-line.mg-line"+r+"-color").remove()}}function we(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 ke(e){"use strict";e=arguments[0],e=fe(e);var r=t.select(e.target);we(r,e);var n=r.selectAll("svg");return de(e),pe(e),me(e),he(n,e),n=_e(n,e),ge(n,e),ve(n,e),xe(n,e),ye(n),a(e),be(n,e),this}function Me(t){return t.label}function Ae(t){t.selectAll(".mg-markers").remove(),t.selectAll(".mg-baselines").remove()}function Ge(t){return function(e){return t.scales.X(e[t.x_accessor])>gr(t)&&t.scales.X(e[t.x_accessor])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=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;mi;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 We(t/(6*u))}),o=rr(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 Qe(t,e,r,n){for(var a=[],o=0;o=0&&1>=t?Math.pow(1-Math.pow(t,e),e):0}function We(t){return Ve(t,2)}function Je(t){return Ve(t,3)}function Ke(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 tr(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 er(t){var e,r,n=Ke(t);r=n.xbar,e=n.ybar;var a=tr(t,r,e);return{beta:a,xbar:r,ybar:e,x0:e-a*r}}function rr(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),h=t.zip(e,r,o).sort(),_=Math.abs(p-m)/a,g=m,v=p,x=t.range(g,v,_),y=[],b=0;bt?"M"+u.map(function(e){return e(t)}).join("L"):e}}}function or(t){return"[object Array]"===Object.prototype.toString.call(t)}function ir(t){return"[object Function]"===Object.prototype.toString.call(t)}function sr(t){return or(t)&&0===t.length}function lr(t){return"[object Object]"===Object.prototype.toString.call(t)}function cr(e){var r=e.map(function(t){return or(t)===!0&&t.length>0});return t.sum(r)===e.length}function ur(e){var r=e.map(function(t){return lr(t)===!0});return t.sum(r)===e.length}function fr(t){return sr(t)||ur(t)}function dr(t){return t.height-t.bottom}function pr(t){return dr(t)-t.buffer}function mr(t){return t.top}function hr(t){return mr(t)+t.buffer}function _r(t){return t.left}function gr(t){return _r(t)+t.buffer}function vr(t){return t.width-t.right}function xr(t){return vr(t)-t.buffer}function yr(t){t.exit().remove()}function br(t,e){t.selectAll(e).remove()}function wr(t,e){return t.append("g").classed(e,!0)}function kr(t,e){var r=zr(t.target),n=Fr(t.data),a=r.selectAll("line."+e).data(n);return a.enter().append("svg:line").attr("class",e).attr("opacity",.3),yr(a),yr(a),a}function Mr(t,e,r,n){t.scalefns[e]=function(e){return t.scales[r](e[n])}}function Ar(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 Gr(e,r,n,a,o,i,s){e.scales[r]=t.scale.ordinal().domain(n).rangeRoundBands([a,o],i||0,s||0)}function Dr(e,r){r&&e.attr({dy:0,transform:function(){var e=t.select(this);return"rotate("+r+" "+e.attr("x")+","+e.attr("y")+")"}})}function Tr(t){t=t[0];for(var e=0;e=r.top&&(o=r.top-16),a.attr("y",o)}}function Yr(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=n.top?n.bottom-r.top:!1}function Er(t,e){for(var r=t.getBoundingClientRect(),n=0;nr.right||a.rightr&&(t.textContent=e.slice(0,--a)+"...",n=t.getBBox(),"..."!==t.textContent););}function qr(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 Hr(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 Ur(t){console.log("INTERNAL ERROR : ",t.target," : ",t.internal_error)}window.MG={version:"2.7.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"},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:30,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,x_rollover_format:null,y_rollover_format:null,transition_on_update:!0,mouseover: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];Nr(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+"`"),Rr(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:'',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-dm.width?"left":"left"==s&&u.left-fi.top+i.height&&(a.top=i.top+i.height-l)}else{var c=e.left-o,u=e.left+o+r;ci.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:''}),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=a,MG.y_rug=o,MG.y_axis=g,MG.y_axis_categorical=x,MG.x_rug=y,MG.x_axis=k,MG.x_axis_categorical=M,MG.init=ke,MG.markers=$e,"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('");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('
"),l=0;l'+n[l]+"");e("."+this._strip_punctuation(d)+"-btns .dropdown-menu li a").on("click",f)}return this},this},function(){"use strict";function e(t,e,i){o(t,e),n(t,e),a(t,e),r(t,e,i)}function r(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])}).y1(function(t){var r=e.show_confidence_band[1];return e.scales.Y(t[r])}).interpolate(e.interpolate).tension(e.interpolate_tension))}function n(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 a(e,r){r.flat_line=t.svg.line().defined(function(t){return(void 0==t._missing||1!=t._missing)&&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 o(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||1!=t._missing)&&null!=t[e.y_accessor]}))}function s(t,e,r,n){var a;t.show_confidence_band&&(a=e.existing_band.empty()?r.append("path").attr("class","mg-confidence-band"):e.existing_band.transition().duration(function(){return t.transition_on_update?1e3:0}),a.attr("d",e.confidence_area(t.data[n])).attr("clip-path","url(#mg-plot-window-"+Pr(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-"+Pr(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-"+Pr(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— "+a+"  "+e.legend_text:"— "+a+"  "+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.length0?t.custom_line_color_map[r]:e;e++}}function b(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 w(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?i: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 M(e,r,n,a,o){var i,s=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]]);i=wr(r,"mg-voronoi"),i.selectAll("path").data(s(b(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",w(e)).on("mouseover",n).on("mouseout",a).on("mousemove",o),T(e,r)}function A(e){var r=t.nest().key(function(t){return t[e.x_accessor]}).entries(t.merge(e.data)).sort(function(t,e){return new Date(t.key)-new Date(e.key)});return r.forEach(function(t){var r=t.values[0];t.key=r[e.x_accessor]}),r}function G(t,e,r,n,a){var o=A(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?gr(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?xr(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=O(e.line_id);return null===t.colors&&(n+=" "+Y(r.line_id)),n}).join(" ");return t.linked&&e.values.length>0&&(r+=" "+C(E(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),F(t,e)}function D(t,e){e.select(".mg-rollover-rect rect").on("mouseover")(t.data[0][0],0)}function T(t,e){for(var r=0;r0&&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 O(t){return"mg-line"+t}function Y(t){return"mg-line"+t+"-color"}function C(t){return"roll_"+t}function E(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 z(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)+" "+O(e.line_id);return t.linked&&(n+=n+" "+C(E(e,r,t))),n}).attr("x",function(e,r){return 1===s.length?gr(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?xr(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),$(t)&&D(t,e)}function F(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 $(t){return 1==t.data.length&&1==t.data[0].length}function S(t,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,a=t.data[n];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+"-color");s(t,e,r,n),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 j(t){var r={},n=zr(t.target);br(n,".mg-line-legend"),h(t,r,n),r.data_median=0,r.update_transition_duration=t.transition_on_update?1e3:0,r.display_area=t.area&&!t.use_data_y_min&&t.data.length<=1,r.legend_text="",e(t,r,n),r.existing_band=n.selectAll(".mg-confidence-band");var a=MG.call_hook("line.before_all_series",[t]);a!==!1&&S(t,r,n),m(t.legend_target,r.legend_text)}function L(t,e){var r=zr(t.target);_(r),v(t,r),x(t,r),y(t),X(t)?M(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):P(t)?G(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):z(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t))}function N(e){this.init=function(t){return this.args=t,t.data&&0!==t.data.length?(t.internal_error=void 0,Le(t),Ne(t),ke(t),k(t),g(t),this.markers(),this.mainPlot(),this.rollover(),this.windowListeners(),MG.call_hook("line.after_init",this),this):(t.internal_error="No data was supplied",Ur(t),this)},this.mainPlot=function(){return j(e),this},this.markers=function(){return $e(e),this},this.rollover=function(){var t=this;return L(e,t),MG.call_hook("line.after_rollover",e),this},this.rolloverOn=function(e){var r,n=zr(e.target);switch(e.processed.x_time_frame){case"millis":r=MG.time_format(e.utc_time,"%b %e, %Y %H:%M:%S.%L");break;case"seconds":r=MG.time_format(e.utc_time,"%b %e, %Y %H:%M:%S");break;case"less-than-a-day":r=MG.time_format(e.utc_time,"%b %e, %Y %I:%M%p");break;case"four-days":r=MG.time_format(e.utc_time,"%b %e, %Y %I:%M%p");break;default:r=MG.time_format(e.utc_time,"%b %e, %Y")}return function(a,o){if(e.aggregate_rollover&&e.data.length>1)n.selectAll("circle.mg-line-rollover-circle").style("opacity",0),a.values.forEach(function(t){if(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){n.select("circle.mg-line-rollover-circle.mg-line"+t.line_id).attr({cx:function(){return e.scales.X(t[e.x_accessor]).toFixed(2)},cy:function(){return e.scales.Y(t[e.y_accessor]).toFixed(2)},r:e.point_size}).style("opacity",1)}});else{if(e.missing_is_hidden&&a._missing||null==a[e.y_accessor])return;if(a[e.x_accessor]>=e.processed.min_x&&a[e.x_accessor]<=e.processed.max_x&&a[e.y_accessor]>=e.processed.min_y&&a[e.y_accessor]<=e.processed.max_y){n.selectAll("circle.mg-line-rollover-circle.mg-line"+a.line_id).classed("mg-line-rollover-circle",!0).attr("cx",function(){return e.scales.X(a[e.x_accessor]).toFixed(2)}).attr("cy",function(){return e.scales.Y(a[e.y_accessor]).toFixed(2)}).attr("r",e.point_size).style("opacity",1)}}if(e.linked&&!MG.globals.link&&(MG.globals.link=!0,!e.aggregate_rollover||void 0!==a.value||a.values.length>0)){var i=a.values?a.values[0]:a,s=E(i,o,e);t.selectAll("."+O(i.line_id)+"."+C(s)).each(function(e){t.select(this).on("mouseover")(e,o)})}n.selectAll("text").filter(function(t){return a===t}).attr("opacity",.3);var l=nr(e);if(e.show_rollover_text){var c=n.select(".mg-active-datapoint"),u=0,f=1.1;c.selectAll("*").remove();var d,p,m=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]},h=function(e,r,n){var a;return a="string"==typeof e?t.format(e)(r[n]):"function"==typeof e?e(r):r[n]};if(p=null!==e.y_rollover_format?e.aggregate_rollover?"":h(e.y_rollover_format,a,e.y_accessor):e.time_series?e.aggregate_rollover?"":e.yax_units+l(a[e.y_accessor]):e.y_accessor+": "+e.yax_units+l(a[e.y_accessor]),null!==e.x_rollover_format)d=e.time_series?e.aggregate_rollover?m(e.x_rollover_format,a,"key",e.utc):m(e.x_rollover_format,a,e.x_accessor,e.utc):h(e.x_rollover_format,a,e.x_accessor);else if(e.time_series){if(e.aggregate_rollover&&e.data.length>1)var _=new Date(a.key);else{var _=new Date(+a[e.x_accessor]);_.setDate(_.getDate())}d=r(_)+" "}else d=e.x_accessor+": "+a[e.x_accessor]+", ";if(e.aggregate_rollover&&e.data.length>1){if(e.time_series){c.append("tspan").text(d.trim()),u=1;a.values.forEach(function(t){p=null!=e.y_rollover_format?h(e.y_rollover_format,t,e.y_accessor):l(t[e.y_accessor]);var r=c.append("tspan").attr({x:0,y:u*f+"em"}).text(p);c.append("tspan").attr({x:-r.node().getComputedTextLength(),y:u*f+"em"}).text("— ").classed("mg-hover-line"+t.line_id+"-color",null===e.colors).attr("fill",null===e.colors?"":e.colors[t.line_id-1]).style("font-weight","bold"),u++}),c.append("tspan").attr("x",0).attr("y",u*f+"em").text(" ")}else a.values.forEach(function(t){p=null!=e.y_rollover_format?h(e.y_rollover_format,t,e.y_accessor):e.yax_units+l(t[e.y_accessor]);var r=c.append("tspan").attr({x:0,y:u*f+"em"}).text(d+" "+p);c.append("tspan").attr({x:-r.node().getComputedTextLength(),y:u*f+"em"}).text("— ").classed("mg-hover-line"+t.line_id+"-color",!0).style("font-weight","bold"),u++});c.append("tspan").attr("x",0).attr("y",u*f+"em").text(" ")}else e.time_series?(c.select("*").remove(),c.append("tspan").classed("mg-x-rollover-text",!0).text(d),c.append("tspan").classed("mg-y-rollover-text",!0).text(p)):(c.append("tspan").text(d),c.append("tspan").text(p))}e.mouseover&&e.mouseover(a,o)}},this.rolloverOff=function(e){var r=zr(e.target);return function(n,a){if(e.linked&&MG.globals.link){MG.globals.link=!1;var o=MG.time_format(e.utc_time,e.linked_format),i=n.values?n.values:[n];i.forEach(function(r){var n=r[e.x_accessor],i="number"==typeof n?a:o(n);t.selectAll(".roll_"+i).each(function(e){t.select(this).on("mouseout")(e)})})}e.aggregate_rollover?r.selectAll("circle.mg-line-rollover-circle").style("opacity",function(){return 0}):r.selectAll("circle.mg-line-rollover-circle.mg-line"+n.line_id).style("opacity",function(){var t=n.line_id-1;return e.custom_line_color_map.length>0&&void 0!==e.custom_line_color_map.indexOf(n.line_id)&&(t=e.custom_line_color_map.indexOf(n.line_id)),1==e.data[t].length?1:0}),r.select(".mg-active-datapoint").text(""),e.mouseout&&e.mouseout(n,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Se(this.args),this},this.init(e)}MG.register("line",N)}.call(this),function(){"use strict";function r(r){this.init=function(t){return this.args=t,Le(t),Ie(t),ke(t),k(t),g(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var t=zr(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 $e(r),this},this.rollover=function(){{var t=zr(r.target);e(e(r.target).find("svg").get(0))}t.selectAll(".mg-rollover-rect").remove(),t.selectAll(".mg-active-datapoint").remove(),t.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r.width-r.right).attr("y",.75*r.top).attr("text-anchor","end");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=zr(e.target);return function(n,a){r.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3);var o=e.processed.xax_format||MG.time_format(e.utc_time,"%b %e, %Y"),i=nr(e);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&&r.select(".mg-active-datapoint").text(function(){if(e.time_series){var t=new Date(+n[e.x_accessor]);return t.setDate(t.getDate()),o(t)+" "+e.yax_units+i(n[e.y_accessor])}return e.x_accessor+": "+i(n[e.x_accessor])+", "+e.y_accessor+": "+e.yax_units+i(n[e.y_accessor])}),e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(e){var r=zr(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),r.select(".mg-active-datapoint").text(""),e.mouseout&&e.mouseout(n,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Se(this.args),this},this.init(r)}var n={mouseover:function(e){t.select("#histogram svg .mg-active-datapoint").text("Frequency Count: "+e.y)},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(e){this.init=function(t){return this.args=t,Le(t),Be(t),ke(t),k(t),g(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.markers=function(){return $e(e),e.least_squares&&qe(e),this},this.mainPlot=function(){var t,r=zr(e.target);r.selectAll(".mg-points").remove(),t=r.append("g").classed("mg-points",!0);var n=t.selectAll("circle").data(e.data[0]).enter().append("svg:circle").attr("class",function(t,e){return"path-"+e}).attr("cx",e.scalefns.xf).attr("cy",e.scalefns.yf);return null!==e.color_accessor?(n.attr("fill",e.scalefns.color),n.attr("stroke",e.scalefns.color)):n.classed("mg-points-mono",!0),null!==e.size_accessor?n.attr("r",e.scalefns.size):n.attr("r",e.point_size),this},this.rollover=function(){var r=zr(e.target);r.selectAll(".mg-voronoi").remove(),r.selectAll(".mg-active-datapoint").remove(),r.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",e.width-e.right).attr("y",.75*e.top).attr("text-anchor","end");var n=t.geom.voronoi().x(e.scalefns.xf).y(e.scalefns.yf).clipExtent([[e.buffer,e.buffer+e.title_y_position],[e.width-e.buffer,e.height-e.buffer]]),a=r.append("g").attr("class","mg-voronoi");return a.selectAll("path").data(n(e.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(e)).on("mouseout",this.rolloverOff(e)).on("mousemove",this.rolloverMove(e)),this},this.rolloverOn=function(e){var r=zr(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)+1}):o.attr("r",e.point_size),e.linked&&!MG.globals.link&&(MG.globals.link=!0,t.selectAll(".mg-voronoi .path-"+a).each(function(){t.select(this).on("mouseover")(n,a)}));var i=MG.time_format(e.utc_time,"%b %e, %Y"),s=nr(e);e.show_rollover_text&&r.select(".mg-active-datapoint").text(function(){if(e.time_series){var t=new Date(+n.point[e.x_accessor]);return t.setDate(t.getDate()),i(t)+" "+e.yax_units+s(n.point[e.y_accessor])}return e.x_accessor+": "+s(n.point[e.x_accessor])+", "+e.y_accessor+": "+e.yax_units+s(n.point[e.y_accessor])}),e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(e){var r=zr(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),r.select(".mg-active-datapoint").text(""),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 Se(this.args),this},this.init(e)}var r={buffer:16,ls:!1,lowess:!1,point_size:2.5,size_accessor:null,color_accessor:null,size_range:null,color_range:null,size_domain:null,color_domain:null,color_type:"number"};MG.register("point",e,r)}.call(this),function(){"use strict";function t(t){this.args=t,this.init=function(t){return this.args=t,Le(t),Re(t),ke(t),this.is_vertical="vertical"===t.bar_orientation,this.is_vertical?(M(t),g(t)):(k(t),x(t)),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var e,r,n,a,o,i=zr(t.target),s=t.data[0],l=i.select("g.mg-barplot"),c=l.empty(),u=c&&t.animate_on_load,f=u||t.transition_on_update,d=t.transition_duration||1e3;c&&(l=i.append("g").classed("mg-barplot",!0)),e=e=l.selectAll(".mg-bar").data(s),e.exit().remove(),e.enter().append("rect").classed("mg-bar",!0),t.predictor_accessor&&(r=l.selectAll(".mg-bar-prediction").data(s),r.exit().remove(),r.enter().append("rect").classed("mg-bar-prediction",!0)),t.baseline_accessor&&(o=l.selectAll(".mg-bar-baseline").data(s),o.exit().remove(),o.enter().append("line").classed("mg-bar-baseline",!0));var p;return f&&(e=e.transition().duration(d),r&&(r=r.transition().duration(d)),o&&(o=o.transition().duration(d))),i.select(".mg-y-axis").node().parentNode.appendChild(l.node()),this.is_vertical?(p=t.scales.X.rangeBand()/1.5,u&&(e.attr({height:0,y:t.scales.Y(0)}),r&&r.attr({height:0,y:t.scales.Y(0)}),o&&o.attr({y1:t.scales.Y(0),y2:t.scales.Y(0)})),e.attr("y",t.scalefns.yf).attr("x",function(e){return t.scalefns.xf(e)+p/2}).attr("width",p).attr("height",function(e){return 0-(t.scalefns.yf(e)-t.scales.Y(0))}),t.predictor_accessor&&(n=t.predictor_proportion,a=n-1,r.attr("y",function(e){return t.scales.Y(0)-(t.scales.Y(0)-t.scales.Y(e[t.predictor_accessor]))}).attr("x",function(e){return t.scalefns.xf(e)+a*p/(2*n)+p/2}).attr("width",p/n).attr("height",function(e){return 0-(t.scales.Y(e[t.predictor_accessor])-t.scales.Y(0))})),t.baseline_accessor&&(n=t.predictor_proportion,o.attr("x1",function(e){return t.scalefns.xf(e)+p/2-p/n+p/2}).attr("x2",function(e){return t.scalefns.xf(e)+p/2+p/n+p/2}).attr("y1",function(e){return t.scales.Y(e[t.baseline_accessor])}).attr("y2",function(e){return t.scales.Y(e[t.baseline_accessor])}))):(p=t.scales.Y.rangeBand()/1.5,u&&(e.attr("width",0),r&&r.attr("width",0),o&&o.attr({x1:t.scales.X(0),x2:t.scales.X(0)})),e.attr("x",t.scales.X(0)).attr("y",function(e){return t.scalefns.yf(e)+p/2}).attr("height",p).attr("width",function(e){return t.scalefns.xf(e)-t.scales.X(0)}),t.predictor_accessor&&(n=t.predictor_proportion,a=n-1,r.attr("x",t.scales.X(0)).attr("y",function(e){return t.scalefns.yf(e)+a*p/(2*n)+p/2}).attr("height",p/n).attr("width",function(e){return t.scales.X(e[t.predictor_accessor])-t.scales.X(0)})),t.baseline_accessor&&(n=t.predictor_proportion,o.attr("x1",function(e){return t.scales.X(e[t.baseline_accessor])}).attr("x2",function(e){return t.scales.X(e[t.baseline_accessor])}).attr("y1",function(e){return t.scalefns.yf(e)+p/2-p/n+p/2}).attr("y2",function(e){return t.scalefns.yf(e)+p/2+p/n+p/2}))),this},this.markers=function(){return $e(t),this},this.rollover=function(){var e,r=zr(t.target);r.selectAll(".mg-rollover-rect").remove(),r.selectAll(".mg-active-datapoint").remove(),r.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",t.width-t.right).attr("y",.75*t.top).attr("dy",".35em").attr("text-anchor","end"),e=r.append("g").attr("class","mg-rollover-rect");var n=e.selectAll(".mg-bar-rollover").data(t.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return this.is_vertical?n.attr("x",t.scalefns.xf).attr("y",function(){return t.scales.Y(0)-t.height}).attr("width",t.scales.X.rangeBand()).attr("height",t.height).attr("opacity",0).on("mouseover",this.rolloverOn(t)).on("mouseout",this.rolloverOff(t)).on("mousemove",this.rolloverMove(t)):n.attr("x",t.scales.X(0)).attr("y",t.scalefns.yf).attr("width",t.width).attr("height",t.scales.Y.rangeBand()+2).attr("opacity",0).on("mouseover",this.rolloverOn(t)).on("mouseout",this.rolloverOff(t)).on("mousemove",this.rolloverMove(t)),this},this.rolloverOn=function(t){var e=zr(t.target),r=this.is_vertical?t.x_accessor:t.y_accessor,n=this.is_vertical?t.y_accessor:t.x_accessor,a=this.is_vertical?t.yax_units:t.xax_units;return function(o,i){e.selectAll("text").filter(function(t){return o===t}).attr("opacity",.3);var s=MG.time_format(t.utc_time,"%b %e, %Y"),l=nr(t);e.selectAll("g.mg-barplot .mg-bar").filter(function(t,e){return e===i}).classed("active",!0),t.show_rollover_text&&e.select(".mg-active-datapoint").text(function(){if(t.time_series){var e=new Date(+o[n]);return e.setDate(e.getDate()),s(e)+" "+a+l(o[r])}return o[r]+": "+l(o[n])}),t.mouseover&&t.mouseover(o,i)}},this.rolloverOff=function(t){var e=zr(t.target);return function(r,n){e.selectAll("g.mg-barplot .mg-bar").classed("active",!1),e.select(".mg-active-datapoint").text(""),t.mouseout&&t.mouseout(r,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Se(this.args),this},this.init(t)}var e={y_accessor:"factor",x_accessor:"value",baseline_accessor:null,predictor_accessor:null,predictor_proportion:5,dodge_accessor:null,binned:!0,padding_percentage:0,outer_padding_percentage:.1,height:500,bar_height:20,top:45,left:70,truncate_x_labels:!0,truncate_y_labels:!0,rotate_x_labels:0,rotate_y_labels:0};MG.register("bar",t,e)}.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=Nr(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;a(r);var n,o,i,s,l,c,u,f,d,p,m,h,_=r.target,g=t.select(_).append("table").classed("mg-data-table",!0),v=g.append("colgroup"),x=g.append("thead"),y=g.append("tbody");for(i=x.append("tr"),h=0;h=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,pe(f),me(f),a(f);var d=t.select(f.target);we(d,f);var p=d.selectAll("svg");if(he(p,f),p=_e(p,f),ve(p,f),xe(p,f),c(f),p.classed("mg-missing",!0),u(f),f.show_missing_background){o(f),r(f),n(f);var m=wr(p,"mg-missing-pane");i(m,f),s(m,f),l(m,f)}return e(p,f),this.windowListeners(),this},this.windowListeners=function(){return Se(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=Le,MG.process_line=Ne,MG.process_histogram=Ie,MG.process_categorical_variables=Re,MG.process_point=Be,MG.add_ls=qe,MG.add_lowess=He,MG.lowess_robust=Ue,MG.lowess=Qe,MG.least_squares=Ze,MG.format_rollover_number=nr,MG.path_tween=ar,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 Qr=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=Nr,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=Ir,MG.warn_deprecation=Rr,MG.truncate_text=Br,MG.wrap_text=qr,MG.error=Hr,MG}); \ No newline at end of file +!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(t,e){t.select(e).remove()}function a(r){"use strict";var a=Xr(r.target);if(n(a,".mg-header"),r.target&&r.title){var o=a.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(o.append("tspan").attr("class","mg-chart-title").text(r.title),r.show_tooltips&&r.description){o.append("tspan").attr("class","mg-chart-description").attr("dx","0.3em").text("");var i=e(o.node());i.popover({html:!0,animation:!1,placement:"top",content:r.description,container:r.target,trigger:"manual",template:'

'}).on("mouseenter",function(){t.selectAll(r.target).selectAll(".mg-popover").remove(),e(this).popover("show"),e(r.target).select(".popover").on("mouseleave",function(){i.popover("hide")})}).on("mouseleave",function(){setTimeout(function(){e(".popover:hover").length||i.popover("hide")},120)})}}r.error&&Qr(r)}function o(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:2*t.buffer/3;var e=Ar(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),Dr(e,t,"mg-y-rug-mono")}function s(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 l(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 c(e){var r=Pr(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={};a.min=n[0],a.max=n[1],a.min>=0&&!e.min_y&&!e.min_y_from_data&&(a.min=0),s(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&&(a.min=a.min/e.inflator),e.processed.min_y=a.min,e.processed.max_y=a.max}function u(t,e){return e.domain([t.processed.min_y,t.processed.max_y]).range([hr(t),t.top]),e}function f(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=u(e,r),e.scales.Y.clamp("log"===e.y_scale_type),e.scales.Y_axis=u(e,t.scale.linear())}function d(t,e){e.y_label&&t.append("text").attr("class","label").attr("x",function(){return-1*(gr(e)+(hr(e)-gr(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 p(t){function e(t){return 1e3===t?3:1e6===t?7:Math.log(t)/Math.LN10}var r=t.scales.Y.ticks(t.yax_count);"log"===t.y_scale_type&&(r=r.filter(function(t){return Math.abs(e(t))%1<1e-6||Math.abs(e(t))%1>1-1e-6}));var n=t.scales.Y.ticks(t.yax_count).length,a=!0;t.data.forEach(function(e){e.forEach(function(e){return e[t.y_accessor]%1!==0?(a=!1,!1):void 0})}),a&&n>t.processed.max_y&&"count"===t.format&&(r=r.filter(function(t){return t%1===0})),t.processed.y_ticks=r}function m(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 h(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 _(t,e){var r=l(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 g(t){t.processed||(t.processed={});var e=Xr(t.target);if(c(t),MG.call_hook("y_axis.process_min_max",t,t.processed.min_y,t.processed.max_y),f(t),Gr(t,"yf","Y",t.y_accessor),kr(e,".mg-y-axis"),!t.y_axis)return this;var r=Mr(e,"mg-y-axis");return d(r,t),p(t),m(r,t),h(r,t),_(r,t),t.y_rug&&o(t),this}function v(t){var e=Xr(t.target);kr(e,".mg-y-axis");var r=Mr(e,"mg-y-axis"),n=r.selectAll("text").data(t.categorical_variables).enter().append("svg:text").attr("x",t.left).attr("y",function(e){return t.scales.Y(e)+t.scales.Y.rangeBand()/2+t.buffer*t.outer_padding_percentage}).attr("dy",".35em").attr("text-anchor","end").text(String);Or(n,t.rotate_y_labels)}function x(t){return Tr(t,"Y",t.categorical_variables,hr(t),t.top,t.padding_percentage,t.outer_padding_percentage),Gr(t,"yf","Y",t.y_accessor),t.y_axis?(v(t),this):this}function y(t){"use strict";t.rug_buffer_size="point"===t.chart_type?t.buffer/2:t.buffer;var e=Ar(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),Dr(e,t,"mg-x-rug-mono")}function b(t){t.processed||(t.processed={})}function w(e){Gr(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:t.scale.linear(),e.scales.X.domain([e.processed.min_x,e.processed.max_x]).range([xr(e),br(e)-e.additional_buffer])}function k(t){"use strict";var e=Xr(t.target);if(b(t),w(t),"point"===t.chart_type&&(G(t),O(t)),kr(e,".mg-x-axis"),!t.x_axis)return this;var r=Mr(e,"mg-x-axis");return t.x_label&&E(r,t),q(r,t),Q(r,t),t.x_rug&&y(t),this}function M(t){var e=Xr(t.target),r=0;"bar"===t.chart_type&&(r=t.buffer+5),Tr(t,"X",t.categorical_variables.reverse(),t.left,br(t)-r),Gr(t,"xf","X",t.x_accessor),kr(e,".mg-x-axis");var n=Mr(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.outer_padding_percentage+r/2}).attr("y",hr(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();Hr(r,t,n)}),Or(n,e.rotate_x_labels)}function G(e){var r,n;null!==e.color_accessor&&(r=D(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)),Gr(e,"color","color",e.color_accessor))}function D(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 O(e){var r,n;null!==e.size_accessor&&(r=Y(e),n=C(e),e.scales.size=t.scale.linear().domain(r).range(n).clamp(!0),Gr(e,"size","size",e.size_accessor))}function Y(e){return null===e.size_domain?t.extent(e.data[0],function(t){return t[e.size_accessor]}):e.size_domain}function C(t){var e;return e=null===t.size_range?[1,5]:t.size_range}function E(t,e){t.append("text").attr("class","label").attr("x",function(){return(e.left+e.width-e.right)/2}).attr("y",(e.height-e.bottom/2).toFixed(2)).attr("dy",".50em").attr("text-anchor","middle").text(function(){return e.x_label})}function z(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 F(t){var e;return e=X(t)?"millis":P(t)?"seconds":$(t)?"less-than-a-day":S(t)?"four-days":j(t)?"many-days":L(t)?"many-months":N(t)?"years":"default"}function X(t){return 10>t}function P(t){return 60>t}function $(t){return 24>=t/3600}function S(t){return 96>=t/3600}function j(t){return 93>=t/86400}function L(t){return 730>t/86400}function N(t){return t/86400>=730}function I(t,e){var r;return r=X(e)?MG.time_format(t,"%M:%S.%L"):P(e)?MG.time_format(t,"%M:%S"):$(e)?MG.time_format(t,"%H:%M"):S(e)?MG.time_format(t,"%H:%M"):j(e)?MG.time_format(t,"%b %d"):L(e)?MG.time_format(t,"%b"):MG.time_format(t,"%Y")}function R(t){var e,r,n;t.time_series&&(e=(t.processed.max_x-t.processed.min_x)/1e3,n=F(e),r=I(t.utc_time,e)),t.processed.main_x_time_format=r,t.processed.x_time_frame=n}function B(e){if(e.xax_format)return e.xax_format;var r=e.processed.original_data||e.data,n=Pr(r)[0][e.processed.original_x_accessor||e.x_accessor];return function(r){R(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){"bar"===e.chart_type||e.y_extended_ticks||(H(e,t),U(e,t))}function H(t,e){var r=t.scales.X.ticks(t.xax_count).length-1;t.x_extended_ticks||e.append("line").attr("x1",function(){return 0===t.xax_count?xr(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?br(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){var r=t.scales.X.ticks(t.xax_count);e.selectAll(".mg-xax-ticks").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",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){Z(e,t),V(e,t)}function Z(e,r){var n=e.scales.X.ticks(e.xax_count),a=r.selectAll(".mg-xax-labels").data(n).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?(a.append("tspan").classed("mg-european-hours",!0).text(function(e,r){var n=new Date(e);return 0===r?t.time.format("%H")(n):""}),a.append("tspan").classed("mg-european-minutes-seconds",!0).text(function(t){var r=new Date(t);return":"+e.processed.xax_format(r)})):a.text(function(t){return e.xax_units+e.processed.xax_format(t)}),Yr(a)){a.filter(function(t,e){return(e+1)%2==0}).remove();var o=Xr(e.target),n=o.selectAll(".mg-xax-ticks").filter(function(t,e){return(e+1)%2==0}).remove()}}function V(t,e){if(t.time_series&&(t.show_years||t.show_secondary_x_label)){var r=W(t);J(t,e,r.timeframe,r.yformat,r.secondary)}}function W(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");case"many-months":r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%b");default:r.secondary=t.time.years,r.yformat=MG.time_format(e.utc_time,"%Y")}return r}function J(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=Mr(e,"mg-year-marker");"default"===r&&t.show_year_markers&&K(t,s,o,n),"years"!=r&&te(t,s,o,n)}function K(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",_r(t)).attr("y2",mr(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 mr(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){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)})}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=Pr(t.data),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=B(t):"bar"===e&&(t.processed.xax_format=z(t)))}function fe(t){var e={target:null,title:null,description:null};return t||(t={}),t.processed||(t.processed={}),t=Rr(t,e)}function de(t){var e=Pr(t.processed.original_data||t.data)[0];t.time_series=e[t.processed.original_x_accessor||t.x_accessor]instanceof Date}function pe(t){var e=t.width;t.full_width&&(e=Nr(t.target)),t.width=e}function me(t){var e=t.height;t.full_height&&(e=Ir(t.target)),"bar"===t.chart_type&&null===e&&(e=t.height=t.data[0].length*t.bar_height+t.top+t.bottom),t.height=e}function he(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 _e(e,r){return Xr(r.target).empty()&&(e=t.select(r.target).append("svg").classed("linked",r.linked).attr("width",r.width).attr("height",r.height)),e}function ge(t,e){t.selectAll(".mg-clip-path").remove(),t.append("defs").attr("class","mg-clip-path").append("clipPath").attr("id","mg-plot-window-"+Sr(e.target)).append("svg:rect").attr("x",e.left).attr("y",e.top).attr("width",e.width-e.left-e.right-e.buffer).attr("height",e.height-e.top-e.bottom-e.buffer+1)}function ve(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 xe(t,e){t.attr("viewBox","0 0 "+e.width+" "+e.height),(e.full_width||e.full_height)&&t.attr("preserveAspectRatio","xMinYMin meet")}function ye(t){t.classed("mg-missing",!1),t.selectAll(".mg-missing-text").remove(),t.selectAll(".mg-missing-pane").remove()}function be(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;ro;r--)t.selectAll(".mg-main-line.mg-line"+r+"-color").remove()}}function we(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 ke(e){"use strict";e=arguments[0],e=fe(e);var r=t.select(e.target);we(r,e);var n=r.selectAll("svg");return de(e),pe(e),me(e),he(n,e),n=_e(n,e),ge(n,e),ve(n,e),xe(n,e),ye(n),a(e),be(n,e),this}function Me(t){return t.label}function Ae(t){t.selectAll(".mg-markers").remove(),t.selectAll(".mg-baselines").remove()}function Ge(t){return function(e){return t.scales.X(e[t.x_accessor])>xr(t)&&t.scales.X(e[t.x_accessor])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=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;mi;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 We(t/(6*u))}),o=rr(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 Qe(t,e,r,n){for(var a=[],o=0;o=0&&1>=t?Math.pow(1-Math.pow(t,e),e):0}function We(t){return Ve(t,2)}function Je(t){return Ve(t,3)}function Ke(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 tr(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 er(t){var e,r,n=Ke(t);r=n.xbar,e=n.ybar;var a=tr(t,r,e);return{beta:a,xbar:r,ybar:e,x0:e-a*r}}function rr(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),h=t.zip(e,r,o).sort(),_=Math.abs(p-m)/a,g=m,v=p,x=t.range(g,v,_),y=[],b=0;bt?"M"+u.map(function(e){return e(t)}).join("L"):e}}}function or(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 ir(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 sr(t){return"[object Array]"===Object.prototype.toString.call(t)}function lr(t){return"[object Function]"===Object.prototype.toString.call(t)}function cr(t){return sr(t)&&0===t.length}function ur(t){return"[object Object]"===Object.prototype.toString.call(t)}function fr(e){var r=e.map(function(t){return sr(t)===!0&&t.length>0});return t.sum(r)===e.length}function dr(e){var r=e.map(function(t){return ur(t)===!0});return t.sum(r)===e.length}function pr(t){return cr(t)||dr(t)}function mr(t){return t.height-t.bottom}function hr(t){return mr(t)-t.buffer}function _r(t){return t.top}function gr(t){return _r(t)+t.buffer}function vr(t){return t.left}function xr(t){return vr(t)+t.buffer}function yr(t){return t.width-t.right}function br(t){return yr(t)-t.buffer}function wr(t){t.exit().remove()}function kr(t,e){t.selectAll(e).remove()}function Mr(t,e){return t.append("g").classed(e,!0)}function Ar(t,e){var r=Xr(t.target),n=Pr(t.data),a=r.selectAll("line."+e).data(n);return a.enter().append("svg:line").attr("class",e).attr("opacity",.3),wr(a),wr(a),a}function Gr(t,e,r,n){t.scalefns[e]=function(e){return t.scales[r](e[n])}}function Dr(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 Tr(e,r,n,a,o,i,s){e.scales[r]=t.scale.ordinal().domain(n).rangeRoundBands([a,o],i||0,s||0)}function Or(e,r){r&&e.attr({dy:0,transform:function(){var e=t.select(this);return"rotate("+r+" "+e.attr("x")+","+e.attr("y")+")"}})}function Yr(t){t=t[0];for(var e=0;e=r.top&&(o=r.top-16),a.attr("y",o)}}function Er(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=n.top?n.bottom-r.top:!1}function Fr(t,e){for(var r=t.getBoundingClientRect(),n=0;nr.right||a.rightr&&(t.textContent=e.slice(0,--a)+"...",n=t.getBBox(),"..."!==t.textContent););}function Ur(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 Qr(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 Zr(t){console.log("INTERNAL ERROR : ",t.target," : ",t.internal_error)}window.MG={version:"2.7.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"},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:30,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,x_rollover_format:null,y_rollover_format:null,transition_on_update:!0,mouseover: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];Rr(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+"`"),qr(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:'',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-dm.width?"left":"left"==s&&u.left-fi.top+i.height&&(a.top=i.top+i.height-l)}else{var c=e.left-o,u=e.left+o+r;ci.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:''}),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=a,MG.y_rug=o,MG.y_axis=g,MG.y_axis_categorical=x,MG.x_rug=y,MG.x_axis=k,MG.x_axis_categorical=M,MG.init=ke,MG.markers=$e,"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('");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('
"),l=0;l'+n[l]+"");e("."+this._strip_punctuation(d)+"-btns .dropdown-menu li a").on("click",f)}return this},this},function(){"use strict";function e(t,e,i){o(t,e),n(t,e),a(t,e),r(t,e,i)}function r(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])}).y1(function(t){var r=e.show_confidence_band[1];return e.scales.Y(t[r])}).interpolate(e.interpolate).tension(e.interpolate_tension))}function n(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 a(e,r){r.flat_line=t.svg.line().defined(function(t){return(void 0==t._missing||1!=t._missing)&&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 o(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||1!=t._missing)&&null!=t[e.y_accessor]}))}function s(t,e,r,n){var a;t.show_confidence_band&&(a=e.existing_band.empty()?r.append("path").attr("class","mg-confidence-band"):e.existing_band.transition().duration(function(){return t.transition_on_update?1e3:0}),a.attr("d",e.confidence_area(t.data[n])).attr("clip-path","url(#mg-plot-window-"+Sr(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-"+Sr(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-"+Sr(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— "+a+"  "+e.legend_text:"— "+a+"  "+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.length0?t.custom_line_color_map[r]:e;e++}}function b(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 w(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?i: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 M(e,r,n,a,o){var i,s=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]]);i=Mr(r,"mg-voronoi"),i.selectAll("path").data(s(b(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",w(e)).on("mouseover",n).on("mouseout",a).on("mousemove",o),T(e,r)}function A(e){var r=t.nest().key(function(t){return t[e.x_accessor]}).entries(t.merge(e.data)).sort(function(t,e){return new Date(t.key)-new Date(e.key)});return r.forEach(function(t){var r=t.values[0];t.key=r[e.x_accessor]}),r}function G(t,e,r,n,a){var o=A(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?xr(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?br(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=O(e.line_id);return null===t.colors&&(n+=" "+Y(r.line_id)),n}).join(" ");return t.linked&&e.values.length>0&&(r+=" "+C(E(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),F(t,e)}function D(t,e){e.select(".mg-rollover-rect rect").on("mouseover")(t.data[0][0],0)}function T(t,e){for(var r=0;r0&&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 O(t){return"mg-line"+t}function Y(t){return"mg-line"+t+"-color"}function C(t){return"roll_"+t}function E(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 z(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)+" "+O(e.line_id);return t.linked&&(n+=n+" "+C(E(e,r,t))),n}).attr("x",function(e,r){return 1===s.length?xr(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?br(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),$(t)&&D(t,e)}function F(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 $(t){return 1==t.data.length&&1==t.data[0].length}function S(t,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,a=t.data[n];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+"-color");s(t,e,r,n),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 j(t){var r={},n=Xr(t.target);kr(n,".mg-line-legend"),h(t,r,n),r.data_median=0,r.update_transition_duration=t.transition_on_update?1e3:0,r.display_area=t.area&&!t.use_data_y_min&&t.data.length<=1,r.legend_text="",e(t,r,n),r.existing_band=n.selectAll(".mg-confidence-band");var a=MG.call_hook("line.before_all_series",[t]);a!==!1&&S(t,r,n),m(t.legend_target,r.legend_text)}function L(t,e){var r=Xr(t.target);_(r),v(t,r),x(t,r),y(t),X(t)?M(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):P(t)?G(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t)):z(t,r,e.rolloverOn(t),e.rolloverOff(t),e.rolloverMove(t))}function N(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){ir(r,t)&&I(t,e,r)});else{if(t.missing_is_hidden&&r._missing||null==r[t.y_accessor])return;ir(r,t)&&R(t,e,r)}}function I(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 R(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 B(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=E(a,n,e);t.selectAll("."+O(a.line_id)+"."+C(o)).each(function(e){t.select(this).on("mouseover")(e,n)})}}function q(t,e,r){var n;return n=null!==t.y_rollover_format?t.aggregate_rollover?ne(t.y_rollover_format,r,t.y_accessor):ne(t.y_rollover_format,r,t.y_accessor):t.time_series?t.aggregate_rollover?e(r[t.y_accessor]):t.yax_units+e(r[t.y_accessor]):t.y_accessor+": "+t.yax_units+e(r[t.y_accessor])}function H(t,e,r){var n;if(null!==t.x_rollover_format)n=t.time_series?t.aggregate_rollover?re(t.x_rollover_format,r,"key",t.utc):re(t.x_rollover_format,r,t.x_accessor,t.utc):ne(t.x_rollover_format,r,t.x_accessor);else if(t.time_series){if(t.aggregate_rollover&&t.data.length>1)var a=new Date(r.key);else{var a=new Date(+r[t.x_accessor]);a.setDate(a.getDate())}n=e(a)+" "}else n=t.x_accessor+": "+r[t.x_accessor]+", ";return n}function U(t,e,r,n,a){var o,i=0,s=1.1;e.append("tspan").text(r.trim()),i=1;n.values.forEach(function(r){o=q(t,a,r);var n=e.append("tspan").attr({x:0,y:i*s+"em"}).text(o);e.append("tspan").attr({x:-n.node().getComputedTextLength(),y:i*s+"em"}).text("— ").classed("mg-hover-line"+r.line_id+"-color",null===t.colors).attr("fill",null===t.colors?"":t.colors[r.line_id-1]).style("font-weight","bold"),i++}),e.append("tspan").attr("x",0).attr("y",i*s+"em").text(" ")}function Q(t,e,r,n,a){var o=0,i=1.1;n.values.forEach(function(n){formatted_y=q(t,a,n),formatted_y=null!=t.y_rollover_format?ne(t.y_rollover_format,n,t.y_accessor):t.yax_units+a(n[t.y_accessor]);var s=e.append("tspan").attr({x:0,y:o*i+"em"}).text(r+" "+formatted_y);e.append("tspan").attr({x:-s.node().getComputedTextLength(),y:o*i+"em"}).text("— ").classed("mg-hover-line"+n.line_id+"-color",!0).style("font-weight","bold"),o++})}function Z(t,e,r,n,a,o,i,s){var l=0,c=1.1;t.time_series?U(t,r,n,s,o):Q(t,r,n,s,o),r.append("tspan").attr("x",0).attr("y",l*c+"em").text(" ")}function V(t,e,r,n,a){var o=nr(t),i=e.select(".mg-active-datapoint");i.selectAll("*").remove();var s,l,l=q(t,o,n),s=H(t,r,n);t.aggregate_rollover&&t.data.length>1?Z(t,e,i,s,l,o,r,n,a):t.time_series?(i.select("*").remove(),i.append("tspan").classed("mg-x-rollover-text",!0).text(s),i.append("tspan").classed("mg-y-rollover-text",!0).text(l)):(i.append("tspan").text(s),i.append("tspan").text(l))}function W(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 J(t,e){e.selectAll("circle.mg-line-rollover-circle").style("opacity",0)}function K(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 te(t){t.select(".mg-active-datapoint").text("")}function ee(t){this.init=function(t){return this.args=t,t.data&&0!==t.data.length?(t.internal_error=void 0,Le(t),Ne(t),ke(t),k(t),g(t),this.markers(),this.mainPlot(),this.rollover(),this.windowListeners(),MG.call_hook("line.after_init",this),this):(t.internal_error="No data was supplied",Zr(t),this)},this.mainPlot=function(){return j(t),this},this.markers=function(){return $e(t),this},this.rollover=function(){var e=this;return L(t,e),MG.call_hook("line.after_rollover",t),this},this.rolloverOn=function(t){var e=Xr(t.target),r=or(t);return function(n,a){N(t,e,n),B(t,n,a),e.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3),t.show_rollover_text&&V(t,e,r,n,a),t.mouseover&&t.mouseover(n,a)}},this.rolloverOff=function(t){var e=Xr(t.target);return function(r,n){W(t,r,n),t.aggregate_rollover?J(t,e):K(t,e,r),te(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 Se(this.args),this},this.init(t)}var re=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]},ne=function(e,r,n){var a;return a="string"==typeof e?t.format(e)(r[n]):"function"==typeof e?e(r):r[n]};MG.register("line",ee)}.call(this),function(){"use strict";function r(r){this.init=function(t){return this.args=t,Le(t),Ie(t),ke(t),k(t),g(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var t=Xr(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 $e(r),this},this.rollover=function(){{var t=Xr(r.target);e(e(r.target).find("svg").get(0))}t.selectAll(".mg-rollover-rect").remove(),t.selectAll(".mg-active-datapoint").remove(),t.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",r.width-r.right).attr("y",.75*r.top).attr("text-anchor","end");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=Xr(e.target);return function(n,a){r.selectAll("text").filter(function(t){return n===t}).attr("opacity",.3);var o=e.processed.xax_format||MG.time_format(e.utc_time,"%b %e, %Y"),i=nr(e);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&&r.select(".mg-active-datapoint").text(function(){if(e.time_series){var t=new Date(+n[e.x_accessor]);return t.setDate(t.getDate()),o(t)+" "+e.yax_units+i(n[e.y_accessor])}return e.x_accessor+": "+i(n[e.x_accessor])+", "+e.y_accessor+": "+e.yax_units+i(n[e.y_accessor])}),e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(e){var r=Xr(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),r.select(".mg-active-datapoint").text(""),e.mouseout&&e.mouseout(n,a)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Se(this.args),this},this.init(r)}var n={mouseover:function(e){t.select("#histogram svg .mg-active-datapoint").text("Frequency Count: "+e.y)},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(e){this.init=function(t){return this.args=t,Le(t),Be(t),ke(t),k(t),g(t),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.markers=function(){return $e(e),e.least_squares&&qe(e),this},this.mainPlot=function(){var t,r=Xr(e.target);r.selectAll(".mg-points").remove(),t=r.append("g").classed("mg-points",!0);var n=t.selectAll("circle").data(e.data[0]).enter().append("svg:circle").attr("class",function(t,e){return"path-"+e}).attr("cx",e.scalefns.xf).attr("cy",e.scalefns.yf);return null!==e.color_accessor?(n.attr("fill",e.scalefns.color),n.attr("stroke",e.scalefns.color)):n.classed("mg-points-mono",!0),null!==e.size_accessor?n.attr("r",e.scalefns.size):n.attr("r",e.point_size),this},this.rollover=function(){var r=Xr(e.target);r.selectAll(".mg-voronoi").remove(),r.selectAll(".mg-active-datapoint").remove(),r.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",e.width-e.right).attr("y",.75*e.top).attr("text-anchor","end");var n=t.geom.voronoi().x(e.scalefns.xf).y(e.scalefns.yf).clipExtent([[e.buffer,e.buffer+e.title_y_position],[e.width-e.buffer,e.height-e.buffer]]),a=r.append("g").attr("class","mg-voronoi");return a.selectAll("path").data(n(e.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(e)).on("mouseout",this.rolloverOff(e)).on("mousemove",this.rolloverMove(e)),this},this.rolloverOn=function(e){var r=Xr(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)+1}):o.attr("r",e.point_size),e.linked&&!MG.globals.link&&(MG.globals.link=!0,t.selectAll(".mg-voronoi .path-"+a).each(function(){t.select(this).on("mouseover")(n,a)}));var i=MG.time_format(e.utc_time,"%b %e, %Y"),s=nr(e);e.show_rollover_text&&r.select(".mg-active-datapoint").text(function(){if(e.time_series){var t=new Date(+n.point[e.x_accessor]);return t.setDate(t.getDate()),i(t)+" "+e.yax_units+s(n.point[e.y_accessor])}return e.x_accessor+": "+s(n.point[e.x_accessor])+", "+e.y_accessor+": "+e.yax_units+s(n.point[e.y_accessor])}),e.mouseover&&e.mouseover(n,a)}},this.rolloverOff=function(e){var r=Xr(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),r.select(".mg-active-datapoint").text(""),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 Se(this.args),this},this.init(e)}var r={buffer:16,ls:!1,lowess:!1,point_size:2.5,size_accessor:null,color_accessor:null,size_range:null,color_range:null,size_domain:null,color_domain:null,color_type:"number"};MG.register("point",e,r)}.call(this),function(){"use strict";function t(t){this.args=t,this.init=function(t){return this.args=t,Le(t),Re(t),ke(t),this.is_vertical="vertical"===t.bar_orientation,this.is_vertical?(M(t),g(t)):(k(t),x(t)),this.mainPlot(),this.markers(),this.rollover(),this.windowListeners(),this},this.mainPlot=function(){var e,r,n,a,o,i=Xr(t.target),s=t.data[0],l=i.select("g.mg-barplot"),c=l.empty(),u=c&&t.animate_on_load,f=u||t.transition_on_update,d=t.transition_duration||1e3;c&&(l=i.append("g").classed("mg-barplot",!0)),e=e=l.selectAll(".mg-bar").data(s),e.exit().remove(),e.enter().append("rect").classed("mg-bar",!0),t.predictor_accessor&&(r=l.selectAll(".mg-bar-prediction").data(s),r.exit().remove(),r.enter().append("rect").classed("mg-bar-prediction",!0)),t.baseline_accessor&&(o=l.selectAll(".mg-bar-baseline").data(s),o.exit().remove(),o.enter().append("line").classed("mg-bar-baseline",!0));var p;return f&&(e=e.transition().duration(d),r&&(r=r.transition().duration(d)),o&&(o=o.transition().duration(d))),i.select(".mg-y-axis").node().parentNode.appendChild(l.node()),this.is_vertical?(p=t.scales.X.rangeBand()/1.5,u&&(e.attr({height:0,y:t.scales.Y(0)}),r&&r.attr({height:0,y:t.scales.Y(0)}),o&&o.attr({y1:t.scales.Y(0),y2:t.scales.Y(0)})),e.attr("y",t.scalefns.yf).attr("x",function(e){return t.scalefns.xf(e)+p/2}).attr("width",p).attr("height",function(e){return 0-(t.scalefns.yf(e)-t.scales.Y(0))}),t.predictor_accessor&&(n=t.predictor_proportion,a=n-1,r.attr("y",function(e){return t.scales.Y(0)-(t.scales.Y(0)-t.scales.Y(e[t.predictor_accessor]))}).attr("x",function(e){return t.scalefns.xf(e)+a*p/(2*n)+p/2}).attr("width",p/n).attr("height",function(e){return 0-(t.scales.Y(e[t.predictor_accessor])-t.scales.Y(0))})),t.baseline_accessor&&(n=t.predictor_proportion,o.attr("x1",function(e){return t.scalefns.xf(e)+p/2-p/n+p/2}).attr("x2",function(e){return t.scalefns.xf(e)+p/2+p/n+p/2}).attr("y1",function(e){return t.scales.Y(e[t.baseline_accessor])}).attr("y2",function(e){return t.scales.Y(e[t.baseline_accessor])}))):(p=t.scales.Y.rangeBand()/1.5,u&&(e.attr("width",0),r&&r.attr("width",0),o&&o.attr({x1:t.scales.X(0),x2:t.scales.X(0)})),e.attr("x",t.scales.X(0)).attr("y",function(e){return t.scalefns.yf(e)+p/2}).attr("height",p).attr("width",function(e){return t.scalefns.xf(e)-t.scales.X(0)}),t.predictor_accessor&&(n=t.predictor_proportion,a=n-1,r.attr("x",t.scales.X(0)).attr("y",function(e){return t.scalefns.yf(e)+a*p/(2*n)+p/2}).attr("height",p/n).attr("width",function(e){return t.scales.X(e[t.predictor_accessor])-t.scales.X(0)})),t.baseline_accessor&&(n=t.predictor_proportion,o.attr("x1",function(e){return t.scales.X(e[t.baseline_accessor])}).attr("x2",function(e){return t.scales.X(e[t.baseline_accessor])}).attr("y1",function(e){return t.scalefns.yf(e)+p/2-p/n+p/2}).attr("y2",function(e){return t.scalefns.yf(e)+p/2+p/n+p/2}))),this},this.markers=function(){return $e(t),this},this.rollover=function(){var e,r=Xr(t.target);r.selectAll(".mg-rollover-rect").remove(),r.selectAll(".mg-active-datapoint").remove(),r.append("text").attr("class","mg-active-datapoint").attr("xml:space","preserve").attr("x",t.width-t.right).attr("y",.75*t.top).attr("dy",".35em").attr("text-anchor","end"),e=r.append("g").attr("class","mg-rollover-rect");var n=e.selectAll(".mg-bar-rollover").data(t.data[0]).enter().append("rect").attr("class","mg-bar-rollover");return this.is_vertical?n.attr("x",t.scalefns.xf).attr("y",function(){return t.scales.Y(0)-t.height}).attr("width",t.scales.X.rangeBand()).attr("height",t.height).attr("opacity",0).on("mouseover",this.rolloverOn(t)).on("mouseout",this.rolloverOff(t)).on("mousemove",this.rolloverMove(t)):n.attr("x",t.scales.X(0)).attr("y",t.scalefns.yf).attr("width",t.width).attr("height",t.scales.Y.rangeBand()+2).attr("opacity",0).on("mouseover",this.rolloverOn(t)).on("mouseout",this.rolloverOff(t)).on("mousemove",this.rolloverMove(t)),this},this.rolloverOn=function(t){var e=Xr(t.target),r=this.is_vertical?t.x_accessor:t.y_accessor,n=this.is_vertical?t.y_accessor:t.x_accessor,a=this.is_vertical?t.yax_units:t.xax_units;return function(o,i){e.selectAll("text").filter(function(t){return o===t}).attr("opacity",.3);var s=MG.time_format(t.utc_time,"%b %e, %Y"),l=nr(t);e.selectAll("g.mg-barplot .mg-bar").filter(function(t,e){return e===i}).classed("active",!0),t.show_rollover_text&&e.select(".mg-active-datapoint").text(function(){if(t.time_series){var e=new Date(+o[n]);return e.setDate(e.getDate()),s(e)+" "+a+l(o[r])}return o[r]+": "+l(o[n])}),t.mouseover&&t.mouseover(o,i)}},this.rolloverOff=function(t){var e=Xr(t.target);return function(r,n){e.selectAll("g.mg-barplot .mg-bar").classed("active",!1),e.select(".mg-active-datapoint").text(""),t.mouseout&&t.mouseout(r,n)}},this.rolloverMove=function(t){return function(e,r){t.mousemove&&t.mousemove(e,r)}},this.windowListeners=function(){return Se(this.args),this},this.init(t)}var e={y_accessor:"factor",x_accessor:"value",baseline_accessor:null,predictor_accessor:null,predictor_proportion:5,dodge_accessor:null,binned:!0,padding_percentage:0,outer_padding_percentage:.1,height:500,bar_height:20,top:45,left:70,truncate_x_labels:!0,truncate_y_labels:!0,rotate_x_labels:0,rotate_y_labels:0};MG.register("bar",t,e)}.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=Rr(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;a(r);var n,o,i,s,l,c,u,f,d,p,m,h,_=r.target,g=t.select(_).append("table").classed("mg-data-table",!0),v=g.append("colgroup"),x=g.append("thead"),y=g.append("tbody");for(i=x.append("tr"),h=0;h=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,pe(f),me(f),a(f);var d=t.select(f.target);we(d,f);var p=d.selectAll("svg");if(he(p,f),p=_e(p,f),ve(p,f),xe(p,f),c(f),p.classed("mg-missing",!0),u(f),f.show_missing_background){o(f),r(f),n(f);var m=Mr(p,"mg-missing-pane");i(m,f),s(m,f),l(m,f)}return e(p,f),this.windowListeners(),this},this.windowListeners=function(){return Se(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=Le,MG.process_line=Ne,MG.process_histogram=Ie,MG.process_categorical_variables=Re,MG.process_point=Be,MG.add_ls=qe,MG.add_lowess=He,MG.lowess_robust=Ue,MG.lowess=Qe,MG.least_squares=Ze,MG.format_rollover_number=nr,MG.path_tween=ar,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 Vr=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=Rr,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=Br,MG.warn_deprecation=qr,MG.truncate_text=Hr,MG.wrap_text=Ur,MG.error=Qr,MG}); \ No newline at end of file diff --git a/src/js/charts/line.js b/src/js/charts/line.js index ae9ee6b194..d52855e25e 100644 --- a/src/js/charts/line.js +++ b/src/js/charts/line.js @@ -625,6 +625,320 @@ } + + function mg_update_rollover_circle(args, svg, d) { + if (args.aggregate_rollover && args.data.length > 1) { + // hide the circles in case a non-contiguous series is present + svg.selectAll('circle.mg-line-rollover-circle') + .style('opacity', 0); + + d.values.forEach(function (datum) { + if (mg_data_in_plot_bounds(datum, args)) mg_update_aggregate_rollover_circle(args, svg, datum); + }); + } else if ((args.missing_is_hidden && d['_missing']) + || d[args.y_accessor] == null + ) { + // disable rollovers for hidden parts of the line + // recall that hidden parts are missing data ranges and possibly also + // data points that have been explicitly identified as missing + return; + } else { + // show circle on mouse-overed rect + if (mg_data_in_plot_bounds(d, args)) { + mg_update_generic_rollover_circle(args, svg, d); + } + } + } + + function mg_update_aggregate_rollover_circle(args, svg, datum) { + var circle = svg.select('circle.mg-line-rollover-circle.mg-line' + datum.line_id) + .attr({ + 'cx': function () { + return args.scales.X(datum[args.x_accessor]).toFixed(2); + }, + 'cy': function () { + return args.scales.Y(datum[args.y_accessor]).toFixed(2); + }, + 'r': args.point_size + }) + .style('opacity', 1); + } + + function mg_update_generic_rollover_circle(args, svg, d) { + var circle = svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) + .classed('mg-line-rollover-circle', true) + .attr('cx', function () { + return args.scales.X(d[args.x_accessor]).toFixed(2); + }) + .attr('cy', function () { + return args.scales.Y(d[args.y_accessor]).toFixed(2); + }) + .attr('r', args.point_size) + .style('opacity', 1); + } + + function mg_trigger_linked_mouseovers(args, d, i) { + if (args.linked && !MG.globals.link) { + MG.globals.link = true; + if (!args.aggregate_rollover || d.value !== undefined || d.values.length > 0) { + var datum = d.values ? d.values[0] : d; + var id = mg_rollover_format_id(datum, i, args); + // trigger mouseover on matching line in .linked charts + d3.selectAll('.' + mg_line_class(datum.line_id) + '.' + mg_rollover_id_class(id)) + .each(function (d) { + d3.select(this).on('mouseover')(d, i); + }); + } + } + } + + var time_rollover_format = function (f, d, accessor, utc) { + var fd; + if (typeof f === 'string') { + fd = MG.time_format(utc, f)(d[accessor]); + } else if (typeof f === 'function') { + fd = f(d); + } else { + fd = d[accessor]; + } + return fd; + }; + + // define our rollover format for numbers + var number_rollover_format = function (f, d, accessor) { + var fd; + if (typeof f === 'string') { + fd = d3.format(f)(d[accessor]); + } else if (typeof f === 'function') { + fd = f(d); + } else { + fd = d[accessor]; + } + return fd; + }; + + function mg_format_y_rollover(args, num, d) { + var formatted_y; + if (args.y_rollover_format !== null) { + if (args.aggregate_rollover) { + formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor);; + } else { + formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor); + } + } else { + if (args.time_series) { + if (args.aggregate_rollover) { + formatted_y = num(d[args.y_accessor]);//number_rollover_format(args.y_rollover_format, d, args.y_accessor); + } else { + formatted_y = args.yax_units + num(d[args.y_accessor]); + } + } + else formatted_y = args.y_accessor + ': ' + args.yax_units + num(d[args.y_accessor]); + } + return formatted_y; + } + + + function mg_format_x_rollover(args, fmt, d) { + var formatted_x; + if (args.x_rollover_format !== null) { + if (args.time_series) { + if (args.aggregate_rollover) { + formatted_x = time_rollover_format(args.x_rollover_format, d, 'key', args.utc); + } else { + formatted_x = time_rollover_format(args.x_rollover_format, d, args.x_accessor, args.utc); + } + } else { + formatted_x = number_rollover_format(args.x_rollover_format, d, args.x_accessor); + } + } else { + if (args.time_series) { + if (args.aggregate_rollover && args.data.length > 1) { + var date = new Date(d.key); + } else { + var date = new Date(+d[args.x_accessor]); + date.setDate(date.getDate()); + } + + formatted_x = fmt(date) + ' '; + } else { + formatted_x = args.x_accessor + ': ' + d[args.x_accessor] + ', '; + } + } + return formatted_x; + } + + function mg_append_aggregate_rollover_timeseries (args, textContainer, formatted_x, d, num) { + var lineCount = 0; + var lineHeight = 1.1; + var formatted_y; + textContainer.append('tspan') + .text(formatted_x.trim()); + + lineCount = 1; + var fy; + + d.values.forEach(function (datum) { + formatted_y = mg_format_y_rollover(args, num, datum); + + var label = textContainer.append('tspan') + .attr({ + x: 0, + y: (lineCount * lineHeight) + 'em' + }) + .text(formatted_y); + + textContainer.append('tspan') + .attr({ + x: -label.node().getComputedTextLength(), + y: (lineCount * lineHeight) + 'em' + }) + .text('\u2014 ') // mdash + .classed('mg-hover-line' + datum.line_id + '-color', args.colors === null) + .attr('fill', args.colors === null ? '' : args.colors[datum.line_id - 1]) + .style('font-weight', 'bold'); + + lineCount++; + }); + + textContainer.append('tspan') + .attr('x', 0) + .attr('y', (lineCount * lineHeight) + 'em') + .text('\u00A0'); + } + + function mg_append_aggregate_rollover_text(args, textContainer, formatted_x, d, num) { + var lineCount = 0; + var lineHeight = 1.1; + d.values.forEach(function (datum) { + formatted_y = mg_format_y_rollover(args, num, datum); + + if (args.y_rollover_format != null) { + formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); + } else { + formatted_y = args.yax_units + num(datum[args.y_accessor]); + } + + var label = textContainer.append('tspan') + .attr({ + x: 0, + y: (lineCount * lineHeight) + 'em' + }) + .text(formatted_x + ' ' + formatted_y); + + textContainer.append('tspan') + .attr({ + x: -label.node().getComputedTextLength(), + y: (lineCount * lineHeight) + 'em' + }) + .text('\u2014 ') // mdash + .classed('mg-hover-line' + datum.line_id + '-color', true) + .style('font-weight', 'bold'); + + lineCount++; + }); + } + + + function mg_format_aggregate_rollover_text(args, svg, textContainer, formatted_x, formatted_y, num, fmt, d, i) { + var lineCount = 0; + var lineHeight = 1.1; + if (args.time_series) { + mg_append_aggregate_rollover_timeseries(args, textContainer, formatted_x, d, num); + + } else { + mg_append_aggregate_rollover_text(args, textContainer, formatted_x, d, num); + } + + // append an blank ( ) line to mdash positioning + textContainer.append('tspan') + .attr('x', 0) + .attr('y', (lineCount * lineHeight) + 'em') + .text('\u00A0'); + } + + function mg_update_line_rollover_text(args, svg, fmt, d, i) { + var num = format_rollover_number(args); + var textContainer = svg.select('.mg-active-datapoint'); + + textContainer + .selectAll('*') + .remove(); + + var formatted_x, formatted_y; + + var formatted_y = mg_format_y_rollover(args, num, d); + var formatted_x = mg_format_x_rollover(args, fmt, d); + + // rollover text when aggregate_rollover is enabled + if (args.aggregate_rollover && args.data.length > 1) { + mg_format_aggregate_rollover_text(args, svg, textContainer, formatted_x, formatted_y, num, fmt, d, i); + } else { + // rollover text when aggregate_rollover is not enabled + if (args.time_series) { + textContainer.select('*').remove(); + textContainer.append('tspan') + .classed('mg-x-rollover-text', true) + .text(formatted_x); + textContainer.append('tspan') + .classed('mg-y-rollover-text', true) + .text(formatted_y); + } else { + textContainer.append('tspan') + .text(formatted_x); + textContainer.append('tspan') + .text(formatted_y); + } + } + } + + function mg_trigger_linked_mouseouts(args, d, i) { + if (args.linked && MG.globals.link) { + MG.globals.link = false; + + var formatter = MG.time_format(args.utc_time, args.linked_format); + var datums = d.values ? d.values : [d]; + datums.forEach(function (datum) { + var v = datum[args.x_accessor]; + var id = (typeof v === 'number') ? i : formatter(v); + + // trigger mouseout on matching line in .linked charts + d3.selectAll('.roll_' + id) + .each(function (d) { + d3.select(this).on('mouseout')(d); + }); + }); + } + } + + function mg_remove_active_data_points_for_aggregate_rollover(args, svg) { + svg.selectAll('circle.mg-line-rollover-circle').style('opacity', 0); + } + + function mg_remove_active_data_points_for_generic_rollover(args, svg, d) { + svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) + .style('opacity', function () { + var id = d.line_id - 1; + + if (args.custom_line_color_map.length > 0 + && args.custom_line_color_map.indexOf(d.line_id) !== undefined + ) { + id = args.custom_line_color_map.indexOf(d.line_id); + } + + if (args.data[id].length == 1) { + // if (args.data.length === 1 && args.data[0].length === 1) { + return 1; + } else { + return 0; + } + }); + } + + function mg_remove_active_text(svg) { + svg.select('.mg-active-datapoint').text(''); + } + function lineChart (args) { this.init = function (args) { this.args = args; @@ -675,90 +989,11 @@ this.rolloverOn = function (args) { var svg = mg_get_svg_child_of(args.target); - var fmt; - switch (args.processed.x_time_frame) { - case 'millis': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S.%L'); - break; - case 'seconds': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S'); - break; - case 'less-than-a-day': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); - break; - case 'four-days': - fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); - break; - default: - fmt = MG.time_format(args.utc_time, '%b %e, %Y'); - } + var fmt = mg_get_rollover_time_format(args); return function (d, i) { - if (args.aggregate_rollover && args.data.length > 1) { - // hide the circles in case a non-contiguous series is present - svg.selectAll('circle.mg-line-rollover-circle') - .style('opacity', 0); - - d.values.forEach(function (datum) { - if (datum[args.x_accessor] >= args.processed.min_x && - datum[args.x_accessor] <= args.processed.max_x && - datum[args.y_accessor] >= args.processed.min_y && - datum[args.y_accessor] <= args.processed.max_y - ) { - var circle = svg.select('circle.mg-line-rollover-circle.mg-line' + datum.line_id) - .attr({ - 'cx': function () { - return args.scales.X(datum[args.x_accessor]).toFixed(2); - }, - 'cy': function () { - return args.scales.Y(datum[args.y_accessor]).toFixed(2); - }, - 'r': args.point_size - }) - .style('opacity', 1); - } - }); - } else if ((args.missing_is_hidden && d['_missing']) - || d[args.y_accessor] == null - ) { - // disable rollovers for hidden parts of the line - // recall that hidden parts are missing data ranges and possibly also - // data points that have been explicitly identified as missing - return; - } else { - // show circle on mouse-overed rect - if (d[args.x_accessor] >= args.processed.min_x && - d[args.x_accessor] <= args.processed.max_x && - d[args.y_accessor] >= args.processed.min_y && - d[args.y_accessor] <= args.processed.max_y - ) { - var circle = svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) - .classed('mg-line-rollover-circle', true) - .attr('cx', function () { - return args.scales.X(d[args.x_accessor]).toFixed(2); - }) - .attr('cy', function () { - return args.scales.Y(d[args.y_accessor]).toFixed(2); - }) - .attr('r', args.point_size) - .style('opacity', 1); - } - } - - // trigger mouseover on all rects for this date in .linked charts - if (args.linked && !MG.globals.link) { - MG.globals.link = true; - - if (!args.aggregate_rollover || d.value !== undefined || d.values.length > 0) { - var datum = d.values ? d.values[0] : d; - var id = mg_rollover_format_id(datum, i, args); - // trigger mouseover on matching line in .linked charts - d3.selectAll('.' + mg_line_class(datum.line_id) + '.' + mg_rollover_id_class(id)) - .each(function (d) { - d3.select(this).on('mouseover')(d, i); - }); - } - } + mg_update_rollover_circle(args, svg, d); + mg_trigger_linked_mouseovers(args, d, i); svg.selectAll('text') .filter(function (g, j) { @@ -766,180 +1001,9 @@ }) .attr('opacity', 0.3); - var num = format_rollover_number(args); - // update rollover text if (args.show_rollover_text) { - var textContainer = svg.select('.mg-active-datapoint'), - lineCount = 0, - lineHeight = 1.1; - - textContainer - .selectAll('*') - .remove(); - - var formatted_x, formatted_y; - - // define our rollover format for time - var time_rollover_format = function (f, d, accessor, utc) { - var fd; - if (typeof f === 'string') { - fd = MG.time_format(utc, f)(d[accessor]); - } else if (typeof f === 'function') { - fd = f(d); - } else { - fd = d[accessor]; - } - return fd; - }; - - // define our rollover format for numbers - var number_rollover_format = function (f, d, accessor) { - var fd; - if (typeof f === 'string') { - fd = d3.format(f)(d[accessor]); - } else if (typeof f === 'function') { - fd = f(d); - } else { - fd = d[accessor]; - } - return fd; - }; - - // format the y-accessor value to show - if (args.y_rollover_format !== null) { - if (args.aggregate_rollover) { - formatted_y = ''; - } else { - formatted_y = number_rollover_format(args.y_rollover_format, d, args.y_accessor); - } - } else { - if (args.time_series) { - if (args.aggregate_rollover) { - formatted_y = ''; - } else { - formatted_y = args.yax_units + num(d[args.y_accessor]); - } - } - else formatted_y = args.y_accessor + ': ' + args.yax_units + num(d[args.y_accessor]); - } - - // format the x-accessor value to show - if (args.x_rollover_format !== null) { - if (args.time_series) { - if (args.aggregate_rollover) { - formatted_x = time_rollover_format(args.x_rollover_format, d, 'key', args.utc); - } else { - formatted_x = time_rollover_format(args.x_rollover_format, d, args.x_accessor, args.utc); - } - } else { - formatted_x = number_rollover_format(args.x_rollover_format, d, args.x_accessor); - } - } else { - if (args.time_series) { - if (args.aggregate_rollover && args.data.length > 1) { - var date = new Date(d.key); - } else { - var date = new Date(+d[args.x_accessor]); - date.setDate(date.getDate()); - } - - formatted_x = fmt(date) + ' '; - } else { - formatted_x = args.x_accessor + ': ' + d[args.x_accessor] + ', '; - } - } - - // rollover text when aggregate_rollover is enabled - if (args.aggregate_rollover && args.data.length > 1) { - if (args.time_series) { - textContainer.append('tspan') - .text(formatted_x.trim()); - - lineCount = 1; - var fy; - - d.values.forEach(function (datum) { - if (args.y_rollover_format != null) { - formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); - } else { - formatted_y = num(datum[args.y_accessor]); - } - - var label = textContainer.append('tspan') - .attr({ - x: 0, - y: (lineCount * lineHeight) + 'em' - }) - .text(formatted_y); - - textContainer.append('tspan') - .attr({ - x: -label.node().getComputedTextLength(), - y: (lineCount * lineHeight) + 'em' - }) - .text('\u2014 ') // mdash - .classed('mg-hover-line' + datum.line_id + '-color', args.colors === null) - .attr('fill', args.colors === null ? '' : args.colors[datum.line_id - 1]) - .style('font-weight', 'bold'); - - lineCount++; - }); - - textContainer.append('tspan') - .attr('x', 0) - .attr('y', (lineCount * lineHeight) + 'em') - .text('\u00A0'); - } else { - d.values.forEach(function (datum) { - if (args.y_rollover_format != null) { - formatted_y = number_rollover_format(args.y_rollover_format, datum, args.y_accessor); - } else { - formatted_y = args.yax_units + num(datum[args.y_accessor]); - } - - var label = textContainer.append('tspan') - .attr({ - x: 0, - y: (lineCount * lineHeight) + 'em' - }) - .text(formatted_x + ' ' + formatted_y); - - textContainer.append('tspan') - .attr({ - x: -label.node().getComputedTextLength(), - y: (lineCount * lineHeight) + 'em' - }) - .text('\u2014 ') // mdash - .classed('mg-hover-line' + datum.line_id + '-color', true) - .style('font-weight', 'bold'); - - lineCount++; - }); - } - - // append an blank ( ) line to mdash positioning - textContainer.append('tspan') - .attr('x', 0) - .attr('y', (lineCount * lineHeight) + 'em') - .text('\u00A0'); - } else { - // rollover text when aggregate_rollover is not enabled - if (args.time_series) { - textContainer.select('*').remove(); - textContainer.append('tspan') - .classed('mg-x-rollover-text', true) - .text(formatted_x); - textContainer.append('tspan') - .classed('mg-y-rollover-text', true) - .text(formatted_y); - } else { - textContainer.append('tspan') - .text(formatted_x); - textContainer.append('tspan') - .text(formatted_y); - } - } + mg_update_line_rollover_text(args, svg, fmt, d, i); } if (args.mouseover) { @@ -952,52 +1016,15 @@ var svg = mg_get_svg_child_of(args.target); return function (d, i) { - if (args.linked && MG.globals.link) { - MG.globals.link = false; - - var formatter = MG.time_format(args.utc_time, args.linked_format); - var datums = d.values ? d.values : [d]; - datums.forEach(function (datum) { - var v = datum[args.x_accessor]; - var id = (typeof v === 'number') ? i : formatter(v); - - // trigger mouseout on matching line in .linked charts - d3.selectAll('.roll_' + id) - .each(function (d) { - d3.select(this).on('mouseout')(d); - }); - }); - } - // remove all active data points when aggregate_rollover is enabled + mg_trigger_linked_mouseouts(args, d, i); if (args.aggregate_rollover) { - svg.selectAll('circle.mg-line-rollover-circle') - .style('opacity', function () { - return 0; - }); - // remove active data point text on mouse out, except if we have a single point + mg_remove_active_data_points_for_aggregate_rollover(args, svg); } else { - svg.selectAll('circle.mg-line-rollover-circle.mg-line' + d.line_id) - .style('opacity', function () { - var id = d.line_id - 1; - - if (args.custom_line_color_map.length > 0 - && args.custom_line_color_map.indexOf(d.line_id) !== undefined - ) { - id = args.custom_line_color_map.indexOf(d.line_id); - } - - if (args.data[id].length == 1) { - // if (args.data.length === 1 && args.data[0].length === 1) { - return 1; - } else { - return 0; - } - }); + mg_remove_active_data_points_for_generic_rollover(args, svg, d); } - svg.select('.mg-active-datapoint') - .text(''); + mg_remove_active_text(svg); if (args.mouseout) { args.mouseout(d, i); diff --git a/src/js/misc/utility.js b/src/js/misc/utility.js index 336877bb16..3cbaee159d 100644 --- a/src/js/misc/utility.js +++ b/src/js/misc/utility.js @@ -26,6 +26,34 @@ MG.time_format = function(utc, specifier) { return utc ? d3.time.format.utc(specifier) : d3.time.format(specifier); }; +function mg_get_rollover_time_format(args) { + var fmt; + switch (args.processed.x_time_frame) { + case 'millis': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S.%L'); + break; + case 'seconds': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %H:%M:%S'); + break; + case 'less-than-a-day': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); + break; + case 'four-days': + fmt = MG.time_format(args.utc_time, '%b %e, %Y %I:%M%p'); + break; + default: + fmt = MG.time_format(args.utc_time, '%b %e, %Y'); + } + return fmt; +} + +function mg_data_in_plot_bounds (datum, args) { + return datum[args.x_accessor] >= args.processed.min_x && + datum[args.x_accessor] <= args.processed.max_x && + datum[args.y_accessor] >= args.processed.min_y && + datum[args.y_accessor] <= args.processed.max_y +} + function is_array(thing){ return Object.prototype.toString.call(thing) === '[object Array]'; }