diff --git a/bower.json b/bower.json index b4714aa961..c17ba12ca2 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "plottable", "description": "A library for creating charts out of D3", - "version": "0.34.1", + "version": "0.35.0", "main": ["plottable.js", "plottable.css"], "license": "MIT", "ignore": [ @@ -28,7 +28,7 @@ "plots" ], "dependencies": { - "d3": "3.4.11" + "d3": "3.4.13" }, "homepage": "plottablejs.org", "repository": { diff --git a/bower_components/d3/.bower.json b/bower_components/d3/.bower.json index 540f739cea..bea24e9864 100644 --- a/bower_components/d3/.bower.json +++ b/bower_components/d3/.bower.json @@ -1,6 +1,6 @@ { "name": "d3", - "version": "3.4.11", + "version": "3.4.13", "main": "d3.js", "scripts": [ "d3.js" @@ -22,13 +22,13 @@ "test" ], "homepage": "https://github.com/mbostock/d3", - "_release": "3.4.11", + "_release": "3.4.13", "_resolution": { "type": "version", - "tag": "v3.4.11", - "commit": "9dbb2266543a6c998c3552074240efb36e4c7cab" + "tag": "v3.4.13", + "commit": "e2dc80f5385c153066150075a4208131e0b78c68" }, "_source": "git://github.com/mbostock/d3.git", - "_target": "3.4.11", + "_target": "3.4.13", "_originalSource": "d3" } \ No newline at end of file diff --git a/bower_components/d3/bower.json b/bower_components/d3/bower.json index 9f5968d2a8..5a81db0c00 100644 --- a/bower_components/d3/bower.json +++ b/bower_components/d3/bower.json @@ -1,6 +1,6 @@ { "name": "d3", - "version": "3.4.11", + "version": "3.4.13", "main": "d3.js", "scripts": [ "d3.js" diff --git a/bower_components/d3/d3.js b/bower_components/d3/d3.js index 82287776f2..2d6329e202 100644 --- a/bower_components/d3/d3.js +++ b/bower_components/d3/d3.js @@ -1,6 +1,6 @@ !function() { var d3 = { - version: "3.4.11" + version: "3.4.13" }; if (!Date.now) Date.now = function() { return +new Date(); @@ -78,24 +78,27 @@ } return [ a, c ]; }; + function d3_number(x) { + return x === null ? NaN : +x; + } + function d3_numeric(x) { + return !isNaN(x); + } d3.sum = function(array, f) { var s = 0, n = array.length, a, i = -1; if (arguments.length === 1) { - while (++i < n) if (!isNaN(a = +array[i])) s += a; + while (++i < n) if (d3_numeric(a = +array[i])) s += a; } else { - while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; + while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a; } return s; }; - function d3_number(x) { - return x != null && !isNaN(x); - } d3.mean = function(array, f) { var s = 0, n = array.length, a, i = -1, j = n; if (arguments.length === 1) { - while (++i < n) if (d3_number(a = array[i])) s += a; else --j; + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j; } else { - while (++i < n) if (d3_number(a = f.call(array, array[i], i))) s += a; else --j; + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; } return j ? s / j : undefined; }; @@ -104,9 +107,13 @@ return e ? v + e * (values[h] - v) : v; }; d3.median = function(array, f) { - if (arguments.length > 1) array = array.map(f); - array = array.filter(d3_number); - return array.length ? d3.quantile(array.sort(d3_ascending), .5) : undefined; + var numbers = [], n = array.length, a, i = -1; + if (arguments.length === 1) { + while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a); + } else { + while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); + } + return numbers.length ? d3.quantile(numbers.sort(d3_ascending), .5) : undefined; }; function d3_bisector(compare) { return { @@ -223,15 +230,11 @@ return k; } function d3_class(ctor, properties) { - try { - for (var key in properties) { - Object.defineProperty(ctor.prototype, key, { - value: properties[key], - enumerable: false - }); - } - } catch (e) { - ctor.prototype = properties; + for (var key in properties) { + Object.defineProperty(ctor.prototype, key, { + value: properties[key], + enumerable: false + }); } } d3.map = function(object) { @@ -241,62 +244,63 @@ }); else for (var key in object) map.set(key, object[key]); return map; }; - function d3_Map() {} + function d3_Map() { + this._ = Object.create(null); + } + var d3_map_proto = "__proto__", d3_map_zero = "\x00"; d3_class(d3_Map, { has: d3_map_has, get: function(key) { - return this[d3_map_prefix + key]; + return this._[d3_map_escape(key)]; }, set: function(key, value) { - return this[d3_map_prefix + key] = value; + return this._[d3_map_escape(key)] = value; }, remove: d3_map_remove, keys: d3_map_keys, values: function() { var values = []; - this.forEach(function(key, value) { - values.push(value); - }); + for (var key in this._) values.push(this._[key]); return values; }, entries: function() { var entries = []; - this.forEach(function(key, value) { - entries.push({ - key: key, - value: value - }); + for (var key in this._) entries.push({ + key: d3_map_unescape(key), + value: this._[key] }); return entries; }, size: d3_map_size, empty: d3_map_empty, forEach: function(f) { - for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) f.call(this, key.substring(1), this[key]); + for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); } }); - var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); + function d3_map_escape(key) { + return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; + } + function d3_map_unescape(key) { + return (key += "")[0] === d3_map_zero ? key.slice(1) : key; + } function d3_map_has(key) { - return d3_map_prefix + key in this; + return d3_map_escape(key) in this._; } function d3_map_remove(key) { - key = d3_map_prefix + key; - return key in this && delete this[key]; + return (key = d3_map_escape(key)) in this._ && delete this._[key]; } function d3_map_keys() { var keys = []; - this.forEach(function(key) { - keys.push(key); - }); + for (var key in this._) keys.push(d3_map_unescape(key)); return keys; } function d3_map_size() { var size = 0; - for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) ++size; + for (var key in this._) ++size; return size; } function d3_map_empty() { - for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) return false; + for (var key in this._) return false; return true; } d3.nest = function() { @@ -367,22 +371,21 @@ if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); return set; }; - function d3_Set() {} + function d3_Set() { + this._ = Object.create(null); + } d3_class(d3_Set, { has: d3_map_has, - add: function(value) { - this[d3_map_prefix + value] = true; - return value; - }, - remove: function(value) { - value = d3_map_prefix + value; - return value in this && delete this[value]; + add: function(key) { + this._[d3_map_escape(key += "")] = true; + return key; }, + remove: d3_map_remove, values: d3_map_keys, size: d3_map_size, empty: d3_map_empty, forEach: function(f) { - for (var value in this) if (value.charCodeAt(0) === d3_map_prefixCode) f.call(this, value.substring(1)); + for (var key in this._) f.call(this, d3_map_unescape(key)); } }); d3.behavior = {}; @@ -399,7 +402,7 @@ } function d3_vendorSymbol(object, name) { if (name in object) return name; - name = name.charAt(0).toUpperCase() + name.substring(1); + name = name.charAt(0).toUpperCase() + name.slice(1); for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { var prefixName = d3_vendorPrefixes[i] + name; if (prefixName in object) return prefixName; @@ -416,8 +419,8 @@ d3_dispatch.prototype.on = function(type, listener) { var i = type.indexOf("."), name = ""; if (i >= 0) { - name = type.substring(i + 1); - type = type.substring(0, i); + name = type.slice(i + 1); + type = type.slice(0, i); } if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); if (arguments.length === 2) { @@ -558,8 +561,8 @@ qualify: function(name) { var i = name.indexOf(":"), prefix = name; if (i >= 0) { - prefix = name.substring(0, i); - name = name.substring(i + 1); + prefix = name.slice(0, i); + name = name.slice(i + 1); } return d3_nsPrefix.hasOwnProperty(prefix) ? { space: d3_nsPrefix[prefix], @@ -762,29 +765,26 @@ function bind(group, groupData) { var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; if (key) { - var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; + var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; for (i = -1; ++i < n; ) { - keyValue = key.call(node = group[i], node.__data__, i); - if (nodeByKeyValue.has(keyValue)) { + if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) { exitNodes[i] = node; } else { nodeByKeyValue.set(keyValue, node); } - keyValues.push(keyValue); + keyValues[i] = keyValue; } for (i = -1; ++i < m; ) { - keyValue = key.call(groupData, nodeData = groupData[i], i); - if (node = nodeByKeyValue.get(keyValue)) { + if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { + enterNodes[i] = d3_selection_dataNode(nodeData); + } else if (node !== true) { updateNodes[i] = node; node.__data__ = nodeData; - } else if (!dataByKeyValue.has(keyValue)) { - enterNodes[i] = d3_selection_dataNode(nodeData); } - dataByKeyValue.set(keyValue, nodeData); - nodeByKeyValue.remove(keyValue); + nodeByKeyValue.set(keyValue, true); } for (i = -1; ++i < n; ) { - if (nodeByKeyValue.has(keyValues[i])) { + if (nodeByKeyValue.get(keyValues[i]) !== true) { exitNodes[i] = group[i]; } } @@ -911,7 +911,7 @@ }; d3_selectionPrototype.size = function() { var n = 0; - this.each(function() { + d3_selection_each(this, function() { ++n; }); return n; @@ -1008,7 +1008,7 @@ }; function d3_selection_on(type, listener, capture) { var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; - if (i > 0) type = type.substring(0, i); + if (i > 0) type = type.slice(0, i); var filter = d3_selection_onFilters.get(type); if (filter) type = filter, wrap = d3_selection_onFilter; function onRemove() { @@ -1116,13 +1116,13 @@ var rect = container.getBoundingClientRect(); return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; } - d3.touches = function(container, touches) { - if (arguments.length < 2) touches = d3_eventSource().touches; - return touches ? d3_array(touches).map(function(touch) { - var point = d3_mousePoint(container, touch); - point.identifier = touch.identifier; - return point; - }) : []; + d3.touch = function(container, touches, identifier) { + if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; + if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { + if ((touch = touches[i]).identifier === identifier) { + return d3_mousePoint(container, touch); + } + } }; d3.behavior.drag = function() { var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_behavior_dragMouseSubject, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_behavior_dragTouchSubject, "touchmove", "touchend"); @@ -1182,6 +1182,14 @@ function d3_behavior_dragMouseSubject() { return d3_window; } + d3.touches = function(container, touches) { + if (arguments.length < 2) touches = d3_eventSource().touches; + return touches ? d3_array(touches).map(function(touch) { + var point = d3_mousePoint(container, touch); + point.identifier = touch.identifier; + return point; + }) : []; + }; var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π; function d3_sgn(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; @@ -1377,10 +1385,11 @@ } } function touchstarted() { - var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress(); + var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(); d3_selection_interrupt.call(that); started(); zoomstarted(dispatch); + subject.on(mousedown, null).on(touchstart, started); function relocate() { var touches = d3.touches(that); scale0 = view.k; @@ -1539,7 +1548,7 @@ } d3.lab = d3_lab; function d3_lab(l, a, b) { - return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); + return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); } var d3_lab_K = 18; var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; @@ -1623,7 +1632,7 @@ } } if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b); - if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.substring(1), 16))) { + if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { if (format.length === 4) { r = (color & 3840) >> 4; r = r >> 4 | r; @@ -1842,7 +1851,7 @@ }; function respond() { var status = request.status, result; - if (!status && request.responseText || status >= 200 && status < 300 || status === 304) { + if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) { try { result = response.call(xhr, request); } catch (e) { @@ -1914,6 +1923,10 @@ callback(error == null ? request : null); } : callback; } + function d3_xhrHasResponse(request) { + var type = request.responseType; + return type && type !== "text" ? request.response : request.responseText; + } d3.dsv = function(delimiter, mimeType) { var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); function dsv(url, row, callback) { @@ -1966,7 +1979,7 @@ } else if (c === 10) { eol = true; } - return text.substring(j + 1, i).replace(/""/g, '"'); + return text.slice(j + 1, i).replace(/""/g, '"'); } while (I < N) { var c = text.charCodeAt(I++), k = 1; @@ -1974,9 +1987,9 @@ eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } else if (c !== delimiterCode) continue; - return text.substring(j, I - k); + return text.slice(j, I - k); } - return text.substring(j); + return text.slice(j); } while ((t = token()) !== EOF) { var a = []; @@ -1984,7 +1997,7 @@ a.push(t); t = token(); } - if (f && !(a = f(a, n++))) continue; + if (f && (a = f(a, n++)) == null) continue; rows.push(a); } return rows; @@ -2018,14 +2031,6 @@ }; d3.csv = d3.dsv(",", "text/csv"); d3.tsv = d3.dsv(" ", "text/tab-separated-values"); - d3.touch = function(container, touches, identifier) { - if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; - if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { - if ((touch = touches[i]).identifier === identifier) { - return d3_mousePoint(container, touch); - } - } - }; var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) { setTimeout(callback, 17); }; @@ -2115,21 +2120,22 @@ }; } function d3_locale_numberFormat(locale) { - var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping ? function(value) { - var i = value.length, t = [], j = 0, g = locale_grouping[0]; + var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) { + var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0; while (i > 0 && g > 0) { + if (length + g + 1 > width) g = Math.max(1, width - length); t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; g = locale_grouping[j = (j + 1) % locale_grouping.length]; } return t.reverse().join(locale_thousands); } : d3_identity; return function(specifier) { - var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false; + var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true; if (precision) precision = +precision.substring(1); if (zfill || fill === "0" && align === "=") { zfill = fill = "0"; align = "="; - if (comma) width -= Math.floor((width - 1) / 4); } switch (type) { case "n": @@ -2156,6 +2162,8 @@ if (symbol === "#") prefix = "0" + type.toLowerCase(); case "c": + exponent = false; + case "d": integer = true; precision = 0; @@ -2176,7 +2184,7 @@ return function(value) { var fullSuffix = suffix; if (integer && value % 1) return ""; - var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; + var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign; if (scale < 0) { var unit = d3.formatPrefix(value, precision); value = unit.scale(value); @@ -2185,10 +2193,17 @@ value *= scale; } value = type(value, precision); - var i = value.lastIndexOf("."), before = i < 0 ? value : value.substring(0, i), after = i < 0 ? "" : locale_decimal + value.substring(i + 1); - if (!zfill && comma) before = formatGroup(before); + var i = value.lastIndexOf("."), before, after; + if (i < 0) { + var j = exponent ? value.lastIndexOf("e") : -1; + if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j); + } else { + before = value.substring(0, i); + after = locale_decimal + value.substring(i + 1); + } + if (!zfill && comma) before = formatGroup(before, Infinity); var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; - if (zcomma) before = formatGroup(padding + before); + if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity); negative += prefix; value = before + after; return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix; @@ -2411,14 +2426,14 @@ var string = [], i = -1, j = 0, c, p, f; while (++i < n) { if (template.charCodeAt(i) === 37) { - string.push(template.substring(j, i)); + string.push(template.slice(j, i)); if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); string.push(c); j = i + 1; } } - string.push(template.substring(j, i)); + string.push(template.slice(j, i)); return string.join(""); } format.parse = function(string) { @@ -2439,7 +2454,7 @@ date.setFullYear(d.y, 0, 1); date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); } else date.setFullYear(d.y, d.m, d.d); - date.setHours(d.H + Math.floor(d.Z / 100), d.M + d.Z % 100, d.S, d.L); + date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L); return localZ ? date._ : date; }; format.toString = function() { @@ -2585,22 +2600,22 @@ }; function d3_time_parseWeekdayAbbrev(date, string, i) { d3_time_dayAbbrevRe.lastIndex = 0; - var n = d3_time_dayAbbrevRe.exec(string.substring(i)); + var n = d3_time_dayAbbrevRe.exec(string.slice(i)); return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; } function d3_time_parseWeekday(date, string, i) { d3_time_dayRe.lastIndex = 0; - var n = d3_time_dayRe.exec(string.substring(i)); + var n = d3_time_dayRe.exec(string.slice(i)); return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; } function d3_time_parseMonthAbbrev(date, string, i) { d3_time_monthAbbrevRe.lastIndex = 0; - var n = d3_time_monthAbbrevRe.exec(string.substring(i)); + var n = d3_time_monthAbbrevRe.exec(string.slice(i)); return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; } function d3_time_parseMonth(date, string, i) { d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.substring(i)); + var n = d3_time_monthRe.exec(string.slice(i)); return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; } function d3_time_parseLocaleFull(date, string, i) { @@ -2613,7 +2628,7 @@ return d3_time_parse(date, d3_time_formats.X.toString(), string, i); } function d3_time_parseAmPm(date, string, i) { - var n = d3_time_periodLookup.get(string.substring(i, i += 2).toLowerCase()); + var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase()); return n == null ? -1 : (date.p = n, i); } return d3_time_format; @@ -2637,31 +2652,31 @@ } function d3_time_parseWeekdayNumber(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 1)); + var n = d3_time_numberRe.exec(string.slice(i, i + 1)); return n ? (date.w = +n[0], i + n[0].length) : -1; } function d3_time_parseWeekNumberSunday(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i)); + var n = d3_time_numberRe.exec(string.slice(i)); return n ? (date.U = +n[0], i + n[0].length) : -1; } function d3_time_parseWeekNumberMonday(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i)); + var n = d3_time_numberRe.exec(string.slice(i)); return n ? (date.W = +n[0], i + n[0].length) : -1; } function d3_time_parseFullYear(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 4)); + var n = d3_time_numberRe.exec(string.slice(i, i + 4)); return n ? (date.y = +n[0], i + n[0].length) : -1; } function d3_time_parseYear(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; } function d3_time_parseZone(date, string, i) { - return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = -string, + return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, i + 5) : -1; } function d3_time_expandYear(d) { @@ -2669,46 +2684,46 @@ } function d3_time_parseMonthNumber(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.m = n[0] - 1, i + n[0].length) : -1; } function d3_time_parseDay(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.d = +n[0], i + n[0].length) : -1; } function d3_time_parseDayOfYear(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 3)); + var n = d3_time_numberRe.exec(string.slice(i, i + 3)); return n ? (date.j = +n[0], i + n[0].length) : -1; } function d3_time_parseHour24(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.H = +n[0], i + n[0].length) : -1; } function d3_time_parseMinutes(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.M = +n[0], i + n[0].length) : -1; } function d3_time_parseSeconds(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + var n = d3_time_numberRe.exec(string.slice(i, i + 2)); return n ? (date.S = +n[0], i + n[0].length) : -1; } function d3_time_parseMilliseconds(date, string, i) { d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.substring(i, i + 3)); + var n = d3_time_numberRe.exec(string.slice(i, i + 3)); return n ? (date.L = +n[0], i + n[0].length) : -1; } function d3_time_zone(d) { - var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(abs(z) / 60), zm = abs(z) % 60; + var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60; return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); } function d3_time_parseLiteralPercent(date, string, i) { d3_time_percentRe.lastIndex = 0; - var n = d3_time_percentRe.exec(string.substring(i, i + 1)); + var n = d3_time_percentRe.exec(string.slice(i, i + 1)); return n ? i + n[0].length : -1; } function d3_time_formatMulti(formats) { @@ -3316,35 +3331,6 @@ function d3_geo_clipSort(a, b) { return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); } - function d3_geo_pointInPolygon(point, polygon) { - var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; - d3_geo_areaRingSum.reset(); - for (var i = 0, n = polygon.length; i < n; ++i) { - var ring = polygon[i], m = ring.length; - if (!m) continue; - var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; - while (true) { - if (j === m) j = 0; - point = ring[j]; - var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; - d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); - polarAngle += antimeridian ? dλ + sdλ * τ : dλ; - if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { - var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); - d3_geo_cartesianNormalize(arc); - var intersection = d3_geo_cartesianCross(meridianNormal, arc); - d3_geo_cartesianNormalize(intersection); - var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); - if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { - winding += antimeridian ^ dλ >= 0 ? 1 : -1; - } - } - if (!j++) break; - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; - } - } - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; - } var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); function d3_geo_clipAntimeridianLine(listener) { var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; @@ -3412,6 +3398,35 @@ listener.point(to[0], to[1]); } } + function d3_geo_pointInPolygon(point, polygon) { + var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; + d3_geo_areaRingSum.reset(); + for (var i = 0, n = polygon.length; i < n; ++i) { + var ring = polygon[i], m = ring.length; + if (!m) continue; + var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; + while (true) { + if (j === m) j = 0; + point = ring[j]; + var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; + d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); + polarAngle += antimeridian ? dλ + sdλ * τ : dλ; + if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { + var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); + d3_geo_cartesianNormalize(arc); + var intersection = d3_geo_cartesianCross(meridianNormal, arc); + d3_geo_cartesianNormalize(intersection); + var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); + if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { + winding += antimeridian ^ dλ >= 0 ? 1 : -1; + } + } + if (!j++) break; + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } + return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; + } function d3_geo_clipCircle(radius) { var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); @@ -5600,9 +5615,9 @@ } d3.interpolateNumber = d3_interpolateNumber; function d3_interpolateNumber(a, b) { - b -= a = +a; + a = +a, b = +b; return function(t) { - return a + b * t; + return a * (1 - t) + b * t; }; } d3.interpolateString = d3_interpolateString; @@ -5611,7 +5626,7 @@ a = a + "", b = b + ""; while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) { if ((bs = bm.index) > bi) { - bs = b.substring(bi, bs); + bs = b.slice(bi, bs); if (s[i]) s[i] += bs; else s[++i] = bs; } if ((am = am[0]) === (bm = bm[0])) { @@ -5626,7 +5641,7 @@ bi = d3_interpolate_numberB.lastIndex; } if (bi < b.length) { - bs = b.substring(bi); + bs = b.slice(bi); if (s[i]) s[i] += bs; else s[++i] = bs; } return s.length < 2 ? q[0] ? (b = q[0].x, function(t) { @@ -5696,7 +5711,7 @@ } }); d3.ease = function(name) { - var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in"; + var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in"; t = d3_ease.get(t) || d3_ease_default; m = d3_ease_mode.get(m) || d3_identity; return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); @@ -5901,15 +5916,15 @@ }; } function d3_uninterpolateNumber(a, b) { - b = b - (a = +a) ? 1 / (b - a) : 0; + b = (b -= a = +a) || 1 / b; return function(x) { - return (x - a) * b; + return (x - a) / b; }; } function d3_uninterpolateClamp(a, b) { - b = b - (a = +a) ? 1 / (b - a) : 0; + b = (b -= a = +a) || 1 / b; return function(x) { - return Math.max(0, Math.min(1, (x - a) * b)); + return Math.max(0, Math.min(1, (x - a) / b)); }; } d3.layout = {}; @@ -6511,6 +6526,7 @@ d3.layout.stack = function() { var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; function stack(data, index) { + if (!(n = data.length)) return data; var series = data.map(function(d, i) { return values.call(stack, d, i); }); @@ -6523,7 +6539,7 @@ series = d3.permute(series, orders); points = d3.permute(points, orders); var offsets = offset.call(stack, points, index); - var n = series.length, m = series[0].length, i, j, o; + var m = series[0].length, n, i, j, o; for (j = 0; j < m; ++j) { out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); for (i = 1; i < n; ++i) { @@ -7678,7 +7694,7 @@ } scale.domain = function(x) { if (!arguments.length) return domain; - domain = x.filter(d3_number).sort(d3_ascending); + domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending); return rescale(); }; scale.range = function(x) { @@ -8627,61 +8643,25 @@ g.each(function() { var g = d3.select(this); var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); - var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickTransform; + var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform; var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), d3.transition(path)); tickEnter.append("line"); tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - switch (orient) { - case "bottom": - { - tickTransform = d3_svg_axisX; - lineEnter.attr("y2", innerTickSize); - textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding); - lineUpdate.attr("x2", 0).attr("y2", innerTickSize); - textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding); - text.attr("dy", ".71em").style("text-anchor", "middle"); - pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); - break; - } - - case "top": - { - tickTransform = d3_svg_axisX; - lineEnter.attr("y2", -innerTickSize); - textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); - lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); - textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); - text.attr("dy", "0em").style("text-anchor", "middle"); - pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); - break; - } - - case "left": - { - tickTransform = d3_svg_axisY; - lineEnter.attr("x2", -innerTickSize); - textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)); - lineUpdate.attr("x2", -innerTickSize).attr("y2", 0); - textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0); - text.attr("dy", ".32em").style("text-anchor", "end"); - pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); - break; - } - - case "right": - { - tickTransform = d3_svg_axisY; - lineEnter.attr("x2", innerTickSize); - textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding); - lineUpdate.attr("x2", innerTickSize).attr("y2", 0); - textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0); - text.attr("dy", ".32em").style("text-anchor", "start"); - pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize); - break; - } - } + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2; + if (orient === "bottom" || orient === "top") { + tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2"; + text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize); + } else { + tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2"; + text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start"); + pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize); + } + lineEnter.attr(y2, sign * innerTickSize); + textEnter.attr(y1, sign * tickSpacing); + lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize); + textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing); if (scale1.rangeBand) { var x = scale1, dx = x.rangeBand() / 2; scale0 = scale1 = function(d) { @@ -8690,10 +8670,10 @@ } else if (scale0.rangeBand) { scale0 = scale1; } else { - tickExit.call(tickTransform, scale1); + tickExit.call(tickTransform, scale1, scale0); } - tickEnter.call(tickTransform, scale0); - tickUpdate.call(tickTransform, scale1); + tickEnter.call(tickTransform, scale0, scale1); + tickUpdate.call(tickTransform, scale1, scale1); }); } axis.scale = function(x) { @@ -8754,14 +8734,16 @@ bottom: 1, left: 1 }; - function d3_svg_axisX(selection, x) { + function d3_svg_axisX(selection, x0, x1) { selection.attr("transform", function(d) { - return "translate(" + x(d) + ",0)"; + var v0 = x0(d); + return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)"; }); } - function d3_svg_axisY(selection, y) { + function d3_svg_axisY(selection, y0, y1) { selection.attr("transform", function(d) { - return "translate(0," + y(d) + ")"; + var v0 = y0(d); + return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")"; }); } d3.svg.brush = function() { diff --git a/bower_components/d3/d3.min.js b/bower_components/d3/d3.min.js index 88550ae512..d7cfb702fc 100644 --- a/bower_components/d3/d3.min.js +++ b/bower_components/d3/d3.min.js @@ -1,5 +1,5 @@ -!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null!=n&&!isNaN(n)}function e(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function r(n){return n.length}function u(n){for(var t=1;n*t%1;)t*=10;return t}function i(n,t){try{for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}catch(r){n.prototype=t}}function o(){}function a(n){return ia+n in this}function c(n){return n=ia+n,n in this&&delete this[n]}function s(){var n=[];return this.forEach(function(t){n.push(t)}),n}function l(){var n=0;for(var t in this)t.charCodeAt(0)===oa&&++n;return n}function f(){for(var n in this)if(n.charCodeAt(0)===oa)return!1;return!0}function h(){}function g(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function p(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.substring(1);for(var e=0,r=aa.length;r>e;++e){var u=aa[e]+t;if(u in n)return u}}function v(){}function d(){}function m(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function U(n){return sa(n,da),n}function j(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.substring(0,a));var s=ya.get(n);return s&&(n=s,c=Y),a?t?u:r:t?v:i}function O(n,t){return function(e){var r=Zo.event;Zo.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Zo.event=r}}}function Y(n,t){var e=O(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function I(){var n=".dragsuppress-"+ ++Ma,t="click"+n,e=Zo.select(Wo).on("touchmove"+n,y).on("dragstart"+n,y).on("selectstart"+n,y);if(xa){var r=Bo.style,u=r[xa];r[xa]="none"}return function(i){function o(){e.on(t,null)}e.on(n,null),xa&&(r[xa]=u),i&&(e.on(t,function(){y(),o()},!0),setTimeout(o,0))}}function Z(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>_a&&(Wo.scrollX||Wo.scrollY)){e=Zo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();_a=!(u.f||u.e),e.remove()}return _a?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function V(){return Zo.event.changedTouches[0].identifier}function X(){return Zo.event.target}function $(){return Wo}function B(n){return n>0?1:0>n?-1:0}function W(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function J(n){return n>1?0:-1>n?ba:Math.acos(n)}function G(n){return n>1?Sa:-1>n?-Sa:Math.asin(n)}function K(n){return((n=Math.exp(n))-1/n)/2}function Q(n){return((n=Math.exp(n))+1/n)/2}function nt(n){return((n=Math.exp(2*n))-1)/(n+1)}function tt(n){return(n=Math.sin(n/2))*n}function et(){}function rt(n,t,e){return this instanceof rt?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof rt?new rt(n.h,n.s,n.l):mt(""+n,yt,rt):new rt(n,t,e)}function ut(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new gt(u(n+120),u(n),u(n-120))}function it(n,t,e){return this instanceof it?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof it?new it(n.h,n.c,n.l):n instanceof at?st(n.l,n.a,n.b):st((n=xt((n=Zo.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new it(n,t,e)}function ot(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new at(e,Math.cos(n*=Aa)*t,Math.sin(n)*t)}function at(n,t,e){return this instanceof at?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof at?new at(n.l,n.a,n.b):n instanceof it?ot(n.l,n.c,n.h):xt((n=gt(n)).r,n.g,n.b):new at(n,t,e)}function ct(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=lt(u)*ja,r=lt(r)*Ha,i=lt(i)*Fa,new gt(ht(3.2404542*u-1.5371385*r-.4985314*i),ht(-.969266*u+1.8760108*r+.041556*i),ht(.0556434*u-.2040259*r+1.0572252*i))}function st(n,t,e){return n>0?new it(Math.atan2(e,t)*Ca,Math.sqrt(t*t+e*e),n):new it(0/0,0/0,n)}function lt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function ft(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function ht(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function gt(n,t,e){return this instanceof gt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof gt?new gt(n.r,n.g,n.b):mt(""+n,gt,ut):new gt(n,t,e)}function pt(n){return new gt(n>>16,255&n>>8,255&n)}function vt(n){return pt(n)+""}function dt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function mt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(_t(u[0]),_t(u[1]),_t(u[2]))}return(i=Ia.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.substring(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function yt(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new rt(r,u,c)}function xt(n,t,e){n=Mt(n),t=Mt(t),e=Mt(e);var r=ft((.4124564*n+.3575761*t+.1804375*e)/ja),u=ft((.2126729*n+.7151522*t+.072175*e)/Ha),i=ft((.0193339*n+.119192*t+.9503041*e)/Fa);return at(116*u-16,500*(r-u),200*(u-i))}function Mt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function _t(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function bt(n){return"function"==typeof n?n:function(){return n}}function wt(n){return n}function St(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),kt(t,e,n,r)}}function kt(n,t,e,r){function u(){var n,t=c.status;if(!t&&c.responseText||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=Zo.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,s=null;return!Wo.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=Zo.event;Zo.event=n;try{o.progress.call(i,c)}finally{Zo.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(s=n,i):s},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Xo(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var l in a)c.setRequestHeader(l,a[l]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=s&&(c.responseType=s),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},Zo.rebind(i,o,"on"),null==r?i:i.get(Et(r))}function Et(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function At(){var n=Ct(),t=Nt()-n;t>24?(isFinite(t)&&(clearTimeout($a),$a=setTimeout(At,t)),Xa=0):(Xa=1,Wa(At))}function Ct(){var n=Date.now();for(Ba=Za;Ba;)n>=Ba.t&&(Ba.f=Ba.c(n-Ba.t)),Ba=Ba.n;return n}function Nt(){for(var n,t=Za,e=1/0;t;)t.f?t=n?n.n=t.n:Za=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Tt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r?function(n){for(var t=n.length,u=[],i=0,o=r[0];t>0&&o>0;)u.push(n.substring(t-=o,t+o)),o=r[i=(i+1)%r.length];return u.reverse().join(e)}:wt;return function(n){var e=Ga.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"",c=e[4]||"",s=e[5],l=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1;switch(h&&(h=+h.substring(1)),(s||"0"===r&&"="===o)&&(s=r="0",o="=",f&&(l-=Math.floor((l-1)/4))),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=Ka.get(g)||qt;var y=s&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):a;if(0>p){var c=Zo.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var x=n.lastIndexOf("."),M=0>x?n:n.substring(0,x),_=0>x?"":t+n.substring(x+1);!s&&f&&(M=i(M));var b=v.length+M.length+_.length+(y?0:u.length),w=l>b?new Array(b=l-b+1).join(r):"";return y&&(M=i(w+M)),u+=v,n=M+_,("<"===o?u+n+w:">"===o?w+u+n:"^"===o?w.substring(0,b>>=1)+u+n+w.substring(b):u+(y?n:w+n))+e}}}function qt(n){return n+""}function Rt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Dt(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new nc(e-1)),1),e}function i(n,e){return t(n=new nc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{nc=Rt;var r=new Rt;return r._=n,o(r,t,e)}finally{nc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Pt(n);return c.floor=c,c.round=Pt(r),c.ceil=Pt(u),c.offset=Pt(i),c.range=a,n}function Pt(n){return function(t,e){try{nc=Rt;var r=new Rt;return r._=t,n(r,e)._}finally{nc=Date}}}function Ut(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=s)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=N[o in ec?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){b.lastIndex=0;var r=b.exec(t.substring(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){M.lastIndex=0;var r=M.exec(t.substring(e));return r?(n.w=_.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.substring(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.substring(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,C.c.toString(),t,r)}function c(n,t,r){return e(n,C.x.toString(),t,r)}function s(n,t,r){return e(n,C.X.toString(),t,r)}function l(n,t,e){var r=x.get(t.substring(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{nc=Rt;var t=new nc;return t._=n,r(t)}finally{nc=Date}}var r=t(n);return e.parse=function(n){try{nc=Rt;var t=r.parse(n);return t&&t._}finally{nc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=re;var x=Zo.map(),M=Ht(v),_=Ft(v),b=Ht(d),w=Ft(d),S=Ht(m),k=Ft(m),E=Ht(y),A=Ft(y);p.forEach(function(n,t){x.set(n.toLowerCase(),t)});var C={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return jt(n.getDate(),t,2)},e:function(n,t){return jt(n.getDate(),t,2)},H:function(n,t){return jt(n.getHours(),t,2)},I:function(n,t){return jt(n.getHours()%12||12,t,2)},j:function(n,t){return jt(1+Qa.dayOfYear(n),t,3)},L:function(n,t){return jt(n.getMilliseconds(),t,3)},m:function(n,t){return jt(n.getMonth()+1,t,2)},M:function(n,t){return jt(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return jt(n.getSeconds(),t,2)},U:function(n,t){return jt(Qa.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return jt(Qa.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return jt(n.getFullYear()%100,t,2)},Y:function(n,t){return jt(n.getFullYear()%1e4,t,4)},Z:te,"%":function(){return"%"}},N={a:r,A:u,b:i,B:o,c:a,d:Wt,e:Wt,H:Gt,I:Gt,j:Jt,L:ne,m:Bt,M:Kt,p:l,S:Qt,U:Yt,w:Ot,W:It,x:c,X:s,y:Vt,Y:Zt,Z:Xt,"%":ee};return t}function jt(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function Ht(n){return new RegExp("^(?:"+n.map(Zo.requote).join("|")+")","i")}function Ft(n){for(var t=new o,e=-1,r=n.length;++e68?1900:2e3)}function Bt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Wt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Jt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function Gt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function Kt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function Qt(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ne(n,t,e){rc.lastIndex=0;var r=rc.exec(t.substring(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function te(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=~~(ua(t)/60),u=ua(t)%60;return e+jt(r,"0",2)+jt(u,"0",2)}function ee(n,t,e){uc.lastIndex=0;var r=uc.exec(t.substring(e,e+1));return r?e+r[0].length:-1}function re(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),s=Math.sin(t),l=i*s,f=u*c+l*Math.cos(a),h=l*o*Math.sin(a);lc.add(Math.atan2(h,f)),r=n,u=c,i=s}var t,e,r,u,i;fc.point=function(o,a){fc.point=n,r=(t=o)*Aa,u=Math.cos(a=(e=a)*Aa/2+ba/4),i=Math.sin(a)},fc.lineEnd=function(){n(t,e)}}function le(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function fe(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function he(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function ge(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function pe(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function ve(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function de(n){return[Math.atan2(n[1],n[0]),G(n[2])]}function me(n,t){return ua(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new Ee(e,n,null,!0),s=new Ee(e,null,c,!1);c.o=s,i.push(c),o.push(s),c=new Ee(r,n,null,!1),s=new Ee(r,null,c,!0),c.o=s,i.push(c),o.push(s)}}),o.sort(t),ke(i),ke(o),i.length){for(var a=0,c=e,s=o.length;s>a;++a)o[a].e=c=!c;for(var l,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;l=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,s=l.length;s>a;++a)u.point((f=l[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){l=g.p.z;for(var a=l.length-1;a>=0;--a)u.point((f=l[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,l=g.z,p=!p}while(!g.v);u.lineEnd()}}}function ke(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(_||(i.polygonStart(),_=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Ce))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:s,polygonStart:function(){y.point=l,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=s,g=Zo.merge(g);var n=Le(m,p);g.length?(_||(i.polygonStart(),_=!0),Se(g,ze,n,e,i)):n&&(_||(i.polygonStart(),_=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),_&&(i.polygonEnd(),_=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},x=Ne(),M=t(x),_=!1;return y}}function Ce(n){return n.length>1}function Ne(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:v,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function ze(n,t){return((n=n.x)[0]<0?n[1]-Sa-ka:Sa-n[1])-((t=t.x)[0]<0?t[1]-Sa-ka:Sa-t[1])}function Le(n,t){var e=n[0],r=n[1],u=[Math.sin(e),-Math.cos(e),0],i=0,o=0;lc.reset();for(var a=0,c=t.length;c>a;++a){var s=t[a],l=s.length;if(l)for(var f=s[0],h=f[0],g=f[1]/2+ba/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===l&&(d=0),n=s[d];var m=n[0],y=n[1]/2+ba/4,x=Math.sin(y),M=Math.cos(y),_=m-h,b=_>=0?1:-1,w=b*_,S=w>ba,k=p*x;if(lc.add(Math.atan2(k*b*Math.sin(w),v*M+k*Math.cos(w))),i+=S?_+b*wa:_,S^h>=e^m>=e){var E=he(le(f),le(n));ve(E);var A=he(u,E);ve(A);var C=(S^_>=0?-1:1)*G(A[2]);(r>C||r===C&&(E[0]||E[1]))&&(o+=S^_>=0?1:-1)}if(!d++)break;h=m,p=x,v=M,f=n}}return(-ka>i||ka>i&&0>lc)^1&o}function Te(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?ba:-ba,c=ua(i-e);ua(c-ba)0?Sa:-Sa),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=ba&&(ua(e-u)ka?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function Re(n,t,e,r){var u;if(null==n)u=e*Sa,r.point(-ba,u),r.point(0,u),r.point(ba,u),r.point(ba,0),r.point(ba,-u),r.point(0,-u),r.point(-ba,-u),r.point(-ba,0),r.point(-ba,u);else if(ua(n[0]-t[0])>ka){var i=n[0]i}function e(n){var e,i,c,s,l;return{lineStart:function(){s=c=!1,l=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?ba:-ba),h):0;if(!e&&(s=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(me(e,g)||me(p,g))&&(p[0]+=ka,p[1]+=ka,v=t(p[0],p[1]))),v!==c)l=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(l=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&me(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return l|(s&&c)<<1}}}function r(n,t,e){var r=le(n),u=le(t),o=[1,0,0],a=he(r,u),c=fe(a,a),s=a[0],l=c-s*s;if(!l)return!e&&n;var f=i*c/l,h=-i*s/l,g=he(o,a),p=pe(o,f),v=pe(a,h);ge(p,v);var d=g,m=fe(p,d),y=fe(d,d),x=m*m-y*(fe(p,p)-1);if(!(0>x)){var M=Math.sqrt(x),_=pe(d,(-m-M)/y);if(ge(_,p),_=de(_),!e)return _;var b,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(b=w,w=S,S=b);var A=S-w,C=ua(A-ba)A;if(!C&&k>E&&(b=k,k=E,E=b),N?C?k+E>0^_[1]<(ua(_[0]-w)ba^(w<=_[0]&&_[0]<=S)){var z=pe(d,(-m+M)/y);return ge(z,p),[_,de(z)]}}}function u(t,e){var r=o?n:ba-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=ua(i)>ka,c=sr(n,6*Aa);return Ae(t,e,c,o?[0,-n]:[-ba,n-ba])}function Pe(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,s=o.y,l=a.x,f=a.y,h=0,g=1,p=l-c,v=f-s;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-s,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-s,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:s+h*v}),1>g&&(u.b={x:c+g*p,y:s+g*v}),u}}}}}}function Ue(n,t,e,r){function u(r,u){return ua(r[0]-n)0?0:3:ua(r[0]-e)0?2:1:ua(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,s=a[0];c>o;++o)i=a[o],s[1]<=r?i[1]>r&&W(s,i,n)>0&&++t:i[1]<=r&&W(s,i,n)<0&&--t,s=i;return 0!==t}function s(i,a,c,s){var l=0,f=0;if(null==i||(l=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do s.point(0===l||3===l?n:e,l>1?r:t);while((l=(l+c+4)%4)!==f)}else s.point(a[0],a[1])}function l(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){l(n,t)&&a.point(n,t)}function h(){N.point=p,d&&d.push(m=[]),S=!0,w=!1,_=b=0/0}function g(){v&&(p(y,x),M&&w&&A.rejoin(),v.push(A.buffer())),N.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-kc,Math.min(kc,n)),t=Math.max(-kc,Math.min(kc,t));var e=l(n,t);if(d&&m.push([n,t]),S)y=n,x=t,M=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:_,y:b},b:{x:n,y:t}};C(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}_=n,b=t,w=e}var v,d,m,y,x,M,_,b,w,S,k,E=a,A=Ne(),C=Pe(n,t,e,r),N={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=Zo.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),s(null,null,1,a),a.lineEnd()),u&&Se(v,i,t,s,a),a.polygonEnd()),v=d=m=null}};return N}}function je(n,t){function e(e,r){return e=n(e,r),t(e[0],e[1])}return n.invert&&t.invert&&(e.invert=function(e,r){return e=t.invert(e,r),e&&n.invert(e[0],e[1])}),e}function He(n){var t=0,e=ba/3,r=tr(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*ba/180,e=n[1]*ba/180):[180*(t/ba),180*(e/ba)]},u}function Fe(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,G((i-(n*n+e*e)*u*u)/(2*u))]},e}function Oe(){function n(n,t){Ac+=u*n-r*t,r=n,u=t}var t,e,r,u;Tc.point=function(i,o){Tc.point=n,t=r=i,e=u=o},Tc.lineEnd=function(){n(t,e)}}function Ye(n,t){Cc>n&&(Cc=n),n>zc&&(zc=n),Nc>t&&(Nc=t),t>Lc&&(Lc=t)}function Ie(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Ze(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Ze(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Ze(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Ve(n,t){pc+=n,vc+=t,++dc}function Xe(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);mc+=o*(t+n)/2,yc+=o*(e+r)/2,xc+=o,Ve(t=n,e=r)}var t,e;Rc.point=function(r,u){Rc.point=n,Ve(t=r,e=u)}}function $e(){Rc.point=Ve}function Be(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);mc+=o*(r+n)/2,yc+=o*(u+t)/2,xc+=o,o=u*n-r*t,Mc+=o*(r+n),_c+=o*(u+t),bc+=3*o,Ve(r=n,u=t)}var t,e,r,u;Rc.point=function(i,o){Rc.point=n,Ve(t=r=i,e=u=o)},Rc.lineEnd=function(){n(t,e)}}function We(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,o,0,wa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:v};return a}function Je(n){function t(n){return(a?r:e)(n)}function e(t){return Qe(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){x=0/0,S.point=i,t.lineStart()}function i(e,r){var i=le([e,r]),o=n(e,r);u(x,M,y,_,b,w,x=o[0],M=o[1],y=e,_=i[0],b=i[1],w=i[2],a,t),t.point(x,M)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=s,S.lineEnd=l}function s(n,t){i(f=n,h=t),g=x,p=M,v=_,d=b,m=w,S.point=i}function l(){u(x,M,y,_,b,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,x,M,_,b,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,s,l,f,h,g,p,v,d,m){var y=l-t,x=f-e,M=y*y+x*x;if(M>4*i&&d--){var _=a+g,b=c+p,w=s+v,S=Math.sqrt(_*_+b*b+w*w),k=Math.asin(w/=S),E=ua(ua(w)-1)i||ua((y*z+x*L)/M-.5)>.3||o>a*g+c*p+s*v)&&(u(t,e,r,a,c,s,C,N,E,_/=S,b/=S,w,d,m),m.point(C,N),u(C,N,E,_,b,w,l,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Aa),a=16; -return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function Ge(n){var t=Je(function(t,e){return n([t*Ca,e*Ca])});return function(n){return er(t(n))}}function Ke(n){this.stream=n}function Qe(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function nr(n){return tr(function(){return n})()}function tr(n){function t(n){return n=a(n[0]*Aa,n[1]*Aa),[n[0]*h+c,s-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(s-n[1])/h),n&&[n[0]*Ca,n[1]*Ca]}function r(){a=je(o=ir(m,y,x),i);var n=i(v,d);return c=g-n[0]*h,s=p+n[1]*h,u()}function u(){return l&&(l.valid=!1,l=null),t}var i,o,a,c,s,l,f=Je(function(n,t){return n=i(n,t),[n[0]*h+c,s-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,x=0,M=Sc,_=wt,b=null,w=null;return t.stream=function(n){return l&&(l.valid=!1),l=er(M(o,f(_(n)))),l.valid=!0,l},t.clipAngle=function(n){return arguments.length?(M=null==n?(b=n,Sc):De((b=+n)*Aa),u()):b},t.clipExtent=function(n){return arguments.length?(w=n,_=n?Ue(n[0][0],n[0][1],n[1][0],n[1][1]):wt,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Aa,d=n[1]%360*Aa,r()):[v*Ca,d*Ca]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Aa,y=n[1]%360*Aa,x=n.length>2?n[2]%360*Aa:0,r()):[m*Ca,y*Ca,x*Ca]},Zo.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function er(n){return Qe(n,function(t,e){n.point(t*Aa,e*Aa)})}function rr(n,t){return[n,t]}function ur(n,t){return[n>ba?n-wa:-ba>n?n+wa:n,t]}function ir(n,t,e){return n?t||e?je(ar(n),cr(t,e)):ar(n):t||e?cr(t,e):ur}function or(n){return function(t,e){return t+=n,[t>ba?t-wa:-ba>t?t+wa:t,e]}}function ar(n){var t=or(n);return t.invert=or(-n),t}function cr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,s=Math.sin(t),l=s*r+a*u;return[Math.atan2(c*i-l*o,a*r-s*u),G(l*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,s=Math.sin(t),l=s*i-c*o;return[Math.atan2(c*i+s*o,a*r+l*u),G(l*r-a*u)]},e}function sr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=lr(e,u),i=lr(e,i),(o>0?i>u:u>i)&&(u+=o*wa)):(u=n+o*wa,i=n-.5*c);for(var s,l=u;o>0?l>i:i>l;l-=c)a.point((s=de([e,-r*Math.cos(l),-r*Math.sin(l)]))[0],s[1])}}function lr(n,t){var e=le(t);e[0]-=n,ve(e);var r=J(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-ka)%(2*Math.PI)}function fr(n,t,e){var r=Zo.range(n,t-ka,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function hr(n,t,e){var r=Zo.range(n,t-ka,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function gr(n){return n.source}function pr(n){return n.target}function vr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),s=u*Math.sin(n),l=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(tt(r-t)+u*o*tt(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*l,u=e*s+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ca,Math.atan2(o,Math.sqrt(r*r+u*u))*Ca]}:function(){return[n*Ca,t*Ca]};return p.distance=h,p}function dr(){function n(n,u){var i=Math.sin(u*=Aa),o=Math.cos(u),a=ua((n*=Aa)-t),c=Math.cos(a);Dc+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Pc.point=function(u,i){t=u*Aa,e=Math.sin(i*=Aa),r=Math.cos(i),Pc.point=n},Pc.lineEnd=function(){Pc.point=Pc.lineEnd=v}}function mr(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function yr(n,t){function e(n,t){o>0?-Sa+ka>t&&(t=-Sa+ka):t>Sa-ka&&(t=Sa-ka);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(ba/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=B(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Sa]},e):Mr}function xr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return ua(u)u;u++){for(;r>1&&W(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function Er(n,t){return n[0]-t[0]||n[1]-t[1]}function Ar(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Cr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],s=e[1],l=t[1]-c,f=r[1]-s,h=(a*(c-s)-f*(u-i))/(f*o-a*l);return[u+h*o,c+h*l]}function Nr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function zr(){Gr(this),this.edge=this.site=this.circle=null}function Lr(n){var t=Bc.pop()||new zr;return t.site=n,t}function Tr(n){Yr(n),Vc.remove(n),Bc.push(n),Gr(n)}function qr(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Tr(n);for(var c=i;c.circle&&ua(e-c.circle.x)l;++l)s=a[l],c=a[l-1],Br(s.edge,c.site,s.site,u);c=a[0],s=a[f-1],s.edge=Xr(c.site,s.site,null,u),Or(c),Or(s)}function Rr(n){for(var t,e,r,u,i=n.x,o=n.y,a=Vc._;a;)if(r=Dr(a,o)-i,r>ka)a=a.L;else{if(u=i-Pr(a,o),!(u>ka)){r>-ka?(t=a.P,e=a):u>-ka?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Lr(n);if(Vc.insert(t,c),t||e){if(t===e)return Yr(t),e=Lr(t.site),Vc.insert(c,e),c.edge=e.edge=Xr(t.site,c.site),Or(t),Or(e),void 0;if(!e)return c.edge=Xr(t.site,c.site),void 0;Yr(t),Yr(e);var s=t.site,l=s.x,f=s.y,h=n.x-l,g=n.y-f,p=e.site,v=p.x-l,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,x=v*v+d*d,M={x:(d*y-g*x)/m+l,y:(h*x-v*y)/m+f};Br(e.edge,s,p,M),c.edge=Xr(s,n,null,M),e.edge=Xr(n,p,null,M),Or(t),Or(e)}}function Dr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,s=c-t;if(!s)return a;var l=a-r,f=1/i-1/s,h=l/s;return f?(-h+Math.sqrt(h*h-2*f*(l*l/(-2*s)-c+s/2+u-i/2)))/f+r:(r+a)/2}function Pr(n,t){var e=n.N;if(e)return Dr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ur(n){this.site=n,this.edges=[]}function jr(n){for(var t,e,r,u,i,o,a,c,s,l,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=Zc,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)l=a[o].end(),r=l.x,u=l.y,s=a[++o%c].start(),t=s.x,e=s.y,(ua(r-t)>ka||ua(u-e)>ka)&&(a.splice(o,0,new Wr($r(i.site,l,ua(r-f)ka?{x:f,y:ua(t-f)ka?{x:ua(e-p)ka?{x:h,y:ua(t-h)ka?{x:ua(e-g)=-Ea)){var g=c*c+s*s,p=l*l+f*f,v=(f*g-s*p)/h,d=(c*p-l*g)/h,f=d+a,m=Wc.pop()||new Fr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,x=$c._;x;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=s)return}else i={x:d,y:c};e={x:d,y:s}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=s)return}else i={x:(c-u)/r,y:c};e={x:(s-u)/r,y:s}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi&&(u=t.substring(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:lu(e,r)})),i=Kc.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function hu(n,t){for(var e,r=Zo.interpolators.length;--r>=0&&!(e=Zo.interpolators[r](n,t)););return e}function gu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(hu(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function pu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function vu(n){return function(t){return 1-n(1-t)}}function du(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function mu(n){return n*n}function yu(n){return n*n*n}function xu(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Mu(n){return function(t){return Math.pow(t,n)}}function _u(n){return 1-Math.cos(n*Sa)}function bu(n){return Math.pow(2,10*(n-1))}function wu(n){return 1-Math.sqrt(1-n*n)}function Su(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/wa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*wa/t)}}function ku(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Eu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Au(n,t){n=Zo.hcl(n),t=Zo.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return ot(e+i*n,r+o*n,u+a*n)+""}}function Cu(n,t){n=Zo.hsl(n),t=Zo.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return ut(e+i*n,r+o*n,u+a*n)+""}}function Nu(n,t){n=Zo.lab(n),t=Zo.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ct(e+i*n,r+o*n,u+a*n)+""}}function zu(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Lu(n){var t=[n.a,n.b],e=[n.c,n.d],r=qu(t),u=Tu(t,e),i=qu(Ru(e,t,-u))||0;t[0]*e[1]180?l+=360:l-s>180&&(s+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:lu(s,l)})):l&&r.push(r.pop()+"rotate("+l+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:lu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:lu(g[0],p[0])},{i:e-2,x:lu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Bu(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function ii(n){return n.reduce(oi,0)}function oi(n,t){return n+t[1]}function ai(n,t){return ci(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function ci(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function si(n){return[Zo.min(n),Zo.max(n)]}function li(n,t){return n.value-t.value}function fi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function hi(n,t){n._pack_next=t,t._pack_prev=n}function gi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function pi(n){function t(n){l=Math.min(n.x-n.r,l),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(s=e.length)){var e,r,u,i,o,a,c,s,l=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(vi),r=e[0],r.x=-r.r,r.y=0,t(r),s>1&&(u=e[1],u.x=u.r,u.y=0,t(u),s>2))for(i=e[2],yi(r,u,i),t(i),fi(r,i),r._pack_prev=i,fi(i,u),u=r._pack_next,o=3;s>o;o++){yi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(gi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!gi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(di)}}function vi(n){n._pack_next=n._pack_prev=n}function di(n){delete n._pack_next,delete n._pack_prev}function mi(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Si(n,t,e){return n.a.parent===t.parent?n.a:e}function ki(n){return 1+Zo.max(n,function(n){return n.y})}function Ei(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Ai(n){var t=n.children;return t&&t.length?Ai(t[0]):n}function Ci(n){var t,e=n.children;return e&&(t=e.length)?Ci(e[t-1]):n}function Ni(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function zi(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Li(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Ti(n){return n.rangeExtent?n.rangeExtent():Li(n.range())}function qi(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Ri(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Di(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:ss}function Pi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Pi:qi,c=r?Uu:Pu;return o=u(n,t,c,e),a=u(t,n,c,hu),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(zu)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Oi(n,t)},i.tickFormat=function(t,e){return Yi(n,t,e)},i.nice=function(t){return Hi(n,t),u()},i.copy=function(){return Ui(n,t,e,r)},u()}function ji(n,t){return Zo.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Hi(n,t){return Ri(n,Di(Fi(n,t)[2]))}function Fi(n,t){null==t&&(t=10);var e=Li(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Oi(n,t){return Zo.range.apply(Zo,Fi(n,t))}function Yi(n,t,e){var r=Fi(n,t);if(e){var u=Ga.exec(e);if(u.shift(),"s"===u[8]){var i=Zo.formatPrefix(Math.max(ua(r[0]),ua(r[1])));return u[7]||(u[7]="."+Ii(i.scale(r[2]))),u[8]="f",e=Zo.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Zi(u[8],r)),e=u.join("")}else e=",."+Ii(r[2])+"f";return Zo.format(e)}function Ii(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Zi(n,t){var e=Ii(t[2]);return n in ls?Math.abs(e-Ii(Math.max(ua(t[0]),ua(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Vi(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Ri(r.map(u),e?Math:hs);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Li(r),o=[],a=n[0],c=n[1],s=Math.floor(u(a)),l=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(l-s)){if(e){for(;l>s;s++)for(var h=1;f>h;h++)o.push(i(s)*h);o.push(i(s))}else for(o.push(i(s));s++0;h--)o.push(i(s)*h);for(s=0;o[s]c;l--);o=o.slice(s,l)}return o},o.tickFormat=function(n,t){if(!arguments.length)return fs;arguments.length<2?t=fs:"function"!=typeof t&&(t=Zo.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Vi(n.copy(),t,e,r)},ji(o,n)}function Xi(n,t,e){function r(t){return n(u(t))}var u=$i(t),i=$i(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Oi(e,n)},r.tickFormat=function(n,t){return Yi(e,n,t)},r.nice=function(n){return r.domain(Hi(e,n))},r.exponent=function(o){return arguments.length?(u=$i(t=o),i=$i(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Xi(n.copy(),t,e)},ji(r,n)}function $i(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Bi(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return Zo.range(n.length).map(function(n){return t+e*n})}var u,i,a;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new o;for(var i,a=-1,c=r.length;++an?[0/0,0/0]:[n>0?o[n-1]:e[0],nt?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return Ji(n,t,e)},u()}function Gi(n,t){function e(e){return e>=e?t[Zo.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return Gi(n,t)},e}function Ki(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Oi(n,t)},t.tickFormat=function(t,e){return Yi(n,t,e)},t.copy=function(){return Ki(n)},t}function Qi(n){return n.innerRadius}function no(n){return n.outerRadius}function to(n){return n.startAngle}function eo(n){return n.endAngle}function ro(n){function t(t){function o(){s.push("M",i(n(l),a))}for(var c,s=[],l=[],f=-1,h=t.length,g=bt(e),p=bt(r);++f1&&u.push("H",r[0]),u.join("")}function ao(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var s=2;s9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function So(n){return n.length<3?uo(n):n[0]+ho(n,wo(n))}function ko(n){for(var t,e,r,u=-1,i=n.length;++ue?s():(u.active=e,i.event&&i.event.start.call(n,l,t),i.tween.forEach(function(e,r){(r=r.call(n,l,t))&&v.push(r)}),Zo.timer(function(){return p.c=c(r||1)?we:c,1},0,a),void 0)}function c(r){if(u.active!==e)return s();for(var o=r/g,a=f(o),c=v.length;c>0;)v[--c].call(n,a); -return o>=1?(i.event&&i.event.end.call(n,l,t),s()):void 0}function s(){return--u.count?delete u[e]:delete n.__transition__,1}var l=n.__data__,f=i.ease,h=i.delay,g=i.duration,p=Ba,v=[];return p.t=h+a,r>=h?o(r-h):(p.c=o,void 0)},0,a)}}function Uo(n,t){n.attr("transform",function(n){return"translate("+t(n)+",0)"})}function jo(n,t){n.attr("transform",function(n){return"translate(0,"+t(n)+")"})}function Ho(n){return n.toISOString()}function Fo(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Zo.bisect(Us,u);return i==Us.length?[t.year,Fi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Us[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Oo(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Oo(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Li(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Oo(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Fo(n.copy(),t,e)},ji(r,n)}function Oo(n){return new Date(n)}function Yo(n){return JSON.parse(n.responseText)}function Io(n){var t=$o.createRange();return t.selectNode($o.body),t.createContextualFragment(n.responseText)}var Zo={version:"3.4.11"};Date.now||(Date.now=function(){return+new Date});var Vo=[].slice,Xo=function(n){return Vo.call(n)},$o=document,Bo=$o.documentElement,Wo=window;try{Xo(Bo.childNodes)[0].nodeType}catch(Jo){Xo=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{$o.createElement("div").style.setProperty("opacity",0,"")}catch(Go){var Ko=Wo.Element.prototype,Qo=Ko.setAttribute,na=Ko.setAttributeNS,ta=Wo.CSSStyleDeclaration.prototype,ea=ta.setProperty;Ko.setAttribute=function(n,t){Qo.call(this,n,t+"")},Ko.setAttributeNS=function(n,t,e){na.call(this,n,t,e+"")},ta.setProperty=function(n,t,e){ea.call(this,n,t+"",e)}}Zo.ascending=n,Zo.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},Zo.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ur&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ur&&(e=r)}return e},Zo.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ue&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ue&&(e=r)}return e},Zo.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=e);)e=u=void 0;for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=e);)e=void 0;for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Zo.sum=function(n,t){var e,r=0,u=n.length,i=-1;if(1===arguments.length)for(;++i1&&(e=e.map(r)),e=e.filter(t),e.length?Zo.quantile(e.sort(n),.5):void 0};var ra=e(n);Zo.bisectLeft=ra.left,Zo.bisect=Zo.bisectRight=ra.right,Zo.bisector=function(t){return e(1===t.length?function(e,r){return n(t(e),r)}:t)},Zo.shuffle=function(n){for(var t,e,r=n.length;r;)e=0|Math.random()*r--,t=n[r],n[r]=n[e],n[e]=t;return n},Zo.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},Zo.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Zo.zip=function(){if(!(u=arguments.length))return[];for(var n=-1,t=Zo.min(arguments,r),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ua=Math.abs;Zo.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/e)throw new Error("infinite range");var r,i=[],o=u(ua(e)),a=-1;if(n*=o,t*=o,e*=o,0>e)for(;(r=n+e*++a)>t;)i.push(r/o);else for(;(r=n+e*++a)=i.length)return r?r.call(u,a):e?a.sort(e):a;for(var s,l,f,h,g=-1,p=a.length,v=i[c++],d=new o;++g=i.length)return n;var r=[],u=a[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],a=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(Zo.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return a[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},Zo.set=function(n){var t=new h;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},i(h,{has:a,add:function(n){return this[ia+n]=!0,n},remove:function(n){return n=ia+n,n in this&&delete this[n]},values:s,size:l,empty:f,forEach:function(n){for(var t in this)t.charCodeAt(0)===oa&&n.call(this,t.substring(1))}}),Zo.behavior={},Zo.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.substring(e+1),n=n.substring(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Zo.event=null,Zo.requote=function(n){return n.replace(ca,"\\$&")};var ca=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,sa={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},la=function(n,t){return t.querySelector(n)},fa=function(n,t){return t.querySelectorAll(n)},ha=Bo.matches||Bo[p(Bo,"matchesSelector")],ga=function(n,t){return ha.call(n,t)};"function"==typeof Sizzle&&(la=function(n,t){return Sizzle(n,t)[0]||null},fa=Sizzle,ga=Sizzle.matchesSelector),Zo.selection=function(){return ma};var pa=Zo.selection.prototype=[];pa.select=function(n){var t,e,r,u,i=[];n=b(n);for(var o=-1,a=this.length;++o=0&&(e=n.substring(0,t),n=n.substring(t+1)),va.hasOwnProperty(e)?{space:va[e],local:n}:n}},pa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Zo.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(S(t,n[t]));return this}return this.each(S(n,t))},pa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=A(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(z(e,n[e],t));return this}if(2>r)return Wo.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(z(n,t,e))},pa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(L(t,n[t]));return this}return this.each(L(n,t))},pa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},pa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},pa.append=function(n){return n=T(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},pa.insert=function(n,t){return n=T(n),t=b(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},pa.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},pa.data=function(n,t){function e(n,e){var r,u,i,a=n.length,f=e.length,h=Math.min(a,f),g=new Array(f),p=new Array(f),v=new Array(a);if(t){var d,m=new o,y=new o,x=[];for(r=-1;++rr;++r)p[r]=q(e[r]);for(;a>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),s.push(g),l.push(v)}var r,u,i=-1,a=this.length;if(!arguments.length){for(n=new Array(a=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return _(u)},pa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},pa.sort=function(n){n=D.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},pa.size=function(){var n=0;return this.each(function(){++n}),n};var da=[];Zo.selection.enter=U,Zo.selection.enter.prototype=da,da.append=pa.append,da.empty=pa.empty,da.node=pa.node,da.call=pa.call,da.size=pa.size,da.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(F(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(F(n,t,e))};var ya=Zo.map({mouseenter:"mouseover",mouseleave:"mouseout"});ya.forEach(function(n){"on"+n in $o&&ya.remove(n)});var xa="onselectstart"in $o?null:p(Bo.style,"userSelect"),Ma=0;Zo.mouse=function(n){return Z(n,x())};var _a=/WebKit/.test(Wo.navigator.userAgent)?-1:0;Zo.touches=function(n,t){return arguments.length<2&&(t=x().touches),t?Xo(t).map(function(t){var e=Z(n,t);return e.identifier=t.identifier,e}):[]},Zo.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",i)}function t(n,t,u,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-x[0],e=r[1]-x[1],p|=n|e,x=r,g({type:"drag",x:r[0]+s[0],y:r[1]+s[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&Zo.event.target===f),g({type:"dragend"}))}var s,l=this,f=Zo.event.target,h=l.parentNode,g=e.of(l,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=Zo.select(u()).on(i+d,a).on(o+d,c),y=I(),x=t(h,v);r?(s=r.apply(l,arguments),s=[s.x-x[0],s.y-x[1]]):s=[0,0],g({type:"dragstart"})}}var e=M(n,"drag","dragstart","dragend"),r=null,u=t(v,Zo.mouse,$,"mousemove","mouseup"),i=t(V,Zo.touch,X,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},Zo.rebind(n,e,"on")};var ba=Math.PI,wa=2*ba,Sa=ba/2,ka=1e-6,Ea=ka*ka,Aa=ba/180,Ca=180/ba,Na=Math.SQRT2,za=2,La=4;Zo.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=Q(v),o=i/(za*h)*(e*nt(Na*t+v)-K(v));return[r+o*s,u+o*l,i*e/Q(Na*t+v)]}return[r+n*s,u+n*l,i*Math.exp(Na*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],s=o-r,l=a-u,f=s*s+l*l,h=Math.sqrt(f),g=(c*c-i*i+La*f)/(2*i*za*h),p=(c*c-i*i-La*f)/(2*c*za*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/Na;return e.duration=1e3*y,e},Zo.behavior.zoom=function(){function n(n){n.on(A,s).on(Ra+".zoom",f).on("dblclick.zoom",h).on(z,l)}function t(n){return[(n[0]-S.x)/S.k,(n[1]-S.y)/S.k]}function e(n){return[n[0]*S.k+S.x,n[1]*S.k+S.y]}function r(n){S.k=Math.max(E[0],Math.min(E[1],n))}function u(n,t){t=e(t),S.x+=n[0]-t[0],S.y+=n[1]-t[1]}function i(){_&&_.domain(x.range().map(function(n){return(n-S.x)/S.k}).map(x.invert)),w&&w.domain(b.range().map(function(n){return(n-S.y)/S.k}).map(b.invert))}function o(n){n({type:"zoomstart"})}function a(n){i(),n({type:"zoom",scale:S.k,translate:[S.x,S.y]})}function c(n){n({type:"zoomend"})}function s(){function n(){l=1,u(Zo.mouse(r),h),a(s)}function e(){f.on(C,null).on(N,null),g(l&&Zo.event.target===i),c(s)}var r=this,i=Zo.event.target,s=L.of(r,arguments),l=0,f=Zo.select(Wo).on(C,n).on(N,e),h=t(Zo.mouse(r)),g=I();H.call(r),o(s)}function l(){function n(){var n=Zo.touches(g);return h=S.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=t(n))}),n}function e(){var t=Zo.event.target;Zo.select(t).on(M,i).on(_,f),b.push(t);for(var e=Zo.event.changedTouches,o=0,c=e.length;c>o;++o)v[e[o].identifier]=null;var s=n(),l=Date.now();if(1===s.length){if(500>l-m){var h=s[0],g=v[h.identifier];r(2*S.k),u(h,g),y(),a(p)}m=l}else if(s.length>1){var h=s[0],x=s[1],w=h[0]-x[0],k=h[1]-x[1];d=w*w+k*k}}function i(){for(var n,t,e,i,o=Zo.touches(g),c=0,s=o.length;s>c;++c,i=null)if(e=o[c],i=v[e.identifier]){if(t)break;n=e,t=i}if(i){var l=(l=e[0]-n[0])*l+(l=e[1]-n[1])*l,f=d&&Math.sqrt(l/d);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*h)}m=null,u(n,t),a(p)}function f(){if(Zo.event.touches.length){for(var t=Zo.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var u in v)return void n()}Zo.selectAll(b).on(x,null),w.on(A,s).on(z,l),k(),c(p)}var h,g=this,p=L.of(g,arguments),v={},d=0,x=".zoom-"+Zo.event.changedTouches[0].identifier,M="touchmove"+x,_="touchend"+x,b=[],w=Zo.select(g).on(A,null).on(z,e),k=I();H.call(g),e(),o(p)}function f(){var n=L.of(this,arguments);d?clearTimeout(d):(g=t(p=v||Zo.mouse(this)),H.call(this),o(n)),d=setTimeout(function(){d=null,c(n)},50),y(),r(Math.pow(2,.002*Ta())*S.k),u(p,g),a(n)}function h(){var n=L.of(this,arguments),e=Zo.mouse(this),i=t(e),s=Math.log(S.k)/Math.LN2;o(n),r(Math.pow(2,Zo.event.shiftKey?Math.ceil(s)-1:Math.floor(s)+1)),u(e,i),a(n),c(n)}var g,p,v,d,m,x,_,b,w,S={x:0,y:0,k:1},k=[960,500],E=qa,A="mousedown.zoom",C="mousemove.zoom",N="mouseup.zoom",z="touchstart.zoom",L=M(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=L.of(this,arguments),t=S;Ss?Zo.select(this).transition().each("start.zoom",function(){S=this.__chart__||{x:0,y:0,k:1},o(n)}).tween("zoom:zoom",function(){var e=k[0],r=k[1],u=e/2,i=r/2,o=Zo.interpolateZoom([(u-S.x)/S.k,(i-S.y)/S.k,e/S.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),c=e/r[2];this.__chart__=S={x:u-r[0]*c,y:i-r[1]*c,k:c},a(n)}}).each("end.zoom",function(){c(n)}):(this.__chart__=S,o(n),a(n),c(n))})},n.translate=function(t){return arguments.length?(S={x:+t[0],y:+t[1],k:S.k},i(),n):[S.x,S.y]},n.scale=function(t){return arguments.length?(S={x:S.x,y:S.y,k:+t},i(),n):S.k},n.scaleExtent=function(t){return arguments.length?(E=null==t?qa:[+t[0],+t[1]],n):E},n.center=function(t){return arguments.length?(v=t&&[+t[0],+t[1]],n):v},n.size=function(t){return arguments.length?(k=t&&[+t[0],+t[1]],n):k},n.x=function(t){return arguments.length?(_=t,x=t.copy(),S={x:0,y:0,k:1},n):_},n.y=function(t){return arguments.length?(w=t,b=t.copy(),S={x:0,y:0,k:1},n):w},Zo.rebind(n,L,"on")};var Ta,qa=[0,1/0],Ra="onwheel"in $o?(Ta=function(){return-Zo.event.deltaY*(Zo.event.deltaMode?120:1)},"wheel"):"onmousewheel"in $o?(Ta=function(){return Zo.event.wheelDelta},"mousewheel"):(Ta=function(){return-Zo.event.detail},"MozMousePixelScroll");Zo.color=et,et.prototype.toString=function(){return this.rgb()+""},Zo.hsl=rt;var Da=rt.prototype=new et;Da.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new rt(this.h,this.s,this.l/n)},Da.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new rt(this.h,this.s,n*this.l)},Da.rgb=function(){return ut(this.h,this.s,this.l)},Zo.hcl=it;var Pa=it.prototype=new et;Pa.brighter=function(n){return new it(this.h,this.c,Math.min(100,this.l+Ua*(arguments.length?n:1)))},Pa.darker=function(n){return new it(this.h,this.c,Math.max(0,this.l-Ua*(arguments.length?n:1)))},Pa.rgb=function(){return ot(this.h,this.c,this.l).rgb()},Zo.lab=at;var Ua=18,ja=.95047,Ha=1,Fa=1.08883,Oa=at.prototype=new et;Oa.brighter=function(n){return new at(Math.min(100,this.l+Ua*(arguments.length?n:1)),this.a,this.b)},Oa.darker=function(n){return new at(Math.max(0,this.l-Ua*(arguments.length?n:1)),this.a,this.b)},Oa.rgb=function(){return ct(this.l,this.a,this.b)},Zo.rgb=gt;var Ya=gt.prototype=new et;Ya.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new gt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new gt(u,u,u)},Ya.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new gt(n*this.r,n*this.g,n*this.b)},Ya.hsl=function(){return yt(this.r,this.g,this.b)},Ya.toString=function(){return"#"+dt(this.r)+dt(this.g)+dt(this.b)};var Ia=Zo.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Ia.forEach(function(n,t){Ia.set(n,pt(t))}),Zo.functor=bt,Zo.xhr=St(wt),Zo.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=kt(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(l>=s)return o;if(u)return u=!1,i;var t=l;if(34===n.charCodeAt(t)){for(var e=t;e++l;){var r=n.charCodeAt(l++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(l)&&(++l,++a);else if(r!==c)continue;return n.substring(t,l-a)}return n.substring(t)}for(var r,u,i={},o={},a=[],s=n.length,l=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();(!t||(h=t(h,f++)))&&a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new h,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},Zo.csv=Zo.dsv(",","text/csv"),Zo.tsv=Zo.dsv(" ","text/tab-separated-values"),Zo.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=x().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return Z(n,r)};var Za,Va,Xa,$a,Ba,Wa=Wo[p(Wo,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Zo.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};Va?Va.n=i:Za=i,Va=i,Xa||($a=clearTimeout($a),Xa=1,Wa(At))},Zo.timer.flush=function(){Ct(),Nt()},Zo.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var Ja=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Lt);Zo.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=Zo.round(n,zt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),Ja[8+e/3]};var Ga=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Ka=Zo.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Zo.round(n,zt(n,t))).toFixed(Math.max(0,Math.min(20,zt(n*(1+1e-15),t))))}}),Qa=Zo.time={},nc=Date;Rt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){tc.setUTCDate.apply(this._,arguments)},setDay:function(){tc.setUTCDay.apply(this._,arguments)},setFullYear:function(){tc.setUTCFullYear.apply(this._,arguments)},setHours:function(){tc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){tc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){tc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){tc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){tc.setUTCSeconds.apply(this._,arguments)},setTime:function(){tc.setTime.apply(this._,arguments)}};var tc=Date.prototype;Qa.year=Dt(function(n){return n=Qa.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),Qa.years=Qa.year.range,Qa.years.utc=Qa.year.utc.range,Qa.day=Dt(function(n){var t=new nc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),Qa.days=Qa.day.range,Qa.days.utc=Qa.day.utc.range,Qa.dayOfYear=function(n){var t=Qa.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=Qa[n]=Dt(function(n){return(n=Qa.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=Qa.year(n).getDay();return Math.floor((Qa.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});Qa[n+"s"]=e.range,Qa[n+"s"].utc=e.utc.range,Qa[n+"OfYear"]=function(n){var e=Qa.year(n).getDay();return Math.floor((Qa.dayOfYear(n)+(e+t)%7)/7)}}),Qa.week=Qa.sunday,Qa.weeks=Qa.sunday.range,Qa.weeks.utc=Qa.sunday.utc.range,Qa.weekOfYear=Qa.sundayOfYear;var ec={"-":"",_:" ",0:"0"},rc=/^\s*\d+/,uc=/^%/;Zo.locale=function(n){return{numberFormat:Tt(n),timeFormat:Ut(n)}};var ic=Zo.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});Zo.format=ic.numberFormat,Zo.geo={},ue.prototype={s:0,t:0,add:function(n){ie(n,this.t,oc),ie(oc.s,this.s,this),this.s?this.t+=oc.t:this.s=oc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var oc=new ue;Zo.geo.stream=function(n,t){n&&ac.hasOwnProperty(n.type)?ac[n.type](n,t):oe(n,t)};var ac={Feature:function(n,t){oe(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*ba+n:n,fc.lineStart=fc.lineEnd=fc.point=v}};Zo.geo.bounds=function(){function n(n,t){x.push(M=[l=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=le([t*Aa,e*Aa]);if(m){var u=he(m,r),i=[u[1],-u[0],0],o=he(i,u);ve(o),o=de(o);var c=t-p,s=c>0?1:-1,v=o[0]*Ca*s,d=ua(c)>180;if(d^(v>s*p&&s*t>v)){var y=o[1]*Ca;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>s*p&&s*t>v)){var y=-o[1]*Ca;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(l,t)>a(l,h)&&(h=t):a(t,h)>a(l,h)&&(l=t):h>=l?(l>t&&(l=t),t>h&&(h=t)):t>p?a(l,t)>a(l,h)&&(h=t):a(t,h)>a(l,h)&&(l=t)}else n(t,e);m=r,p=t}function e(){_.point=t}function r(){M[0]=l,M[1]=h,_.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=ua(r)>180?r+(r>0?360:-360):r}else v=n,d=e;fc.point(n,e),t(n,e)}function i(){fc.lineStart()}function o(){u(v,d),fc.lineEnd(),ua(y)>ka&&(l=-(h=180)),M[0]=l,M[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function s(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nlc?(l=-(h=180),f=-(g=90)):y>ka?g=90:-ka>y&&(f=-90),M[0]=l,M[1]=h}};return function(n){g=h=-(l=f=1/0),x=[],Zo.geo.stream(n,_);var t=x.length;if(t){x.sort(c);for(var e,r=1,u=x[0],i=[u];t>r;++r)e=x[r],s(e[0],u)||s(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e); -for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,l=e[0],h=u[1])}return x=M=null,1/0===l||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[l,f],[h,g]]}}(),Zo.geo.centroid=function(n){hc=gc=pc=vc=dc=mc=yc=xc=Mc=_c=bc=0,Zo.geo.stream(n,wc);var t=Mc,e=_c,r=bc,u=t*t+e*e+r*r;return Ea>u&&(t=mc,e=yc,r=xc,ka>gc&&(t=pc,e=vc,r=dc),u=t*t+e*e+r*r,Ea>u)?[0/0,0/0]:[Math.atan2(e,t)*Ca,G(r/Math.sqrt(u))*Ca]};var hc,gc,pc,vc,dc,mc,yc,xc,Mc,_c,bc,wc={sphere:v,point:ye,lineStart:Me,lineEnd:_e,polygonStart:function(){wc.lineStart=be},polygonEnd:function(){wc.lineStart=Me}},Sc=Ae(we,Te,Re,[-ba,-ba/2]),kc=1e9;Zo.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Ue(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(Zo.geo.conicEqualArea=function(){return He(Fe)}).raw=Fe,Zo.geo.albers=function(){return Zo.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},Zo.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=Zo.geo.albers(),o=Zo.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=Zo.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var s=i.scale(),l=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[l-.455*s,f-.238*s],[l+.455*s,f+.238*s]]).stream(c).point,r=o.translate([l-.307*s,f+.201*s]).clipExtent([[l-.425*s+ka,f+.12*s+ka],[l-.214*s-ka,f+.234*s-ka]]).stream(c).point,u=a.translate([l-.205*s,f+.212*s]).clipExtent([[l-.214*s+ka,f+.166*s+ka],[l-.115*s-ka,f+.234*s-ka]]).stream(c).point,n},n.scale(1070)};var Ec,Ac,Cc,Nc,zc,Lc,Tc={point:v,lineStart:v,lineEnd:v,polygonStart:function(){Ac=0,Tc.lineStart=Oe},polygonEnd:function(){Tc.lineStart=Tc.lineEnd=Tc.point=v,Ec+=ua(Ac/2)}},qc={point:Ye,lineStart:v,lineEnd:v,polygonStart:v,polygonEnd:v},Rc={point:Ve,lineStart:Xe,lineEnd:$e,polygonStart:function(){Rc.lineStart=Be},polygonEnd:function(){Rc.point=Ve,Rc.lineStart=Xe,Rc.lineEnd=$e}};Zo.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),Zo.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return Ec=0,Zo.geo.stream(n,u(Tc)),Ec},n.centroid=function(n){return pc=vc=dc=mc=yc=xc=Mc=_c=bc=0,Zo.geo.stream(n,u(Rc)),bc?[Mc/bc,_c/bc]:xc?[mc/xc,yc/xc]:dc?[pc/dc,vc/dc]:[0/0,0/0]},n.bounds=function(n){return zc=Lc=-(Cc=Nc=1/0),Zo.geo.stream(n,u(qc)),[[Cc,Nc],[zc,Lc]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||Ge(n):wt,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new Ie:new We(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(Zo.geo.albersUsa()).context(null)},Zo.geo.transform=function(n){return{stream:function(t){var e=new Ke(t);for(var r in n)e[r]=n[r];return e}}},Ke.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},Zo.geo.projection=nr,Zo.geo.projectionMutator=tr,(Zo.geo.equirectangular=function(){return nr(rr)}).raw=rr.invert=rr,Zo.geo.rotation=function(n){function t(t){return t=n(t[0]*Aa,t[1]*Aa),t[0]*=Ca,t[1]*=Ca,t}return n=ir(n[0]%360*Aa,n[1]*Aa,n.length>2?n[2]*Aa:0),t.invert=function(t){return t=n.invert(t[0]*Aa,t[1]*Aa),t[0]*=Ca,t[1]*=Ca,t},t},ur.invert=rr,Zo.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=ir(-n[0]*Aa,-n[1]*Aa,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Ca,n[1]*=Ca}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=sr((t=+r)*Aa,u*Aa),n):t},n.precision=function(r){return arguments.length?(e=sr(t*Aa,(u=+r)*Aa),n):u},n.angle(90)},Zo.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Aa,u=n[1]*Aa,i=t[1]*Aa,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),s=Math.cos(u),l=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=s*l-c*f*a)*e),c*l+s*f*a)},Zo.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return Zo.range(Math.ceil(i/d)*d,u,d).map(h).concat(Zo.range(Math.ceil(s/m)*m,c,m).map(g)).concat(Zo.range(Math.ceil(r/p)*p,e,p).filter(function(n){return ua(n%d)>ka}).map(l)).concat(Zo.range(Math.ceil(a/v)*v,o,v).filter(function(n){return ua(n%m)>ka}).map(f))}var e,r,u,i,o,a,c,s,l,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(s).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],s=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),s>c&&(t=s,s=c,c=t),n.precision(y)):[[i,s],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,l=fr(a,o,90),f=hr(r,e,y),h=fr(s,c,90),g=hr(i,u,y),n):y},n.majorExtent([[-180,-90+ka],[180,90-ka]]).minorExtent([[-180,-80-ka],[180,80+ka]])},Zo.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=gr,u=pr;return n.distance=function(){return Zo.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},Zo.geo.interpolate=function(n,t){return vr(n[0]*Aa,n[1]*Aa,t[0]*Aa,t[1]*Aa)},Zo.geo.length=function(n){return Dc=0,Zo.geo.stream(n,Pc),Dc};var Dc,Pc={sphere:v,point:v,lineStart:dr,lineEnd:v,polygonStart:v,polygonEnd:v},Uc=mr(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(Zo.geo.azimuthalEqualArea=function(){return nr(Uc)}).raw=Uc;var jc=mr(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},wt);(Zo.geo.azimuthalEquidistant=function(){return nr(jc)}).raw=jc,(Zo.geo.conicConformal=function(){return He(yr)}).raw=yr,(Zo.geo.conicEquidistant=function(){return He(xr)}).raw=xr;var Hc=mr(function(n){return 1/n},Math.atan);(Zo.geo.gnomonic=function(){return nr(Hc)}).raw=Hc,Mr.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Sa]},(Zo.geo.mercator=function(){return _r(Mr)}).raw=Mr;var Fc=mr(function(){return 1},Math.asin);(Zo.geo.orthographic=function(){return nr(Fc)}).raw=Fc;var Oc=mr(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(Zo.geo.stereographic=function(){return nr(Oc)}).raw=Oc,br.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Sa]},(Zo.geo.transverseMercator=function(){var n=_r(br),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=br,Zo.geom={},Zo.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=bt(e),i=bt(r),o=n.length,a=[],c=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(Er),t=0;o>t;t++)c.push([a[t][0],-a[t][1]]);var s=kr(a),l=kr(c),f=l[0]===s[0],h=l[l.length-1]===s[s.length-1],g=[];for(t=s.length-1;t>=0;--t)g.push(n[a[s[t]][2]]);for(t=+f;t=r&&s.x<=i&&s.y>=u&&s.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];l.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/ka)*ka,y:Math.round(o(n,t)/ka)*ka,i:t}})}var r=wr,u=Sr,i=r,o=u,a=Jc;return n?t(n):(t.links=function(n){return tu(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return tu(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(Hr),c=-1,s=a.length,l=a[s-1].edge,f=l.l===o?l.r:l.l;++c=s,h=r>=l,g=(h<<1)+f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=ou()),f?u=s:a=s,h?o=l:c=l,i(n,t,e,r,u,o,a,c)}var l,f,h,g,p,v,d,m,y,x=bt(a),M=bt(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)l=n[g],l.xm&&(m=l.x),l.y>y&&(y=l.y),f.push(l.x),h.push(l.y);else for(g=0;p>g;++g){var _=+x(l=n[g],g),b=+M(l,g);v>_&&(v=_),d>b&&(d=b),_>m&&(m=_),b>y&&(y=b),f.push(_),h.push(b)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=ou();if(k.add=function(n){i(k,n,+x(n,++g),+M(n,g),v,d,m,y)},k.visit=function(n){au(n,k,v,d,m,y)},g=-1,null==t){for(;++g=0?n.substring(0,t):n,r=t>=0?n.substring(t+1):"in";return e=ns.get(e)||Qc,r=ts.get(r)||wt,pu(r(e.apply(null,Vo.call(arguments,1))))},Zo.interpolateHcl=Au,Zo.interpolateHsl=Cu,Zo.interpolateLab=Nu,Zo.interpolateRound=zu,Zo.transform=function(n){var t=$o.createElementNS(Zo.ns.prefix.svg,"g");return(Zo.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Lu(e?e.matrix:es)})(n)},Lu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var es={a:1,b:0,c:0,d:1,e:0,f:0};Zo.interpolateTransform=Du,Zo.layout={},Zo.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var s=t.charge/c;n.px-=i*s,n.py-=o*s}return!0}if(t.point&&c&&p>c){var s=t.pointCharge/c;n.px-=i*s,n.py-=o*s}}return!t.charge}}function t(n){n.px=Zo.event.x,n.py=Zo.event.y,a.resume()}var e,r,u,i,o,a={},c=Zo.dispatch("start","tick","end"),s=[1,1],l=.9,f=rs,h=us,g=-30,p=is,v=.1,d=.64,m=[],y=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,x,M,_=m.length,b=y.length;for(e=0;b>e;++e)a=y[e],f=a.source,h=a.target,x=h.x-f.x,M=h.y-f.y,(p=x*x+M*M)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,x*=p,M*=p,h.x-=x*(d=f.weight/(h.weight+f.weight)),h.y-=M*d,f.x+=x*(d=1-d),f.y+=M*d);if((d=r*v)&&(x=s[0]/2,M=s[1]/2,e=-1,d))for(;++e<_;)a=m[e],a.x+=(x-a.x)*d,a.y+=(M-a.y)*d;if(g)for(Vu(t=Zo.geom.quadtree(m),r,o),e=-1;++e<_;)(a=m[e]).fixed||t.visit(n(a));for(e=-1;++e<_;)a=m[e],a.fixed?(a.x=a.px,a.y=a.py):(a.x-=(a.px-(a.px=a.x))*l,a.y-=(a.py-(a.py=a.y))*l);c.tick({type:"tick",alpha:r})},a.nodes=function(n){return arguments.length?(m=n,a):m},a.links=function(n){return arguments.length?(y=n,a):y},a.size=function(n){return arguments.length?(s=n,a):s},a.linkDistance=function(n){return arguments.length?(f="function"==typeof n?n:+n,a):f},a.distance=a.linkDistance,a.linkStrength=function(n){return arguments.length?(h="function"==typeof n?n:+n,a):h},a.friction=function(n){return arguments.length?(l=+n,a):l},a.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,a):g},a.chargeDistance=function(n){return arguments.length?(p=n*n,a):Math.sqrt(p)},a.gravity=function(n){return arguments.length?(v=+n,a):v},a.theta=function(n){return arguments.length?(d=n*n,a):Math.sqrt(d)},a.alpha=function(n){return arguments.length?(n=+n,r?r=n>0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),Zo.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;s>a;++a){var u=y[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,s=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;l>t;++t)r=y[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;l>t;++t)u[t]=+f.call(this,y[t],t);else for(t=0;l>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;l>t;++t)i[t]=+h.call(this,y[t],t);else for(t=0;l>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=Zo.behavior.drag().origin(wt).on("dragstart.force",Ou).on("drag.force",t).on("dragend.force",Yu)),arguments.length?(this.on("mouseover.force",Iu).on("mouseout.force",Zu).call(e),void 0):e},Zo.rebind(a,c,"on")};var rs=20,us=1,is=1/0;Zo.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(s=e.call(n,i,i.depth))&&(c=s.length)){for(var c,s,l;--c>=0;)o.push(l=s[c]),l.parent=i,l.depth=i.depth+1;r&&(i.value=0),i.children=s}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Bu(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=Gu,e=Wu,r=Ju;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&($u(t,function(n){n.children&&(n.value=0)}),Bu(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},Zo.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,s=-1;for(r=t.value?r/t.value:0;++sg;++g)for(u.call(n,s[0][g],p=v[g],l[0][g][1]),h=1;d>h;++h)u.call(n,s[h][g],p+=l[h-1][g][1],l[h][g][1]);return a}var t=wt,e=ei,r=ri,u=ti,i=Qu,o=ni;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:as.get(t)||ei,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:cs.get(t)||ri,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var as=Zo.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(ui),i=n.map(ii),o=Zo.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,s=[],l=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],s.push(e)):(c+=i[e],l.push(e));return l.reverse().concat(s)},reverse:function(n){return Zo.range(n.length).reverse()},"default":ei}),cs=Zo.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,s,l=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=s=0,e=1;h>e;++e){for(t=0,u=0;l>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];l>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,s>c&&(s=c)}for(e=0;h>e;++e)g[e]-=s;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ri});Zo.layout.histogram=function(){function n(n,i){for(var o,a,c=[],s=n.map(e,this),l=r.call(this,s,i),f=u.call(this,l,s,i),i=-1,h=s.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=l[0]&&a<=l[1]&&(o=c[Zo.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=si,u=ai;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=bt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return ci(n,t)}:bt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},Zo.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],s=u[1],l=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Bu(a,function(n){n.r=+l(n.value)}),Bu(a,pi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/s))/2;Bu(a,function(n){n.r+=f}),Bu(a,pi),Bu(a,function(n){n.r-=f})}return mi(a,c/2,s/2,t?1:1/Math.max(2*a.r/c,2*a.r/s)),o}var t,e=Zo.layout.hierarchy().sort(li),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Xu(n,e)},Zo.layout.tree=function(){function n(n,u){var l=o.call(this,n,u),f=l[0],h=t(f);if(Bu(h,e),h.parent.m=-h.z,$u(h,r),s)$u(f,i);else{var g=f,p=f,v=f;$u(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);$u(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return l}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){wi(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],s=u.m,l=i.m,f=o.m,h=c.m;o=_i(o),u=Mi(u),o&&u;)c=Mi(c),i=_i(i),i.a=n,r=o.z+f-u.z-s+a(o._,u._),r>0&&(bi(Si(o,n,e),n,r),s+=r,l+=r),f+=o.m,s+=u.m,h+=c.m,l+=i.m;o&&!_i(i)&&(i.t=o,i.m+=f-l),u&&!Mi(c)&&(c.t=u,c.m+=s-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=Zo.layout.hierarchy().sort(null).value(null),a=xi,c=[1,1],s=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(s=null==(c=t)?i:null,n):s?null:c},n.nodeSize=function(t){return arguments.length?(s=null==(c=t)?null:i,n):s?c:null},Xu(n,o)},Zo.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],s=0;Bu(c,function(n){var t=n.children;t&&t.length?(n.x=Ei(t),n.y=ki(t)):(n.x=o?s+=e(n,o):0,n.y=0,o=n)});var l=Ai(c),f=Ci(c),h=l.x-e(l,f)/2,g=f.x+e(f,l)/2;return Bu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=Zo.layout.hierarchy().sort(null).value(null),e=xi,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Xu(n,t)},Zo.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,s=f(e),l=[],h=i.slice(),p=1/0,v="slice"===g?s.dx:"dice"===g?s.dy:"slice-dice"===g?1&e.depth?s.dy:s.dx:Math.min(s.dx,s.dy);for(n(h,s.dx*s.dy/e.value),l.area=0;(c=h.length)>0;)l.push(o=h[c-1]),l.area+=o.area,"squarify"!==g||(a=r(l,v))<=p?(h.pop(),p=a):(l.area-=l.pop().area,u(l,v,s,!1),v=Math.min(s.dx,s.dy),l.length=l.area=0,p=1/0);l.length&&(u(l,v,s,!0),l.length=l.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,s=e.y,l=t?c(n.area/t):0;if(t==e.dx){for((r||l>e.dy)&&(l=e.dy);++ie.dx)&&(l=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=Zo.random.normal.apply(Zo,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=Zo.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},Zo.scale={};var ss={floor:wt,ceil:wt};Zo.scale.linear=function(){return Ui([0,1],[0,1],hu,!1)};var ls={s:1,g:1,p:1,r:1,e:1};Zo.scale.log=function(){return Vi(Zo.scale.linear().domain([0,1]),10,!0,[1,10])};var fs=Zo.format(".0e"),hs={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};Zo.scale.pow=function(){return Xi(Zo.scale.linear(),1,[0,1])},Zo.scale.sqrt=function(){return Zo.scale.pow().exponent(.5)},Zo.scale.ordinal=function(){return Bi([],{t:"range",a:[[]]})},Zo.scale.category10=function(){return Zo.scale.ordinal().range(gs)},Zo.scale.category20=function(){return Zo.scale.ordinal().range(ps)},Zo.scale.category20b=function(){return Zo.scale.ordinal().range(vs)},Zo.scale.category20c=function(){return Zo.scale.ordinal().range(ds)};var gs=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(vt),ps=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(vt),vs=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(vt),ds=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(vt);Zo.scale.quantile=function(){return Wi([],[])},Zo.scale.quantize=function(){return Ji(0,1,[0,1])},Zo.scale.threshold=function(){return Gi([.5],[0,1])},Zo.scale.identity=function(){return Ki([0,1])},Zo.svg={},Zo.svg.arc=function(){function n(){var n=t.apply(this,arguments),i=e.apply(this,arguments),o=r.apply(this,arguments)+ms,a=u.apply(this,arguments)+ms,c=(o>a&&(c=o,o=a,a=c),a-o),s=ba>c?"0":"1",l=Math.cos(o),f=Math.sin(o),h=Math.cos(a),g=Math.sin(a); -return c>=ys?n?"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z":n?"M"+i*l+","+i*f+"A"+i+","+i+" 0 "+s+",1 "+i*h+","+i*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+s+",0 "+n*l+","+n*f+"Z":"M"+i*l+","+i*f+"A"+i+","+i+" 0 "+s+",1 "+i*h+","+i*g+"L0,0"+"Z"}var t=Qi,e=no,r=to,u=eo;return n.innerRadius=function(e){return arguments.length?(t=bt(e),n):t},n.outerRadius=function(t){return arguments.length?(e=bt(t),n):e},n.startAngle=function(t){return arguments.length?(r=bt(t),n):r},n.endAngle=function(t){return arguments.length?(u=bt(t),n):u},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,i=(r.apply(this,arguments)+u.apply(this,arguments))/2+ms;return[Math.cos(i)*n,Math.sin(i)*n]},n};var ms=-Sa,ys=wa-ka;Zo.svg.line=function(){return ro(wt)};var xs=Zo.map({linear:uo,"linear-closed":io,step:oo,"step-before":ao,"step-after":co,basis:po,"basis-open":vo,"basis-closed":mo,bundle:yo,cardinal:fo,"cardinal-open":so,"cardinal-closed":lo,monotone:So});xs.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Ms=[0,2/3,1/3,0],_s=[0,1/3,2/3,0],bs=[0,1/6,2/3,1/6];Zo.svg.line.radial=function(){var n=ro(ko);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},ao.reverse=co,co.reverse=ao,Zo.svg.area=function(){return Eo(wt)},Zo.svg.area.radial=function(){var n=Eo(ko);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},Zo.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),s=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,s)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,s.r,s.p0)+r(s.r,s.p1,s.a1-s.a0)+u(s.r,s.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)+ms,l=s.call(n,u,r)+ms;return{r:i,a0:o,a1:l,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(l),i*Math.sin(l)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>ba)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=gr,o=pr,a=Ao,c=to,s=eo;return n.radius=function(t){return arguments.length?(a=bt(t),n):a},n.source=function(t){return arguments.length?(i=bt(t),n):i},n.target=function(t){return arguments.length?(o=bt(t),n):o},n.startAngle=function(t){return arguments.length?(c=bt(t),n):c},n.endAngle=function(t){return arguments.length?(s=bt(t),n):s},n},Zo.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=gr,e=pr,r=Co;return n.source=function(e){return arguments.length?(t=bt(e),n):t},n.target=function(t){return arguments.length?(e=bt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},Zo.svg.diagonal.radial=function(){var n=Zo.svg.diagonal(),t=Co,e=n.projection;return n.projection=function(n){return arguments.length?e(No(t=n)):t},n},Zo.svg.symbol=function(){function n(n,r){return(ws.get(t.call(this,n,r))||To)(e.call(this,n,r))}var t=Lo,e=zo;return n.type=function(e){return arguments.length?(t=bt(e),n):t},n.size=function(t){return arguments.length?(e=bt(t),n):e},n};var ws=Zo.map({circle:To,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*As)),e=t*As;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Es),e=t*Es/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Es),e=t*Es/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});Zo.svg.symbolTypes=ws.keys();var Ss,ks,Es=Math.sqrt(3),As=Math.tan(30*Aa),Cs=[],Ns=0;Cs.call=pa.call,Cs.empty=pa.empty,Cs.node=pa.node,Cs.size=pa.size,Zo.transition=function(n){return arguments.length?Ss?n.transition():n:ma.transition()},Zo.transition.prototype=Cs,Cs.select=function(n){var t,e,r,u=this.id,i=[];n=b(n);for(var o=-1,a=this.length;++oi;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return qo(u,this.id)},Cs.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):P(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},Cs.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Du:hu,a=Zo.ns.qualify(n);return Ro(this,"attr."+n,t,a.local?i:u)},Cs.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=Zo.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Cs.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=Wo.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=hu(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return Ro(this,"style."+n,t,u)},Cs.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,Wo.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Cs.text=function(n){return Ro(this,"text",n,Do)},Cs.remove=function(){return this.each("end.transition",function(){var n;this.__transition__.count<2&&(n=this.parentNode)&&n.removeChild(this)})},Cs.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=Zo.ease.apply(Zo,arguments)),P(this,function(e){e.__transition__[t].ease=n}))},Cs.delay=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].delay:P(this,"function"==typeof n?function(e,r,u){e.__transition__[t].delay=+n.call(e,e.__data__,r,u)}:(n=+n,function(e){e.__transition__[t].delay=n}))},Cs.duration=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].duration:P(this,"function"==typeof n?function(e,r,u){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,u))}:(n=Math.max(1,n),function(e){e.__transition__[t].duration=n}))},Cs.each=function(n,t){var e=this.id;if(arguments.length<2){var r=ks,u=Ss;Ss=e,P(this,function(t,r,u){ks=t.__transition__[e],n.call(t,t.__data__,r,u)}),ks=r,Ss=u}else P(this,function(r){var u=r.__transition__[e];(u.event||(u.event=Zo.dispatch("start","end"))).on(n,t)});return this},Cs.transition=function(){for(var n,t,e,r,u=this.id,i=++Ns,o=[],a=0,c=this.length;c>a;a++){o.push(n=[]);for(var t=this[a],s=0,l=t.length;l>s;s++)(e=t[s])&&(r=Object.create(e.__transition__[u]),r.delay+=r.duration,Po(e,s,i,r)),n.push(e)}return qo(o,i)},Zo.svg.axis=function(){function n(n){n.each(function(){var n,s=Zo.select(this),l=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):wt:t,p=s.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",ka),d=Zo.transition(p.exit()).style("opacity",ka).remove(),m=Zo.transition(p.order()).style("opacity",1),y=Ti(f),x=s.selectAll(".domain").data([0]),M=(x.enter().append("path").attr("class","domain"),Zo.transition(x));v.append("line"),v.append("text");var _=v.select("line"),b=m.select("line"),w=p.select("text").text(g),S=v.select("text"),k=m.select("text");switch(r){case"bottom":n=Uo,_.attr("y2",u),S.attr("y",Math.max(u,0)+o),b.attr("x2",0).attr("y2",u),k.attr("x",0).attr("y",Math.max(u,0)+o),w.attr("dy",".71em").style("text-anchor","middle"),M.attr("d","M"+y[0]+","+i+"V0H"+y[1]+"V"+i);break;case"top":n=Uo,_.attr("y2",-u),S.attr("y",-(Math.max(u,0)+o)),b.attr("x2",0).attr("y2",-u),k.attr("x",0).attr("y",-(Math.max(u,0)+o)),w.attr("dy","0em").style("text-anchor","middle"),M.attr("d","M"+y[0]+","+-i+"V0H"+y[1]+"V"+-i);break;case"left":n=jo,_.attr("x2",-u),S.attr("x",-(Math.max(u,0)+o)),b.attr("x2",-u).attr("y2",0),k.attr("x",-(Math.max(u,0)+o)).attr("y",0),w.attr("dy",".32em").style("text-anchor","end"),M.attr("d","M"+-i+","+y[0]+"H0V"+y[1]+"H"+-i);break;case"right":n=jo,_.attr("x2",u),S.attr("x",Math.max(u,0)+o),b.attr("x2",u).attr("y2",0),k.attr("x",Math.max(u,0)+o).attr("y",0),w.attr("dy",".32em").style("text-anchor","start"),M.attr("d","M"+i+","+y[0]+"H0V"+y[1]+"H"+i)}if(f.rangeBand){var E=f,A=E.rangeBand()/2;l=f=function(n){return E(n)+A}}else l.rangeBand?l=f:d.call(n,f);v.call(n,l),m.call(n,f)})}var t,e=Zo.scale.linear(),r=zs,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Ls?t+"":zs,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var zs="bottom",Ls={top:1,right:1,bottom:1,left:1};Zo.svg.brush=function(){function n(i){i.each(function(){var i=Zo.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(p,wt);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Ts[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,f=Zo.transition(i),h=Zo.transition(o);c&&(l=Ti(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),e(f)),s&&(l=Ti(s),h.attr("y",l[0]).attr("height",l[1]-l[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+l[+/e$/.test(n)]+","+f[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",l[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",l[1]-l[0])}function r(n){n.select(".extent").attr("y",f[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function u(){function u(){32==Zo.event.keyCode&&(C||(x=null,z[0]-=l[1],z[1]-=f[1],C=2),y())}function p(){32==Zo.event.keyCode&&2==C&&(z[0]+=l[1],z[1]+=f[1],C=0,y())}function v(){var n=Zo.mouse(_),u=!1;M&&(n[0]+=M[0],n[1]+=M[1]),C||(Zo.event.altKey?(x||(x=[(l[0]+l[1])/2,(f[0]+f[1])/2]),z[0]=l[+(n[0]p?(u=r,r=p):u=p),v[0]!=r||v[1]!=u?(e?o=null:i=null,v[0]=r,v[1]=u,!0):void 0}function m(){v(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),Zo.select("body").style("cursor",null),L.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),N(),w({type:"brushend"})}var x,M,_=this,b=Zo.select(Zo.event.target),w=a.of(_,arguments),S=Zo.select(_),k=b.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&s,C=b.classed("extent"),N=I(),z=Zo.mouse(_),L=Zo.select(Wo).on("keydown.brush",u).on("keyup.brush",p);if(Zo.event.changedTouches?L.on("touchmove.brush",v).on("touchend.brush",m):L.on("mousemove.brush",v).on("mouseup.brush",m),S.interrupt().selectAll("*").interrupt(),C)z[0]=l[0]-z[0],z[1]=f[0]-z[1];else if(k){var T=+/w$/.test(k),q=+/^n/.test(k);M=[l[1-T]-z[0],f[1-q]-z[1]],z[0]=l[T],z[1]=f[q]}else Zo.event.altKey&&(x=z.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),Zo.select("body").style("cursor",b.style("cursor")),w({type:"brushstart"}),v()}var i,o,a=M(n,"brushstart","brush","brushend"),c=null,s=null,l=[0,0],f=[0,0],h=!0,g=!0,p=qs[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:l,y:f,i:i,j:o},e=this.__chart__||t;this.__chart__=t,Ss?Zo.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,l=e.x,f=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=gu(l,t.x),r=gu(f,t.y);return i=o=null,function(u){l=t.x=e(u),f=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,p=qs[!c<<1|!s],n):c},n.y=function(t){return arguments.length?(s=t,p=qs[!c<<1|!s],n):s},n.clamp=function(t){return arguments.length?(c&&s?(h=!!t[0],g=!!t[1]):c?h=!!t:s&&(g=!!t),n):c&&s?[h,g]:c?h:s?g:null},n.extent=function(t){var e,r,u,a,h;return arguments.length?(c&&(e=t[0],r=t[1],s&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(h=e,e=r,r=h),(e!=l[0]||r!=l[1])&&(l=[e,r])),s&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],s.invert&&(u=s(u),a=s(a)),u>a&&(h=u,u=a,a=h),(u!=f[0]||a!=f[1])&&(f=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=l[0],r=l[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(h=e,e=r,r=h))),s&&(o?(u=o[0],a=o[1]):(u=f[0],a=f[1],s.invert&&(u=s.invert(u),a=s.invert(a)),u>a&&(h=u,u=a,a=h))),c&&s?[[e,u],[r,a]]:c?[e,r]:s&&[u,a])},n.clear=function(){return n.empty()||(l=[0,0],f=[0,0],i=o=null),n},n.empty=function(){return!!c&&l[0]==l[1]||!!s&&f[0]==f[1]},Zo.rebind(n,a,"on")};var Ts={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},qs=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Rs=Qa.format=ic.timeFormat,Ds=Rs.utc,Ps=Ds("%Y-%m-%dT%H:%M:%S.%LZ");Rs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ho:Ps,Ho.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Ho.toString=Ps.toString,Qa.second=Dt(function(n){return new nc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Qa.seconds=Qa.second.range,Qa.seconds.utc=Qa.second.utc.range,Qa.minute=Dt(function(n){return new nc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Qa.minutes=Qa.minute.range,Qa.minutes.utc=Qa.minute.utc.range,Qa.hour=Dt(function(n){var t=n.getTimezoneOffset()/60;return new nc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Qa.hours=Qa.hour.range,Qa.hours.utc=Qa.hour.utc.range,Qa.month=Dt(function(n){return n=Qa.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Qa.months=Qa.month.range,Qa.months.utc=Qa.month.utc.range;var Us=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],js=[[Qa.second,1],[Qa.second,5],[Qa.second,15],[Qa.second,30],[Qa.minute,1],[Qa.minute,5],[Qa.minute,15],[Qa.minute,30],[Qa.hour,1],[Qa.hour,3],[Qa.hour,6],[Qa.hour,12],[Qa.day,1],[Qa.day,2],[Qa.week,1],[Qa.month,1],[Qa.month,3],[Qa.year,1]],Hs=Rs.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",we]]),Fs={range:function(n,t,e){return Zo.range(Math.ceil(n/e)*e,+t,e).map(Oo)},floor:wt,ceil:wt};js.year=Qa.year,Qa.scale=function(){return Fo(Zo.scale.linear(),js,Hs)};var Os=js.map(function(n){return[n[0].utc,n[1]]}),Ys=Ds.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",we]]);Os.year=Qa.year.utc,Qa.scale.utc=function(){return Fo(Zo.scale.linear(),Os,Ys)},Zo.text=St(function(n){return n.responseText}),Zo.json=function(n,t){return kt(n,"application/json",Yo,t)},Zo.html=function(n,t){return kt(n,"text/html",Io,t)},Zo.xml=St(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(Zo):"object"==typeof module&&module.exports&&(module.exports=Zo),this.d3=Zo}(); \ No newline at end of file +!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===la||n[0]===sa?sa+n:n}function l(n){return(n+="")[0]===sa?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object.create(null)}function d(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function m(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=fa.length;r>e;++e){var u=fa[e]+t;if(u in n)return u}}function y(){}function x(){}function M(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function H(n){return ga(n,Ma),n}function O(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var l=ba.get(n);return l&&(n=l,c=V),a?t?u:r:t?y:i}function Z(n,t){return function(e){var r=Bo.event;Bo.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Bo.event=r}}}function V(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function X(){var n=".dragsuppress-"+ ++Sa,t="click"+n,e=Bo.select(Qo).on("touchmove"+n,_).on("dragstart"+n,_).on("selectstart"+n,_);if(wa){var r=Ko.style,u=r[wa];r[wa]="none"}return function(i){function o(){e.on(t,null)}e.on(n,null),wa&&(r[wa]=u),i&&(e.on(t,function(){_(),o()},!0),setTimeout(o,0))}}function $(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>ka&&(Qo.scrollX||Qo.scrollY)){e=Bo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();ka=!(u.f||u.e),e.remove()}return ka?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function B(){return Bo.event.changedTouches[0].identifier}function W(){return Bo.event.target}function J(){return Qo}function G(n){return n>0?1:0>n?-1:0}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?0:-1>n?Ea:Math.acos(n)}function nt(n){return n>1?Ca:-1>n?-Ca:Math.asin(n)}function tt(n){return((n=Math.exp(n))-1/n)/2}function et(n){return((n=Math.exp(n))+1/n)/2}function rt(n){return((n=Math.exp(2*n))-1)/(n+1)}function ut(n){return(n=Math.sin(n/2))*n}function it(){}function ot(n,t,e){return this instanceof ot?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ot?new ot(n.h,n.s,n.l):Mt(""+n,_t,ot):new ot(n,t,e)}function at(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dt(u(n+120),u(n),u(n-120))}function ct(n,t,e){return this instanceof ct?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof ct?new ct(n.h,n.c,n.l):n instanceof st?ht(n.l,n.a,n.b):ht((n=bt((n=Bo.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new ct(n,t,e)}function lt(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new st(e,Math.cos(n*=La)*t,Math.sin(n)*t)}function st(n,t,e){return this instanceof st?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof st?new st(n.l,n.a,n.b):n instanceof ct?lt(n.h,n.c,n.l):bt((n=dt(n)).r,n.g,n.b):new st(n,t,e)}function ft(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=gt(u)*Ya,r=gt(r)*Ia,i=gt(i)*Za,new dt(vt(3.2404542*u-1.5371385*r-.4985314*i),vt(-.969266*u+1.8760108*r+.041556*i),vt(.0556434*u-.2040259*r+1.0572252*i))}function ht(n,t,e){return n>0?new ct(Math.atan2(e,t)*Ta,Math.sqrt(t*t+e*e),n):new ct(0/0,0/0,n)}function gt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function pt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function vt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dt(n,t,e){return this instanceof dt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dt?new dt(n.r,n.g,n.b):Mt(""+n,dt,at):new dt(n,t,e)}function mt(n){return new dt(n>>16,255&n>>8,255&n)}function yt(n){return mt(n)+""}function xt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function Mt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(St(u[0]),St(u[1]),St(u[2]))}return(i=$a.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function _t(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new ot(r,u,c)}function bt(n,t,e){n=wt(n),t=wt(t),e=wt(e);var r=pt((.4124564*n+.3575761*t+.1804375*e)/Ya),u=pt((.2126729*n+.7151522*t+.072175*e)/Ia),i=pt((.0193339*n+.119192*t+.9503041*e)/Za);return st(116*u-16,500*(r-u),200*(u-i))}function wt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function St(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kt(n){return"function"==typeof n?n:function(){return n}}function Et(n){return n}function At(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Ct(t,e,n,r)}}function Ct(n,t,e,r){function u(){var n,t=c.status;if(!t&&zt(c)||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=Bo.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,l=null;return!Qo.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=Bo.event;Bo.event=n;try{o.progress.call(i,c)}finally{Bo.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(l=n,i):l},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Jo(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var s in a)c.setRequestHeader(s,a[s]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},Bo.rebind(i,o,"on"),null==r?i:i.get(Nt(r))}function Nt(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zt(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function Lt(){var n=Tt(),t=qt()-n;t>24?(isFinite(t)&&(clearTimeout(Ga),Ga=setTimeout(Lt,t)),Ja=0):(Ja=1,Qa(Lt))}function Tt(){var n=Date.now();for(Ka=Ba;Ka;)n>=Ka.t&&(Ka.f=Ka.c(n-Ka.t)),Ka=Ka.n;return n}function qt(){for(var n,t=Ba,e=1/0;t;)t.f?t=n?n.n=t.n:Ba=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Pt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],c=0;u>0&&a>0&&(c+a+1>t&&(a=Math.max(1,t-c)),i.push(n.substring(u-=a,u+a)),!((c+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:Et;return function(n){var e=tc.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",c=e[4]||"",l=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(l||"0"===r&&"="===o)&&(l=r="0",o="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=ec.get(g)||Ut;var x=l&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var c=Bo.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var M,_,b=n.lastIndexOf(".");if(0>b){var w=y?n.lastIndexOf("e"):-1;0>w?(M=n,_=""):(M=n.substring(0,w),_=n.substring(w))}else M=n.substring(0,b),_=t+n.substring(b+1);!l&&f&&(M=i(M,1/0));var S=v.length+M.length+_.length+(x?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return x&&(M=i(k+M,k.length?s-_.length:1/0)),u+=v,n=M+_,("<"===o?u+n+k:">"===o?k+u+n:"^"===o?k.substring(0,S>>=1)+u+n+k.substring(S):u+(x?n:k+n))+e}}}function Ut(n){return n+""}function jt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ft(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new uc(e-1)),1),e}function i(n,e){return t(n=new uc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{uc=jt;var r=new jt;return r._=n,o(r,t,e)}finally{uc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Ht(n);return c.floor=c,c.round=Ht(r),c.ceil=Ht(u),c.offset=Ht(i),c.range=a,n}function Ht(n){return function(t,e){try{uc=jt;var r=new jt;return r._=t,n(r,e)._}finally{uc=Date}}}function Ot(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=l)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=N[o in oc?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){b.lastIndex=0;var r=b.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){M.lastIndex=0;var r=M.exec(t.slice(e));return r?(n.w=_.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.slice(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,C.c.toString(),t,r)}function c(n,t,r){return e(n,C.x.toString(),t,r)}function l(n,t,r){return e(n,C.X.toString(),t,r)}function s(n,t,e){var r=x.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{uc=jt;var t=new uc;return t._=n,r(t)}finally{uc=Date}}var r=t(n);return e.parse=function(n){try{uc=jt;var t=r.parse(n);return t&&t._}finally{uc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ae;var x=Bo.map(),M=It(v),_=Zt(v),b=It(d),w=Zt(d),S=It(m),k=Zt(m),E=It(y),A=Zt(y);p.forEach(function(n,t){x.set(n.toLowerCase(),t)});var C={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return Yt(n.getDate(),t,2)},e:function(n,t){return Yt(n.getDate(),t,2)},H:function(n,t){return Yt(n.getHours(),t,2)},I:function(n,t){return Yt(n.getHours()%12||12,t,2)},j:function(n,t){return Yt(1+rc.dayOfYear(n),t,3)},L:function(n,t){return Yt(n.getMilliseconds(),t,3)},m:function(n,t){return Yt(n.getMonth()+1,t,2)},M:function(n,t){return Yt(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return Yt(n.getSeconds(),t,2)},U:function(n,t){return Yt(rc.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Yt(rc.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return Yt(n.getFullYear()%100,t,2)},Y:function(n,t){return Yt(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},N={a:r,A:u,b:i,B:o,c:a,d:Qt,e:Qt,H:te,I:te,j:ne,L:ue,m:Kt,M:ee,p:s,S:re,U:Xt,w:Vt,W:$t,x:c,X:l,y:Wt,Y:Bt,Z:Jt,"%":oe};return t}function Yt(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function It(n){return new RegExp("^(?:"+n.map(Bo.requote).join("|")+")","i")}function Zt(n){for(var t=new a,e=-1,r=n.length;++e68?1900:2e3)}function Kt(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Qt(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function ne(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function te(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ee(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function re(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ue(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=0|ca(t)/60,u=ca(t)%60;return e+Yt(r,"0",2)+Yt(u,"0",2)}function oe(n,t,e){cc.lastIndex=0;var r=cc.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ae(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),l=Math.sin(t),s=i*l,f=u*c+s*Math.cos(a),h=s*o*Math.sin(a);pc.add(Math.atan2(h,f)),r=n,u=c,i=l}var t,e,r,u,i;vc.point=function(o,a){vc.point=n,r=(t=o)*La,u=Math.cos(a=(e=a)*La/2+Ea/4),i=Math.sin(a)},vc.lineEnd=function(){n(t,e)}}function pe(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ve(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function de(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function me(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function ye(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function xe(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function Me(n){return[Math.atan2(n[1],n[0]),nt(n[2])]}function _e(n,t){return ca(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new ze(e,n,null,!0),l=new ze(e,null,c,!1);c.o=l,i.push(c),o.push(l),c=new ze(r,n,null,!1),l=new ze(r,null,c,!0),c.o=l,i.push(c),o.push(l)}}),o.sort(t),Ne(i),Ne(o),i.length){for(var a=0,c=e,l=o.length;l>a;++a)o[a].e=c=!c;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,l=s.length;l>a;++a)u.point((f=s[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var a=s.length-1;a>=0;--a)u.point((f=s[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function Ne(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(_||(i.polygonStart(),_=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Te))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:l,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=l,g=Bo.merge(g);var n=je(m,p);g.length?(_||(i.polygonStart(),_=!0),Ce(g,Re,n,e,i)):n&&(_||(i.polygonStart(),_=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),_&&(i.polygonEnd(),_=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},x=qe(),M=t(x),_=!1;return y}}function Te(n){return n.length>1}function qe(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:y,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Re(n,t){return((n=n.x)[0]<0?n[1]-Ca-Na:Ca-n[1])-((t=t.x)[0]<0?t[1]-Ca-Na:Ca-t[1])}function De(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?Ea:-Ea,c=ca(i-e);ca(c-Ea)0?Ca:-Ca),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=Ea&&(ca(e-u)Na?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function Ue(n,t,e,r){var u;if(null==n)u=e*Ca,r.point(-Ea,u),r.point(0,u),r.point(Ea,u),r.point(Ea,0),r.point(Ea,-u),r.point(0,-u),r.point(-Ea,-u),r.point(-Ea,0),r.point(-Ea,u);else if(ca(n[0]-t[0])>Na){var i=n[0]a;++a){var l=t[a],s=l.length;if(s)for(var f=l[0],h=f[0],g=f[1]/2+Ea/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=l[d];var m=n[0],y=n[1]/2+Ea/4,x=Math.sin(y),M=Math.cos(y),_=m-h,b=_>=0?1:-1,w=b*_,S=w>Ea,k=p*x;if(pc.add(Math.atan2(k*b*Math.sin(w),v*M+k*Math.cos(w))),i+=S?_+b*Aa:_,S^h>=e^m>=e){var E=de(pe(f),pe(n));xe(E);var A=de(u,E);xe(A);var C=(S^_>=0?-1:1)*nt(A[2]);(r>C||r===C&&(E[0]||E[1]))&&(o+=S^_>=0?1:-1)}if(!d++)break;h=m,p=x,v=M,f=n}}return(-Na>i||Na>i&&0>pc)^1&o}function Fe(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,c,l,s;return{lineStart:function(){l=c=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?Ea:-Ea),h):0;if(!e&&(l=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(_e(e,g)||_e(p,g))&&(p[0]+=Na,p[1]+=Na,v=t(p[0],p[1]))),v!==c)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(s=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&_e(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return s|(l&&c)<<1}}}function r(n,t,e){var r=pe(n),u=pe(t),o=[1,0,0],a=de(r,u),c=ve(a,a),l=a[0],s=c-l*l;if(!s)return!e&&n;var f=i*c/s,h=-i*l/s,g=de(o,a),p=ye(o,f),v=ye(a,h);me(p,v);var d=g,m=ve(p,d),y=ve(d,d),x=m*m-y*(ve(p,p)-1);if(!(0>x)){var M=Math.sqrt(x),_=ye(d,(-m-M)/y);if(me(_,p),_=Me(_),!e)return _;var b,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(b=w,w=S,S=b);var A=S-w,C=ca(A-Ea)A;if(!C&&k>E&&(b=k,k=E,E=b),N?C?k+E>0^_[1]<(ca(_[0]-w)Ea^(w<=_[0]&&_[0]<=S)){var z=ye(d,(-m+M)/y);return me(z,p),[_,Me(z)]}}}function u(t,e){var r=o?n:Ea-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=ca(i)>Na,c=gr(n,6*La);return Le(t,e,c,o?[0,-n]:[-Ea,n-Ea])}function He(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,l=o.y,s=a.x,f=a.y,h=0,g=1,p=s-c,v=f-l;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-l,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-l,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:l+h*v}),1>g&&(u.b={x:c+g*p,y:l+g*v}),u}}}}}}function Oe(n,t,e,r){function u(r,u){return ca(r[0]-n)0?0:3:ca(r[0]-e)0?2:1:ca(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&K(l,i,n)>0&&++t:i[1]<=r&&K(l,i,n)<0&&--t,l=i;return 0!==t}function l(i,a,c,l){var s=0,f=0;if(null==i||(s=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do l.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+c+4)%4)!==f)}else l.point(a[0],a[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&a.point(n,t)}function h(){N.point=p,d&&d.push(m=[]),S=!0,w=!1,_=b=0/0}function g(){v&&(p(y,x),M&&w&&A.rejoin(),v.push(A.buffer())),N.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-Nc,Math.min(Nc,n)),t=Math.max(-Nc,Math.min(Nc,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,x=t,M=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:_,y:b},b:{x:n,y:t}};C(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}_=n,b=t,w=e}var v,d,m,y,x,M,_,b,w,S,k,E=a,A=qe(),C=He(n,t,e,r),N={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=Bo.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Ce(v,i,t,l,a),a.polygonEnd()),v=d=m=null}};return N}}function Ye(n,t){function e(e,r){return e=n(e,r),t(e[0],e[1])}return n.invert&&t.invert&&(e.invert=function(e,r){return e=t.invert(e,r),e&&n.invert(e[0],e[1])}),e}function Ie(n){var t=0,e=Ea/3,r=ir(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*Ea/180,e=n[1]*Ea/180):[180*(t/Ea),180*(e/Ea)]},u}function Ze(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,nt((i-(n*n+e*e)*u*u)/(2*u))]},e}function Ve(){function n(n,t){Lc+=u*n-r*t,r=n,u=t}var t,e,r,u;Pc.point=function(i,o){Pc.point=n,t=r=i,e=u=o},Pc.lineEnd=function(){n(t,e)}}function Xe(n,t){Tc>n&&(Tc=n),n>Rc&&(Rc=n),qc>t&&(qc=t),t>Dc&&(Dc=t)}function $e(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Be(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Be(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Be(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function We(n,t){yc+=n,xc+=t,++Mc}function Je(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);_c+=o*(t+n)/2,bc+=o*(e+r)/2,wc+=o,We(t=n,e=r)}var t,e;jc.point=function(r,u){jc.point=n,We(t=r,e=u)}}function Ge(){jc.point=We}function Ke(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);_c+=o*(r+n)/2,bc+=o*(u+t)/2,wc+=o,o=u*n-r*t,Sc+=o*(r+n),kc+=o*(u+t),Ec+=3*o,We(r=n,u=t)}var t,e,r,u;jc.point=function(i,o){jc.point=n,We(t=r=i,e=u=o)},jc.lineEnd=function(){n(t,e)}}function Qe(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,o,0,Aa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:y};return a}function nr(n){function t(n){return(a?r:e)(n)}function e(t){return rr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){x=0/0,S.point=i,t.lineStart()}function i(e,r){var i=pe([e,r]),o=n(e,r);u(x,M,y,_,b,w,x=o[0],M=o[1],y=e,_=i[0],b=i[1],w=i[2],a,t),t.point(x,M)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=l,S.lineEnd=s}function l(n,t){i(f=n,h=t),g=x,p=M,v=_,d=b,m=w,S.point=i}function s(){u(x,M,y,_,b,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,x,M,_,b,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,l,s,f,h,g,p,v,d,m){var y=s-t,x=f-e,M=y*y+x*x;if(M>4*i&&d--){var _=a+g,b=c+p,w=l+v,S=Math.sqrt(_*_+b*b+w*w),k=Math.asin(w/=S),E=ca(ca(w)-1)i||ca((y*z+x*L)/M-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,C,N,E,_/=S,b/=S,w,d,m),m.point(C,N),u(C,N,E,_,b,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*La),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Ta,e*Ta])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*La,n[1]*La),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ta,n[1]*Ta]}function r(){a=Ye(o=lr(m,y,x),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,x=0,M=Cc,_=Et,b=null,w=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(M(o,f(_(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(M=null==n?(b=n,Cc):Fe((b=+n)*La),u()):b},t.clipExtent=function(n){return arguments.length?(w=n,_=n?Oe(n[0][0],n[0][1],n[1][0],n[1][1]):Et,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*La,d=n[1]%360*La,r()):[v*Ta,d*Ta]},t.rotate=function(n){return arguments.length?(m=n[0]%360*La,y=n[1]%360*La,x=n.length>2?n[2]%360*La:0,r()):[m*Ta,y*Ta,x*Ta]},Bo.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*La,e*La)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>Ea?n-Aa:-Ea>n?n+Aa:n,t]}function lr(n,t,e){return n?t||e?Ye(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>Ea?t-Aa:-Ea>t?t+Aa:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),nt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),nt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*Aa)):(u=n+o*Aa,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=Me([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,xe(e);var r=Q(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Na)%(2*Math.PI)}function vr(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function xr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(ut(r-t)+u*o*ut(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ta,Math.atan2(o,Math.sqrt(r*r+u*u))*Ta]}:function(){return[n*Ta,t*Ta]};return p.distance=h,p}function Mr(){function n(n,u){var i=Math.sin(u*=La),o=Math.cos(u),a=ca((n*=La)-t),c=Math.cos(a);Fc+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Hc.point=function(u,i){t=u*La,e=Math.sin(i*=La),r=Math.cos(i),Hc.point=n},Hc.lineEnd=function(){Hc.point=Hc.lineEnd=y}}function _r(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function br(n,t){function e(n,t){o>0?-Ca+Na>t&&(t=-Ca+Na):t>Ca-Na&&(t=Ca-Na);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(Ea/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=G(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ca]},e):Sr}function wr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return ca(u)u;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function zr(n,t){return n[0]-t[0]||n[1]-t[1]}function Lr(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Tr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],l=e[1],s=t[1]-c,f=r[1]-l,h=(a*(c-l)-f*(u-i))/(f*o-a*s);return[u+h*o,c+h*s]}function qr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Rr(){tu(this),this.edge=this.site=this.circle=null}function Dr(n){var t=Kc.pop()||new Rr;return t.site=n,t}function Pr(n){Xr(n),Wc.remove(n),Kc.push(n),tu(n)}function Ur(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Pr(n);for(var c=i;c.circle&&ca(e-c.circle.x)s;++s)l=a[s],c=a[s-1],Kr(l.edge,c.site,l.site,u);c=a[0],l=a[f-1],l.edge=Jr(c.site,l.site,null,u),Vr(c),Vr(l)}function jr(n){for(var t,e,r,u,i=n.x,o=n.y,a=Wc._;a;)if(r=Fr(a,o)-i,r>Na)a=a.L;else{if(u=i-Hr(a,o),!(u>Na)){r>-Na?(t=a.P,e=a):u>-Na?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Dr(n);if(Wc.insert(t,c),t||e){if(t===e)return Xr(t),e=Dr(t.site),Wc.insert(c,e),c.edge=e.edge=Jr(t.site,c.site),Vr(t),Vr(e),void 0;if(!e)return c.edge=Jr(t.site,c.site),void 0;Xr(t),Xr(e);var l=t.site,s=l.x,f=l.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,x=v*v+d*d,M={x:(d*y-g*x)/m+s,y:(h*x-v*y)/m+f};Kr(e.edge,l,p,M),c.edge=Jr(l,n,null,M),e.edge=Jr(n,p,null,M),Vr(t),Vr(e)}}function Fr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,l=c-t;if(!l)return a;var s=a-r,f=1/i-1/l,h=s/l;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*l)-c+l/2+u-i/2)))/f+r:(r+a)/2}function Hr(n,t){var e=n.N;if(e)return Fr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Or(n){this.site=n,this.edges=[]}function Yr(n){for(var t,e,r,u,i,o,a,c,l,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=Bc,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)s=a[o].end(),r=s.x,u=s.y,l=a[++o%c].start(),t=l.x,e=l.y,(ca(r-t)>Na||ca(u-e)>Na)&&(a.splice(o,0,new Qr(Gr(i.site,s,ca(r-f)Na?{x:f,y:ca(t-f)Na?{x:ca(e-p)Na?{x:h,y:ca(t-h)Na?{x:ca(e-g)=-za)){var g=c*c+l*l,p=s*s+f*f,v=(f*g-l*p)/h,d=(c*p-s*g)/h,f=d+a,m=Qc.pop()||new Zr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,x=Gc._;x;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=l)return}else i={x:d,y:c};e={x:d,y:l}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=l)return}else i={x:(c-u)/r,y:c};e={x:(l-u)/r,y:l}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:pu(e,r)})),i=el.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function du(n,t){for(var e,r=Bo.interpolators.length;--r>=0&&!(e=Bo.interpolators[r](n,t)););return e}function mu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(du(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function yu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function xu(n){return function(t){return 1-n(1-t)}}function Mu(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function _u(n){return n*n}function bu(n){return n*n*n}function wu(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Su(n){return function(t){return Math.pow(t,n)}}function ku(n){return 1-Math.cos(n*Ca)}function Eu(n){return Math.pow(2,10*(n-1))}function Au(n){return 1-Math.sqrt(1-n*n)}function Cu(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Aa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Aa/t)}}function Nu(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function zu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Lu(n,t){n=Bo.hcl(n),t=Bo.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return lt(e+i*n,r+o*n,u+a*n)+""}}function Tu(n,t){n=Bo.hsl(n),t=Bo.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return at(e+i*n,r+o*n,u+a*n)+""}}function qu(n,t){n=Bo.lab(n),t=Bo.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ft(e+i*n,r+o*n,u+a*n)+""}}function Ru(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Du(n){var t=[n.a,n.b],e=[n.c,n.d],r=Uu(t),u=Pu(t,e),i=Uu(ju(e,t,-u))||0;t[0]*e[1]180?s+=360:s-l>180&&(l+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:pu(l,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:pu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:pu(g[0],p[0])},{i:e-2,x:pu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Ku(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function li(n){return n.reduce(si,0)}function si(n,t){return n+t[1]}function fi(n,t){return hi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function hi(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function gi(n){return[Bo.min(n),Bo.max(n)]}function pi(n,t){return n.value-t.value}function vi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function di(n,t){n._pack_next=t,t._pack_prev=n}function mi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function yi(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,u,i,o,a,c,l,s=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(xi),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(u=e[1],u.x=u.r,u.y=0,t(u),l>2))for(i=e[2],bi(r,u,i),t(i),vi(r,i),r._pack_prev=i,vi(i,u),u=r._pack_next,o=3;l>o;o++){bi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(mi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!mi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(Mi)}}function xi(n){n._pack_next=n._pack_prev=n}function Mi(n){delete n._pack_next,delete n._pack_prev}function _i(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Ci(n,t,e){return n.a.parent===t.parent?n.a:e}function Ni(n){return 1+Bo.max(n,function(n){return n.y})}function zi(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Li(n){var t=n.children;return t&&t.length?Li(t[0]):n}function Ti(n){var t,e=n.children;return e&&(t=e.length)?Ti(e[t-1]):n}function qi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ri(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Di(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Pi(n){return n.rangeExtent?n.rangeExtent():Di(n.range())}function Ui(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function ji(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Fi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:gl}function Hi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Hi:Ui,c=r?Ou:Hu;return o=u(n,t,c,e),a=u(t,n,c,du),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Ru)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Vi(n,t)},i.tickFormat=function(t,e){return Xi(n,t,e)},i.nice=function(t){return Ii(n,t),u()},i.copy=function(){return Oi(n,t,e,r)},u()}function Yi(n,t){return Bo.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Ii(n,t){return ji(n,Fi(Zi(n,t)[2]))}function Zi(n,t){null==t&&(t=10);var e=Di(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Vi(n,t){return Bo.range.apply(Bo,Zi(n,t))}function Xi(n,t,e){var r=Zi(n,t);if(e){var u=tc.exec(e);if(u.shift(),"s"===u[8]){var i=Bo.formatPrefix(Math.max(ca(r[0]),ca(r[1])));return u[7]||(u[7]="."+$i(i.scale(r[2]))),u[8]="f",e=Bo.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Bi(u[8],r)),e=u.join("")}else e=",."+$i(r[2])+"f";return Bo.format(e)}function $i(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Bi(n,t){var e=$i(t[2]);return n in pl?Math.abs(e-$i(Math.max(ca(t[0]),ca(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Wi(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=ji(r.map(u),e?Math:dl);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Di(r),o=[],a=n[0],c=n[1],l=Math.floor(u(a)),s=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(s-l)){if(e){for(;s>l;l++)for(var h=1;f>h;h++)o.push(i(l)*h);o.push(i(l))}else for(o.push(i(l));l++0;h--)o.push(i(l)*h);for(l=0;o[l]c;s--);o=o.slice(l,s)}return o},o.tickFormat=function(n,t){if(!arguments.length)return vl;arguments.length<2?t=vl:"function"!=typeof t&&(t=Bo.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Wi(n.copy(),t,e,r)},Yi(o,n)}function Ji(n,t,e){function r(t){return n(u(t))}var u=Gi(t),i=Gi(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Vi(e,n)},r.tickFormat=function(n,t){return Xi(e,n,t)},r.nice=function(n){return r.domain(Ii(e,n))},r.exponent=function(o){return arguments.length?(u=Gi(t=o),i=Gi(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Ji(n.copy(),t,e)},Yi(r,n)}function Gi(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Ki(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return Bo.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new a;for(var i,o=-1,c=r.length;++on?[0/0,0/0]:[n>0?a[n-1]:r[0],nt?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return no(n,t,e)},u()}function to(n,t){function e(e){return e>=e?t[Bo.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return to(n,t)},e}function eo(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Vi(n,t)},t.tickFormat=function(t,e){return Xi(n,t,e)},t.copy=function(){return eo(n)},t}function ro(n){return n.innerRadius}function uo(n){return n.outerRadius}function io(n){return n.startAngle}function oo(n){return n.endAngle}function ao(n){function t(t){function o(){l.push("M",i(n(s),a))}for(var c,l=[],s=[],f=-1,h=t.length,g=kt(e),p=kt(r);++f1&&u.push("H",r[0]),u.join("")}function fo(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var l=2;l9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function Co(n){return n.length<3?co(n):n[0]+mo(n,Ao(n))}function No(n){for(var t,e,r,u=-1,i=n.length;++ue?l():(u.active=e,i.event&&i.event.start.call(n,s,t),i.tween.forEach(function(e,r){(r=r.call(n,s,t))&&v.push(r) +}),Bo.timer(function(){return p.c=c(r||1)?Ae:c,1},0,o),void 0)}function c(r){if(u.active!==e)return l();for(var o=r/g,a=f(o),c=v.length;c>0;)v[--c].call(n,a);return o>=1?(i.event&&i.event.end.call(n,s,t),l()):void 0}function l(){return--u.count?delete u[e]:delete n.__transition__,1}var s=n.__data__,f=i.ease,h=i.delay,g=i.duration,p=Ka,v=[];return p.t=h+o,r>=h?a(r-h):(p.c=a,void 0)},0,o)}}function Oo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Yo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Io(n){return n.toISOString()}function Zo(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Bo.bisect(Ol,u);return i==Ol.length?[t.year,Zi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Ol[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Vo(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Vo(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Di(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Vo(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Zo(n.copy(),t,e)},Yi(r,n)}function Vo(n){return new Date(n)}function Xo(n){return JSON.parse(n.responseText)}function $o(n){var t=Go.createRange();return t.selectNode(Go.body),t.createContextualFragment(n.responseText)}var Bo={version:"3.4.13"};Date.now||(Date.now=function(){return+new Date});var Wo=[].slice,Jo=function(n){return Wo.call(n)},Go=document,Ko=Go.documentElement,Qo=window;try{Jo(Ko.childNodes)[0].nodeType}catch(na){Jo=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{Go.createElement("div").style.setProperty("opacity",0,"")}catch(ta){var ea=Qo.Element.prototype,ra=ea.setAttribute,ua=ea.setAttributeNS,ia=Qo.CSSStyleDeclaration.prototype,oa=ia.setProperty;ea.setAttribute=function(n,t){ra.call(this,n,t+"")},ea.setAttributeNS=function(n,t,e){ua.call(this,n,t,e+"")},ia.setProperty=function(n,t,e){oa.call(this,n,t+"",e)}}Bo.ascending=n,Bo.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},Bo.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ur&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ur&&(e=r)}return e},Bo.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ue&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ue&&(e=r)}return e},Bo.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=e);)e=u=void 0;for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=e);)e=void 0;for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Bo.sum=function(n,t){var r,u=0,i=n.length,o=-1;if(1===arguments.length)for(;++or?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Bo.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=Bo.min(arguments,u),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ca=Math.abs;Bo.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/e)throw new Error("infinite range");var r,u=[],o=i(ca(e)),a=-1;if(n*=o,t*=o,e*=o,0>e)for(;(r=n+e*++a)>t;)u.push(r/o);else for(;(r=n+e*++a)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,s,f,h,g=-1,p=o.length,v=i[c++],d=new a;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(Bo.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},Bo.set=function(n){var t=new v;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},o(v,{has:s,add:function(n){return this._[c(n+="")]=!0,n},remove:f,values:h,size:g,empty:p,forEach:function(n){for(var t in this._)n.call(this,l(t))}}),Bo.behavior={},Bo.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Bo.event=null,Bo.requote=function(n){return n.replace(ha,"\\$&")};var ha=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ga={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},pa=function(n,t){return t.querySelector(n)},va=function(n,t){return t.querySelectorAll(n)},da=Ko.matches||Ko[m(Ko,"matchesSelector")],ma=function(n,t){return da.call(n,t)};"function"==typeof Sizzle&&(pa=function(n,t){return Sizzle(n,t)[0]||null},va=Sizzle,ma=Sizzle.matchesSelector),Bo.selection=function(){return _a};var ya=Bo.selection.prototype=[];ya.select=function(n){var t,e,r,u,i=[];n=k(n);for(var o=-1,a=this.length;++o=0&&(e=n.slice(0,t),n=n.slice(t+1)),xa.hasOwnProperty(e)?{space:xa[e],local:n}:n}},ya.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Bo.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(A(t,n[t]));return this}return this.each(A(n,t))},ya.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(q(e,n[e],t));return this}if(2>r)return Qo.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(q(n,t,e))},ya.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(R(t,n[t]));return this}return this.each(R(n,t))},ya.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},ya.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},ya.append=function(n){return n=D(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},ya.insert=function(n,t){return n=D(n),t=k(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},ya.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},ya.data=function(n,t){function e(n,e){var r,u,i,o=n.length,f=e.length,h=Math.min(o,f),g=new Array(f),p=new Array(f),v=new Array(o);if(t){var d,m=new a,y=new Array(o);for(r=-1;++rr;++r)p[r]=P(e[r]);for(;o>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),l.push(g),s.push(v)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return S(u)},ya.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},ya.sort=function(n){n=j.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},ya.size=function(){var n=0;return F(this,function(){++n}),n};var Ma=[];Bo.selection.enter=H,Bo.selection.enter.prototype=Ma,Ma.append=ya.append,Ma.empty=ya.empty,Ma.node=ya.node,Ma.call=ya.call,Ma.size=ya.size,Ma.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(I(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(I(n,t,e))};var ba=Bo.map({mouseenter:"mouseover",mouseleave:"mouseout"});ba.forEach(function(n){"on"+n in Go&&ba.remove(n)});var wa="onselectstart"in Go?null:m(Ko.style,"userSelect"),Sa=0;Bo.mouse=function(n){return $(n,b())};var ka=/WebKit/.test(Qo.navigator.userAgent)?-1:0;Bo.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=b().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return $(n,r)},Bo.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",i)}function t(n,t,u,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-x[0],e=r[1]-x[1],p|=n|e,x=r,g({type:"drag",x:r[0]+l[0],y:r[1]+l[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&Bo.event.target===f),g({type:"dragend"}))}var l,s=this,f=Bo.event.target,h=s.parentNode,g=e.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=Bo.select(u()).on(i+d,a).on(o+d,c),y=X(),x=t(h,v);r?(l=r.apply(s,arguments),l=[l.x-x[0],l.y-x[1]]):l=[0,0],g({type:"dragstart"})}}var e=w(n,"drag","dragstart","dragend"),r=null,u=t(y,Bo.mouse,J,"mousemove","mouseup"),i=t(B,Bo.touch,W,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},Bo.rebind(n,e,"on")},Bo.touches=function(n,t){return arguments.length<2&&(t=b().touches),t?Jo(t).map(function(t){var e=$(n,t);return e.identifier=t.identifier,e}):[]};var Ea=Math.PI,Aa=2*Ea,Ca=Ea/2,Na=1e-6,za=Na*Na,La=Ea/180,Ta=180/Ea,qa=Math.SQRT2,Ra=2,Da=4;Bo.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=et(v),o=i/(Ra*h)*(e*rt(qa*t+v)-tt(v));return[r+o*l,u+o*s,i*e/et(qa*t+v)]}return[r+n*l,u+n*s,i*Math.exp(qa*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],l=o-r,s=a-u,f=l*l+s*s,h=Math.sqrt(f),g=(c*c-i*i+Da*f)/(2*i*Ra*h),p=(c*c-i*i-Da*f)/(2*c*Ra*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/qa;return e.duration=1e3*y,e},Bo.behavior.zoom=function(){function n(n){n.on(A,l).on(ja+".zoom",f).on("dblclick.zoom",h).on(z,s)}function t(n){return[(n[0]-S.x)/S.k,(n[1]-S.y)/S.k]}function e(n){return[n[0]*S.k+S.x,n[1]*S.k+S.y]}function r(n){S.k=Math.max(E[0],Math.min(E[1],n))}function u(n,t){t=e(t),S.x+=n[0]-t[0],S.y+=n[1]-t[1]}function i(){x&&x.domain(y.range().map(function(n){return(n-S.x)/S.k}).map(y.invert)),b&&b.domain(M.range().map(function(n){return(n-S.y)/S.k}).map(M.invert))}function o(n){n({type:"zoomstart"})}function a(n){i(),n({type:"zoom",scale:S.k,translate:[S.x,S.y]})}function c(n){n({type:"zoomend"})}function l(){function n(){s=1,u(Bo.mouse(r),h),a(l)}function e(){f.on(C,null).on(N,null),g(s&&Bo.event.target===i),c(l)}var r=this,i=Bo.event.target,l=L.of(r,arguments),s=0,f=Bo.select(Qo).on(C,n).on(N,e),h=t(Bo.mouse(r)),g=X();Y.call(r),o(l)}function s(){function n(){var n=Bo.touches(g);return h=S.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=t(n))}),n}function e(){var t=Bo.event.target;Bo.select(t).on(x,i).on(M,f),b.push(t);for(var e=Bo.event.changedTouches,o=0,c=e.length;c>o;++o)v[e[o].identifier]=null;var l=n(),s=Date.now();if(1===l.length){if(500>s-m){var h=l[0],g=v[h.identifier];r(2*S.k),u(h,g),_(),a(p)}m=s}else if(l.length>1){var h=l[0],y=l[1],w=h[0]-y[0],k=h[1]-y[1];d=w*w+k*k}}function i(){for(var n,t,e,i,o=Bo.touches(g),c=0,l=o.length;l>c;++c,i=null)if(e=o[c],i=v[e.identifier]){if(t)break;n=e,t=i}if(i){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=d&&Math.sqrt(s/d);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*h)}m=null,u(n,t),a(p)}function f(){if(Bo.event.touches.length){for(var t=Bo.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var u in v)return void n()}Bo.selectAll(b).on(y,null),w.on(A,l).on(z,s),k(),c(p)}var h,g=this,p=L.of(g,arguments),v={},d=0,y=".zoom-"+Bo.event.changedTouches[0].identifier,x="touchmove"+y,M="touchend"+y,b=[],w=Bo.select(g),k=X();Y.call(g),e(),o(p),w.on(A,null).on(z,e)}function f(){var n=L.of(this,arguments);d?clearTimeout(d):(g=t(p=v||Bo.mouse(this)),Y.call(this),o(n)),d=setTimeout(function(){d=null,c(n)},50),_(),r(Math.pow(2,.002*Pa())*S.k),u(p,g),a(n)}function h(){var n=L.of(this,arguments),e=Bo.mouse(this),i=t(e),l=Math.log(S.k)/Math.LN2;o(n),r(Math.pow(2,Bo.event.shiftKey?Math.ceil(l)-1:Math.floor(l)+1)),u(e,i),a(n),c(n)}var g,p,v,d,m,y,x,M,b,S={x:0,y:0,k:1},k=[960,500],E=Ua,A="mousedown.zoom",C="mousemove.zoom",N="mouseup.zoom",z="touchstart.zoom",L=w(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=L.of(this,arguments),t=S;Cl?Bo.select(this).transition().each("start.zoom",function(){S=this.__chart__||{x:0,y:0,k:1},o(n)}).tween("zoom:zoom",function(){var e=k[0],r=k[1],u=e/2,i=r/2,o=Bo.interpolateZoom([(u-S.x)/S.k,(i-S.y)/S.k,e/S.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),c=e/r[2];this.__chart__=S={x:u-r[0]*c,y:i-r[1]*c,k:c},a(n)}}).each("end.zoom",function(){c(n)}):(this.__chart__=S,o(n),a(n),c(n))})},n.translate=function(t){return arguments.length?(S={x:+t[0],y:+t[1],k:S.k},i(),n):[S.x,S.y]},n.scale=function(t){return arguments.length?(S={x:S.x,y:S.y,k:+t},i(),n):S.k},n.scaleExtent=function(t){return arguments.length?(E=null==t?Ua:[+t[0],+t[1]],n):E},n.center=function(t){return arguments.length?(v=t&&[+t[0],+t[1]],n):v},n.size=function(t){return arguments.length?(k=t&&[+t[0],+t[1]],n):k},n.x=function(t){return arguments.length?(x=t,y=t.copy(),S={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(b=t,M=t.copy(),S={x:0,y:0,k:1},n):b},Bo.rebind(n,L,"on")};var Pa,Ua=[0,1/0],ja="onwheel"in Go?(Pa=function(){return-Bo.event.deltaY*(Bo.event.deltaMode?120:1)},"wheel"):"onmousewheel"in Go?(Pa=function(){return Bo.event.wheelDelta},"mousewheel"):(Pa=function(){return-Bo.event.detail},"MozMousePixelScroll");Bo.color=it,it.prototype.toString=function(){return this.rgb()+""},Bo.hsl=ot;var Fa=ot.prototype=new it;Fa.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,this.l/n)},Fa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,n*this.l)},Fa.rgb=function(){return at(this.h,this.s,this.l)},Bo.hcl=ct;var Ha=ct.prototype=new it;Ha.brighter=function(n){return new ct(this.h,this.c,Math.min(100,this.l+Oa*(arguments.length?n:1)))},Ha.darker=function(n){return new ct(this.h,this.c,Math.max(0,this.l-Oa*(arguments.length?n:1)))},Ha.rgb=function(){return lt(this.h,this.c,this.l).rgb()},Bo.lab=st;var Oa=18,Ya=.95047,Ia=1,Za=1.08883,Va=st.prototype=new it;Va.brighter=function(n){return new st(Math.min(100,this.l+Oa*(arguments.length?n:1)),this.a,this.b)},Va.darker=function(n){return new st(Math.max(0,this.l-Oa*(arguments.length?n:1)),this.a,this.b)},Va.rgb=function(){return ft(this.l,this.a,this.b)},Bo.rgb=dt;var Xa=dt.prototype=new it;Xa.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dt(u,u,u)},Xa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dt(n*this.r,n*this.g,n*this.b)},Xa.hsl=function(){return _t(this.r,this.g,this.b)},Xa.toString=function(){return"#"+xt(this.r)+xt(this.g)+xt(this.b)};var $a=Bo.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});$a.forEach(function(n,t){$a.set(n,mt(t))}),Bo.functor=kt,Bo.xhr=At(Et),Bo.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=Ct(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=l)return o;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++a);else if(r!==c)continue;return n.slice(t,s-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],l=n.length,s=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,f++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new v,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},Bo.csv=Bo.dsv(",","text/csv"),Bo.tsv=Bo.dsv(" ","text/tab-separated-values");var Ba,Wa,Ja,Ga,Ka,Qa=Qo[m(Qo,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Bo.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};Wa?Wa.n=i:Ba=i,Wa=i,Ja||(Ga=clearTimeout(Ga),Ja=1,Qa(Lt))},Bo.timer.flush=function(){Tt(),qt()},Bo.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var nc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Dt);Bo.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=Bo.round(n,Rt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),nc[8+e/3]};var tc=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ec=Bo.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Bo.round(n,Rt(n,t))).toFixed(Math.max(0,Math.min(20,Rt(n*(1+1e-15),t))))}}),rc=Bo.time={},uc=Date;jt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ic.setUTCDate.apply(this._,arguments)},setDay:function(){ic.setUTCDay.apply(this._,arguments)},setFullYear:function(){ic.setUTCFullYear.apply(this._,arguments)},setHours:function(){ic.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ic.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ic.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ic.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ic.setUTCSeconds.apply(this._,arguments)},setTime:function(){ic.setTime.apply(this._,arguments)}};var ic=Date.prototype;rc.year=Ft(function(n){return n=rc.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),rc.years=rc.year.range,rc.years.utc=rc.year.utc.range,rc.day=Ft(function(n){var t=new uc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),rc.days=rc.day.range,rc.days.utc=rc.day.utc.range,rc.dayOfYear=function(n){var t=rc.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=rc[n]=Ft(function(n){return(n=rc.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=rc.year(n).getDay();return Math.floor((rc.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});rc[n+"s"]=e.range,rc[n+"s"].utc=e.utc.range,rc[n+"OfYear"]=function(n){var e=rc.year(n).getDay();return Math.floor((rc.dayOfYear(n)+(e+t)%7)/7)}}),rc.week=rc.sunday,rc.weeks=rc.sunday.range,rc.weeks.utc=rc.sunday.utc.range,rc.weekOfYear=rc.sundayOfYear;var oc={"-":"",_:" ",0:"0"},ac=/^\s*\d+/,cc=/^%/;Bo.locale=function(n){return{numberFormat:Pt(n),timeFormat:Ot(n)}};var lc=Bo.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});Bo.format=lc.numberFormat,Bo.geo={},ce.prototype={s:0,t:0,add:function(n){le(n,this.t,sc),le(sc.s,this.s,this),this.s?this.t+=sc.t:this.s=sc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var sc=new ce;Bo.geo.stream=function(n,t){n&&fc.hasOwnProperty(n.type)?fc[n.type](n,t):se(n,t)};var fc={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*Ea+n:n,vc.lineStart=vc.lineEnd=vc.point=y}};Bo.geo.bounds=function(){function n(n,t){x.push(M=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*La,e*La]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);xe(o),o=Me(o);var c=t-p,l=c>0?1:-1,v=o[0]*Ta*l,d=ca(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Ta;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Ta;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){_.point=t}function r(){M[0]=s,M[1]=h,_.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=ca(r)>180?r+(r>0?360:-360):r}else v=n,d=e;vc.point(n,e),t(n,e)}function i(){vc.lineStart()}function o(){u(v,d),vc.lineEnd(),ca(y)>Na&&(s=-(h=180)),M[0]=s,M[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:npc?(s=-(h=180),f=-(g=90)):y>Na?g=90:-Na>y&&(f=-90),M[0]=s,M[1]=h}};return function(n){g=h=-(s=f=1/0),x=[],Bo.geo.stream(n,_); +var t=x.length;if(t){x.sort(c);for(var e,r=1,u=x[0],i=[u];t>r;++r)e=x[r],l(e[0],u)||l(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,s=e[0],h=u[1])}return x=M=null,1/0===s||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[s,f],[h,g]]}}(),Bo.geo.centroid=function(n){dc=mc=yc=xc=Mc=_c=bc=wc=Sc=kc=Ec=0,Bo.geo.stream(n,Ac);var t=Sc,e=kc,r=Ec,u=t*t+e*e+r*r;return za>u&&(t=_c,e=bc,r=wc,Na>mc&&(t=yc,e=xc,r=Mc),u=t*t+e*e+r*r,za>u)?[0/0,0/0]:[Math.atan2(e,t)*Ta,nt(r/Math.sqrt(u))*Ta]};var dc,mc,yc,xc,Mc,_c,bc,wc,Sc,kc,Ec,Ac={sphere:y,point:be,lineStart:Se,lineEnd:ke,polygonStart:function(){Ac.lineStart=Ee},polygonEnd:function(){Ac.lineStart=Se}},Cc=Le(Ae,De,Ue,[-Ea,-Ea/2]),Nc=1e9;Bo.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Oe(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(Bo.geo.conicEqualArea=function(){return Ie(Ze)}).raw=Ze,Bo.geo.albers=function(){return Bo.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},Bo.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=Bo.geo.albers(),o=Bo.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=Bo.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var l=i.scale(),s=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[s-.455*l,f-.238*l],[s+.455*l,f+.238*l]]).stream(c).point,r=o.translate([s-.307*l,f+.201*l]).clipExtent([[s-.425*l+Na,f+.12*l+Na],[s-.214*l-Na,f+.234*l-Na]]).stream(c).point,u=a.translate([s-.205*l,f+.212*l]).clipExtent([[s-.214*l+Na,f+.166*l+Na],[s-.115*l-Na,f+.234*l-Na]]).stream(c).point,n},n.scale(1070)};var zc,Lc,Tc,qc,Rc,Dc,Pc={point:y,lineStart:y,lineEnd:y,polygonStart:function(){Lc=0,Pc.lineStart=Ve},polygonEnd:function(){Pc.lineStart=Pc.lineEnd=Pc.point=y,zc+=ca(Lc/2)}},Uc={point:Xe,lineStart:y,lineEnd:y,polygonStart:y,polygonEnd:y},jc={point:We,lineStart:Je,lineEnd:Ge,polygonStart:function(){jc.lineStart=Ke},polygonEnd:function(){jc.point=We,jc.lineStart=Je,jc.lineEnd=Ge}};Bo.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),Bo.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return zc=0,Bo.geo.stream(n,u(Pc)),zc},n.centroid=function(n){return yc=xc=Mc=_c=bc=wc=Sc=kc=Ec=0,Bo.geo.stream(n,u(jc)),Ec?[Sc/Ec,kc/Ec]:wc?[_c/wc,bc/wc]:Mc?[yc/Mc,xc/Mc]:[0/0,0/0]},n.bounds=function(n){return Rc=Dc=-(Tc=qc=1/0),Bo.geo.stream(n,u(Uc)),[[Tc,qc],[Rc,Dc]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||tr(n):Et,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new $e:new Qe(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(Bo.geo.albersUsa()).context(null)},Bo.geo.transform=function(n){return{stream:function(t){var e=new er(t);for(var r in n)e[r]=n[r];return e}}},er.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},Bo.geo.projection=ur,Bo.geo.projectionMutator=ir,(Bo.geo.equirectangular=function(){return ur(ar)}).raw=ar.invert=ar,Bo.geo.rotation=function(n){function t(t){return t=n(t[0]*La,t[1]*La),t[0]*=Ta,t[1]*=Ta,t}return n=lr(n[0]%360*La,n[1]*La,n.length>2?n[2]*La:0),t.invert=function(t){return t=n.invert(t[0]*La,t[1]*La),t[0]*=Ta,t[1]*=Ta,t},t},cr.invert=ar,Bo.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=lr(-n[0]*La,-n[1]*La,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Ta,n[1]*=Ta}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=gr((t=+r)*La,u*La),n):t},n.precision=function(r){return arguments.length?(e=gr(t*La,(u=+r)*La),n):u},n.angle(90)},Bo.geo.distance=function(n,t){var e,r=(t[0]-n[0])*La,u=n[1]*La,i=t[1]*La,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),l=Math.cos(u),s=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=l*s-c*f*a)*e),c*s+l*f*a)},Bo.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return Bo.range(Math.ceil(i/d)*d,u,d).map(h).concat(Bo.range(Math.ceil(l/m)*m,c,m).map(g)).concat(Bo.range(Math.ceil(r/p)*p,e,p).filter(function(n){return ca(n%d)>Na}).map(s)).concat(Bo.range(Math.ceil(a/v)*v,o,v).filter(function(n){return ca(n%m)>Na}).map(f))}var e,r,u,i,o,a,c,l,s,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],l=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[i,l],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,s=vr(a,o,90),f=dr(r,e,y),h=vr(l,c,90),g=dr(i,u,y),n):y},n.majorExtent([[-180,-90+Na],[180,90-Na]]).minorExtent([[-180,-80-Na],[180,80+Na]])},Bo.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=mr,u=yr;return n.distance=function(){return Bo.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},Bo.geo.interpolate=function(n,t){return xr(n[0]*La,n[1]*La,t[0]*La,t[1]*La)},Bo.geo.length=function(n){return Fc=0,Bo.geo.stream(n,Hc),Fc};var Fc,Hc={sphere:y,point:y,lineStart:Mr,lineEnd:y,polygonStart:y,polygonEnd:y},Oc=_r(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(Bo.geo.azimuthalEqualArea=function(){return ur(Oc)}).raw=Oc;var Yc=_r(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},Et);(Bo.geo.azimuthalEquidistant=function(){return ur(Yc)}).raw=Yc,(Bo.geo.conicConformal=function(){return Ie(br)}).raw=br,(Bo.geo.conicEquidistant=function(){return Ie(wr)}).raw=wr;var Ic=_r(function(n){return 1/n},Math.atan);(Bo.geo.gnomonic=function(){return ur(Ic)}).raw=Ic,Sr.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Ca]},(Bo.geo.mercator=function(){return kr(Sr)}).raw=Sr;var Zc=_r(function(){return 1},Math.asin);(Bo.geo.orthographic=function(){return ur(Zc)}).raw=Zc;var Vc=_r(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(Bo.geo.stereographic=function(){return ur(Vc)}).raw=Vc,Er.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Ca]},(Bo.geo.transverseMercator=function(){var n=kr(Er),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Er,Bo.geom={},Bo.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=kt(e),i=kt(r),o=n.length,a=[],c=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(zr),t=0;o>t;t++)c.push([a[t][0],-a[t][1]]);var l=Nr(a),s=Nr(c),f=s[0]===l[0],h=s[s.length-1]===l[l.length-1],g=[];for(t=l.length-1;t>=0;--t)g.push(n[a[l[t]][2]]);for(t=+f;t=r&&l.x<=i&&l.y>=u&&l.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];s.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Na)*Na,y:Math.round(o(n,t)/Na)*Na,i:t}})}var r=Ar,u=Cr,i=r,o=u,a=nl;return n?t(n):(t.links=function(n){return iu(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return iu(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(Ir),c=-1,l=a.length,s=a[l-1].edge,f=s.l===o?s.r:s.l;++c=l,h=r>=s,g=(h<<1)+f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=su()),f?u=l:a=l,h?o=s:c=s,i(n,t,e,r,u,o,a,c)}var s,f,h,g,p,v,d,m,y,x=kt(a),M=kt(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)s=n[g],s.xm&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var _=+x(s=n[g],g),b=+M(s,g);v>_&&(v=_),d>b&&(d=b),_>m&&(m=_),b>y&&(y=b),f.push(_),h.push(b)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=su();if(k.add=function(n){i(k,n,+x(n,++g),+M(n,g),v,d,m,y)},k.visit=function(n){fu(n,k,v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=ul.get(e)||rl,r=il.get(r)||Et,yu(r(e.apply(null,Wo.call(arguments,1))))},Bo.interpolateHcl=Lu,Bo.interpolateHsl=Tu,Bo.interpolateLab=qu,Bo.interpolateRound=Ru,Bo.transform=function(n){var t=Go.createElementNS(Bo.ns.prefix.svg,"g");return(Bo.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Du(e?e.matrix:ol)})(n)},Du.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ol={a:1,b:0,c:0,d:1,e:0,f:0};Bo.interpolateTransform=Fu,Bo.layout={},Bo.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var l=t.charge/c;n.px-=i*l,n.py-=o*l}return!0}if(t.point&&c&&p>c){var l=t.pointCharge/c;n.px-=i*l,n.py-=o*l}}return!t.charge}}function t(n){n.px=Bo.event.x,n.py=Bo.event.y,a.resume()}var e,r,u,i,o,a={},c=Bo.dispatch("start","tick","end"),l=[1,1],s=.9,f=al,h=cl,g=-30,p=ll,v=.1,d=.64,m=[],y=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,x,M,_=m.length,b=y.length;for(e=0;b>e;++e)a=y[e],f=a.source,h=a.target,x=h.x-f.x,M=h.y-f.y,(p=x*x+M*M)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,x*=p,M*=p,h.x-=x*(d=f.weight/(h.weight+f.weight)),h.y-=M*d,f.x+=x*(d=1-d),f.y+=M*d);if((d=r*v)&&(x=l[0]/2,M=l[1]/2,e=-1,d))for(;++e<_;)a=m[e],a.x+=(x-a.x)*d,a.y+=(M-a.y)*d;if(g)for(Wu(t=Bo.geom.quadtree(m),r,o),e=-1;++e<_;)(a=m[e]).fixed||t.visit(n(a));for(e=-1;++e<_;)a=m[e],a.fixed?(a.x=a.px,a.y=a.py):(a.x-=(a.px-(a.px=a.x))*s,a.y-=(a.py-(a.py=a.y))*s);c.tick({type:"tick",alpha:r})},a.nodes=function(n){return arguments.length?(m=n,a):m},a.links=function(n){return arguments.length?(y=n,a):y},a.size=function(n){return arguments.length?(l=n,a):l},a.linkDistance=function(n){return arguments.length?(f="function"==typeof n?n:+n,a):f},a.distance=a.linkDistance,a.linkStrength=function(n){return arguments.length?(h="function"==typeof n?n:+n,a):h},a.friction=function(n){return arguments.length?(s=+n,a):s},a.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,a):g},a.chargeDistance=function(n){return arguments.length?(p=n*n,a):Math.sqrt(p)},a.gravity=function(n){return arguments.length?(v=+n,a):v},a.theta=function(n){return arguments.length?(d=n*n,a):Math.sqrt(d)},a.alpha=function(n){return arguments.length?(n=+n,r?r=n>0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),Bo.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;l>a;++a){var u=y[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,l=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;s>t;++t)r=y[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;s>t;++t)u[t]=+f.call(this,y[t],t);else for(t=0;s>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;s>t;++t)i[t]=+h.call(this,y[t],t);else for(t=0;s>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=Bo.behavior.drag().origin(Et).on("dragstart.force",Vu).on("drag.force",t).on("dragend.force",Xu)),arguments.length?(this.on("mouseover.force",$u).on("mouseout.force",Bu).call(e),void 0):e},Bo.rebind(a,c,"on")};var al=20,cl=1,ll=1/0;Bo.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(l=e.call(n,i,i.depth))&&(c=l.length)){for(var c,l,s;--c>=0;)o.push(s=l[c]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=l}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Ku(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=ti,e=Qu,r=ni;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Gu(t,function(n){n.children&&(n.value=0)}),Ku(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},Bo.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,l=-1;for(r=t.value?r/t.value:0;++lp;++p)for(u.call(n,l[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,l[g][p],v+=s[g-1][p][1],s[g][p][1]);return a}var t=Et,e=oi,r=ai,u=ii,i=ri,o=ui;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:fl.get(t)||oi,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:hl.get(t)||ai,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var fl=Bo.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(ci),i=n.map(li),o=Bo.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,l=[],s=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],l.push(e)):(c+=i[e],s.push(e));return s.reverse().concat(l)},reverse:function(n){return Bo.range(n.length).reverse()},"default":oi}),hl=Bo.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,l,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];s>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ai});Bo.layout.histogram=function(){function n(n,i){for(var o,a,c=[],l=n.map(e,this),s=r.call(this,l,i),f=u.call(this,s,l,i),i=-1,h=l.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&a<=s[1]&&(o=c[Bo.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=gi,u=fi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return hi(n,t)}:kt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},Bo.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],l=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Ku(a,function(n){n.r=+s(n.value)}),Ku(a,yi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/l))/2;Ku(a,function(n){n.r+=f}),Ku(a,yi),Ku(a,function(n){n.r-=f})}return _i(a,c/2,l/2,t?1:1/Math.max(2*a.r/c,2*a.r/l)),o}var t,e=Bo.layout.hierarchy().sort(pi),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Ju(n,e)},Bo.layout.tree=function(){function n(n,u){var s=o.call(this,n,u),f=s[0],h=t(f);if(Ku(h,e),h.parent.m=-h.z,Gu(h,r),l)Gu(f,i);else{var g=f,p=f,v=f;Gu(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);Gu(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Ai(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],l=u.m,s=i.m,f=o.m,h=c.m;o=ki(o),u=Si(u),o&&u;)c=Si(c),i=ki(i),i.a=n,r=o.z+f-u.z-l+a(o._,u._),r>0&&(Ei(Ci(o,n,e),n,r),l+=r,s+=r),f+=o.m,l+=u.m,h+=c.m,s+=i.m;o&&!ki(i)&&(i.t=o,i.m+=f-s),u&&!Si(c)&&(c.t=u,c.m+=l-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=Bo.layout.hierarchy().sort(null).value(null),a=wi,c=[1,1],l=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(l=null==(c=t)?i:null,n):l?null:c},n.nodeSize=function(t){return arguments.length?(l=null==(c=t)?null:i,n):l?c:null},Ju(n,o)},Bo.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],l=0;Ku(c,function(n){var t=n.children;t&&t.length?(n.x=zi(t),n.y=Ni(t)):(n.x=o?l+=e(n,o):0,n.y=0,o=n)});var s=Li(c),f=Ti(c),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return Ku(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=Bo.layout.hierarchy().sort(null).value(null),e=wi,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Ju(n,t)},Bo.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,l=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),s.area=0;(c=h.length)>0;)s.push(o=h[c-1]),s.area+=o.area,"squarify"!==g||(a=r(s,v))<=p?(h.pop(),p=a):(s.area-=s.pop().area,u(s,v,l,!1),v=Math.min(l.dx,l.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,l,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,l=e.y,s=t?c(n.area/t):0;if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=Bo.random.normal.apply(Bo,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=Bo.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},Bo.scale={};var gl={floor:Et,ceil:Et};Bo.scale.linear=function(){return Oi([0,1],[0,1],du,!1)};var pl={s:1,g:1,p:1,r:1,e:1};Bo.scale.log=function(){return Wi(Bo.scale.linear().domain([0,1]),10,!0,[1,10])};var vl=Bo.format(".0e"),dl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};Bo.scale.pow=function(){return Ji(Bo.scale.linear(),1,[0,1])},Bo.scale.sqrt=function(){return Bo.scale.pow().exponent(.5)},Bo.scale.ordinal=function(){return Ki([],{t:"range",a:[[]]})},Bo.scale.category10=function(){return Bo.scale.ordinal().range(ml)},Bo.scale.category20=function(){return Bo.scale.ordinal().range(yl)},Bo.scale.category20b=function(){return Bo.scale.ordinal().range(xl)},Bo.scale.category20c=function(){return Bo.scale.ordinal().range(Ml)};var ml=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yt),yl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yt),xl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yt),Ml=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yt);Bo.scale.quantile=function(){return Qi([],[]) +},Bo.scale.quantize=function(){return no(0,1,[0,1])},Bo.scale.threshold=function(){return to([.5],[0,1])},Bo.scale.identity=function(){return eo([0,1])},Bo.svg={},Bo.svg.arc=function(){function n(){var n=t.apply(this,arguments),i=e.apply(this,arguments),o=r.apply(this,arguments)+_l,a=u.apply(this,arguments)+_l,c=(o>a&&(c=o,o=a,a=c),a-o),l=Ea>c?"0":"1",s=Math.cos(o),f=Math.sin(o),h=Math.cos(a),g=Math.sin(a);return c>=bl?n?"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z":n?"M"+i*s+","+i*f+"A"+i+","+i+" 0 "+l+",1 "+i*h+","+i*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+l+",0 "+n*s+","+n*f+"Z":"M"+i*s+","+i*f+"A"+i+","+i+" 0 "+l+",1 "+i*h+","+i*g+"L0,0"+"Z"}var t=ro,e=uo,r=io,u=oo;return n.innerRadius=function(e){return arguments.length?(t=kt(e),n):t},n.outerRadius=function(t){return arguments.length?(e=kt(t),n):e},n.startAngle=function(t){return arguments.length?(r=kt(t),n):r},n.endAngle=function(t){return arguments.length?(u=kt(t),n):u},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,i=(r.apply(this,arguments)+u.apply(this,arguments))/2+_l;return[Math.cos(i)*n,Math.sin(i)*n]},n};var _l=-Ca,bl=Aa-Na;Bo.svg.line=function(){return ao(Et)};var wl=Bo.map({linear:co,"linear-closed":lo,step:so,"step-before":fo,"step-after":ho,basis:xo,"basis-open":Mo,"basis-closed":_o,bundle:bo,cardinal:vo,"cardinal-open":go,"cardinal-closed":po,monotone:Co});wl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Sl=[0,2/3,1/3,0],kl=[0,1/3,2/3,0],El=[0,1/6,2/3,1/6];Bo.svg.line.radial=function(){var n=ao(No);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},fo.reverse=ho,ho.reverse=fo,Bo.svg.area=function(){return zo(Et)},Bo.svg.area.radial=function(){var n=zo(No);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},Bo.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),l=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+u(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)+_l,s=l.call(n,u,r)+_l;return{r:i,a0:o,a1:s,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Ea)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=mr,o=yr,a=Lo,c=io,l=oo;return n.radius=function(t){return arguments.length?(a=kt(t),n):a},n.source=function(t){return arguments.length?(i=kt(t),n):i},n.target=function(t){return arguments.length?(o=kt(t),n):o},n.startAngle=function(t){return arguments.length?(c=kt(t),n):c},n.endAngle=function(t){return arguments.length?(l=kt(t),n):l},n},Bo.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=mr,e=yr,r=To;return n.source=function(e){return arguments.length?(t=kt(e),n):t},n.target=function(t){return arguments.length?(e=kt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},Bo.svg.diagonal.radial=function(){var n=Bo.svg.diagonal(),t=To,e=n.projection;return n.projection=function(n){return arguments.length?e(qo(t=n)):t},n},Bo.svg.symbol=function(){function n(n,r){return(Al.get(t.call(this,n,r))||Po)(e.call(this,n,r))}var t=Do,e=Ro;return n.type=function(e){return arguments.length?(t=kt(e),n):t},n.size=function(t){return arguments.length?(e=kt(t),n):e},n};var Al=Bo.map({circle:Po,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ll)),e=t*Ll;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/zl),e=t*zl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/zl),e=t*zl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});Bo.svg.symbolTypes=Al.keys();var Cl,Nl,zl=Math.sqrt(3),Ll=Math.tan(30*La),Tl=[],ql=0;Tl.call=ya.call,Tl.empty=ya.empty,Tl.node=ya.node,Tl.size=ya.size,Bo.transition=function(n){return arguments.length?Cl?n.transition():n:_a.transition()},Bo.transition.prototype=Tl,Tl.select=function(n){var t,e,r,u=this.id,i=[];n=k(n);for(var o=-1,a=this.length;++oi;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Uo(u,this.id)},Tl.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):F(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},Tl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Fu:du,a=Bo.ns.qualify(n);return jo(this,"attr."+n,t,a.local?i:u)},Tl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=Bo.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Tl.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=Qo.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=du(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return jo(this,"style."+n,t,u)},Tl.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,Qo.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Tl.text=function(n){return jo(this,"text",n,Fo)},Tl.remove=function(){return this.each("end.transition",function(){var n;this.__transition__.count<2&&(n=this.parentNode)&&n.removeChild(this)})},Tl.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=Bo.ease.apply(Bo,arguments)),F(this,function(e){e.__transition__[t].ease=n}))},Tl.delay=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].delay:F(this,"function"==typeof n?function(e,r,u){e.__transition__[t].delay=+n.call(e,e.__data__,r,u)}:(n=+n,function(e){e.__transition__[t].delay=n}))},Tl.duration=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].duration:F(this,"function"==typeof n?function(e,r,u){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,u))}:(n=Math.max(1,n),function(e){e.__transition__[t].duration=n}))},Tl.each=function(n,t){var e=this.id;if(arguments.length<2){var r=Nl,u=Cl;Cl=e,F(this,function(t,r,u){Nl=t.__transition__[e],n.call(t,t.__data__,r,u)}),Nl=r,Cl=u}else F(this,function(r){var u=r.__transition__[e];(u.event||(u.event=Bo.dispatch("start","end"))).on(n,t)});return this},Tl.transition=function(){for(var n,t,e,r,u=this.id,i=++ql,o=[],a=0,c=this.length;c>a;a++){o.push(n=[]);for(var t=this[a],l=0,s=t.length;s>l;l++)(e=t[l])&&(r=Object.create(e.__transition__[u]),r.delay+=r.duration,Ho(e,l,i,r)),n.push(e)}return Uo(o,i)},Bo.svg.axis=function(){function n(n){n.each(function(){var n,l=Bo.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):Et:t,p=l.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Na),d=Bo.transition(p.exit()).style("opacity",Na).remove(),m=Bo.transition(p.order()).style("opacity",1),y=Math.max(u,0)+o,x=Pi(f),M=l.selectAll(".domain").data([0]),_=(M.enter().append("path").attr("class","domain"),Bo.transition(M));v.append("line"),v.append("text");var b,w,S,k,E=v.select("line"),A=m.select("line"),C=p.select("text").text(g),N=v.select("text"),z=m.select("text"),L="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Oo,b="x",S="y",w="x2",k="y2",C.attr("dy",0>L?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+L*i+"V0H"+x[1]+"V"+L*i)):(n=Yo,b="y",S="x",w="y2",k="x2",C.attr("dy",".32em").style("text-anchor",0>L?"end":"start"),_.attr("d","M"+L*i+","+x[0]+"H0V"+x[1]+"H"+L*i)),E.attr(k,L*u),N.attr(S,L*y),A.attr(w,0).attr(k,L*u),z.attr(b,0).attr(S,L*y),f.rangeBand){var T=f,q=T.rangeBand()/2;s=f=function(n){return T(n)+q}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=Bo.scale.linear(),r=Rl,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Dl?t+"":Rl,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Rl="bottom",Dl={top:1,right:1,bottom:1,left:1};Bo.svg.brush=function(){function n(i){i.each(function(){var i=Bo.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(p,Et);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Pl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var s,f=Bo.transition(i),h=Bo.transition(o);c&&(s=Pi(c),h.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),l&&(s=Pi(l),h.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+f[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function r(n){n.select(".extent").attr("y",f[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function u(){function u(){32==Bo.event.keyCode&&(C||(y=null,z[0]-=s[1],z[1]-=f[1],C=2),_())}function p(){32==Bo.event.keyCode&&2==C&&(z[0]+=s[1],z[1]+=f[1],C=0,_())}function v(){var n=Bo.mouse(M),u=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(Bo.event.altKey?(y||(y=[(s[0]+s[1])/2,(f[0]+f[1])/2]),z[0]=s[+(n[0]p?(u=r,r=p):u=p),v[0]!=r||v[1]!=u?(e?o=null:i=null,v[0]=r,v[1]=u,!0):void 0}function m(){v(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),Bo.select("body").style("cursor",null),L.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),N(),w({type:"brushend"})}var y,x,M=this,b=Bo.select(Bo.event.target),w=a.of(M,arguments),S=Bo.select(M),k=b.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&l,C=b.classed("extent"),N=X(),z=Bo.mouse(M),L=Bo.select(Qo).on("keydown.brush",u).on("keyup.brush",p);if(Bo.event.changedTouches?L.on("touchmove.brush",v).on("touchend.brush",m):L.on("mousemove.brush",v).on("mouseup.brush",m),S.interrupt().selectAll("*").interrupt(),C)z[0]=s[0]-z[0],z[1]=f[0]-z[1];else if(k){var T=+/w$/.test(k),q=+/^n/.test(k);x=[s[1-T]-z[0],f[1-q]-z[1]],z[0]=s[T],z[1]=f[q]}else Bo.event.altKey&&(y=z.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),Bo.select("body").style("cursor",b.style("cursor")),w({type:"brushstart"}),v()}var i,o,a=w(n,"brushstart","brush","brushend"),c=null,l=null,s=[0,0],f=[0,0],h=!0,g=!0,p=Ul[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:s,y:f,i:i,j:o},e=this.__chart__||t;this.__chart__=t,Cl?Bo.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,s=e.x,f=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=mu(s,t.x),r=mu(f,t.y);return i=o=null,function(u){s=t.x=e(u),f=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,p=Ul[!c<<1|!l],n):c},n.y=function(t){return arguments.length?(l=t,p=Ul[!c<<1|!l],n):l},n.clamp=function(t){return arguments.length?(c&&l?(h=!!t[0],g=!!t[1]):c?h=!!t:l&&(g=!!t),n):c&&l?[h,g]:c?h:l?g:null},n.extent=function(t){var e,r,u,a,h;return arguments.length?(c&&(e=t[0],r=t[1],l&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(h=e,e=r,r=h),(e!=s[0]||r!=s[1])&&(s=[e,r])),l&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],l.invert&&(u=l(u),a=l(a)),u>a&&(h=u,u=a,a=h),(u!=f[0]||a!=f[1])&&(f=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(h=e,e=r,r=h))),l&&(o?(u=o[0],a=o[1]):(u=f[0],a=f[1],l.invert&&(u=l.invert(u),a=l.invert(a)),u>a&&(h=u,u=a,a=h))),c&&l?[[e,u],[r,a]]:c?[e,r]:l&&[u,a])},n.clear=function(){return n.empty()||(s=[0,0],f=[0,0],i=o=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!l&&f[0]==f[1]},Bo.rebind(n,a,"on")};var Pl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ul=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],jl=rc.format=lc.timeFormat,Fl=jl.utc,Hl=Fl("%Y-%m-%dT%H:%M:%S.%LZ");jl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Io:Hl,Io.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Io.toString=Hl.toString,rc.second=Ft(function(n){return new uc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),rc.seconds=rc.second.range,rc.seconds.utc=rc.second.utc.range,rc.minute=Ft(function(n){return new uc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),rc.minutes=rc.minute.range,rc.minutes.utc=rc.minute.utc.range,rc.hour=Ft(function(n){var t=n.getTimezoneOffset()/60;return new uc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),rc.hours=rc.hour.range,rc.hours.utc=rc.hour.utc.range,rc.month=Ft(function(n){return n=rc.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),rc.months=rc.month.range,rc.months.utc=rc.month.utc.range;var Ol=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Yl=[[rc.second,1],[rc.second,5],[rc.second,15],[rc.second,30],[rc.minute,1],[rc.minute,5],[rc.minute,15],[rc.minute,30],[rc.hour,1],[rc.hour,3],[rc.hour,6],[rc.hour,12],[rc.day,1],[rc.day,2],[rc.week,1],[rc.month,1],[rc.month,3],[rc.year,1]],Il=jl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Ae]]),Zl={range:function(n,t,e){return Bo.range(Math.ceil(n/e)*e,+t,e).map(Vo)},floor:Et,ceil:Et};Yl.year=rc.year,rc.scale=function(){return Zo(Bo.scale.linear(),Yl,Il)};var Vl=Yl.map(function(n){return[n[0].utc,n[1]]}),Xl=Fl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Ae]]);Vl.year=rc.year.utc,rc.scale.utc=function(){return Zo(Bo.scale.linear(),Vl,Xl)},Bo.text=At(function(n){return n.responseText}),Bo.json=function(n,t){return Ct(n,"application/json",Xo,t)},Bo.html=function(n,t){return Ct(n,"text/html",$o,t)},Bo.xml=At(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(Bo):"object"==typeof module&&module.exports&&(module.exports=Bo),this.d3=Bo}(); \ No newline at end of file diff --git a/package.json b/package.json index 80cf3fdb57..2de1176b2a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plottable.js", "description": "A library for creating charts out of D3", - "version": "0.34.1", + "version": "0.35.0", "repository": { "type": "git", "url": "https://github.com/palantir/plottable.git" diff --git a/plottable-dev.d.ts b/plottable-dev.d.ts index aa0bc139e6..7dbf510878 100644 --- a/plottable-dev.d.ts +++ b/plottable-dev.d.ts @@ -38,7 +38,17 @@ declare module Plottable { * Take an accessor object (may be a string to be made into a key, or a value, or a color code) * and "activate" it by turning it into a function in (datum, index, metadata) */ +<<<<<<< HEAD + function accessorize(accessor: any): _Accessor; + /** + * Take an accessor object, activate it, and partially apply it to a Plot's datasource's metadata. + * Temporarily always grabs the metadata of the first dataset. + * HACKHACK #1089 - The accessor currently only grabs the first dataset's metadata + */ + function _applyAccessor(accessor: _Accessor, plot: Plot.AbstractPlot): (d: any, i: number) => any; +======= function accessorize(accessor: any): _IAccessor; +>>>>>>> develop /** * Takes two sets and returns the union * @@ -53,6 +63,12 @@ declare module Plottable { * Populates a map from an array of keys and a transformation function. * * @param {string[]} keys The array of keys. +<<<<<<< HEAD + * @param {(string, number) => T} transform A transformation function to apply to the keys. + * @return {D3.Map} A map mapping keys to their transformed values. + */ + function populateMap(keys: string[], transform: (key: string, index: number) => T): D3.Map; +======= * @param {(string) => T} transform A transformation function to apply to the keys. * @return {D3.Map} A map mapping keys to their transformed values. */ @@ -61,6 +77,7 @@ declare module Plottable { * Take an accessor object, activate it, and partially apply it to a Plot's datasource's metadata */ function _applyAccessor(accessor: _IAccessor, plot: Abstract.Plot): (d: any, i: number) => any; +>>>>>>> develop /** * Take an array of values, and return the unique values. * Will work iff ∀ a, b, a.toString() == b.toString() => a == b; will break on Object inputs @@ -113,7 +130,11 @@ declare module Plottable { * Takes a number and an array of numbers OR an array of objects and an accessor that returns a number. * @param {number} value: The numerical value to insert * @param {any[]} arr: Array to find insertion index, can be number[] or any[] (if accessor provided) +<<<<<<< HEAD + * @param {_Accessor} accessor: If provided, this function is called on members of arr to determine insertion index +======= * @param {_IAccessor} accessor: If provided, this function is called on members of arr to determine insertion index +>>>>>>> develop * @returns {number} The insertion index. * The behavior is undefined for arrays that are unsorted * If there are multiple valid insertion indices that maintain sorted order (e.g. addign 1 to [1,1,1,1,1]) then @@ -145,7 +166,11 @@ declare module Plottable { * OTHER DEALINGS IN THE SOFTWARE. */ function sortedIndex(val: number, arr: number[]): number; +<<<<<<< HEAD + function sortedIndex(val: number, arr: any[], accessor: _Accessor): number; +======= function sortedIndex(val: number, arr: any[], accessor: _IAccessor): number; +>>>>>>> develop } } } @@ -344,7 +369,11 @@ declare module Plottable { * that is appropriate. * Returns an IWriteTextResult with info on whether the text fit, and how much width/height was used. */ +<<<<<<< HEAD + function writeText(text: string, width: number, height: number, tm: TextMeasurer, orientation?: string, write?: IWriteOptions): IWriteTextResult; +======= function writeText(text: string, width: number, height: number, tm: TextMeasurer, horizontally?: boolean, write?: IWriteOptions): IWriteTextResult; +>>>>>>> develop } } } @@ -353,7 +382,11 @@ declare module Plottable { declare module Plottable { module _Util { module WordWrap { +<<<<<<< HEAD + interface WrappedText { +======= interface IWrappedText { +>>>>>>> develop originalText: string; lines: string[]; textFits: boolean; @@ -362,7 +395,11 @@ declare module Plottable { * Takes a block of text, a width and height to fit it in, and a 2-d text measurement function. * Wraps words and fits as much of the text as possible into the given width and height. */ +<<<<<<< HEAD + function breakTextToFitRect(text: string, width: number, height: number, measureText: Text.TextMeasurer): WrappedText; +======= function breakTextToFitRect(text: string, width: number, height: number, measureText: Text.TextMeasurer): IWrappedText; +>>>>>>> develop /** * Determines if it is possible to fit a given text within width without breaking any of the words. * Simple algorithm, split the text up into tokens, and make sure that the widest token doesn't exceed @@ -477,6 +514,8 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD +======= module TickGenerators { /** * Creates a tick generator using specific interval. @@ -493,6 +532,7 @@ declare module Plottable { declare module Plottable { +>>>>>>> develop var version: string; } @@ -520,7 +560,11 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Core { +======= module Abstract { +>>>>>>> develop /** * A class most other Plottable classes inherit from, in order to have a * unique ID. @@ -540,10 +584,17 @@ declare module Plottable { * on it. * * e.g.: +<<<<<<< HEAD + * listenable: Plottable.Listenable; + * listenable.broadcaster.registerListener(callbackToCallOnBroadcast) + */ + interface Listenable { +======= * listenable: Plottable.IListenable; * listenable.broadcaster.registerListener(callbackToCallOnBroadcast) */ interface IListenable { +>>>>>>> develop broadcaster: Broadcaster; } /** @@ -555,36 +606,62 @@ declare module Plottable { * The Listenable is passed as the first argument so that it is easy for the callback to reference the * current state of the Listenable in the resolution logic. */ +<<<<<<< HEAD + interface BroadcasterCallback { + (listenable: Listenable, ...args: any[]): any; + } + /** + * The Broadcaster class is owned by an Listenable. Third parties can register and deregister listeners +======= interface IBroadcasterCallback { (listenable: IListenable, ...args: any[]): any; } /** * The Broadcaster class is owned by an IListenable. Third parties can register and deregister listeners +>>>>>>> develop * from the broadcaster. When the broadcaster.broadcast method is activated, all registered callbacks are * called. The registered callbacks are called with the registered Listenable that the broadcaster is attached * to, along with optional arguments passed to the `broadcast` method. * * The listeners are called synchronously. */ +<<<<<<< HEAD + class Broadcaster extends PlottableObject { + listenable: Listenable; +======= class Broadcaster extends Abstract.PlottableObject { listenable: IListenable; +>>>>>>> develop /** * Constructs a broadcaster, taking the Listenable that the broadcaster will be attached to. * * @constructor +<<<<<<< HEAD + * @param {Listenable} listenable The Listenable-object that this broadcaster is attached to. + */ + constructor(listenable: Listenable); +======= * @param {IListenable} listenable The Listenable-object that this broadcaster is attached to. */ constructor(listenable: IListenable); +>>>>>>> develop /** * Registers a callback to be called when the broadcast method is called. Also takes a key which * is used to support deregistering the same callback later, by passing in the same key. * If there is already a callback associated with that key, then the callback will be replaced. * * @param key The key associated with the callback. Key uniqueness is determined by deep equality. +<<<<<<< HEAD + * @param {BroadcasterCallback} callback A callback to be called when the Scale's domain changes. + * @returns {Broadcaster} this object + */ + registerListener(key: any, callback: BroadcasterCallback): Broadcaster; +======= * @param {IBroadcasterCallback} callback A callback to be called when the Scale's domain changes. * @returns {Broadcaster} this object */ registerListener(key: any, callback: IBroadcasterCallback): Broadcaster; +>>>>>>> develop /** * Call all listening callbacks, optionally with arguments passed through. * @@ -611,7 +688,11 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + class Dataset extends Core.PlottableObject implements Core.Listenable { +======= class Dataset extends Abstract.PlottableObject implements Core.IListenable { +>>>>>>> develop broadcaster: any; /** * Constructs a new set. @@ -651,7 +732,11 @@ declare module Plottable { * @returns {Dataset} The calling Dataset. */ metadata(metadata: any): Dataset; +<<<<<<< HEAD + _getExtent(accessor: _Accessor, typeCoercer: (d: any) => any): any[]; +======= _getExtent(accessor: _IAccessor, typeCoercer: (d: any) => any): any[]; +>>>>>>> develop } } @@ -663,21 +748,33 @@ declare module Plottable { /** * A policy to render components. */ +<<<<<<< HEAD + interface RenderPolicy { +======= interface IRenderPolicy { +>>>>>>> develop render(): any; } /** * Never queue anything, render everything immediately. Useful for * debugging, horrible for performance. */ +<<<<<<< HEAD + class Immediate implements RenderPolicy { +======= class Immediate implements IRenderPolicy { +>>>>>>> develop render(): void; } /** * The default way to render, which only tries to render every frame * (usually, 1/60th of a second). */ +<<<<<<< HEAD + class AnimationFrame implements RenderPolicy { +======= class AnimationFrame implements IRenderPolicy { +>>>>>>> develop render(): void; } /** @@ -685,7 +782,11 @@ declare module Plottable { * compared to `requestAnimationFrame`, but it's still there if you want * it. */ +<<<<<<< HEAD + class Timeout implements RenderPolicy { +======= class Timeout implements IRenderPolicy { +>>>>>>> develop _timeoutMsec: number; render(): void; } @@ -716,23 +817,41 @@ declare module Plottable { * ``` */ module RenderController { +<<<<<<< HEAD + var _renderPolicy: RenderPolicy.RenderPolicy; + function setRenderPolicy(policy: string): void; + function setRenderPolicy(policy: RenderPolicy.RenderPolicy): void; +======= var _renderPolicy: RenderPolicy.IRenderPolicy; function setRenderPolicy(policy: string): void; function setRenderPolicy(policy: RenderPolicy.IRenderPolicy): void; +>>>>>>> develop /** * If the RenderController is enabled, we enqueue the component for * render. Otherwise, it is rendered immediately. * +<<<<<<< HEAD + * @param {AbstractComponent} component Any Plottable component. + */ + function registerToRender(c: Component.AbstractComponent): void; +======= * @param {Abstract.Component} component Any Plottable component. */ function registerToRender(c: Abstract.Component): void; +>>>>>>> develop /** * If the RenderController is enabled, we enqueue the component for * layout and render. Otherwise, it is rendered immediately. * +<<<<<<< HEAD + * @param {AbstractComponent} component Any Plottable component. + */ + function registerToComputeLayout(c: Component.AbstractComponent): void; +======= * @param {Abstract.Component} component Any Plottable component. */ function registerToComputeLayout(c: Abstract.Component): void; +>>>>>>> develop /** * Render everything that is waiting to be rendered right now, instead of * waiting until the next frame. @@ -781,7 +900,11 @@ declare module Plottable { * * @param {Component} component Any Plottable component. */ +<<<<<<< HEAD + function register(c: Component.AbstractComponent): void; +======= function register(c: Abstract.Component): void; +>>>>>>> develop /** * Deregisters the components. * @@ -789,12 +912,27 @@ declare module Plottable { * * @param {Component} component Any Plottable component. */ +<<<<<<< HEAD + function deregister(c: Component.AbstractComponent): void; +======= function deregister(c: Abstract.Component): void; +>>>>>>> develop } } } declare module Plottable { +<<<<<<< HEAD + interface DatasetInterface { + data: any[]; + metadata: Metadata; + } + interface Metadata { + cssClass?: string; + color?: string; + } + interface _Accessor { +======= interface IDataset { data: any[]; metadata: IMetadata; @@ -804,6 +942,7 @@ declare module Plottable { color?: string; } interface _IAccessor { +>>>>>>> develop (datum: any, index?: number, metadata?: any): any; } /** @@ -813,12 +952,21 @@ declare module Plottable { * * Index, if used, will be the index of the datum in the array. */ +<<<<<<< HEAD + interface AppliedAccessor { + (datum?: any, index?: number): any; + } + interface _Projector { + accessor: _Accessor; + scale?: Scale.AbstractScale; +======= interface IAppliedAccessor { (datum: any, index: number): any; } interface _IProjector { accessor: _IAccessor; scale?: Abstract.Scale; +>>>>>>> develop attribute: string; } /** @@ -829,8 +977,13 @@ declare module Plottable { * with both `foo` and `bar`, an entry in this type might be `{"r": * function(d) { return foo + bar; }`. */ +<<<<<<< HEAD + interface AttributeToProjector { + [attrToSet: string]: AppliedAccessor; +======= interface IAttributeToProjector { [attrToSet: string]: IAppliedAccessor; +>>>>>>> develop } /** * A simple bounding box. @@ -841,26 +994,42 @@ declare module Plottable { yMin: number; yMax: number; } +<<<<<<< HEAD + interface _SpaceRequest { +======= interface _ISpaceRequest { +>>>>>>> develop width: number; height: number; wantsWidth: boolean; wantsHeight: boolean; } +<<<<<<< HEAD + interface _PixelArea { +======= interface _IPixelArea { +>>>>>>> develop xMin: number; xMax: number; yMin: number; yMax: number; } /** +<<<<<<< HEAD + * The range of your current data. For example, [1, 2, 6, -5] has the Extent +======= * The range of your current data. For example, [1, 2, 6, -5] has the IExtent +>>>>>>> develop * `{min: -5, max: 6}`. * * The point of this type is to hopefully replace the less-elegant `[min, * max]` extents produced by d3. */ +<<<<<<< HEAD + interface Extent { +======= interface IExtent { +>>>>>>> develop min: number; max: number; } @@ -876,7 +1045,11 @@ declare module Plottable { */ interface DatasetDrawerKey { dataset: Dataset; +<<<<<<< HEAD + drawer: _Drawer.AbstractDrawer; +======= drawer: Abstract._Drawer; +>>>>>>> develop key: string; } } @@ -908,7 +1081,11 @@ declare module Plottable { * @returns {any[]} The domain, as a merging of all exents, as a [min, max] * pair. */ +<<<<<<< HEAD + computeDomain(extents: any[][], scale: Scale.AbstractQuantitative): any[]; +======= computeDomain(extents: any[][], scale: Abstract.QuantitativeScale): any[]; +>>>>>>> develop /** * Sets the Domainer to pad by a given ratio. * @@ -980,8 +1157,13 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Scale { + class AbstractScale extends Core.PlottableObject implements Core.Listenable { +======= module Abstract { class Scale extends PlottableObject implements Core.IListenable { +>>>>>>> develop _d3Scale: D3.Scale.Scale; _autoDomainAutomatically: boolean; broadcaster: any; @@ -989,6 +1171,10 @@ declare module Plottable { [x: string]: D[]; }; _typeCoercer: (d: any) => any; +<<<<<<< HEAD + _adjustmentInProgress: boolean; +======= +>>>>>>> develop /** * Constructs a new Scale. * @@ -1017,7 +1203,11 @@ declare module Plottable { * * @returns {Scale} The calling Scale. */ +<<<<<<< HEAD + autoDomain(): AbstractScale; +======= autoDomain(): Scale; +>>>>>>> develop _autoDomainIfAutomaticMode(): void; /** * Computes the range value corresponding to a given domain value. In other @@ -1042,7 +1232,11 @@ declare module Plottable { * input values. * @returns {Scale} The calling Scale. */ +<<<<<<< HEAD + domain(values: D[]): AbstractScale; +======= domain(values: D[]): Scale; +>>>>>>> develop _getDomain(): any[]; _setDomain(values: D[]): void; /** @@ -1065,14 +1259,22 @@ declare module Plottable { * @param {R[]} values If provided, the new values for the range. * @returns {Scale} The calling Scale. */ +<<<<<<< HEAD + range(values: R[]): AbstractScale; +======= range(values: R[]): Scale; +>>>>>>> develop /** * Constructs a copy of the Scale with the same domain and range but without * any registered listeners. * * @returns {Scale} A copy of the calling Scale. */ +<<<<<<< HEAD + copy(): AbstractScale; +======= copy(): Scale; +>>>>>>> develop /** * When a renderer determines that the extent of a projector has changed, * it will call this function. This function should ensure that @@ -1083,26 +1285,39 @@ declare module Plottable { * @param {string} attr The attribute being projected, e.g. "x", "y0", "r" * @param {D[]} extent The new extent to be included in the scale. */ +<<<<<<< HEAD + _updateExtent(plotProvidedKey: string, attr: string, extent: D[]): AbstractScale; + _removeExtent(plotProvidedKey: string, attr: string): AbstractScale; +======= _updateExtent(plotProvidedKey: string, attr: string, extent: D[]): Scale; _removeExtent(plotProvidedKey: string, attr: string): Scale; +>>>>>>> develop } } } declare module Plottable { +<<<<<<< HEAD + module Scale { + class AbstractQuantitative extends AbstractScale { +======= module Abstract { interface TickGenerator { (scale: QuantitativeScale): D[]; } class QuantitativeScale extends Scale { +>>>>>>> develop _d3Scale: D3.Scale.QuantitativeScale; _numTicks: number; _PADDING_FOR_IDENTICAL_DOMAIN: number; _userSetDomainer: boolean; _domainer: Domainer; _typeCoercer: (d: any) => number; +<<<<<<< HEAD +======= _tickGenerator: TickGenerator; +>>>>>>> develop /** * Constructs a new QuantitativeScale. * @@ -1123,6 +1338,15 @@ declare module Plottable { */ invert(value: number): D; /** +<<<<<<< HEAD + * Creates a copy of the QuantitativeScale with the same domain and range but without any registered list. + * + * @returns {AbstractQuantitative} A copy of the calling QuantitativeScale. + */ + copy(): AbstractQuantitative; + domain(): D[]; + domain(values: D[]): AbstractQuantitative; +======= * Creates a copy of the QuantitativeScale with the same domain and range but without any registered listeners. * * @returns {QuantitativeScale} A copy of the calling QuantitativeScale. @@ -1130,25 +1354,37 @@ declare module Plottable { copy(): QuantitativeScale; domain(): D[]; domain(values: D[]): QuantitativeScale; +>>>>>>> develop _setDomain(values: D[]): void; /** * Sets or gets the QuantitativeScale's output interpolator * * @param {D3.Transition.Interpolate} [factory] The output interpolator to use. +<<<<<<< HEAD + * @returns {D3.Transition.Interpolate|AbstractQuantitative} The current output interpolator, or the calling QuantitativeScale. + */ + interpolate(): D3.Transition.Interpolate; + interpolate(factory: D3.Transition.Interpolate): AbstractQuantitative; +======= * @returns {D3.Transition.Interpolate|QuantitativeScale} The current output interpolator, or the calling QuantitativeScale. */ interpolate(): D3.Transition.Interpolate; interpolate(factory: D3.Transition.Interpolate): QuantitativeScale; +>>>>>>> develop /** * Sets the range of the QuantitativeScale and sets the interpolator to d3.interpolateRound. * * @param {number[]} values The new range value for the range. */ +<<<<<<< HEAD + rangeRound(values: number[]): AbstractQuantitative; +======= rangeRound(values: number[]): QuantitativeScale; /** * Gets ticks generated by the default algorithm. */ getDefaultTicks(): D[]; +>>>>>>> develop /** * Gets the clamp status of the QuantitativeScale (whether to cut off values outside the ouput range). * @@ -1159,6 +1395,20 @@ declare module Plottable { * Sets the clamp status of the QuantitativeScale (whether to cut off values outside the ouput range). * * @param {boolean} clamp Whether or not to clamp the QuantitativeScale. +<<<<<<< HEAD + * @returns {AbstractQuantitative} The calling QuantitativeScale. + */ + clamp(clamp: boolean): AbstractQuantitative; + /** + * Gets a set of tick values spanning the domain. + * + * @param {number} [count] The approximate number of ticks to generate. + * If not supplied, the number specified by + * numTicks() is used instead. + * @returns {any[]} The generated ticks. + */ + ticks(count?: number): any[]; +======= * @returns {QuantitativeScale} The calling QuantitativeScale. */ clamp(clamp: boolean): QuantitativeScale; @@ -1168,6 +1418,7 @@ declare module Plottable { * @returns {any[]} The generated ticks. */ ticks(): any[]; +>>>>>>> develop /** * Gets the default number of ticks. * @@ -1178,9 +1429,15 @@ declare module Plottable { * Sets the default number of ticks to generate. * * @param {number} count The new default number of ticks. +<<<<<<< HEAD + * @returns {Quantitative} The calling QuantitativeScale. + */ + numTicks(count: number): AbstractQuantitative; +======= * @returns {Scale} The calling Scale. */ numTicks(count: number): QuantitativeScale; +>>>>>>> develop /** * Given a domain, expands its domain onto "nice" values, e.g. whole * numbers. @@ -1202,6 +1459,12 @@ declare module Plottable { * includes 0, etc., will be the responsability of the new domainer. * * @param {Domainer} domainer If provided, the new domainer. +<<<<<<< HEAD + * @return {AbstractQuantitative} The calling QuantitativeScale. + */ + domainer(domainer: Domainer): AbstractQuantitative; + _defaultExtent(): any[]; +======= * @return {QuanitativeScale} The calling QuantitativeScale. */ domainer(domainer: Domainer): QuantitativeScale; @@ -1219,6 +1482,7 @@ declare module Plottable { * @return {QuanitativeScale} The calling QuantitativeScale. */ tickGenerator(generator: TickGenerator): QuantitativeScale; +>>>>>>> develop } } } @@ -1226,7 +1490,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class Linear extends AbstractQuantitative { +======= class Linear extends Abstract.QuantitativeScale { +>>>>>>> develop /** * Constructs a new LinearScale. * @@ -1239,10 +1507,17 @@ declare module Plottable { constructor(); constructor(scale: D3.Scale.LinearScale); /** +<<<<<<< HEAD + * Constructs a copy of the LinearScale with the same domain and range but + * without any registered listeners. + * + * @returns {Linear} A copy of the calling LinearScale. +======= * Constructs a copy of the Scale.Linear with the same domain and range but * without any registered listeners. * * @returns {Linear} A copy of the calling Scale.Linear. +>>>>>>> develop */ copy(): Linear; } @@ -1252,7 +1527,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class Log extends AbstractQuantitative { +======= class Log extends Abstract.QuantitativeScale { +>>>>>>> develop /** * Constructs a new Scale.Log. * @@ -1281,7 +1560,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class ModifiedLog extends AbstractQuantitative { +======= class ModifiedLog extends Abstract.QuantitativeScale { +>>>>>>> develop /** * Creates a new Scale.ModifiedLog. * @@ -1338,7 +1621,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class Ordinal extends AbstractScale { +======= class Ordinal extends Abstract.Scale { +>>>>>>> develop _d3Scale: D3.Scale.OrdinalScale; _typeCoercer: (d: any) => any; /** @@ -1391,7 +1678,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class Color extends AbstractScale { +======= class Color extends Abstract.Scale { +>>>>>>> develop /** * Constructs a ColorScale. * @@ -1409,7 +1700,11 @@ declare module Plottable { declare module Plottable { module Scale { +<<<<<<< HEAD + class Time extends AbstractQuantitative { +======= class Time extends Abstract.QuantitativeScale { +>>>>>>> develop _typeCoercer: (d: any) => any; /** * Constructs a TimeScale. @@ -1439,7 +1734,11 @@ declare module Plottable { * * By default it generates a linear scale internally. */ +<<<<<<< HEAD + class InterpolatedColor extends AbstractScale { +======= class InterpolatedColor extends Abstract.Scale { +>>>>>>> develop /** * Constructs an InterpolatedColorScale. * @@ -1499,16 +1798,26 @@ declare module Plottable { * @constructor * @param {Scale[]} scales A list of scales whose domains should be linked. */ +<<<<<<< HEAD + constructor(scales: Scale.AbstractScale[]); + rescale(scale: Scale.AbstractScale): void; +======= constructor(scales: Abstract.Scale[]); rescale(scale: Abstract.Scale): void; +>>>>>>> develop } } } declare module Plottable { +<<<<<<< HEAD + module _Drawer { + class AbstractDrawer { +======= module Abstract { class _Drawer { +>>>>>>> develop _renderArea: D3.Selection; key: string; /** @@ -1526,9 +1835,15 @@ declare module Plottable { * Draws the data into the renderArea using the attrHash for attributes * * @param{any[]} data The data to be drawn +<<<<<<< HEAD + * @param{attrHash} AttributeToProjector The list of attributes to set on the data + */ + draw(data: any[], attrToProjector: AttributeToProjector, animator?: Animator.Null): void; +======= * @param{attrHash} IAttributeToProjector The list of attributes to set on the data */ draw(data: any[], attrToProjector: IAttributeToProjector, animator?: Animator.Null): void; +>>>>>>> develop } } } @@ -1536,8 +1851,13 @@ declare module Plottable { declare module Plottable { module _Drawer { +<<<<<<< HEAD + class Arc extends AbstractDrawer { + draw(data: any[], attrToProjector: AttributeToProjector, animator?: Animator.Null): void; +======= class Arc extends Abstract._Drawer { draw(data: any[], attrToProjector: IAttributeToProjector, animator?: Animator.Null): void; +>>>>>>> develop } } } @@ -1545,8 +1865,13 @@ declare module Plottable { declare module Plottable { module _Drawer { +<<<<<<< HEAD + class Area extends AbstractDrawer { + draw(data: any[], attrToProjector: AttributeToProjector): void; +======= class Area extends Abstract._Drawer { draw(data: any[], attrToProjector: IAttributeToProjector): void; +>>>>>>> develop } } } @@ -1554,23 +1879,37 @@ declare module Plottable { declare module Plottable { module _Drawer { +<<<<<<< HEAD + class Rect extends AbstractDrawer { + draw(data: any[], attrToProjector: AttributeToProjector, animator?: Animator.Null): void; +======= class Rect extends Abstract._Drawer { draw(data: any[], attrToProjector: IAttributeToProjector, animator?: Animator.Null): void; +>>>>>>> develop } } } declare module Plottable { +<<<<<<< HEAD + module Component { + class AbstractComponent extends Core.PlottableObject { +======= module Abstract { class Component extends PlottableObject { +>>>>>>> develop static AUTORESIZE_BY_DEFAULT: boolean; _element: D3.Selection; _content: D3.Selection; _backgroundContainer: D3.Selection; _foregroundContainer: D3.Selection; clipPathEnabled: boolean; +<<<<<<< HEAD + _parent: AbstractComponentContainer; +======= _parent: ComponentContainer; +>>>>>>> develop _xAlignProportion: number; _yAlignProportion: number; _fixedHeightFlag: boolean; @@ -1589,7 +1928,11 @@ declare module Plottable { * Override in subclasses to provide additional functionality. */ _setup(): void; +<<<<<<< HEAD + _requestedSpace(availableWidth: number, availableHeight: number): _SpaceRequest; +======= _requestedSpace(availableWidth: number, availableHeight: number): _ISpaceRequest; +>>>>>>> develop /** * Computes the size, position, and alignment from the specified values. * If no parameters are supplied and the component is a root node, @@ -1611,8 +1954,13 @@ declare module Plottable { * @param {String|D3.Selection} element A D3 selection or a selector for getting the element to render into. * @returns {Component} The calling component. */ +<<<<<<< HEAD + renderTo(selector: String): AbstractComponent; + renderTo(element: D3.Selection): AbstractComponent; +======= renderTo(selector: String): Component; renderTo(element: D3.Selection): Component; +>>>>>>> develop /** * Causes the Component to recompute layout and redraw. If passed arguments, will resize the root SVG it lives in. * @@ -1623,7 +1971,11 @@ declare module Plottable { * @param {number} [availableHeight] - the height of the container element * @returns {Component} The calling component. */ +<<<<<<< HEAD + resize(width?: number, height?: number): AbstractComponent; +======= resize(width?: number, height?: number): Component; +>>>>>>> develop /** * Enables or disables resize on window resizes. * @@ -1634,7 +1986,11 @@ declare module Plottable { * @param {boolean} flag Enable (true) or disable (false) auto-resize. * @returns {Component} The calling component. */ +<<<<<<< HEAD + autoResize(flag: boolean): AbstractComponent; +======= autoResize(flag: boolean): Component; +>>>>>>> develop /** * Sets the x alignment of the Component. This will be used if the * Component is given more space than it needs. @@ -1646,7 +2002,11 @@ declare module Plottable { * @param {string} alignment The x alignment of the Component (one of ["left", "center", "right"]). * @returns {Component} The calling Component. */ +<<<<<<< HEAD + xAlign(alignment: string): AbstractComponent; +======= xAlign(alignment: string): Component; +>>>>>>> develop /** * Sets the y alignment of the Component. This will be used if the * Component is given more space than it needs. @@ -1658,7 +2018,11 @@ declare module Plottable { * @param {string} alignment The x alignment of the Component (one of ["top", "center", "bottom"]). * @returns {Component} The calling Component. */ +<<<<<<< HEAD + yAlign(alignment: string): AbstractComponent; +======= yAlign(alignment: string): Component; +>>>>>>> develop /** * Sets the x offset of the Component. This will be used if the Component * is given more space than it needs. @@ -1667,7 +2031,11 @@ declare module Plottable { * side of the container. * @returns {Component} The calling Component. */ +<<<<<<< HEAD + xOffset(offset: number): AbstractComponent; +======= xOffset(offset: number): Component; +>>>>>>> develop /** * Sets the y offset of the Component. This will be used if the Component * is given more space than it needs. @@ -1676,14 +2044,22 @@ declare module Plottable { * side of the container. * @returns {Component} The calling Component. */ +<<<<<<< HEAD + yOffset(offset: number): AbstractComponent; +======= yOffset(offset: number): Component; +>>>>>>> develop /** * Attaches an Interaction to the Component, so that the Interaction will listen for events on the Component. * * @param {Interaction} interaction The Interaction to attach to the Component. * @returns {Component} The calling Component. */ +<<<<<<< HEAD + registerInteraction(interaction: Interaction.AbstractInteraction): AbstractComponent; +======= registerInteraction(interaction: Interaction): Component; +>>>>>>> develop /** * Adds/removes a given CSS class to/from the Component, or checks if the Component has a particular CSS class. * @@ -1692,7 +2068,11 @@ declare module Plottable { * @returns {boolean|Component} Whether the Component has the given CSS class, or the calling Component (if addClass is supplied). */ classed(cssClass: string): boolean; +<<<<<<< HEAD + classed(cssClass: string, addClass: boolean): AbstractComponent; +======= classed(cssClass: string, addClass: boolean): Component; +>>>>>>> develop /** * Checks if the Component has a fixed width or false if it grows to fill available space. * Returns false by default on the base Component class. @@ -1720,7 +2100,11 @@ declare module Plottable { * @param {Component} c The component to merge in. * @returns {ComponentGroup} The relevant ComponentGroup out of the above four cases. */ +<<<<<<< HEAD + merge(c: AbstractComponent): Group; +======= merge(c: Component): Component.Group; +>>>>>>> develop /** * Detaches a Component from the DOM. The component can be reused. * @@ -1729,7 +2113,11 @@ declare module Plottable { * * @returns The calling Component. */ +<<<<<<< HEAD + detach(): AbstractComponent; +======= detach(): Component; +>>>>>>> develop /** * Removes a Component from the DOM and disconnects it from everything it's * listening to (effectively destroying it). @@ -1753,6 +2141,15 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Component { + class AbstractComponentContainer extends AbstractComponent { + _components: AbstractComponent[]; + _anchor(element: D3.Selection): void; + _render(): void; + _removeComponent(c: AbstractComponent): void; + _addComponent(c: AbstractComponent, prepend?: boolean): boolean; +======= module Abstract { class ComponentContainer extends Component { _components: Component[]; @@ -1760,12 +2157,17 @@ declare module Plottable { _render(): void; _removeComponent(c: Component): void; _addComponent(c: Component, prepend?: boolean): boolean; +>>>>>>> develop /** * Returns a list of components in the ComponentContainer. * * @returns {Component[]} the contained Components */ +<<<<<<< HEAD + components(): AbstractComponent[]; +======= components(): Component[]; +>>>>>>> develop /** * Returns true iff the ComponentContainer is empty. * @@ -1778,7 +2180,11 @@ declare module Plottable { * * @returns {ComponentContainer} The calling ComponentContainer */ +<<<<<<< HEAD + detachAll(): AbstractComponentContainer; +======= detachAll(): ComponentContainer; +>>>>>>> develop remove(): void; } } @@ -1787,7 +2193,11 @@ declare module Plottable { declare module Plottable { module Component { +<<<<<<< HEAD + class Group extends AbstractComponentContainer { +======= class Group extends Abstract.ComponentContainer { +>>>>>>> develop /** * Constructs a GroupComponent. * @@ -1798,9 +2208,15 @@ declare module Plottable { * @constructor * @param {Component[]} components The Components in the Group (default = []). */ +<<<<<<< HEAD + constructor(components?: AbstractComponent[]); + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; + merge(c: AbstractComponent): Group; +======= constructor(components?: Abstract.Component[]); _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; merge(c: Abstract.Component): Group; +>>>>>>> develop _computeLayout(xOrigin?: number, yOrigin?: number, availableWidth?: number, availableHeight?: number): Group; _isFixedWidth(): boolean; _isFixedHeight(): boolean; @@ -1810,8 +2226,13 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Axis { + class AbstractAxis extends Component.AbstractComponent { +======= module Abstract { class Axis extends Component { +>>>>>>> develop /** * The css class applied to each end tick mark (the line on the end tick). */ @@ -1827,7 +2248,11 @@ declare module Plottable { _tickMarkContainer: D3.Selection; _tickLabelContainer: D3.Selection; _baseline: D3.Selection; +<<<<<<< HEAD + _scale: Scale.AbstractScale; +======= _scale: Scale; +>>>>>>> develop _formatter: Formatter; _orientation: string; _computedWidth: number; @@ -1843,12 +2268,20 @@ declare module Plottable { * @param {Formatter} Data is passed through this formatter before being * displayed. */ +<<<<<<< HEAD + constructor(scale: Scale.AbstractScale, orientation: string, formatter?: (d: any) => string); +======= constructor(scale: Scale, orientation: string, formatter?: (d: any) => string); +>>>>>>> develop remove(): void; _isHorizontal(): boolean; _computeWidth(): number; _computeHeight(): number; +<<<<<<< HEAD + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; +======= _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; +>>>>>>> develop _isFixedHeight(): boolean; _isFixedWidth(): boolean; _rescale(): void; @@ -1869,6 +2302,10 @@ declare module Plottable { y2: any; }; _invalidateLayout(): void; +<<<<<<< HEAD + _setDefaultAlignment(): void; +======= +>>>>>>> develop /** * Gets the current formatter on the axis. Data is passed through the * formatter before being displayed. @@ -1884,7 +2321,11 @@ declare module Plottable { * @param {Formatter} formatter If provided, data will be passed though `formatter(data)`. * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + formatter(formatter: Formatter): AbstractAxis; +======= formatter(formatter: Formatter): Axis; +>>>>>>> develop /** * Gets the current tick mark length. * @@ -1897,7 +2338,11 @@ declare module Plottable { * @param {number} length If provided, length of each tick. * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + tickLength(length: number): AbstractAxis; +======= tickLength(length: number): Axis; +>>>>>>> develop /** * Gets the current end tick mark length. * @@ -1910,7 +2355,11 @@ declare module Plottable { * @param {number} length If provided, the length of the end ticks. * @returns {BaseAxis} The calling Axis. */ +<<<<<<< HEAD + endTickLength(length: number): AbstractAxis; +======= endTickLength(length: number): Axis; +>>>>>>> develop _maxLabelTickLength(): number; /** * Gets the padding between each tick mark and its associated label. @@ -1925,7 +2374,11 @@ declare module Plottable { * @param {number} padding If provided, the desired padding. * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + tickLabelPadding(padding: number): AbstractAxis; +======= tickLabelPadding(padding: number): Axis; +>>>>>>> develop /** * Gets the size of the gutter (the extra space between the tick * labels and the outer edge of the axis). @@ -1941,7 +2394,11 @@ declare module Plottable { * @param {number} size If provided, the desired gutter. * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + gutter(size: number): AbstractAxis; +======= gutter(size: number): Axis; +>>>>>>> develop /** * Gets the orientation of the Axis. * @@ -1955,7 +2412,11 @@ declare module Plottable { * (top/bottom/left/right). * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + orient(newOrientation: string): AbstractAxis; +======= orient(newOrientation: string): Axis; +>>>>>>> develop /** * Gets whether the Axis is currently set to show the first and last * tick labels. @@ -1972,7 +2433,11 @@ declare module Plottable { * labels. * @returns {Axis} The calling Axis. */ +<<<<<<< HEAD + showEndTickLabels(show: boolean): AbstractAxis; +======= showEndTickLabels(show: boolean): Axis; +>>>>>>> develop _hideEndTickLabels(): void; _hideOverlappingTickLabels(): void; } @@ -1982,17 +2447,30 @@ declare module Plottable { declare module Plottable { module Axis { +<<<<<<< HEAD + interface _TimeInterval { +======= interface _ITimeInterval { +>>>>>>> develop timeUnit: D3.Time.Interval; step: number; formatString: string; } +<<<<<<< HEAD + class Time extends AbstractAxis { + _majorTickLabels: D3.Selection; + _minorTickLabels: D3.Selection; + _scale: Scale.Time; + static _minorIntervals: _TimeInterval[]; + static _majorIntervals: _TimeInterval[]; +======= class Time extends Abstract.Axis { _majorTickLabels: D3.Selection; _minorTickLabels: D3.Selection; _scale: Scale.Time; static _minorIntervals: _ITimeInterval[]; static _majorIntervals: _ITimeInterval[]; +>>>>>>> develop /** * Constructs a TimeAxis. * @@ -2005,7 +2483,11 @@ declare module Plottable { constructor(scale: Scale.Time, orientation: string); _computeHeight(): number; _setup(): void; +<<<<<<< HEAD + _getTickIntervalValues(interval: _TimeInterval): any[]; +======= _getTickIntervalValues(interval: _ITimeInterval): any[]; +>>>>>>> develop _getTickValues(): any[]; _measureTextHeight(container: D3.Selection): number; _doRender(): Time; @@ -2016,8 +2498,13 @@ declare module Plottable { declare module Plottable { module Axis { +<<<<<<< HEAD + class Numeric extends AbstractAxis { + _scale: Scale.AbstractQuantitative; +======= class Numeric extends Abstract.Axis { _scale: Abstract.QuantitativeScale; +>>>>>>> develop /** * Constructs a NumericAxis. * @@ -2029,7 +2516,11 @@ declare module Plottable { * @param {string} orientation The orientation of the QuantitativeScale (top/bottom/left/right) * @param {Formatter} formatter A function to format tick labels (default Formatters.general(3, false)). */ +<<<<<<< HEAD + constructor(scale: Scale.AbstractQuantitative, orientation: string, formatter?: (d: any) => string); +======= constructor(scale: Abstract.QuantitativeScale, orientation: string, formatter?: (d: any) => string); +>>>>>>> develop _setup(): void; _computeWidth(): number; _computeHeight(): number; @@ -2083,7 +2574,11 @@ declare module Plottable { declare module Plottable { module Axis { +<<<<<<< HEAD + class Category extends AbstractAxis { +======= class Category extends Abstract.Axis { +>>>>>>> develop _scale: Scale.Ordinal; /** * Constructs a CategoryAxis. @@ -2100,8 +2595,27 @@ declare module Plottable { constructor(scale: Scale.Ordinal, orientation?: string, formatter?: (d: any) => string); _setup(): void; _rescale(): void; +<<<<<<< HEAD + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; + _getTickValues(): string[]; + /** + * Sets the angle for the tick labels. Right now vertical-left (-90), horizontal (0), and vertical-right (90) are the only options. + * @param {number} angle The angle for the ticks + * @returns {Category} The calling Category Axis. + * + * Warning - this is not currently well supported and is likely to behave badly unless all the tick labels are short. + * See tracking at https://github.com/palantir/plottable/issues/504 + */ + tickLabelAngle(angle: number): Category; + /** + * Gets the tick label angle + * @returns {number} the tick label angle + */ + tickLabelAngle(): number; +======= _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; _getTickValues(): string[]; +>>>>>>> develop _doRender(): Category; _computeLayout(xOrigin?: number, yOrigin?: number, availableWidth?: number, availableHeight?: number): void; } @@ -2111,7 +2625,11 @@ declare module Plottable { declare module Plottable { module Component { +<<<<<<< HEAD + class Label extends AbstractComponent { +======= class Label extends Abstract.Component { +>>>>>>> develop /** * Creates a Label. * @@ -2120,7 +2638,11 @@ declare module Plottable { * * @constructor * @param {string} displayText The text of the Label (default = ""). +<<<<<<< HEAD + * @param {string} orientation The orientation of the Label (horizontal/left/right) (default = "horizontal"). +======= * @param {string} orientation The orientation of the Label (horizontal/vertical-left/vertical-right) (default = "horizontal"). +>>>>>>> develop */ constructor(displayText?: string, orientation?: string); /** @@ -2139,7 +2661,11 @@ declare module Plottable { * @returns {Label} The calling Label. */ yAlign(alignment: string): Label; +<<<<<<< HEAD + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; +======= _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; +>>>>>>> develop _setup(): void; /** * Gets the current text on the Label. @@ -2164,7 +2690,11 @@ declare module Plottable { * Sets the orientation of the Label. * * @param {string} newOrientation If provided, the desired orientation +<<<<<<< HEAD + * (horizontal/left/right). +======= * (horizontal/vertical-left/vertical-right). +>>>>>>> develop * @returns {Label} The calling Label. */ orient(newOrientation: string): Label; @@ -2199,7 +2729,11 @@ declare module Plottable { interface HoverCallback { (datum?: string): any; } +<<<<<<< HEAD + class Legend extends AbstractComponent { +======= class Legend extends Abstract.Component { +>>>>>>> develop /** * The css class applied to each legend row */ @@ -2277,7 +2811,11 @@ declare module Plottable { */ scale(scale: Scale.Color): Legend; _computeLayout(xOrigin?: number, yOrigin?: number, availableWidth?: number, availableHeight?: number): void; +<<<<<<< HEAD + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; +======= _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; +>>>>>>> develop _doRender(): void; } } @@ -2286,7 +2824,11 @@ declare module Plottable { declare module Plottable { module Component { +<<<<<<< HEAD + class HorizontalLegend extends AbstractComponent { +======= class HorizontalLegend extends Abstract.Component { +>>>>>>> develop /** * The css class applied to each legend row */ @@ -2306,7 +2848,11 @@ declare module Plottable { */ constructor(colorScale: Scale.Color); remove(): void; +<<<<<<< HEAD + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; +======= _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; +>>>>>>> develop _doRender(): void; } } @@ -2315,7 +2861,11 @@ declare module Plottable { declare module Plottable { module Component { +<<<<<<< HEAD + class Gridlines extends AbstractComponent { +======= class Gridlines extends Abstract.Component { +>>>>>>> develop /** * Creates a set of Gridlines. * @constructor @@ -2323,7 +2873,11 @@ declare module Plottable { * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. * @param {QuantitativeScale} yScale The scale to base the y gridlines on. Pass null if no gridlines are desired. */ +<<<<<<< HEAD + constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractQuantitative); +======= constructor(xScale: Abstract.QuantitativeScale, yScale: Abstract.QuantitativeScale); +>>>>>>> develop remove(): Gridlines; _setup(): void; _doRender(): void; @@ -2342,7 +2896,11 @@ declare module Plottable { wantsWidth: boolean; wantsHeight: boolean; } +<<<<<<< HEAD + class Table extends AbstractComponentContainer { +======= class Table extends Abstract.ComponentContainer { +>>>>>>> develop /** * Constructs a Table. * @@ -2357,7 +2915,11 @@ declare module Plottable { * @param {Component[][]} [rows] A 2-D array of the Components to place in the table. * null can be used if a cell is empty. (default = []) */ +<<<<<<< HEAD + constructor(rows?: AbstractComponent[][]); +======= constructor(rows?: Abstract.Component[][]); +>>>>>>> develop /** * Adds a Component in the specified cell. The cell must be unoccupied. * @@ -2375,9 +2937,15 @@ declare module Plottable { * @param {Component} component The Component to be added. * @returns {Table} The calling Table. */ +<<<<<<< HEAD + addComponent(row: number, col: number, component: AbstractComponent): Table; + _removeComponent(component: AbstractComponent): void; + _requestedSpace(offeredWidth: number, offeredHeight: number): _SpaceRequest; +======= addComponent(row: number, col: number, component: Abstract.Component): Table; _removeComponent(component: Abstract.Component): void; _requestedSpace(offeredWidth: number, offeredHeight: number): _ISpaceRequest; +>>>>>>> develop _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; /** * Sets the row and column padding on the Table. @@ -2419,6 +2987,20 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Plot { + class AbstractPlot extends Component.AbstractComponent { + _dataChanged: boolean; + _key2DatasetDrawerKey: D3.Map; + _datasetKeysInOrder: string[]; + _renderArea: D3.Selection; + _projectors: { + [x: string]: _Projector; + }; + _animate: boolean; + _animators: Animator.PlotAnimatorMap; + _ANIMATION_DURATION: number; +======= module Abstract { class Plot extends Component { _dataset: Dataset; @@ -2430,6 +3012,7 @@ declare module Plottable { _projectors: { [x: string]: _IProjector; }; +>>>>>>> develop /** * Constructs a Plot. * @@ -2442,6 +3025,27 @@ declare module Plottable { * @param {any[]|Dataset} [dataset] If provided, the data or Dataset to be associated with this Plot. */ constructor(); +<<<<<<< HEAD + _anchor(element: D3.Selection): void; + _setup(): void; + remove(): void; + /** + * Adds a dataset to this plot. Identify this dataset with a key. + * + * A key is automatically generated if not supplied. + * + * @param {string} [key] The key of the dataset. + * @param {any[]|Dataset} dataset dataset to add. + * @returns {Plot} The calling Plot. + */ + addDataset(key: string, dataset: Dataset): AbstractPlot; + addDataset(key: string, dataset: any[]): AbstractPlot; + addDataset(dataset: Dataset): AbstractPlot; + addDataset(dataset: any[]): AbstractPlot; + _addDataset(key: string, dataset: Dataset): void; + _getDrawer(key: string): _Drawer.AbstractDrawer; + _getAnimator(drawer: _Drawer.AbstractDrawer, index: number): Animator.PlotAnimator; +======= constructor(data: any[]); constructor(dataset: Dataset); _anchor(element: D3.Selection): void; @@ -2459,6 +3063,7 @@ declare module Plottable { * @returns {Plot} The calling Plot. */ dataset(dataset: Dataset): Plot; +>>>>>>> develop _onDatasetUpdate(): void; /** * Sets an attribute of every data point. @@ -2478,11 +3083,24 @@ declare module Plottable { * `d[accessor]` is used. If anything else, use `accessor` as a constant * across all data points. * +<<<<<<< HEAD + * @param {Scale.AbstractScale} scale If provided, the result of the accessor +======= * @param {Abstract.Scale} scale If provided, the result of the accessor +>>>>>>> develop * is passed through the scale, such as `scale.scale(accessor(d, i))`. * * @returns {Plot} The calling Plot. */ +<<<<<<< HEAD + attr(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): AbstractPlot; + /** + * Identical to plot.attr + */ + project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): AbstractPlot; + _generateAttrToProjector(): AttributeToProjector; + _doRender(): void; +======= attr(attrToSet: string, accessor: any, scale?: Scale): Plot; /** * Identical to plot.attr @@ -2492,13 +3110,19 @@ declare module Plottable { _doRender(): void; _paint(): void; _setup(): void; +>>>>>>> develop /** * Enables or disables animation. * * @param {boolean} enabled Whether or not to animate. */ +<<<<<<< HEAD + animate(enabled: boolean): AbstractPlot; + detach(): AbstractPlot; +======= animate(enabled: boolean): Plot; detach(): Plot; +>>>>>>> develop /** * This function makes sure that all of the scales in this._projectors * have an extent that includes all the data that is projected onto them. @@ -2516,6 +3140,18 @@ declare module Plottable { * * @param {D3.Selection} selection The selection of elements to update. * @param {string} animatorKey The key for the animator. +<<<<<<< HEAD + * @param {AttributeToProjector} attrToProjector The set of attributes to set on the selection. + * @returns {D3.Selection} The resulting selection (potentially after the transition) + */ + _applyAnimatedAttributes(selection: any, animatorKey: string, attrToProjector: AttributeToProjector): any; + /** + * Get the animator associated with the specified Animator key. + * + * @return {PlotAnimator} The Animator for the specified key. + */ + animator(animatorKey: string): Animator.PlotAnimator; +======= * @param {IAttributeToProjector} attrToProjector The set of attributes to set on the selection. * @returns {D3.Selection} The resulting selection (potentially after the transition) */ @@ -2526,15 +3162,64 @@ declare module Plottable { * @return {IPlotAnimator} The Animator for the specified key. */ animator(animatorKey: string): Animator.IPlotAnimator; +>>>>>>> develop /** * Set the animator associated with the specified Animator key. * * @param {string} animatorKey The key for the Animator. +<<<<<<< HEAD + * @param {PlotAnimator} animator An Animator to be assigned to + * the specified key. + * @returns {Plot} The calling Plot. + */ + animator(animatorKey: string, animator: Animator.PlotAnimator): AbstractPlot; + /** + * Gets the dataset order by key + * + * @returns {string[]} A string array of the keys in order + */ + datasetOrder(): string[]; + /** + * Sets the dataset order by key + * + * @param {string[]} order If provided, a string array which represents the order of the keys. + * This must be a permutation of existing keys. + * + * @returns {Plot} The calling Plot. + */ + datasetOrder(order: string[]): AbstractPlot; + /** + * Removes a dataset by string key + * + * @param {string} key The key of the dataset + * @return {Plot} The calling Plot. + */ + removeDataset(key: string): AbstractPlot; + /** + * Remove a dataset given the dataset itself + * + * @param {Dataset} dataset The dataset to remove + * @return {Plot} The calling Plot. + */ + removeDataset(dataset: Dataset): AbstractPlot; + /** + * Remove a dataset given the underlying data array + * + * @param {any[]} dataArray The data to remove + * @return {Plot} The calling Plot. + */ + removeDataset(dataArray: any[]): AbstractPlot; + _removeDataset(key: string): AbstractPlot; + datasets(): Dataset[]; + _getDrawersInOrder(): _Drawer.AbstractDrawer[]; + _paint(): void; +======= * @param {IPlotAnimator} animator An Animator to be assigned to * the specified key. * @returns {Plot} The calling Plot. */ animator(animatorKey: string, animator: Animator.IPlotAnimator): Plot; +>>>>>>> develop } } } @@ -2542,15 +3227,25 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class Pie extends AbstractPlot { +======= class Pie extends Abstract.Plot { _key2DatasetDrawerKey: D3.Map; _datasetKeysInOrder: string[]; +>>>>>>> develop /** * Constructs a PiePlot. * * @constructor */ constructor(); +<<<<<<< HEAD + _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; + _addDataset(key: string, dataset: Dataset): void; + _generateAttrToProjector(): AttributeToProjector; + _getDrawer(key: string): _Drawer.AbstractDrawer; +======= _setup(): void; _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; /** @@ -2580,6 +3275,7 @@ declare module Plottable { _getDatasetsInOrder(): Dataset[]; _getDrawersInOrder(): Abstract._Drawer[]; _updateScaleExtent(attr: string): void; +>>>>>>> develop _paint(): void; } } @@ -2587,10 +3283,19 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Plot { + class AbstractXYPlot extends AbstractPlot { + _xScale: Scale.AbstractScale; + _yScale: Scale.AbstractScale; + _autoDomainXScale: boolean; + _autoDomainYScale: boolean; +======= module Abstract { class XYPlot extends Plot { _xScale: Scale; _yScale: Scale; +>>>>>>> develop /** * Constructs an XYPlot. * @@ -2602,11 +3307,41 @@ declare module Plottable { * @param {Scale} xScale The x scale to use. * @param {Scale} yScale The y scale to use. */ +<<<<<<< HEAD + constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale); +======= constructor(dataset: any, xScale: Scale, yScale: Scale); +>>>>>>> develop /** * @param {string} attrToSet One of ["x", "y"] which determines the point's * x and y position in the Plot. */ +<<<<<<< HEAD + project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): AbstractXYPlot; + /** + * Sets the auto domain to visible points for y scale. + * + * @param {boolean} autoDomain The new value for the auto domain for y scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + autoDomainYScale(autoDomain: boolean): AbstractXYPlot; + /** + * Sets the auto domain to visible points for x scale. + * + * @param {boolean} autoDomain The new value for the auto domain for x scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + autoDomainXScale(autoDomain: boolean): AbstractXYPlot; + _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; + _updateXDomainer(): void; + _updateYDomainer(): void; + /** + * Adjust both domains to show all datasets. + * + * This call does not override auto domain logic to visible points. + */ + showAllData(): void; +======= project(attrToSet: string, accessor: any, scale?: Scale): XYPlot; _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; _updateXDomainer(): void; @@ -2678,6 +3413,7 @@ declare module Plottable { _getDatasetsInOrder(): Dataset[]; _getDrawersInOrder(): _Drawer[]; _paint(): void; +>>>>>>> develop } } } @@ -2685,23 +3421,41 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class Scatter extends AbstractXYPlot { + _animators: Animator.PlotAnimatorMap; +======= class Scatter extends Abstract.XYPlot { _animators: Animator.IPlotAnimatorMap; +>>>>>>> develop /** * Constructs a ScatterPlot. * * @constructor +<<<<<<< HEAD + * @param {DatasetInterface | any} dataset The dataset to render. + * @param {Scale} xScale The x scale to use. + * @param {Scale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale); +======= * @param {IDataset | any} dataset The dataset to render. * @param {Scale} xScale The x scale to use. * @param {Scale} yScale The y scale to use. */ constructor(dataset: any, xScale: Abstract.Scale, yScale: Abstract.Scale); +>>>>>>> develop /** * @param {string} attrToSet One of ["x", "y", "cx", "cy", "r", * "fill"]. "cx" and "cy" are aliases for "x" and "y". "r" is the datum's * radius, and "fill" is the CSS color of the datum. */ +<<<<<<< HEAD + project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): Scatter; + _generateAttrToProjector(): AttributeToProjector; +======= project(attrToSet: string, accessor: any, scale?: Abstract.Scale): Scatter; +>>>>>>> develop _paint(): void; } } @@ -2710,11 +3464,19 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class Grid extends AbstractXYPlot { + _colorScale: Scale.AbstractScale; + _xScale: Scale.Ordinal; + _yScale: Scale.Ordinal; + _animators: Animator.PlotAnimatorMap; +======= class Grid extends Abstract.XYPlot { _colorScale: Abstract.Scale; _xScale: Scale.Ordinal; _yScale: Scale.Ordinal; _animators: Animator.IPlotAnimatorMap; +>>>>>>> develop /** * Constructs a GridPlot. * @@ -2722,18 +3484,30 @@ declare module Plottable { * grid, and the datum can control what color it is. * * @constructor +<<<<<<< HEAD +======= * @param {IDataset | any} dataset The dataset to render. +>>>>>>> develop * @param {Scale.Ordinal} xScale The x scale to use. * @param {Scale.Ordinal} yScale The y scale to use. * @param {Scale.Color|Scale.InterpolatedColor} colorScale The color scale * to use for each grid cell. */ +<<<<<<< HEAD + constructor(xScale: Scale.Ordinal, yScale: Scale.Ordinal, colorScale: Scale.AbstractScale); + _addDataset(key: string, dataset: Dataset): void; +======= constructor(dataset: any, xScale: Scale.Ordinal, yScale: Scale.Ordinal, colorScale: Abstract.Scale); +>>>>>>> develop /** * @param {string} attrToSet One of ["x", "y", "fill"]. If "fill" is used, * the data should return a valid CSS color. */ +<<<<<<< HEAD + project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): Grid; +======= project(attrToSet: string, accessor: any, scale?: Abstract.Scale): Grid; +>>>>>>> develop _paint(): void; } } @@ -2741,6 +3515,27 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Plot { + class AbstractBarPlot extends AbstractXYPlot { + static _BarAlignmentToFactor: { + [x: string]: number; + }; + _baseline: D3.Selection; + _baselineValue: number; + _barAlignmentFactor: number; + _isVertical: boolean; + _animators: Animator.PlotAnimatorMap; + /** + * Constructs a BarPlot. + * + * @constructor + * @param {Scale} xScale The x scale to use. + * @param {Scale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale); + _getDrawer(key: string): _Drawer.Rect; +======= module Abstract { class BarPlot extends XYPlot { _bars: D3.UpdateSelection; @@ -2761,6 +3556,7 @@ declare module Plottable { * @param {Scale} yScale The y scale to use. */ constructor(dataset: any, xScale: Scale, yScale: Scale); +>>>>>>> develop _setup(): void; _paint(): void; /** @@ -2771,7 +3567,11 @@ declare module Plottable { * @param {number} value The value to position the baseline at. * @returns {AbstractBarPlot} The calling AbstractBarPlot. */ +<<<<<<< HEAD + baseline(value: number): AbstractBarPlot; +======= baseline(value: number): BarPlot; +>>>>>>> develop /** * Sets the bar alignment relative to the independent axis. * VerticalBarPlot supports "left", "center", "right" @@ -2780,31 +3580,54 @@ declare module Plottable { * @param {string} alignment The desired alignment. * @returns {AbstractBarPlot} The calling AbstractBarPlot. */ +<<<<<<< HEAD + barAlignment(alignment: string): AbstractBarPlot; + /** + * Selects the bar under the given pixel position (if [xValOrExtent] + * and [yValOrExtent] are {number}s), under a given line (if only one + * of [xValOrExtent] or [yValOrExtent] are {Extent}s) or are under a + * 2D area (if [xValOrExtent] and [yValOrExtent] are both {Extent}s). +======= barAlignment(alignment: string): BarPlot; /** * Selects the bar under the given pixel position (if [xValOrExtent] * and [yValOrExtent] are {number}s), under a given line (if only one * of [xValOrExtent] or [yValOrExtent] are {IExtent}s) or are under a * 2D area (if [xValOrExtent] and [yValOrExtent] are both {IExtent}s). +>>>>>>> develop * * @param {any} xValOrExtent The pixel x position, or range of x values. * @param {any} yValOrExtent The pixel y position, or range of y values. * @param {boolean} [select] Whether or not to select the bar (by classing it "selected"); * @returns {D3.Selection} The selected bar, or null if no bar was selected. */ +<<<<<<< HEAD + selectBar(xValOrExtent: Extent, yValOrExtent: Extent, select?: boolean): D3.Selection; + selectBar(xValOrExtent: number, yValOrExtent: Extent, select?: boolean): D3.Selection; + selectBar(xValOrExtent: Extent, yValOrExtent: number, select?: boolean): D3.Selection; +======= selectBar(xValOrExtent: IExtent, yValOrExtent: IExtent, select?: boolean): D3.Selection; selectBar(xValOrExtent: number, yValOrExtent: IExtent, select?: boolean): D3.Selection; selectBar(xValOrExtent: IExtent, yValOrExtent: number, select?: boolean): D3.Selection; +>>>>>>> develop selectBar(xValOrExtent: number, yValOrExtent: number, select?: boolean): D3.Selection; /** * Deselects all bars. * @returns {AbstractBarPlot} The calling AbstractBarPlot. */ +<<<<<<< HEAD + deselectAll(): AbstractBarPlot; + _updateDomainer(scale: Scale.AbstractScale): void; + _updateYDomainer(): void; + _updateXDomainer(): void; + _generateAttrToProjector(): AttributeToProjector; +======= deselectAll(): BarPlot; _updateDomainer(scale: Scale): void; _updateYDomainer(): void; _updateXDomainer(): void; _generateAttrToProjector(): IAttributeToProjector; +>>>>>>> develop } } } @@ -2821,7 +3644,11 @@ declare module Plottable { * - "x" - the horizontal position of a bar * - "y" - the vertical height of a bar */ +<<<<<<< HEAD + class VerticalBar extends AbstractBarPlot { +======= class VerticalBar extends Abstract.BarPlot { +>>>>>>> develop static _BarAlignmentToFactor: { [x: string]: number; }; @@ -2829,11 +3656,19 @@ declare module Plottable { * Constructs a VerticalBarPlot. * * @constructor +<<<<<<< HEAD + * @param {DatasetInterface | any} dataset The dataset to render. + * @param {Scale} xScale The x scale to use. + * @param {QuantitativeScale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractQuantitative); +======= * @param {IDataset | any} dataset The dataset to render. * @param {Scale} xScale The x scale to use. * @param {QuantitativeScale} yScale The y scale to use. */ constructor(dataset: any, xScale: Abstract.Scale, yScale: Abstract.QuantitativeScale); +>>>>>>> develop _updateYDomainer(): void; } } @@ -2851,7 +3686,11 @@ declare module Plottable { * - "x" - the horizontal length of a bar * - "y" - the vertical position of a bar */ +<<<<<<< HEAD + class HorizontalBar extends AbstractBarPlot { +======= class HorizontalBar extends Abstract.BarPlot { +>>>>>>> develop static _BarAlignmentToFactor: { [x: string]: number; }; @@ -2859,6 +3698,14 @@ declare module Plottable { * Constructs a HorizontalBarPlot. * * @constructor +<<<<<<< HEAD + * @param {QuantitativeScale} xScale The x scale to use. + * @param {Scale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractScale); + _updateXDomainer(): void; + _generateAttrToProjector(): AttributeToProjector; +======= * @param {IDataset | any} dataset The dataset to render. * @param {QuantitativeScale} xScale The x scale to use. * @param {Scale} yScale The y scale to use. @@ -2866,6 +3713,7 @@ declare module Plottable { constructor(dataset: any, xScale: Abstract.QuantitativeScale, yScale: Abstract.Scale); _updateXDomainer(): void; _generateAttrToProjector(): IAttributeToProjector; +>>>>>>> develop } } } @@ -2873,13 +3721,29 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class Line extends AbstractXYPlot { + _yScale: Scale.AbstractQuantitative; + _animators: Animator.PlotAnimatorMap; +======= class Line extends Abstract.XYPlot { _yScale: Abstract.QuantitativeScale; _animators: Animator.IPlotAnimatorMap; +>>>>>>> develop /** * Constructs a LinePlot. * * @constructor +<<<<<<< HEAD + * @param {any | DatasetInterface} dataset The dataset to render. + * @param {QuantitativeScale} xScale The x scale to use. + * @param {QuantitativeScale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractQuantitative); + _getResetYFunction(): (d: any, i: number) => number; + _generateAttrToProjector(): AttributeToProjector; + _rejectNullsAndNaNs(d: any, i: number, projector: AppliedAccessor): boolean; +======= * @param {any | IDataset} dataset The dataset to render. * @param {QuantitativeScale} xScale The x scale to use. * @param {QuantitativeScale} yScale The y scale to use. @@ -2889,6 +3753,7 @@ declare module Plottable { _appendPath(): void; _getResetYFunction(): (d: any, i: number) => number; _generateAttrToProjector(): IAttributeToProjector; +>>>>>>> develop _paint(): void; _wholeDatumAttributes(): string[]; } @@ -2906,6 +3771,17 @@ declare module Plottable { * Constructs an AreaPlot. * * @constructor +<<<<<<< HEAD + * @param {DatasetInterface | any} dataset The dataset to render. + * @param {QuantitativeScale} xScale The x scale to use. + * @param {QuantitativeScale} yScale The y scale to use. + */ + constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractQuantitative); + _onDatasetUpdate(): void; + _updateYDomainer(): void; + project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): Area; + _getResetYFunction(): AppliedAccessor; +======= * @param {IDataset | any} dataset The dataset to render. * @param {QuantitativeScale} xScale The x scale to use. * @param {QuantitativeScale} yScale The y scale to use. @@ -2916,6 +3792,7 @@ declare module Plottable { _updateYDomainer(): void; project(attrToSet: string, accessor: any, scale?: Abstract.Scale): Area; _getResetYFunction(): IAppliedAccessor; +>>>>>>> develop _paint(): void; _wholeDatumAttributes(): string[]; } @@ -2924,6 +3801,10 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Plot { + class ClusteredBar extends AbstractBarPlot { +======= module Abstract { class NewStyleBarPlot extends NewStylePlot { static _barAlignmentToFactor: { @@ -2966,6 +3847,7 @@ declare module Plottable { declare module Plottable { module Plot { class ClusteredBar extends Abstract.NewStyleBarPlot { +>>>>>>> develop /** * Creates a ClusteredBarPlot. * @@ -2977,8 +3859,13 @@ declare module Plottable { * @param {Scale} xScale The x scale to use. * @param {Scale} yScale The y scale to use. */ +<<<<<<< HEAD + constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale, isVertical?: boolean); + _generateAttrToProjector(): AttributeToProjector; +======= constructor(xScale: Abstract.Scale, yScale: Abstract.Scale, isVertical?: boolean); _generateAttrToProjector(): IAttributeToProjector; +>>>>>>> develop _paint(): void; } } @@ -2986,8 +3873,13 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Plot { + class AbstractStacked extends AbstractXYPlot { +======= module Abstract { class Stacked extends NewStylePlot { +>>>>>>> develop _isVertical: boolean; _onDatasetUpdate(): void; _updateScaleExtents(): void; @@ -2998,7 +3890,11 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class StackedArea extends AbstractStacked { +======= class StackedArea extends Abstract.Stacked { +>>>>>>> develop _baseline: D3.Selection; _baselineValue: number; /** @@ -3008,13 +3904,21 @@ declare module Plottable { * @param {QuantitativeScale} xScale The x scale to use. * @param {QuantitativeScale} yScale The y scale to use. */ +<<<<<<< HEAD + constructor(xScale: Scale.AbstractQuantitative, yScale: Scale.AbstractQuantitative); +======= constructor(xScale: Abstract.QuantitativeScale, yScale: Abstract.QuantitativeScale); +>>>>>>> develop _getDrawer(key: string): _Drawer.Area; _setup(): void; _paint(): void; _updateYDomainer(): void; _onDatasetUpdate(): void; +<<<<<<< HEAD + _generateAttrToProjector(): AttributeToProjector; +======= _generateAttrToProjector(): IAttributeToProjector; +>>>>>>> develop } } } @@ -3022,7 +3926,11 @@ declare module Plottable { declare module Plottable { module Plot { +<<<<<<< HEAD + class StackedBar extends AbstractStacked { +======= class StackedBar extends Abstract.Stacked { +>>>>>>> develop _baselineValue: number; _baseline: D3.Selection; _barAlignmentFactor: number; @@ -3035,14 +3943,24 @@ declare module Plottable { * @param {Scale} yScale the y scale of the plot. * @param {boolean} isVertical if the plot if vertical. */ +<<<<<<< HEAD + constructor(xScale?: Scale.AbstractScale, yScale?: Scale.AbstractScale, isVertical?: boolean); + _setup(): void; + _getAnimator(drawer: _Drawer.AbstractDrawer, index: number): Animator.MovingRect; +======= constructor(xScale?: Abstract.Scale, yScale?: Abstract.Scale, isVertical?: boolean); _setup(): void; _getAnimator(drawer: Abstract._Drawer, index: number): Animator.Rect; +>>>>>>> develop _getDrawer(key: string): any; _generateAttrToProjector(): any; _paint(): void; baseline(value: number): any; +<<<<<<< HEAD + _updateDomainer(scale: Scale.AbstractScale): any; +======= _updateDomainer(scale: Abstract.Scale): any; +>>>>>>> develop _updateXDomainer(): any; _updateYDomainer(): any; } @@ -3052,11 +3970,27 @@ declare module Plottable { declare module Plottable { module Animator { +<<<<<<< HEAD + interface PlotAnimator { +======= interface IPlotAnimator { +>>>>>>> develop /** * Applies the supplied attributes to a D3.Selection with some animation. * * @param {D3.Selection} selection The update selection or transition selection that we wish to animate. +<<<<<<< HEAD + * @param {AttributeToProjector} attrToProjector The set of + * IAccessors that we will use to set attributes on the selection. + * @return {any} Animators should return the selection or + * transition object so that plots may chain the transitions between + * animators. + */ + animate(selection: any, attrToProjector: AttributeToProjector): any; + } + interface PlotAnimatorMap { + [animatorKey: string]: PlotAnimator; +======= * @param {IAttributeToProjector} attrToProjector The set of * IAccessors that we will use to set attributes on the selection. * @return {D3.Selection} Animators should return the selection or @@ -3067,6 +4001,7 @@ declare module Plottable { } interface IPlotAnimatorMap { [animatorKey: string]: IPlotAnimator; +>>>>>>> develop } } } @@ -3078,8 +4013,13 @@ declare module Plottable { * An animator implementation with no animation. The attributes are * immediately set on the selection. */ +<<<<<<< HEAD + class Null implements PlotAnimator { + animate(selection: any, attrToProjector: AttributeToProjector): D3.Selection; +======= class Null implements IPlotAnimator { animate(selection: any, attrToProjector: IAttributeToProjector): D3.Selection; +>>>>>>> develop } } } @@ -3090,7 +4030,11 @@ declare module Plottable { /** * The base animator implementation with easing, duration, and delay. */ +<<<<<<< HEAD + class Base implements PlotAnimator { +======= class Base implements IPlotAnimator { +>>>>>>> develop /** * The default duration of the animation in milliseconds */ @@ -3109,7 +4053,11 @@ declare module Plottable { * @constructor */ constructor(); +<<<<<<< HEAD + animate(selection: any, attrToProjector: AttributeToProjector): D3.Transition.Transition; +======= animate(selection: any, attrToProjector: IAttributeToProjector): D3.Selection; +>>>>>>> develop /** * Gets the duration of the animation in milliseconds. * @@ -3160,6 +4108,26 @@ declare module Plottable { * An animator that delays the animation of the attributes using the index * of the selection data. * +<<<<<<< HEAD + * The maximum delay between animations can be configured with maxIterativeDelay. + * + * The maximum total animation duration can be configured with maxTotalDuration. + * maxTotalDuration does not set actual total animation duration. + * + * The actual interval delay is calculated by following formula: + * min(maxIterativeDelay(), + * max(totalDurationLimit() - duration(), 0) / ) + */ + class IterativeDelay extends Base { + /** + * The default maximum start delay between each start of an animation + */ + static DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS: number; + /** + * The default maximum total animation duration + */ + static DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS: number; +======= * The delay between animations can be configured with the .delay getter/setter. */ class IterativeDelay extends Base { @@ -3167,12 +4135,42 @@ declare module Plottable { * The start delay between each start of an animation */ static DEFAULT_ITERATIVE_DELAY_MILLISECONDS: number; +>>>>>>> develop /** * Constructs an animator with a start delay between each selection animation * * @constructor */ constructor(); +<<<<<<< HEAD + animate(selection: any, attrToProjector: AttributeToProjector): D3.Transition.Transition; + /** + * Gets the maximum start delay between animations in milliseconds. + * + * @returns {number} The current maximum iterative delay. + */ + maxIterativeDelay(): number; + /** + * Sets the maximum start delay between animations in milliseconds. + * + * @param {number} maxIterDelay The maximum iterative delay in milliseconds. + * @returns {IterativeDelay} The calling IterativeDelay Animator. + */ + maxIterativeDelay(maxIterDelay: number): IterativeDelay; + /** + * Gets the maximum total animation duration in milliseconds. + * + * @returns {number} The current maximum total animation duration. + */ + maxTotalDuration(): number; + /** + * Sets the maximum total animation duration in miliseconds. + * + * @param {number} maxDuration The maximum total animation duration in milliseconds. + * @returns {IterativeDelay} The calling IterativeDelay Animator. + */ + maxTotalDuration(maxDuration: number): IterativeDelay; +======= animate(selection: any, attrToProjector: IAttributeToProjector): D3.Selection; /** * Gets the start delay between animations in milliseconds. @@ -3187,6 +4185,7 @@ declare module Plottable { * @returns {IterativeDelay} The calling IterativeDelay Animator. */ iterativeDelay(iterDelay: number): IterativeDelay; +>>>>>>> develop } } } @@ -3202,8 +4201,37 @@ declare module Plottable { isVertical: boolean; isReverse: boolean; constructor(isVertical?: boolean, isReverse?: boolean); +<<<<<<< HEAD + animate(selection: any, attrToProjector: AttributeToProjector): D3.Transition.Transition; + _startMovingProjector(attrToProjector: AttributeToProjector): AppliedAccessor; + } + } +} + + +declare module Plottable { + module Animator { + /** + * A child class of RectAnimator that will move the rectangle + * as well as animate its growth. + */ + class MovingRect extends Rect { + /** + * The pixel value to move from + */ + startPixelValue: number; + /** + * Constructs a MovingRectAnimator + * + * @param {number} basePixel The pixel value to start moving from + * @param {boolean} isVertical If the movement/animation is vertical + */ + constructor(startPixelValue: number, isVertical?: boolean); + _startMovingProjector(attrToProjector: AttributeToProjector): (p: any) => number; +======= animate(selection: any, attrToProjector: IAttributeToProjector): any; _startMovingProjector(attrToProjector: IAttributeToProjector): IAppliedAccessor; +>>>>>>> develop } } } @@ -3215,7 +4243,11 @@ declare module Plottable { * A function to be called when an event occurs. The argument is the d3 event * generated by the event. */ +<<<<<<< HEAD + interface KeyEventListenerCallback { +======= interface IKeyEventListenerCallback { +>>>>>>> develop (e: D3.D3Event): any; } /** @@ -3233,15 +4265,24 @@ declare module Plottable { * @param {IKeyEventListener} cb Will be called when keyCode key event * occurs. */ +<<<<<<< HEAD + function addCallback(keyCode: number, cb: KeyEventListenerCallback): void; +======= function addCallback(keyCode: number, cb: IKeyEventListenerCallback): void; +>>>>>>> develop } } } declare module Plottable { +<<<<<<< HEAD + module Interaction { + class AbstractInteraction extends Core.PlottableObject { +======= module Abstract { class Interaction extends PlottableObject { +>>>>>>> develop /** * It maintains a 'hitBox' which is where all event listeners are * attached. Due to cross- browser weirdness, the hitbox needs to be an @@ -3250,8 +4291,13 @@ declare module Plottable { * e.g. crosshairs. */ _hitBox: D3.Selection; +<<<<<<< HEAD + _componentToListenTo: Component.AbstractComponent; + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): void; +======= _componentToListenTo: Component; _anchor(component: Component, hitBox: D3.Selection): void; +>>>>>>> develop } } } @@ -3259,8 +4305,13 @@ declare module Plottable { declare module Plottable { module Interaction { +<<<<<<< HEAD + class Click extends AbstractInteraction { + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): void; +======= class Click extends Abstract.Interaction { _anchor(component: Abstract.Component, hitBox: D3.Selection): void; +>>>>>>> develop _listenTo(): string; /** * Sets a callback to be called when a click is received. @@ -3278,7 +4329,11 @@ declare module Plottable { declare module Plottable { module Interaction { +<<<<<<< HEAD + class Key extends AbstractInteraction { +======= class Key extends Abstract.Interaction { +>>>>>>> develop /** * Creates a KeyInteraction. * @@ -3289,7 +4344,11 @@ declare module Plottable { * @param {number} keyCode The key code to listen for. */ constructor(keyCode: number); +<<<<<<< HEAD + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): void; +======= _anchor(component: Abstract.Component, hitBox: D3.Selection): void; +>>>>>>> develop /** * Sets a callback to be called when the designated key is pressed and the * user is moused over the component. @@ -3305,9 +4364,15 @@ declare module Plottable { declare module Plottable { module Interaction { +<<<<<<< HEAD + class PanZoom extends AbstractInteraction { + _xScale: Scale.AbstractQuantitative; + _yScale: Scale.AbstractQuantitative; +======= class PanZoom extends Abstract.Interaction { _xScale: Abstract.QuantitativeScale; _yScale: Abstract.QuantitativeScale; +>>>>>>> develop /** * Creates a PanZoomInteraction. * @@ -3318,12 +4383,20 @@ declare module Plottable { * @param {QuantitativeScale} [xScale] The X scale to update on panning/zooming. * @param {QuantitativeScale} [yScale] The Y scale to update on panning/zooming. */ +<<<<<<< HEAD + constructor(xScale?: Scale.AbstractQuantitative, yScale?: Scale.AbstractQuantitative); +======= constructor(xScale?: Abstract.QuantitativeScale, yScale?: Abstract.QuantitativeScale); +>>>>>>> develop /** * Sets the scales back to their original domains. */ resetZoom(): void; +<<<<<<< HEAD + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): void; +======= _anchor(component: Abstract.Component, hitBox: D3.Selection): void; +>>>>>>> develop } } } @@ -3331,9 +4404,15 @@ declare module Plottable { declare module Plottable { module Interaction { +<<<<<<< HEAD + class BarHover extends AbstractInteraction { + _componentToListenTo: Plot.AbstractBarPlot; + _anchor(barPlot: Plot.AbstractBarPlot, hitBox: D3.Selection): void; +======= class BarHover extends Abstract.Interaction { _componentToListenTo: Abstract.BarPlot; _anchor(barPlot: Abstract.BarPlot, hitBox: D3.Selection): void; +>>>>>>> develop /** * Gets the current hover mode. * @@ -3374,7 +4453,11 @@ declare module Plottable { declare module Plottable { module Interaction { +<<<<<<< HEAD + class Drag extends AbstractInteraction { +======= class Drag extends Abstract.Interaction { +>>>>>>> develop _origin: number[]; _location: number[]; /** @@ -3426,7 +4509,11 @@ declare module Plottable { _doDrag(): void; _dragend(): void; _doDragend(): void; +<<<<<<< HEAD + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): Drag; +======= _anchor(component: Abstract.Component, hitBox: D3.Selection): Drag; +>>>>>>> develop /** * Sets up so that the xScale and yScale that are passed have their * domains automatically changed as you zoom. @@ -3435,7 +4522,11 @@ declare module Plottable { * @param {QuantitativeScale} yScale The scale along the y-axis. * @returns {Drag} The calling Drag. */ +<<<<<<< HEAD + setupZoomCallback(xScale?: Scale.AbstractQuantitative, yScale?: Scale.AbstractQuantitative): Drag; +======= setupZoomCallback(xScale?: Abstract.QuantitativeScale, yScale?: Abstract.QuantitativeScale): Drag; +>>>>>>> develop } } } @@ -3475,7 +4566,11 @@ declare module Plottable { * @returns {DragBox} The calling DragBox. */ setBox(x0: number, x1: number, y0: number, y1: number): DragBox; +<<<<<<< HEAD + _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): DragBox; +======= _anchor(component: Abstract.Component, hitBox: D3.Selection): DragBox; +>>>>>>> develop } } } @@ -3511,8 +4606,13 @@ declare module Plottable { declare module Plottable { +<<<<<<< HEAD + module Dispatcher { + class AbstractDispatcher extends Core.PlottableObject { +======= module Abstract { class Dispatcher extends PlottableObject { +>>>>>>> develop _target: D3.Selection; _event2Callback: { [x: string]: () => any; @@ -3535,19 +4635,31 @@ declare module Plottable { * @param {D3.Selection} target The element to listen for updates on. * @returns {Dispatcher} The calling Dispatcher. */ +<<<<<<< HEAD + target(targetElement: D3.Selection): AbstractDispatcher; +======= target(targetElement: D3.Selection): Dispatcher; +>>>>>>> develop /** * Attaches the Dispatcher's listeners to the Dispatcher's target element. * * @returns {Dispatcher} The calling Dispatcher. */ +<<<<<<< HEAD + connect(): AbstractDispatcher; +======= connect(): Dispatcher; +>>>>>>> develop /** * Detaches the Dispatcher's listeners from the Dispatchers' target element. * * @returns {Dispatcher} The calling Dispatcher. */ +<<<<<<< HEAD + disconnect(): AbstractDispatcher; +======= disconnect(): Dispatcher; +>>>>>>> develop } } } @@ -3555,7 +4667,11 @@ declare module Plottable { declare module Plottable { module Dispatcher { +<<<<<<< HEAD + class Mouse extends AbstractDispatcher { +======= class Mouse extends Abstract.Dispatcher { +>>>>>>> develop /** * Constructs a Mouse Dispatcher with the specified target. * diff --git a/plottable.d.ts b/plottable.d.ts index 585b43e58e..bfaa7ef3e3 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -459,7 +459,7 @@ declare module Plottable { * * @returns {Formatter} A formatter for currency values. */ - function currency(precision?: number, symbol?: string, prefix?: boolean, onlyShowUnchanged?: boolean): (d: any) => string; + function currency(precision?: number, symbol?: string, prefix?: boolean): (d: any) => string; /** * Creates a formatter that displays exactly [precision] decimal places. * @@ -468,7 +468,7 @@ declare module Plottable { * * @returns {Formatter} A formatter that displays exactly [precision] decimal places. */ - function fixed(precision?: number, onlyShowUnchanged?: boolean): (d: any) => string; + function fixed(precision?: number): (d: any) => string; /** * Creates a formatter that formats numbers to show no more than * [precision] decimal places. All other values are stringified. @@ -478,7 +478,7 @@ declare module Plottable { * * @returns {Formatter} A formatter for general values. */ - function general(precision?: number, onlyShowUnchanged?: boolean): (d: any) => string; + function general(precision?: number): (d: any) => string; /** * Creates a formatter that stringifies its input. * @@ -494,7 +494,7 @@ declare module Plottable { * * @returns {Formatter} A formatter for percentage values. */ - function percentage(precision?: number, onlyShowUnchanged?: boolean): (d: any) => string; + function percentage(precision?: number): (d: any) => string; /** * Creates a formatter for values that displays [precision] significant figures * and puts SI notation. @@ -524,6 +524,16 @@ declare module Plottable { } +declare module Plottable { + module Config { + /** + * Specifies if Plottable should show warnings. + */ + var SHOW_WARNINGS: boolean; + } +} + + declare module Plottable { var version: string; } @@ -1013,6 +1023,7 @@ declare module Plottable { [x: string]: D[]; }; _typeCoercer: (d: any) => any; + _domainModificationInProgress: boolean; /** * Constructs a new Scale. * @@ -1543,6 +1554,14 @@ declare module Plottable { * @returns {TickGenerator} A tick generator using the specified interval. */ function intervalTickGenerator(interval: number): TickGenerator; + /** + * Creates a tick generator that will filter for only the integers in defaultTicks and return them. + * + * Will also include the end ticks. + * + * @returns {TickGenerator} A tick generator returning only integer ticks. + */ + function integerTickGenerator(): TickGenerator; } } } @@ -1648,6 +1667,7 @@ declare module Plottable { _getDrawSelection(): D3.Selection; _drawStep(step: DrawStep): void; _enterData(data: any[]): void; + draw(data: any[], drawSteps: DrawStep[]): number; } } } @@ -2121,6 +2141,8 @@ declare module Plottable { * @param {string} orientation The orientation of the Axis (top/bottom) */ constructor(scale: Scale.Time, orientation: string); + orient(): string; + orient(orientation: string): Time; _computeHeight(): number; _setup(): void; _getTickIntervalValues(interval: _TimeInterval): any[]; @@ -2145,7 +2167,7 @@ declare module Plottable { * @constructor * @param {QuantitativeScale} scale The QuantitativeScale to base the axis on. * @param {string} orientation The orientation of the QuantitativeScale (top/bottom/left/right) - * @param {Formatter} formatter A function to format tick labels (default Formatters.general(3, false)). + * @param {Formatter} formatter A function to format tick labels (default Formatters.general()). */ constructor(scale: Scale.AbstractQuantitative, orientation: string, formatter?: (d: any) => string); _setup(): void; @@ -2737,6 +2759,8 @@ declare module Plottable { class AbstractXYPlot extends AbstractPlot { _xScale: Scale.AbstractScale; _yScale: Scale.AbstractScale; + _autoAdjustXScaleDomain: boolean; + _autoAdjustYScaleDomain: boolean; /** * Constructs an XYPlot. * @@ -2754,9 +2778,35 @@ declare module Plottable { * x and y position in the Plot. */ project(attrToSet: string, accessor: any, scale?: Scale.AbstractScale): AbstractXYPlot; + remove(): AbstractXYPlot; + /** + * Sets the automatic domain adjustment over visible points for y scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for y scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + automaticallyAdjustYScaleOverVisiblePoints(autoAdjustment: boolean): AbstractXYPlot; + /** + * Sets the automatic domain adjustment over visible points for x scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for x scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + automaticallyAdjustXScaleOverVisiblePoints(autoAdjustment: boolean): AbstractXYPlot; + _generateAttrToProjector(): AttributeToProjector; _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number): void; _updateXDomainer(): void; _updateYDomainer(): void; + /** + * Adjusts both domains' extents to show all datasets. + * + * This call does not override auto domain adjustment behavior over visible points. + */ + showAllData(): void; } } } @@ -2782,10 +2832,7 @@ declare module Plottable { _getDrawer(key: string): _Drawer.Element; _generateAttrToProjector(): AttributeToProjector; _generateDrawSteps(): _Drawer.DrawStep[]; - _getClosestStruckPoint(p: Point, range: number): { - selection: D3.Selection; - data: any[]; - }; + _getClosestStruckPoint(p: Point, range: number): Interaction.HoverData; _hoverOverComponent(p: Point): void; _hoverOutComponent(p: Point): void; _doHover(p: Point): Interaction.HoverData; @@ -2834,6 +2881,7 @@ declare module Plottable { static _BarAlignmentToFactor: { [x: string]: number; }; + static _DEFAULT_WIDTH: number; _baseline: D3.Selection; _baselineValue: number; _barAlignmentFactor: number; @@ -2848,6 +2896,14 @@ declare module Plottable { constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale); _getDrawer(key: string): _Drawer.Rect; _setup(): void; + /** + * Gets the baseline value for the bars + * + * The baseline is the line that the bars are drawn from, defaulting to 0. + * + * @returns {number} The baseline value. + */ + baseline(): number; /** * Sets the baseline for the bars to the specified value. * @@ -2920,10 +2976,14 @@ declare module Plottable { _generateDrawSteps(): _Drawer.DrawStep[]; _generateAttrToProjector(): AttributeToProjector; /** - * Gets the current hover mode. + * Computes the barPixelWidth of all the bars in the plot. * - * @return {string} The current hover mode. + * If the position scale of the plot is an OrdinalScale and in bands mode, then the rangeBands function will be used. + * If the position scale of the plot is an OrdinalScale and in points mode, then + * from https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints, the max barPixelWidth is step * padding + * If the position scale of the plot is a QuantitativeScale, then _getMinimumDataWidth is scaled to compute the barPixelWidth */ + _getBarPixelWidth(): number; hoverMode(): string; /** * Sets the hover mode for hover interactions. There are two modes: @@ -3161,6 +3221,7 @@ declare module Plottable { _updateScaleExtents(): void; _keyAccessor(): AppliedAccessor; _valueAccessor(): AppliedAccessor; + _getBarPixelWidth(): any; } } } @@ -3363,30 +3424,134 @@ declare module Plottable { declare module Plottable { - module Core { - /** - * A function to be called when an event occurs. The argument is the d3 event - * generated by the event. - */ - interface KeyEventListenerCallback { - (e: D3.D3Event): any; + module Dispatcher { + class AbstractDispatcher extends Core.PlottableObject { + _target: D3.Selection; + _event2Callback: { + [x: string]: () => any; + }; + /** + * Constructs a Dispatcher with the specified target. + * + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. + */ + constructor(target?: D3.Selection); + /** + * Gets the target of the Dispatcher. + * + * @returns {D3.Selection} The Dispatcher's current target. + */ + target(): D3.Selection; + /** + * Sets the target of the Dispatcher. + * + * @param {D3.Selection} target The element to listen for updates on. + * @returns {Dispatcher} The calling Dispatcher. + */ + target(targetElement: D3.Selection): AbstractDispatcher; + /** + * Gets a namespaced version of the event name. + */ + _getEventString(eventName: string): string; + /** + * Attaches the Dispatcher's listeners to the Dispatcher's target element. + * + * @returns {Dispatcher} The calling Dispatcher. + */ + connect(): AbstractDispatcher; + /** + * Detaches the Dispatcher's listeners from the Dispatchers' target element. + * + * @returns {Dispatcher} The calling Dispatcher. + */ + disconnect(): AbstractDispatcher; } - /** - * A module for listening to keypresses on the document. - */ - module KeyEventListener { + } +} + + +declare module Plottable { + module Dispatcher { + class Mouse extends AbstractDispatcher { /** - * Turns on key listening. + * Constructs a Mouse Dispatcher with the specified target. + * + * @param {D3.Selection} target The selection to listen for events on. */ - function initialize(): void; + constructor(target: D3.Selection); /** - * When a key event occurs with the key corresponding te keyCod, call cb. + * Gets the current callback to be called on mouseover. * - * @param {number} keyCode The javascript key code to call cb on. - * @param {IKeyEventListener} cb Will be called when keyCode key event - * occurs. + * @return {(location: Point) => any} The current mouseover callback. */ - function addCallback(keyCode: number, cb: KeyEventListenerCallback): void; + mouseover(): (location: Point) => any; + /** + * Attaches a callback to be called on mouseover. + * + * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. + * Pass in null to remove the callback. + * @return {Mouse} The calling Mouse Handler. + */ + mouseover(callback: (location: Point) => any): Mouse; + /** + * Gets the current callback to be called on mousemove. + * + * @return {(location: Point) => any} The current mousemove callback. + */ + mousemove(): (location: Point) => any; + /** + * Attaches a callback to be called on mousemove. + * + * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. + * Pass in null to remove the callback. + * @return {Mouse} The calling Mouse Handler. + */ + mousemove(callback: (location: Point) => any): Mouse; + /** + * Gets the current callback to be called on mouseout. + * + * @return {(location: Point) => any} The current mouseout callback. + */ + mouseout(): (location: Point) => any; + /** + * Attaches a callback to be called on mouseout. + * + * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. + * Pass in null to remove the callback. + * @return {Mouse} The calling Mouse Handler. + */ + mouseout(callback: (location: Point) => any): Mouse; + } + } +} + + +declare module Plottable { + module Dispatcher { + class Keypress extends AbstractDispatcher { + /** + * Constructs a Keypress Dispatcher with the specified target. + * + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. + */ + constructor(target?: D3.Selection); + connect(): Keypress; + disconnect(): Keypress; + /** + * Gets the callback to be called when a key is pressed. + * + * @return {(e: D3.D3Event) => void} The current keydown callback. + */ + onKeyDown(): (e: D3.D3Event) => void; + /** + * Sets a callback to be called when a key is pressed. + * + * @param {(e: D3.D3Event) => void} A callback that takes in a D3Event. + * @return {Keypress} The calling Dispatcher.Keypress. + */ + onKeyDown(callback: (e: D3.D3Event) => void): Keypress; } } } @@ -3439,18 +3604,18 @@ declare module Plottable { * moused over. * * @constructor - * @param {number} keyCode The key code to listen for. */ - constructor(keyCode: number); + constructor(); _anchor(component: Component.AbstractComponent, hitBox: D3.Selection): void; /** - * Sets a callback to be called when the designated key is pressed and the - * user is moused over the component. + * Sets a callback to be called when the key with the given keyCode is + * pressed and the user is moused over the Component. * - * @param {() => any} cb Callback to be called. - * @returns The calling Key. + * @param {number} keyCode The key code associated with the key. + * @param {() => void} callback Callback to be called. + * @returns The calling Interaction.Key. */ - callback(cb: () => any): Key; + on(keyCode: number, callback: () => void): Key; } } } @@ -3667,6 +3832,7 @@ declare module Plottable { module Interaction { interface HoverData { data: any[]; + pixelPositions: Point[]; selection: D3.Selection; } interface Hoverable extends Component.AbstractComponent { @@ -3720,102 +3886,3 @@ declare module Plottable { } } } - - -declare module Plottable { - module Dispatcher { - class AbstractDispatcher extends Core.PlottableObject { - _target: D3.Selection; - _event2Callback: { - [x: string]: () => any; - }; - /** - * Constructs a Dispatcher with the specified target. - * - * @param {D3.Selection} target The selection to listen for events on. - */ - constructor(target: D3.Selection); - /** - * Gets the target of the Dispatcher. - * - * @returns {D3.Selection} The Dispatcher's current target. - */ - target(): D3.Selection; - /** - * Sets the target of the Dispatcher. - * - * @param {D3.Selection} target The element to listen for updates on. - * @returns {Dispatcher} The calling Dispatcher. - */ - target(targetElement: D3.Selection): AbstractDispatcher; - /** - * Attaches the Dispatcher's listeners to the Dispatcher's target element. - * - * @returns {Dispatcher} The calling Dispatcher. - */ - connect(): AbstractDispatcher; - /** - * Detaches the Dispatcher's listeners from the Dispatchers' target element. - * - * @returns {Dispatcher} The calling Dispatcher. - */ - disconnect(): AbstractDispatcher; - } - } -} - - -declare module Plottable { - module Dispatcher { - class Mouse extends AbstractDispatcher { - /** - * Constructs a Mouse Dispatcher with the specified target. - * - * @param {D3.Selection} target The selection to listen for events on. - */ - constructor(target: D3.Selection); - /** - * Gets the current callback to be called on mouseover. - * - * @return {(location: Point) => any} The current mouseover callback. - */ - mouseover(): (location: Point) => any; - /** - * Attaches a callback to be called on mouseover. - * - * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. - * Pass in null to remove the callback. - * @return {Mouse} The calling Mouse Handler. - */ - mouseover(callback: (location: Point) => any): Mouse; - /** - * Gets the current callback to be called on mousemove. - * - * @return {(location: Point) => any} The current mousemove callback. - */ - mousemove(): (location: Point) => any; - /** - * Attaches a callback to be called on mousemove. - * - * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. - * Pass in null to remove the callback. - * @return {Mouse} The calling Mouse Handler. - */ - mousemove(callback: (location: Point) => any): Mouse; - /** - * Gets the current callback to be called on mouseout. - * - * @return {(location: Point) => any} The current mouseout callback. - */ - mouseout(): (location: Point) => any; - /** - * Attaches a callback to be called on mouseout. - * - * @param {(location: Point) => any} callback A function that takes the pixel position of the mouse event. - * Pass in null to remove the callback. - * @return {Mouse} The calling Mouse Handler. - */ - mouseout(callback: (location: Point) => any): Mouse; - } - } -} diff --git a/plottable.js b/plottable.js index 24c152c33a..bc5ad3e683 100644 --- a/plottable.js +++ b/plottable.js @@ -1,5 +1,5 @@ /*! -Plottable 0.34.1 (https://github.com/palantir/plottable) +Plottable 0.35.0 (https://github.com/palantir/plottable) Copyright 2014 Palantir Technologies Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE) */ @@ -26,6 +26,9 @@ var Plottable; * @param {string} The warnings to print */ function warn(warning) { + if (!Plottable.Config.SHOW_WARNINGS) { + return; + } /* tslint:disable:no-console */ if (window.console != null) { if (window.console.warn != null) { @@ -1178,17 +1181,13 @@ var Plottable; * * @returns {Formatter} A formatter for currency values. */ - function currency(precision, symbol, prefix, onlyShowUnchanged) { + function currency(precision, symbol, prefix) { if (precision === void 0) { precision = 2; } if (symbol === void 0) { symbol = "$"; } if (prefix === void 0) { prefix = true; } - if (onlyShowUnchanged === void 0) { onlyShowUnchanged = true; } var fixedFormatter = Formatters.fixed(precision); return function (d) { var formattedValue = fixedFormatter(Math.abs(d)); - if (onlyShowUnchanged && valueChanged(Math.abs(d), formattedValue)) { - return ""; - } if (formattedValue !== "") { if (prefix) { formattedValue = symbol + formattedValue; @@ -1212,16 +1211,11 @@ var Plottable; * * @returns {Formatter} A formatter that displays exactly [precision] decimal places. */ - function fixed(precision, onlyShowUnchanged) { + function fixed(precision) { if (precision === void 0) { precision = 3; } - if (onlyShowUnchanged === void 0) { onlyShowUnchanged = true; } verifyPrecision(precision); return function (d) { - var formattedValue = d.toFixed(precision); - if (onlyShowUnchanged && valueChanged(d, formattedValue)) { - return ""; - } - return formattedValue; + return d.toFixed(precision); }; } Formatters.fixed = fixed; @@ -1234,18 +1228,13 @@ var Plottable; * * @returns {Formatter} A formatter for general values. */ - function general(precision, onlyShowUnchanged) { + function general(precision) { if (precision === void 0) { precision = 3; } - if (onlyShowUnchanged === void 0) { onlyShowUnchanged = true; } verifyPrecision(precision); return function (d) { if (typeof d === "number") { var multiplier = Math.pow(10, precision); - var formattedValue = String(Math.round(d * multiplier) / multiplier); - if (onlyShowUnchanged && valueChanged(d, formattedValue)) { - return ""; - } - return formattedValue; + return String(Math.round(d * multiplier) / multiplier); } else { return String(d); @@ -1273,24 +1262,16 @@ var Plottable; * * @returns {Formatter} A formatter for percentage values. */ - function percentage(precision, onlyShowUnchanged) { + function percentage(precision) { if (precision === void 0) { precision = 0; } - if (onlyShowUnchanged === void 0) { onlyShowUnchanged = true; } - var fixedFormatter = Formatters.fixed(precision, onlyShowUnchanged); + var fixedFormatter = Formatters.fixed(precision); return function (d) { var valToFormat = d * 100; // Account for float imprecision var valString = d.toString(); var integerPowerTen = Math.pow(10, valString.length - (valString.indexOf(".") + 1)); valToFormat = parseInt((valToFormat * integerPowerTen).toString(), 10) / integerPowerTen; - var formattedValue = fixedFormatter(valToFormat); - if (onlyShowUnchanged && valueChanged(valToFormat, formattedValue)) { - return ""; - } - if (formattedValue !== "") { - formattedValue += "%"; - } - return formattedValue; + return fixedFormatter(valToFormat) + "%"; }; } Formatters.percentage = percentage; @@ -1385,9 +1366,6 @@ var Plottable; throw new RangeError("Formatter precision must be between 0 and 20"); } } - function valueChanged(d, formattedValue) { - return d !== parseFloat(formattedValue); - } })(Plottable.Formatters || (Plottable.Formatters = {})); var Formatters = Plottable.Formatters; })(Plottable || (Plottable = {})); @@ -1395,7 +1373,19 @@ var Plottable; /// var Plottable; (function (Plottable) { - Plottable.version = "0.34.1"; + (function (Config) { + /** + * Specifies if Plottable should show warnings. + */ + Config.SHOW_WARNINGS = true; + })(Plottable.Config || (Plottable.Config = {})); + var Config = Plottable.Config; +})(Plottable || (Plottable = {})); + +/// +var Plottable; +(function (Plottable) { + Plottable.version = "0.35.0"; })(Plottable || (Plottable = {})); /// @@ -2132,6 +2122,7 @@ var Plottable; this.broadcaster = new Plottable.Core.Broadcaster(this); this._rendererAttrID2Extent = {}; this._typeCoercer = function (d) { return d; }; + this._domainModificationInProgress = false; this._d3Scale = scale; } AbstractScale.prototype._getAllExtents = function () { @@ -2189,8 +2180,12 @@ var Plottable; return this._d3Scale.domain(); }; AbstractScale.prototype._setDomain = function (values) { - this._d3Scale.domain(values); - this.broadcaster.broadcast(); + if (!this._domainModificationInProgress) { + this._domainModificationInProgress = true; + this._d3Scale.domain(values); + this.broadcaster.broadcast(); + this._domainModificationInProgress = false; + } }; AbstractScale.prototype.range = function (values) { if (values == null) { @@ -3111,6 +3106,20 @@ var Plottable; }; } TickGenerators.intervalTickGenerator = intervalTickGenerator; + /** + * Creates a tick generator that will filter for only the integers in defaultTicks and return them. + * + * Will also include the end ticks. + * + * @returns {TickGenerator} A tick generator returning only integer ticks. + */ + function integerTickGenerator() { + return function (s) { + var defaultTicks = s.getDefaultTicks(); + return defaultTicks.filter(function (tick, i) { return (tick % 1 === 0) || (i === 0) || (i === defaultTicks.length - 1); }); + }; + } + TickGenerators.integerTickGenerator = integerTickGenerator; })(Scale.TickGenerators || (Scale.TickGenerators = {})); var TickGenerators = Scale.TickGenerators; })(Plottable.Scale || (Plottable.Scale = {})); @@ -3377,6 +3386,23 @@ var Plottable; } dataElements.exit().remove(); }; + Element.prototype.filterDefinedData = function (data, definedFunction) { + return definedFunction ? data.filter(definedFunction) : data; + }; + Element.prototype.draw = function (data, drawSteps) { + var _this = this; + var modifiedDrawSteps = []; + drawSteps.forEach(function (d, i) { + modifiedDrawSteps[i] = { animator: d.animator, attrToProjector: Plottable._Util.Methods.copyMap(d.attrToProjector) }; + }); + var definedData = modifiedDrawSteps.reduce(function (data, drawStep) { return _this.filterDefinedData(data, drawStep.attrToProjector["defined"]); }, data); + modifiedDrawSteps.forEach(function (d) { + if (d.attrToProjector["defined"]) { + delete d.attrToProjector["defined"]; + } + }); + return _super.prototype.draw.call(this, definedData, modifiedDrawSteps); + }; return Element; })(_Drawer.AbstractDrawer); _Drawer.Element = Element; @@ -3546,6 +3572,7 @@ var Plottable; this._yOffset = 0; this.cssClasses = ["component"]; this.removed = false; + this._autoResize = AbstractComponent.AUTORESIZE_BY_DEFAULT; } /** * Attaches the Component as a child of a given a DOM element. Usually only directly invoked on root-level Components. @@ -3600,7 +3627,7 @@ var Plottable; this.interactionsToRegister.forEach(function (r) { return _this.registerInteraction(r); }); this.interactionsToRegister = null; if (this.isTopLevelComponent) { - this.autoResize(AbstractComponent.AUTORESIZE_BY_DEFAULT); + this.autoResize(this._autoResize); } this._isSetup = true; }; @@ -3739,6 +3766,7 @@ var Plottable; else { Plottable.Core.ResizeBroadcaster.deregister(this); } + this._autoResize = flag; // if _setup were called by constructor, this var could be removed #591 return this; }; /** @@ -4536,14 +4564,16 @@ var Plottable; * @param {string} orientation The orientation of the Axis (top/bottom) */ function Time(scale, orientation) { - orientation = orientation.toLowerCase(); - if (orientation !== "top" && orientation !== "bottom") { - throw new Error("unsupported orientation: " + orientation); - } _super.call(this, scale, orientation); this.classed("time-axis", true); this.tickLabelPadding(5); } + Time.prototype.orient = function (orientation) { + if (orientation && (orientation.toLowerCase() === "right" || orientation.toLowerCase() === "left")) { + throw new Error(orientation + " is not a supported orientation for TimeAxis - only horizontal orientations are supported"); + } + return _super.prototype.orient.call(this, orientation); // maintains getter-setter functionality + }; Time.prototype._computeHeight = function () { if (this._computedHeight !== null) { return this._computedHeight; @@ -4790,10 +4820,10 @@ var Plottable; * @constructor * @param {QuantitativeScale} scale The QuantitativeScale to base the axis on. * @param {string} orientation The orientation of the QuantitativeScale (top/bottom/left/right) - * @param {Formatter} formatter A function to format tick labels (default Formatters.general(3, false)). + * @param {Formatter} formatter A function to format tick labels (default Formatters.general()). */ function Numeric(scale, orientation, formatter) { - if (formatter === void 0) { formatter = Plottable.Formatters.general(3, false); } + if (formatter === void 0) { formatter = Plottable.Formatters.general(); } _super.call(this, scale, orientation, formatter); this.tickLabelPositioning = "center"; // Whether or not first/last tick label will still be displayed even if @@ -6513,6 +6543,8 @@ var Plottable; */ function AbstractXYPlot(xScale, yScale) { _super.call(this); + this._autoAdjustXScaleDomain = false; + this._autoAdjustYScaleDomain = false; if (xScale == null || yScale == null) { throw new Error("XYPlots require an xScale and yScale"); } @@ -6525,19 +6557,75 @@ var Plottable; * x and y position in the Plot. */ AbstractXYPlot.prototype.project = function (attrToSet, accessor, scale) { + var _this = this; // We only want padding and nice-ing on scales that will correspond to axes / pixel layout. // So when we get an "x" or "y" scale, enable autoNiceing and autoPadding. if (attrToSet === "x" && scale) { + if (this._xScale) { + this._xScale.broadcaster.deregisterListener("yDomainAdjustment" + this._plottableID); + } this._xScale = scale; this._updateXDomainer(); + scale.broadcaster.registerListener("yDomainAdjustment" + this._plottableID, function () { return _this.adjustYDomainOnChangeFromX(); }); } if (attrToSet === "y" && scale) { + if (this._yScale) { + this._yScale.broadcaster.deregisterListener("xDomainAdjustment" + this._plottableID); + } this._yScale = scale; this._updateYDomainer(); + scale.broadcaster.registerListener("xDomainAdjustment" + this._plottableID, function () { return _this.adjustXDomainOnChangeFromY(); }); } _super.prototype.project.call(this, attrToSet, accessor, scale); return this; }; + AbstractXYPlot.prototype.remove = function () { + _super.prototype.remove.call(this); + if (this._xScale) { + this._xScale.broadcaster.deregisterListener("yDomainAdjustment" + this._plottableID); + } + if (this._yScale) { + this._yScale.broadcaster.deregisterListener("xDomainAdjustment" + this._plottableID); + } + return this; + }; + /** + * Sets the automatic domain adjustment over visible points for y scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for y scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + AbstractXYPlot.prototype.automaticallyAdjustYScaleOverVisiblePoints = function (autoAdjustment) { + this._autoAdjustYScaleDomain = autoAdjustment; + this.adjustYDomainOnChangeFromX(); + return this; + }; + /** + * Sets the automatic domain adjustment over visible points for x scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for x scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + AbstractXYPlot.prototype.automaticallyAdjustXScaleOverVisiblePoints = function (autoAdjustment) { + this._autoAdjustXScaleDomain = autoAdjustment; + this.adjustXDomainOnChangeFromY(); + return this; + }; + AbstractXYPlot.prototype._generateAttrToProjector = function () { + var attrToProjector = _super.prototype._generateAttrToProjector.call(this); + var positionXFn = attrToProjector["x"]; + var positionYFn = attrToProjector["y"]; + attrToProjector["defined"] = function (d, i) { + var positionX = positionXFn(d, i); + var positionY = positionYFn(d, i); + return positionX != null && positionX === positionX && positionY != null && positionY === positionY; + }; + return attrToProjector; + }; AbstractXYPlot.prototype._computeLayout = function (xOffset, yOffset, availableWidth, availableHeight) { _super.prototype._computeLayout.call(this, xOffset, yOffset, availableWidth, availableHeight); this._xScale.range([0, this.width()]); @@ -6559,6 +6647,55 @@ var Plottable; } } }; + /** + * Adjusts both domains' extents to show all datasets. + * + * This call does not override auto domain adjustment behavior over visible points. + */ + AbstractXYPlot.prototype.showAllData = function () { + this._xScale.autoDomain(); + if (!this._autoAdjustYScaleDomain) { + this._yScale.autoDomain(); + } + }; + AbstractXYPlot.prototype.adjustYDomainOnChangeFromX = function () { + if (this._autoAdjustYScaleDomain) { + this.adjustDomainToVisiblePoints(this._xScale, this._yScale, true); + } + }; + AbstractXYPlot.prototype.adjustXDomainOnChangeFromY = function () { + if (this._autoAdjustXScaleDomain) { + this.adjustDomainToVisiblePoints(this._yScale, this._xScale, false); + } + }; + AbstractXYPlot.prototype.adjustDomainToVisiblePoints = function (fromScale, toScale, fromX) { + if (toScale instanceof Plottable.Scale.AbstractQuantitative) { + var toScaleQ = toScale; + var normalizedData = this.normalizeDatasets(fromX); + var adjustedDomain = this.adjustDomainOverVisiblePoints(normalizedData, fromScale.domain()); + if (adjustedDomain.length === 0) { + return; + } + adjustedDomain = toScaleQ.domainer().computeDomain([adjustedDomain], toScaleQ); + toScaleQ.domain(adjustedDomain); + } + }; + AbstractXYPlot.prototype.normalizeDatasets = function (fromX) { + var flattenDatasets = Plottable._Util.Methods.flatten(this.datasets().map(function (d) { return d.data(); })); + var aAccessor = this._projectors[fromX ? "x" : "y"].accessor; + var bAccessor = this._projectors[fromX ? "y" : "x"].accessor; + return flattenDatasets.map(function (d, i) { + return { a: aAccessor(d, i), b: bAccessor(d, i) }; + }); + }; + AbstractXYPlot.prototype.adjustDomainOverVisiblePoints = function (values, fromDomain) { + var bVals = values.filter(function (v) { return fromDomain[0] <= v.a && v.a <= fromDomain[1]; }).map(function (v) { return v.b; }); + var retVal = []; + if (bVals.length !== 0) { + retVal = [Plottable._Util.Methods.min(bVals, null), Plottable._Util.Methods.max(bVals, null)]; + } + return retVal; + }; return AbstractXYPlot; })(Plot.AbstractPlot); Plot.AbstractXYPlot = AbstractXYPlot; @@ -6637,6 +6774,7 @@ var Plottable; }; var overAPoint = false; var closestElement; + var closestIndex; var minDistSq = range * range; drawers.forEach(function (drawer) { drawer._getDrawSelection().each(function (d, i) { @@ -6645,20 +6783,35 @@ var Plottable; if (distSq < r * r) { if (!overAPoint || distSq < minDistSq) { closestElement = this; + closestIndex = i; minDistSq = distSq; } overAPoint = true; } else if (!overAPoint && distSq < minDistSq) { closestElement = this; + closestIndex = i; minDistSq = distSq; } }); }); + if (!closestElement) { + return { + selection: null, + pixelPositions: null, + data: null + }; + } var closestSelection = d3.select(closestElement); + var closestData = closestSelection.data(); + var closestPoint = { + x: attrToProjector["cx"](closestData[0], closestIndex), + y: attrToProjector["cy"](closestData[0], closestIndex) + }; return { - selection: closestElement ? closestSelection : null, - data: closestElement ? closestSelection.data() : null + selection: closestSelection, + pixelPositions: [closestPoint], + data: closestData }; }; //===== Hover logic ===== @@ -6795,15 +6948,10 @@ var Plottable; _super.prototype._setup.call(this); this._baseline = this._renderArea.append("line").classed("baseline", true); }; - /** - * Sets the baseline for the bars to the specified value. - * - * The baseline is the line that the bars are drawn from, defaulting to 0. - * - * @param {number} value The value to position the baseline at. - * @returns {AbstractBarPlot} The calling AbstractBarPlot. - */ AbstractBarPlot.prototype.baseline = function (value) { + if (value == null) { + return this._baselineValue; + } this._baselineValue = value; this._updateXDomainer(); this._updateYDomainer(); @@ -6982,14 +7130,13 @@ var Plottable; var secondaryScale = this._isVertical ? this._xScale : this._yScale; var primaryAttr = this._isVertical ? "y" : "x"; var secondaryAttr = this._isVertical ? "x" : "y"; - var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) && secondaryScale.rangeType() === "bands"; var scaledBaseline = primaryScale.scale(this._baselineValue); if (!attrToProjector["width"]) { - var constantWidth = bandsMode ? secondaryScale.rangeBand() : AbstractBarPlot.DEFAULT_WIDTH; - attrToProjector["width"] = function (d, i) { return constantWidth; }; + attrToProjector["width"] = function () { return _this._getBarPixelWidth(); }; } var positionF = attrToProjector[secondaryAttr]; var widthF = attrToProjector["width"]; + var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) && secondaryScale.rangeType() === "bands"; if (!bandsMode) { attrToProjector[secondaryAttr] = function (d, i) { return positionF(d, i) - widthF(d, i) * _this._barAlignmentFactor; }; } @@ -7017,6 +7164,52 @@ var Plottable; } return attrToProjector; }; + /** + * Computes the barPixelWidth of all the bars in the plot. + * + * If the position scale of the plot is an OrdinalScale and in bands mode, then the rangeBands function will be used. + * If the position scale of the plot is an OrdinalScale and in points mode, then + * from https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints, the max barPixelWidth is step * padding + * If the position scale of the plot is a QuantitativeScale, then _getMinimumDataWidth is scaled to compute the barPixelWidth + */ + AbstractBarPlot.prototype._getBarPixelWidth = function () { + var barPixelWidth; + var barScale = this._isVertical ? this._xScale : this._yScale; + if (barScale instanceof Plottable.Scale.Ordinal) { + var ordScale = barScale; + if (ordScale.rangeType() === "bands") { + barPixelWidth = ordScale.rangeBand(); + } + else { + // padding is defined as 2 * the ordinal scale's _outerPadding variable + // HACKHACK need to use _outerPadding for formula as above + var padding = ordScale._outerPadding * 2; + // step is defined as the range_interval / (padding + number of bars) + var secondaryDimension = this._isVertical ? this.width() : this.height(); + var step = secondaryDimension / (padding + ordScale.domain().length - 1); + barPixelWidth = step * padding * 0.5; + } + } + else { + var barAccessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; + var barAccessorData = d3.set(Plottable._Util.Methods.flatten(this.datasets().map(function (dataset) { + return dataset.data().map(function (d, i) { return barAccessor(d, i); }); + }))).values(); + if (barAccessorData.some(function (datum) { return datum === "undefined"; })) { + return -1; + } + var numberBarAccessorData = d3.set(Plottable._Util.Methods.flatten(this.datasets().map(function (dataset) { + return dataset.data().map(function (d, i) { return barAccessor(d, i).valueOf(); }); + }))).values().map(function (value) { return +value; }); + numberBarAccessorData.sort(function (a, b) { return a - b; }); + var barAccessorDataPairs = d3.pairs(numberBarAccessorData); + var barWidthDimension = this._isVertical ? this.width() : this.height(); + barPixelWidth = Plottable._Util.Methods.min(barAccessorDataPairs, function (pair, i) { + return Math.abs(barScale.scale(pair[1]) - barScale.scale(pair[0])); + }, barWidthDimension * 0.4) * 0.95; + } + return barPixelWidth; + }; AbstractBarPlot.prototype.hoverMode = function (mode) { if (mode == null) { return this._hoverMode; @@ -7041,6 +7234,7 @@ var Plottable; this.clearHoverSelection(); }; AbstractBarPlot.prototype._doHover = function (p) { + var _this = this; var xPositionOrExtent = p.x; var yPositionOrExtent = p.y; if (this._hoverMode === "line") { @@ -7061,14 +7255,36 @@ var Plottable; } else { this.clearHoverSelection(); + return { + data: null, + pixelPositions: null, + selection: null + }; } + var points = []; + var projectors = this._generateAttrToProjector(); + selectedBars.each(function (d, i) { + if (_this._isVertical) { + points.push({ + x: projectors["x"](d, i) + projectors["width"](d, i) / 2, + y: projectors["y"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["height"](d, i)) + }); + } + else { + points.push({ + x: projectors["x"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["width"](d, i)), + y: projectors["y"](d, i) + projectors["height"](d, i) / 2 + }); + } + }); return { - data: selectedBars ? selectedBars.data() : null, + data: selectedBars.data(), + pixelPositions: points, selection: selectedBars }; }; AbstractBarPlot._BarAlignmentToFactor = {}; - AbstractBarPlot.DEFAULT_WIDTH = 10; + AbstractBarPlot._DEFAULT_WIDTH = 10; return AbstractBarPlot; })(Plot.AbstractXYPlot); Plot.AbstractBarPlot = AbstractBarPlot; @@ -7365,15 +7581,12 @@ var Plottable; if (isVertical === void 0) { isVertical = true; } this._isVertical = isVertical; // Has to be set before super() _super.call(this, xScale, yScale); - this.innerScale = new Plottable.Scale.Ordinal(); } ClusteredBar.prototype._generateAttrToProjector = function () { - var _this = this; var attrToProjector = _super.prototype._generateAttrToProjector.call(this); // the width is constant, so set the inner scale range to that - var widthF = attrToProjector["width"]; - this.innerScale.range([0, widthF(null, 0)]); - var innerWidthF = function (d, i) { return _this.innerScale.rangeBand(); }; + var innerScale = this.makeInnerScale(); + var innerWidthF = function (d, i) { return innerScale.rangeBand(); }; var heightF = attrToProjector["height"]; attrToProjector["width"] = this._isVertical ? innerWidthF : heightF; attrToProjector["height"] = this._isVertical ? heightF : innerWidthF; @@ -7385,19 +7598,40 @@ var Plottable; ClusteredBar.prototype._getDataToDraw = function () { var _this = this; var accessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; - this.innerScale.domain(this._datasetKeysInOrder); + var innerScale = this.makeInnerScale(); var clusters = d3.map(); this._datasetKeysInOrder.forEach(function (key) { var data = _this._key2DatasetDrawerKey.get(key).dataset.data(); clusters.set(key, data.map(function (d, i) { var val = accessor(d, i); var primaryScale = _this._isVertical ? _this._xScale : _this._yScale; - d["_PLOTTABLE_PROTECTED_FIELD_POSITION"] = primaryScale.scale(val) + _this.innerScale.scale(key); - return d; + // TODO: store position information in metadata. + var copyD = Plottable._Util.Methods.copyMap(d); + copyD["_PLOTTABLE_PROTECTED_FIELD_POSITION"] = primaryScale.scale(val) + innerScale.scale(key); + return copyD; })); }); return clusters; }; + ClusteredBar.prototype.makeInnerScale = function () { + var innerScale = new Plottable.Scale.Ordinal(); + innerScale.domain(this._datasetKeysInOrder); + // TODO: it might be replaced with _getBarPixelWidth call after closing #1180. + if (!this._projectors["width"]) { + var secondaryScale = this._isVertical ? this._xScale : this._yScale; + var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) && secondaryScale.rangeType() === "bands"; + var constantWidth = bandsMode ? secondaryScale.rangeBand() : Plot.AbstractBarPlot._DEFAULT_WIDTH; + innerScale.range([0, constantWidth]); + } + else { + var projector = this._projectors["width"]; + var accessor = projector.accessor; + var scale = projector.scale; + var fn = scale ? function (d, i) { return scale.scale(accessor(d, i)); } : accessor; + innerScale.range([0, fn(null, 0)]); + } + return innerScale; + }; return ClusteredBar; })(Plot.AbstractBarPlot); Plot.ClusteredBar = ClusteredBar; @@ -7472,10 +7706,6 @@ var Plottable; */ AbstractStacked.prototype._stack = function (dataArray) { var _this = this; - // HACKHACK d3's stack layout logic crashes on 0-length dataArray https://github.com/mbostock/d3/issues/2004 - if (dataArray.length === 0) { - return dataArray; - } var outFunction = function (d, y0, y) { d.offset = y0; }; @@ -7746,6 +7976,10 @@ var Plottable; StackedBar.prototype._valueAccessor = function () { return Plot.AbstractStacked.prototype._valueAccessor.call(this); }; + //===== /Stack logic ===== + StackedBar.prototype._getBarPixelWidth = function () { + return Plot.AbstractBarPlot.prototype._getBarPixelWidth.apply(this); + }; return StackedBar; })(Plot.AbstractBarPlot); Plot.StackedBar = StackedBar; @@ -7983,55 +8217,220 @@ var Plottable; })(Plottable || (Plottable = {})); /// +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; var Plottable; (function (Plottable) { - (function (Core) { - /** - * A module for listening to keypresses on the document. - */ - (function (KeyEventListener) { - var _initialized = false; - var _callbacks = []; + (function (Dispatcher) { + var AbstractDispatcher = (function (_super) { + __extends(AbstractDispatcher, _super); /** - * Turns on key listening. + * Constructs a Dispatcher with the specified target. + * + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. */ - function initialize() { - if (_initialized) { - return; - } - d3.select(document).on("keydown", processEvent); - _initialized = true; + function AbstractDispatcher(target) { + _super.call(this); + this._event2Callback = {}; + this.connected = false; + this._target = target; } - KeyEventListener.initialize = initialize; + AbstractDispatcher.prototype.target = function (targetElement) { + if (targetElement == null) { + return this._target; + } + var wasConnected = this.connected; + this.disconnect(); + this._target = targetElement; + if (wasConnected) { + // re-connect to the new target + this.connect(); + } + return this; + }; + /** + * Gets a namespaced version of the event name. + */ + AbstractDispatcher.prototype._getEventString = function (eventName) { + return eventName + ".dispatcher" + this._plottableID; + }; /** - * When a key event occurs with the key corresponding te keyCod, call cb. + * Attaches the Dispatcher's listeners to the Dispatcher's target element. * - * @param {number} keyCode The javascript key code to call cb on. - * @param {IKeyEventListener} cb Will be called when keyCode key event - * occurs. + * @returns {Dispatcher} The calling Dispatcher. */ - function addCallback(keyCode, cb) { - if (!_initialized) { - initialize(); + AbstractDispatcher.prototype.connect = function () { + var _this = this; + if (this.connected) { + throw new Error("Can't connect dispatcher twice!"); } - if (_callbacks[keyCode] == null) { - _callbacks[keyCode] = []; + if (this._target) { + this.connected = true; + Object.keys(this._event2Callback).forEach(function (event) { + var callback = _this._event2Callback[event]; + _this._target.on(_this._getEventString(event), callback); + }); + } + return this; + }; + /** + * Detaches the Dispatcher's listeners from the Dispatchers' target element. + * + * @returns {Dispatcher} The calling Dispatcher. + */ + AbstractDispatcher.prototype.disconnect = function () { + var _this = this; + this.connected = false; + if (this._target) { + Object.keys(this._event2Callback).forEach(function (event) { + _this._target.on(_this._getEventString(event), null); + }); } - _callbacks[keyCode].push(cb); + return this; + }; + return AbstractDispatcher; + })(Plottable.Core.PlottableObject); + Dispatcher.AbstractDispatcher = AbstractDispatcher; + })(Plottable.Dispatcher || (Plottable.Dispatcher = {})); + var Dispatcher = Plottable.Dispatcher; +})(Plottable || (Plottable = {})); + +/// +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Plottable; +(function (Plottable) { + (function (Dispatcher) { + var Mouse = (function (_super) { + __extends(Mouse, _super); + /** + * Constructs a Mouse Dispatcher with the specified target. + * + * @param {D3.Selection} target The selection to listen for events on. + */ + function Mouse(target) { + var _this = this; + _super.call(this, target); + this._event2Callback["mouseover"] = function () { + if (_this._mouseover != null) { + _this._mouseover(_this.getMousePosition()); + } + }; + this._event2Callback["mousemove"] = function () { + if (_this._mousemove != null) { + _this._mousemove(_this.getMousePosition()); + } + }; + this._event2Callback["mouseout"] = function () { + if (_this._mouseout != null) { + _this._mouseout(_this.getMousePosition()); + } + }; } - KeyEventListener.addCallback = addCallback; - function processEvent() { - if (_callbacks[d3.event.keyCode] == null) { - return; + Mouse.prototype.getMousePosition = function () { + var xy = d3.mouse(this._target.node()); + return { + x: xy[0], + y: xy[1] + }; + }; + Mouse.prototype.mouseover = function (callback) { + if (callback === undefined) { + return this._mouseover; } - _callbacks[d3.event.keyCode].forEach(function (cb) { - cb(d3.event); - }); + this._mouseover = callback; + return this; + }; + Mouse.prototype.mousemove = function (callback) { + if (callback === undefined) { + return this._mousemove; + } + this._mousemove = callback; + return this; + }; + Mouse.prototype.mouseout = function (callback) { + if (callback === undefined) { + return this._mouseout; + } + this._mouseout = callback; + return this; + }; + return Mouse; + })(Dispatcher.AbstractDispatcher); + Dispatcher.Mouse = Mouse; + })(Plottable.Dispatcher || (Plottable.Dispatcher = {})); + var Dispatcher = Plottable.Dispatcher; +})(Plottable || (Plottable = {})); + +/// +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Plottable; +(function (Plottable) { + (function (Dispatcher) { + var Keypress = (function (_super) { + __extends(Keypress, _super); + /** + * Constructs a Keypress Dispatcher with the specified target. + * + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. + */ + function Keypress(target) { + var _this = this; + _super.call(this, target); + this.mousedOverTarget = false; + // Can't attach the key listener to the target (a sub-svg element) + // because "focusable" is only in SVG 1.2 / 2, which most browsers don't + // yet implement + this.keydownListenerTarget = d3.select(document); + this._event2Callback["mouseover"] = function () { + _this.mousedOverTarget = true; + }; + this._event2Callback["mouseout"] = function () { + _this.mousedOverTarget = false; + }; } - })(Core.KeyEventListener || (Core.KeyEventListener = {})); - var KeyEventListener = Core.KeyEventListener; - })(Plottable.Core || (Plottable.Core = {})); - var Core = Plottable.Core; + Keypress.prototype.connect = function () { + var _this = this; + _super.prototype.connect.call(this); + this.keydownListenerTarget.on(this._getEventString("keydown"), function () { + if (_this.mousedOverTarget && _this._onKeyDown) { + _this._onKeyDown(d3.event); + } + }); + return this; + }; + Keypress.prototype.disconnect = function () { + _super.prototype.disconnect.call(this); + this.keydownListenerTarget.on(this._getEventString("keydown"), null); + return this; + }; + Keypress.prototype.onKeyDown = function (callback) { + if (callback === undefined) { + return this._onKeyDown; + } + this._onKeyDown = callback; + return this; + }; + return Keypress; + })(Dispatcher.AbstractDispatcher); + Dispatcher.Keypress = Keypress; + })(Plottable.Dispatcher || (Plottable.Dispatcher = {})); + var Dispatcher = Plottable.Dispatcher; })(Plottable || (Plottable = {})); /// @@ -8134,37 +8533,34 @@ var Plottable; * moused over. * * @constructor - * @param {number} keyCode The key code to listen for. */ - function Key(keyCode) { + function Key() { _super.call(this); this.activated = false; - this.keyCode = keyCode; + this.keyCode2Callback = {}; + this.dispatcher = new Plottable.Dispatcher.Keypress(); } Key.prototype._anchor = function (component, hitBox) { var _this = this; _super.prototype._anchor.call(this, component, hitBox); - hitBox.on("mouseover", function () { - _this.activated = true; - }); - hitBox.on("mouseout", function () { - _this.activated = false; - }); - Plottable.Core.KeyEventListener.addCallback(this.keyCode, function (e) { - if (_this.activated && _this._callback != null) { - _this._callback(); + this.dispatcher.target(this._hitBox); + this.dispatcher.onKeyDown(function (e) { + if (_this.keyCode2Callback[e.keyCode]) { + _this.keyCode2Callback[e.keyCode](); } }); + this.dispatcher.connect(); }; /** - * Sets a callback to be called when the designated key is pressed and the - * user is moused over the component. + * Sets a callback to be called when the key with the given keyCode is + * pressed and the user is moused over the Component. * - * @param {() => any} cb Callback to be called. - * @returns The calling Key. + * @param {number} keyCode The key code associated with the key. + * @param {() => void} callback Callback to be called. + * @returns The calling Interaction.Key. */ - Key.prototype.callback = function (cb) { - this._callback = cb; + Key.prototype.on = function (keyCode, callback) { + this.keyCode2Callback[keyCode] = callback; return this; }; return Key; @@ -8679,6 +9075,7 @@ var Plottable; _super.apply(this, arguments); this.currentHoverData = { data: null, + pixelPositions: null, selection: null }; } @@ -8695,6 +9092,7 @@ var Plottable; _this.safeHoverOut(_this.currentHoverData); _this.currentHoverData = { data: null, + pixelPositions: null, selection: null }; }); @@ -8708,28 +9106,37 @@ var Plottable; if (a.data == null || b.data == null) { return a; } - var notInB = function (d) { return b.data.indexOf(d) === -1; }; - var diffData = a.data.filter(notInB); + var diffData = []; + var diffPoints = []; + var diffElements = []; + a.data.forEach(function (d, i) { + if (b.data.indexOf(d) === -1) { + diffData.push(d); + diffPoints.push(a.pixelPositions[i]); + diffElements.push(a.selection[0][i]); + } + }); if (diffData.length === 0) { return { data: null, + pixelPositions: null, selection: null }; } - var diffSelection = a.selection.filter(notInB); return { data: diffData, - selection: diffSelection + pixelPositions: diffPoints, + selection: d3.selectAll(diffElements) }; }; Hover.prototype.handleHoverOver = function (p) { var lastHoverData = this.currentHoverData; var newHoverData = this._componentToListenTo._doHover(p); + this.currentHoverData = newHoverData; var outData = Hover.diffHoverData(lastHoverData, newHoverData); this.safeHoverOut(outData); var overData = Hover.diffHoverData(newHoverData, lastHoverData); this.safeHoverOver(overData); - this.currentHoverData = newHoverData; }; Hover.prototype.safeHoverOut = function (outData) { if (this.hoverOutCallback && outData.data) { @@ -8778,153 +9185,3 @@ var Plottable; })(Plottable.Interaction || (Plottable.Interaction = {})); var Interaction = Plottable.Interaction; })(Plottable || (Plottable = {})); - -/// -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Plottable; -(function (Plottable) { - (function (Dispatcher) { - var AbstractDispatcher = (function (_super) { - __extends(AbstractDispatcher, _super); - /** - * Constructs a Dispatcher with the specified target. - * - * @param {D3.Selection} target The selection to listen for events on. - */ - function AbstractDispatcher(target) { - _super.call(this); - this._event2Callback = {}; - this.connected = false; - this._target = target; - } - AbstractDispatcher.prototype.target = function (targetElement) { - if (targetElement == null) { - return this._target; - } - var wasConnected = this.connected; - this.disconnect(); - this._target = targetElement; - if (wasConnected) { - // re-connect to the new target - this.connect(); - } - return this; - }; - /** - * Gets a namespaced version of the event name. - */ - AbstractDispatcher.prototype.getEventString = function (eventName) { - return eventName + ".dispatcher" + this._plottableID; - }; - /** - * Attaches the Dispatcher's listeners to the Dispatcher's target element. - * - * @returns {Dispatcher} The calling Dispatcher. - */ - AbstractDispatcher.prototype.connect = function () { - var _this = this; - if (this.connected) { - throw new Error("Can't connect dispatcher twice!"); - } - this.connected = true; - Object.keys(this._event2Callback).forEach(function (event) { - var callback = _this._event2Callback[event]; - _this._target.on(_this.getEventString(event), callback); - }); - return this; - }; - /** - * Detaches the Dispatcher's listeners from the Dispatchers' target element. - * - * @returns {Dispatcher} The calling Dispatcher. - */ - AbstractDispatcher.prototype.disconnect = function () { - var _this = this; - this.connected = false; - Object.keys(this._event2Callback).forEach(function (event) { - _this._target.on(_this.getEventString(event), null); - }); - return this; - }; - return AbstractDispatcher; - })(Plottable.Core.PlottableObject); - Dispatcher.AbstractDispatcher = AbstractDispatcher; - })(Plottable.Dispatcher || (Plottable.Dispatcher = {})); - var Dispatcher = Plottable.Dispatcher; -})(Plottable || (Plottable = {})); - -/// -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Plottable; -(function (Plottable) { - (function (Dispatcher) { - var Mouse = (function (_super) { - __extends(Mouse, _super); - /** - * Constructs a Mouse Dispatcher with the specified target. - * - * @param {D3.Selection} target The selection to listen for events on. - */ - function Mouse(target) { - var _this = this; - _super.call(this, target); - this._event2Callback["mouseover"] = function () { - if (_this._mouseover != null) { - _this._mouseover(_this.getMousePosition()); - } - }; - this._event2Callback["mousemove"] = function () { - if (_this._mousemove != null) { - _this._mousemove(_this.getMousePosition()); - } - }; - this._event2Callback["mouseout"] = function () { - if (_this._mouseout != null) { - _this._mouseout(_this.getMousePosition()); - } - }; - } - Mouse.prototype.getMousePosition = function () { - var xy = d3.mouse(this._target.node()); - return { - x: xy[0], - y: xy[1] - }; - }; - Mouse.prototype.mouseover = function (callback) { - if (callback === undefined) { - return this._mouseover; - } - this._mouseover = callback; - return this; - }; - Mouse.prototype.mousemove = function (callback) { - if (callback === undefined) { - return this._mousemove; - } - this._mousemove = callback; - return this; - }; - Mouse.prototype.mouseout = function (callback) { - if (callback === undefined) { - return this._mouseout; - } - this._mouseout = callback; - return this; - }; - return Mouse; - })(Dispatcher.AbstractDispatcher); - Dispatcher.Mouse = Mouse; - })(Plottable.Dispatcher || (Plottable.Dispatcher = {})); - var Dispatcher = Plottable.Dispatcher; -})(Plottable || (Plottable = {})); diff --git a/plottable.min.js b/plottable.min.js index 01a7c14272..4d5b6a47b4 100644 --- a/plottable.min.js +++ b/plottable.min.js @@ -1,5 +1,5 @@ -var Plottable;!function(a){!function(a){!function(a){function b(a,b,c){return Math.min(b,c)<=a&&a<=Math.max(b,c)}function c(a){null!=window.console&&(null!=window.console.warn?console.warn(a):null!=window.console.log&&console.log(a))}function d(a,b){if(a.length!==b.length)throw new Error("attempted to add arrays of unequal length");return a.map(function(c,d){return a[d]+b[d]})}function e(a,b){var c=d3.set();return a.forEach(function(a){b.has(a)&&c.add(a)}),c}function f(a){return"function"==typeof a?a:"string"==typeof a&&"#"!==a[0]?function(b){return b[a]}:function(){return a}}function g(a,b){var c=f(a);return function(a,d){var e=b.datasets(),f=e.length>0?e[0]:null,g=f?f.metadata():null;return c(a,d,g)}}function h(a,b){var c=d3.set();return a.forEach(function(a){return c.add(a)}),b.forEach(function(a){return c.add(a)}),c}function i(a,b){var c=d3.map();return a.forEach(function(a,d){c.set(a,b(a,d))}),c}function j(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(a)||(b.add(a),c.push(a))}),c}function k(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}function l(a){return Array.prototype.concat.apply([],a)}function m(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;cf;++f)e[f]=a+c*f;return e}function s(a,b){for(var c=[],d=2;dd;){var f=d+e>>>1,g=null==c?b[f]:c(b[f]);a>g?d=f+1:e=f}return d}a.sortedIndex=b}(a.OpenSource||(a.OpenSource={}));a.OpenSource}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.counter={}}return a.prototype.setDefault=function(a){null==this.counter[a]&&(this.counter[a]=0)},a.prototype.increment=function(a){return this.setDefault(a),++this.counter[a]},a.prototype.decrement=function(a){return this.setDefault(a),--this.counter[a]},a.prototype.get=function(a){return this.setDefault(a),this.counter[a]},a}();a.IDCounter=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.keyValuePairs=[]}return a.prototype.set=function(a,b){if(a!==a)throw new Error("NaN may not be used as a key to the StrictEqualityAssociativeArray");for(var c=0;cb){var h=e("."),i=Math.floor(b/h);return"...".substr(0,i)}for(;f+g>b;)d=d.substr(0,d.length-1).trim(),f=e(d);if(e(d+"...")>b)throw new Error("addEllipsesToLine failed :(");return d+"..."}function i(b,c,d,e,f,g){void 0===f&&(f="left"),void 0===g&&(g="top");var h={left:0,center:.5,right:1},i={top:0,center:.5,bottom:1};if(void 0===h[f]||void 0===i[g])throw new Error("unrecognized alignment x:"+f+", y:"+g);var j=c.append("g"),k=j.append("text");k.text(b);var l=a.DOM.getBBox(k),m=l.height,n=l.width;if(n>d||m>e)return a.Methods.warn("Insufficient space to fit text: "+b),k.text(""),{width:0,height:0};var o={left:"start",center:"middle",right:"end"},p=o[f],q=d*h[f],r=e*i[g],s=.85-i[g];return k.attr("text-anchor",p).attr("y",s+"em"),a.DOM.translate(j,q,r),{width:n,height:m}}function j(a,b,c,d,e,f,g){if(void 0===e&&(e="left"),void 0===f&&(f="top"),void 0===g&&(g="right"),"right"!==g&&"left"!==g)throw new Error("unrecognized rotation: "+g);var h="right"===g,j={left:"bottom",right:"top",center:"center",top:"left",bottom:"right"},k={left:"top",right:"bottom",center:"center",top:"right",bottom:"left"},l=h?j:k,m=b.append("g"),n=i(a,m,d,c,l[f],l[e]),o=d3.transform("");return o.rotate="right"===g?90:-90,o.translate=[h?c:0,h?0:d],m.attr("transform",o.toString()),m.classed("rotated-"+g,!0),{width:n.height,height:n.width}}function k(d,e,f,g,h,j){void 0===h&&(h="left"),void 0===j&&(j="top");var k=c(e.append("text"))(b.HEIGHT_TEXT).height,l=0,m=e.append("g");d.forEach(function(b,c){var d=m.append("g");a.DOM.translate(d,0,c*k);var e=i(b,d,f,k,h,j);e.width>l&&(l=e.width)});var n=k*d.length,o=g-n,p={center:.5,top:0,bottom:1};return a.DOM.translate(m,0,o*p[j]),{width:l,height:n}}function l(d,e,f,g,h,i,k){void 0===h&&(h="left"),void 0===i&&(i="top"),void 0===k&&(k="left");var l=c(e.append("text"))(b.HEIGHT_TEXT).height,m=0,n=e.append("g");d.forEach(function(b,c){var d=n.append("g");a.DOM.translate(d,c*l,0);var e=j(b,d,l,g,h,i,k);e.height>m&&(m=e.height)});var o=l*d.length,p=f-o,q={center:.5,left:0,right:1};return a.DOM.translate(n,p*q[h],0),{width:o,height:m}}function m(b,c,d,e,f,g){if(void 0===f&&(f="horizontal"),-1===["left","right","horizontal"].indexOf(f))throw new Error("Unrecognized orientation to writeText: "+f);var h="horizontal"===f,i=h?c:d,j=h?d:c,m=a.WordWrap.breakTextToFitRect(b,i,j,e);if(0===m.lines.length)return{textFits:m.textFits,usedWidth:0,usedHeight:0};var n,o;if(null==g){var p=h?a.Methods.max:d3.sum,q=h?d3.sum:a.Methods.max,r=function(a){return h?e(a).height:e(a).width},s=function(a){return h?e(a).width:e(a).height};n=p(m.lines,s,0),o=q(m.lines,r,0)}else{var t=g.g.append("g").classed("writeText-inner-g",!0),u=h?k:l,v=u.call(this,m.lines,t,c,d,g.xAlign,g.yAlign,f);n=v.width,o=v.height}return{textFits:m.textFits,usedWidth:n,usedHeight:o}}b.HEIGHT_TEXT="bqpdl",b.getTextMeasurer=c;var n="a",o=function(){function b(b){var g=this;this.cache=new a.Cache(c(b),n,a.Methods.objEq),this.measure=d(e(f(function(a){return g.cache.get(a)})))}return b.prototype.clear=function(){return this.cache.clear(),this},b}();b.CachingCharacterMeasurer=o,b.getTruncatedText=g,b.addEllipsesToLine=h,b.writeLineHorizontally=i,b.writeLineVertically=j,b.writeText=m}(a.Text||(a.Text={}));a.Text}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(b){function c(b,c,e,f){var g=function(a){return f(a).width},h=d(b,c,g),i=f("hello world").height,j=Math.floor(e/i),k=j>=h.length;return k||(h=h.splice(0,j),j>0&&(h[j-1]=a.Text.addEllipsesToLine(h[j-1],c,f))),{originalText:b,lines:h,textFits:k}}function d(a,b,c){for(var d=[],e=a.split("\n"),g=0,h=e.length;h>g;g++){var i=e[g];null!==i?d=d.concat(f(i,b,c)):d.push("")}return d}function e(b,c,d){var e=h(b),f=e.map(d),g=a.Methods.max(f,0);return c>=g}function f(a,b,c){for(var d,e=[],f=h(a),i="",j=0;d||je;e++){var g=a[e];""===c||j(c[0],g,d)?c+=g:(b.push(c),c=g),d=g}return c&&b.push(c),b}function i(a){return null==a?!0:""===a.trim()}function j(a,b,c){return m.test(a)&&m.test(b)?!0:m.test(a)||m.test(b)?!1:l.test(c)||k.test(b)?!1:!0}var k=/[{\[]/,l=/[!"%),-.:;?\]}]/,m=/^\s+$/;b.breakTextToFitRect=c,b.canWrapWithoutBreakingWords=e}(a.WordWrap||(a.WordWrap={}));a.WordWrap}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b;try{b=a.node().getBBox()}catch(c){b={x:0,y:0,width:0,height:0}}return b}function c(b){null!=window.requestAnimationFrame?window.requestAnimationFrame(b):setTimeout(b,a.POLYFILL_TIMEOUT_MSEC)}function d(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d!==d?0:d}function e(a){for(var b=a.node();null!==b&&"svg"!==b.nodeName;)b=b.parentNode;return null==b}function f(a){var b=window.getComputedStyle(a);return d(b,"width")+d(b,"padding-left")+d(b,"padding-right")+d(b,"border-left-width")+d(b,"border-right-width")}function g(a){var b=window.getComputedStyle(a);return d(b,"height")+d(b,"padding-top")+d(b,"padding-bottom")+d(b,"border-top-width")+d(b,"border-bottom-width")}function h(a){var b=a.node().clientWidth;if(0===b){var c=a.attr("width");if(-1!==c.indexOf("%")){for(var d=a.node().parentNode;null!=d&&0===d.clientWidth;)d=d.parentNode;if(null==d)throw new Error("Could not compute width of element");b=d.clientWidth*parseFloat(c)/100}else b=parseFloat(c)}return b}function i(a,b,c){var d=d3.transform(a.attr("transform"));return null==b?d.translate:(c=null==c?0:c,d.translate[0]=b,d.translate[1]=c,a.attr("transform",d.toString()),a)}function j(a,b){return a.rightb.right?!1:a.bottomb.bottom?!1:!0}a.getBBox=b,a.POLYFILL_TIMEOUT_MSEC=1e3/60,a.requestAnimationFramePolyfill=c,a.isSelectionRemovedFromSVG=e,a.getElementWidth=f,a.getElementHeight=g,a.getSVGPixelWidth=h,a.translate=i,a.boxesOverlap=j}(a.DOM||(a.DOM={}));a.DOM}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),f=c(b.b);return.2126*d+.7152*e+.0722*f}function c(a,c){var d=b(a)+.05,e=b(c)+.05;return d>e?d/e:e/d}a.contrast=c}(a.Color||(a.Color={}));a.Color}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){a.MILLISECONDS_IN_ONE_DAY=864e5,function(b){function c(a,c,d,e){void 0===a&&(a=2),void 0===c&&(c="$"),void 0===d&&(d=!0),void 0===e&&(e=!0);var f=b.fixed(a);return function(a){var b=f(Math.abs(a));return e&&l(Math.abs(a),b)?"":(""!==b&&(d?b=c+b:b+=c,0>a&&(b="-"+b)),b)}}function d(a,b){return void 0===a&&(a=3),void 0===b&&(b=!0),k(a),function(c){var d=c.toFixed(a);return b&&l(c,d)?"":d}}function e(a,b){return void 0===a&&(a=3),void 0===b&&(b=!0),k(a),function(c){if("number"==typeof c){var d=Math.pow(10,a),e=String(Math.round(c*d)/d);return b&&l(c,e)?"":e}return String(c)}}function f(){return function(a){return String(a)}}function g(a,c){void 0===a&&(a=0),void 0===c&&(c=!0);var d=b.fixed(a,c);return function(a){var b=100*a,e=a.toString(),f=Math.pow(10,e.length-(e.indexOf(".")+1));b=parseInt((b*f).toString(),10)/f;var g=d(b);return c&&l(b,g)?"":(""!==g&&(g+="%"),g)}}function h(a){return void 0===a&&(a=3),k(a),function(b){return d3.format("."+a+"s")(b)}}function i(){var a=8,b={};return b[0]={format:".%L",filter:function(a){return 0!==a.getMilliseconds()}},b[1]={format:":%S",filter:function(a){return 0!==a.getSeconds()}},b[2]={format:"%I:%M",filter:function(a){return 0!==a.getMinutes()}},b[3]={format:"%I %p",filter:function(a){return 0!==a.getHours()}},b[4]={format:"%a %d",filter:function(a){return 0!==a.getDay()&&1!==a.getDate()}},b[5]={format:"%b %d",filter:function(a){return 1!==a.getDate()}},b[6]={format:"%b",filter:function(a){return 0!==a.getMonth()}},b[7]={format:"%Y",filter:function(){return!0}},function(c){for(var d=0;a>d;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function j(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function k(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20")}function l(a,b){return a!==parseFloat(b)}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.time=i,b.relativeDate=j}(a.Formatters||(a.Formatters={}));a.Formatters}(Plottable||(Plottable={}));var Plottable;!function(a){a.version="0.34.1"}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.CORAL_RED="#fd373e",a.INDIGO="#5279c7",a.ROBINS_EGG_BLUE="#06cccc",a.FERN="#63c261",a.BURNING_ORANGE="#ff7939",a.ROYAL_HEATH="#962565",a.CONIFER="#99ce50",a.CERISE_RED="#db2e65",a.BRIGHT_SUN="#fad419",a.JACARTA="#2c2b6f",a.PLOTTABLE_COLORS=[a.INDIGO,a.CORAL_RED,a.FERN,a.BRIGHT_SUN,a.JACARTA,a.BURNING_ORANGE,a.CERISE_RED,a.CONIFER,a.ROYAL_HEATH,a.ROBINS_EGG_BLUE],a}();a.Colors=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._plottableID=a.nextID++}return a.nextID=0,a}();a.PlottableObject=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this.key2callback=new a._Util.StrictEqualityAssociativeArray,this.listenable=c}return __extends(c,b),c.prototype.registerListener=function(a,b){return this.key2callback.set(a,b),this},c.prototype.broadcast=function(){for(var a=this,b=[],c=0;c0){var f=d.valueOf();return d instanceof Date?[f-b.ONE_DAY,f+b.ONE_DAY]:[f-b.PADDING_FOR_IDENTICAL_DOMAIN,f+b.PADDING_FOR_IDENTICAL_DOMAIN]}if(a.domain()[0]===a.domain()[1])return c;var g=this.padProportion/2,h=a.invert(a.scale(d)-(a.scale(e)-a.scale(d))*g),i=a.invert(a.scale(e)+(a.scale(e)-a.scale(d))*g),j=this.paddingExceptions.values().concat(this.unregisteredPaddingExceptions.values()),k=d3.set(j);return k.has(d)&&(h=d),k.has(e)&&(i=e),[h,i]},b.prototype.niceDomain=function(a,b){return this.doNice?a._niceDomain(b,this.niceCount):b},b.prototype.includeDomain=function(a){var b=this.includedValues.values().concat(this.unregisteredIncludedValues.values());return b.reduce(function(a,b){return[Math.min(a[0],b),Math.max(a[1],b)]},a)},b.PADDING_FOR_IDENTICAL_DOMAIN=1,b.ONE_DAY=864e5,b}();a.Domainer=b}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this._autoDomainAutomatically=!0,this.broadcaster=new a.Core.Broadcaster(this),this._rendererAttrID2Extent={},this._typeCoercer=function(a){return a},this._d3Scale=c}return __extends(c,b),c.prototype._getAllExtents=function(){return d3.values(this._rendererAttrID2Extent)},c.prototype._getExtent=function(){return[]},c.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},c.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setDomain=function(a){this._d3Scale.domain(a),this.broadcaster.broadcast()},c.prototype.range=function(a){return null==a?this._d3Scale.range():(this._d3Scale.range(a),this)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._updateExtent=function(a,b,c){return this._rendererAttrID2Extent[a+b]=c,this._autoDomainIfAutomaticMode(),this},c.prototype._removeExtent=function(a,b){return delete this._rendererAttrID2Extent[a+b],this._autoDomainIfAutomaticMode(),this},c}(a.Core.PlottableObject);b.AbstractScale=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this,c),this._numTicks=10,this._PADDING_FOR_IDENTICAL_DOMAIN=1,this._userSetDomainer=!1,this._domainer=new a.Domainer,this._typeCoercer=function(a){return+a},this._tickGenerator=function(a){return a.getDefaultTicks()}}return __extends(c,b),c.prototype._getExtent=function(){return this._domainer.computeDomain(this._getAllExtents(),this)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(c){var d=function(a){return a!==a||1/0===a||a===-1/0};return d(c[0])||d(c[1])?void a._Util.Methods.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.interpolate=function(a){return null==a?this._d3Scale.interpolate():(this._d3Scale.interpolate(a),this)},c.prototype.rangeRound=function(a){return this._d3Scale.rangeRound(a),this},c.prototype.getDefaultTicks=function(){return this._d3Scale.ticks(this.numTicks())},c.prototype.clamp=function(a){return null==a?this._d3Scale.clamp():(this._d3Scale.clamp(a),this)},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype.numTicks=function(a){return null==a?this._numTicks:(this._numTicks=a,this)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c.prototype.domainer=function(a){return null==a?this._domainer:(this._domainer=a,this._userSetDomainer=!0,this._autoDomainIfAutomaticMode(),this)},c.prototype._defaultExtent=function(){return[0,1]},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c}(b.AbstractScale);b.AbstractQuantitative=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){a.call(this,null==b?d3.scale.linear():b)}return __extends(b,a),b.prototype.copy=function(){return new b(this._d3Scale.copy())},b}(a.AbstractQuantitative);a.Linear=b}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(d){b.call(this,null==d?d3.scale.log():d),c.warned||(c.warned=!0,a._Util.Methods.warn("Plottable.Scale.Log is deprecated. If possible, use Plottable.Scale.ModifiedLog instead."))}return __extends(c,b),c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){return[1,10]},c.warned=!1,c}(b.AbstractQuantitative);b.Log=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(void 0===a&&(a=10),b.call(this,d3.scale.linear()),this._showIntermediateTicks=!1,this.base=a,this.pivot=this.base,this.untransformedDomain=this._defaultExtent(),this._numTicks=10,1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return __extends(c,b),c.prototype.adjustedLog=function(a){var b=0>a?-1:1;return a*=b,aa?-1:1;return a*=b,a=Math.pow(this.base,a),a=d&&e>=a}),m=j.concat(l).concat(k);return m.length<=1&&(m=d3.scale.linear().domain([d,e]).ticks(b)),m},c.prototype.logTicks=function(b,c){var d=this,e=this.howManyTicks(b,c);if(0===e)return[];var f=Math.floor(Math.log(b)/Math.log(this.base)),g=Math.ceil(Math.log(c)/Math.log(this.base)),h=d3.range(g,f,-Math.ceil((g-f)/e)),i=this._showIntermediateTicks?Math.floor(e/h.length):1,j=d3.range(this.base,1,-(this.base-1)/i).map(Math.floor),k=a._Util.Methods.uniq(j),l=h.map(function(a){return k.map(function(b){return Math.pow(d.base,a-1)*b})}),m=a._Util.Methods.flatten(l),n=m.filter(function(a){return a>=b&&c>=a}),o=n.sort(function(a,b){return a-b});return o},c.prototype.howManyTicks=function(b,c){var d=this.adjustedLog(a._Util.Methods.min(this.untransformedDomain,0)),e=this.adjustedLog(a._Util.Methods.max(this.untransformedDomain,0)),f=this.adjustedLog(b),g=this.adjustedLog(c),h=(g-f)/(e-d),i=Math.ceil(h*this._numTicks);return i},c.prototype.copy=function(){return new c(this.base)},c.prototype._niceDomain=function(a){return a},c.prototype.showIntermediateTicks=function(a){return null==a?this._showIntermediateTicks:void(this._showIntermediateTicks=a)},c}(b.AbstractQuantitative);b.ModifiedLog=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(b.call(this,null==a?d3.scale.ordinal():a),this._range=[0,1],this._rangeType="bands",this._innerPadding=.3,this._outerPadding=.5,this._typeCoercer=function(a){return null!=a&&a.toString?a.toString():a},this._innerPadding>this._outerPadding)throw new Error("outerPadding must be >= innerPadding so cat axis bands work out reasonably")}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents();return a._Util.Methods.uniq(a._Util.Methods.flatten(b))},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(a){b.prototype._setDomain.call(this,a),this.range(this.range())},c.prototype.range=function(a){return null==a?this._range:(this._range=a,"points"===this._rangeType?this._d3Scale.rangePoints(a,2*this._outerPadding):"bands"===this._rangeType&&this._d3Scale.rangeBands(a,this._innerPadding,this._outerPadding),this)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.innerPadding=function(){var a=this.domain();if(a.length<2)return 0;var b=Math.abs(this.scale(a[1])-this.scale(a[0]));return b-this.rangeBand()},c.prototype.fullBandStartAndWidth=function(a){var b=this.scale(a)-this.innerPadding()/2,c=this.rangeBand()+this.innerPadding();return[b,c]},c.prototype.rangeType=function(a,b,c){if(null==a)return this._rangeType;if("points"!==a&&"bands"!==a)throw new Error("Unsupported range type: "+a); -return this._rangeType=a,null!=b&&(this._outerPadding=b),null!=c&&(this._innerPadding=c),this.range(this.range()),this.broadcaster.broadcast(),this},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c}(b.AbstractScale);b.Ordinal=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){var d;switch(c){case null:case void 0:d=d3.scale.ordinal().range(a.Core.Colors.PLOTTABLE_COLORS);break;case"Category10":case"category10":case"10":d=d3.scale.category10();break;case"Category20":case"category20":case"20":d=d3.scale.category20();break;case"Category20b":case"category20b":case"20b":d=d3.scale.category20b();break;case"Category20c":case"category20c":case"20c":d=d3.scale.category20c();break;default:throw new Error("Unsupported ColorScale type")}b.call(this,d)}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents(),c=[];return b.forEach(function(a){c=c.concat(a)}),a._Util.Methods.uniq(c)},c}(b.AbstractScale);b.Color=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,null==a?d3.time.scale():a),this._typeCoercer=function(a){return a&&a._isAMomentObject||a instanceof Date?a:new Date(a)}}return __extends(c,b),c.prototype._tickInterval=function(a,b){var c=d3.time.scale();return c.domain(this.domain()),c.range(this.range()),c.ticks(a.range,b)},c.prototype._setDomain=function(a){return a=a.map(this._typeCoercer),b.prototype._setDomain.call(this,a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){var b=(new Date).valueOf(),c=b-a.MILLISECONDS_IN_ONE_DAY;return[c,b]},c}(b.AbstractQuantitative);b.Time=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,d){void 0===a&&(a="reds"),void 0===d&&(d="linear"),this._colorRange=this._resolveColorValues(a),this._scaleType=d,b.call(this,c.getD3InterpolatedScale(this._colorRange,this._scaleType))}return __extends(c,b),c.getD3InterpolatedScale=function(a,b){var d;switch(b){case"linear":d=d3.scale.linear();break;case"log":d=d3.scale.log();break;case"sqrt":d=d3.scale.sqrt();break;case"pow":d=d3.scale.pow()}if(null==d)throw new Error("unknown Quantitative scale type "+b);return d.range([0,1]).interpolate(c.interpolateColors(a))},c.interpolateColors=function(a){if(a.length<2)throw new Error("Color scale arrays must have at least two elements.");return function(){return function(b){b=Math.max(0,Math.min(1,b));var c=b*(a.length-1),d=Math.floor(c),e=Math.ceil(c),f=c-d;return d3.interpolateLab(a[d],a[e])(f)}}},c.prototype.colorRange=function(a){return null==a?this._colorRange:(this._colorRange=this._resolveColorValues(a),this._resetScale(),this)},c.prototype.scaleType=function(a){return null==a?this._scaleType:(this._scaleType=a,this._resetScale(),this)},c.prototype._resetScale=function(){this._d3Scale=c.getD3InterpolatedScale(this._colorRange,this._scaleType),this._autoDomainIfAutomaticMode(),this.broadcaster.broadcast()},c.prototype._resolveColorValues=function(a){return a instanceof Array?a:null!=c.COLOR_SCALES[a]?c.COLOR_SCALES[a]:c.COLOR_SCALES.reds},c.prototype.autoDomain=function(){var b=this._getAllExtents();return b.length>0&&this._setDomain([a._Util.Methods.min(b,function(a){return a[0]},0),a._Util.Methods.max(b,function(a){return a[1]},0)]),this},c.COLOR_SCALES={reds:["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],blues:["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],posneg:["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"]},c}(b.AbstractScale);b.InterpolatedColor=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(a){var b=this;if(this.rescaleInProgress=!1,null==a)throw new Error("ScaleDomainCoordinator requires scales to coordinate");this.scales=a,this.scales.forEach(function(a){return a.broadcaster.registerListener(b,function(a){return b.rescale(a)})})}return a.prototype.rescale=function(a){if(!this.rescaleInProgress){this.rescaleInProgress=!0;var b=a.domain();this.scales.forEach(function(a){return a.domain(b)}),this.rescaleInProgress=!1}},a}();a.ScaleDomainCoordinator=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){!function(b){function c(b){if(0>=b)throw new Error("interval must be positive number");return function(c){var d=c.domain(),e=Math.min(d[0],d[1]),f=Math.max(d[0],d[1]),g=Math.ceil(e/b)*b,h=Math.floor((f-g)/b)+1,i=e%b===0?[]:[e],j=a._Util.Methods.range(0,h).map(function(a){return g+a*b}),k=f%b===0?[]:[f];return i.concat(j).concat(k)}}b.intervalTickGenerator=c}(b.TickGenerators||(b.TickGenerators={}));b.TickGenerators}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){var c=function(){function b(a){this.key=a}return b.prototype.setClass=function(a){return this._className=a,this},b.prototype.setup=function(a){this._renderArea=a},b.prototype.remove=function(){null!=this._renderArea&&this._renderArea.remove()},b.prototype._enterData=function(){},b.prototype._drawStep=function(){},b.prototype._numberOfAnimationIterations=function(a){return a.length},b.prototype.draw=function(b,c){var d=this;this._enterData(b);var e=this._numberOfAnimationIterations(b),f=0;return c.forEach(function(b){a._Util.Methods.setTimeout(function(){return d._drawStep(b)},f),f+=b.animator.getTiming(e)}),f},b}();b.AbstractDrawer=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype._enterData=function(a){b.prototype._enterData.call(this,a),this.pathSelection.datum(a)},c.prototype.setup=function(a){this.pathSelection=a.append("path").classed("line",!0).style({fill:"none","vector-effect":"non-scaling-stroke"}),b.prototype.setup.call(this,a)},c.prototype.createLine=function(a,b,c){return c||(c=function(){return!0}),d3.svg.line().x(a).y(b).defined(c)},c.prototype._numberOfAnimationIterations=function(){return 1},c.prototype._drawStep=function(c){{var d=(b.prototype._drawStep.call(this,c),a._Util.Methods.copyMap(c.attrToProjector)),e=d.x,f=d.y;d.defined}delete d.x,delete d.y,d.d=this.createLine(e,f,d.defined),d.defined&&delete d.defined,d.fill&&this.pathSelection.attr("fill",d.fill),c.animator.animate(this.pathSelection,d)},c}(b.AbstractDrawer);b.Line=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(){c.apply(this,arguments),this._drawLine=!0}return __extends(d,c),d.prototype._enterData=function(a){this._drawLine?c.prototype._enterData.call(this,a):b.AbstractDrawer.prototype._enterData.call(this,a),this.areaSelection.datum(a)},d.prototype.drawLine=function(a){return this._drawLine=a,this},d.prototype.setup=function(a){this.areaSelection=a.append("path").classed("area",!0).style({stroke:"none"}),this._drawLine?c.prototype.setup.call(this,a):b.AbstractDrawer.prototype.setup.call(this,a)},d.prototype.createArea=function(a,b,c,d){return d||(d=function(){return!0}),d3.svg.area().x(a).y0(b).y1(c).defined(d)},d.prototype._drawStep=function(d){this._drawLine?c.prototype._drawStep.call(this,d):b.AbstractDrawer.prototype._drawStep.call(this,d);{var e=a._Util.Methods.copyMap(d.attrToProjector),f=e.x,g=e.y0,h=e.y;e.defined}delete e.x,delete e.y0,delete e.y,e.d=this.createArea(f,g,h,e.defined),e.defined&&delete e.defined,e.fill&&this.areaSelection.attr("fill",e.fill),d.animator.animate(this.areaSelection,e)},d}(b.Line);b.Area=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype.svgElement=function(a){return this._svgElement=a,this},b.prototype._getDrawSelection=function(){return this._renderArea.selectAll(this._svgElement)},b.prototype._drawStep=function(b){a.prototype._drawStep.call(this,b);var c=this._getDrawSelection();b.attrToProjector.fill&&c.attr("fill",b.attrToProjector.fill),b.animator.animate(c,b.attrToProjector)},b.prototype._enterData=function(b){a.prototype._enterData.call(this,b);var c=this._getDrawSelection().data(b);c.enter().append(this._svgElement),null!=this._className&&c.classed(this._className,!0),c.exit().remove()},b}(a.AbstractDrawer);a.Element=b}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=5,d=5,e=function(b){function e(a,c){b.call(this,a),this._someLabelsTooWide=!1,this.svgElement("rect"),this._isVertical=c}return __extends(e,b),e.prototype.setup=function(c){b.prototype.setup.call(this,c.append("g").classed("bar-area",!0)),this.textArea=c.append("g").classed("bar-label-text-area",!0),this.measurer=new a._Util.Text.CachingCharacterMeasurer(this.textArea.append("text")).measure},e.prototype.removeLabels=function(){this.textArea.selectAll("g").remove()},e.prototype.drawText=function(b,e){var f=this,g=b.map(function(b,g){var h=e.label(b,g).toString(),i=e.width(b,g),j=e.height(b,g),k=e.x(b,g),l=e.y(b,g),m=e.positive(b,g),n=f.measurer(h),o=e.fill(b,g),p=1.6*a._Util.Color.contrast("white",o)t;if(n.height<=j&&n.width<=i){var v=Math.min((q-r)/2,c);m||(v=-1*v),f._isVertical?l+=v:k+=v;var w=f.textArea.append("g").attr("transform","translate("+k+","+l+")"),x=p?"dark-label":"light-label";w.classed(x,!0);var y,z;f._isVertical?(y="center",z=m?"top":"bottom"):(y=m?"left":"right",z="center"),a._Util.Text.writeLineHorizontally(h,w,i,j,y,z)}return u});this._someLabelsTooWide=g.some(function(a){return a})},e}(b.Element);b.Rect=e}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,a),this._svgElement="path"}return __extends(c,b),c.prototype.createArc=function(a,b){return d3.svg.arc().innerRadius(a).outerRadius(b)},c.prototype.retargetProjectors=function(a){var b={};return d3.entries(a).forEach(function(a){b[a.key]=function(b,c){return a.value(b.data,c)}}),b},c.prototype._drawStep=function(c){var d=a._Util.Methods.copyMap(c.attrToProjector);d=this.retargetProjectors(d);var e=d["inner-radius"],f=d["outer-radius"];return delete d["inner-radius"],delete d["outer-radius"],d.d=this.createArc(e,f),b.prototype._drawStep.call(this,{attrToProjector:d,animator:c.animator})},c.prototype.draw=function(a,c){var d=c[0].attrToProjector.value,e=d3.layout.pie().sort(null).value(d)(a);return c.forEach(function(a){return delete a.attrToProjector.value}),b.prototype.draw.call(this,e,c)},c}(b.Element);b.Arc=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.clipPathEnabled=!1,this._xAlignProportion=0,this._yAlignProportion=0,this._fixedHeightFlag=!1,this._fixedWidthFlag=!1,this._isSetup=!1,this._isAnchored=!1,this.interactionsToRegister=[],this.boxes=[],this.isTopLevelComponent=!1,this._width=0,this._height=0,this._xOffset=0,this._yOffset=0,this.cssClasses=["component"],this.removed=!1}return __extends(c,b),c.prototype._anchor=function(a){if(this.removed)throw new Error("Can't reuse remove()-ed components!");"svg"===a.node().nodeName&&(this.rootSVG=a,this.rootSVG.classed("plottable",!0),this.rootSVG.style("overflow","visible"),this.isTopLevelComponent=!0),null!=this._element?a.node().appendChild(this._element.node()):(this._element=a.append("g"),this._setup()),this._isAnchored=!0},c.prototype._setup=function(){var a=this;this._isSetup||(this.cssClasses.forEach(function(b){a._element.classed(b,!0)}),this.cssClasses=null,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._content=this._element.append("g").classed("content",!0),this._foregroundContainer=this._element.append("g").classed("foreground-container",!0),this.boxContainer=this._element.append("g").classed("box-container",!0),this.clipPathEnabled&&this.generateClipPath(),this.addBox("bounding-box"),this.interactionsToRegister.forEach(function(b){return a.registerInteraction(b)}),this.interactionsToRegister=null,this.isTopLevelComponent&&this.autoResize(c.AUTORESIZE_BY_DEFAULT),this._isSetup=!0)},c.prototype._requestedSpace=function(){return{width:0,height:0,wantsWidth:!1,wantsHeight:!1}},c.prototype._computeLayout=function(b,c,d,e){var f=this;if(null==b||null==c||null==d||null==e){if(null==this._element)throw new Error("anchor must be called before computeLayout");if(!this.isTopLevelComponent)throw new Error("null arguments cannot be passed to _computeLayout() on a non-root node");b=0,c=0,null==this.rootSVG.attr("width")&&this.rootSVG.attr("width","100%"),null==this.rootSVG.attr("height")&&this.rootSVG.attr("height","100%");var g=this.rootSVG.node();d=a._Util.DOM.getElementWidth(g),e=a._Util.DOM.getElementHeight(g)}this.xOrigin=b,this.yOrigin=c;var h=this._requestedSpace(d,e);this._width=this._isFixedWidth()?Math.min(d,h.width):d,this._height=this._isFixedHeight()?Math.min(e,h.height):e;var i=this.xOrigin+this._xOffset,j=this.yOrigin+this._yOffset;i+=(d-this.width())*this._xAlignProportion,j+=(e-h.height)*this._yAlignProportion,this._element.attr("transform","translate("+i+","+j+")"),this.boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())})},c.prototype._render=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToRender(this)},c.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToComputeLayout(this)},c.prototype._doRender=function(){},c.prototype._invalidateLayout=function(){this._isAnchored&&this._isSetup&&(this.isTopLevelComponent?this._scheduleComputeLayout():this._parent._invalidateLayout())},c.prototype.renderTo=function(b){if(null!=b){var c;if(c="function"==typeof b.node?b:d3.select(b),!c.node()||"svg"!==c.node().nodeName)throw new Error("Plottable requires a valid SVG to renderTo");this._anchor(c)}if(null==this._element)throw new Error("If a component has never been rendered before, then renderTo must be given a node to render to, or a D3.Selection, or a selector string");return this._computeLayout(),this._render(),a.Core.RenderController.flush(),this},c.prototype.resize=function(a,b){if(!this.isTopLevelComponent)throw new Error("Cannot resize on non top-level component");return null!=a&&null!=b&&this._isAnchored&&this.rootSVG.attr({width:a,height:b}),this._invalidateLayout(),this},c.prototype.autoResize=function(b){return b?a.Core.ResizeBroadcaster.register(this):a.Core.ResizeBroadcaster.deregister(this),this},c.prototype.xAlign=function(a){if(a=a.toLowerCase(),"left"===a)this._xAlignProportion=0;else if("center"===a)this._xAlignProportion=.5;else{if("right"!==a)throw new Error("Unsupported alignment");this._xAlignProportion=1}return this._invalidateLayout(),this},c.prototype.yAlign=function(a){if(a=a.toLowerCase(),"top"===a)this._yAlignProportion=0;else if("center"===a)this._yAlignProportion=.5;else{if("bottom"!==a)throw new Error("Unsupported alignment");this._yAlignProportion=1}return this._invalidateLayout(),this},c.prototype.xOffset=function(a){return this._xOffset=a,this._invalidateLayout(),this},c.prototype.yOffset=function(a){return this._yOffset=a,this._invalidateLayout(),this},c.prototype.addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");var b=null==b?this.boxContainer:b,c=b.append("rect");return null!=a&&c.classed(a,!0),this.boxes.push(c),null!=this.width()&&null!=this.height()&&c.attr("width",this.width()).attr("height",this.height()),c},c.prototype.generateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;this._element.attr("clip-path","url("+a+"#clipPath"+this._plottableID+")");var b=this.boxContainer.append("clipPath").attr("id","clipPath"+this._plottableID);this.addBox("clip-rect",b)},c.prototype.registerInteraction=function(a){return this._element?(this.hitBox||(this.hitBox=this.addBox("hit-box"),this.hitBox.style("fill","#ffffff").style("opacity",0)),a._anchor(this,this.hitBox)):this.interactionsToRegister.push(a),this},c.prototype.classed=function(a,b){if(null==b)return null==a?!1:null==this._element?-1!==this.cssClasses.indexOf(a):this._element.classed(a);if(null==a)return this;if(null==this._element){var c=this.cssClasses.indexOf(a);b&&-1===c?this.cssClasses.push(a):b||-1===c||this.cssClasses.splice(c,1)}else this._element.classed(a,b);return this},c.prototype._isFixedWidth=function(){return this._fixedWidthFlag},c.prototype._isFixedHeight=function(){return this._fixedHeightFlag},c.prototype.merge=function(b){var c;if(this._isSetup||this._isAnchored)throw new Error("Can't presently merge a component that's already been anchored");return a.Component.Group.prototype.isPrototypeOf(b)?(c=b,c._addComponent(this,!0),c):c=new a.Component.Group([this,b])},c.prototype.detach=function(){return this._isAnchored&&this._element.remove(),null!=this._parent&&this._parent._removeComponent(this),this._isAnchored=!1,this._parent=null,this},c.prototype.remove=function(){this.removed=!0,this.detach(),a.Core.ResizeBroadcaster.deregister(this)},c.prototype.width=function(){return this._width},c.prototype.height=function(){return this._height},c.AUTORESIZE_BY_DEFAULT=!0,c}(a.Core.PlottableObject);b.AbstractComponent=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this._components=[]}return __extends(b,a),b.prototype._anchor=function(b){var c=this;a.prototype._anchor.call(this,b),this._components.forEach(function(a){return a._anchor(c._content)})},b.prototype._render=function(){this._components.forEach(function(a){return a._render()})},b.prototype._removeComponent=function(a){var b=this._components.indexOf(a);b>=0&&(this._components.splice(b,1),this._invalidateLayout())},b.prototype._addComponent=function(a,b){return void 0===b&&(b=!1),!a||this._components.indexOf(a)>=0?!1:(b?this._components.unshift(a):this._components.push(a),a._parent=this,this._isAnchored&&a._anchor(this._content),this._invalidateLayout(),!0)},b.prototype.components=function(){return this._components.slice()},b.prototype.empty=function(){return 0===this._components.length},b.prototype.detachAll=function(){return this._components.slice().forEach(function(a){return a.detach()}),this},b.prototype.remove=function(){a.prototype.remove.call(this),this._components.slice().forEach(function(a){return a.remove()})},b}(a.AbstractComponent);a.AbstractComponentContainer=b}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.classed("component-group",!0),a.forEach(function(a){return c._addComponent(a)})}return __extends(c,b),c.prototype._requestedSpace=function(b,c){var d=this._components.map(function(a){return a._requestedSpace(b,c)});return{width:a._Util.Methods.max(d,function(a){return a.width},0),height:a._Util.Methods.max(d,function(a){return a.height},0),wantsWidth:d.map(function(a){return a.wantsWidth}).some(function(a){return a}),wantsHeight:d.map(function(a){return a.wantsHeight}).some(function(a){return a})}},c.prototype.merge=function(a){return this._addComponent(a),this},c.prototype._computeLayout=function(a,c,d,e){var f=this;return b.prototype._computeLayout.call(this,a,c,d,e),this._components.forEach(function(a){a._computeLayout(0,0,f.width(),f.height())}),this},c.prototype._isFixedWidth=function(){return this._components.every(function(a){return a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return this._components.every(function(a){return a._isFixedHeight()})},c}(b.AbstractComponentContainer);b.Group=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){var f=this;if(void 0===e&&(e=a.Formatters.identity()),b.call(this),this._endTickLength=5,this._tickLength=5,this._tickLabelPadding=10,this._gutter=15,this._showEndTickLabels=!1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orient(d),this._setDefaultAlignment(),this.classed("axis",!0),this._isHorizontal()?this.classed("x-axis",!0):this.classed("y-axis",!0),this.formatter(e),this._scale.broadcaster.registerListener(this,function(){return f._rescale()})}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this._scale.broadcaster.deregisterListener(this)},c.prototype._isHorizontal=function(){return"top"===this._orientation||"bottom"===this._orientation},c.prototype._computeWidth=function(){return this._computedWidth=this._maxLabelTickLength(),this._computedWidth},c.prototype._computeHeight=function(){return this._computedHeight=this._maxLabelTickLength(),this._computedHeight},c.prototype._requestedSpace=function(a,b){var c=0,d=0;return this._isHorizontal()?(null==this._computedHeight&&this._computeHeight(),d=this._computedHeight+this._gutter):(null==this._computedWidth&&this._computeWidth(),c=this._computedWidth+this._gutter),{width:c,height:d,wantsWidth:!this._isHorizontal()&&c>a,wantsHeight:this._isHorizontal()&&d>b}},c.prototype._isFixedHeight=function(){return this._isHorizontal()},c.prototype._isFixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this._render()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._scale.range(this._isHorizontal()?[0,this.width()]:[this.height(),0])},c.prototype._setup=function(){b.prototype._setup.call(this),this._tickMarkContainer=this._content.append("g").classed(c.TICK_MARK_CLASS+"-container",!0),this._tickLabelContainer=this._content.append("g").classed(c.TICK_LABEL_CLASS+"-container",!0),this._baseline=this._content.append("line").classed("baseline",!0)},c.prototype._getTickValues=function(){return[]},c.prototype._doRender=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);b.enter().append("line").classed(c.TICK_MARK_CLASS,!0),b.attr(this._generateTickMarkAttrHash()),d3.select(b[0][0]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),d3.select(b[0][a.length-1]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),b.exit().remove(),this._baseline.attr(this._generateBaselineAttrHash())},c.prototype._generateBaselineAttrHash=function(){var a={x1:0,y1:0,x2:0,y2:0};switch(this._orientation){case"bottom":a.x2=this.width();break;case"top":a.x2=this.width(),a.y1=this.height(),a.y2=this.height();break;case"left":a.x1=this.width(),a.x2=this.width(),a.y2=this.height();break;case"right":a.y2=this.height()}return a},c.prototype._generateTickMarkAttrHash=function(a){var b=this;void 0===a&&(a=!1);var c={x1:0,y1:0,x2:0,y2:0},d=function(a){return b._scale.scale(a)};this._isHorizontal()?(c.x1=d,c.x2=d):(c.y1=d,c.y2=d);var e=a?this._endTickLength:this._tickLength;switch(this._orientation){case"bottom":c.y2=e;break;case"top":c.y1=this.height(),c.y2=this.height()-e;break;case"left":c.x1=this.width(),c.x2=this.width()-e;break;case"right":c.x2=e}return c},c.prototype._invalidateLayout=function(){this._computedWidth=null,this._computedHeight=null,b.prototype._invalidateLayout.call(this)},c.prototype._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlign("top");break;case"top":this.yAlign("bottom");break;case"left":this.xAlign("right");break;case"right":this.xAlign("left")}},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this._invalidateLayout(),this)},c.prototype.tickLength=function(a){if(null==a)return this._tickLength;if(0>a)throw new Error("tick length must be positive");return this._tickLength=a,this._invalidateLayout(),this},c.prototype.endTickLength=function(a){if(null==a)return this._endTickLength;if(0>a)throw new Error("end tick length must be positive");return this._endTickLength=a,this._invalidateLayout(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.tickLength(),this.endTickLength()):this.tickLength()},c.prototype.tickLabelPadding=function(a){if(null==a)return this._tickLabelPadding;if(0>a)throw new Error("tick label padding must be positive");return this._tickLabelPadding=a,this._invalidateLayout(),this},c.prototype.gutter=function(a){if(null==a)return this._gutter;if(0>a)throw new Error("gutter size must be positive");return this._gutter=a,this._invalidateLayout(),this},c.prototype.orient=function(a){if(null==a)return this._orientation;var b=a.toLowerCase();if("top"!==b&&"bottom"!==b&&"left"!==b&&"right"!==b)throw new Error("unsupported orientation");return this._orientation=b,this._invalidateLayout(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this._render(),this)},c.prototype._hideEndTickLabels=function(){var a=this,b=this._element.select(".bounding-box")[0][0].getBoundingClientRect(),d=function(c){return Math.floor(b.left)<=Math.ceil(c.left)&&Math.floor(b.top)<=Math.ceil(c.top)&&Math.floor(c.right)<=Math.ceil(b.left+a.width())&&Math.floor(c.bottom)<=Math.ceil(b.top+a.height())},e=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS);if(0!==e[0].length){var f=e[0][0];d(f.getBoundingClientRect())||d3.select(f).style("visibility","hidden");var g=e[0][e[0].length-1];d(g.getBoundingClientRect())||d3.select(g).style("visibility","hidden")}},c.prototype._hideOverlappingTickLabels=function(){var b,d=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS).filter(function(){return"visible"===d3.select(this).style("visibility")});d.each(function(){var c=this.getBoundingClientRect(),d=d3.select(this);null!=b&&a._Util.DOM.boxesOverlap(c,b)?d.style("visibility","hidden"):(b=c,d.style("visibility","visible"))})},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c}(a.Component.AbstractComponent);b.AbstractAxis=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b){if(b=b.toLowerCase(),"top"!==b&&"bottom"!==b)throw new Error("unsupported orientation: "+b);c.call(this,a,b),this.classed("time-axis",!0),this.tickLabelPadding(5)}return __extends(d,c),d.prototype._computeHeight=function(){if(null!==this._computedHeight)return this._computedHeight;var a=this._measureTextHeight(this._majorTickLabels)+this._measureTextHeight(this._minorTickLabels);return this.tickLength(a),this.endTickLength(a),this._computedHeight=this._maxLabelTickLength()+2*this.tickLabelPadding(),this._computedHeight},d.prototype.calculateWorstWidth=function(a,b){var c=new Date(9999,8,29,12,59,9999);return this.measurer(d3.time.format(b)(c)).width},d.prototype.getIntervalLength=function(a){var b=this._scale.domain()[0],c=a.timeUnit.offset(b,a.step);if(c>this._scale.domain()[1])return this.width();var d=Math.abs(this._scale.scale(c)-this._scale.scale(b));return d},d.prototype.isEnoughSpace=function(a,b){var c=this.calculateWorstWidth(a,b.formatString)+2*this.tickLabelPadding(),d=Math.min(this.getIntervalLength(b),this.width());return d>c},d.prototype._setup=function(){c.prototype._setup.call(this),this._majorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this._minorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this.measurer=a._Util.Text.getTextMeasurer(this._majorTickLabels.append("text"))},d.prototype.getTickLevel=function(){for(var b=0;b=d._minorIntervals.length&&(a._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"),b=d._minorIntervals.length-1),b},d.prototype._getTickIntervalValues=function(a){return this._scale._tickInterval(a.timeUnit,a.step)},d.prototype._getTickValues=function(){var a=this.getTickLevel(),b=this._getTickIntervalValues(d._minorIntervals[a]),c=this._getTickIntervalValues(d._majorIntervals[a]);return b.concat(c)},d.prototype._measureTextHeight=function(c){var d=c.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),e=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return d.remove(),e},d.prototype.renderTickLabels=function(c,d,e){var f=this;c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).remove();var g=this._scale._tickInterval(d.timeUnit,d.step);g.splice(0,0,this._scale.domain()[0]),g.push(this._scale.domain()[1]);var h=1===d.step,i=[];h?g.map(function(a,b){b+1>=g.length||i.push(new Date((g[b+1].valueOf()-g[b].valueOf())/2+g[b].valueOf()))}):i=g,i=i.filter(function(a){return f.canFitLabelFilter(c,a,d3.time.format(d.formatString)(a),h)});var j=c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).data(i,function(a){return a.valueOf()}),k=j.enter().append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0);k.append("text");var l=h?0:this.tickLabelPadding(),m="bottom"===this._orientation?this._maxLabelTickLength()/2*e:this.height()-this._maxLabelTickLength()/2*e+2*this.tickLabelPadding(),n=j.selectAll("text");n.size()>0&&a._Util.DOM.translate(n,l,m),j.exit().remove(),j.attr("transform",function(a){return"translate("+f._scale.scale(a)+",0)" -});var o=h?"middle":"start";j.selectAll("text").text(function(a){return d3.time.format(d.formatString)(a)}).style("text-anchor",o)},d.prototype.canFitLabelFilter=function(a,b,c,d){var e,f,g=this.measurer(c).width+this.tickLabelPadding();return d?(e=this._scale.scale(b)+g/2,f=this._scale.scale(b)-g/2):(e=this._scale.scale(b)+g,f=this._scale.scale(b)),e0},d.prototype.adjustTickLength=function(a,c){var d=this._getTickIntervalValues(c),e=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).filter(function(a){return d.map(function(a){return a.valueOf()}).indexOf(a.valueOf())>=0});"top"===this._orientation&&(a=this.height()-a),e.attr("y2",a)},d.prototype.generateLabellessTicks=function(a){if(!(0>a)){var c=this._getTickIntervalValues(d._minorIntervals[a]),e=this._getTickValues().concat(c),f=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).data(e);f.enter().append("line").classed(b.AbstractAxis.TICK_MARK_CLASS,!0),f.attr(this._generateTickMarkAttrHash()),f.exit().remove(),this.adjustTickLength(this.tickLabelPadding(),d._minorIntervals[a])}},d.prototype._doRender=function(){c.prototype._doRender.call(this);var a=this.getTickLevel();this.renderTickLabels(this._minorTickLabels,d._minorIntervals[a],1),this.renderTickLabels(this._majorTickLabels,d._majorIntervals[a],2);var b=this._scale.domain(),e=this._scale.scale(b[1])-this._scale.scale(b[0]);return 1.5*this.getIntervalLength(d._minorIntervals[a])>=e&&this.generateLabellessTicks(a-1),this.adjustTickLength(this._maxLabelTickLength()/2,d._minorIntervals[a]),this.adjustTickLength(this._maxLabelTickLength(),d._majorIntervals[a]),this},d._minorIntervals=[{timeUnit:d3.time.second,step:1,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:5,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:10,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:15,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:30,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.minute,step:1,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:5,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:10,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:15,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:30,formatString:"%I:%M %p"},{timeUnit:d3.time.hour,step:1,formatString:"%I %p"},{timeUnit:d3.time.hour,step:3,formatString:"%I %p"},{timeUnit:d3.time.hour,step:6,formatString:"%I %p"},{timeUnit:d3.time.hour,step:12,formatString:"%I %p"},{timeUnit:d3.time.day,step:1,formatString:"%a %e"},{timeUnit:d3.time.day,step:1,formatString:"%e"},{timeUnit:d3.time.month,step:1,formatString:"%B"},{timeUnit:d3.time.month,step:1,formatString:"%b"},{timeUnit:d3.time.month,step:3,formatString:"%B"},{timeUnit:d3.time.month,step:6,formatString:"%B"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%y"},{timeUnit:d3.time.year,step:5,formatString:"%Y"},{timeUnit:d3.time.year,step:25,formatString:"%Y"},{timeUnit:d3.time.year,step:50,formatString:"%Y"},{timeUnit:d3.time.year,step:100,formatString:"%Y"},{timeUnit:d3.time.year,step:200,formatString:"%Y"},{timeUnit:d3.time.year,step:500,formatString:"%Y"},{timeUnit:d3.time.year,step:1e3,formatString:"%Y"}],d._majorIntervals=[{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""}],d}(b.AbstractAxis);b.Time=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=a.Formatters.general(3,!1)),c.call(this,b,d,e),this.tickLabelPositioning="center",this.showFirstTickLabel=!1,this.showLastTickLabel=!1}return __extends(d,c),d.prototype._setup=function(){c.prototype._setup.call(this),this.measurer=a._Util.Text.getTextMeasurer(this._tickLabelContainer.append("text").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0))},d.prototype._computeWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b._formatter(a);return b.measurer(c).width}),e=a._Util.Methods.max(d,0);return this._computedWidth="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+e:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+e),this._computedWidth},d.prototype._computeHeight=function(){var b=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return this._computedHeight="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+b:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+b),this._computedHeight},d.prototype._getTickValues=function(){return this._scale.ticks()},d.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||aa,wantsHeight:e>b}},c.prototype._setup=function(){b.prototype._setup.call(this),this.textContainer=this._content.append("g"),this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),this.text(this._text)},c.prototype.text=function(a){return void 0===a?this._text:(this._text=a,this._invalidateLayout(),this)},c.prototype.orient=function(a){if(null==a)return this.orientation;if(a=a.toLowerCase(),"horizontal"!==a&&"left"!==a&&"right"!==a)throw new Error(a+" is not a valid orientation for LabelComponent");return this.orientation=a,this._invalidateLayout(),this},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.textContainer.text("");var c="horizontal"===this.orientation?this.width():this.height(),d=a._Util.Text.getTruncatedText(this._text,c,this.measurer);"horizontal"===this.orientation?a._Util.Text.writeLineHorizontally(d,this.textContainer,this.width(),this.height(),this.xAlignment,this.yAlignment):a._Util.Text.writeLineVertically(d,this.textContainer,this.width(),this.height(),this.xAlignment,this.yAlignment,this.orientation)},c.prototype._computeLayout=function(c,d,e,f){return this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),b.prototype._computeLayout.call(this,c,d,e,f),this},c}(b.AbstractComponent);b.Label=c;var d=function(a){function b(b,c){a.call(this,b,c),this.classed("title-label",!0)}return __extends(b,a),b}(c);b.TitleLabel=d;var e=function(a){function b(b,c){a.call(this,b,c),this.classed("axis-label",!0)}return __extends(b,a),b}(c);b.AxisLabel=e}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this),this.classed("legend",!0),this.scale(a),this.xAlign("RIGHT").yAlign("TOP"),this.xOffset(5).yOffset(5),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this)},c.prototype.toggleCallback=function(a){return void 0!==a?(this._toggleCallback=a,this.isOff=d3.set(),this.updateListeners(),this.updateClasses(),this):this._toggleCallback},c.prototype.hoverCallback=function(a){return void 0!==a?(this._hoverCallback=a,this.datumCurrentlyFocusedOn=void 0,this.updateListeners(),this.updateClasses(),this):this._hoverCallback},c.prototype.scale=function(a){var b=this;return null!=a?(null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this),this.colorScale=a,this.colorScale.broadcaster.registerListener(this,function(){return b.updateDomain()}),this.updateDomain(),this):this.colorScale},c.prototype.updateDomain=function(){null!=this._toggleCallback&&(this.isOff=a._Util.Methods.intersection(this.isOff,d3.set(this.scale().domain()))),null!=this._hoverCallback&&(this.datumCurrentlyFocusedOn=this.scale().domain().indexOf(this.datumCurrentlyFocusedOn)>=0?this.datumCurrentlyFocusedOn:void 0),this._invalidateLayout()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e);var f=this.measureTextHeight(),g=this.colorScale.domain().length;this.nRowsDrawn=Math.min(g,Math.floor(this.height()/f))},c.prototype._requestedSpace=function(b,d){var e=this.measureTextHeight(),f=this.colorScale.domain().length,g=Math.min(f,Math.floor((d-2*c.MARGIN)/e)),h=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),i=a._Util.Text.getTextMeasurer(h.append("text")),j=a._Util.Methods.max(this.colorScale.domain(),function(a){return i(a).width},0);h.remove(),j=void 0===j?0:j;var k=0===g?0:j+e+2*c.MARGIN,l=0===g?0:f*e+2*c.MARGIN;return{width:k,height:l,wantsWidth:k>b,wantsHeight:l>d}},c.prototype.measureTextHeight=function(){var b=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),d=a._Util.Text.getTextMeasurer(b.append("text"))(a._Util.Text.HEIGHT_TEXT).height;return 0===d&&(d=1),b.remove(),d},c.prototype._doRender=function(){b.prototype._doRender.call(this);var d=this.colorScale.domain().slice(0,this.nRowsDrawn),e=this.measureTextHeight(),f=this.width()-e-c.MARGIN,g=.3*e,h=this._content.selectAll("."+c.SUBELEMENT_CLASS).data(d,function(a){return a}),i=h.enter().append("g").classed(c.SUBELEMENT_CLASS,!0);i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove(),h.selectAll("circle").attr("cx",e/2).attr("cy",e/2).attr("r",g).attr("fill",this.colorScale._d3Scale),h.selectAll("g.text-container").text("").attr("transform","translate("+e+", 0)").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),e=a._Util.Text.getTruncatedText(b,f,d),g=d(e);a._Util.Text.writeLineHorizontally(e,c,g.width,g.height)}),h.attr("transform",function(a){return"translate("+c.MARGIN+","+(d.indexOf(a)*e+c.MARGIN)+")"}),this.updateClasses(),this.updateListeners()},c.prototype.updateListeners=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);if(null!=this._hoverCallback){var d=function(b){return function(c){a.datumCurrentlyFocusedOn=b?c:void 0,a._hoverCallback(a.datumCurrentlyFocusedOn),a.updateClasses()}};b.on("mouseover",d(!0)),b.on("mouseout",d(!1))}else b.on("mouseover",null),b.on("mouseout",null);null!=this._toggleCallback?b.on("click",function(b){var c=a.isOff.has(b);c?a.isOff.remove(b):a.isOff.add(b),a._toggleCallback(b,c),a.updateClasses()}):b.on("click",null)}},c.prototype.updateClasses=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);null!=this._hoverCallback?(b.classed("focus",function(b){return a.datumCurrentlyFocusedOn===b}),b.classed("hover",void 0!==this.datumCurrentlyFocusedOn)):(b.classed("hover",!1),b.classed("focus",!1)),null!=this._toggleCallback?(b.classed("toggled-on",function(b){return!a.isOff.has(b)}),b.classed("toggled-off",function(b){return a.isOff.has(b)})):(b.classed("toggled-on",!1),b.classed("toggled-off",!1))}},c.SUBELEMENT_CLASS="legend-row",c.MARGIN=5,c}(b.AbstractComponent);b.Legend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;b.call(this),this.padding=5,this.classed("legend",!0),this.scale=a,this.scale.broadcaster.registerListener(this,function(){return c._invalidateLayout()}),this.xAlign("left").yAlign("center"),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this.scale.broadcaster.deregisterListener(this)},c.prototype.calculateLayoutInfo=function(b,d){var e=this,f=this._content.append("g").classed(c.LEGEND_ROW_CLASS,!0),g=(f.append("g").classed(c.LEGEND_ENTRY_CLASS,!0),a._Util.Text.getTextMeasurer(f.append("text"))),h=g(a._Util.Text.HEIGHT_TEXT).height,i=Math.max(0,b-this.padding),j=function(a){var b=h+g(a).width+e.padding;return Math.min(b,i)},k=this.scale.domain(),l=a._Util.Methods.populateMap(k,j);f.remove();var m=this.packRows(i,k,l),n=Math.floor((d-2*this.padding)/h);return n!==n&&(n=0),{textHeight:h,entryLengths:l,rows:m,numRowsToDraw:Math.max(Math.min(n,m.length),0)}},c.prototype._requestedSpace=function(b,c){var d=this.calculateLayoutInfo(b,c),e=d.rows.map(function(a){return d3.sum(a,function(a){return d.entryLengths.get(a)})}),f=a._Util.Methods.max(e,0);f=void 0===f?0:f;var g=this.padding+f,h=d.numRowsToDraw*d.textHeight+2*this.padding,i=d.rows.length*d.textHeight+2*this.padding;return{width:g,height:h,wantsWidth:g>b,wantsHeight:i>c}},c.prototype.packRows=function(a,b,c){var d=[[]],e=d[0],f=a;return b.forEach(function(b){var g=c.get(b);g>f&&(e=[],d.push(e),f=a),e.push(b),f-=g}),d},c.prototype._doRender=function(){var d=this;b.prototype._doRender.call(this);var e=this.calculateLayoutInfo(this.width(),this.height()),f=e.rows.slice(0,e.numRowsToDraw),g=this._content.selectAll("g."+c.LEGEND_ROW_CLASS).data(f);g.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),g.exit().remove(),g.attr("transform",function(a,b){return"translate(0, "+(b*e.textHeight+d.padding)+")"});var h=g.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),i=h.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove();var j=this.padding;g.each(function(){var a=j,b=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);b.attr("transform",function(b){var c="translate("+a+", 0)";return a+=e.entryLengths.get(b),c})}),h.select("circle").attr("cx",e.textHeight/2).attr("cy",e.textHeight/2).attr("r",.3*e.textHeight).attr("fill",function(a){return d.scale.scale(a)});var k=this.padding,l=h.select("g.text-container");l.text(""),l.append("title").text(function(a){return a}),l.attr("transform","translate("+e.textHeight+", "+.1*e.textHeight+")").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),f=e.entryLengths.get(b)-e.textHeight-k,g=a._Util.Text.getTruncatedText(b,f,d),h=d(g);a._Util.Text.writeLineHorizontally(g,c,h.width,h.height)})},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c}(b.AbstractComponent);b.HorizontalLegend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.AbstractQuantitative");if(null!=d&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.AbstractQuantitative");b.call(this),this.classed("gridlines",!0),this.xScale=c,this.yScale=d,this.xScale&&this.xScale.broadcaster.registerListener(this,function(){return e._render()}),this.yScale&&this.yScale.broadcaster.registerListener(this,function(){return e._render()})}return __extends(c,b),c.prototype.remove=function(){return b.prototype.remove.call(this),this.xScale&&this.xScale.broadcaster.deregisterListener(this),this.yScale&&this.yScale.broadcaster.deregisterListener(this),this},c.prototype._setup=function(){b.prototype._setup.call(this),this.xLinesContainer=this._content.append("g").classed("x-gridlines",!0),this.yLinesContainer=this._content.append("g").classed("y-gridlines",!0)},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.redrawXLines(),this.redrawYLines()},c.prototype.redrawXLines=function(){var a=this;if(this.xScale){var b=this.xScale.ticks(),c=function(b){return a.xScale.scale(b)},d=this.xLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",c).attr("y1",0).attr("x2",c).attr("y2",this.height()).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c.prototype.redrawYLines=function(){var a=this;if(this.yScale){var b=this.yScale.ticks(),c=function(b){return a.yScale.scale(b)},d=this.yLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",0).attr("y1",c).attr("x2",this.width()).attr("y2",c).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c}(b.AbstractComponent);b.Gridlines=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.rowPadding=0,this.colPadding=0,this.rows=[],this.rowWeights=[],this.colWeights=[],this.nRows=0,this.nCols=0,this.classed("table",!0),a.forEach(function(a,b){a.forEach(function(a,d){c.addComponent(b,d,a)})})}return __extends(c,b),c.prototype.addComponent=function(a,b,c){if(this._addComponent(c)){this.nRows=Math.max(a+1,this.nRows),this.nCols=Math.max(b+1,this.nCols),this.padTableToSize(this.nRows,this.nCols);var d=this.rows[a][b];if(d)throw new Error("Table.addComponent cannot be called on a cell where a component already exists (for the moment)");this.rows[a][b]=c}return this},c.prototype._removeComponent=function(a){b.prototype._removeComponent.call(this,a);var c,d;a:for(var e=0;e0&&v&&e!==x,C=f>0&&w&&f!==y;if(!B&&!C)break;if(r>5)break}return e=h-d3.sum(u.guaranteedWidths),f=i-d3.sum(u.guaranteedHeights),n=c.calcProportionalSpace(k,e),o=c.calcProportionalSpace(j,f),{colProportionalSpace:n,rowProportionalSpace:o,guaranteedWidths:u.guaranteedWidths,guaranteedHeights:u.guaranteedHeights,wantsWidth:v,wantsHeight:w}},c.prototype.determineGuarantees=function(b,c){var d=a._Util.Methods.createFilledArray(0,this.nCols),e=a._Util.Methods.createFilledArray(0,this.nRows),f=a._Util.Methods.createFilledArray(!1,this.nCols),g=a._Util.Methods.createFilledArray(!1,this.nRows);return this.rows.forEach(function(a,h){a.forEach(function(a,i){var j;j=null!=a?a._requestedSpace(b[i],c[h]):{width:0,height:0,wantsWidth:!1,wantsHeight:!1};var k=Math.min(j.width,b[i]),l=Math.min(j.height,c[h]);d[i]=Math.max(d[i],k),e[h]=Math.max(e[h],l),f[i]=f[i]||j.wantsWidth,g[h]=g[h]||j.wantsHeight})}),{guaranteedWidths:d,guaranteedHeights:e,wantsWidthArr:f,wantsHeightArr:g}},c.prototype._requestedSpace=function(a,b){var c=this.iterateLayout(a,b);return{width:d3.sum(c.guaranteedWidths),height:d3.sum(c.guaranteedHeights),wantsWidth:c.wantsWidth,wantsHeight:c.wantsHeight}},c.prototype._computeLayout=function(c,d,e,f){var g=this;b.prototype._computeLayout.call(this,c,d,e,f);var h=this.iterateLayout(this.width(),this.height()),i=a._Util.Methods.addArrays(h.rowProportionalSpace,h.guaranteedHeights),j=a._Util.Methods.addArrays(h.colProportionalSpace,h.guaranteedWidths),k=0;this.rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a._computeLayout(c,k,j[d],i[b]),c+=j[d]+g.colPadding}),k+=i[b]+g.rowPadding})},c.prototype.padding=function(a,b){return this.rowPadding=a,this.colPadding=b,this._invalidateLayout(),this},c.prototype.rowWeight=function(a,b){return this.rowWeights[a]=b,this._invalidateLayout(),this},c.prototype.colWeight=function(a,b){return this.colWeights[a]=b,this._invalidateLayout(),this},c.prototype._isFixedWidth=function(){var a=d3.transpose(this.rows);return c.fixedSpace(a,function(a){return null==a||a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return c.fixedSpace(this.rows,function(a){return null==a||a._isFixedHeight()})},c.prototype.padTableToSize=function(a,b){for(var c=0;a>c;c++){void 0===this.rows[c]&&(this.rows[c]=[],this.rowWeights[c]=null);for(var d=0;b>d;d++)void 0===this.rows[c][d]&&(this.rows[c][d]=null)}for(d=0;b>d;d++)void 0===this.colWeights[d]&&(this.colWeights[d]=null)},c.calcComponentWeights=function(a,b,c){return a.map(function(a,d){if(null!=a)return a;var e=b[d].map(c),f=e.reduce(function(a,b){return a&&b},!0);return f?0:1})},c.calcProportionalSpace=function(b,c){var d=d3.sum(b);return 0===d?a._Util.Methods.createFilledArray(0,b.length):b.map(function(a){return c*a/d})},c.fixedSpace=function(a,b){var c=function(a){return a.reduce(function(a,b){return a&&b},!0)},d=function(a){return c(a.map(b))};return c(a.map(d))},c}(b.AbstractComponentContainer);b.Table=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this._dataChanged=!1,this._projectors={},this._animate=!1,this._animators={},this._ANIMATION_DURATION=250,this._animateOnNextRender=!0,this.clipPathEnabled=!0,this.classed("plot",!0),this._key2DatasetDrawerKey=d3.map(),this._datasetKeysInOrder=[],this.nextSeriesIndex=0}return __extends(c,b),c.prototype._anchor=function(a){b.prototype._anchor.call(this,a),this._animateOnNextRender=!0,this._dataChanged=!0,this._updateScaleExtents()},c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._renderArea=this._content.append("g").classed("render-area",!0),this._getDrawersInOrder().forEach(function(b){return b.setup(a._renderArea.append("g"))})},c.prototype.remove=function(){var a=this;b.prototype.remove.call(this),this._datasetKeysInOrder.forEach(function(b){return a.removeDataset(b)});var c=Object.keys(this._projectors);c.forEach(function(b){var c=a._projectors[b];c.scale&&c.scale.broadcaster.deregisterListener(a)})},c.prototype.addDataset=function(b,c){if("string"!=typeof b&&void 0!==c)throw new Error("invalid input to addDataset");"string"==typeof b&&"_"===b[0]&&a._Util.Methods.warn("Warning: Using _named series keys may produce collisions with unlabeled data sources");var d="string"==typeof b?b:"_"+this.nextSeriesIndex++,e="string"!=typeof b?b:c,c=e instanceof a.Dataset?e:new a.Dataset(e);return this._addDataset(d,c),this},c.prototype._addDataset=function(a,b){var c=this;this._key2DatasetDrawerKey.has(a)&&this.removeDataset(a);var d=this._getDrawer(a),e={drawer:d,dataset:b,key:a}; -this._datasetKeysInOrder.push(a),this._key2DatasetDrawerKey.set(a,e),this._isSetup&&d.setup(this._renderArea.append("g")),b.broadcaster.registerListener(this,function(){return c._onDatasetUpdate()}),this._onDatasetUpdate()},c.prototype._getDrawer=function(b){return new a._Drawer.AbstractDrawer(b)},c.prototype._getAnimator=function(b){return this._animate&&this._animateOnNextRender?this._animators[b]||new a.Animator.Null:new a.Animator.Null},c.prototype._onDatasetUpdate=function(){this._updateScaleExtents(),this._animateOnNextRender=!0,this._dataChanged=!0,this._render()},c.prototype.attr=function(a,b,c){return this.project(a,b,c)},c.prototype.project=function(b,c,d){var e=this;b=b.toLowerCase();var f=this._projectors[b],g=f&&f.scale;g&&this._datasetKeysInOrder.forEach(function(a){g._removeExtent(e._plottableID.toString()+"_"+a,b),g.broadcaster.deregisterListener(e)}),d&&d.broadcaster.registerListener(this,function(){return e._render()});var h=a._Util.Methods._applyAccessor(c,this);return this._projectors[b]={accessor:h,scale:d,attribute:b},this._updateScaleExtent(b),this._render(),this},c.prototype._generateAttrToProjector=function(){var a=this,b={};return d3.keys(this._projectors).forEach(function(c){var d=a._projectors[c],e=d.accessor,f=d.scale,g=f?function(a,b){return f.scale(e(a,b))}:e;b[c]=g}),b},c.prototype._doRender=function(){this._isAnchored&&(this.paint(),this._dataChanged=!1,this._animateOnNextRender=!1)},c.prototype.animate=function(a){return this._animate=a,this},c.prototype.detach=function(){return b.prototype.detach.call(this),this._updateScaleExtents(),this},c.prototype._updateScaleExtents=function(){var a=this;d3.keys(this._projectors).forEach(function(b){return a._updateScaleExtent(b)})},c.prototype._updateScaleExtent=function(a){var b=this,c=this._projectors[a];c.scale&&this._key2DatasetDrawerKey.forEach(function(d,e){var f=e.dataset._getExtent(c.accessor,c.scale._typeCoercer),g=b._plottableID.toString()+"_"+d;0!==f.length&&b._isAnchored?c.scale._updateExtent(g,a,f):c.scale._removeExtent(g,a)})},c.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},c.prototype.datasetOrder=function(b){function c(b,c){var d=a._Util.Methods.intersection(d3.set(b),d3.set(c)),e=d.size();return e===b.length&&e===c.length}return void 0===b?this._datasetKeysInOrder:(c(b,this._datasetKeysInOrder)?(this._datasetKeysInOrder=b,this._onDatasetUpdate()):a._Util.Methods.warn("Attempted to change datasetOrder, but new order is not permutation of old. Ignoring."),this)},c.prototype.removeDataset=function(b){var c;if("string"==typeof b)c=b;else if(b instanceof a.Dataset||b instanceof Array){var d=b instanceof a.Dataset?this.datasets():this.datasets().map(function(a){return a.data()}),e=d.indexOf(b);-1!==e&&(c=this._datasetKeysInOrder[e])}return this._removeDataset(c)},c.prototype._removeDataset=function(a){if(null!=a&&this._key2DatasetDrawerKey.has(a)){var b=this._key2DatasetDrawerKey.get(a);b.drawer.remove();var c=d3.values(this._projectors),d=this._plottableID.toString()+"_"+a;c.forEach(function(a){null!=a.scale&&a.scale._removeExtent(d,a.attribute)}),b.dataset.broadcaster.deregisterListener(this),this._datasetKeysInOrder.splice(this._datasetKeysInOrder.indexOf(a),1),this._key2DatasetDrawerKey.remove(a),this._onDatasetUpdate()}return this},c.prototype.datasets=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).dataset})},c.prototype._getDrawersInOrder=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).drawer})},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animator.Null}]},c.prototype._additionalPaint=function(){},c.prototype._getDataToDraw=function(){var a=this,b=d3.map();return this._datasetKeysInOrder.forEach(function(c){b.set(c,a._key2DatasetDrawerKey.get(c).dataset.data())}),b},c.prototype.paint=function(){var b=this._generateDrawSteps(),c=this._getDataToDraw(),d=this._getDrawersInOrder(),e=this._datasetKeysInOrder.map(function(a,e){return d[e].draw(c.get(a),b)}),f=a._Util.Methods.max(e,0);this._additionalPaint(f)},c}(a.Component.AbstractComponent);b.AbstractPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.classed("pie-plot",!0)}return __extends(c,b),c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")")},c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Pie plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);a["inner-radius"]=a["inner-radius"]||d3.functor(0),a["outer-radius"]=a["outer-radius"]||d3.functor(Math.min(this.width(),this.height())/2),null==a.fill&&(a.fill=function(a,b){return c.DEFAULT_COLOR_SCALE.scale(String(b))});var d=function(a){return a.value},e=this._projectors.value;return a.value=e?e.accessor:d,a},c.prototype._getDrawer=function(b){return new a._Drawer.Arc(b).setClass("arc")},c.DEFAULT_COLOR_SCALE=new a.Scale.Color,c}(b.AbstractPlot);b.Pie=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,c){if(b.call(this),null==a||null==c)throw new Error("XYPlots require an xScale and yScale");this.classed("xy-plot",!0),this.project("x","x",a),this.project("y","y",c)}return __extends(c,b),c.prototype.project=function(a,c,d){return"x"===a&&d&&(this._xScale=d,this._updateXDomainer()),"y"===a&&d&&(this._yScale=d,this._updateYDomainer()),b.prototype.project.call(this,a,c,d),this},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._xScale.range([0,this.width()]),this._yScale.range([this.height(),0])},c.prototype._updateXDomainer=function(){if(this._xScale instanceof a.Scale.AbstractQuantitative){var b=this._xScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype._updateYDomainer=function(){if(this._yScale instanceof a.Scale.AbstractQuantitative){var b=this._yScale;b._userSetDomainer||b.domainer().pad().nice()}},c}(b.AbstractPlot);b.AbstractXYPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.closeDetectionRadius=5,this.classed("scatter-plot",!0),this.project("r",3),this.project("opacity",.6),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._animators["circles-reset"]=new a.Animator.Null,this._animators.circles=(new a.Animator.Base).duration(250).delay(5)}return __extends(c,b),c.prototype.project=function(a,c,d){return a="cx"===a?"x":a,a="cy"===a?"y":a,b.prototype.project.call(this,a,c,d),this},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("circle")},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);return a.cx=a.x,delete a.x,a.cy=a.y,delete a.y,a},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.r=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("circles-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("circles")}),a},c.prototype._getClosestStruckPoint=function(a,b){var c,d=this._getDrawersInOrder(),e=this._generateAttrToProjector(),f=function(b,c){var d=e.cx(b,c)-a.x,f=e.cy(b,c)-a.y;return d*d+f*f},g=!1,h=b*b;d.forEach(function(a){a._getDrawSelection().each(function(a,b){var d=f(a,b),i=e.r(a,b);i*i>d?((!g||h>d)&&(c=this,h=d),g=!0):!g&&h>d&&(c=this,h=d)})});var i=d3.select(c);return{selection:c?i:null,data:c?i.data():null}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){return this._getClosestStruckPoint(a,this.closeDetectionRadius)},c}(b.AbstractXYPlot);b.Scatter=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){b.call(this,c,d),this._animators={cells:new a.Animator.Null},this.classed("grid-plot",!0),this._xScale.rangeType("bands",0,0),this._yScale.rangeType("bands",0,0),this._colorScale=e,this.project("fill","value",e),this._animators.cells=new a.Animator.Null}return __extends(c,b),c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Grid plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("rect")},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"fill"===a&&(this._colorScale=this._projectors.fill.scale),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=this._xScale.rangeBand(),d=this._yScale.rangeBand();return a.width=function(){return c},a.height=function(){return d},a},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("cells")}]},c}(b.AbstractXYPlot);b.Grid=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._baselineValue=0,this._barAlignmentFactor=.5,this._barLabelFormatter=a.Formatters.identity(),this._barLabelsEnabled=!1,this._hoverMode="point",this.hideBarsIfAnyAreTooWide=!0,this.classed("bar-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._animators["bars-reset"]=new a.Animator.Null,this._animators.bars=new a.Animator.Base,this._animators.baseline=new a.Animator.Null,this.baseline(this._baselineValue)}return __extends(c,b),c.prototype._getDrawer=function(b){return new a._Drawer.Rect(b,this._isVertical)},c.prototype._setup=function(){b.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},c.prototype.baseline=function(a){return this._baselineValue=a,this._updateXDomainer(),this._updateYDomainer(),this._render(),this},c.prototype.barAlignment=function(a){var b=a.toLowerCase(),c=this.constructor._BarAlignmentToFactor;if(void 0===c[b])throw new Error("unsupported bar alignment");return this._barAlignmentFactor=c[b],this._render(),this},c.prototype.parseExtent=function(a){if("number"==typeof a)return{min:a,max:a};if(a instanceof Object&&"min"in a&&"max"in a)return a;throw new Error("input '"+a+"' can't be parsed as an Extent")},c.prototype.barLabelsEnabled=function(a){return void 0===a?this._barLabelsEnabled:(this._barLabelsEnabled=a,this._render(),this)},c.prototype.barLabelFormatter=function(a){return null==a?this._barLabelFormatter:(this._barLabelFormatter=a,this._render(),this)},c.prototype.selectBar=function(a,b,c){if(void 0===c&&(c=!0),!this._isSetup)return null;var d=[],e=this.parseExtent(a),f=this.parseExtent(b),g=.5;if(this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").each(function(){var a=this.getBBox();a.x+a.width>=e.min-g&&a.x<=e.max+g&&a.y+a.height>=f.min-g&&a.y<=f.max+g&&d.push(this)})}),d.length>0){var h=d3.selectAll(d);return h.classed("selected",c),h}return null},c.prototype.deselectAll=function(){return this._isSetup&&this._getDrawersInOrder().forEach(function(a){return a._renderArea.selectAll("rect").classed("selected",!1)}),this},c.prototype._updateDomainer=function(b){if(b instanceof a.Scale.AbstractQuantitative){var c=b;c._userSetDomainer||(null!=this._baselineValue?c.domainer().addPaddingException(this._baselineValue,"BAR_PLOT+"+this._plottableID).addIncludedValue(this._baselineValue,"BAR_PLOT+"+this._plottableID):c.domainer().removePaddingException("BAR_PLOT+"+this._plottableID).removeIncludedValue("BAR_PLOT+"+this._plottableID),c.domainer().pad()),c._autoDomainIfAutomaticMode()}},c.prototype._updateYDomainer=function(){this._isVertical?this._updateDomainer(this._yScale):b.prototype._updateYDomainer.call(this)},c.prototype._updateXDomainer=function(){this._isVertical?b.prototype._updateXDomainer.call(this):this._updateDomainer(this._xScale)},c.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this._yScale:this._xScale,e=d.scale(this._baselineValue),f={x1:this._isVertical?0:e,y1:this._isVertical?e:0,x2:this._isVertical?this.width():e,y2:this._isVertical?e:this.height()};this._getAnimator("baseline").animate(this._baseline,f);var g=this._getDrawersInOrder();g.forEach(function(a){return a.removeLabels()}),this._barLabelsEnabled&&a._Util.Methods.setTimeout(function(){return c._drawLabels()},b)},c.prototype._drawLabels=function(){var a=this._getDrawersInOrder(),b=this._generateAttrToProjector(),c=this._getDataToDraw();this._datasetKeysInOrder.forEach(function(d,e){return a[e].drawText(c.get(d),b)}),this.hideBarsIfAnyAreTooWide&&a.some(function(a){return a._someLabelsTooWide})&&a.forEach(function(a){return a.removeLabels()})},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged&&this._animate){var b=this._generateAttrToProjector(),c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue),e=this._isVertical?"y":"x",f=this._isVertical?"height":"width";b[e]=function(){return d},b[f]=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("bars-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("bars")}),a},c.prototype._generateAttrToProjector=function(){var d=this,e=b.prototype._generateAttrToProjector.call(this),f=this._isVertical?this._yScale:this._xScale,g=this._isVertical?this._xScale:this._yScale,h=this._isVertical?"y":"x",i=this._isVertical?"x":"y",j=g instanceof a.Scale.Ordinal&&"bands"===g.rangeType(),k=f.scale(this._baselineValue);if(!e.width){var l=j?g.rangeBand():c.DEFAULT_WIDTH;e.width=function(){return l}}var m=e[i],n=e.width;if(j){var o=g.rangeBand();e[i]=function(a,b){return m(a,b)-n(a,b)/2+o/2}}else e[i]=function(a,b){return m(a,b)-n(a,b)*d._barAlignmentFactor};var p=e[h];e[h]=function(a,b){var c=p(a,b);return c>k?k:c},e.height=function(a,b){return Math.abs(k-p(a,b))};var q=this._projectors[h].accessor;return this.barLabelsEnabled&&this.barLabelFormatter&&(e.label=function(a,b){return d._barLabelFormatter(q(a,b))},e.positive=function(a,b){return p(a,b)<=k}),e},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode");return this._hoverMode=b,this},c.prototype.clearHoverSelection=function(){this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed("not-hovered hovered",!1)})},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){this.clearHoverSelection()},c.prototype._doHover=function(a){var b=a.x,c=a.y;if("line"===this._hoverMode){var d={min:-1/0,max:1/0};this._isVertical?c=d:b=d}var e=this.selectBar(b,c,!1);return e?(this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed({hovered:!1,"not-hovered":!0})}),e.classed({hovered:!0,"not-hovered":!1})):this.clearHoverSelection(),{data:e?e.data():null,selection:e}},c._BarAlignmentToFactor={},c.DEFAULT_WIDTH=10,c}(b.AbstractXYPlot);b.AbstractBarPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){this._isVertical=!0,a.call(this,b,c)}return __extends(b,a),b.prototype._updateYDomainer=function(){this._updateDomainer(this._yScale)},b._BarAlignmentToFactor={left:0,center:.5,right:1},b}(a.AbstractBarPlot);a.VerticalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){a.call(this,b,c)}return __extends(b,a),b.prototype._updateXDomainer=function(){this._updateDomainer(this._xScale)},b.prototype._generateAttrToProjector=function(){var b=a.prototype._generateAttrToProjector.call(this),c=b.width;return b.width=b.height,b.height=c,b},b._BarAlignmentToFactor={top:0,center:.5,bottom:1},b}(a.AbstractBarPlot);a.HorizontalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("line-plot",!0),this.project("stroke",function(){return a.Core.Colors.INDIGO}),this.project("stroke-width",function(){return"2px"}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._rejectNullsAndNaNs=function(a,b,c){var d=c(a,b);return null!=d&&d===d},c.prototype._getDrawer=function(b){return new a._Drawer.Line(b)},c.prototype._getResetYFunction=function(){var a=this._yScale.domain(),b=Math.max(a[0],a[1]),c=Math.min(a[0],a[1]),d=0>b&&b||c>0&&c||0,e=this._yScale.scale(d);return function(){return e}},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.y=this._getResetYFunction(),a.push({attrToProjector:b,animator:this._getAnimator("reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("main")}),a},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(c).filter(e);f.forEach(function(a){var b=c[a];c[a]=function(a,c){return a.length>0?b(a[0],c):null}});var g=c.x,h=c.y;return c.defined=function(b,c){return a._rejectNullsAndNaNs(b,c,g)&&a._rejectNullsAndNaNs(b,c,h)},c},c.prototype._wholeDatumAttributes=function(){return["x","y"]},c}(b.AbstractXYPlot);b.Line=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("area-plot",!0),this.project("y0",0,d),this.project("fill",function(){return a.Core.Colors.INDIGO}),this.project("fill-opacity",function(){return.25}),this.project("stroke",function(){return a.Core.Colors.INDIGO}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),null!=this._yScale&&this._updateYDomainer()},c.prototype._getDrawer=function(b){return new a._Drawer.Area(b)},c.prototype._updateYDomainer=function(){var c=this;b.prototype._updateYDomainer.call(this);var d,e=this._projectors.y0,f=e&&e.accessor;if(null!=f){var g=this.datasets().map(function(a){return a._getExtent(f,c._yScale._typeCoercer)}),h=a._Util.Methods.flatten(g),i=a._Util.Methods.uniq(h);1===i.length&&(d=i[0])}this._yScale._userSetDomainer||(null!=d?this._yScale.domainer().addPaddingException(d,"AREA_PLOT+"+this._plottableID):this._yScale.domainer().removePaddingException("AREA_PLOT+"+this._plottableID),this._yScale._autoDomainIfAutomaticMode())},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"y0"===a&&this._updateYDomainer(),this},c.prototype._getResetYFunction=function(){return this._generateAttrToProjector().y0},c.prototype._wholeDatumAttributes=function(){var a=b.prototype._wholeDatumAttributes.call(this);return a.push("y0"),a},c}(b.Line);b.Area=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){void 0===e&&(e=!0),this._isVertical=e,b.call(this,c,d),this.innerScale=new a.Scale.Ordinal}return __extends(c,b),c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this),d=c.width;this.innerScale.range([0,d(null,0)]);var e=function(){return a.innerScale.rangeBand()},f=c.height;c.width=this._isVertical?e:f,c.height=this._isVertical?f:e;var g=function(a){return a._PLOTTABLE_PROTECTED_FIELD_POSITION};return c.x=this._isVertical?g:c.x,c.y=this._isVertical?c.y:g,c},c.prototype._getDataToDraw=function(){var a=this,b=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor;this.innerScale.domain(this._datasetKeysInOrder);var c=d3.map();return this._datasetKeysInOrder.forEach(function(d){var e=a._key2DatasetDrawerKey.get(d).dataset.data();c.set(d,e.map(function(c,e){var f=b(c,e),g=a._isVertical?a._xScale:a._yScale;return c._PLOTTABLE_PROTECTED_FIELD_POSITION=g.scale(f)+a.innerScale.scale(d),c}))}),c},c}(b.AbstractBarPlot);b.ClusteredBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.stackedExtent=[0,0]}return __extends(c,b),c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),this._projectors.x&&this._projectors.y&&("x"===a||"y"===a)&&this._updateStackOffsets(),this},c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),this._datasetKeysInOrder&&this._projectors.x&&this._projectors.y&&this._updateStackOffsets()},c.prototype._updateStackOffsets=function(){var b=this._generateDefaultMapArray(),c=this._getDomainKeys(),d=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.max(0,b.get(a).value)}})}),e=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.min(b.get(a).value,0)}})});this._setDatasetStackOffsets(this._stack(d),this._stack(e)),this._updateStackExtents()},c.prototype._updateStackExtents=function(){var b=this.datasets(),c=this._valueAccessor(),d=a._Util.Methods.max(b,function(b){return a._Util.Methods.max(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0),e=a._Util.Methods.min(b,function(b){return a._Util.Methods.min(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0);this.stackedExtent=[Math.min(e,0),Math.max(0,d)]},c.prototype._stack=function(a){var b=this;if(0===a.length)return a;var c=function(a,b){a.offset=b};return d3.layout.stack().x(function(a){return a.key}).y(function(a){return+a.value}).values(function(a){return b._getDomainKeys().map(function(b){return a.get(b)})}).out(c)(a),a},c.prototype._setDatasetStackOffsets=function(a,b){var c=this._keyAccessor(),d=this._valueAccessor();this.datasets().forEach(function(e,f){var g=a[f],h=b[f],i=e.data().every(function(a){return d(a)<=0});e.data().forEach(function(a){var b=g.get(c(a)).offset,e=h.get(c(a)).offset,f=d(a);a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET=0===f?i?e:b:f>0?b:e})})},c.prototype._getDomainKeys=function(){var a=this._keyAccessor(),b=d3.set(),c=this.datasets();return c.forEach(function(c){c.data().forEach(function(c){b.add(a(c))})}),b.values()},c.prototype._generateDefaultMapArray=function(){var b=this._keyAccessor(),c=this._valueAccessor(),d=this.datasets(),e=this._getDomainKeys(),f=d.map(function(){return a._Util.Methods.populateMap(e,function(a){return{key:a,value:0}})});return d.forEach(function(a,d){a.data().forEach(function(a){var e=b(a),g=c(a);f[d].set(e,{key:e,value:g})})}),f},c.prototype._updateScaleExtents=function(){b.prototype._updateScaleExtents.call(this);var a=this._isVertical?this._yScale:this._xScale;a&&(this._isAnchored&&this.stackedExtent.length>0?a._updateExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT",this.stackedExtent):a._removeExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT"))},c.prototype._keyAccessor=function(){return this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor},c.prototype._valueAccessor=function(){return this._isVertical?this._projectors.y.accessor:this._projectors.x.accessor},c}(b.AbstractXYPlot);b.AbstractStacked=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d){c.call(this,b,d),this._baselineValue=0,this.classed("area-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._isVertical=!0}return __extends(d,c),d.prototype._getDrawer=function(b){return new a._Drawer.Area(b).drawLine(!1)},d.prototype._setup=function(){c.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},d.prototype._updateStackOffsets=function(){var b=this._getDomainKeys(),d=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,e=this.datasets().map(function(a){return d3.set(a.data().map(function(a,b){return d(a,b).toString()})).values()});e.some(function(a){return a.length!==b.length})&&a._Util.Methods.warn("the domains across the datasets are not the same. Plot may produce unintended behavior."),c.prototype._updateStackOffsets.call(this)},d.prototype._additionalPaint=function(){var a=this._yScale.scale(this._baselineValue),b={x1:0,y1:a,x2:this.width(),y2:a};this._getAnimator("baseline").animate(this._baseline,b)},d.prototype._updateYDomainer=function(){c.prototype._updateYDomainer.call(this);var a=this._yScale;a._userSetDomainer||(a.domainer().addPaddingException(0,"STACKED_AREA_PLOT+"+this._plottableID),a._autoDomainIfAutomaticMode())},d.prototype._onDatasetUpdate=function(){c.prototype._onDatasetUpdate.call(this),b.Area.prototype._onDatasetUpdate.apply(this)},d.prototype._generateAttrToProjector=function(){var a=this,b=c.prototype._generateAttrToProjector.call(this),d=this._projectors.y.accessor;b.y=function(b){return a._yScale.scale(+d(b)+b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b.y0=function(b){return a._yScale.scale(b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)};var e=b.fill;return b.fill=function(a,b){return a&&a[0]?e(a[0],b):null},b},d}(b.AbstractStacked);b.StackedArea=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=!0),this._isVertical=e,this._baselineValue=0,c.call(this,b,d),this.classed("bar-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this.baseline(this._baselineValue),this._isVertical=e}return __extends(d,c),d.prototype._getAnimator=function(b){if(this._animate&&this._animateOnNextRender){if(this._animators[b])return this._animators[b];if("stacked-bar"===b){var c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue);return new a.Animator.MovingRect(d,this._isVertical)}}return new a.Animator.Null},d.prototype._generateAttrToProjector=function(){var a=this,c=b.AbstractBarPlot.prototype._generateAttrToProjector.apply(this),d=this._isVertical?"y":"x",e=this._isVertical?this._yScale:this._xScale,f=this._projectors[d].accessor,g=function(a){return e.scale(a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},h=function(a){return e.scale(+f(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},i=function(a){return Math.abs(h(a)-g(a))},j=c.width;c.height=this._isVertical?i:j,c.width=this._isVertical?j:i;var k=function(a){return+f(a)<0?g(a):h(a)};return c[d]=function(b){return a._isVertical?k(b):k(b)-i(b)},c},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("stacked-bar")}]},d.prototype.project=function(a,d,e){return c.prototype.project.call(this,a,d,e),b.AbstractStacked.prototype.project.apply(this,[a,d,e]),this},d.prototype._onDatasetUpdate=function(){return c.prototype._onDatasetUpdate.call(this),b.AbstractStacked.prototype._onDatasetUpdate.apply(this),this},d.prototype._updateStackOffsets=function(){b.AbstractStacked.prototype._updateStackOffsets.call(this)},d.prototype._updateStackExtents=function(){b.AbstractStacked.prototype._updateStackExtents.call(this)},d.prototype._stack=function(a){return b.AbstractStacked.prototype._stack.call(this,a)},d.prototype._setDatasetStackOffsets=function(a,c){b.AbstractStacked.prototype._setDatasetStackOffsets.call(this,a,c)},d.prototype._getDomainKeys=function(){return b.AbstractStacked.prototype._getDomainKeys.call(this)},d.prototype._generateDefaultMapArray=function(){return b.AbstractStacked.prototype._generateDefaultMapArray.call(this)},d.prototype._updateScaleExtents=function(){b.AbstractStacked.prototype._updateScaleExtents.call(this)},d.prototype._keyAccessor=function(){return b.AbstractStacked.prototype._keyAccessor.call(this)},d.prototype._valueAccessor=function(){return b.AbstractStacked.prototype._valueAccessor.call(this)},d}(b.AbstractBarPlot);b.StackedBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.prototype.getTiming=function(){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._duration=a.DEFAULT_DURATION_MILLISECONDS,this._delay=a.DEFAULT_DELAY_MILLISECONDS,this._easing=a.DEFAULT_EASING,this._maxIterativeDelay=a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS}return a.prototype.getTiming=function(a){var b=Math.max(this.maxTotalDuration()-this.duration(),0),c=Math.min(this.maxIterativeDelay(),b/Math.max(a-1,1)),d=c*a+this.delay()+this.duration();return d},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=Math.max(this.maxTotalDuration()-this.duration(),0),f=Math.min(this.maxIterativeDelay(),e/Math.max(d-1,1));return a.transition().ease(this.easing()).duration(this.duration()).delay(function(a,b){return c.delay()+f*b}).attr(b)},a.prototype.duration=function(a){return null==a?this._duration:(this._duration=a,this)},a.prototype.delay=function(a){return null==a?this._delay:(this._delay=a,this)},a.prototype.easing=function(a){return null==a?this._easing:(this._easing=a,this) -},a.prototype.maxIterativeDelay=function(a){return null==a?this._maxIterativeDelay:(this._maxIterativeDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.DEFAULT_DURATION_MILLISECONDS=300,a.DEFAULT_DELAY_MILLISECONDS=0,a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS=15,a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=600,a.DEFAULT_EASING="exp-out",a}();a.Base=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),a.call(this),this.isVertical=b,this.isReverse=c}return __extends(b,a),b.prototype.animate=function(c,d){var e={};return b.ANIMATED_ATTRIBUTES.forEach(function(a){return e[a]=d[a]}),e[this.getMovingAttr()]=this._startMovingProjector(d),e[this.getGrowingAttr()]=function(){return 0},c.attr(e),a.prototype.animate.call(this,c,d)},b.prototype._startMovingProjector=function(a){if(this.isVertical===this.isReverse)return a[this.getMovingAttr()];var b=a[this.getMovingAttr()],c=a[this.getGrowingAttr()];return function(a,d){return b(a,d)+c(a,d)}},b.prototype.getGrowingAttr=function(){return this.isVertical?"height":"width"},b.prototype.getMovingAttr=function(){return this.isVertical?"y":"x"},b.ANIMATED_ATTRIBUTES=["height","width","x","y","fill"],b}(a.Base);a.Rect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===c&&(c=!0),a.call(this,c),this.startPixelValue=b}return __extends(b,a),b.prototype._startMovingProjector=function(){return d3.functor(this.startPixelValue)},b}(a.Rect);a.MovingRect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(){e||(d3.select(document).on("keydown",d),e=!0)}function c(a,c){e||b(),null==f[a]&&(f[a]=[]),f[a].push(c)}function d(){null!=f[d3.event.keyCode]&&f[d3.event.keyCode].forEach(function(a){a(d3.event)})}var e=!1,f=[];a.initialize=b,a.addCallback=c}(a.KeyEventListener||(a.KeyEventListener={}));a.KeyEventListener}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(a,b){this._componentToListenTo=a,this._hitBox=b},b}(a.Core.PlottableObject);b.AbstractInteraction=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(b,c){var d=this;a.prototype._anchor.call(this,b,c),c.on(this._listenTo(),function(){var a=d3.mouse(c.node()),b=a[0],e=a[1];d._callback({x:b,y:e})})},b.prototype._listenTo=function(){return"click"},b.prototype.callback=function(a){return this._callback=a,this},b}(a.AbstractInteraction);a.Click=b;var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._listenTo=function(){return"dblclick"},b}(b);a.DoubleClick=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this),this.activated=!1,this.keyCode=a}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),d.on("mouseover",function(){e.activated=!0}),d.on("mouseout",function(){e.activated=!1}),a.Core.KeyEventListener.addCallback(this.keyCode,function(){e.activated&&null!=e._callback&&e._callback()})},c.prototype.callback=function(a){return this._callback=a,this},c}(b.AbstractInteraction);b.Key=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;b.call(this),null==c&&(c=new a.Scale.Linear),null==d&&(d=new a.Scale.Linear),this._xScale=c,this._yScale=d,this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return e.rerenderZoomed()})}return __extends(c,b),c.prototype.resetZoom=function(){var a=this;this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return a.rerenderZoomed()}),this.zoom(this._hitBox)},c.prototype._anchor=function(a,c){b.prototype._anchor.call(this,a,c),this.zoom(c)},c.prototype.rerenderZoomed=function(){var a=this._xScale._d3Scale.domain(),b=this._yScale._d3Scale.domain();this._xScale.domain(a),this._yScale.domain(b)},c}(b.AbstractInteraction);b.PanZoom=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentBar=null,this._hoverMode="point"}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),a._Util.Methods.warn("Interaction.BarHover is deprecated; please use Interaction.Hover instead"),this.plotIsVertical=this._componentToListenTo._isVertical,this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mousemove(function(a){var b=e.getHoveredBar(a);if(null==b)e._hoverOut();else{if(null!=e.currentBar){if(e.currentBar.node()===b.node())return;e._hoverOut()}e.getBars().classed("not-hovered",!0).classed("hovered",!1),b.classed("not-hovered",!1).classed("hovered",!0),null!=e.hoverCallback&&e.hoverCallback(b.data()[0],b)}e.currentBar=b}),this.dispatcher.mouseout(function(){return e._hoverOut()}),this.dispatcher.connect()},c.prototype.getBars=function(){return this._componentToListenTo._renderArea.selectAll("rect")},c.prototype._hoverOut=function(){this.getBars().classed("not-hovered hovered",!1),null!=this.unhoverCallback&&null!=this.currentBar&&this.unhoverCallback(this.currentBar.data()[0],this.currentBar),this.currentBar=null},c.prototype.getHoveredBar=function(a){if("point"===this._hoverMode)return this._componentToListenTo.selectBar(a.x,a.y,!1);var b={min:-1/0,max:1/0};return this.plotIsVertical?this._componentToListenTo.selectBar(a.x,b,!1):this._componentToListenTo.selectBar(b,a.y,!1)},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode for Interaction.BarHover");return this._hoverMode=b,this},c.prototype.onHover=function(a){return this.hoverCallback=a,this},c.prototype.onUnhover=function(a){return this.unhoverCallback=a,this},c}(b.AbstractInteraction);b.BarHover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){var b=this;a.call(this),this.dragInitialized=!1,this._origin=[0,0],this._location=[0,0],this.dragBehavior=d3.behavior.drag(),this.dragBehavior.on("dragstart",function(){return b._dragstart()}),this.dragBehavior.on("drag",function(){return b._drag()}),this.dragBehavior.on("dragend",function(){return b._dragend()})}return __extends(b,a),b.prototype.dragstart=function(a){return void 0===a?this.ondragstart:(this.ondragstart=a,this)},b.prototype.drag=function(a){return void 0===a?this.ondrag:(this.ondrag=a,this)},b.prototype.dragend=function(a){return void 0===a?this.ondragend:(this.ondragend=a,this)},b.prototype._dragstart=function(){var a=this._componentToListenTo.width(),b=this._componentToListenTo.height(),c=function(a,b){return function(c){return Math.min(Math.max(c,a),b)}};this.constrainX=c(0,a),this.constrainY=c(0,b)},b.prototype._doDragstart=function(){null!=this.ondragstart&&this.ondragstart({x:this._origin[0],y:this._origin[1]})},b.prototype._drag=function(){this.dragInitialized||(this._origin=[d3.event.x,d3.event.y],this.dragInitialized=!0,this._doDragstart()),this._location=[this.constrainX(d3.event.x),this.constrainY(d3.event.y)],this._doDrag()},b.prototype._doDrag=function(){if(null!=this.ondrag){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondrag(a,b)}},b.prototype._dragend=function(){this.dragInitialized&&(this.dragInitialized=!1,this._doDragend())},b.prototype._doDragend=function(){if(null!=this.ondragend){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondragend(a,b)}},b.prototype._anchor=function(b,c){return a.prototype._anchor.call(this,b,c),c.call(this.dragBehavior),this},b.prototype.setupZoomCallback=function(a,b){function c(c,g){return null==c||null==g?(f&&(null!=a&&a.domain(d),null!=b&&b.domain(e)),void(f=!f)):(f=!1,null!=a&&a.domain([a.invert(c.x),a.invert(g.x)]),null!=b&&b.domain([b.invert(g.y),b.invert(c.y)]),void this.clearBox())}var d=null!=a?a.domain():null,e=null!=b?b.domain():null,f=!1;return this.drag(c),this.dragend(c),this},b}(a.AbstractInteraction);a.Drag=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.boxIsDrawn=!1}return __extends(b,a),b.prototype._dragstart=function(){a.prototype._dragstart.call(this),this.clearBox()},b.prototype.clearBox=function(){return null!=this.dragBox?(this.dragBox.attr("height",0).attr("width",0),this.boxIsDrawn=!1,this):void 0},b.prototype.setBox=function(a,b,c,d){if(null!=this.dragBox){var e=Math.abs(a-b),f=Math.abs(c-d),g=Math.min(a,b),h=Math.min(c,d);return this.dragBox.attr({x:g,y:h,width:e,height:f}),this.boxIsDrawn=e>0&&f>0,this}},b.prototype._anchor=function(c,d){a.prototype._anchor.call(this,c,d);var e=b.CLASS_DRAG_BOX,f=this._componentToListenTo._backgroundContainer;return this.dragBox=f.append("rect").classed(e,!0).attr("x",0).attr("y",0),this},b.CLASS_DRAG_BOX="drag-box",b}(a.Drag);a.DragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,b,c,0,this._componentToListenTo.height()),this},b}(a.DragBox);a.XDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0],this._origin[1],this._location[1])},b}(a.DragBox);a.XYDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[1],this._location[1])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,0,this._componentToListenTo.width(),b,c),this},b}(a.DragBox);a.YDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentHoverData={data:null,selection:null}}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mouseover(function(a){e._componentToListenTo._hoverOverComponent(a),e.handleHoverOver(a)}),this.dispatcher.mouseout(function(a){e._componentToListenTo._hoverOutComponent(a),e.safeHoverOut(e.currentHoverData),e.currentHoverData={data:null,selection:null}}),this.dispatcher.mousemove(function(a){return e.handleHoverOver(a)}),this.dispatcher.connect()},c.diffHoverData=function(a,b){if(null==a.data||null==b.data)return a;var c=function(a){return-1===b.data.indexOf(a)},d=a.data.filter(c);if(0===d.length)return{data:null,selection:null};var e=a.selection.filter(c);return{data:d,selection:e}},c.prototype.handleHoverOver=function(a){var b=this.currentHoverData,d=this._componentToListenTo._doHover(a),e=c.diffHoverData(b,d);this.safeHoverOut(e);var f=c.diffHoverData(d,b);this.safeHoverOver(f),this.currentHoverData=d},c.prototype.safeHoverOut=function(a){this.hoverOutCallback&&a.data&&this.hoverOutCallback(a)},c.prototype.safeHoverOver=function(a){this.hoverOverCallback&&a.data&&this.hoverOverCallback(a)},c.prototype.onHoverOver=function(a){return this.hoverOverCallback=a,this},c.prototype.onHoverOut=function(a){return this.hoverOutCallback=a,this},c.prototype.getCurrentHoverData=function(){return this.currentHoverData},c}(b.AbstractInteraction);b.Hover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(b){a.call(this),this._event2Callback={},this.connected=!1,this._target=b}return __extends(b,a),b.prototype.target=function(a){if(null==a)return this._target;var b=this.connected;return this.disconnect(),this._target=a,b&&this.connect(),this},b.prototype.getEventString=function(a){return a+".dispatcher"+this._plottableID},b.prototype.connect=function(){var a=this;if(this.connected)throw new Error("Can't connect dispatcher twice!");return this.connected=!0,Object.keys(this._event2Callback).forEach(function(b){var c=a._event2Callback[b];a._target.on(a.getEventString(b),c)}),this},b.prototype.disconnect=function(){var a=this;return this.connected=!1,Object.keys(this._event2Callback).forEach(function(b){a._target.on(a.getEventString(b),null)}),this},b}(a.Core.PlottableObject);b.AbstractDispatcher=c}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this._event2Callback.mouseover=function(){null!=c._mouseover&&c._mouseover(c.getMousePosition())},this._event2Callback.mousemove=function(){null!=c._mousemove&&c._mousemove(c.getMousePosition())},this._event2Callback.mouseout=function(){null!=c._mouseout&&c._mouseout(c.getMousePosition())}}return __extends(b,a),b.prototype.getMousePosition=function(){var a=d3.mouse(this._target.node());return{x:a[0],y:a[1]}},b.prototype.mouseover=function(a){return void 0===a?this._mouseover:(this._mouseover=a,this)},b.prototype.mousemove=function(a){return void 0===a?this._mousemove:(this._mousemove=a,this)},b.prototype.mouseout=function(a){return void 0===a?this._mouseout:(this._mouseout=a,this)},b}(a.AbstractDispatcher);a.Mouse=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={})); \ No newline at end of file +var Plottable;!function(a){!function(b){!function(b){function c(a,b,c){return Math.min(b,c)<=a&&a<=Math.max(b,c)}function d(b){a.Config.SHOW_WARNINGS&&null!=window.console&&(null!=window.console.warn?console.warn(b):null!=window.console.log&&console.log(b))}function e(a,b){if(a.length!==b.length)throw new Error("attempted to add arrays of unequal length");return a.map(function(c,d){return a[d]+b[d]})}function f(a,b){var c=d3.set();return a.forEach(function(a){b.has(a)&&c.add(a)}),c}function g(a){return"function"==typeof a?a:"string"==typeof a&&"#"!==a[0]?function(b){return b[a]}:function(){return a}}function h(a,b){var c=g(a);return function(a,d){var e=b.datasets(),f=e.length>0?e[0]:null,g=f?f.metadata():null;return c(a,d,g)}}function i(a,b){var c=d3.set();return a.forEach(function(a){return c.add(a)}),b.forEach(function(a){return c.add(a)}),c}function j(a,b){var c=d3.map();return a.forEach(function(a,d){c.set(a,b(a,d))}),c}function k(a){var b=d3.set(),c=[];return a.forEach(function(a){b.has(a)||(b.add(a),c.push(a))}),c}function l(a,b){for(var c=[],d=0;b>d;d++)c[d]="function"==typeof a?a(d):a;return c}function m(a){return Array.prototype.concat.apply([],a)}function n(a,b){if(null==a||null==b)return a===b;if(a.length!==b.length)return!1;for(var c=0;cf;++f)e[f]=a+c*f;return e}function t(a,b){for(var c=[],d=2;dd;){var f=d+e>>>1,g=null==c?b[f]:c(b[f]);a>g?d=f+1:e=f}return d}a.sortedIndex=b}(a.OpenSource||(a.OpenSource={}));a.OpenSource}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.counter={}}return a.prototype.setDefault=function(a){null==this.counter[a]&&(this.counter[a]=0)},a.prototype.increment=function(a){return this.setDefault(a),++this.counter[a]},a.prototype.decrement=function(a){return this.setDefault(a),--this.counter[a]},a.prototype.get=function(a){return this.setDefault(a),this.counter[a]},a}();a.IDCounter=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this.keyValuePairs=[]}return a.prototype.set=function(a,b){if(a!==a)throw new Error("NaN may not be used as a key to the StrictEqualityAssociativeArray");for(var c=0;cb){var h=e("."),i=Math.floor(b/h);return"...".substr(0,i)}for(;f+g>b;)d=d.substr(0,d.length-1).trim(),f=e(d);if(e(d+"...")>b)throw new Error("addEllipsesToLine failed :(");return d+"..."}function i(b,c,d,e,f,g){void 0===f&&(f="left"),void 0===g&&(g="top");var h={left:0,center:.5,right:1},i={top:0,center:.5,bottom:1};if(void 0===h[f]||void 0===i[g])throw new Error("unrecognized alignment x:"+f+", y:"+g);var j=c.append("g"),k=j.append("text");k.text(b);var l=a.DOM.getBBox(k),m=l.height,n=l.width;if(n>d||m>e)return a.Methods.warn("Insufficient space to fit text: "+b),k.text(""),{width:0,height:0};var o={left:"start",center:"middle",right:"end"},p=o[f],q=d*h[f],r=e*i[g],s=.85-i[g];return k.attr("text-anchor",p).attr("y",s+"em"),a.DOM.translate(j,q,r),{width:n,height:m}}function j(a,b,c,d,e,f,g){if(void 0===e&&(e="left"),void 0===f&&(f="top"),void 0===g&&(g="right"),"right"!==g&&"left"!==g)throw new Error("unrecognized rotation: "+g);var h="right"===g,j={left:"bottom",right:"top",center:"center",top:"left",bottom:"right"},k={left:"top",right:"bottom",center:"center",top:"right",bottom:"left"},l=h?j:k,m=b.append("g"),n=i(a,m,d,c,l[f],l[e]),o=d3.transform("");return o.rotate="right"===g?90:-90,o.translate=[h?c:0,h?0:d],m.attr("transform",o.toString()),m.classed("rotated-"+g,!0),{width:n.height,height:n.width}}function k(d,e,f,g,h,j){void 0===h&&(h="left"),void 0===j&&(j="top");var k=c(e.append("text"))(b.HEIGHT_TEXT).height,l=0,m=e.append("g");d.forEach(function(b,c){var d=m.append("g");a.DOM.translate(d,0,c*k);var e=i(b,d,f,k,h,j);e.width>l&&(l=e.width)});var n=k*d.length,o=g-n,p={center:.5,top:0,bottom:1};return a.DOM.translate(m,0,o*p[j]),{width:l,height:n}}function l(d,e,f,g,h,i,k){void 0===h&&(h="left"),void 0===i&&(i="top"),void 0===k&&(k="left");var l=c(e.append("text"))(b.HEIGHT_TEXT).height,m=0,n=e.append("g");d.forEach(function(b,c){var d=n.append("g");a.DOM.translate(d,c*l,0);var e=j(b,d,l,g,h,i,k);e.height>m&&(m=e.height)});var o=l*d.length,p=f-o,q={center:.5,left:0,right:1};return a.DOM.translate(n,p*q[h],0),{width:o,height:m}}function m(b,c,d,e,f,g){if(void 0===f&&(f="horizontal"),-1===["left","right","horizontal"].indexOf(f))throw new Error("Unrecognized orientation to writeText: "+f);var h="horizontal"===f,i=h?c:d,j=h?d:c,m=a.WordWrap.breakTextToFitRect(b,i,j,e);if(0===m.lines.length)return{textFits:m.textFits,usedWidth:0,usedHeight:0};var n,o;if(null==g){var p=h?a.Methods.max:d3.sum,q=h?d3.sum:a.Methods.max,r=function(a){return h?e(a).height:e(a).width},s=function(a){return h?e(a).width:e(a).height};n=p(m.lines,s,0),o=q(m.lines,r,0)}else{var t=g.g.append("g").classed("writeText-inner-g",!0),u=h?k:l,v=u.call(this,m.lines,t,c,d,g.xAlign,g.yAlign,f);n=v.width,o=v.height}return{textFits:m.textFits,usedWidth:n,usedHeight:o}}b.HEIGHT_TEXT="bqpdl",b.getTextMeasurer=c;var n="a",o=function(){function b(b){var g=this;this.cache=new a.Cache(c(b),n,a.Methods.objEq),this.measure=d(e(f(function(a){return g.cache.get(a)})))}return b.prototype.clear=function(){return this.cache.clear(),this},b}();b.CachingCharacterMeasurer=o,b.getTruncatedText=g,b.addEllipsesToLine=h,b.writeLineHorizontally=i,b.writeLineVertically=j,b.writeText=m}(a.Text||(a.Text={}));a.Text}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(b){function c(b,c,e,f){var g=function(a){return f(a).width},h=d(b,c,g),i=f("hello world").height,j=Math.floor(e/i),k=j>=h.length;return k||(h=h.splice(0,j),j>0&&(h[j-1]=a.Text.addEllipsesToLine(h[j-1],c,f))),{originalText:b,lines:h,textFits:k}}function d(a,b,c){for(var d=[],e=a.split("\n"),g=0,h=e.length;h>g;g++){var i=e[g];null!==i?d=d.concat(f(i,b,c)):d.push("")}return d}function e(b,c,d){var e=h(b),f=e.map(d),g=a.Methods.max(f,0);return c>=g}function f(a,b,c){for(var d,e=[],f=h(a),i="",j=0;d||je;e++){var g=a[e];""===c||j(c[0],g,d)?c+=g:(b.push(c),c=g),d=g}return c&&b.push(c),b}function i(a){return null==a?!0:""===a.trim()}function j(a,b,c){return m.test(a)&&m.test(b)?!0:m.test(a)||m.test(b)?!1:l.test(c)||k.test(b)?!1:!0}var k=/[{\[]/,l=/[!"%),-.:;?\]}]/,m=/^\s+$/;b.breakTextToFitRect=c,b.canWrapWithoutBreakingWords=e}(a.WordWrap||(a.WordWrap={}));a.WordWrap}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b;try{b=a.node().getBBox()}catch(c){b={x:0,y:0,width:0,height:0}}return b}function c(b){null!=window.requestAnimationFrame?window.requestAnimationFrame(b):setTimeout(b,a.POLYFILL_TIMEOUT_MSEC)}function d(a,b){var c=a.getPropertyValue(b),d=parseFloat(c);return d!==d?0:d}function e(a){for(var b=a.node();null!==b&&"svg"!==b.nodeName;)b=b.parentNode;return null==b}function f(a){var b=window.getComputedStyle(a);return d(b,"width")+d(b,"padding-left")+d(b,"padding-right")+d(b,"border-left-width")+d(b,"border-right-width")}function g(a){var b=window.getComputedStyle(a);return d(b,"height")+d(b,"padding-top")+d(b,"padding-bottom")+d(b,"border-top-width")+d(b,"border-bottom-width")}function h(a){var b=a.node().clientWidth;if(0===b){var c=a.attr("width");if(-1!==c.indexOf("%")){for(var d=a.node().parentNode;null!=d&&0===d.clientWidth;)d=d.parentNode;if(null==d)throw new Error("Could not compute width of element");b=d.clientWidth*parseFloat(c)/100}else b=parseFloat(c)}return b}function i(a,b,c){var d=d3.transform(a.attr("transform"));return null==b?d.translate:(c=null==c?0:c,d.translate[0]=b,d.translate[1]=c,a.attr("transform",d.toString()),a)}function j(a,b){return a.rightb.right?!1:a.bottomb.bottom?!1:!0}a.getBBox=b,a.POLYFILL_TIMEOUT_MSEC=1e3/60,a.requestAnimationFramePolyfill=c,a.isSelectionRemovedFromSVG=e,a.getElementWidth=f,a.getElementHeight=g,a.getSVGPixelWidth=h,a.translate=i,a.boxesOverlap=j}(a.DOM||(a.DOM={}));a.DOM}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){!function(a){function b(a){var b=d3.rgb(a),c=function(a){return a/=255,.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},d=c(b.r),e=c(b.g),f=c(b.b);return.2126*d+.7152*e+.0722*f}function c(a,c){var d=b(a)+.05,e=b(c)+.05;return d>e?d/e:e/d}a.contrast=c}(a.Color||(a.Color={}));a.Color}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){a.MILLISECONDS_IN_ONE_DAY=864e5,function(b){function c(a,c,d){void 0===a&&(a=2),void 0===c&&(c="$"),void 0===d&&(d=!0);var e=b.fixed(a);return function(a){var b=e(Math.abs(a));return""!==b&&(d?b=c+b:b+=c,0>a&&(b="-"+b)),b}}function d(a){return void 0===a&&(a=3),k(a),function(b){return b.toFixed(a)}}function e(a){return void 0===a&&(a=3),k(a),function(b){if("number"==typeof b){var c=Math.pow(10,a);return String(Math.round(b*c)/c)}return String(b)}}function f(){return function(a){return String(a)}}function g(a){void 0===a&&(a=0);var c=b.fixed(a);return function(a){var b=100*a,d=a.toString(),e=Math.pow(10,d.length-(d.indexOf(".")+1));return b=parseInt((b*e).toString(),10)/e,c(b)+"%"}}function h(a){return void 0===a&&(a=3),k(a),function(b){return d3.format("."+a+"s")(b)}}function i(){var a=8,b={};return b[0]={format:".%L",filter:function(a){return 0!==a.getMilliseconds()}},b[1]={format:":%S",filter:function(a){return 0!==a.getSeconds()}},b[2]={format:"%I:%M",filter:function(a){return 0!==a.getMinutes()}},b[3]={format:"%I %p",filter:function(a){return 0!==a.getHours()}},b[4]={format:"%a %d",filter:function(a){return 0!==a.getDay()&&1!==a.getDate()}},b[5]={format:"%b %d",filter:function(a){return 1!==a.getDate()}},b[6]={format:"%b",filter:function(a){return 0!==a.getMonth()}},b[7]={format:"%Y",filter:function(){return!0}},function(c){for(var d=0;a>d;d++)if(b[d].filter(c))return d3.time.format(b[d].format)(c)}}function j(b,c,d){return void 0===b&&(b=0),void 0===c&&(c=a.MILLISECONDS_IN_ONE_DAY),void 0===d&&(d=""),function(a){var e=Math.round((a.valueOf()-b)/c);return e.toString()+d}}function k(a){if(0>a||a>20)throw new RangeError("Formatter precision must be between 0 and 20")}b.currency=c,b.fixed=d,b.general=e,b.identity=f,b.percentage=g,b.siSuffix=h,b.time=i,b.relativeDate=j}(a.Formatters||(a.Formatters={}));a.Formatters}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){a.SHOW_WARNINGS=!0}(a.Config||(a.Config={}));a.Config}(Plottable||(Plottable={}));var Plottable;!function(a){a.version="0.35.0"}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.CORAL_RED="#fd373e",a.INDIGO="#5279c7",a.ROBINS_EGG_BLUE="#06cccc",a.FERN="#63c261",a.BURNING_ORANGE="#ff7939",a.ROYAL_HEATH="#962565",a.CONIFER="#99ce50",a.CERISE_RED="#db2e65",a.BRIGHT_SUN="#fad419",a.JACARTA="#2c2b6f",a.PLOTTABLE_COLORS=[a.INDIGO,a.CORAL_RED,a.FERN,a.BRIGHT_SUN,a.JACARTA,a.BURNING_ORANGE,a.CERISE_RED,a.CONIFER,a.ROYAL_HEATH,a.ROBINS_EGG_BLUE],a}();a.Colors=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._plottableID=a.nextID++}return a.nextID=0,a}();a.PlottableObject=b}(a.Core||(a.Core={}));a.Core}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this.key2callback=new a._Util.StrictEqualityAssociativeArray,this.listenable=c}return __extends(c,b),c.prototype.registerListener=function(a,b){return this.key2callback.set(a,b),this},c.prototype.broadcast=function(){for(var a=this,b=[],c=0;c0){var f=d.valueOf();return d instanceof Date?[f-b.ONE_DAY,f+b.ONE_DAY]:[f-b.PADDING_FOR_IDENTICAL_DOMAIN,f+b.PADDING_FOR_IDENTICAL_DOMAIN]}if(a.domain()[0]===a.domain()[1])return c;var g=this.padProportion/2,h=a.invert(a.scale(d)-(a.scale(e)-a.scale(d))*g),i=a.invert(a.scale(e)+(a.scale(e)-a.scale(d))*g),j=this.paddingExceptions.values().concat(this.unregisteredPaddingExceptions.values()),k=d3.set(j);return k.has(d)&&(h=d),k.has(e)&&(i=e),[h,i]},b.prototype.niceDomain=function(a,b){return this.doNice?a._niceDomain(b,this.niceCount):b},b.prototype.includeDomain=function(a){var b=this.includedValues.values().concat(this.unregisteredIncludedValues.values());return b.reduce(function(a,b){return[Math.min(a[0],b),Math.max(a[1],b)]},a)},b.PADDING_FOR_IDENTICAL_DOMAIN=1,b.ONE_DAY=864e5,b}();a.Domainer=b}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this),this._autoDomainAutomatically=!0,this.broadcaster=new a.Core.Broadcaster(this),this._rendererAttrID2Extent={},this._typeCoercer=function(a){return a},this._domainModificationInProgress=!1,this._d3Scale=c}return __extends(c,b),c.prototype._getAllExtents=function(){return d3.values(this._rendererAttrID2Extent)},c.prototype._getExtent=function(){return[]},c.prototype.autoDomain=function(){return this._autoDomainAutomatically=!0,this._setDomain(this._getExtent()),this},c.prototype._autoDomainIfAutomaticMode=function(){this._autoDomainAutomatically&&this.autoDomain()},c.prototype.scale=function(a){return this._d3Scale(a)},c.prototype.domain=function(a){return null==a?this._getDomain():(this._autoDomainAutomatically=!1,this._setDomain(a),this)},c.prototype._getDomain=function(){return this._d3Scale.domain()},c.prototype._setDomain=function(a){this._domainModificationInProgress||(this._domainModificationInProgress=!0,this._d3Scale.domain(a),this.broadcaster.broadcast(),this._domainModificationInProgress=!1)},c.prototype.range=function(a){return null==a?this._d3Scale.range():(this._d3Scale.range(a),this)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._updateExtent=function(a,b,c){return this._rendererAttrID2Extent[a+b]=c,this._autoDomainIfAutomaticMode(),this},c.prototype._removeExtent=function(a,b){return delete this._rendererAttrID2Extent[a+b],this._autoDomainIfAutomaticMode(),this},c}(a.Core.PlottableObject);b.AbstractScale=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){b.call(this,c),this._numTicks=10,this._PADDING_FOR_IDENTICAL_DOMAIN=1,this._userSetDomainer=!1,this._domainer=new a.Domainer,this._typeCoercer=function(a){return+a},this._tickGenerator=function(a){return a.getDefaultTicks()}}return __extends(c,b),c.prototype._getExtent=function(){return this._domainer.computeDomain(this._getAllExtents(),this)},c.prototype.invert=function(a){return this._d3Scale.invert(a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(c){var d=function(a){return a!==a||1/0===a||a===-1/0};return d(c[0])||d(c[1])?void a._Util.Methods.warn("Warning: QuantitativeScales cannot take NaN or Infinity as a domain value. Ignoring."):void b.prototype._setDomain.call(this,c)},c.prototype.interpolate=function(a){return null==a?this._d3Scale.interpolate():(this._d3Scale.interpolate(a),this)},c.prototype.rangeRound=function(a){return this._d3Scale.rangeRound(a),this},c.prototype.getDefaultTicks=function(){return this._d3Scale.ticks(this.numTicks())},c.prototype.clamp=function(a){return null==a?this._d3Scale.clamp():(this._d3Scale.clamp(a),this)},c.prototype.ticks=function(){return this._tickGenerator(this)},c.prototype.numTicks=function(a){return null==a?this._numTicks:(this._numTicks=a,this)},c.prototype._niceDomain=function(a,b){return this._d3Scale.copy().domain(a).nice(b).domain()},c.prototype.domainer=function(a){return null==a?this._domainer:(this._domainer=a,this._userSetDomainer=!0,this._autoDomainIfAutomaticMode(),this)},c.prototype._defaultExtent=function(){return[0,1]},c.prototype.tickGenerator=function(a){return null==a?this._tickGenerator:(this._tickGenerator=a,this)},c}(b.AbstractScale);b.AbstractQuantitative=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){a.call(this,null==b?d3.scale.linear():b)}return __extends(b,a),b.prototype.copy=function(){return new b(this._d3Scale.copy())},b}(a.AbstractQuantitative);a.Linear=b}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(d){b.call(this,null==d?d3.scale.log():d),c.warned||(c.warned=!0,a._Util.Methods.warn("Plottable.Scale.Log is deprecated. If possible, use Plottable.Scale.ModifiedLog instead."))}return __extends(c,b),c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){return[1,10]},c.warned=!1,c}(b.AbstractQuantitative);b.Log=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(void 0===a&&(a=10),b.call(this,d3.scale.linear()),this._showIntermediateTicks=!1,this.base=a,this.pivot=this.base,this.untransformedDomain=this._defaultExtent(),this._numTicks=10,1>=a)throw new Error("ModifiedLogScale: The base must be > 1")}return __extends(c,b),c.prototype.adjustedLog=function(a){var b=0>a?-1:1;return a*=b,aa?-1:1;return a*=b,a=Math.pow(this.base,a),a=d&&e>=a}),m=j.concat(l).concat(k);return m.length<=1&&(m=d3.scale.linear().domain([d,e]).ticks(b)),m},c.prototype.logTicks=function(b,c){var d=this,e=this.howManyTicks(b,c);if(0===e)return[];var f=Math.floor(Math.log(b)/Math.log(this.base)),g=Math.ceil(Math.log(c)/Math.log(this.base)),h=d3.range(g,f,-Math.ceil((g-f)/e)),i=this._showIntermediateTicks?Math.floor(e/h.length):1,j=d3.range(this.base,1,-(this.base-1)/i).map(Math.floor),k=a._Util.Methods.uniq(j),l=h.map(function(a){return k.map(function(b){return Math.pow(d.base,a-1)*b})}),m=a._Util.Methods.flatten(l),n=m.filter(function(a){return a>=b&&c>=a}),o=n.sort(function(a,b){return a-b});return o},c.prototype.howManyTicks=function(b,c){var d=this.adjustedLog(a._Util.Methods.min(this.untransformedDomain,0)),e=this.adjustedLog(a._Util.Methods.max(this.untransformedDomain,0)),f=this.adjustedLog(b),g=this.adjustedLog(c),h=(g-f)/(e-d),i=Math.ceil(h*this._numTicks);return i},c.prototype.copy=function(){return new c(this.base)},c.prototype._niceDomain=function(a){return a},c.prototype.showIntermediateTicks=function(a){return null==a?this._showIntermediateTicks:void(this._showIntermediateTicks=a)},c}(b.AbstractQuantitative);b.ModifiedLog=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){if(b.call(this,null==a?d3.scale.ordinal():a),this._range=[0,1],this._rangeType="bands",this._innerPadding=.3,this._outerPadding=.5,this._typeCoercer=function(a){return null!=a&&a.toString?a.toString():a},this._innerPadding>this._outerPadding)throw new Error("outerPadding must be >= innerPadding so cat axis bands work out reasonably")}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents();return a._Util.Methods.uniq(a._Util.Methods.flatten(b))},c.prototype.domain=function(a){return b.prototype.domain.call(this,a)},c.prototype._setDomain=function(a){b.prototype._setDomain.call(this,a),this.range(this.range())},c.prototype.range=function(a){return null==a?this._range:(this._range=a,"points"===this._rangeType?this._d3Scale.rangePoints(a,2*this._outerPadding):"bands"===this._rangeType&&this._d3Scale.rangeBands(a,this._innerPadding,this._outerPadding),this)},c.prototype.rangeBand=function(){return this._d3Scale.rangeBand()},c.prototype.innerPadding=function(){var a=this.domain();if(a.length<2)return 0;var b=Math.abs(this.scale(a[1])-this.scale(a[0]));return b-this.rangeBand()},c.prototype.fullBandStartAndWidth=function(a){var b=this.scale(a)-this.innerPadding()/2,c=this.rangeBand()+this.innerPadding();return[b,c]},c.prototype.rangeType=function(a,b,c){if(null==a)return this._rangeType; +if("points"!==a&&"bands"!==a)throw new Error("Unsupported range type: "+a);return this._rangeType=a,null!=b&&(this._outerPadding=b),null!=c&&(this._innerPadding=c),this.range(this.range()),this.broadcaster.broadcast(),this},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c}(b.AbstractScale);b.Ordinal=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c){var d;switch(c){case null:case void 0:d=d3.scale.ordinal().range(a.Core.Colors.PLOTTABLE_COLORS);break;case"Category10":case"category10":case"10":d=d3.scale.category10();break;case"Category20":case"category20":case"20":d=d3.scale.category20();break;case"Category20b":case"category20b":case"20b":d=d3.scale.category20b();break;case"Category20c":case"category20c":case"20c":d=d3.scale.category20c();break;default:throw new Error("Unsupported ColorScale type")}b.call(this,d)}return __extends(c,b),c.prototype._getExtent=function(){var b=this._getAllExtents(),c=[];return b.forEach(function(a){c=c.concat(a)}),a._Util.Methods.uniq(c)},c}(b.AbstractScale);b.Color=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,null==a?d3.time.scale():a),this._typeCoercer=function(a){return a&&a._isAMomentObject||a instanceof Date?a:new Date(a)}}return __extends(c,b),c.prototype._tickInterval=function(a,b){var c=d3.time.scale();return c.domain(this.domain()),c.range(this.range()),c.ticks(a.range,b)},c.prototype._setDomain=function(a){return a=a.map(this._typeCoercer),b.prototype._setDomain.call(this,a)},c.prototype.copy=function(){return new c(this._d3Scale.copy())},c.prototype._defaultExtent=function(){var b=(new Date).valueOf(),c=b-a.MILLISECONDS_IN_ONE_DAY;return[c,b]},c}(b.AbstractQuantitative);b.Time=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,d){void 0===a&&(a="reds"),void 0===d&&(d="linear"),this._colorRange=this._resolveColorValues(a),this._scaleType=d,b.call(this,c.getD3InterpolatedScale(this._colorRange,this._scaleType))}return __extends(c,b),c.getD3InterpolatedScale=function(a,b){var d;switch(b){case"linear":d=d3.scale.linear();break;case"log":d=d3.scale.log();break;case"sqrt":d=d3.scale.sqrt();break;case"pow":d=d3.scale.pow()}if(null==d)throw new Error("unknown Quantitative scale type "+b);return d.range([0,1]).interpolate(c.interpolateColors(a))},c.interpolateColors=function(a){if(a.length<2)throw new Error("Color scale arrays must have at least two elements.");return function(){return function(b){b=Math.max(0,Math.min(1,b));var c=b*(a.length-1),d=Math.floor(c),e=Math.ceil(c),f=c-d;return d3.interpolateLab(a[d],a[e])(f)}}},c.prototype.colorRange=function(a){return null==a?this._colorRange:(this._colorRange=this._resolveColorValues(a),this._resetScale(),this)},c.prototype.scaleType=function(a){return null==a?this._scaleType:(this._scaleType=a,this._resetScale(),this)},c.prototype._resetScale=function(){this._d3Scale=c.getD3InterpolatedScale(this._colorRange,this._scaleType),this._autoDomainIfAutomaticMode(),this.broadcaster.broadcast()},c.prototype._resolveColorValues=function(a){return a instanceof Array?a:null!=c.COLOR_SCALES[a]?c.COLOR_SCALES[a]:c.COLOR_SCALES.reds},c.prototype.autoDomain=function(){var b=this._getAllExtents();return b.length>0&&this._setDomain([a._Util.Methods.min(b,function(a){return a[0]},0),a._Util.Methods.max(b,function(a){return a[1]},0)]),this},c.COLOR_SCALES={reds:["#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"],blues:["#FFFFFF","#CCFFFF","#A5FFFD","#85F7FB","#6ED3EF","#55A7E0","#417FD0","#2545D3","#0B02E1"],posneg:["#0B02E1","#2545D3","#417FD0","#55A7E0","#6ED3EF","#85F7FB","#A5FFFD","#CCFFFF","#FFFFFF","#FFF6E1","#FEF4C0","#FED976","#FEB24C","#FD8D3C","#FC4E2A","#E31A1C","#B10026"]},c}(b.AbstractScale);b.InterpolatedColor=c}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(a){var b=this;if(this.rescaleInProgress=!1,null==a)throw new Error("ScaleDomainCoordinator requires scales to coordinate");this.scales=a,this.scales.forEach(function(a){return a.broadcaster.registerListener(b,function(a){return b.rescale(a)})})}return a.prototype.rescale=function(a){if(!this.rescaleInProgress){this.rescaleInProgress=!0;var b=a.domain();this.scales.forEach(function(a){return a.domain(b)}),this.rescaleInProgress=!1}},a}();a.ScaleDomainCoordinator=b}(a._Util||(a._Util={}));a._Util}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){!function(b){function c(b){if(0>=b)throw new Error("interval must be positive number");return function(c){var d=c.domain(),e=Math.min(d[0],d[1]),f=Math.max(d[0],d[1]),g=Math.ceil(e/b)*b,h=Math.floor((f-g)/b)+1,i=e%b===0?[]:[e],j=a._Util.Methods.range(0,h).map(function(a){return g+a*b}),k=f%b===0?[]:[f];return i.concat(j).concat(k)}}function d(){return function(a){var b=a.getDefaultTicks();return b.filter(function(a,c){return a%1===0||0===c||c===b.length-1})}}b.intervalTickGenerator=c,b.integerTickGenerator=d}(b.TickGenerators||(b.TickGenerators={}));b.TickGenerators}(a.Scale||(a.Scale={}));a.Scale}(Plottable||(Plottable={}));var Plottable;!function(a){!function(b){var c=function(){function b(a){this.key=a}return b.prototype.setClass=function(a){return this._className=a,this},b.prototype.setup=function(a){this._renderArea=a},b.prototype.remove=function(){null!=this._renderArea&&this._renderArea.remove()},b.prototype._enterData=function(){},b.prototype._drawStep=function(){},b.prototype._numberOfAnimationIterations=function(a){return a.length},b.prototype.draw=function(b,c){var d=this;this._enterData(b);var e=this._numberOfAnimationIterations(b),f=0;return c.forEach(function(b){a._Util.Methods.setTimeout(function(){return d._drawStep(b)},f),f+=b.animator.getTiming(e)}),f},b}();b.AbstractDrawer=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype._enterData=function(a){b.prototype._enterData.call(this,a),this.pathSelection.datum(a)},c.prototype.setup=function(a){this.pathSelection=a.append("path").classed("line",!0).style({fill:"none","vector-effect":"non-scaling-stroke"}),b.prototype.setup.call(this,a)},c.prototype.createLine=function(a,b,c){return c||(c=function(){return!0}),d3.svg.line().x(a).y(b).defined(c)},c.prototype._numberOfAnimationIterations=function(){return 1},c.prototype._drawStep=function(c){{var d=(b.prototype._drawStep.call(this,c),a._Util.Methods.copyMap(c.attrToProjector)),e=d.x,f=d.y;d.defined}delete d.x,delete d.y,d.d=this.createLine(e,f,d.defined),d.defined&&delete d.defined,d.fill&&this.pathSelection.attr("fill",d.fill),c.animator.animate(this.pathSelection,d)},c}(b.AbstractDrawer);b.Line=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(){c.apply(this,arguments),this._drawLine=!0}return __extends(d,c),d.prototype._enterData=function(a){this._drawLine?c.prototype._enterData.call(this,a):b.AbstractDrawer.prototype._enterData.call(this,a),this.areaSelection.datum(a)},d.prototype.drawLine=function(a){return this._drawLine=a,this},d.prototype.setup=function(a){this.areaSelection=a.append("path").classed("area",!0).style({stroke:"none"}),this._drawLine?c.prototype.setup.call(this,a):b.AbstractDrawer.prototype.setup.call(this,a)},d.prototype.createArea=function(a,b,c,d){return d||(d=function(){return!0}),d3.svg.area().x(a).y0(b).y1(c).defined(d)},d.prototype._drawStep=function(d){this._drawLine?c.prototype._drawStep.call(this,d):b.AbstractDrawer.prototype._drawStep.call(this,d);{var e=a._Util.Methods.copyMap(d.attrToProjector),f=e.x,g=e.y0,h=e.y;e.defined}delete e.x,delete e.y0,delete e.y,e.d=this.createArea(f,g,h,e.defined),e.defined&&delete e.defined,e.fill&&this.areaSelection.attr("fill",e.fill),d.animator.animate(this.areaSelection,e)},d}(b.Line);b.Area=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments)}return __extends(c,b),c.prototype.svgElement=function(a){return this._svgElement=a,this},c.prototype._getDrawSelection=function(){return this._renderArea.selectAll(this._svgElement)},c.prototype._drawStep=function(a){b.prototype._drawStep.call(this,a);var c=this._getDrawSelection();a.attrToProjector.fill&&c.attr("fill",a.attrToProjector.fill),a.animator.animate(c,a.attrToProjector)},c.prototype._enterData=function(a){b.prototype._enterData.call(this,a);var c=this._getDrawSelection().data(a);c.enter().append(this._svgElement),null!=this._className&&c.classed(this._className,!0),c.exit().remove()},c.prototype.filterDefinedData=function(a,b){return b?a.filter(b):a},c.prototype.draw=function(c,d){var e=this,f=[];d.forEach(function(b,c){f[c]={animator:b.animator,attrToProjector:a._Util.Methods.copyMap(b.attrToProjector)}});var g=f.reduce(function(a,b){return e.filterDefinedData(a,b.attrToProjector.defined)},c);return f.forEach(function(a){a.attrToProjector.defined&&delete a.attrToProjector.defined}),b.prototype.draw.call(this,g,f)},c}(b.AbstractDrawer);b.Element=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=5,d=5,e=function(b){function e(a,c){b.call(this,a),this._someLabelsTooWide=!1,this.svgElement("rect"),this._isVertical=c}return __extends(e,b),e.prototype.setup=function(c){b.prototype.setup.call(this,c.append("g").classed("bar-area",!0)),this.textArea=c.append("g").classed("bar-label-text-area",!0),this.measurer=new a._Util.Text.CachingCharacterMeasurer(this.textArea.append("text")).measure},e.prototype.removeLabels=function(){this.textArea.selectAll("g").remove()},e.prototype.drawText=function(b,e){var f=this,g=b.map(function(b,g){var h=e.label(b,g).toString(),i=e.width(b,g),j=e.height(b,g),k=e.x(b,g),l=e.y(b,g),m=e.positive(b,g),n=f.measurer(h),o=e.fill(b,g),p=1.6*a._Util.Color.contrast("white",o)t;if(n.height<=j&&n.width<=i){var v=Math.min((q-r)/2,c);m||(v=-1*v),f._isVertical?l+=v:k+=v;var w=f.textArea.append("g").attr("transform","translate("+k+","+l+")"),x=p?"dark-label":"light-label";w.classed(x,!0);var y,z;f._isVertical?(y="center",z=m?"top":"bottom"):(y=m?"left":"right",z="center"),a._Util.Text.writeLineHorizontally(h,w,i,j,y,z)}return u});this._someLabelsTooWide=g.some(function(a){return a})},e}(b.Element);b.Rect=e}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this,a),this._svgElement="path"}return __extends(c,b),c.prototype.createArc=function(a,b){return d3.svg.arc().innerRadius(a).outerRadius(b)},c.prototype.retargetProjectors=function(a){var b={};return d3.entries(a).forEach(function(a){b[a.key]=function(b,c){return a.value(b.data,c)}}),b},c.prototype._drawStep=function(c){var d=a._Util.Methods.copyMap(c.attrToProjector);d=this.retargetProjectors(d);var e=d["inner-radius"],f=d["outer-radius"];return delete d["inner-radius"],delete d["outer-radius"],d.d=this.createArc(e,f),b.prototype._drawStep.call(this,{attrToProjector:d,animator:c.animator})},c.prototype.draw=function(a,c){var d=c[0].attrToProjector.value,e=d3.layout.pie().sort(null).value(d)(a);return c.forEach(function(a){return delete a.attrToProjector.value}),b.prototype.draw.call(this,e,c)},c}(b.Element);b.Arc=c}(a._Drawer||(a._Drawer={}));a._Drawer}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.clipPathEnabled=!1,this._xAlignProportion=0,this._yAlignProportion=0,this._fixedHeightFlag=!1,this._fixedWidthFlag=!1,this._isSetup=!1,this._isAnchored=!1,this.interactionsToRegister=[],this.boxes=[],this.isTopLevelComponent=!1,this._width=0,this._height=0,this._xOffset=0,this._yOffset=0,this.cssClasses=["component"],this.removed=!1,this._autoResize=c.AUTORESIZE_BY_DEFAULT}return __extends(c,b),c.prototype._anchor=function(a){if(this.removed)throw new Error("Can't reuse remove()-ed components!");"svg"===a.node().nodeName&&(this.rootSVG=a,this.rootSVG.classed("plottable",!0),this.rootSVG.style("overflow","visible"),this.isTopLevelComponent=!0),null!=this._element?a.node().appendChild(this._element.node()):(this._element=a.append("g"),this._setup()),this._isAnchored=!0},c.prototype._setup=function(){var a=this;this._isSetup||(this.cssClasses.forEach(function(b){a._element.classed(b,!0)}),this.cssClasses=null,this._backgroundContainer=this._element.append("g").classed("background-container",!0),this._content=this._element.append("g").classed("content",!0),this._foregroundContainer=this._element.append("g").classed("foreground-container",!0),this.boxContainer=this._element.append("g").classed("box-container",!0),this.clipPathEnabled&&this.generateClipPath(),this.addBox("bounding-box"),this.interactionsToRegister.forEach(function(b){return a.registerInteraction(b)}),this.interactionsToRegister=null,this.isTopLevelComponent&&this.autoResize(this._autoResize),this._isSetup=!0)},c.prototype._requestedSpace=function(){return{width:0,height:0,wantsWidth:!1,wantsHeight:!1}},c.prototype._computeLayout=function(b,c,d,e){var f=this;if(null==b||null==c||null==d||null==e){if(null==this._element)throw new Error("anchor must be called before computeLayout");if(!this.isTopLevelComponent)throw new Error("null arguments cannot be passed to _computeLayout() on a non-root node");b=0,c=0,null==this.rootSVG.attr("width")&&this.rootSVG.attr("width","100%"),null==this.rootSVG.attr("height")&&this.rootSVG.attr("height","100%");var g=this.rootSVG.node();d=a._Util.DOM.getElementWidth(g),e=a._Util.DOM.getElementHeight(g)}this.xOrigin=b,this.yOrigin=c;var h=this._requestedSpace(d,e);this._width=this._isFixedWidth()?Math.min(d,h.width):d,this._height=this._isFixedHeight()?Math.min(e,h.height):e;var i=this.xOrigin+this._xOffset,j=this.yOrigin+this._yOffset;i+=(d-this.width())*this._xAlignProportion,j+=(e-h.height)*this._yAlignProportion,this._element.attr("transform","translate("+i+","+j+")"),this.boxes.forEach(function(a){return a.attr("width",f.width()).attr("height",f.height())})},c.prototype._render=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToRender(this)},c.prototype._scheduleComputeLayout=function(){this._isAnchored&&this._isSetup&&a.Core.RenderController.registerToComputeLayout(this)},c.prototype._doRender=function(){},c.prototype._invalidateLayout=function(){this._isAnchored&&this._isSetup&&(this.isTopLevelComponent?this._scheduleComputeLayout():this._parent._invalidateLayout())},c.prototype.renderTo=function(b){if(null!=b){var c;if(c="function"==typeof b.node?b:d3.select(b),!c.node()||"svg"!==c.node().nodeName)throw new Error("Plottable requires a valid SVG to renderTo");this._anchor(c)}if(null==this._element)throw new Error("If a component has never been rendered before, then renderTo must be given a node to render to, or a D3.Selection, or a selector string");return this._computeLayout(),this._render(),a.Core.RenderController.flush(),this},c.prototype.resize=function(a,b){if(!this.isTopLevelComponent)throw new Error("Cannot resize on non top-level component");return null!=a&&null!=b&&this._isAnchored&&this.rootSVG.attr({width:a,height:b}),this._invalidateLayout(),this},c.prototype.autoResize=function(b){return b?a.Core.ResizeBroadcaster.register(this):a.Core.ResizeBroadcaster.deregister(this),this._autoResize=b,this},c.prototype.xAlign=function(a){if(a=a.toLowerCase(),"left"===a)this._xAlignProportion=0;else if("center"===a)this._xAlignProportion=.5;else{if("right"!==a)throw new Error("Unsupported alignment");this._xAlignProportion=1}return this._invalidateLayout(),this},c.prototype.yAlign=function(a){if(a=a.toLowerCase(),"top"===a)this._yAlignProportion=0;else if("center"===a)this._yAlignProportion=.5;else{if("bottom"!==a)throw new Error("Unsupported alignment");this._yAlignProportion=1}return this._invalidateLayout(),this},c.prototype.xOffset=function(a){return this._xOffset=a,this._invalidateLayout(),this},c.prototype.yOffset=function(a){return this._yOffset=a,this._invalidateLayout(),this},c.prototype.addBox=function(a,b){if(null==this._element)throw new Error("Adding boxes before anchoring is currently disallowed");var b=null==b?this.boxContainer:b,c=b.append("rect");return null!=a&&c.classed(a,!0),this.boxes.push(c),null!=this.width()&&null!=this.height()&&c.attr("width",this.width()).attr("height",this.height()),c},c.prototype.generateClipPath=function(){var a=/MSIE [5-9]/.test(navigator.userAgent)?"":document.location.href;this._element.attr("clip-path","url("+a+"#clipPath"+this._plottableID+")");var b=this.boxContainer.append("clipPath").attr("id","clipPath"+this._plottableID);this.addBox("clip-rect",b)},c.prototype.registerInteraction=function(a){return this._element?(this.hitBox||(this.hitBox=this.addBox("hit-box"),this.hitBox.style("fill","#ffffff").style("opacity",0)),a._anchor(this,this.hitBox)):this.interactionsToRegister.push(a),this},c.prototype.classed=function(a,b){if(null==b)return null==a?!1:null==this._element?-1!==this.cssClasses.indexOf(a):this._element.classed(a);if(null==a)return this;if(null==this._element){var c=this.cssClasses.indexOf(a);b&&-1===c?this.cssClasses.push(a):b||-1===c||this.cssClasses.splice(c,1)}else this._element.classed(a,b);return this},c.prototype._isFixedWidth=function(){return this._fixedWidthFlag},c.prototype._isFixedHeight=function(){return this._fixedHeightFlag},c.prototype.merge=function(b){var c;if(this._isSetup||this._isAnchored)throw new Error("Can't presently merge a component that's already been anchored");return a.Component.Group.prototype.isPrototypeOf(b)?(c=b,c._addComponent(this,!0),c):c=new a.Component.Group([this,b])},c.prototype.detach=function(){return this._isAnchored&&this._element.remove(),null!=this._parent&&this._parent._removeComponent(this),this._isAnchored=!1,this._parent=null,this},c.prototype.remove=function(){this.removed=!0,this.detach(),a.Core.ResizeBroadcaster.deregister(this)},c.prototype.width=function(){return this._width},c.prototype.height=function(){return this._height},c.AUTORESIZE_BY_DEFAULT=!0,c}(a.Core.PlottableObject);b.AbstractComponent=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this._components=[]}return __extends(b,a),b.prototype._anchor=function(b){var c=this;a.prototype._anchor.call(this,b),this._components.forEach(function(a){return a._anchor(c._content)})},b.prototype._render=function(){this._components.forEach(function(a){return a._render()})},b.prototype._removeComponent=function(a){var b=this._components.indexOf(a);b>=0&&(this._components.splice(b,1),this._invalidateLayout())},b.prototype._addComponent=function(a,b){return void 0===b&&(b=!1),!a||this._components.indexOf(a)>=0?!1:(b?this._components.unshift(a):this._components.push(a),a._parent=this,this._isAnchored&&a._anchor(this._content),this._invalidateLayout(),!0)},b.prototype.components=function(){return this._components.slice()},b.prototype.empty=function(){return 0===this._components.length},b.prototype.detachAll=function(){return this._components.slice().forEach(function(a){return a.detach()}),this},b.prototype.remove=function(){a.prototype.remove.call(this),this._components.slice().forEach(function(a){return a.remove()})},b}(a.AbstractComponent);a.AbstractComponentContainer=b}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.classed("component-group",!0),a.forEach(function(a){return c._addComponent(a)})}return __extends(c,b),c.prototype._requestedSpace=function(b,c){var d=this._components.map(function(a){return a._requestedSpace(b,c)});return{width:a._Util.Methods.max(d,function(a){return a.width},0),height:a._Util.Methods.max(d,function(a){return a.height},0),wantsWidth:d.map(function(a){return a.wantsWidth}).some(function(a){return a}),wantsHeight:d.map(function(a){return a.wantsHeight}).some(function(a){return a})}},c.prototype.merge=function(a){return this._addComponent(a),this},c.prototype._computeLayout=function(a,c,d,e){var f=this;return b.prototype._computeLayout.call(this,a,c,d,e),this._components.forEach(function(a){a._computeLayout(0,0,f.width(),f.height())}),this},c.prototype._isFixedWidth=function(){return this._components.every(function(a){return a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return this._components.every(function(a){return a._isFixedHeight()})},c}(b.AbstractComponentContainer);b.Group=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){var f=this;if(void 0===e&&(e=a.Formatters.identity()),b.call(this),this._endTickLength=5,this._tickLength=5,this._tickLabelPadding=10,this._gutter=15,this._showEndTickLabels=!1,null==c||null==d)throw new Error("Axis requires a scale and orientation");this._scale=c,this.orient(d),this._setDefaultAlignment(),this.classed("axis",!0),this._isHorizontal()?this.classed("x-axis",!0):this.classed("y-axis",!0),this.formatter(e),this._scale.broadcaster.registerListener(this,function(){return f._rescale()})}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this._scale.broadcaster.deregisterListener(this)},c.prototype._isHorizontal=function(){return"top"===this._orientation||"bottom"===this._orientation},c.prototype._computeWidth=function(){return this._computedWidth=this._maxLabelTickLength(),this._computedWidth},c.prototype._computeHeight=function(){return this._computedHeight=this._maxLabelTickLength(),this._computedHeight},c.prototype._requestedSpace=function(a,b){var c=0,d=0;return this._isHorizontal()?(null==this._computedHeight&&this._computeHeight(),d=this._computedHeight+this._gutter):(null==this._computedWidth&&this._computeWidth(),c=this._computedWidth+this._gutter),{width:c,height:d,wantsWidth:!this._isHorizontal()&&c>a,wantsHeight:this._isHorizontal()&&d>b}},c.prototype._isFixedHeight=function(){return this._isHorizontal()},c.prototype._isFixedWidth=function(){return!this._isHorizontal()},c.prototype._rescale=function(){this._render()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._scale.range(this._isHorizontal()?[0,this.width()]:[this.height(),0])},c.prototype._setup=function(){b.prototype._setup.call(this),this._tickMarkContainer=this._content.append("g").classed(c.TICK_MARK_CLASS+"-container",!0),this._tickLabelContainer=this._content.append("g").classed(c.TICK_LABEL_CLASS+"-container",!0),this._baseline=this._content.append("line").classed("baseline",!0)},c.prototype._getTickValues=function(){return[]},c.prototype._doRender=function(){var a=this._getTickValues(),b=this._tickMarkContainer.selectAll("."+c.TICK_MARK_CLASS).data(a);b.enter().append("line").classed(c.TICK_MARK_CLASS,!0),b.attr(this._generateTickMarkAttrHash()),d3.select(b[0][0]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),d3.select(b[0][a.length-1]).classed(c.END_TICK_MARK_CLASS,!0).attr(this._generateTickMarkAttrHash(!0)),b.exit().remove(),this._baseline.attr(this._generateBaselineAttrHash())},c.prototype._generateBaselineAttrHash=function(){var a={x1:0,y1:0,x2:0,y2:0};switch(this._orientation){case"bottom":a.x2=this.width();break;case"top":a.x2=this.width(),a.y1=this.height(),a.y2=this.height();break;case"left":a.x1=this.width(),a.x2=this.width(),a.y2=this.height();break;case"right":a.y2=this.height()}return a},c.prototype._generateTickMarkAttrHash=function(a){var b=this;void 0===a&&(a=!1);var c={x1:0,y1:0,x2:0,y2:0},d=function(a){return b._scale.scale(a)};this._isHorizontal()?(c.x1=d,c.x2=d):(c.y1=d,c.y2=d);var e=a?this._endTickLength:this._tickLength;switch(this._orientation){case"bottom":c.y2=e;break;case"top":c.y1=this.height(),c.y2=this.height()-e;break;case"left":c.x1=this.width(),c.x2=this.width()-e;break;case"right":c.x2=e}return c},c.prototype._invalidateLayout=function(){this._computedWidth=null,this._computedHeight=null,b.prototype._invalidateLayout.call(this)},c.prototype._setDefaultAlignment=function(){switch(this._orientation){case"bottom":this.yAlign("top");break;case"top":this.yAlign("bottom");break;case"left":this.xAlign("right");break;case"right":this.xAlign("left")}},c.prototype.formatter=function(a){return void 0===a?this._formatter:(this._formatter=a,this._invalidateLayout(),this)},c.prototype.tickLength=function(a){if(null==a)return this._tickLength;if(0>a)throw new Error("tick length must be positive");return this._tickLength=a,this._invalidateLayout(),this},c.prototype.endTickLength=function(a){if(null==a)return this._endTickLength;if(0>a)throw new Error("end tick length must be positive");return this._endTickLength=a,this._invalidateLayout(),this},c.prototype._maxLabelTickLength=function(){return this.showEndTickLabels()?Math.max(this.tickLength(),this.endTickLength()):this.tickLength()},c.prototype.tickLabelPadding=function(a){if(null==a)return this._tickLabelPadding;if(0>a)throw new Error("tick label padding must be positive");return this._tickLabelPadding=a,this._invalidateLayout(),this},c.prototype.gutter=function(a){if(null==a)return this._gutter;if(0>a)throw new Error("gutter size must be positive");return this._gutter=a,this._invalidateLayout(),this},c.prototype.orient=function(a){if(null==a)return this._orientation;var b=a.toLowerCase();if("top"!==b&&"bottom"!==b&&"left"!==b&&"right"!==b)throw new Error("unsupported orientation");return this._orientation=b,this._invalidateLayout(),this},c.prototype.showEndTickLabels=function(a){return null==a?this._showEndTickLabels:(this._showEndTickLabels=a,this._render(),this)},c.prototype._hideEndTickLabels=function(){var a=this,b=this._element.select(".bounding-box")[0][0].getBoundingClientRect(),d=function(c){return Math.floor(b.left)<=Math.ceil(c.left)&&Math.floor(b.top)<=Math.ceil(c.top)&&Math.floor(c.right)<=Math.ceil(b.left+a.width())&&Math.floor(c.bottom)<=Math.ceil(b.top+a.height())},e=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS);if(0!==e[0].length){var f=e[0][0];d(f.getBoundingClientRect())||d3.select(f).style("visibility","hidden");var g=e[0][e[0].length-1];d(g.getBoundingClientRect())||d3.select(g).style("visibility","hidden")}},c.prototype._hideOverlappingTickLabels=function(){var b,d=this._tickLabelContainer.selectAll("."+c.TICK_LABEL_CLASS).filter(function(){return"visible"===d3.select(this).style("visibility")});d.each(function(){var c=this.getBoundingClientRect(),d=d3.select(this);null!=b&&a._Util.DOM.boxesOverlap(c,b)?d.style("visibility","hidden"):(b=c,d.style("visibility","visible"))})},c.END_TICK_MARK_CLASS="end-tick-mark",c.TICK_MARK_CLASS="tick-mark",c.TICK_LABEL_CLASS="tick-label",c}(a.Component.AbstractComponent);b.AbstractAxis=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b){c.call(this,a,b),this.classed("time-axis",!0),this.tickLabelPadding(5)}return __extends(d,c),d.prototype.orient=function(a){if(a&&("right"===a.toLowerCase()||"left"===a.toLowerCase()))throw new Error(a+" is not a supported orientation for TimeAxis - only horizontal orientations are supported");return c.prototype.orient.call(this,a)},d.prototype._computeHeight=function(){if(null!==this._computedHeight)return this._computedHeight;var a=this._measureTextHeight(this._majorTickLabels)+this._measureTextHeight(this._minorTickLabels);return this.tickLength(a),this.endTickLength(a),this._computedHeight=this._maxLabelTickLength()+2*this.tickLabelPadding(),this._computedHeight},d.prototype.calculateWorstWidth=function(a,b){var c=new Date(9999,8,29,12,59,9999);return this.measurer(d3.time.format(b)(c)).width},d.prototype.getIntervalLength=function(a){var b=this._scale.domain()[0],c=a.timeUnit.offset(b,a.step);if(c>this._scale.domain()[1])return this.width();var d=Math.abs(this._scale.scale(c)-this._scale.scale(b));return d},d.prototype.isEnoughSpace=function(a,b){var c=this.calculateWorstWidth(a,b.formatString)+2*this.tickLabelPadding(),d=Math.min(this.getIntervalLength(b),this.width());return d>c},d.prototype._setup=function(){c.prototype._setup.call(this),this._majorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this._minorTickLabels=this._content.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),this.measurer=a._Util.Text.getTextMeasurer(this._majorTickLabels.append("text"))},d.prototype.getTickLevel=function(){for(var b=0;b=d._minorIntervals.length&&(a._Util.Methods.warn("zoomed out too far: could not find suitable interval to display labels"),b=d._minorIntervals.length-1),b},d.prototype._getTickIntervalValues=function(a){return this._scale._tickInterval(a.timeUnit,a.step)},d.prototype._getTickValues=function(){var a=this.getTickLevel(),b=this._getTickIntervalValues(d._minorIntervals[a]),c=this._getTickIntervalValues(d._majorIntervals[a]);return b.concat(c)},d.prototype._measureTextHeight=function(c){var d=c.append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0),e=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return d.remove(),e},d.prototype.renderTickLabels=function(c,d,e){var f=this; +c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).remove();var g=this._scale._tickInterval(d.timeUnit,d.step);g.splice(0,0,this._scale.domain()[0]),g.push(this._scale.domain()[1]);var h=1===d.step,i=[];h?g.map(function(a,b){b+1>=g.length||i.push(new Date((g[b+1].valueOf()-g[b].valueOf())/2+g[b].valueOf()))}):i=g,i=i.filter(function(a){return f.canFitLabelFilter(c,a,d3.time.format(d.formatString)(a),h)});var j=c.selectAll("."+b.AbstractAxis.TICK_LABEL_CLASS).data(i,function(a){return a.valueOf()}),k=j.enter().append("g").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0);k.append("text");var l=h?0:this.tickLabelPadding(),m="bottom"===this._orientation?this._maxLabelTickLength()/2*e:this.height()-this._maxLabelTickLength()/2*e+2*this.tickLabelPadding(),n=j.selectAll("text");n.size()>0&&a._Util.DOM.translate(n,l,m),j.exit().remove(),j.attr("transform",function(a){return"translate("+f._scale.scale(a)+",0)"});var o=h?"middle":"start";j.selectAll("text").text(function(a){return d3.time.format(d.formatString)(a)}).style("text-anchor",o)},d.prototype.canFitLabelFilter=function(a,b,c,d){var e,f,g=this.measurer(c).width+this.tickLabelPadding();return d?(e=this._scale.scale(b)+g/2,f=this._scale.scale(b)-g/2):(e=this._scale.scale(b)+g,f=this._scale.scale(b)),e0},d.prototype.adjustTickLength=function(a,c){var d=this._getTickIntervalValues(c),e=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).filter(function(a){return d.map(function(a){return a.valueOf()}).indexOf(a.valueOf())>=0});"top"===this._orientation&&(a=this.height()-a),e.attr("y2",a)},d.prototype.generateLabellessTicks=function(a){if(!(0>a)){var c=this._getTickIntervalValues(d._minorIntervals[a]),e=this._getTickValues().concat(c),f=this._tickMarkContainer.selectAll("."+b.AbstractAxis.TICK_MARK_CLASS).data(e);f.enter().append("line").classed(b.AbstractAxis.TICK_MARK_CLASS,!0),f.attr(this._generateTickMarkAttrHash()),f.exit().remove(),this.adjustTickLength(this.tickLabelPadding(),d._minorIntervals[a])}},d.prototype._doRender=function(){c.prototype._doRender.call(this);var a=this.getTickLevel();this.renderTickLabels(this._minorTickLabels,d._minorIntervals[a],1),this.renderTickLabels(this._majorTickLabels,d._majorIntervals[a],2);var b=this._scale.domain(),e=this._scale.scale(b[1])-this._scale.scale(b[0]);return 1.5*this.getIntervalLength(d._minorIntervals[a])>=e&&this.generateLabellessTicks(a-1),this.adjustTickLength(this._maxLabelTickLength()/2,d._minorIntervals[a]),this.adjustTickLength(this._maxLabelTickLength(),d._majorIntervals[a]),this},d._minorIntervals=[{timeUnit:d3.time.second,step:1,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:5,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:10,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:15,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.second,step:30,formatString:"%I:%M:%S %p"},{timeUnit:d3.time.minute,step:1,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:5,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:10,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:15,formatString:"%I:%M %p"},{timeUnit:d3.time.minute,step:30,formatString:"%I:%M %p"},{timeUnit:d3.time.hour,step:1,formatString:"%I %p"},{timeUnit:d3.time.hour,step:3,formatString:"%I %p"},{timeUnit:d3.time.hour,step:6,formatString:"%I %p"},{timeUnit:d3.time.hour,step:12,formatString:"%I %p"},{timeUnit:d3.time.day,step:1,formatString:"%a %e"},{timeUnit:d3.time.day,step:1,formatString:"%e"},{timeUnit:d3.time.month,step:1,formatString:"%B"},{timeUnit:d3.time.month,step:1,formatString:"%b"},{timeUnit:d3.time.month,step:3,formatString:"%B"},{timeUnit:d3.time.month,step:6,formatString:"%B"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%y"},{timeUnit:d3.time.year,step:5,formatString:"%Y"},{timeUnit:d3.time.year,step:25,formatString:"%Y"},{timeUnit:d3.time.year,step:50,formatString:"%Y"},{timeUnit:d3.time.year,step:100,formatString:"%Y"},{timeUnit:d3.time.year,step:200,formatString:"%Y"},{timeUnit:d3.time.year,step:500,formatString:"%Y"},{timeUnit:d3.time.year,step:1e3,formatString:"%Y"}],d._majorIntervals=[{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.day,step:1,formatString:"%B %e, %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.month,step:1,formatString:"%B %Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1,formatString:"%Y"},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""},{timeUnit:d3.time.year,step:1e5,formatString:""}],d}(b.AbstractAxis);b.Time=c}(a.Axis||(a.Axis={}));a.Axis}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=a.Formatters.general()),c.call(this,b,d,e),this.tickLabelPositioning="center",this.showFirstTickLabel=!1,this.showLastTickLabel=!1}return __extends(d,c),d.prototype._setup=function(){c.prototype._setup.call(this),this.measurer=a._Util.Text.getTextMeasurer(this._tickLabelContainer.append("text").classed(b.AbstractAxis.TICK_LABEL_CLASS,!0))},d.prototype._computeWidth=function(){var b=this,c=this._getTickValues(),d=c.map(function(a){var c=b._formatter(a);return b.measurer(c).width}),e=a._Util.Methods.max(d,0);return this._computedWidth="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+e:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+e),this._computedWidth},d.prototype._computeHeight=function(){var b=this.measurer(a._Util.Text.HEIGHT_TEXT).height;return this._computedHeight="center"===this.tickLabelPositioning?this._maxLabelTickLength()+this.tickLabelPadding()+b:Math.max(this._maxLabelTickLength(),this.tickLabelPadding()+b),this._computedHeight},d.prototype._getTickValues=function(){return this._scale.ticks()},d.prototype._rescale=function(){if(this._isSetup){if(!this._isHorizontal()){var a=this._computeWidth();if(a>this.width()||aa,wantsHeight:e>b}},c.prototype._setup=function(){b.prototype._setup.call(this),this.textContainer=this._content.append("g"),this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),this.text(this._text)},c.prototype.text=function(a){return void 0===a?this._text:(this._text=a,this._invalidateLayout(),this)},c.prototype.orient=function(a){if(null==a)return this.orientation;if(a=a.toLowerCase(),"horizontal"!==a&&"left"!==a&&"right"!==a)throw new Error(a+" is not a valid orientation for LabelComponent");return this.orientation=a,this._invalidateLayout(),this},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.textContainer.text("");var c="horizontal"===this.orientation?this.width():this.height(),d=a._Util.Text.getTruncatedText(this._text,c,this.measurer);"horizontal"===this.orientation?a._Util.Text.writeLineHorizontally(d,this.textContainer,this.width(),this.height(),this.xAlignment,this.yAlignment):a._Util.Text.writeLineVertically(d,this.textContainer,this.width(),this.height(),this.xAlignment,this.yAlignment,this.orientation)},c.prototype._computeLayout=function(c,d,e,f){return this.measurer=a._Util.Text.getTextMeasurer(this.textContainer.append("text")),b.prototype._computeLayout.call(this,c,d,e,f),this},c}(b.AbstractComponent);b.Label=c;var d=function(a){function b(b,c){a.call(this,b,c),this.classed("title-label",!0)}return __extends(b,a),b}(c);b.TitleLabel=d;var e=function(a){function b(b,c){a.call(this,b,c),this.classed("axis-label",!0)}return __extends(b,a),b}(c);b.AxisLabel=e}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){b.call(this),this.classed("legend",!0),this.scale(a),this.xAlign("RIGHT").yAlign("TOP"),this.xOffset(5).yOffset(5),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this)},c.prototype.toggleCallback=function(a){return void 0!==a?(this._toggleCallback=a,this.isOff=d3.set(),this.updateListeners(),this.updateClasses(),this):this._toggleCallback},c.prototype.hoverCallback=function(a){return void 0!==a?(this._hoverCallback=a,this.datumCurrentlyFocusedOn=void 0,this.updateListeners(),this.updateClasses(),this):this._hoverCallback},c.prototype.scale=function(a){var b=this;return null!=a?(null!=this.colorScale&&this.colorScale.broadcaster.deregisterListener(this),this.colorScale=a,this.colorScale.broadcaster.registerListener(this,function(){return b.updateDomain()}),this.updateDomain(),this):this.colorScale},c.prototype.updateDomain=function(){null!=this._toggleCallback&&(this.isOff=a._Util.Methods.intersection(this.isOff,d3.set(this.scale().domain()))),null!=this._hoverCallback&&(this.datumCurrentlyFocusedOn=this.scale().domain().indexOf(this.datumCurrentlyFocusedOn)>=0?this.datumCurrentlyFocusedOn:void 0),this._invalidateLayout()},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e);var f=this.measureTextHeight(),g=this.colorScale.domain().length;this.nRowsDrawn=Math.min(g,Math.floor(this.height()/f))},c.prototype._requestedSpace=function(b,d){var e=this.measureTextHeight(),f=this.colorScale.domain().length,g=Math.min(f,Math.floor((d-2*c.MARGIN)/e)),h=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),i=a._Util.Text.getTextMeasurer(h.append("text")),j=a._Util.Methods.max(this.colorScale.domain(),function(a){return i(a).width},0);h.remove(),j=void 0===j?0:j;var k=0===g?0:j+e+2*c.MARGIN,l=0===g?0:f*e+2*c.MARGIN;return{width:k,height:l,wantsWidth:k>b,wantsHeight:l>d}},c.prototype.measureTextHeight=function(){var b=this._content.append("g").classed(c.SUBELEMENT_CLASS,!0),d=a._Util.Text.getTextMeasurer(b.append("text"))(a._Util.Text.HEIGHT_TEXT).height;return 0===d&&(d=1),b.remove(),d},c.prototype._doRender=function(){b.prototype._doRender.call(this);var d=this.colorScale.domain().slice(0,this.nRowsDrawn),e=this.measureTextHeight(),f=this.width()-e-c.MARGIN,g=.3*e,h=this._content.selectAll("."+c.SUBELEMENT_CLASS).data(d,function(a){return a}),i=h.enter().append("g").classed(c.SUBELEMENT_CLASS,!0);i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove(),h.selectAll("circle").attr("cx",e/2).attr("cy",e/2).attr("r",g).attr("fill",this.colorScale._d3Scale),h.selectAll("g.text-container").text("").attr("transform","translate("+e+", 0)").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),e=a._Util.Text.getTruncatedText(b,f,d),g=d(e);a._Util.Text.writeLineHorizontally(e,c,g.width,g.height)}),h.attr("transform",function(a){return"translate("+c.MARGIN+","+(d.indexOf(a)*e+c.MARGIN)+")"}),this.updateClasses(),this.updateListeners()},c.prototype.updateListeners=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);if(null!=this._hoverCallback){var d=function(b){return function(c){a.datumCurrentlyFocusedOn=b?c:void 0,a._hoverCallback(a.datumCurrentlyFocusedOn),a.updateClasses()}};b.on("mouseover",d(!0)),b.on("mouseout",d(!1))}else b.on("mouseover",null),b.on("mouseout",null);null!=this._toggleCallback?b.on("click",function(b){var c=a.isOff.has(b);c?a.isOff.remove(b):a.isOff.add(b),a._toggleCallback(b,c),a.updateClasses()}):b.on("click",null)}},c.prototype.updateClasses=function(){var a=this;if(this._isSetup){var b=this._content.selectAll("."+c.SUBELEMENT_CLASS);null!=this._hoverCallback?(b.classed("focus",function(b){return a.datumCurrentlyFocusedOn===b}),b.classed("hover",void 0!==this.datumCurrentlyFocusedOn)):(b.classed("hover",!1),b.classed("focus",!1)),null!=this._toggleCallback?(b.classed("toggled-on",function(b){return!a.isOff.has(b)}),b.classed("toggled-off",function(b){return a.isOff.has(b)})):(b.classed("toggled-on",!1),b.classed("toggled-off",!1))}},c.SUBELEMENT_CLASS="legend-row",c.MARGIN=5,c}(b.AbstractComponent);b.Legend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;b.call(this),this.padding=5,this.classed("legend",!0),this.scale=a,this.scale.broadcaster.registerListener(this,function(){return c._invalidateLayout()}),this.xAlign("left").yAlign("center"),this._fixedWidthFlag=!0,this._fixedHeightFlag=!0}return __extends(c,b),c.prototype.remove=function(){b.prototype.remove.call(this),this.scale.broadcaster.deregisterListener(this)},c.prototype.calculateLayoutInfo=function(b,d){var e=this,f=this._content.append("g").classed(c.LEGEND_ROW_CLASS,!0),g=(f.append("g").classed(c.LEGEND_ENTRY_CLASS,!0),a._Util.Text.getTextMeasurer(f.append("text"))),h=g(a._Util.Text.HEIGHT_TEXT).height,i=Math.max(0,b-this.padding),j=function(a){var b=h+g(a).width+e.padding;return Math.min(b,i)},k=this.scale.domain(),l=a._Util.Methods.populateMap(k,j);f.remove();var m=this.packRows(i,k,l),n=Math.floor((d-2*this.padding)/h);return n!==n&&(n=0),{textHeight:h,entryLengths:l,rows:m,numRowsToDraw:Math.max(Math.min(n,m.length),0)}},c.prototype._requestedSpace=function(b,c){var d=this.calculateLayoutInfo(b,c),e=d.rows.map(function(a){return d3.sum(a,function(a){return d.entryLengths.get(a)})}),f=a._Util.Methods.max(e,0);f=void 0===f?0:f;var g=this.padding+f,h=d.numRowsToDraw*d.textHeight+2*this.padding,i=d.rows.length*d.textHeight+2*this.padding;return{width:g,height:h,wantsWidth:g>b,wantsHeight:i>c}},c.prototype.packRows=function(a,b,c){var d=[[]],e=d[0],f=a;return b.forEach(function(b){var g=c.get(b);g>f&&(e=[],d.push(e),f=a),e.push(b),f-=g}),d},c.prototype._doRender=function(){var d=this;b.prototype._doRender.call(this);var e=this.calculateLayoutInfo(this.width(),this.height()),f=e.rows.slice(0,e.numRowsToDraw),g=this._content.selectAll("g."+c.LEGEND_ROW_CLASS).data(f);g.enter().append("g").classed(c.LEGEND_ROW_CLASS,!0),g.exit().remove(),g.attr("transform",function(a,b){return"translate(0, "+(b*e.textHeight+d.padding)+")"});var h=g.selectAll("g."+c.LEGEND_ENTRY_CLASS).data(function(a){return a}),i=h.enter().append("g").classed(c.LEGEND_ENTRY_CLASS,!0);i.append("circle"),i.append("g").classed("text-container",!0),h.exit().remove();var j=this.padding;g.each(function(){var a=j,b=d3.select(this).selectAll("g."+c.LEGEND_ENTRY_CLASS);b.attr("transform",function(b){var c="translate("+a+", 0)";return a+=e.entryLengths.get(b),c})}),h.select("circle").attr("cx",e.textHeight/2).attr("cy",e.textHeight/2).attr("r",.3*e.textHeight).attr("fill",function(a){return d.scale.scale(a)});var k=this.padding,l=h.select("g.text-container");l.text(""),l.append("title").text(function(a){return a}),l.attr("transform","translate("+e.textHeight+", "+.1*e.textHeight+")").each(function(b){var c=d3.select(this),d=a._Util.Text.getTextMeasurer(c.append("text")),f=e.entryLengths.get(b)-e.textHeight-k,g=a._Util.Text.getTruncatedText(b,f,d),h=d(g);a._Util.Text.writeLineHorizontally(g,c,h.width,h.height)})},c.LEGEND_ROW_CLASS="legend-row",c.LEGEND_ENTRY_CLASS="legend-entry",c}(b.AbstractComponent);b.HorizontalLegend=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;if(null!=c&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(c))throw new Error("xScale needs to inherit from Scale.AbstractQuantitative");if(null!=d&&!a.Scale.AbstractQuantitative.prototype.isPrototypeOf(d))throw new Error("yScale needs to inherit from Scale.AbstractQuantitative");b.call(this),this.classed("gridlines",!0),this.xScale=c,this.yScale=d,this.xScale&&this.xScale.broadcaster.registerListener(this,function(){return e._render()}),this.yScale&&this.yScale.broadcaster.registerListener(this,function(){return e._render()})}return __extends(c,b),c.prototype.remove=function(){return b.prototype.remove.call(this),this.xScale&&this.xScale.broadcaster.deregisterListener(this),this.yScale&&this.yScale.broadcaster.deregisterListener(this),this},c.prototype._setup=function(){b.prototype._setup.call(this),this.xLinesContainer=this._content.append("g").classed("x-gridlines",!0),this.yLinesContainer=this._content.append("g").classed("y-gridlines",!0)},c.prototype._doRender=function(){b.prototype._doRender.call(this),this.redrawXLines(),this.redrawYLines()},c.prototype.redrawXLines=function(){var a=this;if(this.xScale){var b=this.xScale.ticks(),c=function(b){return a.xScale.scale(b)},d=this.xLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",c).attr("y1",0).attr("x2",c).attr("y2",this.height()).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c.prototype.redrawYLines=function(){var a=this;if(this.yScale){var b=this.yScale.ticks(),c=function(b){return a.yScale.scale(b)},d=this.yLinesContainer.selectAll("line").data(b);d.enter().append("line"),d.attr("x1",0).attr("y1",c).attr("x2",this.width()).attr("y2",c).classed("zeroline",function(a){return 0===a}),d.exit().remove()}},c}(b.AbstractComponent);b.Gridlines=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a){var c=this;void 0===a&&(a=[]),b.call(this),this.rowPadding=0,this.colPadding=0,this.rows=[],this.rowWeights=[],this.colWeights=[],this.nRows=0,this.nCols=0,this.classed("table",!0),a.forEach(function(a,b){a.forEach(function(a,d){c.addComponent(b,d,a)})})}return __extends(c,b),c.prototype.addComponent=function(a,b,c){if(this._addComponent(c)){this.nRows=Math.max(a+1,this.nRows),this.nCols=Math.max(b+1,this.nCols),this.padTableToSize(this.nRows,this.nCols);var d=this.rows[a][b];if(d)throw new Error("Table.addComponent cannot be called on a cell where a component already exists (for the moment)");this.rows[a][b]=c}return this},c.prototype._removeComponent=function(a){b.prototype._removeComponent.call(this,a);var c,d;a:for(var e=0;e0&&v&&e!==x,C=f>0&&w&&f!==y;if(!B&&!C)break;if(r>5)break}return e=h-d3.sum(u.guaranteedWidths),f=i-d3.sum(u.guaranteedHeights),n=c.calcProportionalSpace(k,e),o=c.calcProportionalSpace(j,f),{colProportionalSpace:n,rowProportionalSpace:o,guaranteedWidths:u.guaranteedWidths,guaranteedHeights:u.guaranteedHeights,wantsWidth:v,wantsHeight:w}},c.prototype.determineGuarantees=function(b,c){var d=a._Util.Methods.createFilledArray(0,this.nCols),e=a._Util.Methods.createFilledArray(0,this.nRows),f=a._Util.Methods.createFilledArray(!1,this.nCols),g=a._Util.Methods.createFilledArray(!1,this.nRows);return this.rows.forEach(function(a,h){a.forEach(function(a,i){var j;j=null!=a?a._requestedSpace(b[i],c[h]):{width:0,height:0,wantsWidth:!1,wantsHeight:!1};var k=Math.min(j.width,b[i]),l=Math.min(j.height,c[h]);d[i]=Math.max(d[i],k),e[h]=Math.max(e[h],l),f[i]=f[i]||j.wantsWidth,g[h]=g[h]||j.wantsHeight})}),{guaranteedWidths:d,guaranteedHeights:e,wantsWidthArr:f,wantsHeightArr:g}},c.prototype._requestedSpace=function(a,b){var c=this.iterateLayout(a,b);return{width:d3.sum(c.guaranteedWidths),height:d3.sum(c.guaranteedHeights),wantsWidth:c.wantsWidth,wantsHeight:c.wantsHeight}},c.prototype._computeLayout=function(c,d,e,f){var g=this;b.prototype._computeLayout.call(this,c,d,e,f);var h=this.iterateLayout(this.width(),this.height()),i=a._Util.Methods.addArrays(h.rowProportionalSpace,h.guaranteedHeights),j=a._Util.Methods.addArrays(h.colProportionalSpace,h.guaranteedWidths),k=0;this.rows.forEach(function(a,b){var c=0;a.forEach(function(a,d){null!=a&&a._computeLayout(c,k,j[d],i[b]),c+=j[d]+g.colPadding}),k+=i[b]+g.rowPadding})},c.prototype.padding=function(a,b){return this.rowPadding=a,this.colPadding=b,this._invalidateLayout(),this},c.prototype.rowWeight=function(a,b){return this.rowWeights[a]=b,this._invalidateLayout(),this},c.prototype.colWeight=function(a,b){return this.colWeights[a]=b,this._invalidateLayout(),this},c.prototype._isFixedWidth=function(){var a=d3.transpose(this.rows);return c.fixedSpace(a,function(a){return null==a||a._isFixedWidth()})},c.prototype._isFixedHeight=function(){return c.fixedSpace(this.rows,function(a){return null==a||a._isFixedHeight()})},c.prototype.padTableToSize=function(a,b){for(var c=0;a>c;c++){void 0===this.rows[c]&&(this.rows[c]=[],this.rowWeights[c]=null);for(var d=0;b>d;d++)void 0===this.rows[c][d]&&(this.rows[c][d]=null)}for(d=0;b>d;d++)void 0===this.colWeights[d]&&(this.colWeights[d]=null)},c.calcComponentWeights=function(a,b,c){return a.map(function(a,d){if(null!=a)return a;var e=b[d].map(c),f=e.reduce(function(a,b){return a&&b},!0);return f?0:1})},c.calcProportionalSpace=function(b,c){var d=d3.sum(b);return 0===d?a._Util.Methods.createFilledArray(0,b.length):b.map(function(a){return c*a/d})},c.fixedSpace=function(a,b){var c=function(a){return a.reduce(function(a,b){return a&&b},!0)},d=function(a){return c(a.map(b))};return c(a.map(d))},c}(b.AbstractComponentContainer);b.Table=c}(a.Component||(a.Component={}));a.Component}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this._dataChanged=!1,this._projectors={},this._animate=!1,this._animators={},this._ANIMATION_DURATION=250,this._animateOnNextRender=!0,this.clipPathEnabled=!0,this.classed("plot",!0),this._key2DatasetDrawerKey=d3.map(),this._datasetKeysInOrder=[],this.nextSeriesIndex=0}return __extends(c,b),c.prototype._anchor=function(a){b.prototype._anchor.call(this,a),this._animateOnNextRender=!0,this._dataChanged=!0,this._updateScaleExtents()},c.prototype._setup=function(){var a=this;b.prototype._setup.call(this),this._renderArea=this._content.append("g").classed("render-area",!0),this._getDrawersInOrder().forEach(function(b){return b.setup(a._renderArea.append("g")) +})},c.prototype.remove=function(){var a=this;b.prototype.remove.call(this),this._datasetKeysInOrder.forEach(function(b){return a.removeDataset(b)});var c=Object.keys(this._projectors);c.forEach(function(b){var c=a._projectors[b];c.scale&&c.scale.broadcaster.deregisterListener(a)})},c.prototype.addDataset=function(b,c){if("string"!=typeof b&&void 0!==c)throw new Error("invalid input to addDataset");"string"==typeof b&&"_"===b[0]&&a._Util.Methods.warn("Warning: Using _named series keys may produce collisions with unlabeled data sources");var d="string"==typeof b?b:"_"+this.nextSeriesIndex++,e="string"!=typeof b?b:c,c=e instanceof a.Dataset?e:new a.Dataset(e);return this._addDataset(d,c),this},c.prototype._addDataset=function(a,b){var c=this;this._key2DatasetDrawerKey.has(a)&&this.removeDataset(a);var d=this._getDrawer(a),e={drawer:d,dataset:b,key:a};this._datasetKeysInOrder.push(a),this._key2DatasetDrawerKey.set(a,e),this._isSetup&&d.setup(this._renderArea.append("g")),b.broadcaster.registerListener(this,function(){return c._onDatasetUpdate()}),this._onDatasetUpdate()},c.prototype._getDrawer=function(b){return new a._Drawer.AbstractDrawer(b)},c.prototype._getAnimator=function(b){return this._animate&&this._animateOnNextRender?this._animators[b]||new a.Animator.Null:new a.Animator.Null},c.prototype._onDatasetUpdate=function(){this._updateScaleExtents(),this._animateOnNextRender=!0,this._dataChanged=!0,this._render()},c.prototype.attr=function(a,b,c){return this.project(a,b,c)},c.prototype.project=function(b,c,d){var e=this;b=b.toLowerCase();var f=this._projectors[b],g=f&&f.scale;g&&this._datasetKeysInOrder.forEach(function(a){g._removeExtent(e._plottableID.toString()+"_"+a,b),g.broadcaster.deregisterListener(e)}),d&&d.broadcaster.registerListener(this,function(){return e._render()});var h=a._Util.Methods._applyAccessor(c,this);return this._projectors[b]={accessor:h,scale:d,attribute:b},this._updateScaleExtent(b),this._render(),this},c.prototype._generateAttrToProjector=function(){var a=this,b={};return d3.keys(this._projectors).forEach(function(c){var d=a._projectors[c],e=d.accessor,f=d.scale,g=f?function(a,b){return f.scale(e(a,b))}:e;b[c]=g}),b},c.prototype._doRender=function(){this._isAnchored&&(this.paint(),this._dataChanged=!1,this._animateOnNextRender=!1)},c.prototype.animate=function(a){return this._animate=a,this},c.prototype.detach=function(){return b.prototype.detach.call(this),this._updateScaleExtents(),this},c.prototype._updateScaleExtents=function(){var a=this;d3.keys(this._projectors).forEach(function(b){return a._updateScaleExtent(b)})},c.prototype._updateScaleExtent=function(a){var b=this,c=this._projectors[a];c.scale&&this._key2DatasetDrawerKey.forEach(function(d,e){var f=e.dataset._getExtent(c.accessor,c.scale._typeCoercer),g=b._plottableID.toString()+"_"+d;0!==f.length&&b._isAnchored?c.scale._updateExtent(g,a,f):c.scale._removeExtent(g,a)})},c.prototype.animator=function(a,b){return void 0===b?this._animators[a]:(this._animators[a]=b,this)},c.prototype.datasetOrder=function(b){function c(b,c){var d=a._Util.Methods.intersection(d3.set(b),d3.set(c)),e=d.size();return e===b.length&&e===c.length}return void 0===b?this._datasetKeysInOrder:(c(b,this._datasetKeysInOrder)?(this._datasetKeysInOrder=b,this._onDatasetUpdate()):a._Util.Methods.warn("Attempted to change datasetOrder, but new order is not permutation of old. Ignoring."),this)},c.prototype.removeDataset=function(b){var c;if("string"==typeof b)c=b;else if(b instanceof a.Dataset||b instanceof Array){var d=b instanceof a.Dataset?this.datasets():this.datasets().map(function(a){return a.data()}),e=d.indexOf(b);-1!==e&&(c=this._datasetKeysInOrder[e])}return this._removeDataset(c)},c.prototype._removeDataset=function(a){if(null!=a&&this._key2DatasetDrawerKey.has(a)){var b=this._key2DatasetDrawerKey.get(a);b.drawer.remove();var c=d3.values(this._projectors),d=this._plottableID.toString()+"_"+a;c.forEach(function(a){null!=a.scale&&a.scale._removeExtent(d,a.attribute)}),b.dataset.broadcaster.deregisterListener(this),this._datasetKeysInOrder.splice(this._datasetKeysInOrder.indexOf(a),1),this._key2DatasetDrawerKey.remove(a),this._onDatasetUpdate()}return this},c.prototype.datasets=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).dataset})},c.prototype._getDrawersInOrder=function(){var a=this;return this._datasetKeysInOrder.map(function(b){return a._key2DatasetDrawerKey.get(b).drawer})},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:new a.Animator.Null}]},c.prototype._additionalPaint=function(){},c.prototype._getDataToDraw=function(){var a=this,b=d3.map();return this._datasetKeysInOrder.forEach(function(c){b.set(c,a._key2DatasetDrawerKey.get(c).dataset.data())}),b},c.prototype.paint=function(){var b=this._generateDrawSteps(),c=this._getDataToDraw(),d=this._getDrawersInOrder(),e=this._datasetKeysInOrder.map(function(a,e){return d[e].draw(c.get(a),b)}),f=a._Util.Methods.max(e,0);this._additionalPaint(f)},c}(a.Component.AbstractComponent);b.AbstractPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.classed("pie-plot",!0)}return __extends(c,b),c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._renderArea.attr("transform","translate("+this.width()/2+","+this.height()/2+")")},c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Pie plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);a["inner-radius"]=a["inner-radius"]||d3.functor(0),a["outer-radius"]=a["outer-radius"]||d3.functor(Math.min(this.width(),this.height())/2),null==a.fill&&(a.fill=function(a,b){return c.DEFAULT_COLOR_SCALE.scale(String(b))});var d=function(a){return a.value},e=this._projectors.value;return a.value=e?e.accessor:d,a},c.prototype._getDrawer=function(b){return new a._Drawer.Arc(b).setClass("arc")},c.DEFAULT_COLOR_SCALE=new a.Scale.Color,c}(b.AbstractPlot);b.Pie=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(a,c){if(b.call(this),this._autoAdjustXScaleDomain=!1,this._autoAdjustYScaleDomain=!1,null==a||null==c)throw new Error("XYPlots require an xScale and yScale");this.classed("xy-plot",!0),this.project("x","x",a),this.project("y","y",c)}return __extends(c,b),c.prototype.project=function(a,c,d){var e=this;return"x"===a&&d&&(this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._xScale=d,this._updateXDomainer(),d.broadcaster.registerListener("yDomainAdjustment"+this._plottableID,function(){return e.adjustYDomainOnChangeFromX()})),"y"===a&&d&&(this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this._yScale=d,this._updateYDomainer(),d.broadcaster.registerListener("xDomainAdjustment"+this._plottableID,function(){return e.adjustXDomainOnChangeFromY()})),b.prototype.project.call(this,a,c,d),this},c.prototype.remove=function(){return b.prototype.remove.call(this),this._xScale&&this._xScale.broadcaster.deregisterListener("yDomainAdjustment"+this._plottableID),this._yScale&&this._yScale.broadcaster.deregisterListener("xDomainAdjustment"+this._plottableID),this},c.prototype.automaticallyAdjustYScaleOverVisiblePoints=function(a){return this._autoAdjustYScaleDomain=a,this.adjustYDomainOnChangeFromX(),this},c.prototype.automaticallyAdjustXScaleOverVisiblePoints=function(a){return this._autoAdjustXScaleDomain=a,this.adjustXDomainOnChangeFromY(),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=a.x,d=a.y;return a.defined=function(a,b){var e=c(a,b),f=d(a,b);return null!=e&&e===e&&null!=f&&f===f},a},c.prototype._computeLayout=function(a,c,d,e){b.prototype._computeLayout.call(this,a,c,d,e),this._xScale.range([0,this.width()]),this._yScale.range([this.height(),0])},c.prototype._updateXDomainer=function(){if(this._xScale instanceof a.Scale.AbstractQuantitative){var b=this._xScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype._updateYDomainer=function(){if(this._yScale instanceof a.Scale.AbstractQuantitative){var b=this._yScale;b._userSetDomainer||b.domainer().pad().nice()}},c.prototype.showAllData=function(){this._xScale.autoDomain(),this._autoAdjustYScaleDomain||this._yScale.autoDomain()},c.prototype.adjustYDomainOnChangeFromX=function(){this._autoAdjustYScaleDomain&&this.adjustDomainToVisiblePoints(this._xScale,this._yScale,!0)},c.prototype.adjustXDomainOnChangeFromY=function(){this._autoAdjustXScaleDomain&&this.adjustDomainToVisiblePoints(this._yScale,this._xScale,!1)},c.prototype.adjustDomainToVisiblePoints=function(b,c,d){if(c instanceof a.Scale.AbstractQuantitative){var e=c,f=this.normalizeDatasets(d),g=this.adjustDomainOverVisiblePoints(f,b.domain());if(0===g.length)return;g=e.domainer().computeDomain([g],e),e.domain(g)}},c.prototype.normalizeDatasets=function(b){var c=a._Util.Methods.flatten(this.datasets().map(function(a){return a.data()})),d=this._projectors[b?"x":"y"].accessor,e=this._projectors[b?"y":"x"].accessor;return c.map(function(a,b){return{a:d(a,b),b:e(a,b)}})},c.prototype.adjustDomainOverVisiblePoints=function(b,c){var d=b.filter(function(a){return c[0]<=a.a&&a.a<=c[1]}).map(function(a){return a.b}),e=[];return 0!==d.length&&(e=[a._Util.Methods.min(d,null),a._Util.Methods.max(d,null)]),e},c}(b.AbstractPlot);b.AbstractXYPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.closeDetectionRadius=5,this.classed("scatter-plot",!0),this.project("r",3),this.project("opacity",.6),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._animators["circles-reset"]=new a.Animator.Null,this._animators.circles=(new a.Animator.Base).duration(250).delay(5)}return __extends(c,b),c.prototype.project=function(a,c,d){return a="cx"===a?"x":a,a="cy"===a?"y":a,b.prototype.project.call(this,a,c,d),this},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("circle")},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this);return a.cx=a.x,delete a.x,a.cy=a.y,delete a.y,a},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.r=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("circles-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("circles")}),a},c.prototype._getClosestStruckPoint=function(a,b){var c,d,e=this._getDrawersInOrder(),f=this._generateAttrToProjector(),g=function(b,c){var d=f.cx(b,c)-a.x,e=f.cy(b,c)-a.y;return d*d+e*e},h=!1,i=b*b;if(e.forEach(function(a){a._getDrawSelection().each(function(a,b){var e=g(a,b),j=f.r(a,b);j*j>e?((!h||i>e)&&(c=this,d=b,i=e),h=!0):!h&&i>e&&(c=this,d=b,i=e)})}),!c)return{selection:null,pixelPositions:null,data:null};var j=d3.select(c),k=j.data(),l={x:f.cx(k[0],d),y:f.cy(k[0],d)};return{selection:j,pixelPositions:[l],data:k}},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){},c.prototype._doHover=function(a){return this._getClosestStruckPoint(a,this.closeDetectionRadius)},c}(b.AbstractXYPlot);b.Scatter=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d,e){b.call(this,c,d),this._animators={cells:new a.Animator.Null},this.classed("grid-plot",!0),this._xScale.rangeType("bands",0,0),this._yScale.rangeType("bands",0,0),this._colorScale=e,this.project("fill","value",e),this._animators.cells=new a.Animator.Null}return __extends(c,b),c.prototype._addDataset=function(c,d){return 1===this._datasetKeysInOrder.length?void a._Util.Methods.warn("Only one dataset is supported in Grid plots"):void b.prototype._addDataset.call(this,c,d)},c.prototype._getDrawer=function(b){return new a._Drawer.Element(b).svgElement("rect")},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"fill"===a&&(this._colorScale=this._projectors.fill.scale),this},c.prototype._generateAttrToProjector=function(){var a=b.prototype._generateAttrToProjector.call(this),c=this._xScale.rangeBand(),d=this._yScale.rangeBand();return a.width=function(){return c},a.height=function(){return d},a},c.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("cells")}]},c}(b.AbstractXYPlot);b.Grid=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this._baselineValue=0,this._barAlignmentFactor=.5,this._barLabelFormatter=a.Formatters.identity(),this._barLabelsEnabled=!1,this._hoverMode="point",this.hideBarsIfAnyAreTooWide=!0,this.classed("bar-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._animators["bars-reset"]=new a.Animator.Null,this._animators.bars=new a.Animator.Base,this._animators.baseline=new a.Animator.Null,this.baseline(this._baselineValue)}return __extends(c,b),c.prototype._getDrawer=function(b){return new a._Drawer.Rect(b,this._isVertical)},c.prototype._setup=function(){b.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},c.prototype.baseline=function(a){return null==a?this._baselineValue:(this._baselineValue=a,this._updateXDomainer(),this._updateYDomainer(),this._render(),this)},c.prototype.barAlignment=function(a){var b=a.toLowerCase(),c=this.constructor._BarAlignmentToFactor;if(void 0===c[b])throw new Error("unsupported bar alignment");return this._barAlignmentFactor=c[b],this._render(),this},c.prototype.parseExtent=function(a){if("number"==typeof a)return{min:a,max:a};if(a instanceof Object&&"min"in a&&"max"in a)return a;throw new Error("input '"+a+"' can't be parsed as an Extent")},c.prototype.barLabelsEnabled=function(a){return void 0===a?this._barLabelsEnabled:(this._barLabelsEnabled=a,this._render(),this)},c.prototype.barLabelFormatter=function(a){return null==a?this._barLabelFormatter:(this._barLabelFormatter=a,this._render(),this)},c.prototype.selectBar=function(a,b,c){if(void 0===c&&(c=!0),!this._isSetup)return null;var d=[],e=this.parseExtent(a),f=this.parseExtent(b),g=.5;if(this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").each(function(){var a=this.getBBox();a.x+a.width>=e.min-g&&a.x<=e.max+g&&a.y+a.height>=f.min-g&&a.y<=f.max+g&&d.push(this)})}),d.length>0){var h=d3.selectAll(d);return h.classed("selected",c),h}return null},c.prototype.deselectAll=function(){return this._isSetup&&this._getDrawersInOrder().forEach(function(a){return a._renderArea.selectAll("rect").classed("selected",!1)}),this},c.prototype._updateDomainer=function(b){if(b instanceof a.Scale.AbstractQuantitative){var c=b;c._userSetDomainer||(null!=this._baselineValue?c.domainer().addPaddingException(this._baselineValue,"BAR_PLOT+"+this._plottableID).addIncludedValue(this._baselineValue,"BAR_PLOT+"+this._plottableID):c.domainer().removePaddingException("BAR_PLOT+"+this._plottableID).removeIncludedValue("BAR_PLOT+"+this._plottableID),c.domainer().pad()),c._autoDomainIfAutomaticMode()}},c.prototype._updateYDomainer=function(){this._isVertical?this._updateDomainer(this._yScale):b.prototype._updateYDomainer.call(this)},c.prototype._updateXDomainer=function(){this._isVertical?b.prototype._updateXDomainer.call(this):this._updateDomainer(this._xScale)},c.prototype._additionalPaint=function(b){var c=this,d=this._isVertical?this._yScale:this._xScale,e=d.scale(this._baselineValue),f={x1:this._isVertical?0:e,y1:this._isVertical?e:0,x2:this._isVertical?this.width():e,y2:this._isVertical?e:this.height()};this._getAnimator("baseline").animate(this._baseline,f);var g=this._getDrawersInOrder();g.forEach(function(a){return a.removeLabels()}),this._barLabelsEnabled&&a._Util.Methods.setTimeout(function(){return c._drawLabels()},b)},c.prototype._drawLabels=function(){var a=this._getDrawersInOrder(),b=this._generateAttrToProjector(),c=this._getDataToDraw();this._datasetKeysInOrder.forEach(function(d,e){return a[e].drawText(c.get(d),b)}),this.hideBarsIfAnyAreTooWide&&a.some(function(a){return a._someLabelsTooWide})&&a.forEach(function(a){return a.removeLabels()})},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged&&this._animate){var b=this._generateAttrToProjector(),c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue),e=this._isVertical?"y":"x",f=this._isVertical?"height":"width";b[e]=function(){return d},b[f]=function(){return 0},a.push({attrToProjector:b,animator:this._getAnimator("bars-reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("bars")}),a},c.prototype._generateAttrToProjector=function(){var c=this,d=b.prototype._generateAttrToProjector.call(this),e=this._isVertical?this._yScale:this._xScale,f=this._isVertical?this._xScale:this._yScale,g=this._isVertical?"y":"x",h=this._isVertical?"x":"y",i=e.scale(this._baselineValue);d.width||(d.width=function(){return c._getBarPixelWidth()});var j=d[h],k=d.width,l=f instanceof a.Scale.Ordinal&&"bands"===f.rangeType();if(l){var m=f.rangeBand();d[h]=function(a,b){return j(a,b)-k(a,b)/2+m/2}}else d[h]=function(a,b){return j(a,b)-k(a,b)*c._barAlignmentFactor};var n=d[g];d[g]=function(a,b){var c=n(a,b);return c>i?i:c},d.height=function(a,b){return Math.abs(i-n(a,b))};var o=this._projectors[g].accessor;return this.barLabelsEnabled&&this.barLabelFormatter&&(d.label=function(a,b){return c._barLabelFormatter(o(a,b))},d.positive=function(a,b){return n(a,b)<=i}),d},c.prototype._getBarPixelWidth=function(){var b,c=this._isVertical?this._xScale:this._yScale;if(c instanceof a.Scale.Ordinal){var d=c;if("bands"===d.rangeType())b=d.rangeBand();else{var e=2*d._outerPadding,f=this._isVertical?this.width():this.height(),g=f/(e+d.domain().length-1);b=g*e*.5}}else{var h=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,i=d3.set(a._Util.Methods.flatten(this.datasets().map(function(a){return a.data().map(function(a,b){return h(a,b)})}))).values();if(i.some(function(a){return"undefined"===a}))return-1;var j=d3.set(a._Util.Methods.flatten(this.datasets().map(function(a){return a.data().map(function(a,b){return h(a,b).valueOf()})}))).values().map(function(a){return+a});j.sort(function(a,b){return a-b});var k=d3.pairs(j),l=this._isVertical?this.width():this.height();b=.95*a._Util.Methods.min(k,function(a){return Math.abs(c.scale(a[1])-c.scale(a[0]))},.4*l)}return b},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode");return this._hoverMode=b,this},c.prototype.clearHoverSelection=function(){this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed("not-hovered hovered",!1)})},c.prototype._hoverOverComponent=function(){},c.prototype._hoverOutComponent=function(){this.clearHoverSelection()},c.prototype._doHover=function(a){var b=this,c=a.x,d=a.y;if("line"===this._hoverMode){var e={min:-1/0,max:1/0};this._isVertical?d=e:c=e}var f=this.selectBar(c,d,!1);if(!f)return this.clearHoverSelection(),{data:null,pixelPositions:null,selection:null};this._getDrawersInOrder().forEach(function(a){a._renderArea.selectAll("rect").classed({hovered:!1,"not-hovered":!0})}),f.classed({hovered:!0,"not-hovered":!1});var g=[],h=this._generateAttrToProjector();return f.each(function(a,c){g.push(b._isVertical?{x:h.x(a,c)+h.width(a,c)/2,y:h.y(a,c)+(h.positive(a,c)?0:h.height(a,c))}:{x:h.x(a,c)+(h.positive(a,c)?0:h.width(a,c)),y:h.y(a,c)+h.height(a,c)/2})}),{data:f.data(),pixelPositions:g,selection:f}},c._BarAlignmentToFactor={},c._DEFAULT_WIDTH=10,c}(b.AbstractXYPlot);b.AbstractBarPlot=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){this._isVertical=!0,a.call(this,b,c)}return __extends(b,a),b.prototype._updateYDomainer=function(){this._updateDomainer(this._yScale)},b._BarAlignmentToFactor={left:0,center:.5,right:1},b}(a.AbstractBarPlot);a.VerticalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){a.call(this,b,c)}return __extends(b,a),b.prototype._updateXDomainer=function(){this._updateDomainer(this._xScale)},b.prototype._generateAttrToProjector=function(){var b=a.prototype._generateAttrToProjector.call(this),c=b.width;return b.width=b.height,b.height=c,b},b._BarAlignmentToFactor={top:0,center:.5,bottom:1},b}(a.AbstractBarPlot);a.HorizontalBar=b}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("line-plot",!0),this.project("stroke",function(){return a.Core.Colors.INDIGO}),this.project("stroke-width",function(){return"2px"}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._rejectNullsAndNaNs=function(a,b,c){var d=c(a,b);return null!=d&&d===d},c.prototype._getDrawer=function(b){return new a._Drawer.Line(b)},c.prototype._getResetYFunction=function(){var a=this._yScale.domain(),b=Math.max(a[0],a[1]),c=Math.min(a[0],a[1]),d=0>b&&b||c>0&&c||0,e=this._yScale.scale(d);return function(){return e}},c.prototype._generateDrawSteps=function(){var a=[];if(this._dataChanged){var b=this._generateAttrToProjector();b.y=this._getResetYFunction(),a.push({attrToProjector:b,animator:this._getAnimator("reset")})}return a.push({attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("main")}),a},c.prototype._generateAttrToProjector=function(){var a=this,c=b.prototype._generateAttrToProjector.call(this),d=this._wholeDatumAttributes(),e=function(a){return-1===d.indexOf(a)},f=d3.keys(c).filter(e);f.forEach(function(a){var b=c[a];c[a]=function(a,c){return a.length>0?b(a[0],c):null}});var g=c.x,h=c.y;return c.defined=function(b,c){return a._rejectNullsAndNaNs(b,c,g)&&a._rejectNullsAndNaNs(b,c,h)},c},c.prototype._wholeDatumAttributes=function(){return["x","y"]},c}(b.AbstractXYPlot);b.Line=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){b.call(this,c,d),this.classed("area-plot",!0),this.project("y0",0,d),this.project("fill",function(){return a.Core.Colors.INDIGO}),this.project("fill-opacity",function(){return.25}),this.project("stroke",function(){return a.Core.Colors.INDIGO}),this._animators.reset=new a.Animator.Null,this._animators.main=(new a.Animator.Base).duration(600).easing("exp-in-out")}return __extends(c,b),c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),null!=this._yScale&&this._updateYDomainer()},c.prototype._getDrawer=function(b){return new a._Drawer.Area(b)},c.prototype._updateYDomainer=function(){var c=this;b.prototype._updateYDomainer.call(this);var d,e=this._projectors.y0,f=e&&e.accessor;if(null!=f){var g=this.datasets().map(function(a){return a._getExtent(f,c._yScale._typeCoercer)}),h=a._Util.Methods.flatten(g),i=a._Util.Methods.uniq(h);1===i.length&&(d=i[0])}this._yScale._userSetDomainer||(null!=d?this._yScale.domainer().addPaddingException(d,"AREA_PLOT+"+this._plottableID):this._yScale.domainer().removePaddingException("AREA_PLOT+"+this._plottableID),this._yScale._autoDomainIfAutomaticMode())},c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),"y0"===a&&this._updateYDomainer(),this},c.prototype._getResetYFunction=function(){return this._generateAttrToProjector().y0},c.prototype._wholeDatumAttributes=function(){var a=b.prototype._wholeDatumAttributes.call(this);return a.push("y0"),a},c}(b.Line);b.Area=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(a,b,d){void 0===d&&(d=!0),this._isVertical=d,c.call(this,a,b)}return __extends(d,c),d.prototype._generateAttrToProjector=function(){var a=c.prototype._generateAttrToProjector.call(this),b=this.makeInnerScale(),d=function(){return b.rangeBand()},e=a.height;a.width=this._isVertical?d:e,a.height=this._isVertical?e:d;var f=function(a){return a._PLOTTABLE_PROTECTED_FIELD_POSITION};return a.x=this._isVertical?f:a.x,a.y=this._isVertical?a.y:f,a},d.prototype._getDataToDraw=function(){var b=this,c=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,d=this.makeInnerScale(),e=d3.map();return this._datasetKeysInOrder.forEach(function(f){var g=b._key2DatasetDrawerKey.get(f).dataset.data();e.set(f,g.map(function(e,g){var h=c(e,g),i=b._isVertical?b._xScale:b._yScale,j=a._Util.Methods.copyMap(e);return j._PLOTTABLE_PROTECTED_FIELD_POSITION=i.scale(h)+d.scale(f),j}))}),e},d.prototype.makeInnerScale=function(){var c=new a.Scale.Ordinal;if(c.domain(this._datasetKeysInOrder),this._projectors.width){var d=this._projectors.width,e=d.accessor,f=d.scale,g=f?function(a,b){return f.scale(e(a,b))}:e;c.range([0,g(null,0)])}else{var h=this._isVertical?this._xScale:this._yScale,i=h instanceof a.Scale.Ordinal&&"bands"===h.rangeType(),j=i?h.rangeBand():b.AbstractBarPlot._DEFAULT_WIDTH;c.range([0,j])}return c},d}(b.AbstractBarPlot);b.ClusteredBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.stackedExtent=[0,0]}return __extends(c,b),c.prototype.project=function(a,c,d){return b.prototype.project.call(this,a,c,d),this._projectors.x&&this._projectors.y&&("x"===a||"y"===a)&&this._updateStackOffsets(),this},c.prototype._onDatasetUpdate=function(){b.prototype._onDatasetUpdate.call(this),this._datasetKeysInOrder&&this._projectors.x&&this._projectors.y&&this._updateStackOffsets()},c.prototype._updateStackOffsets=function(){var b=this._generateDefaultMapArray(),c=this._getDomainKeys(),d=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.max(0,b.get(a).value)}})}),e=b.map(function(b){return a._Util.Methods.populateMap(c,function(a){return{key:a,value:Math.min(b.get(a).value,0)}})});this._setDatasetStackOffsets(this._stack(d),this._stack(e)),this._updateStackExtents()},c.prototype._updateStackExtents=function(){var b=this.datasets(),c=this._valueAccessor(),d=a._Util.Methods.max(b,function(b){return a._Util.Methods.max(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0),e=a._Util.Methods.min(b,function(b){return a._Util.Methods.min(b.data(),function(a){return+c(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET},0)},0);this.stackedExtent=[Math.min(e,0),Math.max(0,d)]},c.prototype._stack=function(a){var b=this,c=function(a,b){a.offset=b};return d3.layout.stack().x(function(a){return a.key}).y(function(a){return+a.value}).values(function(a){return b._getDomainKeys().map(function(b){return a.get(b)})}).out(c)(a),a},c.prototype._setDatasetStackOffsets=function(a,b){var c=this._keyAccessor(),d=this._valueAccessor();this.datasets().forEach(function(e,f){var g=a[f],h=b[f],i=e.data().every(function(a){return d(a)<=0});e.data().forEach(function(a){var b=g.get(c(a)).offset,e=h.get(c(a)).offset,f=d(a);a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET=0===f?i?e:b:f>0?b:e})})},c.prototype._getDomainKeys=function(){var a=this._keyAccessor(),b=d3.set(),c=this.datasets();return c.forEach(function(c){c.data().forEach(function(c){b.add(a(c))})}),b.values()},c.prototype._generateDefaultMapArray=function(){var b=this._keyAccessor(),c=this._valueAccessor(),d=this.datasets(),e=this._getDomainKeys(),f=d.map(function(){return a._Util.Methods.populateMap(e,function(a){return{key:a,value:0}})});return d.forEach(function(a,d){a.data().forEach(function(a){var e=b(a),g=c(a);f[d].set(e,{key:e,value:g})})}),f},c.prototype._updateScaleExtents=function(){b.prototype._updateScaleExtents.call(this);var a=this._isVertical?this._yScale:this._xScale;a&&(this._isAnchored&&this.stackedExtent.length>0?a._updateExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT",this.stackedExtent):a._removeExtent(this._plottableID.toString(),"_PLOTTABLE_PROTECTED_FIELD_STACK_EXTENT"))},c.prototype._keyAccessor=function(){return this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor},c.prototype._valueAccessor=function(){return this._isVertical?this._projectors.y.accessor:this._projectors.x.accessor},c}(b.AbstractXYPlot);b.AbstractStacked=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d){c.call(this,b,d),this._baselineValue=0,this.classed("area-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this._isVertical=!0}return __extends(d,c),d.prototype._getDrawer=function(b){return new a._Drawer.Area(b).drawLine(!1)},d.prototype._setup=function(){c.prototype._setup.call(this),this._baseline=this._renderArea.append("line").classed("baseline",!0)},d.prototype._updateStackOffsets=function(){var b=this._getDomainKeys(),d=this._isVertical?this._projectors.x.accessor:this._projectors.y.accessor,e=this.datasets().map(function(a){return d3.set(a.data().map(function(a,b){return d(a,b).toString()})).values()});e.some(function(a){return a.length!==b.length})&&a._Util.Methods.warn("the domains across the datasets are not the same. Plot may produce unintended behavior."),c.prototype._updateStackOffsets.call(this)},d.prototype._additionalPaint=function(){var a=this._yScale.scale(this._baselineValue),b={x1:0,y1:a,x2:this.width(),y2:a};this._getAnimator("baseline").animate(this._baseline,b)},d.prototype._updateYDomainer=function(){c.prototype._updateYDomainer.call(this); +var a=this._yScale;a._userSetDomainer||(a.domainer().addPaddingException(0,"STACKED_AREA_PLOT+"+this._plottableID),a._autoDomainIfAutomaticMode())},d.prototype._onDatasetUpdate=function(){c.prototype._onDatasetUpdate.call(this),b.Area.prototype._onDatasetUpdate.apply(this)},d.prototype._generateAttrToProjector=function(){var a=this,b=c.prototype._generateAttrToProjector.call(this),d=this._projectors.y.accessor;b.y=function(b){return a._yScale.scale(+d(b)+b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},b.y0=function(b){return a._yScale.scale(b._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)};var e=b.fill;return b.fill=function(a,b){return a&&a[0]?e(a[0],b):null},b},d}(b.AbstractStacked);b.StackedArea=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(c){function d(b,d,e){void 0===e&&(e=!0),this._isVertical=e,this._baselineValue=0,c.call(this,b,d),this.classed("bar-plot",!0),this.project("fill",function(){return a.Core.Colors.INDIGO}),this.baseline(this._baselineValue),this._isVertical=e}return __extends(d,c),d.prototype._getAnimator=function(b){if(this._animate&&this._animateOnNextRender){if(this._animators[b])return this._animators[b];if("stacked-bar"===b){var c=this._isVertical?this._yScale:this._xScale,d=c.scale(this._baselineValue);return new a.Animator.MovingRect(d,this._isVertical)}}return new a.Animator.Null},d.prototype._generateAttrToProjector=function(){var a=this,c=b.AbstractBarPlot.prototype._generateAttrToProjector.apply(this),d=this._isVertical?"y":"x",e=this._isVertical?this._yScale:this._xScale,f=this._projectors[d].accessor,g=function(a){return e.scale(a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},h=function(a){return e.scale(+f(a)+a._PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET)},i=function(a){return Math.abs(h(a)-g(a))},j=c.width;c.height=this._isVertical?i:j,c.width=this._isVertical?j:i;var k=function(a){return+f(a)<0?g(a):h(a)};return c[d]=function(b){return a._isVertical?k(b):k(b)-i(b)},c},d.prototype._generateDrawSteps=function(){return[{attrToProjector:this._generateAttrToProjector(),animator:this._getAnimator("stacked-bar")}]},d.prototype.project=function(a,d,e){return c.prototype.project.call(this,a,d,e),b.AbstractStacked.prototype.project.apply(this,[a,d,e]),this},d.prototype._onDatasetUpdate=function(){return c.prototype._onDatasetUpdate.call(this),b.AbstractStacked.prototype._onDatasetUpdate.apply(this),this},d.prototype._updateStackOffsets=function(){b.AbstractStacked.prototype._updateStackOffsets.call(this)},d.prototype._updateStackExtents=function(){b.AbstractStacked.prototype._updateStackExtents.call(this)},d.prototype._stack=function(a){return b.AbstractStacked.prototype._stack.call(this,a)},d.prototype._setDatasetStackOffsets=function(a,c){b.AbstractStacked.prototype._setDatasetStackOffsets.call(this,a,c)},d.prototype._getDomainKeys=function(){return b.AbstractStacked.prototype._getDomainKeys.call(this)},d.prototype._generateDefaultMapArray=function(){return b.AbstractStacked.prototype._generateDefaultMapArray.call(this)},d.prototype._updateScaleExtents=function(){b.AbstractStacked.prototype._updateScaleExtents.call(this)},d.prototype._keyAccessor=function(){return b.AbstractStacked.prototype._keyAccessor.call(this)},d.prototype._valueAccessor=function(){return b.AbstractStacked.prototype._valueAccessor.call(this)},d.prototype._getBarPixelWidth=function(){return b.AbstractBarPlot.prototype._getBarPixelWidth.apply(this)},d}(b.AbstractBarPlot);b.StackedBar=c}(a.Plot||(a.Plot={}));a.Plot}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){}return a.prototype.getTiming=function(){return 0},a.prototype.animate=function(a,b){return a.attr(b)},a}();a.Null=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var Plottable;!function(a){!function(a){var b=function(){function a(){this._duration=a.DEFAULT_DURATION_MILLISECONDS,this._delay=a.DEFAULT_DELAY_MILLISECONDS,this._easing=a.DEFAULT_EASING,this._maxIterativeDelay=a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS,this._maxTotalDuration=a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS}return a.prototype.getTiming=function(a){var b=Math.max(this.maxTotalDuration()-this.duration(),0),c=Math.min(this.maxIterativeDelay(),b/Math.max(a-1,1)),d=c*a+this.delay()+this.duration();return d},a.prototype.animate=function(a,b){var c=this,d=a[0].length,e=Math.max(this.maxTotalDuration()-this.duration(),0),f=Math.min(this.maxIterativeDelay(),e/Math.max(d-1,1));return a.transition().ease(this.easing()).duration(this.duration()).delay(function(a,b){return c.delay()+f*b}).attr(b)},a.prototype.duration=function(a){return null==a?this._duration:(this._duration=a,this)},a.prototype.delay=function(a){return null==a?this._delay:(this._delay=a,this)},a.prototype.easing=function(a){return null==a?this._easing:(this._easing=a,this)},a.prototype.maxIterativeDelay=function(a){return null==a?this._maxIterativeDelay:(this._maxIterativeDelay=a,this)},a.prototype.maxTotalDuration=function(a){return null==a?this._maxTotalDuration:(this._maxTotalDuration=a,this)},a.DEFAULT_DURATION_MILLISECONDS=300,a.DEFAULT_DELAY_MILLISECONDS=0,a.DEFAULT_MAX_ITERATIVE_DELAY_MILLISECONDS=15,a.DEFAULT_MAX_TOTAL_DURATION_MILLISECONDS=600,a.DEFAULT_EASING="exp-out",a}();a.Base=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),a.call(this),this.isVertical=b,this.isReverse=c}return __extends(b,a),b.prototype.animate=function(c,d){var e={};return b.ANIMATED_ATTRIBUTES.forEach(function(a){return e[a]=d[a]}),e[this.getMovingAttr()]=this._startMovingProjector(d),e[this.getGrowingAttr()]=function(){return 0},c.attr(e),a.prototype.animate.call(this,c,d)},b.prototype._startMovingProjector=function(a){if(this.isVertical===this.isReverse)return a[this.getMovingAttr()];var b=a[this.getMovingAttr()],c=a[this.getGrowingAttr()];return function(a,d){return b(a,d)+c(a,d)}},b.prototype.getGrowingAttr=function(){return this.isVertical?"height":"width"},b.prototype.getMovingAttr=function(){return this.isVertical?"y":"x"},b.ANIMATED_ATTRIBUTES=["height","width","x","y","fill"],b}(a.Base);a.Rect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b,c){void 0===c&&(c=!0),a.call(this,c),this.startPixelValue=b}return __extends(b,a),b.prototype._startMovingProjector=function(){return d3.functor(this.startPixelValue)},b}(a.Rect);a.MovingRect=b}(a.Animator||(a.Animator={}));a.Animator}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(b){a.call(this),this._event2Callback={},this.connected=!1,this._target=b}return __extends(b,a),b.prototype.target=function(a){if(null==a)return this._target;var b=this.connected;return this.disconnect(),this._target=a,b&&this.connect(),this},b.prototype._getEventString=function(a){return a+".dispatcher"+this._plottableID},b.prototype.connect=function(){var a=this;if(this.connected)throw new Error("Can't connect dispatcher twice!");return this._target&&(this.connected=!0,Object.keys(this._event2Callback).forEach(function(b){var c=a._event2Callback[b];a._target.on(a._getEventString(b),c)})),this},b.prototype.disconnect=function(){var a=this;return this.connected=!1,this._target&&Object.keys(this._event2Callback).forEach(function(b){a._target.on(a._getEventString(b),null)}),this},b}(a.Core.PlottableObject);b.AbstractDispatcher=c}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this._event2Callback.mouseover=function(){null!=c._mouseover&&c._mouseover(c.getMousePosition())},this._event2Callback.mousemove=function(){null!=c._mousemove&&c._mousemove(c.getMousePosition())},this._event2Callback.mouseout=function(){null!=c._mouseout&&c._mouseout(c.getMousePosition())}}return __extends(b,a),b.prototype.getMousePosition=function(){var a=d3.mouse(this._target.node());return{x:a[0],y:a[1]}},b.prototype.mouseover=function(a){return void 0===a?this._mouseover:(this._mouseover=a,this)},b.prototype.mousemove=function(a){return void 0===a?this._mousemove:(this._mousemove=a,this)},b.prototype.mouseout=function(a){return void 0===a?this._mouseout:(this._mouseout=a,this)},b}(a.AbstractDispatcher);a.Mouse=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(b){var c=this;a.call(this,b),this.mousedOverTarget=!1,this.keydownListenerTarget=d3.select(document),this._event2Callback.mouseover=function(){c.mousedOverTarget=!0},this._event2Callback.mouseout=function(){c.mousedOverTarget=!1}}return __extends(b,a),b.prototype.connect=function(){var b=this;return a.prototype.connect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),function(){b.mousedOverTarget&&b._onKeyDown&&b._onKeyDown(d3.event)}),this},b.prototype.disconnect=function(){return a.prototype.disconnect.call(this),this.keydownListenerTarget.on(this._getEventString("keydown"),null),this},b.prototype.onKeyDown=function(a){return void 0===a?this._onKeyDown:(this._onKeyDown=a,this)},b}(a.AbstractDispatcher);a.Keypress=b}(a.Dispatcher||(a.Dispatcher={}));a.Dispatcher}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(a,b){this._componentToListenTo=a,this._hitBox=b},b}(a.Core.PlottableObject);b.AbstractInteraction=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._anchor=function(b,c){var d=this;a.prototype._anchor.call(this,b,c),c.on(this._listenTo(),function(){var a=d3.mouse(c.node()),b=a[0],e=a[1];d._callback({x:b,y:e})})},b.prototype._listenTo=function(){return"click"},b.prototype.callback=function(a){return this._callback=a,this},b}(a.AbstractInteraction);a.Click=b;var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._listenTo=function(){return"dblclick"},b}(b);a.DoubleClick=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.call(this),this.activated=!1,this.keyCode2Callback={},this.dispatcher=new a.Dispatcher.Keypress}return __extends(c,b),c.prototype._anchor=function(a,c){var d=this;b.prototype._anchor.call(this,a,c),this.dispatcher.target(this._hitBox),this.dispatcher.onKeyDown(function(a){d.keyCode2Callback[a.keyCode]&&d.keyCode2Callback[a.keyCode]()}),this.dispatcher.connect()},c.prototype.on=function(a,b){return this.keyCode2Callback[a]=b,this},c}(b.AbstractInteraction);b.Key=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(c,d){var e=this;b.call(this),null==c&&(c=new a.Scale.Linear),null==d&&(d=new a.Scale.Linear),this._xScale=c,this._yScale=d,this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return e.rerenderZoomed()})}return __extends(c,b),c.prototype.resetZoom=function(){var a=this;this.zoom=d3.behavior.zoom(),this.zoom.x(this._xScale._d3Scale),this.zoom.y(this._yScale._d3Scale),this.zoom.on("zoom",function(){return a.rerenderZoomed()}),this.zoom(this._hitBox)},c.prototype._anchor=function(a,c){b.prototype._anchor.call(this,a,c),this.zoom(c)},c.prototype.rerenderZoomed=function(){var a=this._xScale._d3Scale.domain(),b=this._yScale._d3Scale.domain();this._xScale.domain(a),this._yScale.domain(b)},c}(b.AbstractInteraction);b.PanZoom=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentBar=null,this._hoverMode="point"}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),a._Util.Methods.warn("Interaction.BarHover is deprecated; please use Interaction.Hover instead"),this.plotIsVertical=this._componentToListenTo._isVertical,this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mousemove(function(a){var b=e.getHoveredBar(a);if(null==b)e._hoverOut();else{if(null!=e.currentBar){if(e.currentBar.node()===b.node())return;e._hoverOut()}e.getBars().classed("not-hovered",!0).classed("hovered",!1),b.classed("not-hovered",!1).classed("hovered",!0),null!=e.hoverCallback&&e.hoverCallback(b.data()[0],b)}e.currentBar=b}),this.dispatcher.mouseout(function(){return e._hoverOut()}),this.dispatcher.connect()},c.prototype.getBars=function(){return this._componentToListenTo._renderArea.selectAll("rect")},c.prototype._hoverOut=function(){this.getBars().classed("not-hovered hovered",!1),null!=this.unhoverCallback&&null!=this.currentBar&&this.unhoverCallback(this.currentBar.data()[0],this.currentBar),this.currentBar=null},c.prototype.getHoveredBar=function(a){if("point"===this._hoverMode)return this._componentToListenTo.selectBar(a.x,a.y,!1);var b={min:-1/0,max:1/0};return this.plotIsVertical?this._componentToListenTo.selectBar(a.x,b,!1):this._componentToListenTo.selectBar(b,a.y,!1)},c.prototype.hoverMode=function(a){if(null==a)return this._hoverMode;var b=a.toLowerCase();if("point"!==b&&"line"!==b)throw new Error(a+" is not a valid hover mode for Interaction.BarHover");return this._hoverMode=b,this},c.prototype.onHover=function(a){return this.hoverCallback=a,this},c.prototype.onUnhover=function(a){return this.unhoverCallback=a,this},c}(b.AbstractInteraction);b.BarHover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){var b=this;a.call(this),this.dragInitialized=!1,this._origin=[0,0],this._location=[0,0],this.dragBehavior=d3.behavior.drag(),this.dragBehavior.on("dragstart",function(){return b._dragstart()}),this.dragBehavior.on("drag",function(){return b._drag()}),this.dragBehavior.on("dragend",function(){return b._dragend()})}return __extends(b,a),b.prototype.dragstart=function(a){return void 0===a?this.ondragstart:(this.ondragstart=a,this)},b.prototype.drag=function(a){return void 0===a?this.ondrag:(this.ondrag=a,this)},b.prototype.dragend=function(a){return void 0===a?this.ondragend:(this.ondragend=a,this)},b.prototype._dragstart=function(){var a=this._componentToListenTo.width(),b=this._componentToListenTo.height(),c=function(a,b){return function(c){return Math.min(Math.max(c,a),b)}};this.constrainX=c(0,a),this.constrainY=c(0,b)},b.prototype._doDragstart=function(){null!=this.ondragstart&&this.ondragstart({x:this._origin[0],y:this._origin[1]})},b.prototype._drag=function(){this.dragInitialized||(this._origin=[d3.event.x,d3.event.y],this.dragInitialized=!0,this._doDragstart()),this._location=[this.constrainX(d3.event.x),this.constrainY(d3.event.y)],this._doDrag()},b.prototype._doDrag=function(){if(null!=this.ondrag){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondrag(a,b)}},b.prototype._dragend=function(){this.dragInitialized&&(this.dragInitialized=!1,this._doDragend())},b.prototype._doDragend=function(){if(null!=this.ondragend){var a={x:this._origin[0],y:this._origin[1]},b={x:this._location[0],y:this._location[1]};this.ondragend(a,b)}},b.prototype._anchor=function(b,c){return a.prototype._anchor.call(this,b,c),c.call(this.dragBehavior),this},b.prototype.setupZoomCallback=function(a,b){function c(c,g){return null==c||null==g?(f&&(null!=a&&a.domain(d),null!=b&&b.domain(e)),void(f=!f)):(f=!1,null!=a&&a.domain([a.invert(c.x),a.invert(g.x)]),null!=b&&b.domain([b.invert(g.y),b.invert(c.y)]),void this.clearBox())}var d=null!=a?a.domain():null,e=null!=b?b.domain():null,f=!1;return this.drag(c),this.dragend(c),this},b}(a.AbstractInteraction);a.Drag=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.boxIsDrawn=!1}return __extends(b,a),b.prototype._dragstart=function(){a.prototype._dragstart.call(this),this.clearBox()},b.prototype.clearBox=function(){return null!=this.dragBox?(this.dragBox.attr("height",0).attr("width",0),this.boxIsDrawn=!1,this):void 0},b.prototype.setBox=function(a,b,c,d){if(null!=this.dragBox){var e=Math.abs(a-b),f=Math.abs(c-d),g=Math.min(a,b),h=Math.min(c,d);return this.dragBox.attr({x:g,y:h,width:e,height:f}),this.boxIsDrawn=e>0&&f>0,this}},b.prototype._anchor=function(c,d){a.prototype._anchor.call(this,c,d);var e=b.CLASS_DRAG_BOX,f=this._componentToListenTo._backgroundContainer;return this.dragBox=f.append("rect").classed(e,!0).attr("x",0).attr("y",0),this},b.CLASS_DRAG_BOX="drag-box",b}(a.Drag);a.DragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,b,c,0,this._componentToListenTo.height()),this},b}(a.DragBox);a.XDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[0],this._location[0],this._origin[1],this._location[1])},b}(a.DragBox);a.XYDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b.prototype._drag=function(){a.prototype._drag.call(this),this.setBox(this._origin[1],this._location[1])},b.prototype.setBox=function(b,c){return a.prototype.setBox.call(this,0,this._componentToListenTo.width(),b,c),this},b}(a.DragBox);a.YDragBox=b}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Plottable;!function(a){!function(b){var c=function(b){function c(){b.apply(this,arguments),this.currentHoverData={data:null,pixelPositions:null,selection:null}}return __extends(c,b),c.prototype._anchor=function(c,d){var e=this;b.prototype._anchor.call(this,c,d),this.dispatcher=new a.Dispatcher.Mouse(this._hitBox),this.dispatcher.mouseover(function(a){e._componentToListenTo._hoverOverComponent(a),e.handleHoverOver(a)}),this.dispatcher.mouseout(function(a){e._componentToListenTo._hoverOutComponent(a),e.safeHoverOut(e.currentHoverData),e.currentHoverData={data:null,pixelPositions:null,selection:null}}),this.dispatcher.mousemove(function(a){return e.handleHoverOver(a)}),this.dispatcher.connect()},c.diffHoverData=function(a,b){if(null==a.data||null==b.data)return a;var c=[],d=[],e=[];return a.data.forEach(function(f,g){-1===b.data.indexOf(f)&&(c.push(f),d.push(a.pixelPositions[g]),e.push(a.selection[0][g]))}),0===c.length?{data:null,pixelPositions:null,selection:null}:{data:c,pixelPositions:d,selection:d3.selectAll(e)}},c.prototype.handleHoverOver=function(a){var b=this.currentHoverData,d=this._componentToListenTo._doHover(a);this.currentHoverData=d;var e=c.diffHoverData(b,d);this.safeHoverOut(e);var f=c.diffHoverData(d,b);this.safeHoverOver(f)},c.prototype.safeHoverOut=function(a){this.hoverOutCallback&&a.data&&this.hoverOutCallback(a)},c.prototype.safeHoverOver=function(a){this.hoverOverCallback&&a.data&&this.hoverOverCallback(a)},c.prototype.onHoverOver=function(a){return this.hoverOverCallback=a,this},c.prototype.onHoverOut=function(a){return this.hoverOutCallback=a,this},c.prototype.getCurrentHoverData=function(){return this.currentHoverData},c}(b.AbstractInteraction);b.Hover=c}(a.Interaction||(a.Interaction={}));a.Interaction}(Plottable||(Plottable={})); \ No newline at end of file diff --git a/plottable.zip b/plottable.zip index f29041a5f2..ab142477ce 100644 Binary files a/plottable.zip and b/plottable.zip differ diff --git a/quicktests/html/domain_adjustment_algorithm.html b/quicktests/html/domain_adjustment_algorithm.html new file mode 100644 index 0000000000..026d580512 --- /dev/null +++ b/quicktests/html/domain_adjustment_algorithm.html @@ -0,0 +1,32 @@ + + + + Y Scale domain adjustment algorithm + + + + + + + + + + + +
+ + + diff --git a/quicktests/html/linear_scale_bar.html b/quicktests/html/linear_scale_bar.html new file mode 100644 index 0000000000..af20130ec3 --- /dev/null +++ b/quicktests/html/linear_scale_bar.html @@ -0,0 +1,32 @@ + + + + Linear Scale Bar + + + + + + + + + + + +
+ + + diff --git a/quicktests/html/ordinal_scale_points_bar.html b/quicktests/html/ordinal_scale_points_bar.html new file mode 100644 index 0000000000..3be58db342 --- /dev/null +++ b/quicktests/html/ordinal_scale_points_bar.html @@ -0,0 +1,32 @@ + + + + Linear Scale Bar + + + + + + + + + + + +
+ + + diff --git a/quicktests/js/clustered_bar.js b/quicktests/js/clustered_bar.js index 5c1071e7f6..2b19eab8c5 100644 --- a/quicktests/js/clustered_bar.js +++ b/quicktests/js/clustered_bar.js @@ -26,7 +26,7 @@ function run(div, data, Plottable) { .attr("fill", "type", colorScale) .attr("type", "type") .attr("yval", "y") - .barLabels(true); + .barLabelsEnabled(true); var center = clusteredBarRenderer.merge(new Plottable.Component.Legend(colorScale)); diff --git a/quicktests/js/domain_adjustment_algorithm.js b/quicktests/js/domain_adjustment_algorithm.js new file mode 100644 index 0000000000..53904b3ca5 --- /dev/null +++ b/quicktests/js/domain_adjustment_algorithm.js @@ -0,0 +1,36 @@ + +function makeData() { + "use strict"; + + return makeRandomData(50); +} + +function run(div, data, Plottable) { + "use strict"; + + var svg = div.append("svg").attr("height", 500); + var ds = new Plottable.Dataset(data); + + var xScale = new Plottable.Scale.Linear(); + var yScale = new Plottable.Scale.Linear(); + var xAxis = new Plottable.Axis.Numeric(xScale, "bottom"); + var yAxis = new Plottable.Axis.Numeric(yScale, "left"); + var linePlot = new Plottable.Plot.Line(xScale, yScale).automaticallyAdjustYScaleOverVisiblePoints(true).addDataset(ds); + + var focusXLabel = new Plottable.Component.Label("focus X"); + + var basicTable = new Plottable.Component.Table([ + [yAxis, linePlot], + [focusXLabel, xAxis] + ]); + + basicTable.renderTo(svg); + + function xFocus(){ + xScale.domain([0.25, 0.5]); + } + + focusXLabel.registerInteraction( + new Plottable.Interaction.Click().callback(xFocus) + ); +} diff --git a/quicktests/js/interaction_hover_scatter.js b/quicktests/js/interaction_hover_scatter.js index 4a850f4f23..c4045f6a53 100644 --- a/quicktests/js/interaction_hover_scatter.js +++ b/quicktests/js/interaction_hover_scatter.js @@ -32,15 +32,29 @@ function run(div, data, Plottable) { chart.renderTo(svg); + var hoverCircle = plot._foregroundContainer.append("circle") + .attr({ + "stroke": "black", + "fill": "none", + "r": 15 + }) + .style("visibility", "hidden"); + var hover = new Plottable.Interaction.Hover(); hover.onHoverOver(function(hoverData) { var color = hoverData.data[0].color.toUpperCase(); var xString = hoverData.data[0].x.toFixed(2); var yString = hoverData.data[0].y.toFixed(2); title.text(color + ": [ " + xString + ", " + yString + " ]"); + + hoverCircle.attr({ + "cx": hoverData.pixelPositions[0].x, + "cy": hoverData.pixelPositions[0].y + }).style("visibility", "visible"); }); hover.onHoverOut(function(hoverData) { title.text("Hover over points"); + hoverCircle.style("visibility", "hidden"); }); plot.registerInteraction(hover); } diff --git a/quicktests/js/key_interaction.js b/quicktests/js/key_interaction.js index 61839a9b16..72edb80e7b 100644 --- a/quicktests/js/key_interaction.js +++ b/quicktests/js/key_interaction.js @@ -26,8 +26,9 @@ function run(div, data, Plottable) { var pzi = new Plottable.Interaction.PanZoom(xScale, yScale); scatterPlot.registerInteraction(pzi); - var ki = new Plottable.Interaction.Key(65); - ki.callback(function() { + var ki = new Plottable.Interaction.Key(); + // press "a" (keycode 65) to reset + ki.on(65, function() { xScale.autoDomain(); yScale.autoDomain(); pzi.resetZoom(); diff --git a/quicktests/js/linear_scale_bar.js b/quicktests/js/linear_scale_bar.js new file mode 100644 index 0000000000..29bf2a7b78 --- /dev/null +++ b/quicktests/js/linear_scale_bar.js @@ -0,0 +1,31 @@ +function makeData() { + "use strict"; + + var data = [{name: 1, y: 1, type: "q1"}, {name: 2, y: 2, type: "q1"}, {name: 4, y: 1, type: "q1"}]; + return data; +} + +function run(div, data, Plottable) { + "use strict"; + + var svg = div.append("svg").attr("height", 500); + var xScale = new Plottable.Scale.Linear(); + var yScale = new Plottable.Scale.Linear(); + var colorScale = new Plottable.Scale.Color("10"); + + var xAxis = new Plottable.Axis.Numeric(xScale, "bottom"); + var yAxis = new Plottable.Axis.Numeric(yScale, "left"); + var clusteredBarRenderer = new Plottable.Plot.VerticalBar(xScale, yScale) + .addDataset("d1", data) + .attr("x", "name", xScale) + .attr("y", "y", yScale) + .attr("fill", "type", colorScale) + .attr("type", "type") + .attr("yval", "y"); + + var center = clusteredBarRenderer.merge(new Plottable.Component.Legend(colorScale)); + + new Plottable.Component.Table([ + [yAxis, center], [null, xAxis] + ]).renderTo(svg); +} diff --git a/quicktests/js/ordinal_scale_points_bar.js b/quicktests/js/ordinal_scale_points_bar.js new file mode 100644 index 0000000000..d3a95044a7 --- /dev/null +++ b/quicktests/js/ordinal_scale_points_bar.js @@ -0,0 +1,31 @@ +function makeData() { + "use strict"; + + var data = [{name: "1", y: 1, type: "q1"}, {name: "2", y: 2, type: "q1"}, {name: "4", y: 1, type: "q1"}]; + return data; +} + +function run(div, data, Plottable) { + "use strict"; + + var svg = div.append("svg").attr("height", 500); + var xScale = new Plottable.Scale.Ordinal().rangeType("points"); + var yScale = new Plottable.Scale.Linear(); + var colorScale = new Plottable.Scale.Color("10"); + + var xAxis = new Plottable.Axis.Category(xScale, "bottom"); + var yAxis = new Plottable.Axis.Numeric(yScale, "left"); + var clusteredBarRenderer = new Plottable.Plot.VerticalBar(xScale, yScale) + .addDataset("d1", data) + .attr("x", "name", xScale) + .attr("y", "y", yScale) + .attr("fill", "type", colorScale) + .attr("type", "type") + .attr("yval", "y"); + + var center = clusteredBarRenderer.merge(new Plottable.Component.Legend(colorScale)); + + new Plottable.Component.Table([ + [yAxis, center], [null, xAxis] + ]).renderTo(svg); +} diff --git a/quicktests/js/stacked_bar.js b/quicktests/js/stacked_bar.js index ab437faaaa..c2a80c5718 100644 --- a/quicktests/js/stacked_bar.js +++ b/quicktests/js/stacked_bar.js @@ -27,7 +27,7 @@ function run(div, data, Plottable) { .addDataset("d2", data[1]) .addDataset("d3", data[2]) .animate(true) - .barLabels(true); + .barLabelsEnabled(true); var center = stackedBarPlot.merge(new Plottable.Component.Legend(colorScale)); diff --git a/quicktests/js/stocks.js b/quicktests/js/stocks.js index 7e27658a95..73633fa016 100644 --- a/quicktests/js/stocks.js +++ b/quicktests/js/stocks.js @@ -102,9 +102,14 @@ function run(div, data, Plottable) { var svg = div.append("svg").attr("height", 480); table.renderTo(svg); - plotArea.registerInteraction(new Plottable.Interaction.PanZoom(xScale, null)); + var pzi = new Plottable.Interaction.PanZoom(xScale, null); + plotArea.registerInteraction(pzi); plotArea.registerInteraction( - new Plottable.Interaction.Key(65).callback(function() { xScale.autoDomain(); }) + new Plottable.Interaction.Key() + .on(65, function() { + xScale.autoDomain(); + pzi.resetZoom(); + }) ); }); diff --git a/quicktests/list_of_quicktests.json b/quicktests/list_of_quicktests.json index 3ab6fa1256..0f5784695e 100644 --- a/quicktests/list_of_quicktests.json +++ b/quicktests/list_of_quicktests.json @@ -252,7 +252,14 @@ { "name":"stocks", "categories":["Integration", "Vertical Bar Plot", "Legend", "Layout", "PanZoom Interaction", "Key Interaction"] - }, { + }, + + { + "name":"domain_adjustment_algorithm", + "categories":["Linear Scale", "Numeric Axis", "Line Plot", "Adjustment", "Layout"] + }, + + { "name":"tick_generator", "categories":["Linear Scale", "Tick Generation", "Line Plot"] } diff --git a/src/components/abstractComponent.ts b/src/components/abstractComponent.ts index 1115ec184e..453bd988b3 100644 --- a/src/components/abstractComponent.ts +++ b/src/components/abstractComponent.ts @@ -33,6 +33,7 @@ export module Component { private _yOffset = 0; private cssClasses: string[] = ["component"]; private removed = false; + private _autoResize = AbstractComponent.AUTORESIZE_BY_DEFAULT; /** * Attaches the Component as a child of a given a DOM element. Usually only directly invoked on root-level Components. @@ -91,7 +92,7 @@ export module Component { this.interactionsToRegister.forEach((r) => this.registerInteraction(r)); this.interactionsToRegister = null; if (this.isTopLevelComponent) { - this.autoResize(AbstractComponent.AUTORESIZE_BY_DEFAULT); + this.autoResize(this._autoResize); } this._isSetup = true; } @@ -244,6 +245,7 @@ export module Component { } else { Core.ResizeBroadcaster.deregister(this); } + this._autoResize = flag; // if _setup were called by constructor, this var could be removed #591 return this; } diff --git a/src/components/axes/numericAxis.ts b/src/components/axes/numericAxis.ts index f3aba24208..2f48d0e08a 100644 --- a/src/components/axes/numericAxis.ts +++ b/src/components/axes/numericAxis.ts @@ -20,9 +20,9 @@ export module Axis { * @constructor * @param {QuantitativeScale} scale The QuantitativeScale to base the axis on. * @param {string} orientation The orientation of the QuantitativeScale (top/bottom/left/right) - * @param {Formatter} formatter A function to format tick labels (default Formatters.general(3, false)). + * @param {Formatter} formatter A function to format tick labels (default Formatters.general()). */ - constructor(scale: Scale.AbstractQuantitative, orientation: string, formatter = Formatters.general(3, false)) { + constructor(scale: Scale.AbstractQuantitative, orientation: string, formatter = Formatters.general()) { super(scale, orientation, formatter); } diff --git a/src/components/axes/timeAxis.ts b/src/components/axes/timeAxis.ts index 2383e4c274..031acdecb5 100644 --- a/src/components/axes/timeAxis.ts +++ b/src/components/axes/timeAxis.ts @@ -93,15 +93,20 @@ export module Axis { * @param {string} orientation The orientation of the Axis (top/bottom) */ constructor(scale: Scale.Time, orientation: string) { - orientation = orientation.toLowerCase(); - if (orientation !== "top" && orientation !== "bottom") { - throw new Error ("unsupported orientation: " + orientation); - } super(scale, orientation); this.classed("time-axis", true); this.tickLabelPadding(5); } + public orient(): string; + public orient(orientation: string): Time; + public orient(orientation?: string): any { + if (orientation && (orientation.toLowerCase() === "right" || orientation.toLowerCase() === "left")) { + throw new Error(orientation + " is not a supported orientation for TimeAxis - only horizontal orientations are supported"); + } + return super.orient(orientation); // maintains getter-setter functionality + } + public _computeHeight() { if (this._computedHeight !== null) { return this._computedHeight; diff --git a/src/components/plots/abstractBarPlot.ts b/src/components/plots/abstractBarPlot.ts index f9077b27a7..360fbdf16d 100644 --- a/src/components/plots/abstractBarPlot.ts +++ b/src/components/plots/abstractBarPlot.ts @@ -4,7 +4,7 @@ module Plottable { export module Plot { export class AbstractBarPlot extends AbstractXYPlot implements Interaction.Hoverable { public static _BarAlignmentToFactor: {[alignment: string]: number} = {}; - private static DEFAULT_WIDTH = 10; + public static _DEFAULT_WIDTH = 10; public _baseline: D3.Selection; public _baselineValue = 0; public _barAlignmentFactor = 0.5; @@ -40,6 +40,14 @@ export module Plot { this._baseline = this._renderArea.append("line").classed("baseline", true); } + /** + * Gets the baseline value for the bars + * + * The baseline is the line that the bars are drawn from, defaulting to 0. + * + * @returns {number} The baseline value. + */ + public baseline(): number; /** * Sets the baseline for the bars to the specified value. * @@ -48,7 +56,11 @@ export module Plot { * @param {number} value The value to position the baseline at. * @returns {AbstractBarPlot} The calling AbstractBarPlot. */ - public baseline(value: number) { + public baseline(value: number): AbstractBarPlot; + public baseline(value?: number): any { + if (value == null) { + return this._baselineValue; + } this._baselineValue = value; this._updateXDomainer(); this._updateYDomainer(); @@ -285,16 +297,15 @@ export module Plot { var secondaryScale: Scale.AbstractScale = this._isVertical ? this._xScale : this._yScale; var primaryAttr = this._isVertical ? "y" : "x"; var secondaryAttr = this._isVertical ? "x" : "y"; - var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) - && ( secondaryScale).rangeType() === "bands"; var scaledBaseline = primaryScale.scale(this._baselineValue); if (!attrToProjector["width"]) { - var constantWidth = bandsMode ? ( secondaryScale).rangeBand() : AbstractBarPlot.DEFAULT_WIDTH; - attrToProjector["width"] = (d: any, i: number) => constantWidth; + attrToProjector["width"] = () => this._getBarPixelWidth(); } var positionF = attrToProjector[secondaryAttr]; var widthF = attrToProjector["width"]; + var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) + && ( secondaryScale).rangeType() === "bands"; if (!bandsMode) { attrToProjector[secondaryAttr] = (d: any, i: number) => positionF(d, i) - widthF(d, i) * this._barAlignmentFactor; } else { @@ -314,6 +325,7 @@ export module Plot { attrToProjector["height"] = (d: any, i: number) => { return Math.abs(scaledBaseline - originalPositionFn(d, i)); }; + var primaryAccessor = this._projectors[primaryAttr].accessor; if (this.barLabelsEnabled && this.barLabelFormatter) { attrToProjector["label"] = (d: any, i: number) => { @@ -325,6 +337,57 @@ export module Plot { } /** + * Computes the barPixelWidth of all the bars in the plot. + * + * If the position scale of the plot is an OrdinalScale and in bands mode, then the rangeBands function will be used. + * If the position scale of the plot is an OrdinalScale and in points mode, then + * from https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints, the max barPixelWidth is step * padding + * If the position scale of the plot is a QuantitativeScale, then _getMinimumDataWidth is scaled to compute the barPixelWidth + */ + public _getBarPixelWidth(): number { + var barPixelWidth: number; + var barScale: Scale.AbstractScale = this._isVertical ? this._xScale : this._yScale; + if (barScale instanceof Plottable.Scale.Ordinal) { + var ordScale = barScale; + if (ordScale.rangeType() === "bands") { + barPixelWidth = ordScale.rangeBand(); + } else { + // padding is defined as 2 * the ordinal scale's _outerPadding variable + // HACKHACK need to use _outerPadding for formula as above + var padding = ( ordScale)._outerPadding * 2; + + // step is defined as the range_interval / (padding + number of bars) + var secondaryDimension = this._isVertical ? this.width() : this.height(); + var step = secondaryDimension / (padding + ordScale.domain().length - 1); + + barPixelWidth = step * padding * 0.5; + } + } else { + var barAccessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; + + var barAccessorData = d3.set(_Util.Methods.flatten(this.datasets().map((dataset) => { + return dataset.data().map((d, i) => barAccessor(d, i)); + }))).values(); + + if (barAccessorData.some((datum) => datum === "undefined")) { return -1; } + + var numberBarAccessorData = d3.set(_Util.Methods.flatten(this.datasets().map((dataset) => { + return dataset.data().map((d, i) => barAccessor(d, i).valueOf()); + }))).values().map((value) => +value); + + numberBarAccessorData.sort((a, b) => a - b); + + var barAccessorDataPairs = d3.pairs(numberBarAccessorData); + var barWidthDimension = this._isVertical ? this.width() : this.height(); + + barPixelWidth = _Util.Methods.min(barAccessorDataPairs, (pair: any[], i: number) => { + return Math.abs(barScale.scale(pair[1]) - barScale.scale(pair[0])); + }, barWidthDimension * 0.4) * 0.95; + } + return barPixelWidth; + } + + /* * Gets the current hover mode. * * @return {string} The current hover mode. @@ -388,9 +451,32 @@ export module Plot { selectedBars.classed({ "hovered": true, "not-hovered": false }); } else { this.clearHoverSelection(); + return { + data: null, + pixelPositions: null, + selection: null + }; } + + var points: Point[] = []; + var projectors = this._generateAttrToProjector(); + selectedBars.each((d, i) => { + if (this._isVertical) { + points.push({ + x: projectors["x"](d, i) + projectors["width"](d, i)/2, + y: projectors["y"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["height"](d, i)) + }); + } else { + points.push({ + x: projectors["x"](d, i) + (projectors["positive"](d, i) ? 0 : projectors["width"](d, i)), + y: projectors["y"](d, i) + projectors["height"](d, i)/2 + }); + } + }); + return { - data: selectedBars ? selectedBars.data() : null, + data: selectedBars.data(), + pixelPositions: points, selection: selectedBars }; } diff --git a/src/components/plots/abstractStackedPlot.ts b/src/components/plots/abstractStackedPlot.ts index 62fe3f714c..881cbdd8ff 100644 --- a/src/components/plots/abstractStackedPlot.ts +++ b/src/components/plots/abstractStackedPlot.ts @@ -71,11 +71,6 @@ export module Plot { * the stack offsets and use the the function declared in .out to set the offsets on the data. */ public _stack(dataArray: D3.Map[]): D3.Map[] { - // HACKHACK d3's stack layout logic crashes on 0-length dataArray https://github.com/mbostock/d3/issues/2004 - if (dataArray.length === 0) { - return dataArray; - } - var outFunction = (d: StackedDatum, y0: number, y: number) => { d.offset = y0; }; diff --git a/src/components/plots/abstractXYPlot.ts b/src/components/plots/abstractXYPlot.ts index a091d505df..2eea031392 100644 --- a/src/components/plots/abstractXYPlot.ts +++ b/src/components/plots/abstractXYPlot.ts @@ -5,6 +5,9 @@ export module Plot { export class AbstractXYPlot extends AbstractPlot { public _xScale: Scale.AbstractScale; public _yScale: Scale.AbstractScale; + public _autoAdjustXScaleDomain = false; + public _autoAdjustYScaleDomain = false; + /** * Constructs an XYPlot. * @@ -35,13 +38,21 @@ export module Plot { // We only want padding and nice-ing on scales that will correspond to axes / pixel layout. // So when we get an "x" or "y" scale, enable autoNiceing and autoPadding. if (attrToSet === "x" && scale) { + if (this._xScale) { + this._xScale.broadcaster.deregisterListener("yDomainAdjustment" + this._plottableID); + } this._xScale = scale; this._updateXDomainer(); + scale.broadcaster.registerListener("yDomainAdjustment" + this._plottableID, () => this.adjustYDomainOnChangeFromX()); } if (attrToSet === "y" && scale) { + if (this._yScale) { + this._yScale.broadcaster.deregisterListener("xDomainAdjustment" + this._plottableID); + } this._yScale = scale; this._updateYDomainer(); + scale.broadcaster.registerListener("xDomainAdjustment" + this._plottableID, () => this.adjustXDomainOnChangeFromY()); } super.project(attrToSet, accessor, scale); @@ -49,6 +60,58 @@ export module Plot { return this; } + public remove() { + super.remove(); + if (this._xScale) { + this._xScale.broadcaster.deregisterListener("yDomainAdjustment" + this._plottableID); + } + if (this._yScale) { + this._yScale.broadcaster.deregisterListener("xDomainAdjustment" + this._plottableID); + } + return this; + } + + /** + * Sets the automatic domain adjustment over visible points for y scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for y scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + public automaticallyAdjustYScaleOverVisiblePoints(autoAdjustment: boolean): AbstractXYPlot { + this._autoAdjustYScaleDomain = autoAdjustment; + this.adjustYDomainOnChangeFromX(); + return this; + } + + /** + * Sets the automatic domain adjustment over visible points for x scale. + * + * If autoAdjustment is true adjustment is immediately performend. + * + * @param {boolean} autoAdjustment The new value for the automatic adjustment domain for x scale. + * @returns {AbstractXYPlot} The calling AbstractXYPlot. + */ + public automaticallyAdjustXScaleOverVisiblePoints(autoAdjustment: boolean): AbstractXYPlot { + this._autoAdjustXScaleDomain = autoAdjustment; + this.adjustXDomainOnChangeFromY(); + return this; + } + + public _generateAttrToProjector(): AttributeToProjector { + var attrToProjector: AttributeToProjector = super._generateAttrToProjector(); + var positionXFn = attrToProjector["x"]; + var positionYFn = attrToProjector["y"]; + attrToProjector["defined"] = (d: any, i: number) => { + var positionX = positionXFn(d, i); + var positionY = positionYFn(d, i); + return positionX != null && positionX === positionX && + positionY != null && positionY === positionY; + }; + return attrToProjector; + } + public _computeLayout(xOffset?: number, yOffset?: number, availableWidth?: number, availableHeight?: number) { super._computeLayout(xOffset, yOffset, availableWidth, availableHeight); this._xScale.range([0, this.width()]); @@ -72,6 +135,60 @@ export module Plot { } } } + + /** + * Adjusts both domains' extents to show all datasets. + * + * This call does not override auto domain adjustment behavior over visible points. + */ + public showAllData() { + this._xScale.autoDomain(); + if(!this._autoAdjustYScaleDomain) { + this._yScale.autoDomain(); + } + } + + private adjustYDomainOnChangeFromX() { + if(this._autoAdjustYScaleDomain) { + this.adjustDomainToVisiblePoints(this._xScale, this._yScale, true); + } + } + private adjustXDomainOnChangeFromY() { + if(this._autoAdjustXScaleDomain) { + this.adjustDomainToVisiblePoints(this._yScale, this._xScale, false); + } + } + + private adjustDomainToVisiblePoints(fromScale: Scale.AbstractScale, + toScale: Scale.AbstractScale, + fromX: boolean) { + if (toScale instanceof Scale.AbstractQuantitative) { + var toScaleQ = > toScale; + var normalizedData = this.normalizeDatasets(fromX); + var adjustedDomain = this.adjustDomainOverVisiblePoints(normalizedData, fromScale.domain()); + if(adjustedDomain.length === 0) { + return; + } + adjustedDomain = toScaleQ.domainer().computeDomain([adjustedDomain], toScaleQ); + toScaleQ.domain(adjustedDomain); + } + } + + private normalizeDatasets(fromX: boolean): {a: A; b: B;}[] { + var flattenDatasets = _Util.Methods.flatten(this.datasets().map(d => d.data())); + var aAccessor: (d: any, i: number) => A = this._projectors[fromX ? "x" : "y"].accessor; + var bAccessor: (d: any, i: number) => B = this._projectors[fromX ? "y" : "x"].accessor; + return flattenDatasets.map((d, i) => { return { a: aAccessor(d, i), b: bAccessor(d, i) }; }); + } + + private adjustDomainOverVisiblePoints(values: {a: A; b: B}[], fromDomain: A[]): B[] { + var bVals = values.filter(v => fromDomain[0] <= v.a && v.a <= fromDomain[1]).map(v => v.b); + var retVal: B[] = []; + if (bVals.length !== 0) { + retVal = [_Util.Methods.min(bVals, null), _Util.Methods.max(bVals, null)]; + } + return retVal; + } } } } diff --git a/src/components/plots/clusteredBarPlot.ts b/src/components/plots/clusteredBarPlot.ts index 7598473851..8592706d51 100644 --- a/src/components/plots/clusteredBarPlot.ts +++ b/src/components/plots/clusteredBarPlot.ts @@ -3,7 +3,6 @@ module Plottable { export module Plot { export class ClusteredBar extends AbstractBarPlot { - private innerScale: Scale.Ordinal; /** * Creates a ClusteredBarPlot. @@ -19,16 +18,13 @@ export module Plot { constructor(xScale: Scale.AbstractScale, yScale: Scale.AbstractScale, isVertical = true) { this._isVertical = isVertical; // Has to be set before super() super(xScale, yScale); - this.innerScale = new Scale.Ordinal(); } public _generateAttrToProjector() { var attrToProjector = super._generateAttrToProjector(); // the width is constant, so set the inner scale range to that - var widthF = attrToProjector["width"]; - this.innerScale.range([0, widthF(null, 0)]); - - var innerWidthF = (d: any, i: number) => this.innerScale.rangeBand(); + var innerScale = this.makeInnerScale(); + var innerWidthF = (d: any, i: number) => innerScale.rangeBand(); var heightF = attrToProjector["height"]; attrToProjector["width"] = this._isVertical ? innerWidthF : heightF; attrToProjector["height"] = this._isVertical ? heightF : innerWidthF; @@ -42,7 +38,7 @@ export module Plot { public _getDataToDraw() { var accessor = this._isVertical ? this._projectors["x"].accessor : this._projectors["y"].accessor; - this.innerScale.domain(this._datasetKeysInOrder); + var innerScale = this.makeInnerScale(); var clusters: D3.Map = d3.map(); this._datasetKeysInOrder.forEach((key: string) => { var data = this._key2DatasetDrawerKey.get(key).dataset.data(); @@ -50,12 +46,34 @@ export module Plot { clusters.set(key, data.map((d, i) => { var val = accessor(d, i); var primaryScale: Scale.AbstractScale = this._isVertical ? this._xScale : this._yScale; - d["_PLOTTABLE_PROTECTED_FIELD_POSITION"] = primaryScale.scale(val) + this.innerScale.scale(key); - return d; + // TODO: store position information in metadata. + var copyD = _Util.Methods.copyMap(d); + copyD["_PLOTTABLE_PROTECTED_FIELD_POSITION"] = primaryScale.scale(val) + innerScale.scale(key); + return copyD; })); }); return clusters; } + + private makeInnerScale(){ + var innerScale = new Scale.Ordinal(); + innerScale.domain(this._datasetKeysInOrder); + // TODO: it might be replaced with _getBarPixelWidth call after closing #1180. + if (!this._projectors["width"]) { + var secondaryScale: Scale.AbstractScale = this._isVertical ? this._xScale : this._yScale; + var bandsMode = (secondaryScale instanceof Plottable.Scale.Ordinal) + && ( secondaryScale).rangeType() === "bands"; + var constantWidth = bandsMode ? ( secondaryScale).rangeBand() : AbstractBarPlot._DEFAULT_WIDTH; + innerScale.range([0, constantWidth]); + } else { + var projector = this._projectors["width"]; + var accessor = projector.accessor; + var scale = projector.scale; + var fn = scale ? (d: any, i: number) => scale.scale(accessor(d, i)) : accessor; + innerScale.range([0, fn(null, 0)]); + } + return innerScale; + } } } } diff --git a/src/components/plots/scatterPlot.ts b/src/components/plots/scatterPlot.ts index 30b9b56055..3a6773a96c 100644 --- a/src/components/plots/scatterPlot.ts +++ b/src/components/plots/scatterPlot.ts @@ -61,7 +61,7 @@ export module Plot { return drawSteps; } - public _getClosestStruckPoint(p: Point, range: number) { + public _getClosestStruckPoint(p: Point, range: number): Interaction.HoverData { var drawers = <_Drawer.Element[]> this._getDrawersInOrder(); var attrToProjector = this._generateAttrToProjector(); @@ -73,6 +73,7 @@ export module Plot { var overAPoint = false; var closestElement: Element; + var closestIndex: number; var minDistSq = range * range; drawers.forEach((drawer) => { @@ -83,20 +84,36 @@ export module Plot { if (distSq < r * r) { // cursor is over this point if (!overAPoint || distSq < minDistSq) { closestElement = this; + closestIndex = i; minDistSq = distSq; } overAPoint = true; } else if (!overAPoint && distSq < minDistSq) { closestElement = this; + closestIndex = i; minDistSq = distSq; } }); }); + if (!closestElement) { + return { + selection: null, + pixelPositions: null, + data: null + }; + } + var closestSelection = d3.select(closestElement); + var closestData = closestSelection.data(); + var closestPoint = { + x: attrToProjector["cx"](closestData[0], closestIndex), + y: attrToProjector["cy"](closestData[0], closestIndex) + }; return { - selection: closestElement ? closestSelection : null, - data: closestElement ? closestSelection.data() : null + selection: closestSelection, + pixelPositions: [closestPoint], + data: closestData }; } diff --git a/src/components/plots/stackedBarPlot.ts b/src/components/plots/stackedBarPlot.ts index 4a33bcc98c..d757202cca 100644 --- a/src/components/plots/stackedBarPlot.ts +++ b/src/components/plots/stackedBarPlot.ts @@ -112,6 +112,10 @@ export module Plot { return AbstractStacked.prototype._valueAccessor.call(this); } //===== /Stack logic ===== + + public _getBarPixelWidth() { + return AbstractBarPlot.prototype._getBarPixelWidth.apply(this); + } } } } diff --git a/src/core/config.ts b/src/core/config.ts new file mode 100644 index 0000000000..286967b785 --- /dev/null +++ b/src/core/config.ts @@ -0,0 +1,10 @@ +/// + +module Plottable { + export module Config { + /** + * Specifies if Plottable should show warnings. + */ + export var SHOW_WARNINGS = true; + } +} diff --git a/src/dispatchers/abstractDispatcher.ts b/src/dispatchers/abstractDispatcher.ts index 23e523a286..2cfbab72dd 100644 --- a/src/dispatchers/abstractDispatcher.ts +++ b/src/dispatchers/abstractDispatcher.ts @@ -10,9 +10,10 @@ export module Dispatcher { /** * Constructs a Dispatcher with the specified target. * - * @param {D3.Selection} target The selection to listen for events on. + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. */ - constructor(target: D3.Selection) { + constructor(target?: D3.Selection) { super(); this._target = target; } @@ -47,7 +48,7 @@ export module Dispatcher { /** * Gets a namespaced version of the event name. */ - private getEventString(eventName: string) { + public _getEventString(eventName: string) { return eventName + ".dispatcher" + this._plottableID; } @@ -60,11 +61,13 @@ export module Dispatcher { if (this.connected) { throw new Error("Can't connect dispatcher twice!"); } - this.connected = true; - Object.keys(this._event2Callback).forEach((event: string) => { - var callback = this._event2Callback[event]; - this._target.on(this.getEventString(event), callback); - }); + if (this._target) { + this.connected = true; + Object.keys(this._event2Callback).forEach((event: string) => { + var callback = this._event2Callback[event]; + this._target.on(this._getEventString(event), callback); + }); + } return this; } @@ -76,9 +79,11 @@ export module Dispatcher { */ public disconnect() { this.connected = false; - Object.keys(this._event2Callback).forEach((event: string) => { - this._target.on(this.getEventString(event), null); - }); + if (this._target) { + Object.keys(this._event2Callback).forEach((event: string) => { + this._target.on(this._getEventString(event), null); + }); + } return this; } } diff --git a/src/dispatchers/keypressDispatcher.ts b/src/dispatchers/keypressDispatcher.ts new file mode 100644 index 0000000000..9b141dfe42 --- /dev/null +++ b/src/dispatchers/keypressDispatcher.ts @@ -0,0 +1,71 @@ +/// + +module Plottable { +export module Dispatcher { + export class Keypress extends Dispatcher.AbstractDispatcher { + private mousedOverTarget = false; + private keydownListenerTarget: D3.Selection; + private _onKeyDown: (e: D3.D3Event) => void; + + /** + * Constructs a Keypress Dispatcher with the specified target. + * + * @constructor + * @param {D3.Selection} [target] The selection to listen for events on. + */ + constructor(target?: D3.Selection) { + super(target); + + // Can't attach the key listener to the target (a sub-svg element) + // because "focusable" is only in SVG 1.2 / 2, which most browsers don't + // yet implement + this.keydownListenerTarget = d3.select(document); + + this._event2Callback["mouseover"] = () => { + this.mousedOverTarget = true; + }; + + this._event2Callback["mouseout"] = () => { + this.mousedOverTarget = false; + }; + } + + public connect() { + super.connect(); + this.keydownListenerTarget.on(this._getEventString("keydown"), () => { + if (this.mousedOverTarget && this._onKeyDown) { + this._onKeyDown(d3.event); + } + }); + return this; + } + + public disconnect() { + super.disconnect(); + this.keydownListenerTarget.on(this._getEventString("keydown"), null); + return this; + } + + /** + * Gets the callback to be called when a key is pressed. + * + * @return {(e: D3.D3Event) => void} The current keydown callback. + */ + public onKeyDown(): (e: D3.D3Event) => void; + /** + * Sets a callback to be called when a key is pressed. + * + * @param {(e: D3.D3Event) => void} A callback that takes in a D3Event. + * @return {Keypress} The calling Dispatcher.Keypress. + */ + public onKeyDown(callback: (e: D3.D3Event) => void): Keypress; + public onKeyDown(callback?: (e: D3.D3Event) => void): any { + if (callback === undefined) { + return this._onKeyDown; + } + this._onKeyDown = callback; + return this; + } + } +} +} diff --git a/src/drawers/elementDrawer.ts b/src/drawers/elementDrawer.ts index e3e73e97ba..2a533fecbf 100644 --- a/src/drawers/elementDrawer.ts +++ b/src/drawers/elementDrawer.ts @@ -37,6 +37,28 @@ export module _Drawer { } dataElements.exit().remove(); } + + private filterDefinedData(data: any[], definedFunction: (d: any, i: number) => boolean): any[] { + return definedFunction ? data.filter(definedFunction) : data; + } + + public draw(data: any[], drawSteps: DrawStep[]): number { + var modifiedDrawSteps: DrawStep[] = []; + drawSteps.forEach((d: DrawStep, i: number) => { + modifiedDrawSteps[i] = {animator: d.animator, attrToProjector: _Util.Methods.copyMap(d.attrToProjector)}; + }); + + var definedData: any[] = modifiedDrawSteps.reduce((data: any[], drawStep: DrawStep) => + this.filterDefinedData(data, drawStep.attrToProjector["defined"]), data); + + modifiedDrawSteps.forEach((d: DrawStep) => { + if (d.attrToProjector["defined"]) { + delete d.attrToProjector["defined"]; + } + }); + + return super.draw(definedData, modifiedDrawSteps); + } } } } diff --git a/src/interactions/hoverInteraction.ts b/src/interactions/hoverInteraction.ts index 1643d71fa6..314327780b 100644 --- a/src/interactions/hoverInteraction.ts +++ b/src/interactions/hoverInteraction.ts @@ -4,6 +4,7 @@ module Plottable { export module Interaction { export interface HoverData { data: any[]; + pixelPositions: Point[]; selection: D3.Selection; } @@ -38,6 +39,7 @@ export module Interaction { private currentHoverData: HoverData = { data: null, + pixelPositions: null, selection: null }; @@ -55,6 +57,7 @@ export module Interaction { this.safeHoverOut(this.currentHoverData); this.currentHoverData = { data: null, + pixelPositions: null, selection: null }; }); @@ -72,20 +75,29 @@ export module Interaction { return a; } - var notInB = (d: any) => b.data.indexOf(d) === -1; + var diffData: any[] = []; + var diffPoints: Point[] = []; + var diffElements: Element[] = []; + a.data.forEach((d: any, i: number) => { + if (b.data.indexOf(d) === -1) { + diffData.push(d); + diffPoints.push(a.pixelPositions[i]); + diffElements.push(a.selection[0][i]); + } + }); - var diffData = a.data.filter(notInB); if (diffData.length === 0) { return { data: null, + pixelPositions: null, selection: null }; } - var diffSelection = a.selection.filter(notInB); return { data: diffData, - selection: diffSelection + pixelPositions: diffPoints, + selection: d3.selectAll(diffElements) }; } @@ -93,13 +105,13 @@ export module Interaction { var lastHoverData = this.currentHoverData; var newHoverData = this._componentToListenTo._doHover(p); + this.currentHoverData = newHoverData; + var outData = Hover.diffHoverData(lastHoverData, newHoverData); this.safeHoverOut(outData); var overData = Hover.diffHoverData(newHoverData, lastHoverData); this.safeHoverOver(overData); - - this.currentHoverData = newHoverData; } private safeHoverOut(outData: HoverData) { diff --git a/src/interactions/keyEventListener.ts b/src/interactions/keyEventListener.ts deleted file mode 100644 index 2beffba785..0000000000 --- a/src/interactions/keyEventListener.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// - -module Plottable { -export module Core { - /** - * A function to be called when an event occurs. The argument is the d3 event - * generated by the event. - */ - export interface KeyEventListenerCallback { - (e: D3.D3Event): any - } - - /** - * A module for listening to keypresses on the document. - */ - export module KeyEventListener { - var _initialized: boolean = false; - var _callbacks: KeyEventListenerCallback[][] = []; - - /** - * Turns on key listening. - */ - export function initialize() { - if (_initialized) { - return; - } - d3.select(document).on("keydown", processEvent); - _initialized = true; - } - - /** - * When a key event occurs with the key corresponding te keyCod, call cb. - * - * @param {number} keyCode The javascript key code to call cb on. - * @param {IKeyEventListener} cb Will be called when keyCode key event - * occurs. - */ - export function addCallback(keyCode: number, cb: KeyEventListenerCallback) { - if (!_initialized) { - initialize(); - } - - if (_callbacks[keyCode] == null) { - _callbacks[keyCode] = []; - } - - _callbacks[keyCode].push(cb); - } - - function processEvent() { - if (_callbacks[d3.event.keyCode] == null) { - return; - } - - _callbacks[d3.event.keyCode].forEach((cb: KeyEventListenerCallback) => { - cb(d3.event); - }); - } - } -} -} diff --git a/src/interactions/keyInteraction.ts b/src/interactions/keyInteraction.ts index 47c7981b35..e0a73e7fbc 100644 --- a/src/interactions/keyInteraction.ts +++ b/src/interactions/keyInteraction.ts @@ -3,9 +3,10 @@ module Plottable { export module Interaction { export class Key extends AbstractInteraction { - private _callback: () => any; private activated = false; private keyCode: number; + private dispatcher: Plottable.Dispatcher.Keypress; + private keyCode2Callback: { [keyCode: string]: () => void; } = {}; /** * Creates a KeyInteraction. @@ -14,38 +15,35 @@ export module Interaction { * moused over. * * @constructor - * @param {number} keyCode The key code to listen for. */ - constructor(keyCode: number) { + constructor() { super(); - this.keyCode = keyCode; + this.dispatcher = new Plottable.Dispatcher.Keypress(); } public _anchor(component: Component.AbstractComponent, hitBox: D3.Selection) { super._anchor(component, hitBox); - hitBox.on("mouseover", () => { - this.activated = true; - }); - hitBox.on("mouseout", () => { - this.activated = false; - }); - Core.KeyEventListener.addCallback(this.keyCode, (e: D3.D3Event) => { - if (this.activated && this._callback != null) { - this._callback(); + this.dispatcher.target(this._hitBox); + + this.dispatcher.onKeyDown((e: D3.D3Event) => { + if (this.keyCode2Callback[e.keyCode]) { + this.keyCode2Callback[e.keyCode](); } }); + this.dispatcher.connect(); } /** - * Sets a callback to be called when the designated key is pressed and the - * user is moused over the component. + * Sets a callback to be called when the key with the given keyCode is + * pressed and the user is moused over the Component. * - * @param {() => any} cb Callback to be called. - * @returns The calling Key. + * @param {number} keyCode The key code associated with the key. + * @param {() => void} callback Callback to be called. + * @returns The calling Interaction.Key. */ - public callback(cb: () => any): Key { - this._callback = cb; + public on(keyCode: number, callback: () => void): Key { + this.keyCode2Callback[keyCode] = callback; return this; } } diff --git a/src/reference.ts b/src/reference.ts index befd64bb67..9bd5855e8d 100644 --- a/src/reference.ts +++ b/src/reference.ts @@ -10,6 +10,7 @@ /// +/// /// /// /// @@ -77,7 +78,10 @@ /// /// -/// +/// +/// +/// + /// /// /// @@ -89,6 +93,3 @@ /// /// /// - -/// -/// diff --git a/src/scales/abstractScale.ts b/src/scales/abstractScale.ts index 1452638762..8e4ead87d0 100644 --- a/src/scales/abstractScale.ts +++ b/src/scales/abstractScale.ts @@ -8,6 +8,7 @@ export module Scale { public broadcaster = new Plottable.Core.Broadcaster(this); public _rendererAttrID2Extent: {[rendererAttrID: string]: D[]} = {}; public _typeCoercer: (d: any) => any = (d: any) => d; + public _domainModificationInProgress: boolean = false; /** * Constructs a new Scale. * @@ -100,8 +101,12 @@ export module Scale { } public _setDomain(values: D[]) { - this._d3Scale.domain(values); - this.broadcaster.broadcast(); + if(!this._domainModificationInProgress) { + this._domainModificationInProgress = true; + this._d3Scale.domain(values); + this.broadcaster.broadcast(); + this._domainModificationInProgress = false; + } } /** diff --git a/src/scales/tickGenerators.ts b/src/scales/tickGenerators.ts index a501e2a5a3..18ad1661a4 100644 --- a/src/scales/tickGenerators.ts +++ b/src/scales/tickGenerators.ts @@ -34,6 +34,20 @@ module Plottable { return lowTicks.concat(middleTicks).concat(highTicks); }; } + + /** + * Creates a tick generator that will filter for only the integers in defaultTicks and return them. + * + * Will also include the end ticks. + * + * @returns {TickGenerator} A tick generator returning only integer ticks. + */ + export function integerTickGenerator(): TickGenerator { + return function(s: Scale.AbstractQuantitative) { + var defaultTicks = s.getDefaultTicks(); + return defaultTicks.filter((tick, i) => (tick % 1 === 0) || (i === 0) || (i === defaultTicks.length - 1)); + }; + } } } } diff --git a/src/utils/formatters.ts b/src/utils/formatters.ts index 943e592fab..a92f06d171 100644 --- a/src/utils/formatters.ts +++ b/src/utils/formatters.ts @@ -25,13 +25,10 @@ module Plottable { * * @returns {Formatter} A formatter for currency values. */ - export function currency(precision = 2, symbol = "$", prefix = true, onlyShowUnchanged = true) { + export function currency(precision = 2, symbol = "$", prefix = true) { var fixedFormatter = Formatters.fixed(precision); return function(d: any) { var formattedValue = fixedFormatter(Math.abs(d)); - if (onlyShowUnchanged && valueChanged(Math.abs(d), formattedValue)) { - return ""; - } if (formattedValue !== "") { if (prefix) { formattedValue = symbol + formattedValue; @@ -55,14 +52,10 @@ module Plottable { * * @returns {Formatter} A formatter that displays exactly [precision] decimal places. */ - export function fixed(precision = 3, onlyShowUnchanged = true) { + export function fixed(precision = 3) { verifyPrecision(precision); return function(d: any) { - var formattedValue = ( d).toFixed(precision); - if (onlyShowUnchanged && valueChanged(d, formattedValue)) { - return ""; - } - return formattedValue; + return ( d).toFixed(precision); }; } @@ -75,16 +68,12 @@ module Plottable { * * @returns {Formatter} A formatter for general values. */ - export function general(precision = 3, onlyShowUnchanged = true) { + export function general(precision = 3) { verifyPrecision(precision); return function(d: any) { if (typeof d === "number") { var multiplier = Math.pow(10, precision); - var formattedValue = String(Math.round(d * multiplier) / multiplier); - if (onlyShowUnchanged && valueChanged(d, formattedValue)) { - return ""; - } - return formattedValue; + return String(Math.round(d * multiplier) / multiplier); } else { return String(d); } @@ -111,8 +100,8 @@ module Plottable { * * @returns {Formatter} A formatter for percentage values. */ - export function percentage(precision = 0, onlyShowUnchanged = true) { - var fixedFormatter = Formatters.fixed(precision, onlyShowUnchanged); + export function percentage(precision = 0) { + var fixedFormatter = Formatters.fixed(precision); return function(d: any) { var valToFormat = d * 100; @@ -121,14 +110,7 @@ module Plottable { var integerPowerTen = Math.pow(10, valString.length - (valString.indexOf(".") + 1)); valToFormat = parseInt((valToFormat * integerPowerTen).toString(), 10) / integerPowerTen; - var formattedValue = fixedFormatter(valToFormat); - if (onlyShowUnchanged && valueChanged(valToFormat, formattedValue)) { - return ""; - } - if (formattedValue !== "") { - formattedValue += "%"; - } - return formattedValue; + return fixedFormatter(valToFormat) + "%"; }; } @@ -224,9 +206,5 @@ module Plottable { } } - function valueChanged(d: any, formattedValue: string) { - return d !== parseFloat(formattedValue); - } - } } diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 7bd0e4cfb8..b507d863c0 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -21,6 +21,9 @@ export module _Util { * @param {string} The warnings to print */ export function warn(warning: string) { + if (!Config.SHOW_WARNINGS) { + return; + } /* tslint:disable:no-console */ if (( window).console != null) { if (( window).console.warn != null) { diff --git a/test/components/plots/areaPlotTests.ts b/test/components/plots/areaPlotTests.ts index a73371627a..b40ec14ec3 100644 --- a/test/components/plots/areaPlotTests.ts +++ b/test/components/plots/areaPlotTests.ts @@ -87,22 +87,28 @@ describe("Plots", () => { var dataWithNaN = areaData.slice(); dataWithNaN[2] = { foo: 0.4, bar: NaN }; simpleDataset.data(dataWithNaN); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, - "area d was set correctly (y=NaN case)"); + + var areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (y=NaN case)"); + dataWithNaN[2] = { foo: NaN, bar: 0.4 }; simpleDataset.data(dataWithNaN); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, - "area d was set correctly (x=NaN case)"); + + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (x=NaN case)"); var dataWithUndefined = areaData.slice(); dataWithUndefined[2] = { foo: 0.4, bar: undefined }; simpleDataset.data(dataWithUndefined); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, - "area d was set correctly (y=undefined case)"); + + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (y=undefined case)"); + dataWithUndefined[2] = { foo: undefined, bar: 0.4 }; simpleDataset.data(dataWithUndefined); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, - "area d was set correctly (x=undefined case)"); + + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (x=undefined case)"); svg.remove(); }); diff --git a/test/components/plots/barPlotTests.ts b/test/components/plots/barPlotTests.ts index 72c54f9282..29a4d11261 100644 --- a/test/components/plots/barPlotTests.ts +++ b/test/components/plots/barPlotTests.ts @@ -37,12 +37,12 @@ describe("Plots", () => { assert.lengthOf(bars[0], 3, "One bar was created per data point"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); assert.equal(bar0.attr("height"), "100", "bar0 height is correct"); assert.equal(bar1.attr("height"), "150", "bar1 height is correct"); - assert.equal(bar0.attr("x"), "145", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "445", "bar1 x is correct"); + assert.equal(bar0.attr("x"), "75", "bar0 x is correct"); + assert.equal(bar1.attr("x"), "375", "bar1 x is correct"); assert.equal(bar0.attr("y"), "100", "bar0 y is correct"); assert.equal(bar1.attr("y"), "200", "bar1 y is correct"); @@ -80,20 +80,20 @@ describe("Plots", () => { var bars = renderArea.selectAll("rect"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); - assert.equal(bar0.attr("x"), "145", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "445", "bar1 x is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); + assert.equal(numAttr(bar0, "x"), 75, "bar0 x is correct"); + assert.equal(numAttr(bar1, "x"), 375, "bar1 x is correct"); barPlot.barAlignment("right"); renderArea = barPlot._renderArea; bars = renderArea.selectAll("rect"); bar0 = d3.select(bars[0][0]); bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); - assert.equal(bar0.attr("x"), "140", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "440", "bar1 x is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); + assert.equal(numAttr(bar0, "x"), 0, "bar0 x is correct"); + assert.equal(numAttr(bar1, "x"), 300, "bar1 x is correct"); assert.throws(() => barPlot.barAlignment("blargh"), Error); assert.equal(barPlot._barAlignmentFactor, 1, "the bad barAlignment didnt break internal state"); @@ -159,6 +159,160 @@ describe("Plots", () => { svg.remove(); }); + + it("don't show points from outside of domain", () => { + xScale.domain(["C"]); + var bars = barPlot._renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 0, "no bars have been rendered"); + svg.remove(); + }); + }); + + describe("Vertical Bar Plot modified log scale", () => { + var svg: D3.Selection; + var dataset: Plottable.Dataset; + var xScale: Plottable.Scale.ModifiedLog; + var yScale: Plottable.Scale.Linear; + var barPlot: Plottable.Plot.VerticalBar; + var SVG_WIDTH = 600; + var SVG_HEIGHT = 400; + + beforeEach(() => { + svg = generateSVG(SVG_WIDTH, SVG_HEIGHT); + xScale = new Plottable.Scale.ModifiedLog(); + yScale = new Plottable.Scale.Linear(); + var data = [ + {x: 2, y: 1}, + {x: 10, y: -1.5}, + {x: 100, y: 1} + ]; + dataset = new Plottable.Dataset(data); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(dataset); + barPlot.animate(false); + barPlot.baseline(0); + yScale.domain([-2, 2]); + barPlot.renderTo(svg); + }); + + it("barPixelWidth calculated appropriately", () => { + assert.strictEqual(barPlot._getBarPixelWidth(), (xScale.scale(10) - xScale.scale(2)) * 0.95); + svg.remove(); + }); + + it("bar widths are equal to barPixelWidth", () => { + var renderArea = barPlot._renderArea; + var bars = renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 3, "One bar was created per data point"); + + var barPixelWidth = barPlot._getBarPixelWidth(); + var bar0 = d3.select(bars[0][0]); + var bar1 = d3.select(bars[0][1]); + var bar2 = d3.select(bars[0][2]); + assert.closeTo(numAttr(bar0, "width"), barPixelWidth, 0.1, "bar0 width is correct"); + assert.closeTo(numAttr(bar1, "width"), barPixelWidth, 0.1, "bar1 width is correct"); + assert.closeTo(numAttr(bar2, "width"), barPixelWidth, 0.1, "bar2 width is correct"); + svg.remove(); + }); + }); + + describe("Vertical Bar Plot linear scale", () => { + var svg: D3.Selection; + var dataset: Plottable.Dataset; + var xScale: Plottable.Scale.Linear; + var yScale: Plottable.Scale.Linear; + var barPlot: Plottable.Plot.VerticalBar; + var SVG_WIDTH = 600; + var SVG_HEIGHT = 400; + + beforeEach(() => { + svg = generateSVG(SVG_WIDTH, SVG_HEIGHT); + xScale = new Plottable.Scale.Linear(); + yScale = new Plottable.Scale.Linear(); + var data = [ + {x: 2, y: 1}, + {x: 10, y: -1.5}, + {x: 100, y: 1} + ]; + dataset = new Plottable.Dataset(data); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(dataset); + barPlot.baseline(0); + barPlot.renderTo(svg); + }); + + it("bar width takes an appropriate value", () => { + assert.strictEqual(barPlot._getBarPixelWidth(), (xScale.scale(10) - xScale.scale(2)) * 0.95); + svg.remove(); + }); + + it("bar widths are equal to barPixelWidth", () => { + var renderArea = barPlot._renderArea; + var bars = renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 3, "One bar was created per data point"); + + var barPixelWidth = barPlot._getBarPixelWidth(); + var bar0 = d3.select(bars[0][0]); + var bar1 = d3.select(bars[0][1]); + var bar2 = d3.select(bars[0][2]); + assert.closeTo(numAttr(bar0, "width"), barPixelWidth, 0.1, "bar0 width is correct"); + assert.closeTo(numAttr(bar1, "width"), barPixelWidth, 0.1, "bar1 width is correct"); + assert.closeTo(numAttr(bar2, "width"), barPixelWidth, 0.1, "bar2 width is correct"); + svg.remove(); + }); + + it("sensible bar width one datum", () => { + barPlot.removeDataset(dataset); + barPlot.addDataset([{x: 10, y: 2}]); + assert.closeTo(barPlot._getBarPixelWidth(), 228, 0.1, "sensible bar width for only one datum"); + svg.remove(); + }); + + it("sensible bar width same datum", () => { + barPlot.removeDataset(dataset); + barPlot.addDataset([{x: 10, y: 2}, {x: 10, y: 2}]); + assert.closeTo(barPlot._getBarPixelWidth(), 228, 0.1, "uses the width sensible for one datum"); + svg.remove(); + }); + + it("sensible bar width unsorted data", () => { + barPlot.removeDataset(dataset); + barPlot.addDataset([{x: 2, y: 2}, {x: 20, y: 2}, {x: 5, y: 2}]); + var expectedBarPixelWidth = (xScale.scale(5) - xScale.scale(2)) * 0.95; + assert.closeTo(barPlot._getBarPixelWidth(), expectedBarPixelWidth, 0.1, "bar width uses closest sorted x values"); + svg.remove(); + }); + }); + + describe("Vertical Bar Plot time scale", () => { + var svg: D3.Selection; + var barPlot: Plottable.Plot.VerticalBar; + var xScale: Plottable.Scale.Time; + + beforeEach(() => { + svg = generateSVG(600, 400); + var data = [{ x: "12/01/92", y: 0, type: "a" }, + { x: "12/01/93", y: 1, type: "a" }, + { x: "12/01/94", y: 1, type: "a" }, + { x: "12/01/95", y: 2, type: "a" }, + { x: "12/01/96", y: 2, type: "a" }, + { x: "12/01/97", y: 2, type: "a" }]; + xScale = new Plottable.Scale.Time(); + var yScale = new Plottable.Scale.Linear(); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(data) + .project("x", (d: any) => d3.time.format("%m/%d/%y").parse(d.x), xScale) + .project("y", "y", yScale) + .renderTo(svg); + }); + + it("bar width takes an appropriate value", () => { + var timeFormatter = d3.time.format("%m/%d/%y"); + var expectedBarWidth = (xScale.scale(timeFormatter.parse("12/01/94")) - xScale.scale(timeFormatter.parse("12/01/93"))) * 0.95; + assert.closeTo(barPlot._getBarPixelWidth(), expectedBarWidth, 0.1, "width is difference between two dates"); + svg.remove(); + }); + }); describe("Horizontal Bar Plot in Points Mode", () => { @@ -195,12 +349,12 @@ describe("Plots", () => { assert.lengthOf(bars[0], 3, "One bar was created per data point"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); assert.equal(bar0.attr("width"), "100", "bar0 width is correct"); assert.equal(bar1.attr("width"), "150", "bar1 width is correct"); - assert.equal(bar0.attr("y"), "295", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "95", "bar1 y is correct"); + assert.equal(bar0.attr("y"), "250", "bar0 y is correct"); + assert.equal(bar1.attr("y"), "50", "bar1 y is correct"); assert.equal(bar0.attr("x"), "300", "bar0 x is correct"); assert.equal(bar1.attr("x"), "150", "bar1 x is correct"); @@ -238,20 +392,20 @@ describe("Plots", () => { var bars = renderArea.selectAll("rect"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); - assert.equal(bar0.attr("y"), "295", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "95", "bar1 y is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); + assert.equal(numAttr(bar0, "y"), 250, "bar0 y is correct"); + assert.equal(numAttr(bar1, "y"), 50, "bar1 y is correct"); barPlot.barAlignment("bottom"); renderArea = barPlot._renderArea; bars = renderArea.selectAll("rect"); bar0 = d3.select(bars[0][0]); bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); - assert.equal(bar0.attr("y"), "290", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "90", "bar1 y is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); + assert.equal(numAttr(bar0, "y"), 200, "bar0 y is correct"); + assert.equal(numAttr(bar1, "y"), 0, "bar1 y is correct"); assert.throws(() => barPlot.barAlignment("blargh"), Error); diff --git a/test/components/plots/clusteredBarPlotTests.ts b/test/components/plots/clusteredBarPlotTests.ts index 08b5801902..99c29fc0aa 100644 --- a/test/components/plots/clusteredBarPlotTests.ts +++ b/test/components/plots/clusteredBarPlotTests.ts @@ -66,7 +66,7 @@ describe("Plots", () => { assert.closeTo(numAttr(bar3, "height"), (400 - axisHeight) / 2, 0.01, "height is correct for bar3"); // check that clustering is correct - var off = (renderer).innerScale.scale("_0"); + var off = (renderer).makeInnerScale().scale("_0"); assert.closeTo(numAttr(bar0, "x") + numAttr(bar0, "width") / 2, xScale.scale(bar0X) + bandWidth / 2 - off, 0.01 , "x pos correct for bar0"); assert.closeTo(numAttr(bar1, "x") + numAttr(bar1, "width") / 2, xScale.scale(bar1X) + bandWidth / 2 - off, 0.01 @@ -143,7 +143,7 @@ describe("Plots", () => { var bar3Y = bar3.data()[0].y; // check that clustering is correct - var off = (renderer).innerScale.scale("_0"); + var off = (renderer).makeInnerScale().scale("_0"); assert.closeTo(numAttr(bar0, "y") + numAttr(bar0, "height") / 2, yScale.scale(bar0Y) + bandWidth / 2 - off, 0.01 , "y pos correct for bar0"); assert.closeTo(numAttr(bar1, "y") + numAttr(bar1, "height") / 2, yScale.scale(bar1Y) + bandWidth / 2 - off, 0.01 diff --git a/test/components/plots/plotTests.ts b/test/components/plots/plotTests.ts index 4d0a3a751d..b80ac05d86 100644 --- a/test/components/plots/plotTests.ts +++ b/test/components/plots/plotTests.ts @@ -275,4 +275,121 @@ describe("Plots", () => { assert.equal(recordedTime, 20, "additionalPaint passed appropriate time argument"); }); }); + + describe("Abstract XY Plot", () => { + var svg: D3.Selection; + var xScale: Plottable.Scale.Linear; + var yScale: Plottable.Scale.Linear; + var xAccessor: any; + var yAccessor: any; + var simpleDataset: Plottable.Dataset; + var plot: Plottable.Plot.AbstractXYPlot; + + before(() => { + xAccessor = (d: any) => d.a; + yAccessor = (d: any) => d.b; + }); + + beforeEach(() => { + svg = generateSVG(500, 500); + simpleDataset = new Plottable.Dataset([{a: -5, b: 6}, {a: -2, b: 2}, {a: 2, b: -2}, {a: 5, b: -6}]); + xScale = new Plottable.Scale.Linear(); + yScale = new Plottable.Scale.Linear(); + plot = new Plottable.Plot.AbstractXYPlot(xScale, yScale); + plot.addDataset(simpleDataset) + .project("x", xAccessor, xScale) + .project("y", yAccessor, yScale) + .renderTo(svg); + }); + + it("plot auto domain scale to visible points", () => { + xScale.domain([-3, 3]); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has not been adjusted to visible points"); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "domain has been adjusted to visible points"); + plot.automaticallyAdjustYScaleOverVisiblePoints(false); + plot.automaticallyAdjustXScaleOverVisiblePoints(true); + yScale.domain([-6, 6]); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to visible points"); + svg.remove(); + }); + + it("no visible points", () => { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been not been adjusted"); + svg.remove(); + }); + + it("automaticallyAdjustYScaleOverVisiblePoints disables autoDomain", () => { + xScale.domain([-2, 2]); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + plot.renderTo(svg); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "domain has been been adjusted"); + svg.remove(); + }); + + it("show all data", () => { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + plot.showAllData(); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been adjusted to show all data"); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to show all data"); + svg.remove(); + }); + + it("show all data without auto adjust domain", () => { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + plot.automaticallyAdjustYScaleOverVisiblePoints(false); + plot.showAllData(); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been adjusted to show all data"); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to show all data"); + svg.remove(); + }); + + it("no cycle in auto domain on plot", () => { + var zScale = new Plottable.Scale.Linear().domain([-10, 10]); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + var plot2 = new Plottable.Plot.AbstractXYPlot(zScale, yScale) + .automaticallyAdjustXScaleOverVisiblePoints(true) + .project("x", xAccessor, zScale) + .project("y", yAccessor, yScale) + .addDataset(simpleDataset); + var plot3 = new Plottable.Plot.AbstractXYPlot(zScale, xScale) + .automaticallyAdjustYScaleOverVisiblePoints(true) + .project("x", xAccessor, zScale) + .project("y", yAccessor, xScale) + .addDataset(simpleDataset); + plot2.renderTo(svg); + plot3.renderTo(svg); + + xScale.domain([-2, 2]); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "y domain is adjusted by x domain using custom algorithm and domainer"); + assert.deepEqual(zScale.domain(), [-2.5, 2.5], "z domain is adjusted by y domain using custom algorithm and domainer"); + assert.deepEqual(xScale.domain(), [-2, 2], "x domain is not adjusted using custom algorithm and domainer"); + + svg.remove(); + }); + + it("listeners are deregistered after removal", () => { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + plot.remove(); + var key2callback = ( xScale).broadcaster.key2callback; + assert.isUndefined(key2callback.get("yDomainAdjustment" + plot._plottableID), "the plot is no longer attached to the xScale"); + key2callback = ( yScale).broadcaster.key2callback; + assert.isUndefined(key2callback.get("xDomainAdjustment" + plot._plottableID), "the plot is no longer attached to the yScale"); + svg.remove(); + }); + + it("listeners are deregistered for changed scale", () => { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + var newScale = new Plottable.Scale.Linear().domain([-10, 10]); + plot.project("x", xAccessor, newScale); + xScale.domain([-2, 2]); + assert.deepEqual(yScale.domain(), [-7, 7], "replaced xScale didn't adjust yScale"); + svg.remove(); + }); + + }); }); diff --git a/test/components/timeAxisTests.ts b/test/components/timeAxisTests.ts index 7a9d55b34e..f5cee20fd3 100644 --- a/test/components/timeAxisTests.ts +++ b/test/components/timeAxisTests.ts @@ -3,10 +3,21 @@ var assert = chai.assert; describe("TimeAxis", () => { + var scale: Plottable.Scale.Time; + var axis: Plottable.Axis.Time; + beforeEach(() => { + scale = new Plottable.Scale.Time(); + axis = new Plottable.Axis.Time(scale, "bottom"); + }); it("can not initialize vertical time axis", () => { - var scale = new Plottable.Scale.Time(); - assert.throws(() => new Plottable.Axis.Time(scale, "left"), "unsupported"); - assert.throws(() => new Plottable.Axis.Time(scale, "right"), "unsupported"); + assert.throws(() => new Plottable.Axis.Time(scale, "left"), "horizontal"); + assert.throws(() => new Plottable.Axis.Time(scale, "right"), "horizontal"); + }); + + it("cannot change time axis orientation to vertical", () => { + assert.throws(() => axis.orient("left"), "horizontal"); + assert.throws(() => axis.orient("right"), "horizontal"); + assert.equal(axis.orient(), "bottom", "orientation unchanged"); }); it("major and minor intervals arrays are the same length", () => { @@ -16,8 +27,6 @@ describe("TimeAxis", () => { it("Computing the default ticks doesn't error out for edge cases", () => { var svg = generateSVG(400, 100); - var scale = new Plottable.Scale.Time(); - var axis = new Plottable.Axis.Time(scale, "bottom"); scale.range([0, 400]); // very large time span @@ -33,9 +42,7 @@ describe("TimeAxis", () => { it("Tick labels don't overlap", () => { var svg = generateSVG(400, 100); - var scale = new Plottable.Scale.Time(); scale.range([0, 400]); - var axis = new Plottable.Axis.Time(scale, "bottom"); function checkDomain(domain: any[]) { scale.domain(domain); @@ -78,6 +85,6 @@ describe("TimeAxis", () => { // 1 second span checkDomain([new Date(2000, 0, 1, 0, 0, 0, 0), new Date(2000, 0, 1, 0, 0, 1, 0)]); - svg.remove(); + svg.remove(); }); }); diff --git a/test/core/componentTests.ts b/test/core/componentTests.ts index 0478818605..a277ddbdf8 100644 --- a/test/core/componentTests.ts +++ b/test/core/componentTests.ts @@ -400,4 +400,69 @@ it("components can be offset relative to their alignment, and throw errors if th assert.deepEqual(transform.translate, [0, 0], "the element was not translated"); svg.remove(); }); + describe("resizeBroadcaster testing", () => { + var oldRegister: any; + var oldDeregister: any; + var registeredComponents: D3.Set; + var id: number; + before(() => { + oldRegister = Plottable.Core.ResizeBroadcaster.register; + oldDeregister = Plottable.Core.ResizeBroadcaster.deregister; + var mockRegister = (c: Plottable.Component.AbstractComponent) => { + registeredComponents.add(c._plottableID); + }; + + var mockDeregister = (c: Plottable.Component.AbstractComponent) => { + registeredComponents.remove(c._plottableID); + }; + Plottable.Core.ResizeBroadcaster.register = mockRegister; + Plottable.Core.ResizeBroadcaster.deregister = mockDeregister; + }); + + after(() => { + Plottable.Core.ResizeBroadcaster.register = oldRegister; + Plottable.Core.ResizeBroadcaster.deregister = oldDeregister; + }); + + beforeEach(() => { + registeredComponents = d3.set(); + id = c._plottableID; + }); + + afterEach(() => { + svg.remove(); // svg contains no useful info + }); + + it("components can be removed from resizeBroadcaster before rendering", () => { + c.autoResize(false); + c.renderTo(svg); + assert.isFalse(registeredComponents.has(id), "component not registered to broadcaster"); + }); + + it("components register by default", () => { + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + }); + + it("component can be deregistered then registered before render", () => { + c.autoResize(false); + c.autoResize(true); + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + }); + + it("component can be deregistered after rendering", () => { + c.renderTo(svg); + c.autoResize(false); + assert.isFalse(registeredComponents.has(id), "component was deregistered after rendering"); + }); + + it("calling .remove deregisters a component", () => { + c.autoResize(true); + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + c.remove(); + assert.isFalse(registeredComponents.has(id), "component is deregistered after removal"); + }); + }); }); diff --git a/test/core/domainerTests.ts b/test/core/domainerTests.ts index c47c88a7aa..9cfab969bb 100644 --- a/test/core/domainerTests.ts +++ b/test/core/domainerTests.ts @@ -13,7 +13,8 @@ describe("Domainer", () => { it("pad() works in general case", () => { scale._updateExtent("1", "x", [100, 200]); scale.domainer(new Plottable.Domainer().pad(0.2)); - assert.deepEqual(scale.domain(), [90, 210]); + assert.closeTo(scale.domain()[0], 90, 0.1, "lower bound of domain correct"); + assert.closeTo(scale.domain()[1], 210, 0.1, "upper bound of domain correct"); }); it("pad() works for date scales", () => { diff --git a/test/dispatchers/dispatcherTests.ts b/test/dispatchers/dispatcherTests.ts index 4726ce5c36..a041c2f4b0 100644 --- a/test/dispatchers/dispatcherTests.ts +++ b/test/dispatchers/dispatcherTests.ts @@ -123,4 +123,36 @@ describe("Dispatchers", () => { target.remove(); }); }); + + describe("Keypress Dispatcher", () => { + it("triggers the callback only when moused over the target", () => { + var target = generateSVG(400, 400); + + var kpd = new Plottable.Dispatcher.Keypress(target); + var keyDownCalled = false; + var lastKeyCode: number; + kpd.onKeyDown((e: D3.D3Event) => { + keyDownCalled = true; + lastKeyCode = e.keyCode; + }); + kpd.connect(); + + var $target = $(target.node()); + + $target.simulate("keydown", { keyCode: 80 }); + assert.isFalse(keyDownCalled, "didn't trigger callback if not moused over the target"); + + $target.simulate("mouseover"); + $target.simulate("keydown", { keyCode: 80 }); + assert.isTrue(keyDownCalled, "correctly triggers callback if moused over the target"); + assert.strictEqual(lastKeyCode, 80, "correct event info was passed to the callback"); + + keyDownCalled = false; + $target.simulate("mouseout"); + $target.simulate("keydown", { keyCode: 80 }); + assert.isFalse(keyDownCalled, "didn't trigger callback after mousing out of the target"); + + target.remove(); + }); + }); }); diff --git a/test/interactions/hoverInteractionTests.ts b/test/interactions/hoverInteractionTests.ts index 810d285105..606f71ced7 100644 --- a/test/interactions/hoverInteractionTests.ts +++ b/test/interactions/hoverInteractionTests.ts @@ -4,6 +4,9 @@ var assert = chai.assert; class TestHoverable extends Plottable.Component.AbstractComponent implements Plottable.Interaction.Hoverable { + public leftPoint = { x: 100, y: 200 }; + public rightPoint = { x: 300, y: 200 }; + public _hoverOverComponent(p: Plottable.Point) { // cast-override } @@ -14,14 +17,18 @@ class TestHoverable extends Plottable.Component.AbstractComponent public _doHover(p: Plottable.Point): Plottable.Interaction.HoverData { var data: string[] = []; + var points: Plottable.Point[] = []; if (p.x < 250) { data.push("left"); + points.push(this.leftPoint); } if (p.x > 150) { data.push("right"); + points.push(this.rightPoint); } return { data: data, + pixelPositions: points, selection: this._element }; } @@ -66,6 +73,8 @@ describe("Interactions", () => { overCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 100, 200); assert.isTrue(overCallbackCalled, "onHoverOver was called on mousing over a target area"); + assert.deepEqual(overData.pixelPositions, [testTarget.leftPoint], + "onHoverOver was called with the correct pixel position (mouse onto left)"); assert.deepEqual(overData.data, ["left"], "onHoverOver was called with the correct data (mouse onto left)"); @@ -77,12 +86,16 @@ describe("Interactions", () => { overCallbackCalled = false; triggerFakeMouseEvent("mousemove", hitbox, 200, 200); assert.isTrue(overCallbackCalled, "onHoverOver was called when mousing into a new region"); + assert.deepEqual(overData.pixelPositions, [testTarget.rightPoint], + "onHoverOver was called with the correct pixel position (left --> center)"); assert.deepEqual(overData.data, ["right"], "onHoverOver was called with the new data only (left --> center)"); triggerFakeMouseEvent("mouseout", hitbox, 400, 200); overCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 200, 200); + assert.deepEqual(overData.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], + "onHoverOver was called with the correct pixel positions"); assert.deepEqual(overData.data, ["left", "right"], "onHoverOver is called with the correct data"); svg.remove(); @@ -99,17 +112,23 @@ describe("Interactions", () => { outCallbackCalled = false; triggerFakeMouseEvent("mousemove", hitbox, 300, 200); assert.isTrue(outCallbackCalled, "onHoverOut was called when the hover data changes"); + assert.deepEqual(outData.pixelPositions, [testTarget.leftPoint], + "onHoverOut was called with the correct pixel position (center --> right)"); assert.deepEqual(outData.data, ["left"], "onHoverOut was called with the correct data (center --> right)"); outCallbackCalled = false; triggerFakeMouseEvent("mouseout", hitbox, 400, 200); assert.isTrue(outCallbackCalled, "onHoverOut is called on mousing out of the Component"); + assert.deepEqual(outData.pixelPositions, [testTarget.rightPoint], + "onHoverOut was called with the correct pixel position"); assert.deepEqual(outData.data, ["right"], "onHoverOut was called with the correct data"); outCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 200, 200); triggerFakeMouseEvent("mouseout", hitbox, 200, 400); + assert.deepEqual(outData.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], + "onHoverOut was called with the correct pixel positions"); assert.deepEqual(outData.data, ["left", "right"], "onHoverOut is called with the correct data"); svg.remove(); @@ -118,11 +137,15 @@ describe("Interactions", () => { it("getCurrentHoverData()", () => { triggerFakeMouseEvent("mouseover", hitbox, 100, 200); var currentlyHovered = hoverInteraction.getCurrentHoverData(); + assert.deepEqual(currentlyHovered.pixelPositions, [testTarget.leftPoint], + "retrieves pixel positions corresponding to the current position"); assert.deepEqual(currentlyHovered.data, ["left"], "retrieves data corresponding to the current position"); triggerFakeMouseEvent("mousemove", hitbox, 200, 200); currentlyHovered = hoverInteraction.getCurrentHoverData(); + assert.deepEqual(currentlyHovered.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], + "retrieves pixel positions corresponding to the current position"); assert.deepEqual(currentlyHovered.data, ["left", "right"], "retrieves data corresponding to the current position"); diff --git a/test/interactions/interactionTests.ts b/test/interactions/interactionTests.ts index 1c73092d5e..1dda8c08d6 100644 --- a/test/interactions/interactionTests.ts +++ b/test/interactions/interactionTests.ts @@ -237,42 +237,36 @@ describe("Interactions", () => { }); describe("KeyInteraction", () => { - it("Triggers the callback only when the Component is moused over and appropriate key is pressed", () => { + it("Triggers appropriate callback for the key pressed", () => { var svg = generateSVG(400, 400); - // svg.attr("id", "key-interaction-test"); var component = new Plottable.Component.AbstractComponent(); component.renderTo(svg); - var code = 65; // "a" key - var ki = new Plottable.Interaction.Key(code); + var ki = new Plottable.Interaction.Key(); - var callbackCalled = false; - var callback = () => { - callbackCalled = true; - }; + var aCode = 65; // "a" key + var bCode = 66; // "b" key + + var aCallbackCalled = false; + var aCallback = () => aCallbackCalled = true; + var bCallbackCalled = false; + var bCallback = () => bCallbackCalled = true; - ki.callback(callback); + ki.on(aCode, aCallback); + ki.on(bCode, bCallback); component.registerInteraction(ki); var $hitbox = $(( component).hitBox.node()); - $hitbox.simulate("keydown", { keyCode: code }); - assert.isFalse(callbackCalled, "callback is not called if component does not have mouse focus (before mouseover)"); - $hitbox.simulate("mouseover"); - - $hitbox.simulate("keydown", { keyCode: code }); - assert.isTrue(callbackCalled, "callback gets called if the appropriate key is pressed while the component has mouse focus"); - - callbackCalled = false; - $hitbox.simulate("keydown", { keyCode: (code + 1) }); - assert.isFalse(callbackCalled, "callback is not called if the wrong key is pressed"); - - $hitbox.simulate("mouseout"); - - $hitbox.simulate("keydown", { keyCode: code }); - assert.isFalse(callbackCalled, "callback is not called if component does not have mouse focus (after mouseout)"); - + $hitbox.simulate("keydown", { keyCode: aCode }); + assert.isTrue(aCallbackCalled, "callback for \"a\" was called when \"a\" key was pressed"); + assert.isFalse(bCallbackCalled, "callback for \"b\" was not called when \"a\" key was pressed"); + + aCallbackCalled = false; + $hitbox.simulate("keydown", { keyCode: bCode }); + assert.isFalse(aCallbackCalled, "callback for \"a\" was not called when \"b\" key was pressed"); + assert.isTrue(bCallbackCalled, "callback for \"b\" was called when \"b\" key was pressed"); svg.remove(); }); }); diff --git a/test/scales/scaleTests.ts b/test/scales/scaleTests.ts index 34d408ee77..45f24b9bfd 100644 --- a/test/scales/scaleTests.ts +++ b/test/scales/scaleTests.ts @@ -103,10 +103,12 @@ describe("Scales", () => { assert.isTrue(( scale)._autoDomainAutomatically, "autoDomain enabled3"); scale._removeExtent("1", "x"); assert.isTrue(( scale)._autoDomainAutomatically, "autoDomain enabled4"); - assert.deepEqual(scale.domain(), [-20, 1], "only the bar accessor is active"); + assert.closeTo(scale.domain()[0], -20, 0.1, "only the bar accessor is active"); + assert.closeTo(scale.domain()[1], 1, 0.1, "only the bar accessor is active"); scale._updateExtent("2", "x", d3.extent(data, (e) => e.foo)); assert.isTrue(( scale)._autoDomainAutomatically, "autoDomain enabled5"); - assert.deepEqual(scale.domain(), [0, 5], "the bar accessor was overwritten"); + assert.closeTo(scale.domain()[0], 0, 0.1, "the bar accessor was overwritten"); + assert.closeTo(scale.domain()[1], 5, 0.1, "the bar accessor was overwritten"); }); it("should resize when a plot is removed", () => { diff --git a/test/scales/tickGeneratorsTests.ts b/test/scales/tickGeneratorsTests.ts index 9aecc2ff9f..240045b868 100644 --- a/test/scales/tickGeneratorsTests.ts +++ b/test/scales/tickGeneratorsTests.ts @@ -38,4 +38,30 @@ describe("Tick generators", () => { assert.throws(() => Plottable.Scale.TickGenerators.intervalTickGenerator(-2), "interval must be positive number"); }); }); + + describe("integer", () => { + it("normal case", () => { + var scale = new Plottable.Scale.Linear().domain([0, 4]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [0, 1, 2, 3, 4], "only the integers are returned"); + }); + + it("works across negative numbers", () => { + var scale = new Plottable.Scale.Linear().domain([-2, 1]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [-2, -1, 0, 1], "only the integers are returned"); + }); + + it("includes endticks", () => { + var scale = new Plottable.Scale.Linear().domain([-2.7, 1.5]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [-2.5, -2, -1, 0, 1, 1.5], "end ticks are included"); + }); + + it("all float ticks", () => { + var scale = new Plottable.Scale.Linear().domain([1.1, 1.5]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [1.1, 1.5], "only the end ticks are returned"); + }); + }); }); diff --git a/test/testUtils.ts b/test/testUtils.ts index 2fd6bca4b6..837c17a36a 100644 --- a/test/testUtils.ts +++ b/test/testUtils.ts @@ -137,3 +137,27 @@ function triggerFakeMouseEvent(type: string, target: D3.Selection, relativeX: nu 1, null); target.node().dispatchEvent(e); } + +function assertAreaPathCloseTo(actualPath: string, expectedPath: string, precision: number, msg: string) { + var actualAreaPathStrings = actualPath.split("Z"); + var expectedAreaPathStrings = expectedPath.split("Z"); + + actualAreaPathStrings.pop(); + expectedAreaPathStrings.pop(); + + var actualAreaPathPoints = actualAreaPathStrings.map((path) => path.split(/[A-Z]/).map((point) => point.split(","))); + actualAreaPathPoints.forEach((areaPathPoint) => areaPathPoint.shift()); + var expectedAreaPathPoints = expectedAreaPathStrings.map((path) => path.split(/[A-Z]/).map((point) => point.split(","))); + expectedAreaPathPoints.forEach((areaPathPoint) => areaPathPoint.shift()); + + assert.lengthOf(actualAreaPathPoints, expectedAreaPathPoints.length, "number of broken area paths should be equal"); + actualAreaPathPoints.forEach((actualAreaPoints, i) => { + var expectedAreaPoints = expectedAreaPathPoints[i]; + assert.lengthOf(actualAreaPoints, expectedAreaPoints.length, "number of points in path should be equal"); + actualAreaPoints.forEach((actualAreaPoint, j) => { + var expectedAreaPoint = expectedAreaPoints[j]; + assert.closeTo(+actualAreaPoint[0], +expectedAreaPoint[0], 0.1, msg); + assert.closeTo(+actualAreaPoint[1], +expectedAreaPoint[1], 0.1, msg); + }); + }); +} diff --git a/test/tests.js b/test/tests.js index 25372dfef9..ff622946fa 100644 --- a/test/tests.js +++ b/test/tests.js @@ -111,6 +111,26 @@ function triggerFakeMouseEvent(type, target, relativeX, relativeY) { e.initMouseEvent(type, true, true, window, 1, xPos, yPos, xPos, yPos, false, false, false, false, 1, null); target.node().dispatchEvent(e); } +function assertAreaPathCloseTo(actualPath, expectedPath, precision, msg) { + var actualAreaPathStrings = actualPath.split("Z"); + var expectedAreaPathStrings = expectedPath.split("Z"); + actualAreaPathStrings.pop(); + expectedAreaPathStrings.pop(); + var actualAreaPathPoints = actualAreaPathStrings.map(function (path) { return path.split(/[A-Z]/).map(function (point) { return point.split(","); }); }); + actualAreaPathPoints.forEach(function (areaPathPoint) { return areaPathPoint.shift(); }); + var expectedAreaPathPoints = expectedAreaPathStrings.map(function (path) { return path.split(/[A-Z]/).map(function (point) { return point.split(","); }); }); + expectedAreaPathPoints.forEach(function (areaPathPoint) { return areaPathPoint.shift(); }); + assert.lengthOf(actualAreaPathPoints, expectedAreaPathPoints.length, "number of broken area paths should be equal"); + actualAreaPathPoints.forEach(function (actualAreaPoints, i) { + var expectedAreaPoints = expectedAreaPathPoints[i]; + assert.lengthOf(actualAreaPoints, expectedAreaPoints.length, "number of points in path should be equal"); + actualAreaPoints.forEach(function (actualAreaPoint, j) { + var expectedAreaPoint = expectedAreaPoints[j]; + assert.closeTo(+actualAreaPoint[0], +expectedAreaPoint[0], 0.1, msg); + assert.closeTo(+actualAreaPoint[1], +expectedAreaPoint[1], 0.1, msg); + }); + }); +} /// before(function () { @@ -422,18 +442,26 @@ describe("BaseAxis", function () { /// var assert = chai.assert; describe("TimeAxis", function () { + var scale; + var axis; + beforeEach(function () { + scale = new Plottable.Scale.Time(); + axis = new Plottable.Axis.Time(scale, "bottom"); + }); it("can not initialize vertical time axis", function () { - var scale = new Plottable.Scale.Time(); - assert.throws(function () { return new Plottable.Axis.Time(scale, "left"); }, "unsupported"); - assert.throws(function () { return new Plottable.Axis.Time(scale, "right"); }, "unsupported"); + assert.throws(function () { return new Plottable.Axis.Time(scale, "left"); }, "horizontal"); + assert.throws(function () { return new Plottable.Axis.Time(scale, "right"); }, "horizontal"); + }); + it("cannot change time axis orientation to vertical", function () { + assert.throws(function () { return axis.orient("left"); }, "horizontal"); + assert.throws(function () { return axis.orient("right"); }, "horizontal"); + assert.equal(axis.orient(), "bottom", "orientation unchanged"); }); it("major and minor intervals arrays are the same length", function () { assert.equal(Plottable.Axis.Time._majorIntervals.length, Plottable.Axis.Time._minorIntervals.length, "major and minor interval arrays must be same size"); }); it("Computing the default ticks doesn't error out for edge cases", function () { var svg = generateSVG(400, 100); - var scale = new Plottable.Scale.Time(); - var axis = new Plottable.Axis.Time(scale, "bottom"); scale.range([0, 400]); // very large time span assert.doesNotThrow(function () { return scale.domain([new Date(0, 0, 1, 0, 0, 0, 0), new Date(50000, 0, 1, 0, 0, 0, 0)]); }); @@ -445,9 +473,7 @@ describe("TimeAxis", function () { }); it("Tick labels don't overlap", function () { var svg = generateSVG(400, 100); - var scale = new Plottable.Scale.Time(); scale.range([0, 400]); - var axis = new Plottable.Axis.Time(scale, "bottom"); function checkDomain(domain) { scale.domain(domain); axis.renderTo(svg); @@ -1774,6 +1800,98 @@ describe("Plots", function () { assert.equal(recordedTime, 20, "additionalPaint passed appropriate time argument"); }); }); + describe("Abstract XY Plot", function () { + var svg; + var xScale; + var yScale; + var xAccessor; + var yAccessor; + var simpleDataset; + var plot; + before(function () { + xAccessor = function (d) { return d.a; }; + yAccessor = function (d) { return d.b; }; + }); + beforeEach(function () { + svg = generateSVG(500, 500); + simpleDataset = new Plottable.Dataset([{ a: -5, b: 6 }, { a: -2, b: 2 }, { a: 2, b: -2 }, { a: 5, b: -6 }]); + xScale = new Plottable.Scale.Linear(); + yScale = new Plottable.Scale.Linear(); + plot = new Plottable.Plot.AbstractXYPlot(xScale, yScale); + plot.addDataset(simpleDataset).project("x", xAccessor, xScale).project("y", yAccessor, yScale).renderTo(svg); + }); + it("plot auto domain scale to visible points", function () { + xScale.domain([-3, 3]); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has not been adjusted to visible points"); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "domain has been adjusted to visible points"); + plot.automaticallyAdjustYScaleOverVisiblePoints(false); + plot.automaticallyAdjustXScaleOverVisiblePoints(true); + yScale.domain([-6, 6]); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to visible points"); + svg.remove(); + }); + it("no visible points", function () { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been not been adjusted"); + svg.remove(); + }); + it("automaticallyAdjustYScaleOverVisiblePoints disables autoDomain", function () { + xScale.domain([-2, 2]); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + plot.renderTo(svg); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "domain has been been adjusted"); + svg.remove(); + }); + it("show all data", function () { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + plot.showAllData(); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been adjusted to show all data"); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to show all data"); + svg.remove(); + }); + it("show all data without auto adjust domain", function () { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + xScale.domain([-0.5, 0.5]); + plot.automaticallyAdjustYScaleOverVisiblePoints(false); + plot.showAllData(); + assert.deepEqual(yScale.domain(), [-7, 7], "domain has been adjusted to show all data"); + assert.deepEqual(xScale.domain(), [-6, 6], "domain has been adjusted to show all data"); + svg.remove(); + }); + it("no cycle in auto domain on plot", function () { + var zScale = new Plottable.Scale.Linear().domain([-10, 10]); + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + var plot2 = new Plottable.Plot.AbstractXYPlot(zScale, yScale).automaticallyAdjustXScaleOverVisiblePoints(true).project("x", xAccessor, zScale).project("y", yAccessor, yScale).addDataset(simpleDataset); + var plot3 = new Plottable.Plot.AbstractXYPlot(zScale, xScale).automaticallyAdjustYScaleOverVisiblePoints(true).project("x", xAccessor, zScale).project("y", yAccessor, xScale).addDataset(simpleDataset); + plot2.renderTo(svg); + plot3.renderTo(svg); + xScale.domain([-2, 2]); + assert.deepEqual(yScale.domain(), [-2.5, 2.5], "y domain is adjusted by x domain using custom algorithm and domainer"); + assert.deepEqual(zScale.domain(), [-2.5, 2.5], "z domain is adjusted by y domain using custom algorithm and domainer"); + assert.deepEqual(xScale.domain(), [-2, 2], "x domain is not adjusted using custom algorithm and domainer"); + svg.remove(); + }); + it("listeners are deregistered after removal", function () { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + plot.remove(); + var key2callback = xScale.broadcaster.key2callback; + assert.isUndefined(key2callback.get("yDomainAdjustment" + plot._plottableID), "the plot is no longer attached to the xScale"); + key2callback = yScale.broadcaster.key2callback; + assert.isUndefined(key2callback.get("xDomainAdjustment" + plot._plottableID), "the plot is no longer attached to the yScale"); + svg.remove(); + }); + it("listeners are deregistered for changed scale", function () { + plot.automaticallyAdjustYScaleOverVisiblePoints(true); + var newScale = new Plottable.Scale.Linear().domain([-10, 10]); + plot.project("x", xAccessor, newScale); + xScale.domain([-2, 2]); + assert.deepEqual(yScale.domain(), [-7, 7], "replaced xScale didn't adjust yScale"); + svg.remove(); + }); + }); }); /// @@ -2149,17 +2267,21 @@ describe("Plots", function () { var dataWithNaN = areaData.slice(); dataWithNaN[2] = { foo: 0.4, bar: NaN }; simpleDataset.data(dataWithNaN); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, "area d was set correctly (y=NaN case)"); + var areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (y=NaN case)"); dataWithNaN[2] = { foo: NaN, bar: 0.4 }; simpleDataset.data(dataWithNaN); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, "area d was set correctly (x=NaN case)"); + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (x=NaN case)"); var dataWithUndefined = areaData.slice(); dataWithUndefined[2] = { foo: 0.4, bar: undefined }; simpleDataset.data(dataWithUndefined); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, "area d was set correctly (y=undefined case)"); + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (y=undefined case)"); dataWithUndefined[2] = { foo: undefined, bar: 0.4 }; simpleDataset.data(dataWithUndefined); - assert.strictEqual(normalizePath(areaPath.attr("d")), expectedPath, "area d was set correctly (x=undefined case)"); + areaPathString = normalizePath(areaPath.attr("d")); + assertAreaPathCloseTo(areaPathString, expectedPath, 0.1, "area d was set correctly (x=undefined case)"); svg.remove(); }); }); @@ -2200,12 +2322,12 @@ describe("Plots", function () { assert.lengthOf(bars[0], 3, "One bar was created per data point"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); assert.equal(bar0.attr("height"), "100", "bar0 height is correct"); assert.equal(bar1.attr("height"), "150", "bar1 height is correct"); - assert.equal(bar0.attr("x"), "145", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "445", "bar1 x is correct"); + assert.equal(bar0.attr("x"), "75", "bar0 x is correct"); + assert.equal(bar1.attr("x"), "375", "bar1 x is correct"); assert.equal(bar0.attr("y"), "100", "bar0 y is correct"); assert.equal(bar1.attr("y"), "200", "bar1 y is correct"); var baseline = renderArea.select(".baseline"); @@ -2238,19 +2360,19 @@ describe("Plots", function () { var bars = renderArea.selectAll("rect"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); - assert.equal(bar0.attr("x"), "145", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "445", "bar1 x is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); + assert.equal(numAttr(bar0, "x"), 75, "bar0 x is correct"); + assert.equal(numAttr(bar1, "x"), 375, "bar1 x is correct"); barPlot.barAlignment("right"); renderArea = barPlot._renderArea; bars = renderArea.selectAll("rect"); bar0 = d3.select(bars[0][0]); bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("width"), "10", "bar0 width is correct"); - assert.equal(bar1.attr("width"), "10", "bar1 width is correct"); - assert.equal(bar0.attr("x"), "140", "bar0 x is correct"); - assert.equal(bar1.attr("x"), "440", "bar1 x is correct"); + assert.equal(numAttr(bar0, "width"), 150, "bar0 width is correct"); + assert.equal(numAttr(bar1, "width"), 150, "bar1 width is correct"); + assert.equal(numAttr(bar0, "x"), 0, "bar0 x is correct"); + assert.equal(numAttr(bar1, "x"), 300, "bar1 x is correct"); assert.throws(function () { return barPlot.barAlignment("blargh"); }, Error); assert.equal(barPlot._barAlignmentFactor, 1, "the bad barAlignment didnt break internal state"); svg.remove(); @@ -2299,6 +2421,134 @@ describe("Plots", function () { assert.isNull(brandNew.selectBar(0, 0), "selects return empty after setup"); svg.remove(); }); + it("don't show points from outside of domain", function () { + xScale.domain(["C"]); + var bars = barPlot._renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 0, "no bars have been rendered"); + svg.remove(); + }); + }); + describe("Vertical Bar Plot modified log scale", function () { + var svg; + var dataset; + var xScale; + var yScale; + var barPlot; + var SVG_WIDTH = 600; + var SVG_HEIGHT = 400; + beforeEach(function () { + svg = generateSVG(SVG_WIDTH, SVG_HEIGHT); + xScale = new Plottable.Scale.ModifiedLog(); + yScale = new Plottable.Scale.Linear(); + var data = [ + { x: 2, y: 1 }, + { x: 10, y: -1.5 }, + { x: 100, y: 1 } + ]; + dataset = new Plottable.Dataset(data); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(dataset); + barPlot.animate(false); + barPlot.baseline(0); + yScale.domain([-2, 2]); + barPlot.renderTo(svg); + }); + it("barPixelWidth calculated appropriately", function () { + assert.strictEqual(barPlot._getBarPixelWidth(), (xScale.scale(10) - xScale.scale(2)) * 0.95); + svg.remove(); + }); + it("bar widths are equal to barPixelWidth", function () { + var renderArea = barPlot._renderArea; + var bars = renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 3, "One bar was created per data point"); + var barPixelWidth = barPlot._getBarPixelWidth(); + var bar0 = d3.select(bars[0][0]); + var bar1 = d3.select(bars[0][1]); + var bar2 = d3.select(bars[0][2]); + assert.closeTo(numAttr(bar0, "width"), barPixelWidth, 0.1, "bar0 width is correct"); + assert.closeTo(numAttr(bar1, "width"), barPixelWidth, 0.1, "bar1 width is correct"); + assert.closeTo(numAttr(bar2, "width"), barPixelWidth, 0.1, "bar2 width is correct"); + svg.remove(); + }); + }); + describe("Vertical Bar Plot linear scale", function () { + var svg; + var dataset; + var xScale; + var yScale; + var barPlot; + var SVG_WIDTH = 600; + var SVG_HEIGHT = 400; + beforeEach(function () { + svg = generateSVG(SVG_WIDTH, SVG_HEIGHT); + xScale = new Plottable.Scale.Linear(); + yScale = new Plottable.Scale.Linear(); + var data = [ + { x: 2, y: 1 }, + { x: 10, y: -1.5 }, + { x: 100, y: 1 } + ]; + dataset = new Plottable.Dataset(data); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(dataset); + barPlot.baseline(0); + barPlot.renderTo(svg); + }); + it("bar width takes an appropriate value", function () { + assert.strictEqual(barPlot._getBarPixelWidth(), (xScale.scale(10) - xScale.scale(2)) * 0.95); + svg.remove(); + }); + it("bar widths are equal to barPixelWidth", function () { + var renderArea = barPlot._renderArea; + var bars = renderArea.selectAll("rect"); + assert.lengthOf(bars[0], 3, "One bar was created per data point"); + var barPixelWidth = barPlot._getBarPixelWidth(); + var bar0 = d3.select(bars[0][0]); + var bar1 = d3.select(bars[0][1]); + var bar2 = d3.select(bars[0][2]); + assert.closeTo(numAttr(bar0, "width"), barPixelWidth, 0.1, "bar0 width is correct"); + assert.closeTo(numAttr(bar1, "width"), barPixelWidth, 0.1, "bar1 width is correct"); + assert.closeTo(numAttr(bar2, "width"), barPixelWidth, 0.1, "bar2 width is correct"); + svg.remove(); + }); + it("sensible bar width one datum", function () { + barPlot.removeDataset(dataset); + barPlot.addDataset([{ x: 10, y: 2 }]); + assert.closeTo(barPlot._getBarPixelWidth(), 228, 0.1, "sensible bar width for only one datum"); + svg.remove(); + }); + it("sensible bar width same datum", function () { + barPlot.removeDataset(dataset); + barPlot.addDataset([{ x: 10, y: 2 }, { x: 10, y: 2 }]); + assert.closeTo(barPlot._getBarPixelWidth(), 228, 0.1, "uses the width sensible for one datum"); + svg.remove(); + }); + it("sensible bar width unsorted data", function () { + barPlot.removeDataset(dataset); + barPlot.addDataset([{ x: 2, y: 2 }, { x: 20, y: 2 }, { x: 5, y: 2 }]); + var expectedBarPixelWidth = (xScale.scale(5) - xScale.scale(2)) * 0.95; + assert.closeTo(barPlot._getBarPixelWidth(), expectedBarPixelWidth, 0.1, "bar width uses closest sorted x values"); + svg.remove(); + }); + }); + describe("Vertical Bar Plot time scale", function () { + var svg; + var barPlot; + var xScale; + beforeEach(function () { + svg = generateSVG(600, 400); + var data = [{ x: "12/01/92", y: 0, type: "a" }, { x: "12/01/93", y: 1, type: "a" }, { x: "12/01/94", y: 1, type: "a" }, { x: "12/01/95", y: 2, type: "a" }, { x: "12/01/96", y: 2, type: "a" }, { x: "12/01/97", y: 2, type: "a" }]; + xScale = new Plottable.Scale.Time(); + var yScale = new Plottable.Scale.Linear(); + barPlot = new Plottable.Plot.VerticalBar(xScale, yScale); + barPlot.addDataset(data).project("x", function (d) { return d3.time.format("%m/%d/%y").parse(d.x); }, xScale).project("y", "y", yScale).renderTo(svg); + }); + it("bar width takes an appropriate value", function () { + var timeFormatter = d3.time.format("%m/%d/%y"); + var expectedBarWidth = (xScale.scale(timeFormatter.parse("12/01/94")) - xScale.scale(timeFormatter.parse("12/01/93"))) * 0.95; + assert.closeTo(barPlot._getBarPixelWidth(), expectedBarWidth, 0.1, "width is difference between two dates"); + svg.remove(); + }); }); describe("Horizontal Bar Plot in Points Mode", function () { var svg; @@ -2331,12 +2581,12 @@ describe("Plots", function () { assert.lengthOf(bars[0], 3, "One bar was created per data point"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); assert.equal(bar0.attr("width"), "100", "bar0 width is correct"); assert.equal(bar1.attr("width"), "150", "bar1 width is correct"); - assert.equal(bar0.attr("y"), "295", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "95", "bar1 y is correct"); + assert.equal(bar0.attr("y"), "250", "bar0 y is correct"); + assert.equal(bar1.attr("y"), "50", "bar1 y is correct"); assert.equal(bar0.attr("x"), "300", "bar0 x is correct"); assert.equal(bar1.attr("x"), "150", "bar1 x is correct"); var baseline = renderArea.select(".baseline"); @@ -2369,19 +2619,19 @@ describe("Plots", function () { var bars = renderArea.selectAll("rect"); var bar0 = d3.select(bars[0][0]); var bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); - assert.equal(bar0.attr("y"), "295", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "95", "bar1 y is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); + assert.equal(numAttr(bar0, "y"), 250, "bar0 y is correct"); + assert.equal(numAttr(bar1, "y"), 50, "bar1 y is correct"); barPlot.barAlignment("bottom"); renderArea = barPlot._renderArea; bars = renderArea.selectAll("rect"); bar0 = d3.select(bars[0][0]); bar1 = d3.select(bars[0][1]); - assert.equal(bar0.attr("height"), "10", "bar0 height is correct"); - assert.equal(bar1.attr("height"), "10", "bar1 height is correct"); - assert.equal(bar0.attr("y"), "290", "bar0 y is correct"); - assert.equal(bar1.attr("y"), "90", "bar1 y is correct"); + assert.equal(numAttr(bar0, "height"), 100, "bar0 height is correct"); + assert.equal(numAttr(bar1, "height"), 100, "bar1 height is correct"); + assert.equal(numAttr(bar0, "y"), 200, "bar0 y is correct"); + assert.equal(numAttr(bar1, "y"), 0, "bar1 y is correct"); assert.throws(function () { return barPlot.barAlignment("blargh"); }, Error); svg.remove(); }); @@ -3491,7 +3741,7 @@ describe("Plots", function () { assert.closeTo(numAttr(bar2, "height"), (400 - axisHeight), 0.01, "height is correct for bar2"); assert.closeTo(numAttr(bar3, "height"), (400 - axisHeight) / 2, 0.01, "height is correct for bar3"); // check that clustering is correct - var off = renderer.innerScale.scale("_0"); + var off = renderer.makeInnerScale().scale("_0"); assert.closeTo(numAttr(bar0, "x") + numAttr(bar0, "width") / 2, xScale.scale(bar0X) + bandWidth / 2 - off, 0.01, "x pos correct for bar0"); assert.closeTo(numAttr(bar1, "x") + numAttr(bar1, "width") / 2, xScale.scale(bar1X) + bandWidth / 2 - off, 0.01, "x pos correct for bar1"); assert.closeTo(numAttr(bar2, "x") + numAttr(bar2, "width") / 2, xScale.scale(bar2X) + bandWidth / 2 + off, 0.01, "x pos correct for bar2"); @@ -3555,7 +3805,7 @@ describe("Plots", function () { var bar2Y = bar2.data()[0].y; var bar3Y = bar3.data()[0].y; // check that clustering is correct - var off = renderer.innerScale.scale("_0"); + var off = renderer.makeInnerScale().scale("_0"); assert.closeTo(numAttr(bar0, "y") + numAttr(bar0, "height") / 2, yScale.scale(bar0Y) + bandWidth / 2 - off, 0.01, "y pos correct for bar0"); assert.closeTo(numAttr(bar1, "y") + numAttr(bar1, "height") / 2, yScale.scale(bar1Y) + bandWidth / 2 - off, 0.01, "y pos correct for bar1"); assert.closeTo(numAttr(bar2, "y") + numAttr(bar2, "height") / 2, yScale.scale(bar2Y) + bandWidth / 2 + off, 0.01, "y pos correct for bar2"); @@ -4262,6 +4512,62 @@ describe("Component behavior", function () { assert.deepEqual(transform.translate, [0, 0], "the element was not translated"); svg.remove(); }); + describe("resizeBroadcaster testing", function () { + var oldRegister; + var oldDeregister; + var registeredComponents; + var id; + before(function () { + oldRegister = Plottable.Core.ResizeBroadcaster.register; + oldDeregister = Plottable.Core.ResizeBroadcaster.deregister; + var mockRegister = function (c) { + registeredComponents.add(c._plottableID); + }; + var mockDeregister = function (c) { + registeredComponents.remove(c._plottableID); + }; + Plottable.Core.ResizeBroadcaster.register = mockRegister; + Plottable.Core.ResizeBroadcaster.deregister = mockDeregister; + }); + after(function () { + Plottable.Core.ResizeBroadcaster.register = oldRegister; + Plottable.Core.ResizeBroadcaster.deregister = oldDeregister; + }); + beforeEach(function () { + registeredComponents = d3.set(); + id = c._plottableID; + }); + afterEach(function () { + svg.remove(); // svg contains no useful info + }); + it("components can be removed from resizeBroadcaster before rendering", function () { + c.autoResize(false); + c.renderTo(svg); + assert.isFalse(registeredComponents.has(id), "component not registered to broadcaster"); + }); + it("components register by default", function () { + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + }); + it("component can be deregistered then registered before render", function () { + c.autoResize(false); + c.autoResize(true); + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + }); + it("component can be deregistered after rendering", function () { + c.renderTo(svg); + c.autoResize(false); + assert.isFalse(registeredComponents.has(id), "component was deregistered after rendering"); + }); + it("calling .remove deregisters a component", function () { + c.autoResize(true); + c.renderTo(svg); + assert.isTrue(registeredComponents.has(id), "component is registered"); + c.remove(); + assert.isFalse(registeredComponents.has(id), "component is deregistered after removal"); + }); + }); }); /// @@ -4600,7 +4906,8 @@ describe("Domainer", function () { it("pad() works in general case", function () { scale._updateExtent("1", "x", [100, 200]); scale.domainer(new Plottable.Domainer().pad(0.2)); - assert.deepEqual(scale.domain(), [90, 210]); + assert.closeTo(scale.domain()[0], 90, 0.1, "lower bound of domain correct"); + assert.closeTo(scale.domain()[1], 210, 0.1, "upper bound of domain correct"); }); it("pad() works for date scales", function () { var timeScale = new Plottable.Scale.Time(); @@ -4877,10 +5184,12 @@ describe("Scales", function () { assert.isTrue(scale._autoDomainAutomatically, "autoDomain enabled3"); scale._removeExtent("1", "x"); assert.isTrue(scale._autoDomainAutomatically, "autoDomain enabled4"); - assert.deepEqual(scale.domain(), [-20, 1], "only the bar accessor is active"); + assert.closeTo(scale.domain()[0], -20, 0.1, "only the bar accessor is active"); + assert.closeTo(scale.domain()[1], 1, 0.1, "only the bar accessor is active"); scale._updateExtent("2", "x", d3.extent(data, function (e) { return e.foo; })); assert.isTrue(scale._autoDomainAutomatically, "autoDomain enabled5"); - assert.deepEqual(scale.domain(), [0, 5], "the bar accessor was overwritten"); + assert.closeTo(scale.domain()[0], 0, 0.1, "the bar accessor was overwritten"); + assert.closeTo(scale.domain()[1], 5, 0.1, "the bar accessor was overwritten"); }); it("should resize when a plot is removed", function () { var svg = generateSVG(400, 400); @@ -5282,6 +5591,28 @@ describe("Tick generators", function () { assert.throws(function () { return Plottable.Scale.TickGenerators.intervalTickGenerator(-2); }, "interval must be positive number"); }); }); + describe("integer", function () { + it("normal case", function () { + var scale = new Plottable.Scale.Linear().domain([0, 4]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [0, 1, 2, 3, 4], "only the integers are returned"); + }); + it("works across negative numbers", function () { + var scale = new Plottable.Scale.Linear().domain([-2, 1]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [-2, -1, 0, 1], "only the integers are returned"); + }); + it("includes endticks", function () { + var scale = new Plottable.Scale.Linear().domain([-2.7, 1.5]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [-2.5, -2, -1, 0, 1, 1.5], "end ticks are included"); + }); + it("all float ticks", function () { + var scale = new Plottable.Scale.Linear().domain([1.1, 1.5]); + var ticks = Plottable.Scale.TickGenerators.integerTickGenerator()(scale); + assert.deepEqual(ticks, [1.1, 1.5], "only the end ticks are returned"); + }); + }); }); /// @@ -5374,8 +5705,8 @@ describe("Formatters", function () { assert.strictEqual(result, "1.000", "defaults to three decimal places"); result = fixed3(1.234); assert.strictEqual(result, "1.234", "shows three decimal places"); - result = fixed3(1.2345); - assert.strictEqual(result, "", "changed values are not shown (get turned into empty strings)"); + result = fixed3(1.2346); + assert.strictEqual(result, "1.235", "changed values are not shown (get turned into empty strings)"); }); it("precision can be changed", function () { var fixed2 = Plottable.Formatters.fixed(2); @@ -5383,7 +5714,7 @@ describe("Formatters", function () { assert.strictEqual(result, "1.00", "formatter was changed to show only two decimal places"); }); it("can be set to show rounded values", function () { - var fixed3 = Plottable.Formatters.fixed(3, false); + var fixed3 = Plottable.Formatters.fixed(3); var result = fixed3(1.2349); assert.strictEqual(result, "1.235", "long values are rounded correctly"); }); @@ -5396,7 +5727,7 @@ describe("Formatters", function () { result = general(1.234); assert.strictEqual(result, "1.234", "shows up to three decimal places"); result = general(1.2345); - assert.strictEqual(result, "", "(changed) values with more than three decimal places are not shown"); + assert.strictEqual(result, "1.235", "(changed) values with more than three decimal places are not shown"); }); it("stringifies non-number values", function () { var general = Plottable.Formatters.general(); @@ -5481,7 +5812,7 @@ describe("Formatters", function () { assert.strictEqual(result2, "0.35%", "works even if multiplying by 100 does not make it an integer"); }); it("onlyShowUnchanged set to false", function () { - var percentFormatter = Plottable.Formatters.percentage(0, false); + var percentFormatter = Plottable.Formatters.percentage(0); var result = percentFormatter(0.075); assert.strictEqual(result, "8%", "shows formatter changed value"); }); @@ -6330,31 +6661,29 @@ describe("Interactions", function () { }); }); describe("KeyInteraction", function () { - it("Triggers the callback only when the Component is moused over and appropriate key is pressed", function () { + it("Triggers appropriate callback for the key pressed", function () { var svg = generateSVG(400, 400); - // svg.attr("id", "key-interaction-test"); var component = new Plottable.Component.AbstractComponent(); component.renderTo(svg); - var code = 65; // "a" key - var ki = new Plottable.Interaction.Key(code); - var callbackCalled = false; - var callback = function () { - callbackCalled = true; - }; - ki.callback(callback); + var ki = new Plottable.Interaction.Key(); + var aCode = 65; // "a" key + var bCode = 66; // "b" key + var aCallbackCalled = false; + var aCallback = function () { return aCallbackCalled = true; }; + var bCallbackCalled = false; + var bCallback = function () { return bCallbackCalled = true; }; + ki.on(aCode, aCallback); + ki.on(bCode, bCallback); component.registerInteraction(ki); var $hitbox = $(component.hitBox.node()); - $hitbox.simulate("keydown", { keyCode: code }); - assert.isFalse(callbackCalled, "callback is not called if component does not have mouse focus (before mouseover)"); $hitbox.simulate("mouseover"); - $hitbox.simulate("keydown", { keyCode: code }); - assert.isTrue(callbackCalled, "callback gets called if the appropriate key is pressed while the component has mouse focus"); - callbackCalled = false; - $hitbox.simulate("keydown", { keyCode: (code + 1) }); - assert.isFalse(callbackCalled, "callback is not called if the wrong key is pressed"); - $hitbox.simulate("mouseout"); - $hitbox.simulate("keydown", { keyCode: code }); - assert.isFalse(callbackCalled, "callback is not called if component does not have mouse focus (after mouseout)"); + $hitbox.simulate("keydown", { keyCode: aCode }); + assert.isTrue(aCallbackCalled, "callback for \"a\" was called when \"a\" key was pressed"); + assert.isFalse(bCallbackCalled, "callback for \"b\" was not called when \"a\" key was pressed"); + aCallbackCalled = false; + $hitbox.simulate("keydown", { keyCode: bCode }); + assert.isFalse(aCallbackCalled, "callback for \"a\" was not called when \"b\" key was pressed"); + assert.isTrue(bCallbackCalled, "callback for \"b\" was called when \"b\" key was pressed"); svg.remove(); }); }); @@ -6472,6 +6801,8 @@ var TestHoverable = (function (_super) { __extends(TestHoverable, _super); function TestHoverable() { _super.apply(this, arguments); + this.leftPoint = { x: 100, y: 200 }; + this.rightPoint = { x: 300, y: 200 }; } TestHoverable.prototype._hoverOverComponent = function (p) { // cast-override @@ -6481,14 +6812,18 @@ var TestHoverable = (function (_super) { }; TestHoverable.prototype._doHover = function (p) { var data = []; + var points = []; if (p.x < 250) { data.push("left"); + points.push(this.leftPoint); } if (p.x > 150) { data.push("right"); + points.push(this.rightPoint); } return { data: data, + pixelPositions: points, selection: this._element }; }; @@ -6527,6 +6862,7 @@ describe("Interactions", function () { overCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 100, 200); assert.isTrue(overCallbackCalled, "onHoverOver was called on mousing over a target area"); + assert.deepEqual(overData.pixelPositions, [testTarget.leftPoint], "onHoverOver was called with the correct pixel position (mouse onto left)"); assert.deepEqual(overData.data, ["left"], "onHoverOver was called with the correct data (mouse onto left)"); overCallbackCalled = false; triggerFakeMouseEvent("mousemove", hitbox, 100, 200); @@ -6534,10 +6870,12 @@ describe("Interactions", function () { overCallbackCalled = false; triggerFakeMouseEvent("mousemove", hitbox, 200, 200); assert.isTrue(overCallbackCalled, "onHoverOver was called when mousing into a new region"); + assert.deepEqual(overData.pixelPositions, [testTarget.rightPoint], "onHoverOver was called with the correct pixel position (left --> center)"); assert.deepEqual(overData.data, ["right"], "onHoverOver was called with the new data only (left --> center)"); triggerFakeMouseEvent("mouseout", hitbox, 400, 200); overCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 200, 200); + assert.deepEqual(overData.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], "onHoverOver was called with the correct pixel positions"); assert.deepEqual(overData.data, ["left", "right"], "onHoverOver is called with the correct data"); svg.remove(); }); @@ -6549,23 +6887,28 @@ describe("Interactions", function () { outCallbackCalled = false; triggerFakeMouseEvent("mousemove", hitbox, 300, 200); assert.isTrue(outCallbackCalled, "onHoverOut was called when the hover data changes"); + assert.deepEqual(outData.pixelPositions, [testTarget.leftPoint], "onHoverOut was called with the correct pixel position (center --> right)"); assert.deepEqual(outData.data, ["left"], "onHoverOut was called with the correct data (center --> right)"); outCallbackCalled = false; triggerFakeMouseEvent("mouseout", hitbox, 400, 200); assert.isTrue(outCallbackCalled, "onHoverOut is called on mousing out of the Component"); + assert.deepEqual(outData.pixelPositions, [testTarget.rightPoint], "onHoverOut was called with the correct pixel position"); assert.deepEqual(outData.data, ["right"], "onHoverOut was called with the correct data"); outCallbackCalled = false; triggerFakeMouseEvent("mouseover", hitbox, 200, 200); triggerFakeMouseEvent("mouseout", hitbox, 200, 400); + assert.deepEqual(outData.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], "onHoverOut was called with the correct pixel positions"); assert.deepEqual(outData.data, ["left", "right"], "onHoverOut is called with the correct data"); svg.remove(); }); it("getCurrentHoverData()", function () { triggerFakeMouseEvent("mouseover", hitbox, 100, 200); var currentlyHovered = hoverInteraction.getCurrentHoverData(); + assert.deepEqual(currentlyHovered.pixelPositions, [testTarget.leftPoint], "retrieves pixel positions corresponding to the current position"); assert.deepEqual(currentlyHovered.data, ["left"], "retrieves data corresponding to the current position"); triggerFakeMouseEvent("mousemove", hitbox, 200, 200); currentlyHovered = hoverInteraction.getCurrentHoverData(); + assert.deepEqual(currentlyHovered.pixelPositions, [testTarget.leftPoint, testTarget.rightPoint], "retrieves pixel positions corresponding to the current position"); assert.deepEqual(currentlyHovered.data, ["left", "right"], "retrieves data corresponding to the current position"); triggerFakeMouseEvent("mouseout", hitbox, 400, 200); currentlyHovered = hoverInteraction.getCurrentHoverData(); @@ -6676,4 +7019,29 @@ describe("Dispatchers", function () { target.remove(); }); }); + describe("Keypress Dispatcher", function () { + it("triggers the callback only when moused over the target", function () { + var target = generateSVG(400, 400); + var kpd = new Plottable.Dispatcher.Keypress(target); + var keyDownCalled = false; + var lastKeyCode; + kpd.onKeyDown(function (e) { + keyDownCalled = true; + lastKeyCode = e.keyCode; + }); + kpd.connect(); + var $target = $(target.node()); + $target.simulate("keydown", { keyCode: 80 }); + assert.isFalse(keyDownCalled, "didn't trigger callback if not moused over the target"); + $target.simulate("mouseover"); + $target.simulate("keydown", { keyCode: 80 }); + assert.isTrue(keyDownCalled, "correctly triggers callback if moused over the target"); + assert.strictEqual(lastKeyCode, 80, "correct event info was passed to the callback"); + keyDownCalled = false; + $target.simulate("mouseout"); + $target.simulate("keydown", { keyCode: 80 }); + assert.isFalse(keyDownCalled, "didn't trigger callback after mousing out of the target"); + target.remove(); + }); + }); }); diff --git a/test/utils/formattersTests.ts b/test/utils/formattersTests.ts index aa4a3191d0..db41985015 100644 --- a/test/utils/formattersTests.ts +++ b/test/utils/formattersTests.ts @@ -10,8 +10,8 @@ describe("Formatters", () => { assert.strictEqual(result, "1.000", "defaults to three decimal places"); result = fixed3(1.234); assert.strictEqual(result, "1.234", "shows three decimal places"); - result = fixed3(1.2345); - assert.strictEqual(result, "", "changed values are not shown (get turned into empty strings)"); + result = fixed3(1.2346); + assert.strictEqual(result, "1.235", "changed values are not shown (get turned into empty strings)"); }); it("precision can be changed", () => { @@ -21,7 +21,7 @@ describe("Formatters", () => { }); it("can be set to show rounded values", () => { - var fixed3 = Plottable.Formatters.fixed(3, false); + var fixed3 = Plottable.Formatters.fixed(3); var result = fixed3(1.2349); assert.strictEqual(result, "1.235", "long values are rounded correctly"); }); @@ -35,7 +35,7 @@ describe("Formatters", () => { result = general(1.234); assert.strictEqual(result, "1.234", "shows up to three decimal places"); result = general(1.2345); - assert.strictEqual(result, "", "(changed) values with more than three decimal places are not shown"); + assert.strictEqual(result, "1.235", "(changed) values with more than three decimal places are not shown"); }); it("stringifies non-number values", () => { @@ -131,7 +131,7 @@ describe("Formatters", () => { }); it("onlyShowUnchanged set to false", ()=> { - var percentFormatter = Plottable.Formatters.percentage(0, false); + var percentFormatter = Plottable.Formatters.percentage(0); var result = percentFormatter(0.075); assert.strictEqual(result, "8%", "shows formatter changed value"); }); diff --git a/typings/d3/d3.d.ts b/typings/d3/d3.d.ts index 92a2d253a1..5ede764b67 100644 --- a/typings/d3/d3.d.ts +++ b/typings/d3/d3.d.ts @@ -233,6 +233,13 @@ declare module D3 { */ transpose(matrix: any[]): any[]; /** + * Creates an array containing tuples of adjacent pairs + * + * @param arr An array containing entries to pair + * @returns any[][] An array of 2-element tuples for each pair + */ + pairs(arr: any[]): any[][]; + /** * List the keys of an associative array. * * @param map Array of objects to get the key values from