{ "version": 3, "sources": ["../../../node_modules/d3/d3.js", "../../../node_modules/nvd3/src/core.js", "../../../node_modules/nvd3/src/dom.js", "../../../node_modules/nvd3/src/interactiveLayer.js", "../../../node_modules/nvd3/src/tooltip.js", "../../../node_modules/nvd3/src/utils.js", "../../../node_modules/nvd3/src/models/axis.js", "../../../node_modules/nvd3/src/models/boxPlot.js", "../../../node_modules/nvd3/src/models/boxPlotChart.js", "../../../node_modules/nvd3/src/models/bullet.js", "../../../node_modules/nvd3/src/models/bulletChart.js", "../../../node_modules/nvd3/src/models/candlestickBar.js", "../../../node_modules/nvd3/src/models/cumulativeLineChart.js", "../../../node_modules/nvd3/src/models/discreteBar.js", "../../../node_modules/nvd3/src/models/discreteBarChart.js", "../../../node_modules/nvd3/src/models/distribution.js", "../../../node_modules/nvd3/src/models/focus.js", "../../../node_modules/nvd3/src/models/forceDirectedGraph.js", "../../../node_modules/nvd3/src/models/furiousLegend.js", "../../../node_modules/nvd3/src/models/historicalBar.js", "../../../node_modules/nvd3/src/models/historicalBarChart.js", "../../../node_modules/nvd3/src/models/legend.js", "../../../node_modules/nvd3/src/models/line.js", "../../../node_modules/nvd3/src/models/lineChart.js", "../../../node_modules/nvd3/src/models/linePlusBarChart.js", "../../../node_modules/nvd3/src/models/multiBar.js", "../../../node_modules/nvd3/src/models/multiBarChart.js", "../../../node_modules/nvd3/src/models/multiBarHorizontal.js", "../../../node_modules/nvd3/src/models/multiBarHorizontalChart.js", "../../../node_modules/nvd3/src/models/multiChart.js", "../../../node_modules/nvd3/src/models/ohlcBar.js", "../../../node_modules/nvd3/src/models/parallelCoordinates.js", "../../../node_modules/nvd3/src/models/parallelCoordinatesChart.js", "../../../node_modules/nvd3/src/models/pie.js", "../../../node_modules/nvd3/src/models/pieChart.js", "../../../node_modules/nvd3/src/models/sankey.js", "../../../node_modules/nvd3/src/models/sankeyChart.js", "../../../node_modules/nvd3/src/models/scatter.js", "../../../node_modules/nvd3/src/models/scatterChart.js", "../../../node_modules/nvd3/src/models/sparkline.js", "../../../node_modules/nvd3/src/models/sparklinePlus.js", "../../../node_modules/nvd3/src/models/stackedArea.js", "../../../node_modules/nvd3/src/models/stackedAreaChart.js", "../../../node_modules/nvd3/src/models/sunburst.js", "../../../node_modules/nvd3/src/models/sunburstChart.js", "../../../node_modules/@popperjs/core/lib/index.js", "../../../node_modules/@popperjs/core/lib/enums.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js", "../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js", "../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js", "../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js", "../../../node_modules/@popperjs/core/lib/utils/math.js", "../../../node_modules/@popperjs/core/lib/utils/userAgent.js", "../../../node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js", "../../../node_modules/@popperjs/core/lib/dom-utils/contains.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js", "../../../node_modules/@popperjs/core/lib/dom-utils/isTableElement.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getParentNode.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js", "../../../node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js", "../../../node_modules/@popperjs/core/lib/utils/within.js", "../../../node_modules/@popperjs/core/lib/utils/getFreshSideObject.js", "../../../node_modules/@popperjs/core/lib/utils/mergePaddingObject.js", "../../../node_modules/@popperjs/core/lib/utils/expandToHashMap.js", "../../../node_modules/@popperjs/core/lib/modifiers/arrow.js", "../../../node_modules/@popperjs/core/lib/utils/getVariation.js", "../../../node_modules/@popperjs/core/lib/modifiers/computeStyles.js", "../../../node_modules/@popperjs/core/lib/modifiers/eventListeners.js", "../../../node_modules/@popperjs/core/lib/utils/getOppositePlacement.js", "../../../node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js", "../../../node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js", "../../../node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js", "../../../node_modules/@popperjs/core/lib/utils/rectToClientRect.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js", "../../../node_modules/@popperjs/core/lib/utils/computeOffsets.js", "../../../node_modules/@popperjs/core/lib/utils/detectOverflow.js", "../../../node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js", "../../../node_modules/@popperjs/core/lib/modifiers/flip.js", "../../../node_modules/@popperjs/core/lib/modifiers/hide.js", "../../../node_modules/@popperjs/core/lib/modifiers/offset.js", "../../../node_modules/@popperjs/core/lib/modifiers/popperOffsets.js", "../../../node_modules/@popperjs/core/lib/utils/getAltAxis.js", "../../../node_modules/@popperjs/core/lib/modifiers/preventOverflow.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js", "../../../node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js", "../../../node_modules/@popperjs/core/lib/utils/orderModifiers.js", "../../../node_modules/@popperjs/core/lib/utils/debounce.js", "../../../node_modules/@popperjs/core/lib/utils/mergeByName.js", "../../../node_modules/@popperjs/core/lib/createPopper.js", "../../../node_modules/@popperjs/core/lib/popper-lite.js", "../../../node_modules/@popperjs/core/lib/popper.js", "../../../node_modules/bootstrap/js/src/dom/data.js", "../../../node_modules/bootstrap/js/src/util/index.js", "../../../node_modules/bootstrap/js/src/dom/event-handler.js", "../../../node_modules/bootstrap/js/src/dom/manipulator.js", "../../../node_modules/bootstrap/js/src/util/config.js", "../../../node_modules/bootstrap/js/src/base-component.js", "../../../node_modules/bootstrap/js/src/dom/selector-engine.js", "../../../node_modules/bootstrap/js/src/util/component-functions.js", "../../../node_modules/bootstrap/js/src/alert.js", "../../../node_modules/bootstrap/js/src/button.js", "../../../node_modules/bootstrap/js/src/util/swipe.js", "../../../node_modules/bootstrap/js/src/carousel.js", "../../../node_modules/bootstrap/js/src/collapse.js", "../../../node_modules/bootstrap/js/src/dropdown.js", "../../../node_modules/bootstrap/js/src/util/backdrop.js", "../../../node_modules/bootstrap/js/src/util/focustrap.js", "../../../node_modules/bootstrap/js/src/util/scrollbar.js", "../../../node_modules/bootstrap/js/src/modal.js", "../../../node_modules/bootstrap/js/src/offcanvas.js", "../../../node_modules/bootstrap/js/src/util/sanitizer.js", "../../../node_modules/bootstrap/js/src/util/template-factory.js", "../../../node_modules/bootstrap/js/src/tooltip.js", "../../../node_modules/bootstrap/js/src/popover.js", "../../../node_modules/bootstrap/js/src/scrollspy.js", "../../../node_modules/bootstrap/js/src/tab.js", "../../../node_modules/bootstrap/js/src/toast.js", "../../javascript/application.js", "../../javascript/src/js/chart.js"], "sourcesContent": ["!function() {\n var d3 = {\n version: \"3.5.17\"\n };\n var d3_arraySlice = [].slice, d3_array = function(list) {\n return d3_arraySlice.call(list);\n };\n var d3_document = this.document;\n function d3_documentElement(node) {\n return node && (node.ownerDocument || node.document || node).documentElement;\n }\n function d3_window(node) {\n return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView);\n }\n if (d3_document) {\n try {\n d3_array(d3_document.documentElement.childNodes)[0].nodeType;\n } catch (e) {\n d3_array = function(list) {\n var i = list.length, array = new Array(i);\n while (i--) array[i] = list[i];\n return array;\n };\n }\n }\n if (!Date.now) Date.now = function() {\n return +new Date();\n };\n if (d3_document) {\n try {\n d3_document.createElement(\"DIV\").style.setProperty(\"opacity\", 0, \"\");\n } catch (error) {\n var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = this.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;\n d3_element_prototype.setAttribute = function(name, value) {\n d3_element_setAttribute.call(this, name, value + \"\");\n };\n d3_element_prototype.setAttributeNS = function(space, local, value) {\n d3_element_setAttributeNS.call(this, space, local, value + \"\");\n };\n d3_style_prototype.setProperty = function(name, value, priority) {\n d3_style_setProperty.call(this, name, value + \"\", priority);\n };\n }\n }\n d3.ascending = d3_ascending;\n function d3_ascending(a, b) {\n return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;\n }\n d3.descending = function(a, b) {\n return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n };\n d3.min = function(array, f) {\n var i = -1, n = array.length, a, b;\n if (arguments.length === 1) {\n while (++i < n) if ((b = array[i]) != null && b >= b) {\n a = b;\n break;\n }\n while (++i < n) if ((b = array[i]) != null && a > b) a = b;\n } else {\n while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n a = b;\n break;\n }\n while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;\n }\n return a;\n };\n d3.max = function(array, f) {\n var i = -1, n = array.length, a, b;\n if (arguments.length === 1) {\n while (++i < n) if ((b = array[i]) != null && b >= b) {\n a = b;\n break;\n }\n while (++i < n) if ((b = array[i]) != null && b > a) a = b;\n } else {\n while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n a = b;\n break;\n }\n while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;\n }\n return a;\n };\n d3.extent = function(array, f) {\n var i = -1, n = array.length, a, b, c;\n if (arguments.length === 1) {\n while (++i < n) if ((b = array[i]) != null && b >= b) {\n a = c = b;\n break;\n }\n while (++i < n) if ((b = array[i]) != null) {\n if (a > b) a = b;\n if (c < b) c = b;\n }\n } else {\n while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n a = c = b;\n break;\n }\n while (++i < n) if ((b = f.call(array, array[i], i)) != null) {\n if (a > b) a = b;\n if (c < b) c = b;\n }\n }\n return [ a, c ];\n };\n function d3_number(x) {\n return x === null ? NaN : +x;\n }\n function d3_numeric(x) {\n return !isNaN(x);\n }\n d3.sum = function(array, f) {\n var s = 0, n = array.length, a, i = -1;\n if (arguments.length === 1) {\n while (++i < n) if (d3_numeric(a = +array[i])) s += a;\n } else {\n while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;\n }\n return s;\n };\n d3.mean = function(array, f) {\n var s = 0, n = array.length, a, i = -1, j = n;\n if (arguments.length === 1) {\n while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;\n } else {\n while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;\n }\n if (j) return s / j;\n };\n d3.quantile = function(values, p) {\n var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;\n return e ? v + e * (values[h] - v) : v;\n };\n d3.median = function(array, f) {\n var numbers = [], n = array.length, a, i = -1;\n if (arguments.length === 1) {\n while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);\n } else {\n while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);\n }\n if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);\n };\n d3.variance = function(array, f) {\n var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;\n if (arguments.length === 1) {\n while (++i < n) {\n if (d3_numeric(a = d3_number(array[i]))) {\n d = a - m;\n m += d / ++j;\n s += d * (a - m);\n }\n }\n } else {\n while (++i < n) {\n if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {\n d = a - m;\n m += d / ++j;\n s += d * (a - m);\n }\n }\n }\n if (j > 1) return s / (j - 1);\n };\n d3.deviation = function() {\n var v = d3.variance.apply(this, arguments);\n return v ? Math.sqrt(v) : v;\n };\n function d3_bisector(compare) {\n return {\n left: function(a, x, lo, hi) {\n if (arguments.length < 3) lo = 0;\n if (arguments.length < 4) hi = a.length;\n while (lo < hi) {\n var mid = lo + hi >>> 1;\n if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;\n }\n return lo;\n },\n right: function(a, x, lo, hi) {\n if (arguments.length < 3) lo = 0;\n if (arguments.length < 4) hi = a.length;\n while (lo < hi) {\n var mid = lo + hi >>> 1;\n if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;\n }\n return lo;\n }\n };\n }\n var d3_bisect = d3_bisector(d3_ascending);\n d3.bisectLeft = d3_bisect.left;\n d3.bisect = d3.bisectRight = d3_bisect.right;\n d3.bisector = function(f) {\n return d3_bisector(f.length === 1 ? function(d, x) {\n return d3_ascending(f(d), x);\n } : f);\n };\n d3.shuffle = function(array, i0, i1) {\n if ((m = arguments.length) < 3) {\n i1 = array.length;\n if (m < 2) i0 = 0;\n }\n var m = i1 - i0, t, i;\n while (m) {\n i = Math.random() * m-- | 0;\n t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;\n }\n return array;\n };\n d3.permute = function(array, indexes) {\n var i = indexes.length, permutes = new Array(i);\n while (i--) permutes[i] = array[indexes[i]];\n return permutes;\n };\n d3.pairs = function(array) {\n var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);\n while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];\n return pairs;\n };\n d3.transpose = function(matrix) {\n if (!(n = matrix.length)) return [];\n for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) {\n for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) {\n row[j] = matrix[j][i];\n }\n }\n return transpose;\n };\n function d3_transposeLength(d) {\n return d.length;\n }\n d3.zip = function() {\n return d3.transpose(arguments);\n };\n d3.keys = function(map) {\n var keys = [];\n for (var key in map) keys.push(key);\n return keys;\n };\n d3.values = function(map) {\n var values = [];\n for (var key in map) values.push(map[key]);\n return values;\n };\n d3.entries = function(map) {\n var entries = [];\n for (var key in map) entries.push({\n key: key,\n value: map[key]\n });\n return entries;\n };\n d3.merge = function(arrays) {\n var n = arrays.length, m, i = -1, j = 0, merged, array;\n while (++i < n) j += arrays[i].length;\n merged = new Array(j);\n while (--n >= 0) {\n array = arrays[n];\n m = array.length;\n while (--m >= 0) {\n merged[--j] = array[m];\n }\n }\n return merged;\n };\n var abs = Math.abs;\n d3.range = function(start, stop, step) {\n if (arguments.length < 3) {\n step = 1;\n if (arguments.length < 2) {\n stop = start;\n start = 0;\n }\n }\n if ((stop - start) / step === Infinity) throw new Error(\"infinite range\");\n var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;\n start *= k, stop *= k, step *= k;\n if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);\n return range;\n };\n function d3_range_integerScale(x) {\n var k = 1;\n while (x * k % 1) k *= 10;\n return k;\n }\n function d3_class(ctor, properties) {\n for (var key in properties) {\n Object.defineProperty(ctor.prototype, key, {\n value: properties[key],\n enumerable: false\n });\n }\n }\n d3.map = function(object, f) {\n var map = new d3_Map();\n if (object instanceof d3_Map) {\n object.forEach(function(key, value) {\n map.set(key, value);\n });\n } else if (Array.isArray(object)) {\n var i = -1, n = object.length, o;\n if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o);\n } else {\n for (var key in object) map.set(key, object[key]);\n }\n return map;\n };\n function d3_Map() {\n this._ = Object.create(null);\n }\n var d3_map_proto = \"__proto__\", d3_map_zero = \"\\x00\";\n d3_class(d3_Map, {\n has: d3_map_has,\n get: function(key) {\n return this._[d3_map_escape(key)];\n },\n set: function(key, value) {\n return this._[d3_map_escape(key)] = value;\n },\n remove: d3_map_remove,\n keys: d3_map_keys,\n values: function() {\n var values = [];\n for (var key in this._) values.push(this._[key]);\n return values;\n },\n entries: function() {\n var entries = [];\n for (var key in this._) entries.push({\n key: d3_map_unescape(key),\n value: this._[key]\n });\n return entries;\n },\n size: d3_map_size,\n empty: d3_map_empty,\n forEach: function(f) {\n for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);\n }\n });\n function d3_map_escape(key) {\n return (key += \"\") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;\n }\n function d3_map_unescape(key) {\n return (key += \"\")[0] === d3_map_zero ? key.slice(1) : key;\n }\n function d3_map_has(key) {\n return d3_map_escape(key) in this._;\n }\n function d3_map_remove(key) {\n return (key = d3_map_escape(key)) in this._ && delete this._[key];\n }\n function d3_map_keys() {\n var keys = [];\n for (var key in this._) keys.push(d3_map_unescape(key));\n return keys;\n }\n function d3_map_size() {\n var size = 0;\n for (var key in this._) ++size;\n return size;\n }\n function d3_map_empty() {\n for (var key in this._) return false;\n return true;\n }\n d3.nest = function() {\n var nest = {}, keys = [], sortKeys = [], sortValues, rollup;\n function map(mapType, array, depth) {\n if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;\n var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;\n while (++i < n) {\n if (values = valuesByKey.get(keyValue = key(object = array[i]))) {\n values.push(object);\n } else {\n valuesByKey.set(keyValue, [ object ]);\n }\n }\n if (mapType) {\n object = mapType();\n setter = function(keyValue, values) {\n object.set(keyValue, map(mapType, values, depth));\n };\n } else {\n object = {};\n setter = function(keyValue, values) {\n object[keyValue] = map(mapType, values, depth);\n };\n }\n valuesByKey.forEach(setter);\n return object;\n }\n function entries(map, depth) {\n if (depth >= keys.length) return map;\n var array = [], sortKey = sortKeys[depth++];\n map.forEach(function(key, keyMap) {\n array.push({\n key: key,\n values: entries(keyMap, depth)\n });\n });\n return sortKey ? array.sort(function(a, b) {\n return sortKey(a.key, b.key);\n }) : array;\n }\n nest.map = function(array, mapType) {\n return map(mapType, array, 0);\n };\n nest.entries = function(array) {\n return entries(map(d3.map, array, 0), 0);\n };\n nest.key = function(d) {\n keys.push(d);\n return nest;\n };\n nest.sortKeys = function(order) {\n sortKeys[keys.length - 1] = order;\n return nest;\n };\n nest.sortValues = function(order) {\n sortValues = order;\n return nest;\n };\n nest.rollup = function(f) {\n rollup = f;\n return nest;\n };\n return nest;\n };\n d3.set = function(array) {\n var set = new d3_Set();\n if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);\n return set;\n };\n function d3_Set() {\n this._ = Object.create(null);\n }\n d3_class(d3_Set, {\n has: d3_map_has,\n add: function(key) {\n this._[d3_map_escape(key += \"\")] = true;\n return key;\n },\n remove: d3_map_remove,\n values: d3_map_keys,\n size: d3_map_size,\n empty: d3_map_empty,\n forEach: function(f) {\n for (var key in this._) f.call(this, d3_map_unescape(key));\n }\n });\n d3.behavior = {};\n function d3_identity(d) {\n return d;\n }\n d3.rebind = function(target, source) {\n var i = 1, n = arguments.length, method;\n while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);\n return target;\n };\n function d3_rebind(target, source, method) {\n return function() {\n var value = method.apply(source, arguments);\n return value === source ? target : value;\n };\n }\n function d3_vendorSymbol(object, name) {\n if (name in object) return name;\n name = name.charAt(0).toUpperCase() + name.slice(1);\n for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {\n var prefixName = d3_vendorPrefixes[i] + name;\n if (prefixName in object) return prefixName;\n }\n }\n var d3_vendorPrefixes = [ \"webkit\", \"ms\", \"moz\", \"Moz\", \"o\", \"O\" ];\n function d3_noop() {}\n d3.dispatch = function() {\n var dispatch = new d3_dispatch(), i = -1, n = arguments.length;\n while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n return dispatch;\n };\n function d3_dispatch() {}\n d3_dispatch.prototype.on = function(type, listener) {\n var i = type.indexOf(\".\"), name = \"\";\n if (i >= 0) {\n name = type.slice(i + 1);\n type = type.slice(0, i);\n }\n if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);\n if (arguments.length === 2) {\n if (listener == null) for (type in this) {\n if (this.hasOwnProperty(type)) this[type].on(name, null);\n }\n return this;\n }\n };\n function d3_dispatch_event(dispatch) {\n var listeners = [], listenerByName = new d3_Map();\n function event() {\n var z = listeners, i = -1, n = z.length, l;\n while (++i < n) if (l = z[i].on) l.apply(this, arguments);\n return dispatch;\n }\n event.on = function(name, listener) {\n var l = listenerByName.get(name), i;\n if (arguments.length < 2) return l && l.on;\n if (l) {\n l.on = null;\n listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));\n listenerByName.remove(name);\n }\n if (listener) listeners.push(listenerByName.set(name, {\n on: listener\n }));\n return dispatch;\n };\n return event;\n }\n d3.event = null;\n function d3_eventPreventDefault() {\n d3.event.preventDefault();\n }\n function d3_eventSource() {\n var e = d3.event, s;\n while (s = e.sourceEvent) e = s;\n return e;\n }\n function d3_eventDispatch(target) {\n var dispatch = new d3_dispatch(), i = 0, n = arguments.length;\n while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n dispatch.of = function(thiz, argumentz) {\n return function(e1) {\n try {\n var e0 = e1.sourceEvent = d3.event;\n e1.target = target;\n d3.event = e1;\n dispatch[e1.type].apply(thiz, argumentz);\n } finally {\n d3.event = e0;\n }\n };\n };\n return dispatch;\n }\n d3.requote = function(s) {\n return s.replace(d3_requote_re, \"\\\\$&\");\n };\n var d3_requote_re = /[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g;\n var d3_subclass = {}.__proto__ ? function(object, prototype) {\n object.__proto__ = prototype;\n } : function(object, prototype) {\n for (var property in prototype) object[property] = prototype[property];\n };\n function d3_selection(groups) {\n d3_subclass(groups, d3_selectionPrototype);\n return groups;\n }\n var d3_select = function(s, n) {\n return n.querySelector(s);\n }, d3_selectAll = function(s, n) {\n return n.querySelectorAll(s);\n }, d3_selectMatches = function(n, s) {\n var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, \"matchesSelector\")];\n d3_selectMatches = function(n, s) {\n return d3_selectMatcher.call(n, s);\n };\n return d3_selectMatches(n, s);\n };\n if (typeof Sizzle === \"function\") {\n d3_select = function(s, n) {\n return Sizzle(s, n)[0] || null;\n };\n d3_selectAll = Sizzle;\n d3_selectMatches = Sizzle.matchesSelector;\n }\n d3.selection = function() {\n return d3.select(d3_document.documentElement);\n };\n var d3_selectionPrototype = d3.selection.prototype = [];\n d3_selectionPrototype.select = function(selector) {\n var subgroups = [], subgroup, subnode, group, node;\n selector = d3_selection_selector(selector);\n for (var j = -1, m = this.length; ++j < m; ) {\n subgroups.push(subgroup = []);\n subgroup.parentNode = (group = this[j]).parentNode;\n for (var i = -1, n = group.length; ++i < n; ) {\n if (node = group[i]) {\n subgroup.push(subnode = selector.call(node, node.__data__, i, j));\n if (subnode && \"__data__\" in node) subnode.__data__ = node.__data__;\n } else {\n subgroup.push(null);\n }\n }\n }\n return d3_selection(subgroups);\n };\n function d3_selection_selector(selector) {\n return typeof selector === \"function\" ? selector : function() {\n return d3_select(selector, this);\n };\n }\n d3_selectionPrototype.selectAll = function(selector) {\n var subgroups = [], subgroup, node;\n selector = d3_selection_selectorAll(selector);\n for (var j = -1, m = this.length; ++j < m; ) {\n for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n if (node = group[i]) {\n subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));\n subgroup.parentNode = node;\n }\n }\n }\n return d3_selection(subgroups);\n };\n function d3_selection_selectorAll(selector) {\n return typeof selector === \"function\" ? selector : function() {\n return d3_selectAll(selector, this);\n };\n }\n var d3_nsXhtml = \"http://www.w3.org/1999/xhtml\";\n var d3_nsPrefix = {\n svg: \"http://www.w3.org/2000/svg\",\n xhtml: d3_nsXhtml,\n xlink: \"http://www.w3.org/1999/xlink\",\n xml: \"http://www.w3.org/XML/1998/namespace\",\n xmlns: \"http://www.w3.org/2000/xmlns/\"\n };\n d3.ns = {\n prefix: d3_nsPrefix,\n qualify: function(name) {\n var i = name.indexOf(\":\"), prefix = name;\n if (i >= 0 && (prefix = name.slice(0, i)) !== \"xmlns\") name = name.slice(i + 1);\n return d3_nsPrefix.hasOwnProperty(prefix) ? {\n space: d3_nsPrefix[prefix],\n local: name\n } : name;\n }\n };\n d3_selectionPrototype.attr = function(name, value) {\n if (arguments.length < 2) {\n if (typeof name === \"string\") {\n var node = this.node();\n name = d3.ns.qualify(name);\n return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);\n }\n for (value in name) this.each(d3_selection_attr(value, name[value]));\n return this;\n }\n return this.each(d3_selection_attr(name, value));\n };\n function d3_selection_attr(name, value) {\n name = d3.ns.qualify(name);\n function attrNull() {\n this.removeAttribute(name);\n }\n function attrNullNS() {\n this.removeAttributeNS(name.space, name.local);\n }\n function attrConstant() {\n this.setAttribute(name, value);\n }\n function attrConstantNS() {\n this.setAttributeNS(name.space, name.local, value);\n }\n function attrFunction() {\n var x = value.apply(this, arguments);\n if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);\n }\n function attrFunctionNS() {\n var x = value.apply(this, arguments);\n if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);\n }\n return value == null ? name.local ? attrNullNS : attrNull : typeof value === \"function\" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;\n }\n function d3_collapse(s) {\n return s.trim().replace(/\\s+/g, \" \");\n }\n d3_selectionPrototype.classed = function(name, value) {\n if (arguments.length < 2) {\n if (typeof name === \"string\") {\n var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;\n if (value = node.classList) {\n while (++i < n) if (!value.contains(name[i])) return false;\n } else {\n value = node.getAttribute(\"class\");\n while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;\n }\n return true;\n }\n for (value in name) this.each(d3_selection_classed(value, name[value]));\n return this;\n }\n return this.each(d3_selection_classed(name, value));\n };\n function d3_selection_classedRe(name) {\n return new RegExp(\"(?:^|\\\\s+)\" + d3.requote(name) + \"(?:\\\\s+|$)\", \"g\");\n }\n function d3_selection_classes(name) {\n return (name + \"\").trim().split(/^|\\s+/);\n }\n function d3_selection_classed(name, value) {\n name = d3_selection_classes(name).map(d3_selection_classedName);\n var n = name.length;\n function classedConstant() {\n var i = -1;\n while (++i < n) name[i](this, value);\n }\n function classedFunction() {\n var i = -1, x = value.apply(this, arguments);\n while (++i < n) name[i](this, x);\n }\n return typeof value === \"function\" ? classedFunction : classedConstant;\n }\n function d3_selection_classedName(name) {\n var re = d3_selection_classedRe(name);\n return function(node, value) {\n if (c = node.classList) return value ? c.add(name) : c.remove(name);\n var c = node.getAttribute(\"class\") || \"\";\n if (value) {\n re.lastIndex = 0;\n if (!re.test(c)) node.setAttribute(\"class\", d3_collapse(c + \" \" + name));\n } else {\n node.setAttribute(\"class\", d3_collapse(c.replace(re, \" \")));\n }\n };\n }\n d3_selectionPrototype.style = function(name, value, priority) {\n var n = arguments.length;\n if (n < 3) {\n if (typeof name !== \"string\") {\n if (n < 2) value = \"\";\n for (priority in name) this.each(d3_selection_style(priority, name[priority], value));\n return this;\n }\n if (n < 2) {\n var node = this.node();\n return d3_window(node).getComputedStyle(node, null).getPropertyValue(name);\n }\n priority = \"\";\n }\n return this.each(d3_selection_style(name, value, priority));\n };\n function d3_selection_style(name, value, priority) {\n function styleNull() {\n this.style.removeProperty(name);\n }\n function styleConstant() {\n this.style.setProperty(name, value, priority);\n }\n function styleFunction() {\n var x = value.apply(this, arguments);\n if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);\n }\n return value == null ? styleNull : typeof value === \"function\" ? styleFunction : styleConstant;\n }\n d3_selectionPrototype.property = function(name, value) {\n if (arguments.length < 2) {\n if (typeof name === \"string\") return this.node()[name];\n for (value in name) this.each(d3_selection_property(value, name[value]));\n return this;\n }\n return this.each(d3_selection_property(name, value));\n };\n function d3_selection_property(name, value) {\n function propertyNull() {\n delete this[name];\n }\n function propertyConstant() {\n this[name] = value;\n }\n function propertyFunction() {\n var x = value.apply(this, arguments);\n if (x == null) delete this[name]; else this[name] = x;\n }\n return value == null ? propertyNull : typeof value === \"function\" ? propertyFunction : propertyConstant;\n }\n d3_selectionPrototype.text = function(value) {\n return arguments.length ? this.each(typeof value === \"function\" ? function() {\n var v = value.apply(this, arguments);\n this.textContent = v == null ? \"\" : v;\n } : value == null ? function() {\n this.textContent = \"\";\n } : function() {\n this.textContent = value;\n }) : this.node().textContent;\n };\n d3_selectionPrototype.html = function(value) {\n return arguments.length ? this.each(typeof value === \"function\" ? function() {\n var v = value.apply(this, arguments);\n this.innerHTML = v == null ? \"\" : v;\n } : value == null ? function() {\n this.innerHTML = \"\";\n } : function() {\n this.innerHTML = value;\n }) : this.node().innerHTML;\n };\n d3_selectionPrototype.append = function(name) {\n name = d3_selection_creator(name);\n return this.select(function() {\n return this.appendChild(name.apply(this, arguments));\n });\n };\n function d3_selection_creator(name) {\n function create() {\n var document = this.ownerDocument, namespace = this.namespaceURI;\n return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name);\n }\n function createNS() {\n return this.ownerDocument.createElementNS(name.space, name.local);\n }\n return typeof name === \"function\" ? name : (name = d3.ns.qualify(name)).local ? createNS : create;\n }\n d3_selectionPrototype.insert = function(name, before) {\n name = d3_selection_creator(name);\n before = d3_selection_selector(before);\n return this.select(function() {\n return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);\n });\n };\n d3_selectionPrototype.remove = function() {\n return this.each(d3_selectionRemove);\n };\n function d3_selectionRemove() {\n var parent = this.parentNode;\n if (parent) parent.removeChild(this);\n }\n d3_selectionPrototype.data = function(value, key) {\n var i = -1, n = this.length, group, node;\n if (!arguments.length) {\n value = new Array(n = (group = this[0]).length);\n while (++i < n) {\n if (node = group[i]) {\n value[i] = node.__data__;\n }\n }\n return value;\n }\n function bind(group, groupData) {\n 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;\n if (key) {\n var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;\n for (i = -1; ++i < n; ) {\n if (node = group[i]) {\n if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) {\n exitNodes[i] = node;\n } else {\n nodeByKeyValue.set(keyValue, node);\n }\n keyValues[i] = keyValue;\n }\n }\n for (i = -1; ++i < m; ) {\n if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {\n enterNodes[i] = d3_selection_dataNode(nodeData);\n } else if (node !== true) {\n updateNodes[i] = node;\n node.__data__ = nodeData;\n }\n nodeByKeyValue.set(keyValue, true);\n }\n for (i = -1; ++i < n; ) {\n if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) {\n exitNodes[i] = group[i];\n }\n }\n } else {\n for (i = -1; ++i < n0; ) {\n node = group[i];\n nodeData = groupData[i];\n if (node) {\n node.__data__ = nodeData;\n updateNodes[i] = node;\n } else {\n enterNodes[i] = d3_selection_dataNode(nodeData);\n }\n }\n for (;i < m; ++i) {\n enterNodes[i] = d3_selection_dataNode(groupData[i]);\n }\n for (;i < n; ++i) {\n exitNodes[i] = group[i];\n }\n }\n enterNodes.update = updateNodes;\n enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;\n enter.push(enterNodes);\n update.push(updateNodes);\n exit.push(exitNodes);\n }\n var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);\n if (typeof value === \"function\") {\n while (++i < n) {\n bind(group = this[i], value.call(group, group.parentNode.__data__, i));\n }\n } else {\n while (++i < n) {\n bind(group = this[i], value);\n }\n }\n update.enter = function() {\n return enter;\n };\n update.exit = function() {\n return exit;\n };\n return update;\n };\n function d3_selection_dataNode(data) {\n return {\n __data__: data\n };\n }\n d3_selectionPrototype.datum = function(value) {\n return arguments.length ? this.property(\"__data__\", value) : this.property(\"__data__\");\n };\n d3_selectionPrototype.filter = function(filter) {\n var subgroups = [], subgroup, group, node;\n if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n for (var j = 0, m = this.length; j < m; j++) {\n subgroups.push(subgroup = []);\n subgroup.parentNode = (group = this[j]).parentNode;\n for (var i = 0, n = group.length; i < n; i++) {\n if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n subgroup.push(node);\n }\n }\n }\n return d3_selection(subgroups);\n };\n function d3_selection_filter(selector) {\n return function() {\n return d3_selectMatches(this, selector);\n };\n }\n d3_selectionPrototype.order = function() {\n for (var j = -1, m = this.length; ++j < m; ) {\n for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {\n if (node = group[i]) {\n if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);\n next = node;\n }\n }\n }\n return this;\n };\n d3_selectionPrototype.sort = function(comparator) {\n comparator = d3_selection_sortComparator.apply(this, arguments);\n for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);\n return this.order();\n };\n function d3_selection_sortComparator(comparator) {\n if (!arguments.length) comparator = d3_ascending;\n return function(a, b) {\n return a && b ? comparator(a.__data__, b.__data__) : !a - !b;\n };\n }\n d3_selectionPrototype.each = function(callback) {\n return d3_selection_each(this, function(node, i, j) {\n callback.call(node, node.__data__, i, j);\n });\n };\n function d3_selection_each(groups, callback) {\n for (var j = 0, m = groups.length; j < m; j++) {\n for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {\n if (node = group[i]) callback(node, i, j);\n }\n }\n return groups;\n }\n d3_selectionPrototype.call = function(callback) {\n var args = d3_array(arguments);\n callback.apply(args[0] = this, args);\n return this;\n };\n d3_selectionPrototype.empty = function() {\n return !this.node();\n };\n d3_selectionPrototype.node = function() {\n for (var j = 0, m = this.length; j < m; j++) {\n for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n var node = group[i];\n if (node) return node;\n }\n }\n return null;\n };\n d3_selectionPrototype.size = function() {\n var n = 0;\n d3_selection_each(this, function() {\n ++n;\n });\n return n;\n };\n function d3_selection_enter(selection) {\n d3_subclass(selection, d3_selection_enterPrototype);\n return selection;\n }\n var d3_selection_enterPrototype = [];\n d3.selection.enter = d3_selection_enter;\n d3.selection.enter.prototype = d3_selection_enterPrototype;\n d3_selection_enterPrototype.append = d3_selectionPrototype.append;\n d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;\n d3_selection_enterPrototype.node = d3_selectionPrototype.node;\n d3_selection_enterPrototype.call = d3_selectionPrototype.call;\n d3_selection_enterPrototype.size = d3_selectionPrototype.size;\n d3_selection_enterPrototype.select = function(selector) {\n var subgroups = [], subgroup, subnode, upgroup, group, node;\n for (var j = -1, m = this.length; ++j < m; ) {\n upgroup = (group = this[j]).update;\n subgroups.push(subgroup = []);\n subgroup.parentNode = group.parentNode;\n for (var i = -1, n = group.length; ++i < n; ) {\n if (node = group[i]) {\n subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));\n subnode.__data__ = node.__data__;\n } else {\n subgroup.push(null);\n }\n }\n }\n return d3_selection(subgroups);\n };\n d3_selection_enterPrototype.insert = function(name, before) {\n if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);\n return d3_selectionPrototype.insert.call(this, name, before);\n };\n function d3_selection_enterInsertBefore(enter) {\n var i0, j0;\n return function(d, i, j) {\n var group = enter[j].update, n = group.length, node;\n if (j != j0) j0 = j, i0 = 0;\n if (i >= i0) i0 = i + 1;\n while (!(node = group[i0]) && ++i0 < n) ;\n return node;\n };\n }\n d3.select = function(node) {\n var group;\n if (typeof node === \"string\") {\n group = [ d3_select(node, d3_document) ];\n group.parentNode = d3_document.documentElement;\n } else {\n group = [ node ];\n group.parentNode = d3_documentElement(node);\n }\n return d3_selection([ group ]);\n };\n d3.selectAll = function(nodes) {\n var group;\n if (typeof nodes === \"string\") {\n group = d3_array(d3_selectAll(nodes, d3_document));\n group.parentNode = d3_document.documentElement;\n } else {\n group = d3_array(nodes);\n group.parentNode = null;\n }\n return d3_selection([ group ]);\n };\n d3_selectionPrototype.on = function(type, listener, capture) {\n var n = arguments.length;\n if (n < 3) {\n if (typeof type !== \"string\") {\n if (n < 2) listener = false;\n for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));\n return this;\n }\n if (n < 2) return (n = this.node()[\"__on\" + type]) && n._;\n capture = false;\n }\n return this.each(d3_selection_on(type, listener, capture));\n };\n function d3_selection_on(type, listener, capture) {\n var name = \"__on\" + type, i = type.indexOf(\".\"), wrap = d3_selection_onListener;\n if (i > 0) type = type.slice(0, i);\n var filter = d3_selection_onFilters.get(type);\n if (filter) type = filter, wrap = d3_selection_onFilter;\n function onRemove() {\n var l = this[name];\n if (l) {\n this.removeEventListener(type, l, l.$);\n delete this[name];\n }\n }\n function onAdd() {\n var l = wrap(listener, d3_array(arguments));\n onRemove.call(this);\n this.addEventListener(type, this[name] = l, l.$ = capture);\n l._ = listener;\n }\n function removeAll() {\n var re = new RegExp(\"^__on([^.]+)\" + d3.requote(type) + \"$\"), match;\n for (var name in this) {\n if (match = name.match(re)) {\n var l = this[name];\n this.removeEventListener(match[1], l, l.$);\n delete this[name];\n }\n }\n }\n return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;\n }\n var d3_selection_onFilters = d3.map({\n mouseenter: \"mouseover\",\n mouseleave: \"mouseout\"\n });\n if (d3_document) {\n d3_selection_onFilters.forEach(function(k) {\n if (\"on\" + k in d3_document) d3_selection_onFilters.remove(k);\n });\n }\n function d3_selection_onListener(listener, argumentz) {\n return function(e) {\n var o = d3.event;\n d3.event = e;\n argumentz[0] = this.__data__;\n try {\n listener.apply(this, argumentz);\n } finally {\n d3.event = o;\n }\n };\n }\n function d3_selection_onFilter(listener, argumentz) {\n var l = d3_selection_onListener(listener, argumentz);\n return function(e) {\n var target = this, related = e.relatedTarget;\n if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {\n l.call(target, e);\n }\n };\n }\n var d3_event_dragSelect, d3_event_dragId = 0;\n function d3_event_dragSuppress(node) {\n var name = \".dragsuppress-\" + ++d3_event_dragId, click = \"click\" + name, w = d3.select(d3_window(node)).on(\"touchmove\" + name, d3_eventPreventDefault).on(\"dragstart\" + name, d3_eventPreventDefault).on(\"selectstart\" + name, d3_eventPreventDefault);\n if (d3_event_dragSelect == null) {\n d3_event_dragSelect = \"onselectstart\" in node ? false : d3_vendorSymbol(node.style, \"userSelect\");\n }\n if (d3_event_dragSelect) {\n var style = d3_documentElement(node).style, select = style[d3_event_dragSelect];\n style[d3_event_dragSelect] = \"none\";\n }\n return function(suppressClick) {\n w.on(name, null);\n if (d3_event_dragSelect) style[d3_event_dragSelect] = select;\n if (suppressClick) {\n var off = function() {\n w.on(click, null);\n };\n w.on(click, function() {\n d3_eventPreventDefault();\n off();\n }, true);\n setTimeout(off, 0);\n }\n };\n }\n d3.mouse = function(container) {\n return d3_mousePoint(container, d3_eventSource());\n };\n var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0;\n function d3_mousePoint(container, e) {\n if (e.changedTouches) e = e.changedTouches[0];\n var svg = container.ownerSVGElement || container;\n if (svg.createSVGPoint) {\n var point = svg.createSVGPoint();\n if (d3_mouse_bug44083 < 0) {\n var window = d3_window(container);\n if (window.scrollX || window.scrollY) {\n svg = d3.select(\"body\").append(\"svg\").style({\n position: \"absolute\",\n top: 0,\n left: 0,\n margin: 0,\n padding: 0,\n border: \"none\"\n }, \"important\");\n var ctm = svg[0][0].getScreenCTM();\n d3_mouse_bug44083 = !(ctm.f || ctm.e);\n svg.remove();\n }\n }\n if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, \n point.y = e.clientY;\n point = point.matrixTransform(container.getScreenCTM().inverse());\n return [ point.x, point.y ];\n }\n var rect = container.getBoundingClientRect();\n return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];\n }\n d3.touch = function(container, touches, identifier) {\n if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;\n if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {\n if ((touch = touches[i]).identifier === identifier) {\n return d3_mousePoint(container, touch);\n }\n }\n };\n d3.behavior.drag = function() {\n var event = d3_eventDispatch(drag, \"drag\", \"dragstart\", \"dragend\"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, \"mousemove\", \"mouseup\"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, \"touchmove\", \"touchend\");\n function drag() {\n this.on(\"mousedown.drag\", mousedown).on(\"touchstart.drag\", touchstart);\n }\n function dragstart(id, position, subject, move, end) {\n return function() {\n var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = \".drag\" + (dragId == null ? \"\" : \"-\" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId);\n if (origin) {\n dragOffset = origin.apply(that, arguments);\n dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];\n } else {\n dragOffset = [ 0, 0 ];\n }\n dispatch({\n type: \"dragstart\"\n });\n function moved() {\n var position1 = position(parent, dragId), dx, dy;\n if (!position1) return;\n dx = position1[0] - position0[0];\n dy = position1[1] - position0[1];\n dragged |= dx | dy;\n position0 = position1;\n dispatch({\n type: \"drag\",\n x: position1[0] + dragOffset[0],\n y: position1[1] + dragOffset[1],\n dx: dx,\n dy: dy\n });\n }\n function ended() {\n if (!position(parent, dragId)) return;\n dragSubject.on(move + dragName, null).on(end + dragName, null);\n dragRestore(dragged);\n dispatch({\n type: \"dragend\"\n });\n }\n };\n }\n drag.origin = function(x) {\n if (!arguments.length) return origin;\n origin = x;\n return drag;\n };\n return d3.rebind(drag, event, \"on\");\n };\n function d3_behavior_dragTouchId() {\n return d3.event.changedTouches[0].identifier;\n }\n d3.touches = function(container, touches) {\n if (arguments.length < 2) touches = d3_eventSource().touches;\n return touches ? d3_array(touches).map(function(touch) {\n var point = d3_mousePoint(container, touch);\n point.identifier = touch.identifier;\n return point;\n }) : [];\n };\n var \u03B5 = 1e-6, \u03B52 = \u03B5 * \u03B5, \u03C0 = Math.PI, \u03C4 = 2 * \u03C0, \u03C4\u03B5 = \u03C4 - \u03B5, half\u03C0 = \u03C0 / 2, d3_radians = \u03C0 / 180, d3_degrees = 180 / \u03C0;\n function d3_sgn(x) {\n return x > 0 ? 1 : x < 0 ? -1 : 0;\n }\n function d3_cross2d(a, b, c) {\n return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);\n }\n function d3_acos(x) {\n return x > 1 ? 0 : x < -1 ? \u03C0 : Math.acos(x);\n }\n function d3_asin(x) {\n return x > 1 ? half\u03C0 : x < -1 ? -half\u03C0 : Math.asin(x);\n }\n function d3_sinh(x) {\n return ((x = Math.exp(x)) - 1 / x) / 2;\n }\n function d3_cosh(x) {\n return ((x = Math.exp(x)) + 1 / x) / 2;\n }\n function d3_tanh(x) {\n return ((x = Math.exp(2 * x)) - 1) / (x + 1);\n }\n function d3_haversin(x) {\n return (x = Math.sin(x / 2)) * x;\n }\n var \u03C1 = Math.SQRT2, \u03C12 = 2, \u03C14 = 4;\n d3.interpolateZoom = function(p0, p1) {\n var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S;\n if (d2 < \u03B52) {\n S = Math.log(w1 / w0) / \u03C1;\n i = function(t) {\n return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(\u03C1 * t * S) ];\n };\n } else {\n var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + \u03C14 * d2) / (2 * w0 * \u03C12 * d1), b1 = (w1 * w1 - w0 * w0 - \u03C14 * d2) / (2 * w1 * \u03C12 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);\n S = (r1 - r0) / \u03C1;\n i = function(t) {\n var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (\u03C12 * d1) * (coshr0 * d3_tanh(\u03C1 * s + r0) - d3_sinh(r0));\n return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(\u03C1 * s + r0) ];\n };\n }\n i.duration = S * 1e3;\n return i;\n };\n d3.behavior.zoom = function() {\n var view = {\n x: 0,\n y: 0,\n k: 1\n }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = \"mousedown.zoom\", mousemove = \"mousemove.zoom\", mouseup = \"mouseup.zoom\", mousewheelTimer, touchstart = \"touchstart.zoom\", touchtime, event = d3_eventDispatch(zoom, \"zoomstart\", \"zoom\", \"zoomend\"), x0, x1, y0, y1;\n if (!d3_behavior_zoomWheel) {\n d3_behavior_zoomWheel = \"onwheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);\n }, \"wheel\") : \"onmousewheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n return d3.event.wheelDelta;\n }, \"mousewheel\") : (d3_behavior_zoomDelta = function() {\n return -d3.event.detail;\n }, \"MozMousePixelScroll\");\n }\n function zoom(g) {\n g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + \".zoom\", mousewheeled).on(\"dblclick.zoom\", dblclicked).on(touchstart, touchstarted);\n }\n zoom.event = function(g) {\n g.each(function() {\n var dispatch = event.of(this, arguments), view1 = view;\n if (d3_transitionInheritId) {\n d3.select(this).transition().each(\"start.zoom\", function() {\n view = this.__chart__ || {\n x: 0,\n y: 0,\n k: 1\n };\n zoomstarted(dispatch);\n }).tween(\"zoom:zoom\", function() {\n var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);\n return function(t) {\n var l = i(t), k = dx / l[2];\n this.__chart__ = view = {\n x: cx - l[0] * k,\n y: cy - l[1] * k,\n k: k\n };\n zoomed(dispatch);\n };\n }).each(\"interrupt.zoom\", function() {\n zoomended(dispatch);\n }).each(\"end.zoom\", function() {\n zoomended(dispatch);\n });\n } else {\n this.__chart__ = view;\n zoomstarted(dispatch);\n zoomed(dispatch);\n zoomended(dispatch);\n }\n });\n };\n zoom.translate = function(_) {\n if (!arguments.length) return [ view.x, view.y ];\n view = {\n x: +_[0],\n y: +_[1],\n k: view.k\n };\n rescale();\n return zoom;\n };\n zoom.scale = function(_) {\n if (!arguments.length) return view.k;\n view = {\n x: view.x,\n y: view.y,\n k: null\n };\n scaleTo(+_);\n rescale();\n return zoom;\n };\n zoom.scaleExtent = function(_) {\n if (!arguments.length) return scaleExtent;\n scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];\n return zoom;\n };\n zoom.center = function(_) {\n if (!arguments.length) return center;\n center = _ && [ +_[0], +_[1] ];\n return zoom;\n };\n zoom.size = function(_) {\n if (!arguments.length) return size;\n size = _ && [ +_[0], +_[1] ];\n return zoom;\n };\n zoom.duration = function(_) {\n if (!arguments.length) return duration;\n duration = +_;\n return zoom;\n };\n zoom.x = function(z) {\n if (!arguments.length) return x1;\n x1 = z;\n x0 = z.copy();\n view = {\n x: 0,\n y: 0,\n k: 1\n };\n return zoom;\n };\n zoom.y = function(z) {\n if (!arguments.length) return y1;\n y1 = z;\n y0 = z.copy();\n view = {\n x: 0,\n y: 0,\n k: 1\n };\n return zoom;\n };\n function location(p) {\n return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];\n }\n function point(l) {\n return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];\n }\n function scaleTo(s) {\n view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));\n }\n function translateTo(p, l) {\n l = point(l);\n view.x += p[0] - l[0];\n view.y += p[1] - l[1];\n }\n function zoomTo(that, p, l, k) {\n that.__chart__ = {\n x: view.x,\n y: view.y,\n k: view.k\n };\n scaleTo(Math.pow(2, k));\n translateTo(center0 = p, l);\n that = d3.select(that);\n if (duration > 0) that = that.transition().duration(duration);\n that.call(zoom.event);\n }\n function rescale() {\n if (x1) x1.domain(x0.range().map(function(x) {\n return (x - view.x) / view.k;\n }).map(x0.invert));\n if (y1) y1.domain(y0.range().map(function(y) {\n return (y - view.y) / view.k;\n }).map(y0.invert));\n }\n function zoomstarted(dispatch) {\n if (!zooming++) dispatch({\n type: \"zoomstart\"\n });\n }\n function zoomed(dispatch) {\n rescale();\n dispatch({\n type: \"zoom\",\n scale: view.k,\n translate: [ view.x, view.y ]\n });\n }\n function zoomended(dispatch) {\n if (!--zooming) dispatch({\n type: \"zoomend\"\n }), center0 = null;\n }\n function mousedowned() {\n var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that);\n d3_selection_interrupt.call(that);\n zoomstarted(dispatch);\n function moved() {\n dragged = 1;\n translateTo(d3.mouse(that), location0);\n zoomed(dispatch);\n }\n function ended() {\n subject.on(mousemove, null).on(mouseup, null);\n dragRestore(dragged);\n zoomended(dispatch);\n }\n }\n function touchstarted() {\n 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(that);\n started();\n zoomstarted(dispatch);\n subject.on(mousedown, null).on(touchstart, started);\n function relocate() {\n var touches = d3.touches(that);\n scale0 = view.k;\n touches.forEach(function(t) {\n if (t.identifier in locations0) locations0[t.identifier] = location(t);\n });\n return touches;\n }\n function started() {\n var target = d3.event.target;\n d3.select(target).on(touchmove, moved).on(touchend, ended);\n targets.push(target);\n var changed = d3.event.changedTouches;\n for (var i = 0, n = changed.length; i < n; ++i) {\n locations0[changed[i].identifier] = null;\n }\n var touches = relocate(), now = Date.now();\n if (touches.length === 1) {\n if (now - touchtime < 500) {\n var p = touches[0];\n zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);\n d3_eventPreventDefault();\n }\n touchtime = now;\n } else if (touches.length > 1) {\n var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];\n distance0 = dx * dx + dy * dy;\n }\n }\n function moved() {\n var touches = d3.touches(that), p0, l0, p1, l1;\n d3_selection_interrupt.call(that);\n for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {\n p1 = touches[i];\n if (l1 = locations0[p1.identifier]) {\n if (l0) break;\n p0 = p1, l0 = l1;\n }\n }\n if (l1) {\n var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);\n p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];\n l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];\n scaleTo(scale1 * scale0);\n }\n touchtime = null;\n translateTo(p0, l0);\n zoomed(dispatch);\n }\n function ended() {\n if (d3.event.touches.length) {\n var changed = d3.event.changedTouches;\n for (var i = 0, n = changed.length; i < n; ++i) {\n delete locations0[changed[i].identifier];\n }\n for (var identifier in locations0) {\n return void relocate();\n }\n }\n d3.selectAll(targets).on(zoomName, null);\n subject.on(mousedown, mousedowned).on(touchstart, touchstarted);\n dragRestore();\n zoomended(dispatch);\n }\n }\n function mousewheeled() {\n var dispatch = event.of(this, arguments);\n if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), \n translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch);\n mousewheelTimer = setTimeout(function() {\n mousewheelTimer = null;\n zoomended(dispatch);\n }, 50);\n d3_eventPreventDefault();\n scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);\n translateTo(center0, translate0);\n zoomed(dispatch);\n }\n function dblclicked() {\n var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;\n zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);\n }\n return d3.rebind(zoom, event, \"on\");\n };\n var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel;\n d3.color = d3_color;\n function d3_color() {}\n d3_color.prototype.toString = function() {\n return this.rgb() + \"\";\n };\n d3.hsl = d3_hsl;\n function d3_hsl(h, s, l) {\n return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse(\"\" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l);\n }\n var d3_hslPrototype = d3_hsl.prototype = new d3_color();\n d3_hslPrototype.brighter = function(k) {\n k = Math.pow(.7, arguments.length ? k : 1);\n return new d3_hsl(this.h, this.s, this.l / k);\n };\n d3_hslPrototype.darker = function(k) {\n k = Math.pow(.7, arguments.length ? k : 1);\n return new d3_hsl(this.h, this.s, k * this.l);\n };\n d3_hslPrototype.rgb = function() {\n return d3_hsl_rgb(this.h, this.s, this.l);\n };\n function d3_hsl_rgb(h, s, l) {\n var m1, m2;\n h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;\n s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;\n l = l < 0 ? 0 : l > 1 ? 1 : l;\n m2 = l <= .5 ? l * (1 + s) : l + s - l * s;\n m1 = 2 * l - m2;\n function v(h) {\n if (h > 360) h -= 360; else if (h < 0) h += 360;\n if (h < 60) return m1 + (m2 - m1) * h / 60;\n if (h < 180) return m2;\n if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;\n return m1;\n }\n function vv(h) {\n return Math.round(v(h) * 255);\n }\n return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));\n }\n d3.hcl = d3_hcl;\n function d3_hcl(h, c, l) {\n return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l);\n }\n var d3_hclPrototype = d3_hcl.prototype = new d3_color();\n d3_hclPrototype.brighter = function(k) {\n return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));\n };\n d3_hclPrototype.darker = function(k) {\n return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));\n };\n d3_hclPrototype.rgb = function() {\n return d3_hcl_lab(this.h, this.c, this.l).rgb();\n };\n function d3_hcl_lab(h, c, l) {\n if (isNaN(h)) h = 0;\n if (isNaN(c)) c = 0;\n return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);\n }\n d3.lab = d3_lab;\n function d3_lab(l, a, b) {\n 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);\n }\n var d3_lab_K = 18;\n var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;\n var d3_labPrototype = d3_lab.prototype = new d3_color();\n d3_labPrototype.brighter = function(k) {\n return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n };\n d3_labPrototype.darker = function(k) {\n return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n };\n d3_labPrototype.rgb = function() {\n return d3_lab_rgb(this.l, this.a, this.b);\n };\n function d3_lab_rgb(l, a, b) {\n var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;\n x = d3_lab_xyz(x) * d3_lab_X;\n y = d3_lab_xyz(y) * d3_lab_Y;\n z = d3_lab_xyz(z) * d3_lab_Z;\n return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));\n }\n function d3_lab_hcl(l, a, b) {\n return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l);\n }\n function d3_lab_xyz(x) {\n return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;\n }\n function d3_xyz_lab(x) {\n return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;\n }\n function d3_xyz_rgb(r) {\n return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));\n }\n d3.rgb = d3_rgb;\n function d3_rgb(r, g, b) {\n return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse(\"\" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b);\n }\n function d3_rgbNumber(value) {\n return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);\n }\n function d3_rgbString(value) {\n return d3_rgbNumber(value) + \"\";\n }\n var d3_rgbPrototype = d3_rgb.prototype = new d3_color();\n d3_rgbPrototype.brighter = function(k) {\n k = Math.pow(.7, arguments.length ? k : 1);\n var r = this.r, g = this.g, b = this.b, i = 30;\n if (!r && !g && !b) return new d3_rgb(i, i, i);\n if (r && r < i) r = i;\n if (g && g < i) g = i;\n if (b && b < i) b = i;\n return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));\n };\n d3_rgbPrototype.darker = function(k) {\n k = Math.pow(.7, arguments.length ? k : 1);\n return new d3_rgb(k * this.r, k * this.g, k * this.b);\n };\n d3_rgbPrototype.hsl = function() {\n return d3_rgb_hsl(this.r, this.g, this.b);\n };\n d3_rgbPrototype.toString = function() {\n return \"#\" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);\n };\n function d3_rgb_hex(v) {\n return v < 16 ? \"0\" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);\n }\n function d3_rgb_parse(format, rgb, hsl) {\n var r = 0, g = 0, b = 0, m1, m2, color;\n m1 = /([a-z]+)\\((.*)\\)/.exec(format = format.toLowerCase());\n if (m1) {\n m2 = m1[2].split(\",\");\n switch (m1[1]) {\n case \"hsl\":\n {\n return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);\n }\n\n case \"rgb\":\n {\n return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));\n }\n }\n }\n if (color = d3_rgb_names.get(format)) {\n return rgb(color.r, color.g, color.b);\n }\n if (format != null && format.charAt(0) === \"#\" && !isNaN(color = parseInt(format.slice(1), 16))) {\n if (format.length === 4) {\n r = (color & 3840) >> 4;\n r = r >> 4 | r;\n g = color & 240;\n g = g >> 4 | g;\n b = color & 15;\n b = b << 4 | b;\n } else if (format.length === 7) {\n r = (color & 16711680) >> 16;\n g = (color & 65280) >> 8;\n b = color & 255;\n }\n }\n return rgb(r, g, b);\n }\n function d3_rgb_hsl(r, g, b) {\n var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;\n if (d) {\n s = l < .5 ? d / (max + min) : d / (2 - max - min);\n if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;\n h *= 60;\n } else {\n h = NaN;\n s = l > 0 && l < 1 ? 0 : h;\n }\n return new d3_hsl(h, s, l);\n }\n function d3_rgb_lab(r, g, b) {\n r = d3_rgb_xyz(r);\n g = d3_rgb_xyz(g);\n b = d3_rgb_xyz(b);\n var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z);\n return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));\n }\n function d3_rgb_xyz(r) {\n return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);\n }\n function d3_rgb_parseNumber(c) {\n var f = parseFloat(c);\n return c.charAt(c.length - 1) === \"%\" ? Math.round(f * 2.55) : f;\n }\n var d3_rgb_names = d3.map({\n aliceblue: 15792383,\n antiquewhite: 16444375,\n aqua: 65535,\n aquamarine: 8388564,\n azure: 15794175,\n beige: 16119260,\n bisque: 16770244,\n black: 0,\n blanchedalmond: 16772045,\n blue: 255,\n blueviolet: 9055202,\n brown: 10824234,\n burlywood: 14596231,\n cadetblue: 6266528,\n chartreuse: 8388352,\n chocolate: 13789470,\n coral: 16744272,\n cornflowerblue: 6591981,\n cornsilk: 16775388,\n crimson: 14423100,\n cyan: 65535,\n darkblue: 139,\n darkcyan: 35723,\n darkgoldenrod: 12092939,\n darkgray: 11119017,\n darkgreen: 25600,\n darkgrey: 11119017,\n darkkhaki: 12433259,\n darkmagenta: 9109643,\n darkolivegreen: 5597999,\n darkorange: 16747520,\n darkorchid: 10040012,\n darkred: 9109504,\n darksalmon: 15308410,\n darkseagreen: 9419919,\n darkslateblue: 4734347,\n darkslategray: 3100495,\n darkslategrey: 3100495,\n darkturquoise: 52945,\n darkviolet: 9699539,\n deeppink: 16716947,\n deepskyblue: 49151,\n dimgray: 6908265,\n dimgrey: 6908265,\n dodgerblue: 2003199,\n firebrick: 11674146,\n floralwhite: 16775920,\n forestgreen: 2263842,\n fuchsia: 16711935,\n gainsboro: 14474460,\n ghostwhite: 16316671,\n gold: 16766720,\n goldenrod: 14329120,\n gray: 8421504,\n green: 32768,\n greenyellow: 11403055,\n grey: 8421504,\n honeydew: 15794160,\n hotpink: 16738740,\n indianred: 13458524,\n indigo: 4915330,\n ivory: 16777200,\n khaki: 15787660,\n lavender: 15132410,\n lavenderblush: 16773365,\n lawngreen: 8190976,\n lemonchiffon: 16775885,\n lightblue: 11393254,\n lightcoral: 15761536,\n lightcyan: 14745599,\n lightgoldenrodyellow: 16448210,\n lightgray: 13882323,\n lightgreen: 9498256,\n lightgrey: 13882323,\n lightpink: 16758465,\n lightsalmon: 16752762,\n lightseagreen: 2142890,\n lightskyblue: 8900346,\n lightslategray: 7833753,\n lightslategrey: 7833753,\n lightsteelblue: 11584734,\n lightyellow: 16777184,\n lime: 65280,\n limegreen: 3329330,\n linen: 16445670,\n magenta: 16711935,\n maroon: 8388608,\n mediumaquamarine: 6737322,\n mediumblue: 205,\n mediumorchid: 12211667,\n mediumpurple: 9662683,\n mediumseagreen: 3978097,\n mediumslateblue: 8087790,\n mediumspringgreen: 64154,\n mediumturquoise: 4772300,\n mediumvioletred: 13047173,\n midnightblue: 1644912,\n mintcream: 16121850,\n mistyrose: 16770273,\n moccasin: 16770229,\n navajowhite: 16768685,\n navy: 128,\n oldlace: 16643558,\n olive: 8421376,\n olivedrab: 7048739,\n orange: 16753920,\n orangered: 16729344,\n orchid: 14315734,\n palegoldenrod: 15657130,\n palegreen: 10025880,\n paleturquoise: 11529966,\n palevioletred: 14381203,\n papayawhip: 16773077,\n peachpuff: 16767673,\n peru: 13468991,\n pink: 16761035,\n plum: 14524637,\n powderblue: 11591910,\n purple: 8388736,\n rebeccapurple: 6697881,\n red: 16711680,\n rosybrown: 12357519,\n royalblue: 4286945,\n saddlebrown: 9127187,\n salmon: 16416882,\n sandybrown: 16032864,\n seagreen: 3050327,\n seashell: 16774638,\n sienna: 10506797,\n silver: 12632256,\n skyblue: 8900331,\n slateblue: 6970061,\n slategray: 7372944,\n slategrey: 7372944,\n snow: 16775930,\n springgreen: 65407,\n steelblue: 4620980,\n tan: 13808780,\n teal: 32896,\n thistle: 14204888,\n tomato: 16737095,\n turquoise: 4251856,\n violet: 15631086,\n wheat: 16113331,\n white: 16777215,\n whitesmoke: 16119285,\n yellow: 16776960,\n yellowgreen: 10145074\n });\n d3_rgb_names.forEach(function(key, value) {\n d3_rgb_names.set(key, d3_rgbNumber(value));\n });\n function d3_functor(v) {\n return typeof v === \"function\" ? v : function() {\n return v;\n };\n }\n d3.functor = d3_functor;\n d3.xhr = d3_xhrType(d3_identity);\n function d3_xhrType(response) {\n return function(url, mimeType, callback) {\n if (arguments.length === 2 && typeof mimeType === \"function\") callback = mimeType, \n mimeType = null;\n return d3_xhr(url, mimeType, response, callback);\n };\n }\n function d3_xhr(url, mimeType, response, callback) {\n var xhr = {}, dispatch = d3.dispatch(\"beforesend\", \"progress\", \"load\", \"error\"), headers = {}, request = new XMLHttpRequest(), responseType = null;\n if (this.XDomainRequest && !(\"withCredentials\" in request) && /^(http(s)?:)?\\/\\//.test(url)) request = new XDomainRequest();\n \"onload\" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {\n request.readyState > 3 && respond();\n };\n function respond() {\n var status = request.status, result;\n if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {\n try {\n result = response.call(xhr, request);\n } catch (e) {\n dispatch.error.call(xhr, e);\n return;\n }\n dispatch.load.call(xhr, result);\n } else {\n dispatch.error.call(xhr, request);\n }\n }\n request.onprogress = function(event) {\n var o = d3.event;\n d3.event = event;\n try {\n dispatch.progress.call(xhr, request);\n } finally {\n d3.event = o;\n }\n };\n xhr.header = function(name, value) {\n name = (name + \"\").toLowerCase();\n if (arguments.length < 2) return headers[name];\n if (value == null) delete headers[name]; else headers[name] = value + \"\";\n return xhr;\n };\n xhr.mimeType = function(value) {\n if (!arguments.length) return mimeType;\n mimeType = value == null ? null : value + \"\";\n return xhr;\n };\n xhr.responseType = function(value) {\n if (!arguments.length) return responseType;\n responseType = value;\n return xhr;\n };\n xhr.response = function(value) {\n response = value;\n return xhr;\n };\n [ \"get\", \"post\" ].forEach(function(method) {\n xhr[method] = function() {\n return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));\n };\n });\n xhr.send = function(method, data, callback) {\n if (arguments.length === 2 && typeof data === \"function\") callback = data, data = null;\n request.open(method, url, true);\n if (mimeType != null && !(\"accept\" in headers)) headers[\"accept\"] = mimeType + \",*/*\";\n if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);\n if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);\n if (responseType != null) request.responseType = responseType;\n if (callback != null) xhr.on(\"error\", callback).on(\"load\", function(request) {\n callback(null, request);\n });\n dispatch.beforesend.call(xhr, request);\n request.send(data == null ? null : data);\n return xhr;\n };\n xhr.abort = function() {\n request.abort();\n return xhr;\n };\n d3.rebind(xhr, dispatch, \"on\");\n return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));\n }\n function d3_xhr_fixCallback(callback) {\n return callback.length === 1 ? function(error, request) {\n callback(error == null ? request : null);\n } : callback;\n }\n function d3_xhrHasResponse(request) {\n var type = request.responseType;\n return type && type !== \"text\" ? request.response : request.responseText;\n }\n d3.dsv = function(delimiter, mimeType) {\n var reFormat = new RegExp('[\"' + delimiter + \"\\n]\"), delimiterCode = delimiter.charCodeAt(0);\n function dsv(url, row, callback) {\n if (arguments.length < 3) callback = row, row = null;\n var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);\n xhr.row = function(_) {\n return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;\n };\n return xhr;\n }\n function response(request) {\n return dsv.parse(request.responseText);\n }\n function typedResponse(f) {\n return function(request) {\n return dsv.parse(request.responseText, f);\n };\n }\n dsv.parse = function(text, f) {\n var o;\n return dsv.parseRows(text, function(row, i) {\n if (o) return o(row, i - 1);\n var a = new Function(\"d\", \"return {\" + row.map(function(name, i) {\n return JSON.stringify(name) + \": d[\" + i + \"]\";\n }).join(\",\") + \"}\");\n o = f ? function(row, i) {\n return f(a(row), i);\n } : a;\n });\n };\n dsv.parseRows = function(text, f) {\n var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;\n function token() {\n if (I >= N) return EOF;\n if (eol) return eol = false, EOL;\n var j = I;\n if (text.charCodeAt(j) === 34) {\n var i = j;\n while (i++ < N) {\n if (text.charCodeAt(i) === 34) {\n if (text.charCodeAt(i + 1) !== 34) break;\n ++i;\n }\n }\n I = i + 2;\n var c = text.charCodeAt(i + 1);\n if (c === 13) {\n eol = true;\n if (text.charCodeAt(i + 2) === 10) ++I;\n } else if (c === 10) {\n eol = true;\n }\n return text.slice(j + 1, i).replace(/\"\"/g, '\"');\n }\n while (I < N) {\n var c = text.charCodeAt(I++), k = 1;\n if (c === 10) eol = true; else if (c === 13) {\n eol = true;\n if (text.charCodeAt(I) === 10) ++I, ++k;\n } else if (c !== delimiterCode) continue;\n return text.slice(j, I - k);\n }\n return text.slice(j);\n }\n while ((t = token()) !== EOF) {\n var a = [];\n while (t !== EOL && t !== EOF) {\n a.push(t);\n t = token();\n }\n if (f && (a = f(a, n++)) == null) continue;\n rows.push(a);\n }\n return rows;\n };\n dsv.format = function(rows) {\n if (Array.isArray(rows[0])) return dsv.formatRows(rows);\n var fieldSet = new d3_Set(), fields = [];\n rows.forEach(function(row) {\n for (var field in row) {\n if (!fieldSet.has(field)) {\n fields.push(fieldSet.add(field));\n }\n }\n });\n return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {\n return fields.map(function(field) {\n return formatValue(row[field]);\n }).join(delimiter);\n })).join(\"\\n\");\n };\n dsv.formatRows = function(rows) {\n return rows.map(formatRow).join(\"\\n\");\n };\n function formatRow(row) {\n return row.map(formatValue).join(delimiter);\n }\n function formatValue(text) {\n return reFormat.test(text) ? '\"' + text.replace(/\\\"/g, '\"\"') + '\"' : text;\n }\n return dsv;\n };\n d3.csv = d3.dsv(\",\", \"text/csv\");\n d3.tsv = d3.dsv(\"\t\", \"text/tab-separated-values\");\n var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, \"requestAnimationFrame\")] || function(callback) {\n setTimeout(callback, 17);\n };\n d3.timer = function() {\n d3_timer.apply(this, arguments);\n };\n function d3_timer(callback, delay, then) {\n var n = arguments.length;\n if (n < 2) delay = 0;\n if (n < 3) then = Date.now();\n var time = then + delay, timer = {\n c: callback,\n t: time,\n n: null\n };\n if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;\n d3_timer_queueTail = timer;\n if (!d3_timer_interval) {\n d3_timer_timeout = clearTimeout(d3_timer_timeout);\n d3_timer_interval = 1;\n d3_timer_frame(d3_timer_step);\n }\n return timer;\n }\n function d3_timer_step() {\n var now = d3_timer_mark(), delay = d3_timer_sweep() - now;\n if (delay > 24) {\n if (isFinite(delay)) {\n clearTimeout(d3_timer_timeout);\n d3_timer_timeout = setTimeout(d3_timer_step, delay);\n }\n d3_timer_interval = 0;\n } else {\n d3_timer_interval = 1;\n d3_timer_frame(d3_timer_step);\n }\n }\n d3.timer.flush = function() {\n d3_timer_mark();\n d3_timer_sweep();\n };\n function d3_timer_mark() {\n var now = Date.now(), timer = d3_timer_queueHead;\n while (timer) {\n if (now >= timer.t && timer.c(now - timer.t)) timer.c = null;\n timer = timer.n;\n }\n return now;\n }\n function d3_timer_sweep() {\n var t0, t1 = d3_timer_queueHead, time = Infinity;\n while (t1) {\n if (t1.c) {\n if (t1.t < time) time = t1.t;\n t1 = (t0 = t1).n;\n } else {\n t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;\n }\n }\n d3_timer_queueTail = t0;\n return time;\n }\n function d3_format_precision(x, p) {\n return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);\n }\n d3.round = function(x, n) {\n return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);\n };\n var d3_formatPrefixes = [ \"y\", \"z\", \"a\", \"f\", \"p\", \"n\", \"\u00B5\", \"m\", \"\", \"k\", \"M\", \"G\", \"T\", \"P\", \"E\", \"Z\", \"Y\" ].map(d3_formatPrefix);\n d3.formatPrefix = function(value, precision) {\n var i = 0;\n if (value = +value) {\n if (value < 0) value *= -1;\n if (precision) value = d3.round(value, d3_format_precision(value, precision));\n i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);\n i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));\n }\n return d3_formatPrefixes[8 + i / 3];\n };\n function d3_formatPrefix(d, i) {\n var k = Math.pow(10, abs(8 - i) * 3);\n return {\n scale: i > 8 ? function(d) {\n return d / k;\n } : function(d) {\n return d * k;\n },\n symbol: d\n };\n }\n function d3_locale_numberFormat(locale) {\n 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) {\n var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;\n while (i > 0 && g > 0) {\n if (length + g + 1 > width) g = Math.max(1, width - length);\n t.push(value.substring(i -= g, i + g));\n if ((length += g + 1) > width) break;\n g = locale_grouping[j = (j + 1) % locale_grouping.length];\n }\n return t.reverse().join(locale_thousands);\n } : d3_identity;\n return function(specifier) {\n 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;\n if (precision) precision = +precision.substring(1);\n if (zfill || fill === \"0\" && align === \"=\") {\n zfill = fill = \"0\";\n align = \"=\";\n }\n switch (type) {\n case \"n\":\n comma = true;\n type = \"g\";\n break;\n\n case \"%\":\n scale = 100;\n suffix = \"%\";\n type = \"f\";\n break;\n\n case \"p\":\n scale = 100;\n suffix = \"%\";\n type = \"r\";\n break;\n\n case \"b\":\n case \"o\":\n case \"x\":\n case \"X\":\n if (symbol === \"#\") prefix = \"0\" + type.toLowerCase();\n\n case \"c\":\n exponent = false;\n\n case \"d\":\n integer = true;\n precision = 0;\n break;\n\n case \"s\":\n scale = -1;\n type = \"r\";\n break;\n }\n if (symbol === \"$\") prefix = locale_currency[0], suffix = locale_currency[1];\n if (type == \"r\" && !precision) type = \"g\";\n if (precision != null) {\n if (type == \"g\") precision = Math.max(1, Math.min(21, precision)); else if (type == \"e\" || type == \"f\") precision = Math.max(0, Math.min(20, precision));\n }\n type = d3_format_types.get(type) || d3_format_typeDefault;\n var zcomma = zfill && comma;\n return function(value) {\n var fullSuffix = suffix;\n if (integer && value % 1) return \"\";\n var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, \"-\") : sign === \"-\" ? \"\" : sign;\n if (scale < 0) {\n var unit = d3.formatPrefix(value, precision);\n value = unit.scale(value);\n fullSuffix = unit.symbol + suffix;\n } else {\n value *= scale;\n }\n value = type(value, precision);\n var i = value.lastIndexOf(\".\"), before, after;\n if (i < 0) {\n var j = exponent ? value.lastIndexOf(\"e\") : -1;\n if (j < 0) before = value, after = \"\"; else before = value.substring(0, j), after = value.substring(j);\n } else {\n before = value.substring(0, i);\n after = locale_decimal + value.substring(i + 1);\n }\n if (!zfill && comma) before = formatGroup(before, Infinity);\n var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : \"\";\n if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);\n negative += prefix;\n value = before + after;\n 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;\n };\n };\n }\n var d3_format_re = /(?:([^{])?([<>=^]))?([+\\- ])?([$#])?(0)?(\\d+)?(,)?(\\.-?\\d+)?([a-z%])?/i;\n var d3_format_types = d3.map({\n b: function(x) {\n return x.toString(2);\n },\n c: function(x) {\n return String.fromCharCode(x);\n },\n o: function(x) {\n return x.toString(8);\n },\n x: function(x) {\n return x.toString(16);\n },\n X: function(x) {\n return x.toString(16).toUpperCase();\n },\n g: function(x, p) {\n return x.toPrecision(p);\n },\n e: function(x, p) {\n return x.toExponential(p);\n },\n f: function(x, p) {\n return x.toFixed(p);\n },\n r: function(x, p) {\n return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p))));\n }\n });\n function d3_format_typeDefault(x) {\n return x + \"\";\n }\n var d3_time = d3.time = {}, d3_date = Date;\n function d3_date_utc() {\n this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);\n }\n d3_date_utc.prototype = {\n getDate: function() {\n return this._.getUTCDate();\n },\n getDay: function() {\n return this._.getUTCDay();\n },\n getFullYear: function() {\n return this._.getUTCFullYear();\n },\n getHours: function() {\n return this._.getUTCHours();\n },\n getMilliseconds: function() {\n return this._.getUTCMilliseconds();\n },\n getMinutes: function() {\n return this._.getUTCMinutes();\n },\n getMonth: function() {\n return this._.getUTCMonth();\n },\n getSeconds: function() {\n return this._.getUTCSeconds();\n },\n getTime: function() {\n return this._.getTime();\n },\n getTimezoneOffset: function() {\n return 0;\n },\n valueOf: function() {\n return this._.valueOf();\n },\n setDate: function() {\n d3_time_prototype.setUTCDate.apply(this._, arguments);\n },\n setDay: function() {\n d3_time_prototype.setUTCDay.apply(this._, arguments);\n },\n setFullYear: function() {\n d3_time_prototype.setUTCFullYear.apply(this._, arguments);\n },\n setHours: function() {\n d3_time_prototype.setUTCHours.apply(this._, arguments);\n },\n setMilliseconds: function() {\n d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);\n },\n setMinutes: function() {\n d3_time_prototype.setUTCMinutes.apply(this._, arguments);\n },\n setMonth: function() {\n d3_time_prototype.setUTCMonth.apply(this._, arguments);\n },\n setSeconds: function() {\n d3_time_prototype.setUTCSeconds.apply(this._, arguments);\n },\n setTime: function() {\n d3_time_prototype.setTime.apply(this._, arguments);\n }\n };\n var d3_time_prototype = Date.prototype;\n function d3_time_interval(local, step, number) {\n function round(date) {\n var d0 = local(date), d1 = offset(d0, 1);\n return date - d0 < d1 - date ? d0 : d1;\n }\n function ceil(date) {\n step(date = local(new d3_date(date - 1)), 1);\n return date;\n }\n function offset(date, k) {\n step(date = new d3_date(+date), k);\n return date;\n }\n function range(t0, t1, dt) {\n var time = ceil(t0), times = [];\n if (dt > 1) {\n while (time < t1) {\n if (!(number(time) % dt)) times.push(new Date(+time));\n step(time, 1);\n }\n } else {\n while (time < t1) times.push(new Date(+time)), step(time, 1);\n }\n return times;\n }\n function range_utc(t0, t1, dt) {\n try {\n d3_date = d3_date_utc;\n var utc = new d3_date_utc();\n utc._ = t0;\n return range(utc, t1, dt);\n } finally {\n d3_date = Date;\n }\n }\n local.floor = local;\n local.round = round;\n local.ceil = ceil;\n local.offset = offset;\n local.range = range;\n var utc = local.utc = d3_time_interval_utc(local);\n utc.floor = utc;\n utc.round = d3_time_interval_utc(round);\n utc.ceil = d3_time_interval_utc(ceil);\n utc.offset = d3_time_interval_utc(offset);\n utc.range = range_utc;\n return local;\n }\n function d3_time_interval_utc(method) {\n return function(date, k) {\n try {\n d3_date = d3_date_utc;\n var utc = new d3_date_utc();\n utc._ = date;\n return method(utc, k)._;\n } finally {\n d3_date = Date;\n }\n };\n }\n d3_time.year = d3_time_interval(function(date) {\n date = d3_time.day(date);\n date.setMonth(0, 1);\n return date;\n }, function(date, offset) {\n date.setFullYear(date.getFullYear() + offset);\n }, function(date) {\n return date.getFullYear();\n });\n d3_time.years = d3_time.year.range;\n d3_time.years.utc = d3_time.year.utc.range;\n d3_time.day = d3_time_interval(function(date) {\n var day = new d3_date(2e3, 0);\n day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n return day;\n }, function(date, offset) {\n date.setDate(date.getDate() + offset);\n }, function(date) {\n return date.getDate() - 1;\n });\n d3_time.days = d3_time.day.range;\n d3_time.days.utc = d3_time.day.utc.range;\n d3_time.dayOfYear = function(date) {\n var year = d3_time.year(date);\n return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);\n };\n [ \"sunday\", \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\" ].forEach(function(day, i) {\n i = 7 - i;\n var interval = d3_time[day] = d3_time_interval(function(date) {\n (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);\n return date;\n }, function(date, offset) {\n date.setDate(date.getDate() + Math.floor(offset) * 7);\n }, function(date) {\n var day = d3_time.year(date).getDay();\n return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);\n });\n d3_time[day + \"s\"] = interval.range;\n d3_time[day + \"s\"].utc = interval.utc.range;\n d3_time[day + \"OfYear\"] = function(date) {\n var day = d3_time.year(date).getDay();\n return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);\n };\n });\n d3_time.week = d3_time.sunday;\n d3_time.weeks = d3_time.sunday.range;\n d3_time.weeks.utc = d3_time.sunday.utc.range;\n d3_time.weekOfYear = d3_time.sundayOfYear;\n function d3_locale_timeFormat(locale) {\n var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths;\n function d3_time_format(template) {\n var n = template.length;\n function format(date) {\n var string = [], i = -1, j = 0, c, p, f;\n while (++i < n) {\n if (template.charCodeAt(i) === 37) {\n string.push(template.slice(j, i));\n if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);\n if (f = d3_time_formats[c]) c = f(date, p == null ? c === \"e\" ? \" \" : \"0\" : p);\n string.push(c);\n j = i + 1;\n }\n }\n string.push(template.slice(j, i));\n return string.join(\"\");\n }\n format.parse = function(string) {\n var d = {\n y: 1900,\n m: 0,\n d: 1,\n H: 0,\n M: 0,\n S: 0,\n L: 0,\n Z: null\n }, i = d3_time_parse(d, template, string, 0);\n if (i != string.length) return null;\n if (\"p\" in d) d.H = d.H % 12 + d.p * 12;\n var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();\n if (\"j\" in d) date.setFullYear(d.y, 0, d.j); else if (\"W\" in d || \"U\" in d) {\n if (!(\"w\" in d)) d.w = \"W\" in d ? 1 : 0;\n date.setFullYear(d.y, 0, 1);\n 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);\n } else date.setFullYear(d.y, d.m, d.d);\n date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);\n return localZ ? date._ : date;\n };\n format.toString = function() {\n return template;\n };\n return format;\n }\n function d3_time_parse(date, template, string, j) {\n var c, p, t, i = 0, n = template.length, m = string.length;\n while (i < n) {\n if (j >= m) return -1;\n c = template.charCodeAt(i++);\n if (c === 37) {\n t = template.charAt(i++);\n p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];\n if (!p || (j = p(date, string, j)) < 0) return -1;\n } else if (c != string.charCodeAt(j++)) {\n return -1;\n }\n }\n return j;\n }\n d3_time_format.utc = function(template) {\n var local = d3_time_format(template);\n function format(date) {\n try {\n d3_date = d3_date_utc;\n var utc = new d3_date();\n utc._ = date;\n return local(utc);\n } finally {\n d3_date = Date;\n }\n }\n format.parse = function(string) {\n try {\n d3_date = d3_date_utc;\n var date = local.parse(string);\n return date && date._;\n } finally {\n d3_date = Date;\n }\n };\n format.toString = local.toString;\n return format;\n };\n d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;\n var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths);\n locale_periods.forEach(function(p, i) {\n d3_time_periodLookup.set(p.toLowerCase(), i);\n });\n var d3_time_formats = {\n a: function(d) {\n return locale_shortDays[d.getDay()];\n },\n A: function(d) {\n return locale_days[d.getDay()];\n },\n b: function(d) {\n return locale_shortMonths[d.getMonth()];\n },\n B: function(d) {\n return locale_months[d.getMonth()];\n },\n c: d3_time_format(locale_dateTime),\n d: function(d, p) {\n return d3_time_formatPad(d.getDate(), p, 2);\n },\n e: function(d, p) {\n return d3_time_formatPad(d.getDate(), p, 2);\n },\n H: function(d, p) {\n return d3_time_formatPad(d.getHours(), p, 2);\n },\n I: function(d, p) {\n return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);\n },\n j: function(d, p) {\n return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);\n },\n L: function(d, p) {\n return d3_time_formatPad(d.getMilliseconds(), p, 3);\n },\n m: function(d, p) {\n return d3_time_formatPad(d.getMonth() + 1, p, 2);\n },\n M: function(d, p) {\n return d3_time_formatPad(d.getMinutes(), p, 2);\n },\n p: function(d) {\n return locale_periods[+(d.getHours() >= 12)];\n },\n S: function(d, p) {\n return d3_time_formatPad(d.getSeconds(), p, 2);\n },\n U: function(d, p) {\n return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);\n },\n w: function(d) {\n return d.getDay();\n },\n W: function(d, p) {\n return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);\n },\n x: d3_time_format(locale_date),\n X: d3_time_format(locale_time),\n y: function(d, p) {\n return d3_time_formatPad(d.getFullYear() % 100, p, 2);\n },\n Y: function(d, p) {\n return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);\n },\n Z: d3_time_zone,\n \"%\": function() {\n return \"%\";\n }\n };\n var d3_time_parsers = {\n a: d3_time_parseWeekdayAbbrev,\n A: d3_time_parseWeekday,\n b: d3_time_parseMonthAbbrev,\n B: d3_time_parseMonth,\n c: d3_time_parseLocaleFull,\n d: d3_time_parseDay,\n e: d3_time_parseDay,\n H: d3_time_parseHour24,\n I: d3_time_parseHour24,\n j: d3_time_parseDayOfYear,\n L: d3_time_parseMilliseconds,\n m: d3_time_parseMonthNumber,\n M: d3_time_parseMinutes,\n p: d3_time_parseAmPm,\n S: d3_time_parseSeconds,\n U: d3_time_parseWeekNumberSunday,\n w: d3_time_parseWeekdayNumber,\n W: d3_time_parseWeekNumberMonday,\n x: d3_time_parseLocaleDate,\n X: d3_time_parseLocaleTime,\n y: d3_time_parseYear,\n Y: d3_time_parseFullYear,\n Z: d3_time_parseZone,\n \"%\": d3_time_parseLiteralPercent\n };\n function d3_time_parseWeekdayAbbrev(date, string, i) {\n d3_time_dayAbbrevRe.lastIndex = 0;\n var n = d3_time_dayAbbrevRe.exec(string.slice(i));\n return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n }\n function d3_time_parseWeekday(date, string, i) {\n d3_time_dayRe.lastIndex = 0;\n var n = d3_time_dayRe.exec(string.slice(i));\n return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n }\n function d3_time_parseMonthAbbrev(date, string, i) {\n d3_time_monthAbbrevRe.lastIndex = 0;\n var n = d3_time_monthAbbrevRe.exec(string.slice(i));\n return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n }\n function d3_time_parseMonth(date, string, i) {\n d3_time_monthRe.lastIndex = 0;\n var n = d3_time_monthRe.exec(string.slice(i));\n return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n }\n function d3_time_parseLocaleFull(date, string, i) {\n return d3_time_parse(date, d3_time_formats.c.toString(), string, i);\n }\n function d3_time_parseLocaleDate(date, string, i) {\n return d3_time_parse(date, d3_time_formats.x.toString(), string, i);\n }\n function d3_time_parseLocaleTime(date, string, i) {\n return d3_time_parse(date, d3_time_formats.X.toString(), string, i);\n }\n function d3_time_parseAmPm(date, string, i) {\n var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());\n return n == null ? -1 : (date.p = n, i);\n }\n return d3_time_format;\n }\n var d3_time_formatPads = {\n \"-\": \"\",\n _: \" \",\n \"0\": \"0\"\n }, d3_time_numberRe = /^\\s*\\d+/, d3_time_percentRe = /^%/;\n function d3_time_formatPad(value, fill, width) {\n var sign = value < 0 ? \"-\" : \"\", string = (sign ? -value : value) + \"\", length = string.length;\n return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);\n }\n function d3_time_formatRe(names) {\n return new RegExp(\"^(?:\" + names.map(d3.requote).join(\"|\") + \")\", \"i\");\n }\n function d3_time_formatLookup(names) {\n var map = new d3_Map(), i = -1, n = names.length;\n while (++i < n) map.set(names[i].toLowerCase(), i);\n return map;\n }\n function d3_time_parseWeekdayNumber(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 1));\n return n ? (date.w = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseWeekNumberSunday(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i));\n return n ? (date.U = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseWeekNumberMonday(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i));\n return n ? (date.W = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseFullYear(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 4));\n return n ? (date.y = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseYear(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;\n }\n function d3_time_parseZone(date, string, i) {\n return /^[+-]\\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, \n i + 5) : -1;\n }\n function d3_time_expandYear(d) {\n return d + (d > 68 ? 1900 : 2e3);\n }\n function d3_time_parseMonthNumber(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.m = n[0] - 1, i + n[0].length) : -1;\n }\n function d3_time_parseDay(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.d = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseDayOfYear(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n return n ? (date.j = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseHour24(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.H = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseMinutes(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.M = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseSeconds(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n return n ? (date.S = +n[0], i + n[0].length) : -1;\n }\n function d3_time_parseMilliseconds(date, string, i) {\n d3_time_numberRe.lastIndex = 0;\n var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n return n ? (date.L = +n[0], i + n[0].length) : -1;\n }\n function d3_time_zone(d) {\n var z = d.getTimezoneOffset(), zs = z > 0 ? \"-\" : \"+\", zh = abs(z) / 60 | 0, zm = abs(z) % 60;\n return zs + d3_time_formatPad(zh, \"0\", 2) + d3_time_formatPad(zm, \"0\", 2);\n }\n function d3_time_parseLiteralPercent(date, string, i) {\n d3_time_percentRe.lastIndex = 0;\n var n = d3_time_percentRe.exec(string.slice(i, i + 1));\n return n ? i + n[0].length : -1;\n }\n function d3_time_formatMulti(formats) {\n var n = formats.length, i = -1;\n while (++i < n) formats[i][0] = this(formats[i][0]);\n return function(date) {\n var i = 0, f = formats[i];\n while (!f[1](date)) f = formats[++i];\n return f[0](date);\n };\n }\n d3.locale = function(locale) {\n return {\n numberFormat: d3_locale_numberFormat(locale),\n timeFormat: d3_locale_timeFormat(locale)\n };\n };\n var d3_locale_enUS = d3.locale({\n decimal: \".\",\n thousands: \",\",\n grouping: [ 3 ],\n currency: [ \"$\", \"\" ],\n dateTime: \"%a %b %e %X %Y\",\n date: \"%m/%d/%Y\",\n time: \"%H:%M:%S\",\n periods: [ \"AM\", \"PM\" ],\n days: [ \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\" ],\n shortDays: [ \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" ],\n months: [ \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" ],\n shortMonths: [ \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" ]\n });\n d3.format = d3_locale_enUS.numberFormat;\n d3.geo = {};\n function d3_adder() {}\n d3_adder.prototype = {\n s: 0,\n t: 0,\n add: function(y) {\n d3_adderSum(y, this.t, d3_adderTemp);\n d3_adderSum(d3_adderTemp.s, this.s, this);\n if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;\n },\n reset: function() {\n this.s = this.t = 0;\n },\n valueOf: function() {\n return this.s;\n }\n };\n var d3_adderTemp = new d3_adder();\n function d3_adderSum(a, b, o) {\n var x = o.s = a + b, bv = x - a, av = x - bv;\n o.t = a - av + (b - bv);\n }\n d3.geo.stream = function(object, listener) {\n if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {\n d3_geo_streamObjectType[object.type](object, listener);\n } else {\n d3_geo_streamGeometry(object, listener);\n }\n };\n function d3_geo_streamGeometry(geometry, listener) {\n if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {\n d3_geo_streamGeometryType[geometry.type](geometry, listener);\n }\n }\n var d3_geo_streamObjectType = {\n Feature: function(feature, listener) {\n d3_geo_streamGeometry(feature.geometry, listener);\n },\n FeatureCollection: function(object, listener) {\n var features = object.features, i = -1, n = features.length;\n while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);\n }\n };\n var d3_geo_streamGeometryType = {\n Sphere: function(object, listener) {\n listener.sphere();\n },\n Point: function(object, listener) {\n object = object.coordinates;\n listener.point(object[0], object[1], object[2]);\n },\n MultiPoint: function(object, listener) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);\n },\n LineString: function(object, listener) {\n d3_geo_streamLine(object.coordinates, listener, 0);\n },\n MultiLineString: function(object, listener) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);\n },\n Polygon: function(object, listener) {\n d3_geo_streamPolygon(object.coordinates, listener);\n },\n MultiPolygon: function(object, listener) {\n var coordinates = object.coordinates, i = -1, n = coordinates.length;\n while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);\n },\n GeometryCollection: function(object, listener) {\n var geometries = object.geometries, i = -1, n = geometries.length;\n while (++i < n) d3_geo_streamGeometry(geometries[i], listener);\n }\n };\n function d3_geo_streamLine(coordinates, listener, closed) {\n var i = -1, n = coordinates.length - closed, coordinate;\n listener.lineStart();\n while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);\n listener.lineEnd();\n }\n function d3_geo_streamPolygon(coordinates, listener) {\n var i = -1, n = coordinates.length;\n listener.polygonStart();\n while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);\n listener.polygonEnd();\n }\n d3.geo.area = function(object) {\n d3_geo_areaSum = 0;\n d3.geo.stream(object, d3_geo_area);\n return d3_geo_areaSum;\n };\n var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();\n var d3_geo_area = {\n sphere: function() {\n d3_geo_areaSum += 4 * \u03C0;\n },\n point: d3_noop,\n lineStart: d3_noop,\n lineEnd: d3_noop,\n polygonStart: function() {\n d3_geo_areaRingSum.reset();\n d3_geo_area.lineStart = d3_geo_areaRingStart;\n },\n polygonEnd: function() {\n var area = 2 * d3_geo_areaRingSum;\n d3_geo_areaSum += area < 0 ? 4 * \u03C0 + area : area;\n d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;\n }\n };\n function d3_geo_areaRingStart() {\n var \u03BB00, \u03C600, \u03BB0, cos\u03C60, sin\u03C60;\n d3_geo_area.point = function(\u03BB, \u03C6) {\n d3_geo_area.point = nextPoint;\n \u03BB0 = (\u03BB00 = \u03BB) * d3_radians, cos\u03C60 = Math.cos(\u03C6 = (\u03C600 = \u03C6) * d3_radians / 2 + \u03C0 / 4), \n sin\u03C60 = Math.sin(\u03C6);\n };\n function nextPoint(\u03BB, \u03C6) {\n \u03BB *= d3_radians;\n \u03C6 = \u03C6 * d3_radians / 2 + \u03C0 / 4;\n var d\u03BB = \u03BB - \u03BB0, sd\u03BB = d\u03BB >= 0 ? 1 : -1, ad\u03BB = sd\u03BB * d\u03BB, cos\u03C6 = Math.cos(\u03C6), sin\u03C6 = Math.sin(\u03C6), k = sin\u03C60 * sin\u03C6, u = cos\u03C60 * cos\u03C6 + k * Math.cos(ad\u03BB), v = k * sd\u03BB * Math.sin(ad\u03BB);\n d3_geo_areaRingSum.add(Math.atan2(v, u));\n \u03BB0 = \u03BB, cos\u03C60 = cos\u03C6, sin\u03C60 = sin\u03C6;\n }\n d3_geo_area.lineEnd = function() {\n nextPoint(\u03BB00, \u03C600);\n };\n }\n function d3_geo_cartesian(spherical) {\n var \u03BB = spherical[0], \u03C6 = spherical[1], cos\u03C6 = Math.cos(\u03C6);\n return [ cos\u03C6 * Math.cos(\u03BB), cos\u03C6 * Math.sin(\u03BB), Math.sin(\u03C6) ];\n }\n function d3_geo_cartesianDot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n }\n function d3_geo_cartesianCross(a, b) {\n return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ];\n }\n function d3_geo_cartesianAdd(a, b) {\n a[0] += b[0];\n a[1] += b[1];\n a[2] += b[2];\n }\n function d3_geo_cartesianScale(vector, k) {\n return [ vector[0] * k, vector[1] * k, vector[2] * k ];\n }\n function d3_geo_cartesianNormalize(d) {\n var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);\n d[0] /= l;\n d[1] /= l;\n d[2] /= l;\n }\n function d3_geo_spherical(cartesian) {\n return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];\n }\n function d3_geo_sphericalEqual(a, b) {\n return abs(a[0] - b[0]) < \u03B5 && abs(a[1] - b[1]) < \u03B5;\n }\n d3.geo.bounds = function() {\n var \u03BB0, \u03C60, \u03BB1, \u03C61, \u03BB_, \u03BB__, \u03C6__, p0, d\u03BBSum, ranges, range;\n var bound = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() {\n bound.point = ringPoint;\n bound.lineStart = ringStart;\n bound.lineEnd = ringEnd;\n d\u03BBSum = 0;\n d3_geo_area.polygonStart();\n },\n polygonEnd: function() {\n d3_geo_area.polygonEnd();\n bound.point = point;\n bound.lineStart = lineStart;\n bound.lineEnd = lineEnd;\n if (d3_geo_areaRingSum < 0) \u03BB0 = -(\u03BB1 = 180), \u03C60 = -(\u03C61 = 90); else if (d\u03BBSum > \u03B5) \u03C61 = 90; else if (d\u03BBSum < -\u03B5) \u03C60 = -90;\n range[0] = \u03BB0, range[1] = \u03BB1;\n }\n };\n function point(\u03BB, \u03C6) {\n ranges.push(range = [ \u03BB0 = \u03BB, \u03BB1 = \u03BB ]);\n if (\u03C6 < \u03C60) \u03C60 = \u03C6;\n if (\u03C6 > \u03C61) \u03C61 = \u03C6;\n }\n function linePoint(\u03BB, \u03C6) {\n var p = d3_geo_cartesian([ \u03BB * d3_radians, \u03C6 * d3_radians ]);\n if (p0) {\n var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);\n d3_geo_cartesianNormalize(inflection);\n inflection = d3_geo_spherical(inflection);\n var d\u03BB = \u03BB - \u03BB_, s = d\u03BB > 0 ? 1 : -1, \u03BBi = inflection[0] * d3_degrees * s, antimeridian = abs(d\u03BB) > 180;\n if (antimeridian ^ (s * \u03BB_ < \u03BBi && \u03BBi < s * \u03BB)) {\n var \u03C6i = inflection[1] * d3_degrees;\n if (\u03C6i > \u03C61) \u03C61 = \u03C6i;\n } else if (\u03BBi = (\u03BBi + 360) % 360 - 180, antimeridian ^ (s * \u03BB_ < \u03BBi && \u03BBi < s * \u03BB)) {\n var \u03C6i = -inflection[1] * d3_degrees;\n if (\u03C6i < \u03C60) \u03C60 = \u03C6i;\n } else {\n if (\u03C6 < \u03C60) \u03C60 = \u03C6;\n if (\u03C6 > \u03C61) \u03C61 = \u03C6;\n }\n if (antimeridian) {\n if (\u03BB < \u03BB_) {\n if (angle(\u03BB0, \u03BB) > angle(\u03BB0, \u03BB1)) \u03BB1 = \u03BB;\n } else {\n if (angle(\u03BB, \u03BB1) > angle(\u03BB0, \u03BB1)) \u03BB0 = \u03BB;\n }\n } else {\n if (\u03BB1 >= \u03BB0) {\n if (\u03BB < \u03BB0) \u03BB0 = \u03BB;\n if (\u03BB > \u03BB1) \u03BB1 = \u03BB;\n } else {\n if (\u03BB > \u03BB_) {\n if (angle(\u03BB0, \u03BB) > angle(\u03BB0, \u03BB1)) \u03BB1 = \u03BB;\n } else {\n if (angle(\u03BB, \u03BB1) > angle(\u03BB0, \u03BB1)) \u03BB0 = \u03BB;\n }\n }\n }\n } else {\n point(\u03BB, \u03C6);\n }\n p0 = p, \u03BB_ = \u03BB;\n }\n function lineStart() {\n bound.point = linePoint;\n }\n function lineEnd() {\n range[0] = \u03BB0, range[1] = \u03BB1;\n bound.point = point;\n p0 = null;\n }\n function ringPoint(\u03BB, \u03C6) {\n if (p0) {\n var d\u03BB = \u03BB - \u03BB_;\n d\u03BBSum += abs(d\u03BB) > 180 ? d\u03BB + (d\u03BB > 0 ? 360 : -360) : d\u03BB;\n } else \u03BB__ = \u03BB, \u03C6__ = \u03C6;\n d3_geo_area.point(\u03BB, \u03C6);\n linePoint(\u03BB, \u03C6);\n }\n function ringStart() {\n d3_geo_area.lineStart();\n }\n function ringEnd() {\n ringPoint(\u03BB__, \u03C6__);\n d3_geo_area.lineEnd();\n if (abs(d\u03BBSum) > \u03B5) \u03BB0 = -(\u03BB1 = 180);\n range[0] = \u03BB0, range[1] = \u03BB1;\n p0 = null;\n }\n function angle(\u03BB0, \u03BB1) {\n return (\u03BB1 -= \u03BB0) < 0 ? \u03BB1 + 360 : \u03BB1;\n }\n function compareRanges(a, b) {\n return a[0] - b[0];\n }\n function withinRange(x, range) {\n return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;\n }\n return function(feature) {\n \u03C61 = \u03BB1 = -(\u03BB0 = \u03C60 = Infinity);\n ranges = [];\n d3.geo.stream(feature, bound);\n var n = ranges.length;\n if (n) {\n ranges.sort(compareRanges);\n for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {\n b = ranges[i];\n if (withinRange(b[0], a) || withinRange(b[1], a)) {\n if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];\n if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];\n } else {\n merged.push(a = b);\n }\n }\n var best = -Infinity, d\u03BB;\n for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {\n b = merged[i];\n if ((d\u03BB = angle(a[1], b[0])) > best) best = d\u03BB, \u03BB0 = b[0], \u03BB1 = a[1];\n }\n }\n ranges = range = null;\n return \u03BB0 === Infinity || \u03C60 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ \u03BB0, \u03C60 ], [ \u03BB1, \u03C61 ] ];\n };\n }();\n d3.geo.centroid = function(object) {\n d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n d3.geo.stream(object, d3_geo_centroid);\n var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;\n if (m < \u03B52) {\n x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;\n if (d3_geo_centroidW1 < \u03B5) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;\n m = x * x + y * y + z * z;\n if (m < \u03B52) return [ NaN, NaN ];\n }\n return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];\n };\n var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2;\n var d3_geo_centroid = {\n sphere: d3_noop,\n point: d3_geo_centroidPoint,\n lineStart: d3_geo_centroidLineStart,\n lineEnd: d3_geo_centroidLineEnd,\n polygonStart: function() {\n d3_geo_centroid.lineStart = d3_geo_centroidRingStart;\n },\n polygonEnd: function() {\n d3_geo_centroid.lineStart = d3_geo_centroidLineStart;\n }\n };\n function d3_geo_centroidPoint(\u03BB, \u03C6) {\n \u03BB *= d3_radians;\n var cos\u03C6 = Math.cos(\u03C6 *= d3_radians);\n d3_geo_centroidPointXYZ(cos\u03C6 * Math.cos(\u03BB), cos\u03C6 * Math.sin(\u03BB), Math.sin(\u03C6));\n }\n function d3_geo_centroidPointXYZ(x, y, z) {\n ++d3_geo_centroidW0;\n d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;\n d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;\n d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;\n }\n function d3_geo_centroidLineStart() {\n var x0, y0, z0;\n d3_geo_centroid.point = function(\u03BB, \u03C6) {\n \u03BB *= d3_radians;\n var cos\u03C6 = Math.cos(\u03C6 *= d3_radians);\n x0 = cos\u03C6 * Math.cos(\u03BB);\n y0 = cos\u03C6 * Math.sin(\u03BB);\n z0 = Math.sin(\u03C6);\n d3_geo_centroid.point = nextPoint;\n d3_geo_centroidPointXYZ(x0, y0, z0);\n };\n function nextPoint(\u03BB, \u03C6) {\n \u03BB *= d3_radians;\n var cos\u03C6 = Math.cos(\u03C6 *= d3_radians), x = cos\u03C6 * Math.cos(\u03BB), y = cos\u03C6 * Math.sin(\u03BB), z = Math.sin(\u03C6), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);\n d3_geo_centroidW1 += w;\n d3_geo_centroidX1 += w * (x0 + (x0 = x));\n d3_geo_centroidY1 += w * (y0 + (y0 = y));\n d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n d3_geo_centroidPointXYZ(x0, y0, z0);\n }\n }\n function d3_geo_centroidLineEnd() {\n d3_geo_centroid.point = d3_geo_centroidPoint;\n }\n function d3_geo_centroidRingStart() {\n var \u03BB00, \u03C600, x0, y0, z0;\n d3_geo_centroid.point = function(\u03BB, \u03C6) {\n \u03BB00 = \u03BB, \u03C600 = \u03C6;\n d3_geo_centroid.point = nextPoint;\n \u03BB *= d3_radians;\n var cos\u03C6 = Math.cos(\u03C6 *= d3_radians);\n x0 = cos\u03C6 * Math.cos(\u03BB);\n y0 = cos\u03C6 * Math.sin(\u03BB);\n z0 = Math.sin(\u03C6);\n d3_geo_centroidPointXYZ(x0, y0, z0);\n };\n d3_geo_centroid.lineEnd = function() {\n nextPoint(\u03BB00, \u03C600);\n d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;\n d3_geo_centroid.point = d3_geo_centroidPoint;\n };\n function nextPoint(\u03BB, \u03C6) {\n \u03BB *= d3_radians;\n var cos\u03C6 = Math.cos(\u03C6 *= d3_radians), x = cos\u03C6 * Math.cos(\u03BB), y = cos\u03C6 * Math.sin(\u03BB), z = Math.sin(\u03C6), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u);\n d3_geo_centroidX2 += v * cx;\n d3_geo_centroidY2 += v * cy;\n d3_geo_centroidZ2 += v * cz;\n d3_geo_centroidW1 += w;\n d3_geo_centroidX1 += w * (x0 + (x0 = x));\n d3_geo_centroidY1 += w * (y0 + (y0 = y));\n d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n d3_geo_centroidPointXYZ(x0, y0, z0);\n }\n }\n function d3_geo_compose(a, b) {\n function compose(x, y) {\n return x = a(x, y), b(x[0], x[1]);\n }\n if (a.invert && b.invert) compose.invert = function(x, y) {\n return x = b.invert(x, y), x && a.invert(x[0], x[1]);\n };\n return compose;\n }\n function d3_true() {\n return true;\n }\n function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {\n var subject = [], clip = [];\n segments.forEach(function(segment) {\n if ((n = segment.length - 1) <= 0) return;\n var n, p0 = segment[0], p1 = segment[n];\n if (d3_geo_sphericalEqual(p0, p1)) {\n listener.lineStart();\n for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);\n listener.lineEnd();\n return;\n }\n var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);\n a.o = b;\n subject.push(a);\n clip.push(b);\n a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);\n b = new d3_geo_clipPolygonIntersection(p1, null, a, true);\n a.o = b;\n subject.push(a);\n clip.push(b);\n });\n clip.sort(compare);\n d3_geo_clipPolygonLinkCircular(subject);\n d3_geo_clipPolygonLinkCircular(clip);\n if (!subject.length) return;\n for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {\n clip[i].e = entry = !entry;\n }\n var start = subject[0], points, point;\n while (1) {\n var current = start, isSubject = true;\n while (current.v) if ((current = current.n) === start) return;\n points = current.z;\n listener.lineStart();\n do {\n current.v = current.o.v = true;\n if (current.e) {\n if (isSubject) {\n for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);\n } else {\n interpolate(current.x, current.n.x, 1, listener);\n }\n current = current.n;\n } else {\n if (isSubject) {\n points = current.p.z;\n for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);\n } else {\n interpolate(current.x, current.p.x, -1, listener);\n }\n current = current.p;\n }\n current = current.o;\n points = current.z;\n isSubject = !isSubject;\n } while (!current.v);\n listener.lineEnd();\n }\n }\n function d3_geo_clipPolygonLinkCircular(array) {\n if (!(n = array.length)) return;\n var n, i = 0, a = array[0], b;\n while (++i < n) {\n a.n = b = array[i];\n b.p = a;\n a = b;\n }\n a.n = b = array[0];\n b.p = a;\n }\n function d3_geo_clipPolygonIntersection(point, points, other, entry) {\n this.x = point;\n this.z = points;\n this.o = other;\n this.e = entry;\n this.v = false;\n this.n = this.p = null;\n }\n function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {\n return function(rotate, listener) {\n var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);\n var clip = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() {\n clip.point = pointRing;\n clip.lineStart = ringStart;\n clip.lineEnd = ringEnd;\n segments = [];\n polygon = [];\n },\n polygonEnd: function() {\n clip.point = point;\n clip.lineStart = lineStart;\n clip.lineEnd = lineEnd;\n segments = d3.merge(segments);\n var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);\n if (segments.length) {\n if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);\n } else if (clipStartInside) {\n if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n listener.lineStart();\n interpolate(null, null, 1, listener);\n listener.lineEnd();\n }\n if (polygonStarted) listener.polygonEnd(), polygonStarted = false;\n segments = polygon = null;\n },\n sphere: function() {\n listener.polygonStart();\n listener.lineStart();\n interpolate(null, null, 1, listener);\n listener.lineEnd();\n listener.polygonEnd();\n }\n };\n function point(\u03BB, \u03C6) {\n var point = rotate(\u03BB, \u03C6);\n if (pointVisible(\u03BB = point[0], \u03C6 = point[1])) listener.point(\u03BB, \u03C6);\n }\n function pointLine(\u03BB, \u03C6) {\n var point = rotate(\u03BB, \u03C6);\n line.point(point[0], point[1]);\n }\n function lineStart() {\n clip.point = pointLine;\n line.lineStart();\n }\n function lineEnd() {\n clip.point = point;\n line.lineEnd();\n }\n var segments;\n var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;\n function pointRing(\u03BB, \u03C6) {\n ring.push([ \u03BB, \u03C6 ]);\n var point = rotate(\u03BB, \u03C6);\n ringListener.point(point[0], point[1]);\n }\n function ringStart() {\n ringListener.lineStart();\n ring = [];\n }\n function ringEnd() {\n pointRing(ring[0][0], ring[0][1]);\n ringListener.lineEnd();\n var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;\n ring.pop();\n polygon.push(ring);\n ring = null;\n if (!n) return;\n if (clean & 1) {\n segment = ringSegments[0];\n var n = segment.length - 1, i = -1, point;\n if (n > 0) {\n if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n listener.lineStart();\n while (++i < n) listener.point((point = segment[i])[0], point[1]);\n listener.lineEnd();\n }\n return;\n }\n if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));\n segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));\n }\n return clip;\n };\n }\n function d3_geo_clipSegmentLength1(segment) {\n return segment.length > 1;\n }\n function d3_geo_clipBufferListener() {\n var lines = [], line;\n return {\n lineStart: function() {\n lines.push(line = []);\n },\n point: function(\u03BB, \u03C6) {\n line.push([ \u03BB, \u03C6 ]);\n },\n lineEnd: d3_noop,\n buffer: function() {\n var buffer = lines;\n lines = [];\n line = null;\n return buffer;\n },\n rejoin: function() {\n if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));\n }\n };\n }\n function d3_geo_clipSort(a, b) {\n return ((a = a.x)[0] < 0 ? a[1] - half\u03C0 - \u03B5 : half\u03C0 - a[1]) - ((b = b.x)[0] < 0 ? b[1] - half\u03C0 - \u03B5 : half\u03C0 - b[1]);\n }\n var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -\u03C0, -\u03C0 / 2 ]);\n function d3_geo_clipAntimeridianLine(listener) {\n var \u03BB0 = NaN, \u03C60 = NaN, s\u03BB0 = NaN, clean;\n return {\n lineStart: function() {\n listener.lineStart();\n clean = 1;\n },\n point: function(\u03BB1, \u03C61) {\n var s\u03BB1 = \u03BB1 > 0 ? \u03C0 : -\u03C0, d\u03BB = abs(\u03BB1 - \u03BB0);\n if (abs(d\u03BB - \u03C0) < \u03B5) {\n listener.point(\u03BB0, \u03C60 = (\u03C60 + \u03C61) / 2 > 0 ? half\u03C0 : -half\u03C0);\n listener.point(s\u03BB0, \u03C60);\n listener.lineEnd();\n listener.lineStart();\n listener.point(s\u03BB1, \u03C60);\n listener.point(\u03BB1, \u03C60);\n clean = 0;\n } else if (s\u03BB0 !== s\u03BB1 && d\u03BB >= \u03C0) {\n if (abs(\u03BB0 - s\u03BB0) < \u03B5) \u03BB0 -= s\u03BB0 * \u03B5;\n if (abs(\u03BB1 - s\u03BB1) < \u03B5) \u03BB1 -= s\u03BB1 * \u03B5;\n \u03C60 = d3_geo_clipAntimeridianIntersect(\u03BB0, \u03C60, \u03BB1, \u03C61);\n listener.point(s\u03BB0, \u03C60);\n listener.lineEnd();\n listener.lineStart();\n listener.point(s\u03BB1, \u03C60);\n clean = 0;\n }\n listener.point(\u03BB0 = \u03BB1, \u03C60 = \u03C61);\n s\u03BB0 = s\u03BB1;\n },\n lineEnd: function() {\n listener.lineEnd();\n \u03BB0 = \u03C60 = NaN;\n },\n clean: function() {\n return 2 - clean;\n }\n };\n }\n function d3_geo_clipAntimeridianIntersect(\u03BB0, \u03C60, \u03BB1, \u03C61) {\n var cos\u03C60, cos\u03C61, sin\u03BB0_\u03BB1 = Math.sin(\u03BB0 - \u03BB1);\n return abs(sin\u03BB0_\u03BB1) > \u03B5 ? Math.atan((Math.sin(\u03C60) * (cos\u03C61 = Math.cos(\u03C61)) * Math.sin(\u03BB1) - Math.sin(\u03C61) * (cos\u03C60 = Math.cos(\u03C60)) * Math.sin(\u03BB0)) / (cos\u03C60 * cos\u03C61 * sin\u03BB0_\u03BB1)) : (\u03C60 + \u03C61) / 2;\n }\n function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {\n var \u03C6;\n if (from == null) {\n \u03C6 = direction * half\u03C0;\n listener.point(-\u03C0, \u03C6);\n listener.point(0, \u03C6);\n listener.point(\u03C0, \u03C6);\n listener.point(\u03C0, 0);\n listener.point(\u03C0, -\u03C6);\n listener.point(0, -\u03C6);\n listener.point(-\u03C0, -\u03C6);\n listener.point(-\u03C0, 0);\n listener.point(-\u03C0, \u03C6);\n } else if (abs(from[0] - to[0]) > \u03B5) {\n var s = from[0] < to[0] ? \u03C0 : -\u03C0;\n \u03C6 = direction * s / 2;\n listener.point(-s, \u03C6);\n listener.point(0, \u03C6);\n listener.point(s, \u03C6);\n } else {\n listener.point(to[0], to[1]);\n }\n }\n function d3_geo_pointInPolygon(point, polygon) {\n var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;\n d3_geo_areaRingSum.reset();\n for (var i = 0, n = polygon.length; i < n; ++i) {\n var ring = polygon[i], m = ring.length;\n if (!m) continue;\n var point0 = ring[0], \u03BB0 = point0[0], \u03C60 = point0[1] / 2 + \u03C0 / 4, sin\u03C60 = Math.sin(\u03C60), cos\u03C60 = Math.cos(\u03C60), j = 1;\n while (true) {\n if (j === m) j = 0;\n point = ring[j];\n var \u03BB = point[0], \u03C6 = point[1] / 2 + \u03C0 / 4, sin\u03C6 = Math.sin(\u03C6), cos\u03C6 = Math.cos(\u03C6), d\u03BB = \u03BB - \u03BB0, sd\u03BB = d\u03BB >= 0 ? 1 : -1, ad\u03BB = sd\u03BB * d\u03BB, antimeridian = ad\u03BB > \u03C0, k = sin\u03C60 * sin\u03C6;\n d3_geo_areaRingSum.add(Math.atan2(k * sd\u03BB * Math.sin(ad\u03BB), cos\u03C60 * cos\u03C6 + k * Math.cos(ad\u03BB)));\n polarAngle += antimeridian ? d\u03BB + sd\u03BB * \u03C4 : d\u03BB;\n if (antimeridian ^ \u03BB0 >= meridian ^ \u03BB >= meridian) {\n var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));\n d3_geo_cartesianNormalize(arc);\n var intersection = d3_geo_cartesianCross(meridianNormal, arc);\n d3_geo_cartesianNormalize(intersection);\n var \u03C6arc = (antimeridian ^ d\u03BB >= 0 ? -1 : 1) * d3_asin(intersection[2]);\n if (parallel > \u03C6arc || parallel === \u03C6arc && (arc[0] || arc[1])) {\n winding += antimeridian ^ d\u03BB >= 0 ? 1 : -1;\n }\n }\n if (!j++) break;\n \u03BB0 = \u03BB, sin\u03C60 = sin\u03C6, cos\u03C60 = cos\u03C6, point0 = point;\n }\n }\n return (polarAngle < -\u03B5 || polarAngle < \u03B5 && d3_geo_areaRingSum < -\u03B5) ^ winding & 1;\n }\n function d3_geo_clipCircle(radius) {\n var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > \u03B5, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);\n return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -\u03C0, radius - \u03C0 ]);\n function visible(\u03BB, \u03C6) {\n return Math.cos(\u03BB) * Math.cos(\u03C6) > cr;\n }\n function clipLine(listener) {\n var point0, c0, v0, v00, clean;\n return {\n lineStart: function() {\n v00 = v0 = false;\n clean = 1;\n },\n point: function(\u03BB, \u03C6) {\n var point1 = [ \u03BB, \u03C6 ], point2, v = visible(\u03BB, \u03C6), c = smallRadius ? v ? 0 : code(\u03BB, \u03C6) : v ? code(\u03BB + (\u03BB < 0 ? \u03C0 : -\u03C0), \u03C6) : 0;\n if (!point0 && (v00 = v0 = v)) listener.lineStart();\n if (v !== v0) {\n point2 = intersect(point0, point1);\n if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {\n point1[0] += \u03B5;\n point1[1] += \u03B5;\n v = visible(point1[0], point1[1]);\n }\n }\n if (v !== v0) {\n clean = 0;\n if (v) {\n listener.lineStart();\n point2 = intersect(point1, point0);\n listener.point(point2[0], point2[1]);\n } else {\n point2 = intersect(point0, point1);\n listener.point(point2[0], point2[1]);\n listener.lineEnd();\n }\n point0 = point2;\n } else if (notHemisphere && point0 && smallRadius ^ v) {\n var t;\n if (!(c & c0) && (t = intersect(point1, point0, true))) {\n clean = 0;\n if (smallRadius) {\n listener.lineStart();\n listener.point(t[0][0], t[0][1]);\n listener.point(t[1][0], t[1][1]);\n listener.lineEnd();\n } else {\n listener.point(t[1][0], t[1][1]);\n listener.lineEnd();\n listener.lineStart();\n listener.point(t[0][0], t[0][1]);\n }\n }\n }\n if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {\n listener.point(point1[0], point1[1]);\n }\n point0 = point1, v0 = v, c0 = c;\n },\n lineEnd: function() {\n if (v0) listener.lineEnd();\n point0 = null;\n },\n clean: function() {\n return clean | (v00 && v0) << 1;\n }\n };\n }\n function intersect(a, b, two) {\n var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);\n var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;\n if (!determinant) return !two && a;\n var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2);\n d3_geo_cartesianAdd(A, B);\n var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1);\n if (t2 < 0) return;\n var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);\n d3_geo_cartesianAdd(q, A);\n q = d3_geo_spherical(q);\n if (!two) return q;\n var \u03BB0 = a[0], \u03BB1 = b[0], \u03C60 = a[1], \u03C61 = b[1], z;\n if (\u03BB1 < \u03BB0) z = \u03BB0, \u03BB0 = \u03BB1, \u03BB1 = z;\n var \u03B4\u03BB = \u03BB1 - \u03BB0, polar = abs(\u03B4\u03BB - \u03C0) < \u03B5, meridian = polar || \u03B4\u03BB < \u03B5;\n if (!polar && \u03C61 < \u03C60) z = \u03C60, \u03C60 = \u03C61, \u03C61 = z;\n if (meridian ? polar ? \u03C60 + \u03C61 > 0 ^ q[1] < (abs(q[0] - \u03BB0) < \u03B5 ? \u03C60 : \u03C61) : \u03C60 <= q[1] && q[1] <= \u03C61 : \u03B4\u03BB > \u03C0 ^ (\u03BB0 <= q[0] && q[0] <= \u03BB1)) {\n var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);\n d3_geo_cartesianAdd(q1, A);\n return [ q, d3_geo_spherical(q1) ];\n }\n }\n function code(\u03BB, \u03C6) {\n var r = smallRadius ? radius : \u03C0 - radius, code = 0;\n if (\u03BB < -r) code |= 1; else if (\u03BB > r) code |= 2;\n if (\u03C6 < -r) code |= 4; else if (\u03C6 > r) code |= 8;\n return code;\n }\n }\n function d3_geom_clipLine(x0, y0, x1, y1) {\n return function(line) {\n var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;\n r = x0 - ax;\n if (!dx && r > 0) return;\n r /= dx;\n if (dx < 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n } else if (dx > 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n }\n r = x1 - ax;\n if (!dx && r < 0) return;\n r /= dx;\n if (dx < 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n } else if (dx > 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n }\n r = y0 - ay;\n if (!dy && r > 0) return;\n r /= dy;\n if (dy < 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n } else if (dy > 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n }\n r = y1 - ay;\n if (!dy && r < 0) return;\n r /= dy;\n if (dy < 0) {\n if (r > t1) return;\n if (r > t0) t0 = r;\n } else if (dy > 0) {\n if (r < t0) return;\n if (r < t1) t1 = r;\n }\n if (t0 > 0) line.a = {\n x: ax + t0 * dx,\n y: ay + t0 * dy\n };\n if (t1 < 1) line.b = {\n x: ax + t1 * dx,\n y: ay + t1 * dy\n };\n return line;\n };\n }\n var d3_geo_clipExtentMAX = 1e9;\n d3.geo.clipExtent = function() {\n var x0, y0, x1, y1, stream, clip, clipExtent = {\n stream: function(output) {\n if (stream) stream.valid = false;\n stream = clip(output);\n stream.valid = true;\n return stream;\n },\n extent: function(_) {\n if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);\n if (stream) stream.valid = false, stream = null;\n return clipExtent;\n }\n };\n return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);\n };\n function d3_geo_clipExtent(x0, y0, x1, y1) {\n return function(listener) {\n var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;\n var clip = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() {\n listener = bufferListener;\n segments = [];\n polygon = [];\n clean = true;\n },\n polygonEnd: function() {\n listener = listener_;\n segments = d3.merge(segments);\n var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;\n if (inside || visible) {\n listener.polygonStart();\n if (inside) {\n listener.lineStart();\n interpolate(null, null, 1, listener);\n listener.lineEnd();\n }\n if (visible) {\n d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);\n }\n listener.polygonEnd();\n }\n segments = polygon = ring = null;\n }\n };\n function insidePolygon(p) {\n var wn = 0, n = polygon.length, y = p[1];\n for (var i = 0; i < n; ++i) {\n for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {\n b = v[j];\n if (a[1] <= y) {\n if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;\n } else {\n if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;\n }\n a = b;\n }\n }\n return wn !== 0;\n }\n function interpolate(from, to, direction, listener) {\n var a = 0, a1 = 0;\n if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {\n do {\n listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);\n } while ((a = (a + direction + 4) % 4) !== a1);\n } else {\n listener.point(to[0], to[1]);\n }\n }\n function pointVisible(x, y) {\n return x0 <= x && x <= x1 && y0 <= y && y <= y1;\n }\n function point(x, y) {\n if (pointVisible(x, y)) listener.point(x, y);\n }\n var x__, y__, v__, x_, y_, v_, first, clean;\n function lineStart() {\n clip.point = linePoint;\n if (polygon) polygon.push(ring = []);\n first = true;\n v_ = false;\n x_ = y_ = NaN;\n }\n function lineEnd() {\n if (segments) {\n linePoint(x__, y__);\n if (v__ && v_) bufferListener.rejoin();\n segments.push(bufferListener.buffer());\n }\n clip.point = point;\n if (v_) listener.lineEnd();\n }\n function linePoint(x, y) {\n x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));\n y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));\n var v = pointVisible(x, y);\n if (polygon) ring.push([ x, y ]);\n if (first) {\n x__ = x, y__ = y, v__ = v;\n first = false;\n if (v) {\n listener.lineStart();\n listener.point(x, y);\n }\n } else {\n if (v && v_) listener.point(x, y); else {\n var l = {\n a: {\n x: x_,\n y: y_\n },\n b: {\n x: x,\n y: y\n }\n };\n if (clipLine(l)) {\n if (!v_) {\n listener.lineStart();\n listener.point(l.a.x, l.a.y);\n }\n listener.point(l.b.x, l.b.y);\n if (!v) listener.lineEnd();\n clean = false;\n } else if (v) {\n listener.lineStart();\n listener.point(x, y);\n clean = false;\n }\n }\n }\n x_ = x, y_ = y, v_ = v;\n }\n return clip;\n };\n function corner(p, direction) {\n return abs(p[0] - x0) < \u03B5 ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < \u03B5 ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < \u03B5 ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;\n }\n function compare(a, b) {\n return comparePoints(a.x, b.x);\n }\n function comparePoints(a, b) {\n var ca = corner(a, 1), cb = corner(b, 1);\n return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];\n }\n }\n function d3_geo_conic(projectAt) {\n var \u03C60 = 0, \u03C61 = \u03C0 / 3, m = d3_geo_projectionMutator(projectAt), p = m(\u03C60, \u03C61);\n p.parallels = function(_) {\n if (!arguments.length) return [ \u03C60 / \u03C0 * 180, \u03C61 / \u03C0 * 180 ];\n return m(\u03C60 = _[0] * \u03C0 / 180, \u03C61 = _[1] * \u03C0 / 180);\n };\n return p;\n }\n function d3_geo_conicEqualArea(\u03C60, \u03C61) {\n var sin\u03C60 = Math.sin(\u03C60), n = (sin\u03C60 + Math.sin(\u03C61)) / 2, C = 1 + sin\u03C60 * (2 * n - sin\u03C60), \u03C10 = Math.sqrt(C) / n;\n function forward(\u03BB, \u03C6) {\n var \u03C1 = Math.sqrt(C - 2 * n * Math.sin(\u03C6)) / n;\n return [ \u03C1 * Math.sin(\u03BB *= n), \u03C10 - \u03C1 * Math.cos(\u03BB) ];\n }\n forward.invert = function(x, y) {\n var \u03C10_y = \u03C10 - y;\n return [ Math.atan2(x, \u03C10_y) / n, d3_asin((C - (x * x + \u03C10_y * \u03C10_y) * n * n) / (2 * n)) ];\n };\n return forward;\n }\n (d3.geo.conicEqualArea = function() {\n return d3_geo_conic(d3_geo_conicEqualArea);\n }).raw = d3_geo_conicEqualArea;\n d3.geo.albers = function() {\n return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);\n };\n d3.geo.albersUsa = function() {\n var lower48 = d3.geo.albers();\n var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);\n var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);\n var point, pointStream = {\n point: function(x, y) {\n point = [ x, y ];\n }\n }, lower48Point, alaskaPoint, hawaiiPoint;\n function albersUsa(coordinates) {\n var x = coordinates[0], y = coordinates[1];\n point = null;\n (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);\n return point;\n }\n albersUsa.invert = function(coordinates) {\n var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;\n return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);\n };\n albersUsa.stream = function(stream) {\n var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);\n return {\n point: function(x, y) {\n lower48Stream.point(x, y);\n alaskaStream.point(x, y);\n hawaiiStream.point(x, y);\n },\n sphere: function() {\n lower48Stream.sphere();\n alaskaStream.sphere();\n hawaiiStream.sphere();\n },\n lineStart: function() {\n lower48Stream.lineStart();\n alaskaStream.lineStart();\n hawaiiStream.lineStart();\n },\n lineEnd: function() {\n lower48Stream.lineEnd();\n alaskaStream.lineEnd();\n hawaiiStream.lineEnd();\n },\n polygonStart: function() {\n lower48Stream.polygonStart();\n alaskaStream.polygonStart();\n hawaiiStream.polygonStart();\n },\n polygonEnd: function() {\n lower48Stream.polygonEnd();\n alaskaStream.polygonEnd();\n hawaiiStream.polygonEnd();\n }\n };\n };\n albersUsa.precision = function(_) {\n if (!arguments.length) return lower48.precision();\n lower48.precision(_);\n alaska.precision(_);\n hawaii.precision(_);\n return albersUsa;\n };\n albersUsa.scale = function(_) {\n if (!arguments.length) return lower48.scale();\n lower48.scale(_);\n alaska.scale(_ * .35);\n hawaii.scale(_);\n return albersUsa.translate(lower48.translate());\n };\n albersUsa.translate = function(_) {\n if (!arguments.length) return lower48.translate();\n var k = lower48.scale(), x = +_[0], y = +_[1];\n lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;\n alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + \u03B5, y + .12 * k + \u03B5 ], [ x - .214 * k - \u03B5, y + .234 * k - \u03B5 ] ]).stream(pointStream).point;\n hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + \u03B5, y + .166 * k + \u03B5 ], [ x - .115 * k - \u03B5, y + .234 * k - \u03B5 ] ]).stream(pointStream).point;\n return albersUsa;\n };\n return albersUsa.scale(1070);\n };\n var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {\n point: d3_noop,\n lineStart: d3_noop,\n lineEnd: d3_noop,\n polygonStart: function() {\n d3_geo_pathAreaPolygon = 0;\n d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;\n },\n polygonEnd: function() {\n d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;\n d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);\n }\n };\n function d3_geo_pathAreaRingStart() {\n var x00, y00, x0, y0;\n d3_geo_pathArea.point = function(x, y) {\n d3_geo_pathArea.point = nextPoint;\n x00 = x0 = x, y00 = y0 = y;\n };\n function nextPoint(x, y) {\n d3_geo_pathAreaPolygon += y0 * x - x0 * y;\n x0 = x, y0 = y;\n }\n d3_geo_pathArea.lineEnd = function() {\n nextPoint(x00, y00);\n };\n }\n var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;\n var d3_geo_pathBounds = {\n point: d3_geo_pathBoundsPoint,\n lineStart: d3_noop,\n lineEnd: d3_noop,\n polygonStart: d3_noop,\n polygonEnd: d3_noop\n };\n function d3_geo_pathBoundsPoint(x, y) {\n if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;\n if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;\n if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;\n if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;\n }\n function d3_geo_pathBuffer() {\n var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];\n var stream = {\n point: point,\n lineStart: function() {\n stream.point = pointLineStart;\n },\n lineEnd: lineEnd,\n polygonStart: function() {\n stream.lineEnd = lineEndPolygon;\n },\n polygonEnd: function() {\n stream.lineEnd = lineEnd;\n stream.point = point;\n },\n pointRadius: function(_) {\n pointCircle = d3_geo_pathBufferCircle(_);\n return stream;\n },\n result: function() {\n if (buffer.length) {\n var result = buffer.join(\"\");\n buffer = [];\n return result;\n }\n }\n };\n function point(x, y) {\n buffer.push(\"M\", x, \",\", y, pointCircle);\n }\n function pointLineStart(x, y) {\n buffer.push(\"M\", x, \",\", y);\n stream.point = pointLine;\n }\n function pointLine(x, y) {\n buffer.push(\"L\", x, \",\", y);\n }\n function lineEnd() {\n stream.point = point;\n }\n function lineEndPolygon() {\n buffer.push(\"Z\");\n }\n return stream;\n }\n function d3_geo_pathBufferCircle(radius) {\n return \"m0,\" + radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + -2 * radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + 2 * radius + \"z\";\n }\n var d3_geo_pathCentroid = {\n point: d3_geo_pathCentroidPoint,\n lineStart: d3_geo_pathCentroidLineStart,\n lineEnd: d3_geo_pathCentroidLineEnd,\n polygonStart: function() {\n d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;\n },\n polygonEnd: function() {\n d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;\n d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;\n }\n };\n function d3_geo_pathCentroidPoint(x, y) {\n d3_geo_centroidX0 += x;\n d3_geo_centroidY0 += y;\n ++d3_geo_centroidZ0;\n }\n function d3_geo_pathCentroidLineStart() {\n var x0, y0;\n d3_geo_pathCentroid.point = function(x, y) {\n d3_geo_pathCentroid.point = nextPoint;\n d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n };\n function nextPoint(x, y) {\n var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n d3_geo_centroidX1 += z * (x0 + x) / 2;\n d3_geo_centroidY1 += z * (y0 + y) / 2;\n d3_geo_centroidZ1 += z;\n d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n }\n }\n function d3_geo_pathCentroidLineEnd() {\n d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n }\n function d3_geo_pathCentroidRingStart() {\n var x00, y00, x0, y0;\n d3_geo_pathCentroid.point = function(x, y) {\n d3_geo_pathCentroid.point = nextPoint;\n d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);\n };\n function nextPoint(x, y) {\n var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n d3_geo_centroidX1 += z * (x0 + x) / 2;\n d3_geo_centroidY1 += z * (y0 + y) / 2;\n d3_geo_centroidZ1 += z;\n z = y0 * x - x0 * y;\n d3_geo_centroidX2 += z * (x0 + x);\n d3_geo_centroidY2 += z * (y0 + y);\n d3_geo_centroidZ2 += z * 3;\n d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n }\n d3_geo_pathCentroid.lineEnd = function() {\n nextPoint(x00, y00);\n };\n }\n function d3_geo_pathContext(context) {\n var pointRadius = 4.5;\n var stream = {\n point: point,\n lineStart: function() {\n stream.point = pointLineStart;\n },\n lineEnd: lineEnd,\n polygonStart: function() {\n stream.lineEnd = lineEndPolygon;\n },\n polygonEnd: function() {\n stream.lineEnd = lineEnd;\n stream.point = point;\n },\n pointRadius: function(_) {\n pointRadius = _;\n return stream;\n },\n result: d3_noop\n };\n function point(x, y) {\n context.moveTo(x + pointRadius, y);\n context.arc(x, y, pointRadius, 0, \u03C4);\n }\n function pointLineStart(x, y) {\n context.moveTo(x, y);\n stream.point = pointLine;\n }\n function pointLine(x, y) {\n context.lineTo(x, y);\n }\n function lineEnd() {\n stream.point = point;\n }\n function lineEndPolygon() {\n context.closePath();\n }\n return stream;\n }\n function d3_geo_resample(project) {\n var \u03B42 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;\n function resample(stream) {\n return (maxDepth ? resampleRecursive : resampleNone)(stream);\n }\n function resampleNone(stream) {\n return d3_geo_transformPoint(stream, function(x, y) {\n x = project(x, y);\n stream.point(x[0], x[1]);\n });\n }\n function resampleRecursive(stream) {\n var \u03BB00, \u03C600, x00, y00, a00, b00, c00, \u03BB0, x0, y0, a0, b0, c0;\n var resample = {\n point: point,\n lineStart: lineStart,\n lineEnd: lineEnd,\n polygonStart: function() {\n stream.polygonStart();\n resample.lineStart = ringStart;\n },\n polygonEnd: function() {\n stream.polygonEnd();\n resample.lineStart = lineStart;\n }\n };\n function point(x, y) {\n x = project(x, y);\n stream.point(x[0], x[1]);\n }\n function lineStart() {\n x0 = NaN;\n resample.point = linePoint;\n stream.lineStart();\n }\n function linePoint(\u03BB, \u03C6) {\n var c = d3_geo_cartesian([ \u03BB, \u03C6 ]), p = project(\u03BB, \u03C6);\n resampleLineTo(x0, y0, \u03BB0, a0, b0, c0, x0 = p[0], y0 = p[1], \u03BB0 = \u03BB, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);\n stream.point(x0, y0);\n }\n function lineEnd() {\n resample.point = point;\n stream.lineEnd();\n }\n function ringStart() {\n lineStart();\n resample.point = ringPoint;\n resample.lineEnd = ringEnd;\n }\n function ringPoint(\u03BB, \u03C6) {\n linePoint(\u03BB00 = \u03BB, \u03C600 = \u03C6), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;\n resample.point = linePoint;\n }\n function ringEnd() {\n resampleLineTo(x0, y0, \u03BB0, a0, b0, c0, x00, y00, \u03BB00, a00, b00, c00, maxDepth, stream);\n resample.lineEnd = lineEnd;\n lineEnd();\n }\n return resample;\n }\n function resampleLineTo(x0, y0, \u03BB0, a0, b0, c0, x1, y1, \u03BB1, a1, b1, c1, depth, stream) {\n var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;\n if (d2 > 4 * \u03B42 && depth--) {\n var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), \u03C62 = Math.asin(c /= m), \u03BB2 = abs(abs(c) - 1) < \u03B5 || abs(\u03BB0 - \u03BB1) < \u03B5 ? (\u03BB0 + \u03BB1) / 2 : Math.atan2(b, a), p = project(\u03BB2, \u03C62), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;\n if (dz * dz / d2 > \u03B42 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {\n resampleLineTo(x0, y0, \u03BB0, a0, b0, c0, x2, y2, \u03BB2, a /= m, b /= m, c, depth, stream);\n stream.point(x2, y2);\n resampleLineTo(x2, y2, \u03BB2, a, b, c, x1, y1, \u03BB1, a1, b1, c1, depth, stream);\n }\n }\n }\n resample.precision = function(_) {\n if (!arguments.length) return Math.sqrt(\u03B42);\n maxDepth = (\u03B42 = _ * _) > 0 && 16;\n return resample;\n };\n return resample;\n }\n d3.geo.path = function() {\n var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;\n function path(object) {\n if (object) {\n if (typeof pointRadius === \"function\") contextStream.pointRadius(+pointRadius.apply(this, arguments));\n if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);\n d3.geo.stream(object, cacheStream);\n }\n return contextStream.result();\n }\n path.area = function(object) {\n d3_geo_pathAreaSum = 0;\n d3.geo.stream(object, projectStream(d3_geo_pathArea));\n return d3_geo_pathAreaSum;\n };\n path.centroid = function(object) {\n d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n d3.geo.stream(object, projectStream(d3_geo_pathCentroid));\n return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ];\n };\n path.bounds = function(object) {\n d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);\n d3.geo.stream(object, projectStream(d3_geo_pathBounds));\n return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];\n };\n path.projection = function(_) {\n if (!arguments.length) return projection;\n projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;\n return reset();\n };\n path.context = function(_) {\n if (!arguments.length) return context;\n contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);\n if (typeof pointRadius !== \"function\") contextStream.pointRadius(pointRadius);\n return reset();\n };\n path.pointRadius = function(_) {\n if (!arguments.length) return pointRadius;\n pointRadius = typeof _ === \"function\" ? _ : (contextStream.pointRadius(+_), +_);\n return path;\n };\n function reset() {\n cacheStream = null;\n return path;\n }\n return path.projection(d3.geo.albersUsa()).context(null);\n };\n function d3_geo_pathProjectStream(project) {\n var resample = d3_geo_resample(function(x, y) {\n return project([ x * d3_degrees, y * d3_degrees ]);\n });\n return function(stream) {\n return d3_geo_projectionRadians(resample(stream));\n };\n }\n d3.geo.transform = function(methods) {\n return {\n stream: function(stream) {\n var transform = new d3_geo_transform(stream);\n for (var k in methods) transform[k] = methods[k];\n return transform;\n }\n };\n };\n function d3_geo_transform(stream) {\n this.stream = stream;\n }\n d3_geo_transform.prototype = {\n point: function(x, y) {\n this.stream.point(x, y);\n },\n sphere: function() {\n this.stream.sphere();\n },\n lineStart: function() {\n this.stream.lineStart();\n },\n lineEnd: function() {\n this.stream.lineEnd();\n },\n polygonStart: function() {\n this.stream.polygonStart();\n },\n polygonEnd: function() {\n this.stream.polygonEnd();\n }\n };\n function d3_geo_transformPoint(stream, point) {\n return {\n point: point,\n sphere: function() {\n stream.sphere();\n },\n lineStart: function() {\n stream.lineStart();\n },\n lineEnd: function() {\n stream.lineEnd();\n },\n polygonStart: function() {\n stream.polygonStart();\n },\n polygonEnd: function() {\n stream.polygonEnd();\n }\n };\n }\n d3.geo.projection = d3_geo_projection;\n d3.geo.projectionMutator = d3_geo_projectionMutator;\n function d3_geo_projection(project) {\n return d3_geo_projectionMutator(function() {\n return project;\n })();\n }\n function d3_geo_projectionMutator(projectAt) {\n var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {\n x = project(x, y);\n return [ x[0] * k + \u03B4x, \u03B4y - x[1] * k ];\n }), k = 150, x = 480, y = 250, \u03BB = 0, \u03C6 = 0, \u03B4\u03BB = 0, \u03B4\u03C6 = 0, \u03B4\u03B3 = 0, \u03B4x, \u03B4y, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream;\n function projection(point) {\n point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);\n return [ point[0] * k + \u03B4x, \u03B4y - point[1] * k ];\n }\n function invert(point) {\n point = projectRotate.invert((point[0] - \u03B4x) / k, (\u03B4y - point[1]) / k);\n return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];\n }\n projection.stream = function(output) {\n if (stream) stream.valid = false;\n stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));\n stream.valid = true;\n return stream;\n };\n projection.clipAngle = function(_) {\n if (!arguments.length) return clipAngle;\n preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);\n return invalidate();\n };\n projection.clipExtent = function(_) {\n if (!arguments.length) return clipExtent;\n clipExtent = _;\n postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;\n return invalidate();\n };\n projection.scale = function(_) {\n if (!arguments.length) return k;\n k = +_;\n return reset();\n };\n projection.translate = function(_) {\n if (!arguments.length) return [ x, y ];\n x = +_[0];\n y = +_[1];\n return reset();\n };\n projection.center = function(_) {\n if (!arguments.length) return [ \u03BB * d3_degrees, \u03C6 * d3_degrees ];\n \u03BB = _[0] % 360 * d3_radians;\n \u03C6 = _[1] % 360 * d3_radians;\n return reset();\n };\n projection.rotate = function(_) {\n if (!arguments.length) return [ \u03B4\u03BB * d3_degrees, \u03B4\u03C6 * d3_degrees, \u03B4\u03B3 * d3_degrees ];\n \u03B4\u03BB = _[0] % 360 * d3_radians;\n \u03B4\u03C6 = _[1] % 360 * d3_radians;\n \u03B4\u03B3 = _.length > 2 ? _[2] % 360 * d3_radians : 0;\n return reset();\n };\n d3.rebind(projection, projectResample, \"precision\");\n function reset() {\n projectRotate = d3_geo_compose(rotate = d3_geo_rotation(\u03B4\u03BB, \u03B4\u03C6, \u03B4\u03B3), project);\n var center = project(\u03BB, \u03C6);\n \u03B4x = x - center[0] * k;\n \u03B4y = y + center[1] * k;\n return invalidate();\n }\n function invalidate() {\n if (stream) stream.valid = false, stream = null;\n return projection;\n }\n return function() {\n project = projectAt.apply(this, arguments);\n projection.invert = project.invert && invert;\n return reset();\n };\n }\n function d3_geo_projectionRadians(stream) {\n return d3_geo_transformPoint(stream, function(x, y) {\n stream.point(x * d3_radians, y * d3_radians);\n });\n }\n function d3_geo_equirectangular(\u03BB, \u03C6) {\n return [ \u03BB, \u03C6 ];\n }\n (d3.geo.equirectangular = function() {\n return d3_geo_projection(d3_geo_equirectangular);\n }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;\n d3.geo.rotation = function(rotate) {\n rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);\n function forward(coordinates) {\n coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n }\n forward.invert = function(coordinates) {\n coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n };\n return forward;\n };\n function d3_geo_identityRotation(\u03BB, \u03C6) {\n return [ \u03BB > \u03C0 ? \u03BB - \u03C4 : \u03BB < -\u03C0 ? \u03BB + \u03C4 : \u03BB, \u03C6 ];\n }\n d3_geo_identityRotation.invert = d3_geo_equirectangular;\n function d3_geo_rotation(\u03B4\u03BB, \u03B4\u03C6, \u03B4\u03B3) {\n return \u03B4\u03BB ? \u03B4\u03C6 || \u03B4\u03B3 ? d3_geo_compose(d3_geo_rotation\u03BB(\u03B4\u03BB), d3_geo_rotation\u03C6\u03B3(\u03B4\u03C6, \u03B4\u03B3)) : d3_geo_rotation\u03BB(\u03B4\u03BB) : \u03B4\u03C6 || \u03B4\u03B3 ? d3_geo_rotation\u03C6\u03B3(\u03B4\u03C6, \u03B4\u03B3) : d3_geo_identityRotation;\n }\n function d3_geo_forwardRotation\u03BB(\u03B4\u03BB) {\n return function(\u03BB, \u03C6) {\n return \u03BB += \u03B4\u03BB, [ \u03BB > \u03C0 ? \u03BB - \u03C4 : \u03BB < -\u03C0 ? \u03BB + \u03C4 : \u03BB, \u03C6 ];\n };\n }\n function d3_geo_rotation\u03BB(\u03B4\u03BB) {\n var rotation = d3_geo_forwardRotation\u03BB(\u03B4\u03BB);\n rotation.invert = d3_geo_forwardRotation\u03BB(-\u03B4\u03BB);\n return rotation;\n }\n function d3_geo_rotation\u03C6\u03B3(\u03B4\u03C6, \u03B4\u03B3) {\n var cos\u03B4\u03C6 = Math.cos(\u03B4\u03C6), sin\u03B4\u03C6 = Math.sin(\u03B4\u03C6), cos\u03B4\u03B3 = Math.cos(\u03B4\u03B3), sin\u03B4\u03B3 = Math.sin(\u03B4\u03B3);\n function rotation(\u03BB, \u03C6) {\n var cos\u03C6 = Math.cos(\u03C6), x = Math.cos(\u03BB) * cos\u03C6, y = Math.sin(\u03BB) * cos\u03C6, z = Math.sin(\u03C6), k = z * cos\u03B4\u03C6 + x * sin\u03B4\u03C6;\n return [ Math.atan2(y * cos\u03B4\u03B3 - k * sin\u03B4\u03B3, x * cos\u03B4\u03C6 - z * sin\u03B4\u03C6), d3_asin(k * cos\u03B4\u03B3 + y * sin\u03B4\u03B3) ];\n }\n rotation.invert = function(\u03BB, \u03C6) {\n var cos\u03C6 = Math.cos(\u03C6), x = Math.cos(\u03BB) * cos\u03C6, y = Math.sin(\u03BB) * cos\u03C6, z = Math.sin(\u03C6), k = z * cos\u03B4\u03B3 - y * sin\u03B4\u03B3;\n return [ Math.atan2(y * cos\u03B4\u03B3 + z * sin\u03B4\u03B3, x * cos\u03B4\u03C6 + k * sin\u03B4\u03C6), d3_asin(k * cos\u03B4\u03C6 - x * sin\u03B4\u03C6) ];\n };\n return rotation;\n }\n d3.geo.circle = function() {\n var origin = [ 0, 0 ], angle, precision = 6, interpolate;\n function circle() {\n var center = typeof origin === \"function\" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];\n interpolate(null, null, 1, {\n point: function(x, y) {\n ring.push(x = rotate(x, y));\n x[0] *= d3_degrees, x[1] *= d3_degrees;\n }\n });\n return {\n type: \"Polygon\",\n coordinates: [ ring ]\n };\n }\n circle.origin = function(x) {\n if (!arguments.length) return origin;\n origin = x;\n return circle;\n };\n circle.angle = function(x) {\n if (!arguments.length) return angle;\n interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);\n return circle;\n };\n circle.precision = function(_) {\n if (!arguments.length) return precision;\n interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);\n return circle;\n };\n return circle.angle(90);\n };\n function d3_geo_circleInterpolate(radius, precision) {\n var cr = Math.cos(radius), sr = Math.sin(radius);\n return function(from, to, direction, listener) {\n var step = direction * precision;\n if (from != null) {\n from = d3_geo_circleAngle(cr, from);\n to = d3_geo_circleAngle(cr, to);\n if (direction > 0 ? from < to : from > to) from += direction * \u03C4;\n } else {\n from = radius + direction * \u03C4;\n to = radius - .5 * step;\n }\n for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {\n listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);\n }\n };\n }\n function d3_geo_circleAngle(cr, point) {\n var a = d3_geo_cartesian(point);\n a[0] -= cr;\n d3_geo_cartesianNormalize(a);\n var angle = d3_acos(-a[1]);\n return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - \u03B5) % (2 * Math.PI);\n }\n d3.geo.distance = function(a, b) {\n var \u0394\u03BB = (b[0] - a[0]) * d3_radians, \u03C60 = a[1] * d3_radians, \u03C61 = b[1] * d3_radians, sin\u0394\u03BB = Math.sin(\u0394\u03BB), cos\u0394\u03BB = Math.cos(\u0394\u03BB), sin\u03C60 = Math.sin(\u03C60), cos\u03C60 = Math.cos(\u03C60), sin\u03C61 = Math.sin(\u03C61), cos\u03C61 = Math.cos(\u03C61), t;\n return Math.atan2(Math.sqrt((t = cos\u03C61 * sin\u0394\u03BB) * t + (t = cos\u03C60 * sin\u03C61 - sin\u03C60 * cos\u03C61 * cos\u0394\u03BB) * t), sin\u03C60 * sin\u03C61 + cos\u03C60 * cos\u03C61 * cos\u0394\u03BB);\n };\n d3.geo.graticule = function() {\n var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;\n function graticule() {\n return {\n type: \"MultiLineString\",\n coordinates: lines()\n };\n }\n function lines() {\n return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) {\n return abs(x % DX) > \u03B5;\n }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {\n return abs(y % DY) > \u03B5;\n }).map(y));\n }\n graticule.lines = function() {\n return lines().map(function(coordinates) {\n return {\n type: \"LineString\",\n coordinates: coordinates\n };\n });\n };\n graticule.outline = function() {\n return {\n type: \"Polygon\",\n coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]\n };\n };\n graticule.extent = function(_) {\n if (!arguments.length) return graticule.minorExtent();\n return graticule.majorExtent(_).minorExtent(_);\n };\n graticule.majorExtent = function(_) {\n if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];\n X0 = +_[0][0], X1 = +_[1][0];\n Y0 = +_[0][1], Y1 = +_[1][1];\n if (X0 > X1) _ = X0, X0 = X1, X1 = _;\n if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;\n return graticule.precision(precision);\n };\n graticule.minorExtent = function(_) {\n if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n x0 = +_[0][0], x1 = +_[1][0];\n y0 = +_[0][1], y1 = +_[1][1];\n if (x0 > x1) _ = x0, x0 = x1, x1 = _;\n if (y0 > y1) _ = y0, y0 = y1, y1 = _;\n return graticule.precision(precision);\n };\n graticule.step = function(_) {\n if (!arguments.length) return graticule.minorStep();\n return graticule.majorStep(_).minorStep(_);\n };\n graticule.majorStep = function(_) {\n if (!arguments.length) return [ DX, DY ];\n DX = +_[0], DY = +_[1];\n return graticule;\n };\n graticule.minorStep = function(_) {\n if (!arguments.length) return [ dx, dy ];\n dx = +_[0], dy = +_[1];\n return graticule;\n };\n graticule.precision = function(_) {\n if (!arguments.length) return precision;\n precision = +_;\n x = d3_geo_graticuleX(y0, y1, 90);\n y = d3_geo_graticuleY(x0, x1, precision);\n X = d3_geo_graticuleX(Y0, Y1, 90);\n Y = d3_geo_graticuleY(X0, X1, precision);\n return graticule;\n };\n return graticule.majorExtent([ [ -180, -90 + \u03B5 ], [ 180, 90 - \u03B5 ] ]).minorExtent([ [ -180, -80 - \u03B5 ], [ 180, 80 + \u03B5 ] ]);\n };\n function d3_geo_graticuleX(y0, y1, dy) {\n var y = d3.range(y0, y1 - \u03B5, dy).concat(y1);\n return function(x) {\n return y.map(function(y) {\n return [ x, y ];\n });\n };\n }\n function d3_geo_graticuleY(x0, x1, dx) {\n var x = d3.range(x0, x1 - \u03B5, dx).concat(x1);\n return function(y) {\n return x.map(function(x) {\n return [ x, y ];\n });\n };\n }\n function d3_source(d) {\n return d.source;\n }\n function d3_target(d) {\n return d.target;\n }\n d3.geo.greatArc = function() {\n var source = d3_source, source_, target = d3_target, target_;\n function greatArc() {\n return {\n type: \"LineString\",\n coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]\n };\n }\n greatArc.distance = function() {\n return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));\n };\n greatArc.source = function(_) {\n if (!arguments.length) return source;\n source = _, source_ = typeof _ === \"function\" ? null : _;\n return greatArc;\n };\n greatArc.target = function(_) {\n if (!arguments.length) return target;\n target = _, target_ = typeof _ === \"function\" ? null : _;\n return greatArc;\n };\n greatArc.precision = function() {\n return arguments.length ? greatArc : 0;\n };\n return greatArc;\n };\n d3.geo.interpolate = function(source, target) {\n return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);\n };\n function d3_geo_interpolate(x0, y0, x1, y1) {\n var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d);\n var interpolate = d ? function(t) {\n var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;\n return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];\n } : function() {\n return [ x0 * d3_degrees, y0 * d3_degrees ];\n };\n interpolate.distance = d;\n return interpolate;\n }\n d3.geo.length = function(object) {\n d3_geo_lengthSum = 0;\n d3.geo.stream(object, d3_geo_length);\n return d3_geo_lengthSum;\n };\n var d3_geo_lengthSum;\n var d3_geo_length = {\n sphere: d3_noop,\n point: d3_noop,\n lineStart: d3_geo_lengthLineStart,\n lineEnd: d3_noop,\n polygonStart: d3_noop,\n polygonEnd: d3_noop\n };\n function d3_geo_lengthLineStart() {\n var \u03BB0, sin\u03C60, cos\u03C60;\n d3_geo_length.point = function(\u03BB, \u03C6) {\n \u03BB0 = \u03BB * d3_radians, sin\u03C60 = Math.sin(\u03C6 *= d3_radians), cos\u03C60 = Math.cos(\u03C6);\n d3_geo_length.point = nextPoint;\n };\n d3_geo_length.lineEnd = function() {\n d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;\n };\n function nextPoint(\u03BB, \u03C6) {\n var sin\u03C6 = Math.sin(\u03C6 *= d3_radians), cos\u03C6 = Math.cos(\u03C6), t = abs((\u03BB *= d3_radians) - \u03BB0), cos\u0394\u03BB = Math.cos(t);\n d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cos\u03C6 * Math.sin(t)) * t + (t = cos\u03C60 * sin\u03C6 - sin\u03C60 * cos\u03C6 * cos\u0394\u03BB) * t), sin\u03C60 * sin\u03C6 + cos\u03C60 * cos\u03C6 * cos\u0394\u03BB);\n \u03BB0 = \u03BB, sin\u03C60 = sin\u03C6, cos\u03C60 = cos\u03C6;\n }\n }\n function d3_geo_azimuthal(scale, angle) {\n function azimuthal(\u03BB, \u03C6) {\n var cos\u03BB = Math.cos(\u03BB), cos\u03C6 = Math.cos(\u03C6), k = scale(cos\u03BB * cos\u03C6);\n return [ k * cos\u03C6 * Math.sin(\u03BB), k * Math.sin(\u03C6) ];\n }\n azimuthal.invert = function(x, y) {\n var \u03C1 = Math.sqrt(x * x + y * y), c = angle(\u03C1), sinc = Math.sin(c), cosc = Math.cos(c);\n return [ Math.atan2(x * sinc, \u03C1 * cosc), Math.asin(\u03C1 && y * sinc / \u03C1) ];\n };\n return azimuthal;\n }\n var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cos\u03BBcos\u03C6) {\n return Math.sqrt(2 / (1 + cos\u03BBcos\u03C6));\n }, function(\u03C1) {\n return 2 * Math.asin(\u03C1 / 2);\n });\n (d3.geo.azimuthalEqualArea = function() {\n return d3_geo_projection(d3_geo_azimuthalEqualArea);\n }).raw = d3_geo_azimuthalEqualArea;\n var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cos\u03BBcos\u03C6) {\n var c = Math.acos(cos\u03BBcos\u03C6);\n return c && c / Math.sin(c);\n }, d3_identity);\n (d3.geo.azimuthalEquidistant = function() {\n return d3_geo_projection(d3_geo_azimuthalEquidistant);\n }).raw = d3_geo_azimuthalEquidistant;\n function d3_geo_conicConformal(\u03C60, \u03C61) {\n var cos\u03C60 = Math.cos(\u03C60), t = function(\u03C6) {\n return Math.tan(\u03C0 / 4 + \u03C6 / 2);\n }, n = \u03C60 === \u03C61 ? Math.sin(\u03C60) : Math.log(cos\u03C60 / Math.cos(\u03C61)) / Math.log(t(\u03C61) / t(\u03C60)), F = cos\u03C60 * Math.pow(t(\u03C60), n) / n;\n if (!n) return d3_geo_mercator;\n function forward(\u03BB, \u03C6) {\n if (F > 0) {\n if (\u03C6 < -half\u03C0 + \u03B5) \u03C6 = -half\u03C0 + \u03B5;\n } else {\n if (\u03C6 > half\u03C0 - \u03B5) \u03C6 = half\u03C0 - \u03B5;\n }\n var \u03C1 = F / Math.pow(t(\u03C6), n);\n return [ \u03C1 * Math.sin(n * \u03BB), F - \u03C1 * Math.cos(n * \u03BB) ];\n }\n forward.invert = function(x, y) {\n var \u03C10_y = F - y, \u03C1 = d3_sgn(n) * Math.sqrt(x * x + \u03C10_y * \u03C10_y);\n return [ Math.atan2(x, \u03C10_y) / n, 2 * Math.atan(Math.pow(F / \u03C1, 1 / n)) - half\u03C0 ];\n };\n return forward;\n }\n (d3.geo.conicConformal = function() {\n return d3_geo_conic(d3_geo_conicConformal);\n }).raw = d3_geo_conicConformal;\n function d3_geo_conicEquidistant(\u03C60, \u03C61) {\n var cos\u03C60 = Math.cos(\u03C60), n = \u03C60 === \u03C61 ? Math.sin(\u03C60) : (cos\u03C60 - Math.cos(\u03C61)) / (\u03C61 - \u03C60), G = cos\u03C60 / n + \u03C60;\n if (abs(n) < \u03B5) return d3_geo_equirectangular;\n function forward(\u03BB, \u03C6) {\n var \u03C1 = G - \u03C6;\n return [ \u03C1 * Math.sin(n * \u03BB), G - \u03C1 * Math.cos(n * \u03BB) ];\n }\n forward.invert = function(x, y) {\n var \u03C10_y = G - y;\n return [ Math.atan2(x, \u03C10_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + \u03C10_y * \u03C10_y) ];\n };\n return forward;\n }\n (d3.geo.conicEquidistant = function() {\n return d3_geo_conic(d3_geo_conicEquidistant);\n }).raw = d3_geo_conicEquidistant;\n var d3_geo_gnomonic = d3_geo_azimuthal(function(cos\u03BBcos\u03C6) {\n return 1 / cos\u03BBcos\u03C6;\n }, Math.atan);\n (d3.geo.gnomonic = function() {\n return d3_geo_projection(d3_geo_gnomonic);\n }).raw = d3_geo_gnomonic;\n function d3_geo_mercator(\u03BB, \u03C6) {\n return [ \u03BB, Math.log(Math.tan(\u03C0 / 4 + \u03C6 / 2)) ];\n }\n d3_geo_mercator.invert = function(x, y) {\n return [ x, 2 * Math.atan(Math.exp(y)) - half\u03C0 ];\n };\n function d3_geo_mercatorProjection(project) {\n var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;\n m.scale = function() {\n var v = scale.apply(m, arguments);\n return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n };\n m.translate = function() {\n var v = translate.apply(m, arguments);\n return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n };\n m.clipExtent = function(_) {\n var v = clipExtent.apply(m, arguments);\n if (v === m) {\n if (clipAuto = _ == null) {\n var k = \u03C0 * scale(), t = translate();\n clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);\n }\n } else if (clipAuto) {\n v = null;\n }\n return v;\n };\n return m.clipExtent(null);\n }\n (d3.geo.mercator = function() {\n return d3_geo_mercatorProjection(d3_geo_mercator);\n }).raw = d3_geo_mercator;\n var d3_geo_orthographic = d3_geo_azimuthal(function() {\n return 1;\n }, Math.asin);\n (d3.geo.orthographic = function() {\n return d3_geo_projection(d3_geo_orthographic);\n }).raw = d3_geo_orthographic;\n var d3_geo_stereographic = d3_geo_azimuthal(function(cos\u03BBcos\u03C6) {\n return 1 / (1 + cos\u03BBcos\u03C6);\n }, function(\u03C1) {\n return 2 * Math.atan(\u03C1);\n });\n (d3.geo.stereographic = function() {\n return d3_geo_projection(d3_geo_stereographic);\n }).raw = d3_geo_stereographic;\n function d3_geo_transverseMercator(\u03BB, \u03C6) {\n return [ Math.log(Math.tan(\u03C0 / 4 + \u03C6 / 2)), -\u03BB ];\n }\n d3_geo_transverseMercator.invert = function(x, y) {\n return [ -y, 2 * Math.atan(Math.exp(x)) - half\u03C0 ];\n };\n (d3.geo.transverseMercator = function() {\n var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;\n projection.center = function(_) {\n return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);\n };\n projection.rotate = function(_) {\n return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), \n [ _[0], _[1], _[2] - 90 ]);\n };\n return rotate([ 0, 0, 90 ]);\n }).raw = d3_geo_transverseMercator;\n d3.geom = {};\n function d3_geom_pointX(d) {\n return d[0];\n }\n function d3_geom_pointY(d) {\n return d[1];\n }\n d3.geom.hull = function(vertices) {\n var x = d3_geom_pointX, y = d3_geom_pointY;\n if (arguments.length) return hull(vertices);\n function hull(data) {\n if (data.length < 3) return [];\n var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];\n for (i = 0; i < n; i++) {\n points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);\n }\n points.sort(d3_geom_hullOrder);\n for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);\n var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);\n var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];\n for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);\n for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);\n return polygon;\n }\n hull.x = function(_) {\n return arguments.length ? (x = _, hull) : x;\n };\n hull.y = function(_) {\n return arguments.length ? (y = _, hull) : y;\n };\n return hull;\n };\n function d3_geom_hullUpper(points) {\n var n = points.length, hull = [ 0, 1 ], hs = 2;\n for (var i = 2; i < n; i++) {\n while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;\n hull[hs++] = i;\n }\n return hull.slice(0, hs);\n }\n function d3_geom_hullOrder(a, b) {\n return a[0] - b[0] || a[1] - b[1];\n }\n d3.geom.polygon = function(coordinates) {\n d3_subclass(coordinates, d3_geom_polygonPrototype);\n return coordinates;\n };\n var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];\n d3_geom_polygonPrototype.area = function() {\n var i = -1, n = this.length, a, b = this[n - 1], area = 0;\n while (++i < n) {\n a = b;\n b = this[i];\n area += a[1] * b[0] - a[0] * b[1];\n }\n return area * .5;\n };\n d3_geom_polygonPrototype.centroid = function(k) {\n var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;\n if (!arguments.length) k = -1 / (6 * this.area());\n while (++i < n) {\n a = b;\n b = this[i];\n c = a[0] * b[1] - b[0] * a[1];\n x += (a[0] + b[0]) * c;\n y += (a[1] + b[1]) * c;\n }\n return [ x * k, y * k ];\n };\n d3_geom_polygonPrototype.clip = function(subject) {\n var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d;\n while (++i < n) {\n input = subject.slice();\n subject.length = 0;\n b = this[i];\n c = input[(m = input.length - closed) - 1];\n j = -1;\n while (++j < m) {\n d = input[j];\n if (d3_geom_polygonInside(d, a, b)) {\n if (!d3_geom_polygonInside(c, a, b)) {\n subject.push(d3_geom_polygonIntersect(c, d, a, b));\n }\n subject.push(d);\n } else if (d3_geom_polygonInside(c, a, b)) {\n subject.push(d3_geom_polygonIntersect(c, d, a, b));\n }\n c = d;\n }\n if (closed) subject.push(subject[0]);\n a = b;\n }\n return subject;\n };\n function d3_geom_polygonInside(p, a, b) {\n return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);\n }\n function d3_geom_polygonIntersect(c, d, a, b) {\n var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21);\n return [ x1 + ua * x21, y1 + ua * y21 ];\n }\n function d3_geom_polygonClosed(coordinates) {\n var a = coordinates[0], b = coordinates[coordinates.length - 1];\n return !(a[0] - b[0] || a[1] - b[1]);\n }\n var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];\n function d3_geom_voronoiBeach() {\n d3_geom_voronoiRedBlackNode(this);\n this.edge = this.site = this.circle = null;\n }\n function d3_geom_voronoiCreateBeach(site) {\n var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();\n beach.site = site;\n return beach;\n }\n function d3_geom_voronoiDetachBeach(beach) {\n d3_geom_voronoiDetachCircle(beach);\n d3_geom_voronoiBeaches.remove(beach);\n d3_geom_voronoiBeachPool.push(beach);\n d3_geom_voronoiRedBlackNode(beach);\n }\n function d3_geom_voronoiRemoveBeach(beach) {\n var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {\n x: x,\n y: y\n }, previous = beach.P, next = beach.N, disappearing = [ beach ];\n d3_geom_voronoiDetachBeach(beach);\n var lArc = previous;\n while (lArc.circle && abs(x - lArc.circle.x) < \u03B5 && abs(y - lArc.circle.cy) < \u03B5) {\n previous = lArc.P;\n disappearing.unshift(lArc);\n d3_geom_voronoiDetachBeach(lArc);\n lArc = previous;\n }\n disappearing.unshift(lArc);\n d3_geom_voronoiDetachCircle(lArc);\n var rArc = next;\n while (rArc.circle && abs(x - rArc.circle.x) < \u03B5 && abs(y - rArc.circle.cy) < \u03B5) {\n next = rArc.N;\n disappearing.push(rArc);\n d3_geom_voronoiDetachBeach(rArc);\n rArc = next;\n }\n disappearing.push(rArc);\n d3_geom_voronoiDetachCircle(rArc);\n var nArcs = disappearing.length, iArc;\n for (iArc = 1; iArc < nArcs; ++iArc) {\n rArc = disappearing[iArc];\n lArc = disappearing[iArc - 1];\n d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);\n }\n lArc = disappearing[0];\n rArc = disappearing[nArcs - 1];\n rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);\n d3_geom_voronoiAttachCircle(lArc);\n d3_geom_voronoiAttachCircle(rArc);\n }\n function d3_geom_voronoiAddBeach(site) {\n var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;\n while (node) {\n dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;\n if (dxl > \u03B5) node = node.L; else {\n dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);\n if (dxr > \u03B5) {\n if (!node.R) {\n lArc = node;\n break;\n }\n node = node.R;\n } else {\n if (dxl > -\u03B5) {\n lArc = node.P;\n rArc = node;\n } else if (dxr > -\u03B5) {\n lArc = node;\n rArc = node.N;\n } else {\n lArc = rArc = node;\n }\n break;\n }\n }\n }\n var newArc = d3_geom_voronoiCreateBeach(site);\n d3_geom_voronoiBeaches.insert(lArc, newArc);\n if (!lArc && !rArc) return;\n if (lArc === rArc) {\n d3_geom_voronoiDetachCircle(lArc);\n rArc = d3_geom_voronoiCreateBeach(lArc.site);\n d3_geom_voronoiBeaches.insert(newArc, rArc);\n newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n d3_geom_voronoiAttachCircle(lArc);\n d3_geom_voronoiAttachCircle(rArc);\n return;\n }\n if (!rArc) {\n newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n return;\n }\n d3_geom_voronoiDetachCircle(lArc);\n d3_geom_voronoiDetachCircle(rArc);\n var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = {\n x: (cy * hb - by * hc) / d + ax,\n y: (bx * hc - cx * hb) / d + ay\n };\n d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);\n newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);\n rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);\n d3_geom_voronoiAttachCircle(lArc);\n d3_geom_voronoiAttachCircle(rArc);\n }\n function d3_geom_voronoiLeftBreakPoint(arc, directrix) {\n var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;\n if (!pby2) return rfocx;\n var lArc = arc.P;\n if (!lArc) return -Infinity;\n site = lArc.site;\n var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;\n if (!plby2) return lfocx;\n var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;\n if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;\n return (rfocx + lfocx) / 2;\n }\n function d3_geom_voronoiRightBreakPoint(arc, directrix) {\n var rArc = arc.N;\n if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);\n var site = arc.site;\n return site.y === directrix ? site.x : Infinity;\n }\n function d3_geom_voronoiCell(site) {\n this.site = site;\n this.edges = [];\n }\n d3_geom_voronoiCell.prototype.prepare = function() {\n var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;\n while (iHalfEdge--) {\n edge = halfEdges[iHalfEdge].edge;\n if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);\n }\n halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);\n return halfEdges.length;\n };\n function d3_geom_voronoiCloseCells(extent) {\n var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end;\n while (iCell--) {\n cell = cells[iCell];\n if (!cell || !cell.prepare()) continue;\n halfEdges = cell.edges;\n nHalfEdges = halfEdges.length;\n iHalfEdge = 0;\n while (iHalfEdge < nHalfEdges) {\n end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;\n start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;\n if (abs(x3 - x2) > \u03B5 || abs(y3 - y2) > \u03B5) {\n halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < \u03B5 && y1 - y3 > \u03B5 ? {\n x: x0,\n y: abs(x2 - x0) < \u03B5 ? y2 : y1\n } : abs(y3 - y1) < \u03B5 && x1 - x3 > \u03B5 ? {\n x: abs(y2 - y1) < \u03B5 ? x2 : x1,\n y: y1\n } : abs(x3 - x1) < \u03B5 && y3 - y0 > \u03B5 ? {\n x: x1,\n y: abs(x2 - x1) < \u03B5 ? y2 : y0\n } : abs(y3 - y0) < \u03B5 && x3 - x0 > \u03B5 ? {\n x: abs(y2 - y0) < \u03B5 ? x2 : x0,\n y: y0\n } : null), cell.site, null));\n ++nHalfEdges;\n }\n }\n }\n }\n function d3_geom_voronoiHalfEdgeOrder(a, b) {\n return b.angle - a.angle;\n }\n function d3_geom_voronoiCircle() {\n d3_geom_voronoiRedBlackNode(this);\n this.x = this.y = this.arc = this.site = this.cy = null;\n }\n function d3_geom_voronoiAttachCircle(arc) {\n var lArc = arc.P, rArc = arc.N;\n if (!lArc || !rArc) return;\n var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;\n if (lSite === rSite) return;\n var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;\n var d = 2 * (ax * cy - ay * cx);\n if (d >= -\u03B52) return;\n var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by;\n var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();\n circle.arc = arc;\n circle.site = cSite;\n circle.x = x + bx;\n circle.y = cy + Math.sqrt(x * x + y * y);\n circle.cy = cy;\n arc.circle = circle;\n var before = null, node = d3_geom_voronoiCircles._;\n while (node) {\n if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {\n if (node.L) node = node.L; else {\n before = node.P;\n break;\n }\n } else {\n if (node.R) node = node.R; else {\n before = node;\n break;\n }\n }\n }\n d3_geom_voronoiCircles.insert(before, circle);\n if (!before) d3_geom_voronoiFirstCircle = circle;\n }\n function d3_geom_voronoiDetachCircle(arc) {\n var circle = arc.circle;\n if (circle) {\n if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;\n d3_geom_voronoiCircles.remove(circle);\n d3_geom_voronoiCirclePool.push(circle);\n d3_geom_voronoiRedBlackNode(circle);\n arc.circle = null;\n }\n }\n function d3_geom_voronoiClipEdges(extent) {\n var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e;\n while (i--) {\n e = edges[i];\n if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < \u03B5 && abs(e.a.y - e.b.y) < \u03B5) {\n e.a = e.b = null;\n edges.splice(i, 1);\n }\n }\n }\n function d3_geom_voronoiConnectEdge(edge, extent) {\n var vb = edge.b;\n if (vb) return true;\n var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb;\n if (ry === ly) {\n if (fx < x0 || fx >= x1) return;\n if (lx > rx) {\n if (!va) va = {\n x: fx,\n y: y0\n }; else if (va.y >= y1) return;\n vb = {\n x: fx,\n y: y1\n };\n } else {\n if (!va) va = {\n x: fx,\n y: y1\n }; else if (va.y < y0) return;\n vb = {\n x: fx,\n y: y0\n };\n }\n } else {\n fm = (lx - rx) / (ry - ly);\n fb = fy - fm * fx;\n if (fm < -1 || fm > 1) {\n if (lx > rx) {\n if (!va) va = {\n x: (y0 - fb) / fm,\n y: y0\n }; else if (va.y >= y1) return;\n vb = {\n x: (y1 - fb) / fm,\n y: y1\n };\n } else {\n if (!va) va = {\n x: (y1 - fb) / fm,\n y: y1\n }; else if (va.y < y0) return;\n vb = {\n x: (y0 - fb) / fm,\n y: y0\n };\n }\n } else {\n if (ly < ry) {\n if (!va) va = {\n x: x0,\n y: fm * x0 + fb\n }; else if (va.x >= x1) return;\n vb = {\n x: x1,\n y: fm * x1 + fb\n };\n } else {\n if (!va) va = {\n x: x1,\n y: fm * x1 + fb\n }; else if (va.x < x0) return;\n vb = {\n x: x0,\n y: fm * x0 + fb\n };\n }\n }\n }\n edge.a = va;\n edge.b = vb;\n return true;\n }\n function d3_geom_voronoiEdge(lSite, rSite) {\n this.l = lSite;\n this.r = rSite;\n this.a = this.b = null;\n }\n function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {\n var edge = new d3_geom_voronoiEdge(lSite, rSite);\n d3_geom_voronoiEdges.push(edge);\n if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);\n if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);\n d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));\n d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));\n return edge;\n }\n function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {\n var edge = new d3_geom_voronoiEdge(lSite, null);\n edge.a = va;\n edge.b = vb;\n d3_geom_voronoiEdges.push(edge);\n return edge;\n }\n function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {\n if (!edge.a && !edge.b) {\n edge.a = vertex;\n edge.l = lSite;\n edge.r = rSite;\n } else if (edge.l === rSite) {\n edge.b = vertex;\n } else {\n edge.a = vertex;\n }\n }\n function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {\n var va = edge.a, vb = edge.b;\n this.edge = edge;\n this.site = lSite;\n this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y);\n }\n d3_geom_voronoiHalfEdge.prototype = {\n start: function() {\n return this.edge.l === this.site ? this.edge.a : this.edge.b;\n },\n end: function() {\n return this.edge.l === this.site ? this.edge.b : this.edge.a;\n }\n };\n function d3_geom_voronoiRedBlackTree() {\n this._ = null;\n }\n function d3_geom_voronoiRedBlackNode(node) {\n node.U = node.C = node.L = node.R = node.P = node.N = null;\n }\n d3_geom_voronoiRedBlackTree.prototype = {\n insert: function(after, node) {\n var parent, grandpa, uncle;\n if (after) {\n node.P = after;\n node.N = after.N;\n if (after.N) after.N.P = node;\n after.N = node;\n if (after.R) {\n after = after.R;\n while (after.L) after = after.L;\n after.L = node;\n } else {\n after.R = node;\n }\n parent = after;\n } else if (this._) {\n after = d3_geom_voronoiRedBlackFirst(this._);\n node.P = null;\n node.N = after;\n after.P = after.L = node;\n parent = after;\n } else {\n node.P = node.N = null;\n this._ = node;\n parent = null;\n }\n node.L = node.R = null;\n node.U = parent;\n node.C = true;\n after = node;\n while (parent && parent.C) {\n grandpa = parent.U;\n if (parent === grandpa.L) {\n uncle = grandpa.R;\n if (uncle && uncle.C) {\n parent.C = uncle.C = false;\n grandpa.C = true;\n after = grandpa;\n } else {\n if (after === parent.R) {\n d3_geom_voronoiRedBlackRotateLeft(this, parent);\n after = parent;\n parent = after.U;\n }\n parent.C = false;\n grandpa.C = true;\n d3_geom_voronoiRedBlackRotateRight(this, grandpa);\n }\n } else {\n uncle = grandpa.L;\n if (uncle && uncle.C) {\n parent.C = uncle.C = false;\n grandpa.C = true;\n after = grandpa;\n } else {\n if (after === parent.L) {\n d3_geom_voronoiRedBlackRotateRight(this, parent);\n after = parent;\n parent = after.U;\n }\n parent.C = false;\n grandpa.C = true;\n d3_geom_voronoiRedBlackRotateLeft(this, grandpa);\n }\n }\n parent = after.U;\n }\n this._.C = false;\n },\n remove: function(node) {\n if (node.N) node.N.P = node.P;\n if (node.P) node.P.N = node.N;\n node.N = node.P = null;\n var parent = node.U, sibling, left = node.L, right = node.R, next, red;\n if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);\n if (parent) {\n if (parent.L === node) parent.L = next; else parent.R = next;\n } else {\n this._ = next;\n }\n if (left && right) {\n red = next.C;\n next.C = node.C;\n next.L = left;\n left.U = next;\n if (next !== right) {\n parent = next.U;\n next.U = node.U;\n node = next.R;\n parent.L = node;\n next.R = right;\n right.U = next;\n } else {\n next.U = parent;\n parent = next;\n node = next.R;\n }\n } else {\n red = node.C;\n node = next;\n }\n if (node) node.U = parent;\n if (red) return;\n if (node && node.C) {\n node.C = false;\n return;\n }\n do {\n if (node === this._) break;\n if (node === parent.L) {\n sibling = parent.R;\n if (sibling.C) {\n sibling.C = false;\n parent.C = true;\n d3_geom_voronoiRedBlackRotateLeft(this, parent);\n sibling = parent.R;\n }\n if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n if (!sibling.R || !sibling.R.C) {\n sibling.L.C = false;\n sibling.C = true;\n d3_geom_voronoiRedBlackRotateRight(this, sibling);\n sibling = parent.R;\n }\n sibling.C = parent.C;\n parent.C = sibling.R.C = false;\n d3_geom_voronoiRedBlackRotateLeft(this, parent);\n node = this._;\n break;\n }\n } else {\n sibling = parent.L;\n if (sibling.C) {\n sibling.C = false;\n parent.C = true;\n d3_geom_voronoiRedBlackRotateRight(this, parent);\n sibling = parent.L;\n }\n if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n if (!sibling.L || !sibling.L.C) {\n sibling.R.C = false;\n sibling.C = true;\n d3_geom_voronoiRedBlackRotateLeft(this, sibling);\n sibling = parent.L;\n }\n sibling.C = parent.C;\n parent.C = sibling.L.C = false;\n d3_geom_voronoiRedBlackRotateRight(this, parent);\n node = this._;\n break;\n }\n }\n sibling.C = true;\n node = parent;\n parent = parent.U;\n } while (!node.C);\n if (node) node.C = false;\n }\n };\n function d3_geom_voronoiRedBlackRotateLeft(tree, node) {\n var p = node, q = node.R, parent = p.U;\n if (parent) {\n if (parent.L === p) parent.L = q; else parent.R = q;\n } else {\n tree._ = q;\n }\n q.U = parent;\n p.U = q;\n p.R = q.L;\n if (p.R) p.R.U = p;\n q.L = p;\n }\n function d3_geom_voronoiRedBlackRotateRight(tree, node) {\n var p = node, q = node.L, parent = p.U;\n if (parent) {\n if (parent.L === p) parent.L = q; else parent.R = q;\n } else {\n tree._ = q;\n }\n q.U = parent;\n p.U = q;\n p.L = q.R;\n if (p.L) p.L.U = p;\n q.R = p;\n }\n function d3_geom_voronoiRedBlackFirst(node) {\n while (node.L) node = node.L;\n return node;\n }\n function d3_geom_voronoi(sites, bbox) {\n var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;\n d3_geom_voronoiEdges = [];\n d3_geom_voronoiCells = new Array(sites.length);\n d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();\n d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();\n while (true) {\n circle = d3_geom_voronoiFirstCircle;\n if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {\n if (site.x !== x0 || site.y !== y0) {\n d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);\n d3_geom_voronoiAddBeach(site);\n x0 = site.x, y0 = site.y;\n }\n site = sites.pop();\n } else if (circle) {\n d3_geom_voronoiRemoveBeach(circle.arc);\n } else {\n break;\n }\n }\n if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);\n var diagram = {\n cells: d3_geom_voronoiCells,\n edges: d3_geom_voronoiEdges\n };\n d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;\n return diagram;\n }\n function d3_geom_voronoiVertexOrder(a, b) {\n return b.y - a.y || b.x - a.x;\n }\n d3.geom.voronoi = function(points) {\n var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;\n if (points) return voronoi(points);\n function voronoi(data) {\n var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];\n d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {\n var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {\n var s = e.start();\n return [ s.x, s.y ];\n }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];\n polygon.point = data[i];\n });\n return polygons;\n }\n function sites(data) {\n return data.map(function(d, i) {\n return {\n x: Math.round(fx(d, i) / \u03B5) * \u03B5,\n y: Math.round(fy(d, i) / \u03B5) * \u03B5,\n i: i\n };\n });\n }\n voronoi.links = function(data) {\n return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {\n return edge.l && edge.r;\n }).map(function(edge) {\n return {\n source: data[edge.l.i],\n target: data[edge.r.i]\n };\n });\n };\n voronoi.triangles = function(data) {\n var triangles = [];\n d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {\n var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l;\n while (++j < m) {\n e0 = e1;\n s0 = s1;\n e1 = edges[j].edge;\n s1 = e1.l === site ? e1.r : e1.l;\n if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {\n triangles.push([ data[i], data[s0.i], data[s1.i] ]);\n }\n }\n });\n return triangles;\n };\n voronoi.x = function(_) {\n return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;\n };\n voronoi.y = function(_) {\n return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;\n };\n voronoi.clipExtent = function(_) {\n if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;\n clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;\n return voronoi;\n };\n voronoi.size = function(_) {\n if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];\n return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);\n };\n return voronoi;\n };\n var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];\n function d3_geom_voronoiTriangleArea(a, b, c) {\n return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);\n }\n d3.geom.delaunay = function(vertices) {\n return d3.geom.voronoi().triangles(vertices);\n };\n d3.geom.quadtree = function(points, x1, y1, x2, y2) {\n var x = d3_geom_pointX, y = d3_geom_pointY, compat;\n if (compat = arguments.length) {\n x = d3_geom_quadtreeCompatX;\n y = d3_geom_quadtreeCompatY;\n if (compat === 3) {\n y2 = y1;\n x2 = x1;\n y1 = x1 = 0;\n }\n return quadtree(points);\n }\n function quadtree(data) {\n var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;\n if (x1 != null) {\n x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;\n } else {\n x2_ = y2_ = -(x1_ = y1_ = Infinity);\n xs = [], ys = [];\n n = data.length;\n if (compat) for (i = 0; i < n; ++i) {\n d = data[i];\n if (d.x < x1_) x1_ = d.x;\n if (d.y < y1_) y1_ = d.y;\n if (d.x > x2_) x2_ = d.x;\n if (d.y > y2_) y2_ = d.y;\n xs.push(d.x);\n ys.push(d.y);\n } else for (i = 0; i < n; ++i) {\n var x_ = +fx(d = data[i], i), y_ = +fy(d, i);\n if (x_ < x1_) x1_ = x_;\n if (y_ < y1_) y1_ = y_;\n if (x_ > x2_) x2_ = x_;\n if (y_ > y2_) y2_ = y_;\n xs.push(x_);\n ys.push(y_);\n }\n }\n var dx = x2_ - x1_, dy = y2_ - y1_;\n if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;\n function insert(n, d, x, y, x1, y1, x2, y2) {\n if (isNaN(x) || isNaN(y)) return;\n if (n.leaf) {\n var nx = n.x, ny = n.y;\n if (nx != null) {\n if (abs(nx - x) + abs(ny - y) < .01) {\n insertChild(n, d, x, y, x1, y1, x2, y2);\n } else {\n var nPoint = n.point;\n n.x = n.y = n.point = null;\n insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);\n insertChild(n, d, x, y, x1, y1, x2, y2);\n }\n } else {\n n.x = x, n.y = y, n.point = d;\n }\n } else {\n insertChild(n, d, x, y, x1, y1, x2, y2);\n }\n }\n function insertChild(n, d, x, y, x1, y1, x2, y2) {\n var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;\n n.leaf = false;\n n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());\n if (right) x1 = xm; else x2 = xm;\n if (below) y1 = ym; else y2 = ym;\n insert(n, d, x, y, x1, y1, x2, y2);\n }\n var root = d3_geom_quadtreeNode();\n root.add = function(d) {\n insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);\n };\n root.visit = function(f) {\n d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);\n };\n root.find = function(point) {\n return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);\n };\n i = -1;\n if (x1 == null) {\n while (++i < n) {\n insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);\n }\n --i;\n } else data.forEach(root.add);\n xs = ys = data = d = null;\n return root;\n }\n quadtree.x = function(_) {\n return arguments.length ? (x = _, quadtree) : x;\n };\n quadtree.y = function(_) {\n return arguments.length ? (y = _, quadtree) : y;\n };\n quadtree.extent = function(_) {\n if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];\n if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], \n y2 = +_[1][1];\n return quadtree;\n };\n quadtree.size = function(_) {\n if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];\n if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];\n return quadtree;\n };\n return quadtree;\n };\n function d3_geom_quadtreeCompatX(d) {\n return d.x;\n }\n function d3_geom_quadtreeCompatY(d) {\n return d.y;\n }\n function d3_geom_quadtreeNode() {\n return {\n leaf: true,\n nodes: [],\n point: null,\n x: null,\n y: null\n };\n }\n function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {\n if (!f(node, x1, y1, x2, y2)) {\n var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;\n if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);\n if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);\n if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);\n if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);\n }\n }\n function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {\n var minDistance2 = Infinity, closestPoint;\n (function find(node, x1, y1, x2, y2) {\n if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;\n if (point = node.point) {\n var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy;\n if (distance2 < minDistance2) {\n var distance = Math.sqrt(minDistance2 = distance2);\n x0 = x - distance, y0 = y - distance;\n x3 = x + distance, y3 = y + distance;\n closestPoint = point;\n }\n }\n var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;\n for (var i = below << 1 | right, j = i + 4; i < j; ++i) {\n if (node = children[i & 3]) switch (i & 3) {\n case 0:\n find(node, x1, y1, xm, ym);\n break;\n\n case 1:\n find(node, xm, y1, x2, ym);\n break;\n\n case 2:\n find(node, x1, ym, xm, y2);\n break;\n\n case 3:\n find(node, xm, ym, x2, y2);\n break;\n }\n }\n })(root, x0, y0, x3, y3);\n return closestPoint;\n }\n d3.interpolateRgb = d3_interpolateRgb;\n function d3_interpolateRgb(a, b) {\n a = d3.rgb(a);\n b = d3.rgb(b);\n var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;\n return function(t) {\n return \"#\" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t));\n };\n }\n d3.interpolateObject = d3_interpolateObject;\n function d3_interpolateObject(a, b) {\n var i = {}, c = {}, k;\n for (k in a) {\n if (k in b) {\n i[k] = d3_interpolate(a[k], b[k]);\n } else {\n c[k] = a[k];\n }\n }\n for (k in b) {\n if (!(k in a)) {\n c[k] = b[k];\n }\n }\n return function(t) {\n for (k in i) c[k] = i[k](t);\n return c;\n };\n }\n d3.interpolateNumber = d3_interpolateNumber;\n function d3_interpolateNumber(a, b) {\n a = +a, b = +b;\n return function(t) {\n return a * (1 - t) + b * t;\n };\n }\n d3.interpolateString = d3_interpolateString;\n function d3_interpolateString(a, b) {\n var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];\n a = a + \"\", b = b + \"\";\n while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {\n if ((bs = bm.index) > bi) {\n bs = b.slice(bi, bs);\n if (s[i]) s[i] += bs; else s[++i] = bs;\n }\n if ((am = am[0]) === (bm = bm[0])) {\n if (s[i]) s[i] += bm; else s[++i] = bm;\n } else {\n s[++i] = null;\n q.push({\n i: i,\n x: d3_interpolateNumber(am, bm)\n });\n }\n bi = d3_interpolate_numberB.lastIndex;\n }\n if (bi < b.length) {\n bs = b.slice(bi);\n if (s[i]) s[i] += bs; else s[++i] = bs;\n }\n return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {\n return b(t) + \"\";\n }) : function() {\n return b;\n } : (b = q.length, function(t) {\n for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);\n return s.join(\"\");\n });\n }\n var d3_interpolate_numberA = /[-+]?(?:\\d+\\.?\\d*|\\.?\\d+)(?:[eE][-+]?\\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, \"g\");\n d3.interpolate = d3_interpolate;\n function d3_interpolate(a, b) {\n var i = d3.interpolators.length, f;\n while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;\n return f;\n }\n d3.interpolators = [ function(a, b) {\n var t = typeof b;\n return (t === \"string\" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\\(|hsl\\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === \"object\" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);\n } ];\n d3.interpolateArray = d3_interpolateArray;\n function d3_interpolateArray(a, b) {\n var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;\n for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));\n for (;i < na; ++i) c[i] = a[i];\n for (;i < nb; ++i) c[i] = b[i];\n return function(t) {\n for (i = 0; i < n0; ++i) c[i] = x[i](t);\n return c;\n };\n }\n var d3_ease_default = function() {\n return d3_identity;\n };\n var d3_ease = d3.map({\n linear: d3_ease_default,\n poly: d3_ease_poly,\n quad: function() {\n return d3_ease_quad;\n },\n cubic: function() {\n return d3_ease_cubic;\n },\n sin: function() {\n return d3_ease_sin;\n },\n exp: function() {\n return d3_ease_exp;\n },\n circle: function() {\n return d3_ease_circle;\n },\n elastic: d3_ease_elastic,\n back: d3_ease_back,\n bounce: function() {\n return d3_ease_bounce;\n }\n });\n var d3_ease_mode = d3.map({\n \"in\": d3_identity,\n out: d3_ease_reverse,\n \"in-out\": d3_ease_reflect,\n \"out-in\": function(f) {\n return d3_ease_reflect(d3_ease_reverse(f));\n }\n });\n d3.ease = function(name) {\n var i = name.indexOf(\"-\"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : \"in\";\n t = d3_ease.get(t) || d3_ease_default;\n m = d3_ease_mode.get(m) || d3_identity;\n return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));\n };\n function d3_ease_clamp(f) {\n return function(t) {\n return t <= 0 ? 0 : t >= 1 ? 1 : f(t);\n };\n }\n function d3_ease_reverse(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n }\n function d3_ease_reflect(f) {\n return function(t) {\n return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));\n };\n }\n function d3_ease_quad(t) {\n return t * t;\n }\n function d3_ease_cubic(t) {\n return t * t * t;\n }\n function d3_ease_cubicInOut(t) {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n var t2 = t * t, t3 = t2 * t;\n return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);\n }\n function d3_ease_poly(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n function d3_ease_sin(t) {\n return 1 - Math.cos(t * half\u03C0);\n }\n function d3_ease_exp(t) {\n return Math.pow(2, 10 * (t - 1));\n }\n function d3_ease_circle(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n function d3_ease_elastic(a, p) {\n var s;\n if (arguments.length < 2) p = .45;\n if (arguments.length) s = p / \u03C4 * Math.asin(1 / a); else a = 1, s = p / 4;\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * \u03C4 / p);\n };\n }\n function d3_ease_back(s) {\n if (!s) s = 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n function d3_ease_bounce(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;\n }\n d3.interpolateHcl = d3_interpolateHcl;\n function d3_interpolateHcl(a, b) {\n a = d3.hcl(a);\n b = d3.hcl(b);\n var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;\n if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;\n if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n return function(t) {\n return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + \"\";\n };\n }\n d3.interpolateHsl = d3_interpolateHsl;\n function d3_interpolateHsl(a, b) {\n a = d3.hsl(a);\n b = d3.hsl(b);\n var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;\n if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;\n if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n return function(t) {\n return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + \"\";\n };\n }\n d3.interpolateLab = d3_interpolateLab;\n function d3_interpolateLab(a, b) {\n a = d3.lab(a);\n b = d3.lab(b);\n var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;\n return function(t) {\n return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + \"\";\n };\n }\n d3.interpolateRound = d3_interpolateRound;\n function d3_interpolateRound(a, b) {\n b -= a;\n return function(t) {\n return Math.round(a + b * t);\n };\n }\n d3.transform = function(string) {\n var g = d3_document.createElementNS(d3.ns.prefix.svg, \"g\");\n return (d3.transform = function(string) {\n if (string != null) {\n g.setAttribute(\"transform\", string);\n var t = g.transform.baseVal.consolidate();\n }\n return new d3_transform(t ? t.matrix : d3_transformIdentity);\n })(string);\n };\n function d3_transform(m) {\n var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;\n if (r0[0] * r1[1] < r1[0] * r0[1]) {\n r0[0] *= -1;\n r0[1] *= -1;\n kx *= -1;\n kz *= -1;\n }\n this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;\n this.translate = [ m.e, m.f ];\n this.scale = [ kx, ky ];\n this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;\n }\n d3_transform.prototype.toString = function() {\n return \"translate(\" + this.translate + \")rotate(\" + this.rotate + \")skewX(\" + this.skew + \")scale(\" + this.scale + \")\";\n };\n function d3_transformDot(a, b) {\n return a[0] * b[0] + a[1] * b[1];\n }\n function d3_transformNormalize(a) {\n var k = Math.sqrt(d3_transformDot(a, a));\n if (k) {\n a[0] /= k;\n a[1] /= k;\n }\n return k;\n }\n function d3_transformCombine(a, b, k) {\n a[0] += k * b[0];\n a[1] += k * b[1];\n return a;\n }\n var d3_transformIdentity = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0\n };\n d3.interpolateTransform = d3_interpolateTransform;\n function d3_interpolateTransformPop(s) {\n return s.length ? s.pop() + \",\" : \"\";\n }\n function d3_interpolateTranslate(ta, tb, s, q) {\n if (ta[0] !== tb[0] || ta[1] !== tb[1]) {\n var i = s.push(\"translate(\", null, \",\", null, \")\");\n q.push({\n i: i - 4,\n x: d3_interpolateNumber(ta[0], tb[0])\n }, {\n i: i - 2,\n x: d3_interpolateNumber(ta[1], tb[1])\n });\n } else if (tb[0] || tb[1]) {\n s.push(\"translate(\" + tb + \")\");\n }\n }\n function d3_interpolateRotate(ra, rb, s, q) {\n if (ra !== rb) {\n if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;\n q.push({\n i: s.push(d3_interpolateTransformPop(s) + \"rotate(\", null, \")\") - 2,\n x: d3_interpolateNumber(ra, rb)\n });\n } else if (rb) {\n s.push(d3_interpolateTransformPop(s) + \"rotate(\" + rb + \")\");\n }\n }\n function d3_interpolateSkew(wa, wb, s, q) {\n if (wa !== wb) {\n q.push({\n i: s.push(d3_interpolateTransformPop(s) + \"skewX(\", null, \")\") - 2,\n x: d3_interpolateNumber(wa, wb)\n });\n } else if (wb) {\n s.push(d3_interpolateTransformPop(s) + \"skewX(\" + wb + \")\");\n }\n }\n function d3_interpolateScale(ka, kb, s, q) {\n if (ka[0] !== kb[0] || ka[1] !== kb[1]) {\n var i = s.push(d3_interpolateTransformPop(s) + \"scale(\", null, \",\", null, \")\");\n q.push({\n i: i - 4,\n x: d3_interpolateNumber(ka[0], kb[0])\n }, {\n i: i - 2,\n x: d3_interpolateNumber(ka[1], kb[1])\n });\n } else if (kb[0] !== 1 || kb[1] !== 1) {\n s.push(d3_interpolateTransformPop(s) + \"scale(\" + kb + \")\");\n }\n }\n function d3_interpolateTransform(a, b) {\n var s = [], q = [];\n a = d3.transform(a), b = d3.transform(b);\n d3_interpolateTranslate(a.translate, b.translate, s, q);\n d3_interpolateRotate(a.rotate, b.rotate, s, q);\n d3_interpolateSkew(a.skew, b.skew, s, q);\n d3_interpolateScale(a.scale, b.scale, s, q);\n a = b = null;\n return function(t) {\n var i = -1, n = q.length, o;\n while (++i < n) s[(o = q[i]).i] = o.x(t);\n return s.join(\"\");\n };\n }\n function d3_uninterpolateNumber(a, b) {\n b = (b -= a = +a) || 1 / b;\n return function(x) {\n return (x - a) / b;\n };\n }\n function d3_uninterpolateClamp(a, b) {\n b = (b -= a = +a) || 1 / b;\n return function(x) {\n return Math.max(0, Math.min(1, (x - a) / b));\n };\n }\n d3.layout = {};\n d3.layout.bundle = function() {\n return function(links) {\n var paths = [], i = -1, n = links.length;\n while (++i < n) paths.push(d3_layout_bundlePath(links[i]));\n return paths;\n };\n };\n function d3_layout_bundlePath(link) {\n var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];\n while (start !== lca) {\n start = start.parent;\n points.push(start);\n }\n var k = points.length;\n while (end !== lca) {\n points.splice(k, 0, end);\n end = end.parent;\n }\n return points;\n }\n function d3_layout_bundleAncestors(node) {\n var ancestors = [], parent = node.parent;\n while (parent != null) {\n ancestors.push(node);\n node = parent;\n parent = parent.parent;\n }\n ancestors.push(node);\n return ancestors;\n }\n function d3_layout_bundleLeastCommonAncestor(a, b) {\n if (a === b) return a;\n var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;\n while (aNode === bNode) {\n sharedNode = aNode;\n aNode = aNodes.pop();\n bNode = bNodes.pop();\n }\n return sharedNode;\n }\n d3.layout.chord = function() {\n var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;\n function relayout() {\n var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;\n chords = [];\n groups = [];\n k = 0, i = -1;\n while (++i < n) {\n x = 0, j = -1;\n while (++j < n) {\n x += matrix[i][j];\n }\n groupSums.push(x);\n subgroupIndex.push(d3.range(n));\n k += x;\n }\n if (sortGroups) {\n groupIndex.sort(function(a, b) {\n return sortGroups(groupSums[a], groupSums[b]);\n });\n }\n if (sortSubgroups) {\n subgroupIndex.forEach(function(d, i) {\n d.sort(function(a, b) {\n return sortSubgroups(matrix[i][a], matrix[i][b]);\n });\n });\n }\n k = (\u03C4 - padding * n) / k;\n x = 0, i = -1;\n while (++i < n) {\n x0 = x, j = -1;\n while (++j < n) {\n var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;\n subgroups[di + \"-\" + dj] = {\n index: di,\n subindex: dj,\n startAngle: a0,\n endAngle: a1,\n value: v\n };\n }\n groups[di] = {\n index: di,\n startAngle: x0,\n endAngle: x,\n value: groupSums[di]\n };\n x += padding;\n }\n i = -1;\n while (++i < n) {\n j = i - 1;\n while (++j < n) {\n var source = subgroups[i + \"-\" + j], target = subgroups[j + \"-\" + i];\n if (source.value || target.value) {\n chords.push(source.value < target.value ? {\n source: target,\n target: source\n } : {\n source: source,\n target: target\n });\n }\n }\n }\n if (sortChords) resort();\n }\n function resort() {\n chords.sort(function(a, b) {\n return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);\n });\n }\n chord.matrix = function(x) {\n if (!arguments.length) return matrix;\n n = (matrix = x) && matrix.length;\n chords = groups = null;\n return chord;\n };\n chord.padding = function(x) {\n if (!arguments.length) return padding;\n padding = x;\n chords = groups = null;\n return chord;\n };\n chord.sortGroups = function(x) {\n if (!arguments.length) return sortGroups;\n sortGroups = x;\n chords = groups = null;\n return chord;\n };\n chord.sortSubgroups = function(x) {\n if (!arguments.length) return sortSubgroups;\n sortSubgroups = x;\n chords = null;\n return chord;\n };\n chord.sortChords = function(x) {\n if (!arguments.length) return sortChords;\n sortChords = x;\n if (chords) resort();\n return chord;\n };\n chord.chords = function() {\n if (!chords) relayout();\n return chords;\n };\n chord.groups = function() {\n if (!groups) relayout();\n return groups;\n };\n return chord;\n };\n d3.layout.force = function() {\n var force = {}, event = d3.dispatch(\"start\", \"tick\", \"end\"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges;\n function repulse(node) {\n return function(quad, x1, _, x2) {\n if (quad.point !== node) {\n var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;\n if (dw * dw / theta2 < dn) {\n if (dn < chargeDistance2) {\n var k = quad.charge / dn;\n node.px -= dx * k;\n node.py -= dy * k;\n }\n return true;\n }\n if (quad.point && dn && dn < chargeDistance2) {\n var k = quad.pointCharge / dn;\n node.px -= dx * k;\n node.py -= dy * k;\n }\n }\n return !quad.charge;\n };\n }\n force.tick = function() {\n if ((alpha *= .99) < .005) {\n timer = null;\n event.end({\n type: \"end\",\n alpha: alpha = 0\n });\n return true;\n }\n var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;\n for (i = 0; i < m; ++i) {\n o = links[i];\n s = o.source;\n t = o.target;\n x = t.x - s.x;\n y = t.y - s.y;\n if (l = x * x + y * y) {\n l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;\n x *= l;\n y *= l;\n t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5);\n t.y -= y * k;\n s.x += x * (k = 1 - k);\n s.y += y * k;\n }\n }\n if (k = alpha * gravity) {\n x = size[0] / 2;\n y = size[1] / 2;\n i = -1;\n if (k) while (++i < n) {\n o = nodes[i];\n o.x += (x - o.x) * k;\n o.y += (y - o.y) * k;\n }\n }\n if (charge) {\n d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);\n i = -1;\n while (++i < n) {\n if (!(o = nodes[i]).fixed) {\n q.visit(repulse(o));\n }\n }\n }\n i = -1;\n while (++i < n) {\n o = nodes[i];\n if (o.fixed) {\n o.x = o.px;\n o.y = o.py;\n } else {\n o.x -= (o.px - (o.px = o.x)) * friction;\n o.y -= (o.py - (o.py = o.y)) * friction;\n }\n }\n event.tick({\n type: \"tick\",\n alpha: alpha\n });\n };\n force.nodes = function(x) {\n if (!arguments.length) return nodes;\n nodes = x;\n return force;\n };\n force.links = function(x) {\n if (!arguments.length) return links;\n links = x;\n return force;\n };\n force.size = function(x) {\n if (!arguments.length) return size;\n size = x;\n return force;\n };\n force.linkDistance = function(x) {\n if (!arguments.length) return linkDistance;\n linkDistance = typeof x === \"function\" ? x : +x;\n return force;\n };\n force.distance = force.linkDistance;\n force.linkStrength = function(x) {\n if (!arguments.length) return linkStrength;\n linkStrength = typeof x === \"function\" ? x : +x;\n return force;\n };\n force.friction = function(x) {\n if (!arguments.length) return friction;\n friction = +x;\n return force;\n };\n force.charge = function(x) {\n if (!arguments.length) return charge;\n charge = typeof x === \"function\" ? x : +x;\n return force;\n };\n force.chargeDistance = function(x) {\n if (!arguments.length) return Math.sqrt(chargeDistance2);\n chargeDistance2 = x * x;\n return force;\n };\n force.gravity = function(x) {\n if (!arguments.length) return gravity;\n gravity = +x;\n return force;\n };\n force.theta = function(x) {\n if (!arguments.length) return Math.sqrt(theta2);\n theta2 = x * x;\n return force;\n };\n force.alpha = function(x) {\n if (!arguments.length) return alpha;\n x = +x;\n if (alpha) {\n if (x > 0) {\n alpha = x;\n } else {\n timer.c = null, timer.t = NaN, timer = null;\n event.end({\n type: \"end\",\n alpha: alpha = 0\n });\n }\n } else if (x > 0) {\n event.start({\n type: \"start\",\n alpha: alpha = x\n });\n timer = d3_timer(force.tick);\n }\n return force;\n };\n force.start = function() {\n var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;\n for (i = 0; i < n; ++i) {\n (o = nodes[i]).index = i;\n o.weight = 0;\n }\n for (i = 0; i < m; ++i) {\n o = links[i];\n if (typeof o.source == \"number\") o.source = nodes[o.source];\n if (typeof o.target == \"number\") o.target = nodes[o.target];\n ++o.source.weight;\n ++o.target.weight;\n }\n for (i = 0; i < n; ++i) {\n o = nodes[i];\n if (isNaN(o.x)) o.x = position(\"x\", w);\n if (isNaN(o.y)) o.y = position(\"y\", h);\n if (isNaN(o.px)) o.px = o.x;\n if (isNaN(o.py)) o.py = o.y;\n }\n distances = [];\n if (typeof linkDistance === \"function\") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance;\n strengths = [];\n if (typeof linkStrength === \"function\") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength;\n charges = [];\n if (typeof charge === \"function\") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge;\n function position(dimension, size) {\n if (!neighbors) {\n neighbors = new Array(n);\n for (j = 0; j < n; ++j) {\n neighbors[j] = [];\n }\n for (j = 0; j < m; ++j) {\n var o = links[j];\n neighbors[o.source.index].push(o.target);\n neighbors[o.target.index].push(o.source);\n }\n }\n var candidates = neighbors[i], j = -1, l = candidates.length, x;\n while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x;\n return Math.random() * size;\n }\n return force.resume();\n };\n force.resume = function() {\n return force.alpha(.1);\n };\n force.stop = function() {\n return force.alpha(0);\n };\n force.drag = function() {\n if (!drag) drag = d3.behavior.drag().origin(d3_identity).on(\"dragstart.force\", d3_layout_forceDragstart).on(\"drag.force\", dragmove).on(\"dragend.force\", d3_layout_forceDragend);\n if (!arguments.length) return drag;\n this.on(\"mouseover.force\", d3_layout_forceMouseover).on(\"mouseout.force\", d3_layout_forceMouseout).call(drag);\n };\n function dragmove(d) {\n d.px = d3.event.x, d.py = d3.event.y;\n force.resume();\n }\n return d3.rebind(force, event, \"on\");\n };\n function d3_layout_forceDragstart(d) {\n d.fixed |= 2;\n }\n function d3_layout_forceDragend(d) {\n d.fixed &= ~6;\n }\n function d3_layout_forceMouseover(d) {\n d.fixed |= 4;\n d.px = d.x, d.py = d.y;\n }\n function d3_layout_forceMouseout(d) {\n d.fixed &= ~4;\n }\n function d3_layout_forceAccumulate(quad, alpha, charges) {\n var cx = 0, cy = 0;\n quad.charge = 0;\n if (!quad.leaf) {\n var nodes = quad.nodes, n = nodes.length, i = -1, c;\n while (++i < n) {\n c = nodes[i];\n if (c == null) continue;\n d3_layout_forceAccumulate(c, alpha, charges);\n quad.charge += c.charge;\n cx += c.charge * c.cx;\n cy += c.charge * c.cy;\n }\n }\n if (quad.point) {\n if (!quad.leaf) {\n quad.point.x += Math.random() - .5;\n quad.point.y += Math.random() - .5;\n }\n var k = alpha * charges[quad.point.index];\n quad.charge += quad.pointCharge = k;\n cx += k * quad.point.x;\n cy += k * quad.point.y;\n }\n quad.cx = cx / quad.charge;\n quad.cy = cy / quad.charge;\n }\n var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;\n d3.layout.hierarchy = function() {\n var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;\n function hierarchy(root) {\n var stack = [ root ], nodes = [], node;\n root.depth = 0;\n while ((node = stack.pop()) != null) {\n nodes.push(node);\n if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {\n var n, childs, child;\n while (--n >= 0) {\n stack.push(child = childs[n]);\n child.parent = node;\n child.depth = node.depth + 1;\n }\n if (value) node.value = 0;\n node.children = childs;\n } else {\n if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;\n delete node.children;\n }\n }\n d3_layout_hierarchyVisitAfter(root, function(node) {\n var childs, parent;\n if (sort && (childs = node.children)) childs.sort(sort);\n if (value && (parent = node.parent)) parent.value += node.value;\n });\n return nodes;\n }\n hierarchy.sort = function(x) {\n if (!arguments.length) return sort;\n sort = x;\n return hierarchy;\n };\n hierarchy.children = function(x) {\n if (!arguments.length) return children;\n children = x;\n return hierarchy;\n };\n hierarchy.value = function(x) {\n if (!arguments.length) return value;\n value = x;\n return hierarchy;\n };\n hierarchy.revalue = function(root) {\n if (value) {\n d3_layout_hierarchyVisitBefore(root, function(node) {\n if (node.children) node.value = 0;\n });\n d3_layout_hierarchyVisitAfter(root, function(node) {\n var parent;\n if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;\n if (parent = node.parent) parent.value += node.value;\n });\n }\n return root;\n };\n return hierarchy;\n };\n function d3_layout_hierarchyRebind(object, hierarchy) {\n d3.rebind(object, hierarchy, \"sort\", \"children\", \"value\");\n object.nodes = object;\n object.links = d3_layout_hierarchyLinks;\n return object;\n }\n function d3_layout_hierarchyVisitBefore(node, callback) {\n var nodes = [ node ];\n while ((node = nodes.pop()) != null) {\n callback(node);\n if ((children = node.children) && (n = children.length)) {\n var n, children;\n while (--n >= 0) nodes.push(children[n]);\n }\n }\n }\n function d3_layout_hierarchyVisitAfter(node, callback) {\n var nodes = [ node ], nodes2 = [];\n while ((node = nodes.pop()) != null) {\n nodes2.push(node);\n if ((children = node.children) && (n = children.length)) {\n var i = -1, n, children;\n while (++i < n) nodes.push(children[i]);\n }\n }\n while ((node = nodes2.pop()) != null) {\n callback(node);\n }\n }\n function d3_layout_hierarchyChildren(d) {\n return d.children;\n }\n function d3_layout_hierarchyValue(d) {\n return d.value;\n }\n function d3_layout_hierarchySort(a, b) {\n return b.value - a.value;\n }\n function d3_layout_hierarchyLinks(nodes) {\n return d3.merge(nodes.map(function(parent) {\n return (parent.children || []).map(function(child) {\n return {\n source: parent,\n target: child\n };\n });\n }));\n }\n d3.layout.partition = function() {\n var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];\n function position(node, x, dx, dy) {\n var children = node.children;\n node.x = x;\n node.y = node.depth * dy;\n node.dx = dx;\n node.dy = dy;\n if (children && (n = children.length)) {\n var i = -1, n, c, d;\n dx = node.value ? dx / node.value : 0;\n while (++i < n) {\n position(c = children[i], x, d = c.value * dx, dy);\n x += d;\n }\n }\n }\n function depth(node) {\n var children = node.children, d = 0;\n if (children && (n = children.length)) {\n var i = -1, n;\n while (++i < n) d = Math.max(d, depth(children[i]));\n }\n return 1 + d;\n }\n function partition(d, i) {\n var nodes = hierarchy.call(this, d, i);\n position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));\n return nodes;\n }\n partition.size = function(x) {\n if (!arguments.length) return size;\n size = x;\n return partition;\n };\n return d3_layout_hierarchyRebind(partition, hierarchy);\n };\n d3.layout.pie = function() {\n var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = \u03C4, padAngle = 0;\n function pie(data) {\n var n = data.length, values = data.map(function(d, i) {\n return +value.call(pie, d, i);\n }), a = +(typeof startAngle === \"function\" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === \"function\" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === \"function\" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v;\n if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {\n return values[j] - values[i];\n } : function(i, j) {\n return sort(data[i], data[j]);\n });\n index.forEach(function(i) {\n arcs[i] = {\n data: data[i],\n value: v = values[i],\n startAngle: a,\n endAngle: a += v * k + pa,\n padAngle: p\n };\n });\n return arcs;\n }\n pie.value = function(_) {\n if (!arguments.length) return value;\n value = _;\n return pie;\n };\n pie.sort = function(_) {\n if (!arguments.length) return sort;\n sort = _;\n return pie;\n };\n pie.startAngle = function(_) {\n if (!arguments.length) return startAngle;\n startAngle = _;\n return pie;\n };\n pie.endAngle = function(_) {\n if (!arguments.length) return endAngle;\n endAngle = _;\n return pie;\n };\n pie.padAngle = function(_) {\n if (!arguments.length) return padAngle;\n padAngle = _;\n return pie;\n };\n return pie;\n };\n var d3_layout_pieSortByValue = {};\n d3.layout.stack = function() {\n var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;\n function stack(data, index) {\n if (!(n = data.length)) return data;\n var series = data.map(function(d, i) {\n return values.call(stack, d, i);\n });\n var points = series.map(function(d) {\n return d.map(function(v, i) {\n return [ x.call(stack, v, i), y.call(stack, v, i) ];\n });\n });\n var orders = order.call(stack, points, index);\n series = d3.permute(series, orders);\n points = d3.permute(points, orders);\n var offsets = offset.call(stack, points, index);\n var m = series[0].length, n, i, j, o;\n for (j = 0; j < m; ++j) {\n out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);\n for (i = 1; i < n; ++i) {\n out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);\n }\n }\n return data;\n }\n stack.values = function(x) {\n if (!arguments.length) return values;\n values = x;\n return stack;\n };\n stack.order = function(x) {\n if (!arguments.length) return order;\n order = typeof x === \"function\" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;\n return stack;\n };\n stack.offset = function(x) {\n if (!arguments.length) return offset;\n offset = typeof x === \"function\" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;\n return stack;\n };\n stack.x = function(z) {\n if (!arguments.length) return x;\n x = z;\n return stack;\n };\n stack.y = function(z) {\n if (!arguments.length) return y;\n y = z;\n return stack;\n };\n stack.out = function(z) {\n if (!arguments.length) return out;\n out = z;\n return stack;\n };\n return stack;\n };\n function d3_layout_stackX(d) {\n return d.x;\n }\n function d3_layout_stackY(d) {\n return d.y;\n }\n function d3_layout_stackOut(d, y0, y) {\n d.y0 = y0;\n d.y = y;\n }\n var d3_layout_stackOrders = d3.map({\n \"inside-out\": function(data) {\n var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) {\n return max[a] - max[b];\n }), top = 0, bottom = 0, tops = [], bottoms = [];\n for (i = 0; i < n; ++i) {\n j = index[i];\n if (top < bottom) {\n top += sums[j];\n tops.push(j);\n } else {\n bottom += sums[j];\n bottoms.push(j);\n }\n }\n return bottoms.reverse().concat(tops);\n },\n reverse: function(data) {\n return d3.range(data.length).reverse();\n },\n \"default\": d3_layout_stackOrderDefault\n });\n var d3_layout_stackOffsets = d3.map({\n silhouette: function(data) {\n var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];\n for (j = 0; j < m; ++j) {\n for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n if (o > max) max = o;\n sums.push(o);\n }\n for (j = 0; j < m; ++j) {\n y0[j] = (max - sums[j]) / 2;\n }\n return y0;\n },\n wiggle: function(data) {\n var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];\n y0[0] = o = o0 = 0;\n for (j = 1; j < m; ++j) {\n for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];\n for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {\n for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {\n s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;\n }\n s2 += s3 * data[i][j][1];\n }\n y0[j] = o -= s1 ? s2 / s1 * dx : 0;\n if (o < o0) o0 = o;\n }\n for (j = 0; j < m; ++j) y0[j] -= o0;\n return y0;\n },\n expand: function(data) {\n var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];\n for (j = 0; j < m; ++j) {\n for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k;\n }\n for (j = 0; j < m; ++j) y0[j] = 0;\n return y0;\n },\n zero: d3_layout_stackOffsetZero\n });\n function d3_layout_stackOrderDefault(data) {\n return d3.range(data.length);\n }\n function d3_layout_stackOffsetZero(data) {\n var j = -1, m = data[0].length, y0 = [];\n while (++j < m) y0[j] = 0;\n return y0;\n }\n function d3_layout_stackMaxIndex(array) {\n var i = 1, j = 0, v = array[0][1], k, n = array.length;\n for (;i < n; ++i) {\n if ((k = array[i][1]) > v) {\n j = i;\n v = k;\n }\n }\n return j;\n }\n function d3_layout_stackReduceSum(d) {\n return d.reduce(d3_layout_stackSum, 0);\n }\n function d3_layout_stackSum(p, d) {\n return p + d[1];\n }\n d3.layout.histogram = function() {\n var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;\n function histogram(data, i) {\n var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x;\n while (++i < m) {\n bin = bins[i] = [];\n bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);\n bin.y = 0;\n }\n if (m > 0) {\n i = -1;\n while (++i < n) {\n x = values[i];\n if (x >= range[0] && x <= range[1]) {\n bin = bins[d3.bisect(thresholds, x, 1, m) - 1];\n bin.y += k;\n bin.push(data[i]);\n }\n }\n }\n return bins;\n }\n histogram.value = function(x) {\n if (!arguments.length) return valuer;\n valuer = x;\n return histogram;\n };\n histogram.range = function(x) {\n if (!arguments.length) return ranger;\n ranger = d3_functor(x);\n return histogram;\n };\n histogram.bins = function(x) {\n if (!arguments.length) return binner;\n binner = typeof x === \"number\" ? function(range) {\n return d3_layout_histogramBinFixed(range, x);\n } : d3_functor(x);\n return histogram;\n };\n histogram.frequency = function(x) {\n if (!arguments.length) return frequency;\n frequency = !!x;\n return histogram;\n };\n return histogram;\n };\n function d3_layout_histogramBinSturges(range, values) {\n return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));\n }\n function d3_layout_histogramBinFixed(range, n) {\n var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];\n while (++x <= n) f[x] = m * x + b;\n return f;\n }\n function d3_layout_histogramRange(values) {\n return [ d3.min(values), d3.max(values) ];\n }\n d3.layout.pack = function() {\n var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;\n function pack(d, i) {\n var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === \"function\" ? radius : function() {\n return radius;\n };\n root.x = root.y = 0;\n d3_layout_hierarchyVisitAfter(root, function(d) {\n d.r = +r(d.value);\n });\n d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n if (padding) {\n var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;\n d3_layout_hierarchyVisitAfter(root, function(d) {\n d.r += dr;\n });\n d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n d3_layout_hierarchyVisitAfter(root, function(d) {\n d.r -= dr;\n });\n }\n d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));\n return nodes;\n }\n pack.size = function(_) {\n if (!arguments.length) return size;\n size = _;\n return pack;\n };\n pack.radius = function(_) {\n if (!arguments.length) return radius;\n radius = _ == null || typeof _ === \"function\" ? _ : +_;\n return pack;\n };\n pack.padding = function(_) {\n if (!arguments.length) return padding;\n padding = +_;\n return pack;\n };\n return d3_layout_hierarchyRebind(pack, hierarchy);\n };\n function d3_layout_packSort(a, b) {\n return a.value - b.value;\n }\n function d3_layout_packInsert(a, b) {\n var c = a._pack_next;\n a._pack_next = b;\n b._pack_prev = a;\n b._pack_next = c;\n c._pack_prev = b;\n }\n function d3_layout_packSplice(a, b) {\n a._pack_next = b;\n b._pack_prev = a;\n }\n function d3_layout_packIntersects(a, b) {\n var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;\n return .999 * dr * dr > dx * dx + dy * dy;\n }\n function d3_layout_packSiblings(node) {\n if (!(nodes = node.children) || !(n = nodes.length)) return;\n var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;\n function bound(node) {\n xMin = Math.min(node.x - node.r, xMin);\n xMax = Math.max(node.x + node.r, xMax);\n yMin = Math.min(node.y - node.r, yMin);\n yMax = Math.max(node.y + node.r, yMax);\n }\n nodes.forEach(d3_layout_packLink);\n a = nodes[0];\n a.x = -a.r;\n a.y = 0;\n bound(a);\n if (n > 1) {\n b = nodes[1];\n b.x = b.r;\n b.y = 0;\n bound(b);\n if (n > 2) {\n c = nodes[2];\n d3_layout_packPlace(a, b, c);\n bound(c);\n d3_layout_packInsert(a, c);\n a._pack_prev = c;\n d3_layout_packInsert(c, b);\n b = a._pack_next;\n for (i = 3; i < n; i++) {\n d3_layout_packPlace(a, b, c = nodes[i]);\n var isect = 0, s1 = 1, s2 = 1;\n for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {\n if (d3_layout_packIntersects(j, c)) {\n isect = 1;\n break;\n }\n }\n if (isect == 1) {\n for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {\n if (d3_layout_packIntersects(k, c)) {\n break;\n }\n }\n }\n if (isect) {\n if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);\n i--;\n } else {\n d3_layout_packInsert(a, c);\n b = c;\n bound(c);\n }\n }\n }\n }\n var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;\n for (i = 0; i < n; i++) {\n c = nodes[i];\n c.x -= cx;\n c.y -= cy;\n cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));\n }\n node.r = cr;\n nodes.forEach(d3_layout_packUnlink);\n }\n function d3_layout_packLink(node) {\n node._pack_next = node._pack_prev = node;\n }\n function d3_layout_packUnlink(node) {\n delete node._pack_next;\n delete node._pack_prev;\n }\n function d3_layout_packTransform(node, x, y, k) {\n var children = node.children;\n node.x = x += k * node.x;\n node.y = y += k * node.y;\n node.r *= k;\n if (children) {\n var i = -1, n = children.length;\n while (++i < n) d3_layout_packTransform(children[i], x, y, k);\n }\n }\n function d3_layout_packPlace(a, b, c) {\n var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;\n if (db && (dx || dy)) {\n var da = b.r + c.r, dc = dx * dx + dy * dy;\n da *= da;\n db *= db;\n var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);\n c.x = a.x + x * dx + y * dy;\n c.y = a.y + x * dy - y * dx;\n } else {\n c.x = a.x + db;\n c.y = a.y;\n }\n }\n d3.layout.tree = function() {\n var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;\n function tree(d, i) {\n var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);\n d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;\n d3_layout_hierarchyVisitBefore(root1, secondWalk);\n if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {\n var left = root0, right = root0, bottom = root0;\n d3_layout_hierarchyVisitBefore(root0, function(node) {\n if (node.x < left.x) left = node;\n if (node.x > right.x) right = node;\n if (node.depth > bottom.depth) bottom = node;\n });\n var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);\n d3_layout_hierarchyVisitBefore(root0, function(node) {\n node.x = (node.x + tx) * kx;\n node.y = node.depth * ky;\n });\n }\n return nodes;\n }\n function wrapTree(root0) {\n var root1 = {\n A: null,\n children: [ root0 ]\n }, queue = [ root1 ], node1;\n while ((node1 = queue.pop()) != null) {\n for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {\n queue.push((children[i] = child = {\n _: children[i],\n parent: node1,\n children: (child = children[i].children) && child.slice() || [],\n A: null,\n a: null,\n z: 0,\n m: 0,\n c: 0,\n s: 0,\n t: null,\n i: i\n }).a = child);\n }\n }\n return root1.children[0];\n }\n function firstWalk(v) {\n var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;\n if (children.length) {\n d3_layout_treeShift(v);\n var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n if (w) {\n v.z = w.z + separation(v._, w._);\n v.m = v.z - midpoint;\n } else {\n v.z = midpoint;\n }\n } else if (w) {\n v.z = w.z + separation(v._, w._);\n }\n v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n }\n function secondWalk(v) {\n v._.x = v.z + v.parent.m;\n v.m += v.parent.m;\n }\n function apportion(v, w, ancestor) {\n if (w) {\n var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;\n while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {\n vom = d3_layout_treeLeft(vom);\n vop = d3_layout_treeRight(vop);\n vop.a = v;\n shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);\n if (shift > 0) {\n d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);\n sip += shift;\n sop += shift;\n }\n sim += vim.m;\n sip += vip.m;\n som += vom.m;\n sop += vop.m;\n }\n if (vim && !d3_layout_treeRight(vop)) {\n vop.t = vim;\n vop.m += sim - sop;\n }\n if (vip && !d3_layout_treeLeft(vom)) {\n vom.t = vip;\n vom.m += sip - som;\n ancestor = v;\n }\n }\n return ancestor;\n }\n function sizeNode(node) {\n node.x *= size[0];\n node.y = node.depth * size[1];\n }\n tree.separation = function(x) {\n if (!arguments.length) return separation;\n separation = x;\n return tree;\n };\n tree.size = function(x) {\n if (!arguments.length) return nodeSize ? null : size;\n nodeSize = (size = x) == null ? sizeNode : null;\n return tree;\n };\n tree.nodeSize = function(x) {\n if (!arguments.length) return nodeSize ? size : null;\n nodeSize = (size = x) == null ? null : sizeNode;\n return tree;\n };\n return d3_layout_hierarchyRebind(tree, hierarchy);\n };\n function d3_layout_treeSeparation(a, b) {\n return a.parent == b.parent ? 1 : 2;\n }\n function d3_layout_treeLeft(v) {\n var children = v.children;\n return children.length ? children[0] : v.t;\n }\n function d3_layout_treeRight(v) {\n var children = v.children, n;\n return (n = children.length) ? children[n - 1] : v.t;\n }\n function d3_layout_treeMove(wm, wp, shift) {\n var change = shift / (wp.i - wm.i);\n wp.c -= change;\n wp.s += shift;\n wm.c += change;\n wp.z += shift;\n wp.m += shift;\n }\n function d3_layout_treeShift(v) {\n var shift = 0, change = 0, children = v.children, i = children.length, w;\n while (--i >= 0) {\n w = children[i];\n w.z += shift;\n w.m += shift;\n shift += w.s + (change += w.c);\n }\n }\n function d3_layout_treeAncestor(vim, v, ancestor) {\n return vim.a.parent === v.parent ? vim.a : ancestor;\n }\n d3.layout.cluster = function() {\n var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;\n function cluster(d, i) {\n var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;\n d3_layout_hierarchyVisitAfter(root, function(node) {\n var children = node.children;\n if (children && children.length) {\n node.x = d3_layout_clusterX(children);\n node.y = d3_layout_clusterY(children);\n } else {\n node.x = previousNode ? x += separation(node, previousNode) : 0;\n node.y = 0;\n previousNode = node;\n }\n });\n var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;\n d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {\n node.x = (node.x - root.x) * size[0];\n node.y = (root.y - node.y) * size[1];\n } : function(node) {\n node.x = (node.x - x0) / (x1 - x0) * size[0];\n node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];\n });\n return nodes;\n }\n cluster.separation = function(x) {\n if (!arguments.length) return separation;\n separation = x;\n return cluster;\n };\n cluster.size = function(x) {\n if (!arguments.length) return nodeSize ? null : size;\n nodeSize = (size = x) == null;\n return cluster;\n };\n cluster.nodeSize = function(x) {\n if (!arguments.length) return nodeSize ? size : null;\n nodeSize = (size = x) != null;\n return cluster;\n };\n return d3_layout_hierarchyRebind(cluster, hierarchy);\n };\n function d3_layout_clusterY(children) {\n return 1 + d3.max(children, function(child) {\n return child.y;\n });\n }\n function d3_layout_clusterX(children) {\n return children.reduce(function(x, child) {\n return x + child.x;\n }, 0) / children.length;\n }\n function d3_layout_clusterLeft(node) {\n var children = node.children;\n return children && children.length ? d3_layout_clusterLeft(children[0]) : node;\n }\n function d3_layout_clusterRight(node) {\n var children = node.children, n;\n return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;\n }\n d3.layout.treemap = function() {\n var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = \"squarify\", ratio = .5 * (1 + Math.sqrt(5));\n function scale(children, k) {\n var i = -1, n = children.length, child, area;\n while (++i < n) {\n area = (child = children[i]).value * (k < 0 ? 0 : k);\n child.area = isNaN(area) || area <= 0 ? 0 : area;\n }\n }\n function squarify(node) {\n var children = node.children;\n if (children && children.length) {\n var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === \"slice\" ? rect.dx : mode === \"dice\" ? rect.dy : mode === \"slice-dice\" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n;\n scale(remaining, rect.dx * rect.dy / node.value);\n row.area = 0;\n while ((n = remaining.length) > 0) {\n row.push(child = remaining[n - 1]);\n row.area += child.area;\n if (mode !== \"squarify\" || (score = worst(row, u)) <= best) {\n remaining.pop();\n best = score;\n } else {\n row.area -= row.pop().area;\n position(row, u, rect, false);\n u = Math.min(rect.dx, rect.dy);\n row.length = row.area = 0;\n best = Infinity;\n }\n }\n if (row.length) {\n position(row, u, rect, true);\n row.length = row.area = 0;\n }\n children.forEach(squarify);\n }\n }\n function stickify(node) {\n var children = node.children;\n if (children && children.length) {\n var rect = pad(node), remaining = children.slice(), child, row = [];\n scale(remaining, rect.dx * rect.dy / node.value);\n row.area = 0;\n while (child = remaining.pop()) {\n row.push(child);\n row.area += child.area;\n if (child.z != null) {\n position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);\n row.length = row.area = 0;\n }\n }\n children.forEach(stickify);\n }\n }\n function worst(row, u) {\n var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;\n while (++i < n) {\n if (!(r = row[i].area)) continue;\n if (r < rmin) rmin = r;\n if (r > rmax) rmax = r;\n }\n s *= s;\n u *= u;\n return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;\n }\n function position(row, u, rect, flush) {\n var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;\n if (u == rect.dx) {\n if (flush || v > rect.dy) v = rect.dy;\n while (++i < n) {\n o = row[i];\n o.x = x;\n o.y = y;\n o.dy = v;\n x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);\n }\n o.z = true;\n o.dx += rect.x + rect.dx - x;\n rect.y += v;\n rect.dy -= v;\n } else {\n if (flush || v > rect.dx) v = rect.dx;\n while (++i < n) {\n o = row[i];\n o.x = x;\n o.y = y;\n o.dx = v;\n y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);\n }\n o.z = false;\n o.dy += rect.y + rect.dy - y;\n rect.x += v;\n rect.dx -= v;\n }\n }\n function treemap(d) {\n var nodes = stickies || hierarchy(d), root = nodes[0];\n root.x = root.y = 0;\n if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0;\n if (stickies) hierarchy.revalue(root);\n scale([ root ], root.dx * root.dy / root.value);\n (stickies ? stickify : squarify)(root);\n if (sticky) stickies = nodes;\n return nodes;\n }\n treemap.size = function(x) {\n if (!arguments.length) return size;\n size = x;\n return treemap;\n };\n treemap.padding = function(x) {\n if (!arguments.length) return padding;\n function padFunction(node) {\n var p = x.call(treemap, node, node.depth);\n return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === \"number\" ? [ p, p, p, p ] : p);\n }\n function padConstant(node) {\n return d3_layout_treemapPad(node, x);\n }\n var type;\n pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === \"function\" ? padFunction : type === \"number\" ? (x = [ x, x, x, x ], \n padConstant) : padConstant;\n return treemap;\n };\n treemap.round = function(x) {\n if (!arguments.length) return round != Number;\n round = x ? Math.round : Number;\n return treemap;\n };\n treemap.sticky = function(x) {\n if (!arguments.length) return sticky;\n sticky = x;\n stickies = null;\n return treemap;\n };\n treemap.ratio = function(x) {\n if (!arguments.length) return ratio;\n ratio = x;\n return treemap;\n };\n treemap.mode = function(x) {\n if (!arguments.length) return mode;\n mode = x + \"\";\n return treemap;\n };\n return d3_layout_hierarchyRebind(treemap, hierarchy);\n };\n function d3_layout_treemapPadNull(node) {\n return {\n x: node.x,\n y: node.y,\n dx: node.dx,\n dy: node.dy\n };\n }\n function d3_layout_treemapPad(node, padding) {\n var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2];\n if (dx < 0) {\n x += dx / 2;\n dx = 0;\n }\n if (dy < 0) {\n y += dy / 2;\n dy = 0;\n }\n return {\n x: x,\n y: y,\n dx: dx,\n dy: dy\n };\n }\n d3.random = {\n normal: function(\u00B5, \u03C3) {\n var n = arguments.length;\n if (n < 2) \u03C3 = 1;\n if (n < 1) \u00B5 = 0;\n return function() {\n var x, y, r;\n do {\n x = Math.random() * 2 - 1;\n y = Math.random() * 2 - 1;\n r = x * x + y * y;\n } while (!r || r > 1);\n return \u00B5 + \u03C3 * x * Math.sqrt(-2 * Math.log(r) / r);\n };\n },\n logNormal: function() {\n var random = d3.random.normal.apply(d3, arguments);\n return function() {\n return Math.exp(random());\n };\n },\n bates: function(m) {\n var random = d3.random.irwinHall(m);\n return function() {\n return random() / m;\n };\n },\n irwinHall: function(m) {\n return function() {\n for (var s = 0, j = 0; j < m; j++) s += Math.random();\n return s;\n };\n }\n };\n d3.scale = {};\n function d3_scaleExtent(domain) {\n var start = domain[0], stop = domain[domain.length - 1];\n return start < stop ? [ start, stop ] : [ stop, start ];\n }\n function d3_scaleRange(scale) {\n return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());\n }\n function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {\n var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);\n return function(x) {\n return i(u(x));\n };\n }\n function d3_scale_nice(domain, nice) {\n var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;\n if (x1 < x0) {\n dx = i0, i0 = i1, i1 = dx;\n dx = x0, x0 = x1, x1 = dx;\n }\n domain[i0] = nice.floor(x0);\n domain[i1] = nice.ceil(x1);\n return domain;\n }\n function d3_scale_niceStep(step) {\n return step ? {\n floor: function(x) {\n return Math.floor(x / step) * step;\n },\n ceil: function(x) {\n return Math.ceil(x / step) * step;\n }\n } : d3_scale_niceIdentity;\n }\n var d3_scale_niceIdentity = {\n floor: d3_identity,\n ceil: d3_identity\n };\n function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {\n var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;\n if (domain[k] < domain[0]) {\n domain = domain.slice().reverse();\n range = range.slice().reverse();\n }\n while (++j <= k) {\n u.push(uninterpolate(domain[j - 1], domain[j]));\n i.push(interpolate(range[j - 1], range[j]));\n }\n return function(x) {\n var j = d3.bisect(domain, x, 1, k) - 1;\n return i[j](u[j](x));\n };\n }\n d3.scale.linear = function() {\n return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);\n };\n function d3_scale_linear(domain, range, interpolate, clamp) {\n var output, input;\n function rescale() {\n var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;\n output = linear(domain, range, uninterpolate, interpolate);\n input = linear(range, domain, uninterpolate, d3_interpolate);\n return scale;\n }\n function scale(x) {\n return output(x);\n }\n scale.invert = function(y) {\n return input(y);\n };\n scale.domain = function(x) {\n if (!arguments.length) return domain;\n domain = x.map(Number);\n return rescale();\n };\n scale.range = function(x) {\n if (!arguments.length) return range;\n range = x;\n return rescale();\n };\n scale.rangeRound = function(x) {\n return scale.range(x).interpolate(d3_interpolateRound);\n };\n scale.clamp = function(x) {\n if (!arguments.length) return clamp;\n clamp = x;\n return rescale();\n };\n scale.interpolate = function(x) {\n if (!arguments.length) return interpolate;\n interpolate = x;\n return rescale();\n };\n scale.ticks = function(m) {\n return d3_scale_linearTicks(domain, m);\n };\n scale.tickFormat = function(m, format) {\n return d3_scale_linearTickFormat(domain, m, format);\n };\n scale.nice = function(m) {\n d3_scale_linearNice(domain, m);\n return rescale();\n };\n scale.copy = function() {\n return d3_scale_linear(domain, range, interpolate, clamp);\n };\n return rescale();\n }\n function d3_scale_linearRebind(scale, linear) {\n return d3.rebind(scale, linear, \"range\", \"rangeRound\", \"interpolate\", \"clamp\");\n }\n function d3_scale_linearNice(domain, m) {\n d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n return domain;\n }\n function d3_scale_linearTickRange(domain, m) {\n if (m == null) m = 10;\n var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;\n if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;\n extent[0] = Math.ceil(extent[0] / step) * step;\n extent[1] = Math.floor(extent[1] / step) * step + step * .5;\n extent[2] = step;\n return extent;\n }\n function d3_scale_linearTicks(domain, m) {\n return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));\n }\n function d3_scale_linearTickFormat(domain, m, format) {\n var range = d3_scale_linearTickRange(domain, m);\n if (format) {\n var match = d3_format_re.exec(format);\n match.shift();\n if (match[8] === \"s\") {\n var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));\n if (!match[7]) match[7] = \".\" + d3_scale_linearPrecision(prefix.scale(range[2]));\n match[8] = \"f\";\n format = d3.format(match.join(\"\"));\n return function(d) {\n return format(prefix.scale(d)) + prefix.symbol;\n };\n }\n if (!match[7]) match[7] = \".\" + d3_scale_linearFormatPrecision(match[8], range);\n format = match.join(\"\");\n } else {\n format = \",.\" + d3_scale_linearPrecision(range[2]) + \"f\";\n }\n return d3.format(format);\n }\n var d3_scale_linearFormatSignificant = {\n s: 1,\n g: 1,\n p: 1,\n r: 1,\n e: 1\n };\n function d3_scale_linearPrecision(value) {\n return -Math.floor(Math.log(value) / Math.LN10 + .01);\n }\n function d3_scale_linearFormatPrecision(type, range) {\n var p = d3_scale_linearPrecision(range[2]);\n return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== \"e\") : p - (type === \"%\") * 2;\n }\n d3.scale.log = function() {\n return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);\n };\n function d3_scale_log(linear, base, positive, domain) {\n function log(x) {\n return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);\n }\n function pow(x) {\n return positive ? Math.pow(base, x) : -Math.pow(base, -x);\n }\n function scale(x) {\n return linear(log(x));\n }\n scale.invert = function(x) {\n return pow(linear.invert(x));\n };\n scale.domain = function(x) {\n if (!arguments.length) return domain;\n positive = x[0] >= 0;\n linear.domain((domain = x.map(Number)).map(log));\n return scale;\n };\n scale.base = function(_) {\n if (!arguments.length) return base;\n base = +_;\n linear.domain(domain.map(log));\n return scale;\n };\n scale.nice = function() {\n var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);\n linear.domain(niced);\n domain = niced.map(pow);\n return scale;\n };\n scale.ticks = function() {\n var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;\n if (isFinite(j - i)) {\n if (positive) {\n for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);\n ticks.push(pow(i));\n } else {\n ticks.push(pow(i));\n for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);\n }\n for (i = 0; ticks[i] < u; i++) {}\n for (j = ticks.length; ticks[j - 1] > v; j--) {}\n ticks = ticks.slice(i, j);\n }\n return ticks;\n };\n scale.tickFormat = function(n, format) {\n if (!arguments.length) return d3_scale_logFormat;\n if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== \"function\") format = d3.format(format);\n var k = Math.max(1, base * n / scale.ticks().length);\n return function(d) {\n var i = d / pow(Math.round(log(d)));\n if (i * base < base - .5) i *= base;\n return i <= k ? format(d) : \"\";\n };\n };\n scale.copy = function() {\n return d3_scale_log(linear.copy(), base, positive, domain);\n };\n return d3_scale_linearRebind(scale, linear);\n }\n var d3_scale_logFormat = d3.format(\".0e\"), d3_scale_logNiceNegative = {\n floor: function(x) {\n return -Math.ceil(-x);\n },\n ceil: function(x) {\n return -Math.floor(-x);\n }\n };\n d3.scale.pow = function() {\n return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);\n };\n function d3_scale_pow(linear, exponent, domain) {\n var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);\n function scale(x) {\n return linear(powp(x));\n }\n scale.invert = function(x) {\n return powb(linear.invert(x));\n };\n scale.domain = function(x) {\n if (!arguments.length) return domain;\n linear.domain((domain = x.map(Number)).map(powp));\n return scale;\n };\n scale.ticks = function(m) {\n return d3_scale_linearTicks(domain, m);\n };\n scale.tickFormat = function(m, format) {\n return d3_scale_linearTickFormat(domain, m, format);\n };\n scale.nice = function(m) {\n return scale.domain(d3_scale_linearNice(domain, m));\n };\n scale.exponent = function(x) {\n if (!arguments.length) return exponent;\n powp = d3_scale_powPow(exponent = x);\n powb = d3_scale_powPow(1 / exponent);\n linear.domain(domain.map(powp));\n return scale;\n };\n scale.copy = function() {\n return d3_scale_pow(linear.copy(), exponent, domain);\n };\n return d3_scale_linearRebind(scale, linear);\n }\n function d3_scale_powPow(e) {\n return function(x) {\n return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);\n };\n }\n d3.scale.sqrt = function() {\n return d3.scale.pow().exponent(.5);\n };\n d3.scale.ordinal = function() {\n return d3_scale_ordinal([], {\n t: \"range\",\n a: [ [] ]\n });\n };\n function d3_scale_ordinal(domain, ranger) {\n var index, range, rangeBand;\n function scale(x) {\n return range[((index.get(x) || (ranger.t === \"range\" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];\n }\n function steps(start, step) {\n return d3.range(domain.length).map(function(i) {\n return start + step * i;\n });\n }\n scale.domain = function(x) {\n if (!arguments.length) return domain;\n domain = [];\n index = new d3_Map();\n var i = -1, n = x.length, xi;\n while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));\n return scale[ranger.t].apply(scale, ranger.a);\n };\n scale.range = function(x) {\n if (!arguments.length) return range;\n range = x;\n rangeBand = 0;\n ranger = {\n t: \"range\",\n a: arguments\n };\n return scale;\n };\n scale.rangePoints = function(x, padding) {\n if (arguments.length < 2) padding = 0;\n var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, \n 0) : (stop - start) / (domain.length - 1 + padding);\n range = steps(start + step * padding / 2, step);\n rangeBand = 0;\n ranger = {\n t: \"rangePoints\",\n a: arguments\n };\n return scale;\n };\n scale.rangeRoundPoints = function(x, padding) {\n if (arguments.length < 2) padding = 0;\n var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), \n 0) : (stop - start) / (domain.length - 1 + padding) | 0;\n range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);\n rangeBand = 0;\n ranger = {\n t: \"rangeRoundPoints\",\n a: arguments\n };\n return scale;\n };\n scale.rangeBands = function(x, padding, outerPadding) {\n if (arguments.length < 2) padding = 0;\n if (arguments.length < 3) outerPadding = padding;\n var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);\n range = steps(start + step * outerPadding, step);\n if (reverse) range.reverse();\n rangeBand = step * (1 - padding);\n ranger = {\n t: \"rangeBands\",\n a: arguments\n };\n return scale;\n };\n scale.rangeRoundBands = function(x, padding, outerPadding) {\n if (arguments.length < 2) padding = 0;\n if (arguments.length < 3) outerPadding = padding;\n var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));\n range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);\n if (reverse) range.reverse();\n rangeBand = Math.round(step * (1 - padding));\n ranger = {\n t: \"rangeRoundBands\",\n a: arguments\n };\n return scale;\n };\n scale.rangeBand = function() {\n return rangeBand;\n };\n scale.rangeExtent = function() {\n return d3_scaleExtent(ranger.a[0]);\n };\n scale.copy = function() {\n return d3_scale_ordinal(domain, ranger);\n };\n return scale.domain(domain);\n }\n d3.scale.category10 = function() {\n return d3.scale.ordinal().range(d3_category10);\n };\n d3.scale.category20 = function() {\n return d3.scale.ordinal().range(d3_category20);\n };\n d3.scale.category20b = function() {\n return d3.scale.ordinal().range(d3_category20b);\n };\n d3.scale.category20c = function() {\n return d3.scale.ordinal().range(d3_category20c);\n };\n var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);\n var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString);\n var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString);\n var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString);\n d3.scale.quantile = function() {\n return d3_scale_quantile([], []);\n };\n function d3_scale_quantile(domain, range) {\n var thresholds;\n function rescale() {\n var k = 0, q = range.length;\n thresholds = [];\n while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);\n return scale;\n }\n function scale(x) {\n if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];\n }\n scale.domain = function(x) {\n if (!arguments.length) return domain;\n domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);\n return rescale();\n };\n scale.range = function(x) {\n if (!arguments.length) return range;\n range = x;\n return rescale();\n };\n scale.quantiles = function() {\n return thresholds;\n };\n scale.invertExtent = function(y) {\n y = range.indexOf(y);\n return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];\n };\n scale.copy = function() {\n return d3_scale_quantile(domain, range);\n };\n return rescale();\n }\n d3.scale.quantize = function() {\n return d3_scale_quantize(0, 1, [ 0, 1 ]);\n };\n function d3_scale_quantize(x0, x1, range) {\n var kx, i;\n function scale(x) {\n return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];\n }\n function rescale() {\n kx = range.length / (x1 - x0);\n i = range.length - 1;\n return scale;\n }\n scale.domain = function(x) {\n if (!arguments.length) return [ x0, x1 ];\n x0 = +x[0];\n x1 = +x[x.length - 1];\n return rescale();\n };\n scale.range = function(x) {\n if (!arguments.length) return range;\n range = x;\n return rescale();\n };\n scale.invertExtent = function(y) {\n y = range.indexOf(y);\n y = y < 0 ? NaN : y / kx + x0;\n return [ y, y + 1 / kx ];\n };\n scale.copy = function() {\n return d3_scale_quantize(x0, x1, range);\n };\n return rescale();\n }\n d3.scale.threshold = function() {\n return d3_scale_threshold([ .5 ], [ 0, 1 ]);\n };\n function d3_scale_threshold(domain, range) {\n function scale(x) {\n if (x <= x) return range[d3.bisect(domain, x)];\n }\n scale.domain = function(_) {\n if (!arguments.length) return domain;\n domain = _;\n return scale;\n };\n scale.range = function(_) {\n if (!arguments.length) return range;\n range = _;\n return scale;\n };\n scale.invertExtent = function(y) {\n y = range.indexOf(y);\n return [ domain[y - 1], domain[y] ];\n };\n scale.copy = function() {\n return d3_scale_threshold(domain, range);\n };\n return scale;\n }\n d3.scale.identity = function() {\n return d3_scale_identity([ 0, 1 ]);\n };\n function d3_scale_identity(domain) {\n function identity(x) {\n return +x;\n }\n identity.invert = identity;\n identity.domain = identity.range = function(x) {\n if (!arguments.length) return domain;\n domain = x.map(identity);\n return identity;\n };\n identity.ticks = function(m) {\n return d3_scale_linearTicks(domain, m);\n };\n identity.tickFormat = function(m, format) {\n return d3_scale_linearTickFormat(domain, m, format);\n };\n identity.copy = function() {\n return d3_scale_identity(domain);\n };\n return identity;\n }\n d3.svg = {};\n function d3_zero() {\n return 0;\n }\n d3.svg.arc = function() {\n var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle;\n function arc() {\n var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - half\u03C0, a1 = endAngle.apply(this, arguments) - half\u03C0, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1;\n if (r1 < r0) rc = r1, r1 = r0, r0 = rc;\n if (da >= \u03C4\u03B5) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : \"\") + \"Z\";\n var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];\n if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {\n rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);\n if (!cw) p1 *= -1;\n if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));\n if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));\n }\n if (r1) {\n x0 = r1 * Math.cos(a0 + p1);\n y0 = r1 * Math.sin(a0 + p1);\n x1 = r1 * Math.cos(a1 - p1);\n y1 = r1 * Math.sin(a1 - p1);\n var l1 = Math.abs(a1 - a0 - 2 * p1) <= \u03C0 ? 0 : 1;\n if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {\n var h1 = (a0 + a1) / 2;\n x0 = r1 * Math.cos(h1);\n y0 = r1 * Math.sin(h1);\n x1 = y1 = null;\n }\n } else {\n x0 = y0 = 0;\n }\n if (r0) {\n x2 = r0 * Math.cos(a1 - p0);\n y2 = r0 * Math.sin(a1 - p0);\n x3 = r0 * Math.cos(a0 + p0);\n y3 = r0 * Math.sin(a0 + p0);\n var l0 = Math.abs(a0 - a1 + 2 * p0) <= \u03C0 ? 0 : 1;\n if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {\n var h0 = (a0 + a1) / 2;\n x2 = r0 * Math.cos(h0);\n y2 = r0 * Math.sin(h0);\n x3 = y3 = null;\n }\n } else {\n x2 = y2 = 0;\n }\n if (da > \u03B5 && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {\n cr = r0 < r1 ^ cw ? 0 : 1;\n var rc1 = rc, rc0 = rc;\n if (da < \u03C0) {\n var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);\n rc0 = Math.min(rc, (r0 - lc) / (kc - 1));\n rc1 = Math.min(rc, (r1 - lc) / (kc + 1));\n }\n if (x1 != null) {\n var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);\n if (rc === rc1) {\n path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t30[1], \"A\", r1, \",\", r1, \" 0 \", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), \",\", cw, \" \", t12[1], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t12[0]);\n } else {\n path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 1,\", cr, \" \", t12[0]);\n }\n } else {\n path.push(\"M\", x0, \",\", y0);\n }\n if (x3 != null) {\n var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);\n if (rc === rc0) {\n path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t21[1], \"A\", r0, \",\", r0, \" 0 \", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), \",\", 1 - cw, \" \", t03[1], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n } else {\n path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n }\n } else {\n path.push(\"L\", x2, \",\", y2);\n }\n } else {\n path.push(\"M\", x0, \",\", y0);\n if (x1 != null) path.push(\"A\", r1, \",\", r1, \" 0 \", l1, \",\", cw, \" \", x1, \",\", y1);\n path.push(\"L\", x2, \",\", y2);\n if (x3 != null) path.push(\"A\", r0, \",\", r0, \" 0 \", l0, \",\", 1 - cw, \" \", x3, \",\", y3);\n }\n path.push(\"Z\");\n return path.join(\"\");\n }\n function circleSegment(r1, cw) {\n return \"M0,\" + r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + -r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + r1;\n }\n arc.innerRadius = function(v) {\n if (!arguments.length) return innerRadius;\n innerRadius = d3_functor(v);\n return arc;\n };\n arc.outerRadius = function(v) {\n if (!arguments.length) return outerRadius;\n outerRadius = d3_functor(v);\n return arc;\n };\n arc.cornerRadius = function(v) {\n if (!arguments.length) return cornerRadius;\n cornerRadius = d3_functor(v);\n return arc;\n };\n arc.padRadius = function(v) {\n if (!arguments.length) return padRadius;\n padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);\n return arc;\n };\n arc.startAngle = function(v) {\n if (!arguments.length) return startAngle;\n startAngle = d3_functor(v);\n return arc;\n };\n arc.endAngle = function(v) {\n if (!arguments.length) return endAngle;\n endAngle = d3_functor(v);\n return arc;\n };\n arc.padAngle = function(v) {\n if (!arguments.length) return padAngle;\n padAngle = d3_functor(v);\n return arc;\n };\n arc.centroid = function() {\n var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - half\u03C0;\n return [ Math.cos(a) * r, Math.sin(a) * r ];\n };\n return arc;\n };\n var d3_svg_arcAuto = \"auto\";\n function d3_svg_arcInnerRadius(d) {\n return d.innerRadius;\n }\n function d3_svg_arcOuterRadius(d) {\n return d.outerRadius;\n }\n function d3_svg_arcStartAngle(d) {\n return d.startAngle;\n }\n function d3_svg_arcEndAngle(d) {\n return d.endAngle;\n }\n function d3_svg_arcPadAngle(d) {\n return d && d.padAngle;\n }\n function d3_svg_arcSweep(x0, y0, x1, y1) {\n return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;\n }\n function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {\n var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;\n if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;\n return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];\n }\n function d3_svg_line(projection) {\n var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;\n function line(data) {\n var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);\n function segment() {\n segments.push(\"M\", interpolate(projection(points), tension));\n }\n while (++i < n) {\n if (defined.call(this, d = data[i], i)) {\n points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);\n } else if (points.length) {\n segment();\n points = [];\n }\n }\n if (points.length) segment();\n return segments.length ? segments.join(\"\") : null;\n }\n line.x = function(_) {\n if (!arguments.length) return x;\n x = _;\n return line;\n };\n line.y = function(_) {\n if (!arguments.length) return y;\n y = _;\n return line;\n };\n line.defined = function(_) {\n if (!arguments.length) return defined;\n defined = _;\n return line;\n };\n line.interpolate = function(_) {\n if (!arguments.length) return interpolateKey;\n if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n return line;\n };\n line.tension = function(_) {\n if (!arguments.length) return tension;\n tension = _;\n return line;\n };\n return line;\n }\n d3.svg.line = function() {\n return d3_svg_line(d3_identity);\n };\n var d3_svg_lineInterpolators = d3.map({\n linear: d3_svg_lineLinear,\n \"linear-closed\": d3_svg_lineLinearClosed,\n step: d3_svg_lineStep,\n \"step-before\": d3_svg_lineStepBefore,\n \"step-after\": d3_svg_lineStepAfter,\n basis: d3_svg_lineBasis,\n \"basis-open\": d3_svg_lineBasisOpen,\n \"basis-closed\": d3_svg_lineBasisClosed,\n bundle: d3_svg_lineBundle,\n cardinal: d3_svg_lineCardinal,\n \"cardinal-open\": d3_svg_lineCardinalOpen,\n \"cardinal-closed\": d3_svg_lineCardinalClosed,\n monotone: d3_svg_lineMonotone\n });\n d3_svg_lineInterpolators.forEach(function(key, value) {\n value.key = key;\n value.closed = /-closed$/.test(key);\n });\n function d3_svg_lineLinear(points) {\n return points.length > 1 ? points.join(\"L\") : points + \"Z\";\n }\n function d3_svg_lineLinearClosed(points) {\n return points.join(\"L\") + \"Z\";\n }\n function d3_svg_lineStep(points) {\n var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n while (++i < n) path.push(\"H\", (p[0] + (p = points[i])[0]) / 2, \"V\", p[1]);\n if (n > 1) path.push(\"H\", p[0]);\n return path.join(\"\");\n }\n function d3_svg_lineStepBefore(points) {\n var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n while (++i < n) path.push(\"V\", (p = points[i])[1], \"H\", p[0]);\n return path.join(\"\");\n }\n function d3_svg_lineStepAfter(points) {\n var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n while (++i < n) path.push(\"H\", (p = points[i])[0], \"V\", p[1]);\n return path.join(\"\");\n }\n function d3_svg_lineCardinalOpen(points, tension) {\n return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));\n }\n function d3_svg_lineCardinalClosed(points, tension) {\n return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), \n points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));\n }\n function d3_svg_lineCardinal(points, tension) {\n return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));\n }\n function d3_svg_lineHermite(points, tangents) {\n if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {\n return d3_svg_lineLinear(points);\n }\n var quad = points.length != tangents.length, path = \"\", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;\n if (quad) {\n path += \"Q\" + (p[0] - t0[0] * 2 / 3) + \",\" + (p[1] - t0[1] * 2 / 3) + \",\" + p[0] + \",\" + p[1];\n p0 = points[1];\n pi = 2;\n }\n if (tangents.length > 1) {\n t = tangents[1];\n p = points[pi];\n pi++;\n path += \"C\" + (p0[0] + t0[0]) + \",\" + (p0[1] + t0[1]) + \",\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n for (var i = 2; i < tangents.length; i++, pi++) {\n p = points[pi];\n t = tangents[i];\n path += \"S\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n }\n }\n if (quad) {\n var lp = points[pi];\n path += \"Q\" + (p[0] + t[0] * 2 / 3) + \",\" + (p[1] + t[1] * 2 / 3) + \",\" + lp[0] + \",\" + lp[1];\n }\n return path;\n }\n function d3_svg_lineCardinalTangents(points, tension) {\n var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;\n while (++i < n) {\n p0 = p1;\n p1 = p2;\n p2 = points[i];\n tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);\n }\n return tangents;\n }\n function d3_svg_lineBasis(points) {\n if (points.length < 3) return d3_svg_lineLinear(points);\n var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, \",\", y0, \"L\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n points.push(points[n - 1]);\n while (++i <= n) {\n pi = points[i];\n px.shift();\n px.push(pi[0]);\n py.shift();\n py.push(pi[1]);\n d3_svg_lineBasisBezier(path, px, py);\n }\n points.pop();\n path.push(\"L\", pi);\n return path.join(\"\");\n }\n function d3_svg_lineBasisOpen(points) {\n if (points.length < 4) return d3_svg_lineLinear(points);\n var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];\n while (++i < 3) {\n pi = points[i];\n px.push(pi[0]);\n py.push(pi[1]);\n }\n path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + \",\" + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));\n --i;\n while (++i < n) {\n pi = points[i];\n px.shift();\n px.push(pi[0]);\n py.shift();\n py.push(pi[1]);\n d3_svg_lineBasisBezier(path, px, py);\n }\n return path.join(\"\");\n }\n function d3_svg_lineBasisClosed(points) {\n var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];\n while (++i < 4) {\n pi = points[i % n];\n px.push(pi[0]);\n py.push(pi[1]);\n }\n path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n --i;\n while (++i < m) {\n pi = points[i % n];\n px.shift();\n px.push(pi[0]);\n py.shift();\n py.push(pi[1]);\n d3_svg_lineBasisBezier(path, px, py);\n }\n return path.join(\"\");\n }\n function d3_svg_lineBundle(points, tension) {\n var n = points.length - 1;\n if (n) {\n var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;\n while (++i <= n) {\n p = points[i];\n t = i / n;\n p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);\n p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);\n }\n }\n return d3_svg_lineBasis(points);\n }\n function d3_svg_lineDot4(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n }\n var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ];\n function d3_svg_lineBasisBezier(path, x, y) {\n path.push(\"C\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));\n }\n function d3_svg_lineSlope(p0, p1) {\n return (p1[1] - p0[1]) / (p1[0] - p0[0]);\n }\n function d3_svg_lineFiniteDifferences(points) {\n var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);\n while (++i < j) {\n m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;\n }\n m[i] = d;\n return m;\n }\n function d3_svg_lineMonotoneTangents(points) {\n var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;\n while (++i < j) {\n d = d3_svg_lineSlope(points[i], points[i + 1]);\n if (abs(d) < \u03B5) {\n m[i] = m[i + 1] = 0;\n } else {\n a = m[i] / d;\n b = m[i + 1] / d;\n s = a * a + b * b;\n if (s > 9) {\n s = d * 3 / Math.sqrt(s);\n m[i] = s * a;\n m[i + 1] = s * b;\n }\n }\n }\n i = -1;\n while (++i <= j) {\n s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));\n tangents.push([ s || 0, m[i] * s || 0 ]);\n }\n return tangents;\n }\n function d3_svg_lineMonotone(points) {\n return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));\n }\n d3.svg.line.radial = function() {\n var line = d3_svg_line(d3_svg_lineRadial);\n line.radius = line.x, delete line.x;\n line.angle = line.y, delete line.y;\n return line;\n };\n function d3_svg_lineRadial(points) {\n var point, i = -1, n = points.length, r, a;\n while (++i < n) {\n point = points[i];\n r = point[0];\n a = point[1] - half\u03C0;\n point[0] = r * Math.cos(a);\n point[1] = r * Math.sin(a);\n }\n return points;\n }\n function d3_svg_area(projection) {\n var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = \"L\", tension = .7;\n function area(data) {\n var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {\n return x;\n } : d3_functor(x1), fy1 = y0 === y1 ? function() {\n return y;\n } : d3_functor(y1), x, y;\n function segment() {\n segments.push(\"M\", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), \"Z\");\n }\n while (++i < n) {\n if (defined.call(this, d = data[i], i)) {\n points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);\n points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);\n } else if (points0.length) {\n segment();\n points0 = [];\n points1 = [];\n }\n }\n if (points0.length) segment();\n return segments.length ? segments.join(\"\") : null;\n }\n area.x = function(_) {\n if (!arguments.length) return x1;\n x0 = x1 = _;\n return area;\n };\n area.x0 = function(_) {\n if (!arguments.length) return x0;\n x0 = _;\n return area;\n };\n area.x1 = function(_) {\n if (!arguments.length) return x1;\n x1 = _;\n return area;\n };\n area.y = function(_) {\n if (!arguments.length) return y1;\n y0 = y1 = _;\n return area;\n };\n area.y0 = function(_) {\n if (!arguments.length) return y0;\n y0 = _;\n return area;\n };\n area.y1 = function(_) {\n if (!arguments.length) return y1;\n y1 = _;\n return area;\n };\n area.defined = function(_) {\n if (!arguments.length) return defined;\n defined = _;\n return area;\n };\n area.interpolate = function(_) {\n if (!arguments.length) return interpolateKey;\n if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n interpolateReverse = interpolate.reverse || interpolate;\n L = interpolate.closed ? \"M\" : \"L\";\n return area;\n };\n area.tension = function(_) {\n if (!arguments.length) return tension;\n tension = _;\n return area;\n };\n return area;\n }\n d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;\n d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;\n d3.svg.area = function() {\n return d3_svg_area(d3_identity);\n };\n d3.svg.area.radial = function() {\n var area = d3_svg_area(d3_svg_lineRadial);\n area.radius = area.x, delete area.x;\n area.innerRadius = area.x0, delete area.x0;\n area.outerRadius = area.x1, delete area.x1;\n area.angle = area.y, delete area.y;\n area.startAngle = area.y0, delete area.y0;\n area.endAngle = area.y1, delete area.y1;\n return area;\n };\n d3.svg.chord = function() {\n var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;\n function chord(d, i) {\n var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);\n return \"M\" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + \"Z\";\n }\n function subgroup(self, f, d, i) {\n var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - half\u03C0, a1 = endAngle.call(self, subgroup, i) - half\u03C0;\n return {\n r: r,\n a0: a0,\n a1: a1,\n p0: [ r * Math.cos(a0), r * Math.sin(a0) ],\n p1: [ r * Math.cos(a1), r * Math.sin(a1) ]\n };\n }\n function equals(a, b) {\n return a.a0 == b.a0 && a.a1 == b.a1;\n }\n function arc(r, p, a) {\n return \"A\" + r + \",\" + r + \" 0 \" + +(a > \u03C0) + \",1 \" + p;\n }\n function curve(r0, p0, r1, p1) {\n return \"Q 0,0 \" + p1;\n }\n chord.radius = function(v) {\n if (!arguments.length) return radius;\n radius = d3_functor(v);\n return chord;\n };\n chord.source = function(v) {\n if (!arguments.length) return source;\n source = d3_functor(v);\n return chord;\n };\n chord.target = function(v) {\n if (!arguments.length) return target;\n target = d3_functor(v);\n return chord;\n };\n chord.startAngle = function(v) {\n if (!arguments.length) return startAngle;\n startAngle = d3_functor(v);\n return chord;\n };\n chord.endAngle = function(v) {\n if (!arguments.length) return endAngle;\n endAngle = d3_functor(v);\n return chord;\n };\n return chord;\n };\n function d3_svg_chordRadius(d) {\n return d.radius;\n }\n d3.svg.diagonal = function() {\n var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;\n function diagonal(d, i) {\n var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {\n x: p0.x,\n y: m\n }, {\n x: p3.x,\n y: m\n }, p3 ];\n p = p.map(projection);\n return \"M\" + p[0] + \"C\" + p[1] + \" \" + p[2] + \" \" + p[3];\n }\n diagonal.source = function(x) {\n if (!arguments.length) return source;\n source = d3_functor(x);\n return diagonal;\n };\n diagonal.target = function(x) {\n if (!arguments.length) return target;\n target = d3_functor(x);\n return diagonal;\n };\n diagonal.projection = function(x) {\n if (!arguments.length) return projection;\n projection = x;\n return diagonal;\n };\n return diagonal;\n };\n function d3_svg_diagonalProjection(d) {\n return [ d.x, d.y ];\n }\n d3.svg.diagonal.radial = function() {\n var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;\n diagonal.projection = function(x) {\n return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;\n };\n return diagonal;\n };\n function d3_svg_diagonalRadialProjection(projection) {\n return function() {\n var d = projection.apply(this, arguments), r = d[0], a = d[1] - half\u03C0;\n return [ r * Math.cos(a), r * Math.sin(a) ];\n };\n }\n d3.svg.symbol = function() {\n var type = d3_svg_symbolType, size = d3_svg_symbolSize;\n function symbol(d, i) {\n return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));\n }\n symbol.type = function(x) {\n if (!arguments.length) return type;\n type = d3_functor(x);\n return symbol;\n };\n symbol.size = function(x) {\n if (!arguments.length) return size;\n size = d3_functor(x);\n return symbol;\n };\n return symbol;\n };\n function d3_svg_symbolSize() {\n return 64;\n }\n function d3_svg_symbolType() {\n return \"circle\";\n }\n function d3_svg_symbolCircle(size) {\n var r = Math.sqrt(size / \u03C0);\n return \"M0,\" + r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + -r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + r + \"Z\";\n }\n var d3_svg_symbols = d3.map({\n circle: d3_svg_symbolCircle,\n cross: function(size) {\n var r = Math.sqrt(size / 5) / 2;\n return \"M\" + -3 * r + \",\" + -r + \"H\" + -r + \"V\" + -3 * r + \"H\" + r + \"V\" + -r + \"H\" + 3 * r + \"V\" + r + \"H\" + r + \"V\" + 3 * r + \"H\" + -r + \"V\" + r + \"H\" + -3 * r + \"Z\";\n },\n diamond: function(size) {\n var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;\n return \"M0,\" + -ry + \"L\" + rx + \",0\" + \" 0,\" + ry + \" \" + -rx + \",0\" + \"Z\";\n },\n square: function(size) {\n var r = Math.sqrt(size) / 2;\n return \"M\" + -r + \",\" + -r + \"L\" + r + \",\" + -r + \" \" + r + \",\" + r + \" \" + -r + \",\" + r + \"Z\";\n },\n \"triangle-down\": function(size) {\n var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n return \"M0,\" + ry + \"L\" + rx + \",\" + -ry + \" \" + -rx + \",\" + -ry + \"Z\";\n },\n \"triangle-up\": function(size) {\n var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n return \"M0,\" + -ry + \"L\" + rx + \",\" + ry + \" \" + -rx + \",\" + ry + \"Z\";\n }\n });\n d3.svg.symbolTypes = d3_svg_symbols.keys();\n var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);\n d3_selectionPrototype.transition = function(name) {\n var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {\n time: Date.now(),\n ease: d3_ease_cubicInOut,\n delay: 0,\n duration: 250\n };\n for (var j = -1, m = this.length; ++j < m; ) {\n subgroups.push(subgroup = []);\n for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);\n subgroup.push(node);\n }\n }\n return d3_transition(subgroups, ns, id);\n };\n d3_selectionPrototype.interrupt = function(name) {\n return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));\n };\n var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());\n function d3_selection_interruptNS(ns) {\n return function() {\n var lock, activeId, active;\n if ((lock = this[ns]) && (active = lock[activeId = lock.active])) {\n active.timer.c = null;\n active.timer.t = NaN;\n if (--lock.count) delete lock[activeId]; else delete this[ns];\n lock.active += .5;\n active.event && active.event.interrupt.call(this, this.__data__, active.index);\n }\n };\n }\n function d3_transition(groups, ns, id) {\n d3_subclass(groups, d3_transitionPrototype);\n groups.namespace = ns;\n groups.id = id;\n return groups;\n }\n var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;\n d3_transitionPrototype.call = d3_selectionPrototype.call;\n d3_transitionPrototype.empty = d3_selectionPrototype.empty;\n d3_transitionPrototype.node = d3_selectionPrototype.node;\n d3_transitionPrototype.size = d3_selectionPrototype.size;\n d3.transition = function(selection, name) {\n return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection);\n };\n d3.transition.prototype = d3_transitionPrototype;\n d3_transitionPrototype.select = function(selector) {\n var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;\n selector = d3_selection_selector(selector);\n for (var j = -1, m = this.length; ++j < m; ) {\n subgroups.push(subgroup = []);\n for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {\n if (\"__data__\" in node) subnode.__data__ = node.__data__;\n d3_transitionNode(subnode, i, ns, id, node[ns][id]);\n subgroup.push(subnode);\n } else {\n subgroup.push(null);\n }\n }\n }\n return d3_transition(subgroups, ns, id);\n };\n d3_transitionPrototype.selectAll = function(selector) {\n var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;\n selector = d3_selection_selectorAll(selector);\n for (var j = -1, m = this.length; ++j < m; ) {\n for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n if (node = group[i]) {\n transition = node[ns][id];\n subnodes = selector.call(node, node.__data__, i, j);\n subgroups.push(subgroup = []);\n for (var k = -1, o = subnodes.length; ++k < o; ) {\n if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);\n subgroup.push(subnode);\n }\n }\n }\n }\n return d3_transition(subgroups, ns, id);\n };\n d3_transitionPrototype.filter = function(filter) {\n var subgroups = [], subgroup, group, node;\n if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n for (var j = 0, m = this.length; j < m; j++) {\n subgroups.push(subgroup = []);\n for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n subgroup.push(node);\n }\n }\n }\n return d3_transition(subgroups, this.namespace, this.id);\n };\n d3_transitionPrototype.tween = function(name, tween) {\n var id = this.id, ns = this.namespace;\n if (arguments.length < 2) return this.node()[ns][id].tween.get(name);\n return d3_selection_each(this, tween == null ? function(node) {\n node[ns][id].tween.remove(name);\n } : function(node) {\n node[ns][id].tween.set(name, tween);\n });\n };\n function d3_transition_tween(groups, name, value, tween) {\n var id = groups.id, ns = groups.namespace;\n return d3_selection_each(groups, typeof value === \"function\" ? function(node, i, j) {\n node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));\n } : (value = tween(value), function(node) {\n node[ns][id].tween.set(name, value);\n }));\n }\n d3_transitionPrototype.attr = function(nameNS, value) {\n if (arguments.length < 2) {\n for (value in nameNS) this.attr(value, nameNS[value]);\n return this;\n }\n var interpolate = nameNS == \"transform\" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);\n function attrNull() {\n this.removeAttribute(name);\n }\n function attrNullNS() {\n this.removeAttributeNS(name.space, name.local);\n }\n function attrTween(b) {\n return b == null ? attrNull : (b += \"\", function() {\n var a = this.getAttribute(name), i;\n return a !== b && (i = interpolate(a, b), function(t) {\n this.setAttribute(name, i(t));\n });\n });\n }\n function attrTweenNS(b) {\n return b == null ? attrNullNS : (b += \"\", function() {\n var a = this.getAttributeNS(name.space, name.local), i;\n return a !== b && (i = interpolate(a, b), function(t) {\n this.setAttributeNS(name.space, name.local, i(t));\n });\n });\n }\n return d3_transition_tween(this, \"attr.\" + nameNS, value, name.local ? attrTweenNS : attrTween);\n };\n d3_transitionPrototype.attrTween = function(nameNS, tween) {\n var name = d3.ns.qualify(nameNS);\n function attrTween(d, i) {\n var f = tween.call(this, d, i, this.getAttribute(name));\n return f && function(t) {\n this.setAttribute(name, f(t));\n };\n }\n function attrTweenNS(d, i) {\n var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));\n return f && function(t) {\n this.setAttributeNS(name.space, name.local, f(t));\n };\n }\n return this.tween(\"attr.\" + nameNS, name.local ? attrTweenNS : attrTween);\n };\n d3_transitionPrototype.style = function(name, value, priority) {\n var n = arguments.length;\n if (n < 3) {\n if (typeof name !== \"string\") {\n if (n < 2) value = \"\";\n for (priority in name) this.style(priority, name[priority], value);\n return this;\n }\n priority = \"\";\n }\n function styleNull() {\n this.style.removeProperty(name);\n }\n function styleString(b) {\n return b == null ? styleNull : (b += \"\", function() {\n var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i;\n return a !== b && (i = d3_interpolate(a, b), function(t) {\n this.style.setProperty(name, i(t), priority);\n });\n });\n }\n return d3_transition_tween(this, \"style.\" + name, value, styleString);\n };\n d3_transitionPrototype.styleTween = function(name, tween, priority) {\n if (arguments.length < 3) priority = \"\";\n function styleTween(d, i) {\n var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));\n return f && function(t) {\n this.style.setProperty(name, f(t), priority);\n };\n }\n return this.tween(\"style.\" + name, styleTween);\n };\n d3_transitionPrototype.text = function(value) {\n return d3_transition_tween(this, \"text\", value, d3_transition_text);\n };\n function d3_transition_text(b) {\n if (b == null) b = \"\";\n return function() {\n this.textContent = b;\n };\n }\n d3_transitionPrototype.remove = function() {\n var ns = this.namespace;\n return this.each(\"end.transition\", function() {\n var p;\n if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);\n });\n };\n d3_transitionPrototype.ease = function(value) {\n var id = this.id, ns = this.namespace;\n if (arguments.length < 1) return this.node()[ns][id].ease;\n if (typeof value !== \"function\") value = d3.ease.apply(d3, arguments);\n return d3_selection_each(this, function(node) {\n node[ns][id].ease = value;\n });\n };\n d3_transitionPrototype.delay = function(value) {\n var id = this.id, ns = this.namespace;\n if (arguments.length < 1) return this.node()[ns][id].delay;\n return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n node[ns][id].delay = +value.call(node, node.__data__, i, j);\n } : (value = +value, function(node) {\n node[ns][id].delay = value;\n }));\n };\n d3_transitionPrototype.duration = function(value) {\n var id = this.id, ns = this.namespace;\n if (arguments.length < 1) return this.node()[ns][id].duration;\n return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));\n } : (value = Math.max(1, value), function(node) {\n node[ns][id].duration = value;\n }));\n };\n d3_transitionPrototype.each = function(type, listener) {\n var id = this.id, ns = this.namespace;\n if (arguments.length < 2) {\n var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;\n try {\n d3_transitionInheritId = id;\n d3_selection_each(this, function(node, i, j) {\n d3_transitionInherit = node[ns][id];\n type.call(node, node.__data__, i, j);\n });\n } finally {\n d3_transitionInherit = inherit;\n d3_transitionInheritId = inheritId;\n }\n } else {\n d3_selection_each(this, function(node) {\n var transition = node[ns][id];\n (transition.event || (transition.event = d3.dispatch(\"start\", \"end\", \"interrupt\"))).on(type, listener);\n });\n }\n return this;\n };\n d3_transitionPrototype.transition = function() {\n var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;\n for (var j = 0, m = this.length; j < m; j++) {\n subgroups.push(subgroup = []);\n for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n if (node = group[i]) {\n transition = node[ns][id0];\n d3_transitionNode(node, i, ns, id1, {\n time: transition.time,\n ease: transition.ease,\n delay: transition.delay + transition.duration,\n duration: transition.duration\n });\n }\n subgroup.push(node);\n }\n }\n return d3_transition(subgroups, ns, id1);\n };\n function d3_transitionNamespace(name) {\n return name == null ? \"__transition__\" : \"__transition_\" + name + \"__\";\n }\n function d3_transitionNode(node, i, ns, id, inherit) {\n var lock = node[ns] || (node[ns] = {\n active: 0,\n count: 0\n }), transition = lock[id], time, timer, duration, ease, tweens;\n function schedule(elapsed) {\n var delay = transition.delay;\n timer.t = delay + time;\n if (delay <= elapsed) return start(elapsed - delay);\n timer.c = start;\n }\n function start(elapsed) {\n var activeId = lock.active, active = lock[activeId];\n if (active) {\n active.timer.c = null;\n active.timer.t = NaN;\n --lock.count;\n delete lock[activeId];\n active.event && active.event.interrupt.call(node, node.__data__, active.index);\n }\n for (var cancelId in lock) {\n if (+cancelId < id) {\n var cancel = lock[cancelId];\n cancel.timer.c = null;\n cancel.timer.t = NaN;\n --lock.count;\n delete lock[cancelId];\n }\n }\n timer.c = tick;\n d3_timer(function() {\n if (timer.c && tick(elapsed || 1)) {\n timer.c = null;\n timer.t = NaN;\n }\n return 1;\n }, 0, time);\n lock.active = id;\n transition.event && transition.event.start.call(node, node.__data__, i);\n tweens = [];\n transition.tween.forEach(function(key, value) {\n if (value = value.call(node, node.__data__, i)) {\n tweens.push(value);\n }\n });\n ease = transition.ease;\n duration = transition.duration;\n }\n function tick(elapsed) {\n var t = elapsed / duration, e = ease(t), n = tweens.length;\n while (n > 0) {\n tweens[--n].call(node, e);\n }\n if (t >= 1) {\n transition.event && transition.event.end.call(node, node.__data__, i);\n if (--lock.count) delete lock[id]; else delete node[ns];\n return 1;\n }\n }\n if (!transition) {\n time = inherit.time;\n timer = d3_timer(schedule, 0, time);\n transition = lock[id] = {\n tween: new d3_Map(),\n time: time,\n timer: timer,\n delay: inherit.delay,\n duration: inherit.duration,\n ease: inherit.ease,\n index: i\n };\n inherit = null;\n ++lock.count;\n }\n }\n d3.svg.axis = function() {\n var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;\n function axis(g) {\n g.each(function() {\n var g = d3.select(this);\n var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();\n 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\", \u03B5), tickExit = d3.transition(tick.exit()).style(\"opacity\", \u03B5).remove(), tickUpdate = d3.transition(tick.order()).style(\"opacity\", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform;\n var range = d3_scaleRange(scale1), path = g.selectAll(\".domain\").data([ 0 ]), pathUpdate = (path.enter().append(\"path\").attr(\"class\", \"domain\"), \n d3.transition(path));\n tickEnter.append(\"line\");\n tickEnter.append(\"text\");\n 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;\n if (orient === \"bottom\" || orient === \"top\") {\n tickTransform = d3_svg_axisX, x1 = \"x\", y1 = \"y\", x2 = \"x2\", y2 = \"y2\";\n text.attr(\"dy\", sign < 0 ? \"0em\" : \".71em\").style(\"text-anchor\", \"middle\");\n pathUpdate.attr(\"d\", \"M\" + range[0] + \",\" + sign * outerTickSize + \"V0H\" + range[1] + \"V\" + sign * outerTickSize);\n } else {\n tickTransform = d3_svg_axisY, x1 = \"y\", y1 = \"x\", x2 = \"y2\", y2 = \"x2\";\n text.attr(\"dy\", \".32em\").style(\"text-anchor\", sign < 0 ? \"end\" : \"start\");\n pathUpdate.attr(\"d\", \"M\" + sign * outerTickSize + \",\" + range[0] + \"H0V\" + range[1] + \"H\" + sign * outerTickSize);\n }\n lineEnter.attr(y2, sign * innerTickSize);\n textEnter.attr(y1, sign * tickSpacing);\n lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);\n textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);\n if (scale1.rangeBand) {\n var x = scale1, dx = x.rangeBand() / 2;\n scale0 = scale1 = function(d) {\n return x(d) + dx;\n };\n } else if (scale0.rangeBand) {\n scale0 = scale1;\n } else {\n tickExit.call(tickTransform, scale1, scale0);\n }\n tickEnter.call(tickTransform, scale0, scale1);\n tickUpdate.call(tickTransform, scale1, scale1);\n });\n }\n axis.scale = function(x) {\n if (!arguments.length) return scale;\n scale = x;\n return axis;\n };\n axis.orient = function(x) {\n if (!arguments.length) return orient;\n orient = x in d3_svg_axisOrients ? x + \"\" : d3_svg_axisDefaultOrient;\n return axis;\n };\n axis.ticks = function() {\n if (!arguments.length) return tickArguments_;\n tickArguments_ = d3_array(arguments);\n return axis;\n };\n axis.tickValues = function(x) {\n if (!arguments.length) return tickValues;\n tickValues = x;\n return axis;\n };\n axis.tickFormat = function(x) {\n if (!arguments.length) return tickFormat_;\n tickFormat_ = x;\n return axis;\n };\n axis.tickSize = function(x) {\n var n = arguments.length;\n if (!n) return innerTickSize;\n innerTickSize = +x;\n outerTickSize = +arguments[n - 1];\n return axis;\n };\n axis.innerTickSize = function(x) {\n if (!arguments.length) return innerTickSize;\n innerTickSize = +x;\n return axis;\n };\n axis.outerTickSize = function(x) {\n if (!arguments.length) return outerTickSize;\n outerTickSize = +x;\n return axis;\n };\n axis.tickPadding = function(x) {\n if (!arguments.length) return tickPadding;\n tickPadding = +x;\n return axis;\n };\n axis.tickSubdivide = function() {\n return arguments.length && axis;\n };\n return axis;\n };\n var d3_svg_axisDefaultOrient = \"bottom\", d3_svg_axisOrients = {\n top: 1,\n right: 1,\n bottom: 1,\n left: 1\n };\n function d3_svg_axisX(selection, x0, x1) {\n selection.attr(\"transform\", function(d) {\n var v0 = x0(d);\n return \"translate(\" + (isFinite(v0) ? v0 : x1(d)) + \",0)\";\n });\n }\n function d3_svg_axisY(selection, y0, y1) {\n selection.attr(\"transform\", function(d) {\n var v0 = y0(d);\n return \"translate(0,\" + (isFinite(v0) ? v0 : y1(d)) + \")\";\n });\n }\n d3.svg.brush = function() {\n var event = d3_eventDispatch(brush, \"brushstart\", \"brush\", \"brushend\"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0];\n function brush(g) {\n g.each(function() {\n var g = d3.select(this).style(\"pointer-events\", \"all\").style(\"-webkit-tap-highlight-color\", \"rgba(0,0,0,0)\").on(\"mousedown.brush\", brushstart).on(\"touchstart.brush\", brushstart);\n var background = g.selectAll(\".background\").data([ 0 ]);\n background.enter().append(\"rect\").attr(\"class\", \"background\").style(\"visibility\", \"hidden\").style(\"cursor\", \"crosshair\");\n g.selectAll(\".extent\").data([ 0 ]).enter().append(\"rect\").attr(\"class\", \"extent\").style(\"cursor\", \"move\");\n var resize = g.selectAll(\".resize\").data(resizes, d3_identity);\n resize.exit().remove();\n resize.enter().append(\"g\").attr(\"class\", function(d) {\n return \"resize \" + d;\n }).style(\"cursor\", function(d) {\n return d3_svg_brushCursor[d];\n }).append(\"rect\").attr(\"x\", function(d) {\n return /[ew]$/.test(d) ? -3 : null;\n }).attr(\"y\", function(d) {\n return /^[ns]/.test(d) ? -3 : null;\n }).attr(\"width\", 6).attr(\"height\", 6).style(\"visibility\", \"hidden\");\n resize.style(\"display\", brush.empty() ? \"none\" : null);\n var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;\n if (x) {\n range = d3_scaleRange(x);\n backgroundUpdate.attr(\"x\", range[0]).attr(\"width\", range[1] - range[0]);\n redrawX(gUpdate);\n }\n if (y) {\n range = d3_scaleRange(y);\n backgroundUpdate.attr(\"y\", range[0]).attr(\"height\", range[1] - range[0]);\n redrawY(gUpdate);\n }\n redraw(gUpdate);\n });\n }\n brush.event = function(g) {\n g.each(function() {\n var event_ = event.of(this, arguments), extent1 = {\n x: xExtent,\n y: yExtent,\n i: xExtentDomain,\n j: yExtentDomain\n }, extent0 = this.__chart__ || extent1;\n this.__chart__ = extent1;\n if (d3_transitionInheritId) {\n d3.select(this).transition().each(\"start.brush\", function() {\n xExtentDomain = extent0.i;\n yExtentDomain = extent0.j;\n xExtent = extent0.x;\n yExtent = extent0.y;\n event_({\n type: \"brushstart\"\n });\n }).tween(\"brush:brush\", function() {\n var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);\n xExtentDomain = yExtentDomain = null;\n return function(t) {\n xExtent = extent1.x = xi(t);\n yExtent = extent1.y = yi(t);\n event_({\n type: \"brush\",\n mode: \"resize\"\n });\n };\n }).each(\"end.brush\", function() {\n xExtentDomain = extent1.i;\n yExtentDomain = extent1.j;\n event_({\n type: \"brush\",\n mode: \"resize\"\n });\n event_({\n type: \"brushend\"\n });\n });\n } else {\n event_({\n type: \"brushstart\"\n });\n event_({\n type: \"brush\",\n mode: \"resize\"\n });\n event_({\n type: \"brushend\"\n });\n }\n });\n };\n function redraw(g) {\n g.selectAll(\".resize\").attr(\"transform\", function(d) {\n return \"translate(\" + xExtent[+/e$/.test(d)] + \",\" + yExtent[+/^s/.test(d)] + \")\";\n });\n }\n function redrawX(g) {\n g.select(\".extent\").attr(\"x\", xExtent[0]);\n g.selectAll(\".extent,.n>rect,.s>rect\").attr(\"width\", xExtent[1] - xExtent[0]);\n }\n function redrawY(g) {\n g.select(\".extent\").attr(\"y\", yExtent[0]);\n g.selectAll(\".extent,.e>rect,.w>rect\").attr(\"height\", yExtent[1] - yExtent[0]);\n }\n function brushstart() {\n var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed(\"extent\"), dragRestore = d3_event_dragSuppress(target), center, origin = d3.mouse(target), offset;\n var w = d3.select(d3_window(target)).on(\"keydown.brush\", keydown).on(\"keyup.brush\", keyup);\n if (d3.event.changedTouches) {\n w.on(\"touchmove.brush\", brushmove).on(\"touchend.brush\", brushend);\n } else {\n w.on(\"mousemove.brush\", brushmove).on(\"mouseup.brush\", brushend);\n }\n g.interrupt().selectAll(\"*\").interrupt();\n if (dragging) {\n origin[0] = xExtent[0] - origin[0];\n origin[1] = yExtent[0] - origin[1];\n } else if (resizing) {\n var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);\n offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];\n origin[0] = xExtent[ex];\n origin[1] = yExtent[ey];\n } else if (d3.event.altKey) center = origin.slice();\n g.style(\"pointer-events\", \"none\").selectAll(\".resize\").style(\"display\", null);\n d3.select(\"body\").style(\"cursor\", eventTarget.style(\"cursor\"));\n event_({\n type: \"brushstart\"\n });\n brushmove();\n function keydown() {\n if (d3.event.keyCode == 32) {\n if (!dragging) {\n center = null;\n origin[0] -= xExtent[1];\n origin[1] -= yExtent[1];\n dragging = 2;\n }\n d3_eventPreventDefault();\n }\n }\n function keyup() {\n if (d3.event.keyCode == 32 && dragging == 2) {\n origin[0] += xExtent[1];\n origin[1] += yExtent[1];\n dragging = 0;\n d3_eventPreventDefault();\n }\n }\n function brushmove() {\n var point = d3.mouse(target), moved = false;\n if (offset) {\n point[0] += offset[0];\n point[1] += offset[1];\n }\n if (!dragging) {\n if (d3.event.altKey) {\n if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];\n origin[0] = xExtent[+(point[0] < center[0])];\n origin[1] = yExtent[+(point[1] < center[1])];\n } else center = null;\n }\n if (resizingX && move1(point, x, 0)) {\n redrawX(g);\n moved = true;\n }\n if (resizingY && move1(point, y, 1)) {\n redrawY(g);\n moved = true;\n }\n if (moved) {\n redraw(g);\n event_({\n type: \"brush\",\n mode: dragging ? \"move\" : \"resize\"\n });\n }\n }\n function move1(point, scale, i) {\n var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max;\n if (dragging) {\n r0 -= position;\n r1 -= size + position;\n }\n min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];\n if (dragging) {\n max = (min += position) + size;\n } else {\n if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));\n if (position < min) {\n max = min;\n min = position;\n } else {\n max = position;\n }\n }\n if (extent[0] != min || extent[1] != max) {\n if (i) yExtentDomain = null; else xExtentDomain = null;\n extent[0] = min;\n extent[1] = max;\n return true;\n }\n }\n function brushend() {\n brushmove();\n g.style(\"pointer-events\", \"all\").selectAll(\".resize\").style(\"display\", brush.empty() ? \"none\" : null);\n d3.select(\"body\").style(\"cursor\", null);\n w.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 dragRestore();\n event_({\n type: \"brushend\"\n });\n }\n }\n brush.x = function(z) {\n if (!arguments.length) return x;\n x = z;\n resizes = d3_svg_brushResizes[!x << 1 | !y];\n return brush;\n };\n brush.y = function(z) {\n if (!arguments.length) return y;\n y = z;\n resizes = d3_svg_brushResizes[!x << 1 | !y];\n return brush;\n };\n brush.clamp = function(z) {\n if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;\n if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;\n return brush;\n };\n brush.extent = function(z) {\n var x0, x1, y0, y1, t;\n if (!arguments.length) {\n if (x) {\n if (xExtentDomain) {\n x0 = xExtentDomain[0], x1 = xExtentDomain[1];\n } else {\n x0 = xExtent[0], x1 = xExtent[1];\n if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);\n if (x1 < x0) t = x0, x0 = x1, x1 = t;\n }\n }\n if (y) {\n if (yExtentDomain) {\n y0 = yExtentDomain[0], y1 = yExtentDomain[1];\n } else {\n y0 = yExtent[0], y1 = yExtent[1];\n if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);\n if (y1 < y0) t = y0, y0 = y1, y1 = t;\n }\n }\n return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];\n }\n if (x) {\n x0 = z[0], x1 = z[1];\n if (y) x0 = x0[0], x1 = x1[0];\n xExtentDomain = [ x0, x1 ];\n if (x.invert) x0 = x(x0), x1 = x(x1);\n if (x1 < x0) t = x0, x0 = x1, x1 = t;\n if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];\n }\n if (y) {\n y0 = z[0], y1 = z[1];\n if (x) y0 = y0[1], y1 = y1[1];\n yExtentDomain = [ y0, y1 ];\n if (y.invert) y0 = y(y0), y1 = y(y1);\n if (y1 < y0) t = y0, y0 = y1, y1 = t;\n if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];\n }\n return brush;\n };\n brush.clear = function() {\n if (!brush.empty()) {\n xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];\n xExtentDomain = yExtentDomain = null;\n }\n return brush;\n };\n brush.empty = function() {\n return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];\n };\n return d3.rebind(brush, event, \"on\");\n };\n var d3_svg_brushCursor = {\n n: \"ns-resize\",\n e: \"ew-resize\",\n s: \"ns-resize\",\n w: \"ew-resize\",\n nw: \"nwse-resize\",\n ne: \"nesw-resize\",\n se: \"nwse-resize\",\n sw: \"nesw-resize\"\n };\n var d3_svg_brushResizes = [ [ \"n\", \"e\", \"s\", \"w\", \"nw\", \"ne\", \"se\", \"sw\" ], [ \"e\", \"w\" ], [ \"n\", \"s\" ], [] ];\n var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;\n var d3_time_formatUtc = d3_time_format.utc;\n var d3_time_formatIso = d3_time_formatUtc(\"%Y-%m-%dT%H:%M:%S.%LZ\");\n d3_time_format.iso = Date.prototype.toISOString && +new Date(\"2000-01-01T00:00:00.000Z\") ? d3_time_formatIsoNative : d3_time_formatIso;\n function d3_time_formatIsoNative(date) {\n return date.toISOString();\n }\n d3_time_formatIsoNative.parse = function(string) {\n var date = new Date(string);\n return isNaN(date) ? null : date;\n };\n d3_time_formatIsoNative.toString = d3_time_formatIso.toString;\n d3_time.second = d3_time_interval(function(date) {\n return new d3_date(Math.floor(date / 1e3) * 1e3);\n }, function(date, offset) {\n date.setTime(date.getTime() + Math.floor(offset) * 1e3);\n }, function(date) {\n return date.getSeconds();\n });\n d3_time.seconds = d3_time.second.range;\n d3_time.seconds.utc = d3_time.second.utc.range;\n d3_time.minute = d3_time_interval(function(date) {\n return new d3_date(Math.floor(date / 6e4) * 6e4);\n }, function(date, offset) {\n date.setTime(date.getTime() + Math.floor(offset) * 6e4);\n }, function(date) {\n return date.getMinutes();\n });\n d3_time.minutes = d3_time.minute.range;\n d3_time.minutes.utc = d3_time.minute.utc.range;\n d3_time.hour = d3_time_interval(function(date) {\n var timezone = date.getTimezoneOffset() / 60;\n return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);\n }, function(date, offset) {\n date.setTime(date.getTime() + Math.floor(offset) * 36e5);\n }, function(date) {\n return date.getHours();\n });\n d3_time.hours = d3_time.hour.range;\n d3_time.hours.utc = d3_time.hour.utc.range;\n d3_time.month = d3_time_interval(function(date) {\n date = d3_time.day(date);\n date.setDate(1);\n return date;\n }, function(date, offset) {\n date.setMonth(date.getMonth() + offset);\n }, function(date) {\n return date.getMonth();\n });\n d3_time.months = d3_time.month.range;\n d3_time.months.utc = d3_time.month.utc.range;\n function d3_time_scale(linear, methods, format) {\n function scale(x) {\n return linear(x);\n }\n scale.invert = function(x) {\n return d3_time_scaleDate(linear.invert(x));\n };\n scale.domain = function(x) {\n if (!arguments.length) return linear.domain().map(d3_time_scaleDate);\n linear.domain(x);\n return scale;\n };\n function tickMethod(extent, count) {\n var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);\n return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {\n return d / 31536e6;\n }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];\n }\n scale.nice = function(interval, skip) {\n var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" && tickMethod(extent, interval);\n if (method) interval = method[0], skip = method[1];\n function skipped(date) {\n return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;\n }\n return scale.domain(d3_scale_nice(domain, skip > 1 ? {\n floor: function(date) {\n while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);\n return date;\n },\n ceil: function(date) {\n while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);\n return date;\n }\n } : interval));\n };\n scale.ticks = function(interval, skip) {\n var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" ? tickMethod(extent, interval) : !interval.range && [ {\n range: interval\n }, skip ];\n if (method) interval = method[0], skip = method[1];\n return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);\n };\n scale.tickFormat = function() {\n return format;\n };\n scale.copy = function() {\n return d3_time_scale(linear.copy(), methods, format);\n };\n return d3_scale_linearRebind(scale, linear);\n }\n function d3_time_scaleDate(t) {\n return new Date(t);\n }\n var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];\n var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ];\n var d3_time_scaleLocalFormat = d3_time_format.multi([ [ \".%L\", function(d) {\n return d.getMilliseconds();\n } ], [ \":%S\", function(d) {\n return d.getSeconds();\n } ], [ \"%I:%M\", function(d) {\n return d.getMinutes();\n } ], [ \"%I %p\", function(d) {\n return d.getHours();\n } ], [ \"%a %d\", function(d) {\n return d.getDay() && d.getDate() != 1;\n } ], [ \"%b %d\", function(d) {\n return d.getDate() != 1;\n } ], [ \"%B\", function(d) {\n return d.getMonth();\n } ], [ \"%Y\", d3_true ] ]);\n var d3_time_scaleMilliseconds = {\n range: function(start, stop, step) {\n return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);\n },\n floor: d3_identity,\n ceil: d3_identity\n };\n d3_time_scaleLocalMethods.year = d3_time.year;\n d3_time.scale = function() {\n return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);\n };\n var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {\n return [ m[0].utc, m[1] ];\n });\n var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ \".%L\", function(d) {\n return d.getUTCMilliseconds();\n } ], [ \":%S\", function(d) {\n return d.getUTCSeconds();\n } ], [ \"%I:%M\", function(d) {\n return d.getUTCMinutes();\n } ], [ \"%I %p\", function(d) {\n return d.getUTCHours();\n } ], [ \"%a %d\", function(d) {\n return d.getUTCDay() && d.getUTCDate() != 1;\n } ], [ \"%b %d\", function(d) {\n return d.getUTCDate() != 1;\n } ], [ \"%B\", function(d) {\n return d.getUTCMonth();\n } ], [ \"%Y\", d3_true ] ]);\n d3_time_scaleUtcMethods.year = d3_time.year.utc;\n d3_time.scale.utc = function() {\n return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);\n };\n d3.text = d3_xhrType(function(request) {\n return request.responseText;\n });\n d3.json = function(url, callback) {\n return d3_xhr(url, \"application/json\", d3_json, callback);\n };\n function d3_json(request) {\n return JSON.parse(request.responseText);\n }\n d3.html = function(url, callback) {\n return d3_xhr(url, \"text/html\", d3_html, callback);\n };\n function d3_html(request) {\n var range = d3_document.createRange();\n range.selectNode(d3_document.body);\n return range.createContextualFragment(request.responseText);\n }\n d3.xml = d3_xhrType(function(request) {\n return request.responseXML;\n });\n if (typeof define === \"function\" && define.amd) this.d3 = d3, define(d3); else if (typeof module === \"object\" && module.exports) module.exports = d3; else this.d3 = d3;\n}();", "\n// set up main nv object\nvar nv = {};\n\n// the major global objects under the nv namespace\nnv.dev = false; //set false when in production\nnv.tooltip = nv.tooltip || {}; // For the tooltip system\nnv.utils = nv.utils || {}; // Utility subsystem\nnv.models = nv.models || {}; //stores all the possible models/components\nnv.charts = {}; //stores all the ready to use charts\nnv.logs = {}; //stores some statistics and potential error messages\nnv.dom = {}; //DOM manipulation functions\n\n// Node/CommonJS - require D3\nif (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined' && typeof(d3) == 'undefined') {\n d3 = require('d3');\n}\n\nnv.dispatch = d3.dispatch('render_start', 'render_end');\n\n// Function bind polyfill\n// Needed ONLY for phantomJS as it's missing until version 2.0 which is unreleased as of this comment\n// https://github.com/ariya/phantomjs/issues/10522\n// http://kangax.github.io/compat-table/es5/#Function.prototype.bind\n// phantomJS is used for running the test suite\nif (!Function.prototype.bind) {\n Function.prototype.bind = function (oThis) {\n if (typeof this !== \"function\") {\n // closest thing possible to the ECMAScript 5 internal IsCallable function\n throw new TypeError(\"Function.prototype.bind - what is trying to be bound is not callable\");\n }\n\n var aArgs = Array.prototype.slice.call(arguments, 1),\n fToBind = this,\n fNOP = function () {},\n fBound = function () {\n return fToBind.apply(this instanceof fNOP && oThis\n ? this\n : oThis,\n aArgs.concat(Array.prototype.slice.call(arguments)));\n };\n\n fNOP.prototype = this.prototype;\n fBound.prototype = new fNOP();\n return fBound;\n };\n}\n\n// Development render timers - disabled if dev = false\nif (nv.dev) {\n nv.dispatch.on('render_start', function(e) {\n nv.logs.startTime = +new Date();\n });\n\n nv.dispatch.on('render_end', function(e) {\n nv.logs.endTime = +new Date();\n nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime;\n nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times\n });\n}\n\n// Logs all arguments, and returns the last so you can test things in place\n// Note: in IE8 console.log is an object not a function, and if modernizr is used\n// then calling Function.prototype.bind with with anything other than a function\n// causes a TypeError to be thrown.\nnv.log = function() {\n if (nv.dev && window.console && console.log && console.log.apply)\n console.log.apply(console, arguments);\n else if (nv.dev && window.console && typeof console.log == \"function\" && Function.prototype.bind) {\n var log = Function.prototype.bind.call(console.log, console);\n log.apply(console, arguments);\n }\n return arguments[arguments.length - 1];\n};\n\n// print console warning, should be used by deprecated functions\nnv.deprecated = function(name, info) {\n if (console && console.warn) {\n console.warn('nvd3 warning: `' + name + '` has been deprecated. ', info || '');\n }\n};\n\n// The nv.render function is used to queue up chart rendering\n// in non-blocking async functions.\n// When all queued charts are done rendering, nv.dispatch.render_end is invoked.\nnv.render = function render(step) {\n // number of graphs to generate in each timeout loop\n step = step || 1;\n\n nv.render.active = true;\n nv.dispatch.render_start();\n\n var renderLoop = function() {\n var chart, graph;\n\n for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) {\n chart = graph.generate();\n if (typeof graph.callback == typeof(Function)) graph.callback(chart);\n }\n\n nv.render.queue.splice(0, i);\n\n if (nv.render.queue.length) {\n setTimeout(renderLoop);\n }\n else {\n nv.dispatch.render_end();\n nv.render.active = false;\n }\n };\n\n setTimeout(renderLoop);\n};\n\nnv.render.active = false;\nnv.render.queue = [];\n\n/*\nAdds a chart to the async rendering queue. This method can take arguments in two forms:\nnv.addGraph({\n generate: \n callback: \n})\n\nor\n\nnv.addGraph(, )\n\nThe generate function should contain code that creates the NVD3 model, sets options\non it, adds data to an SVG element, and invokes the chart model. The generate function\nshould return the chart model. See examples/lineChart.html for a usage example.\n\nThe callback function is optional, and it is called when the generate function completes.\n*/\nnv.addGraph = function(obj) {\n if (typeof arguments[0] === typeof(Function)) {\n obj = {generate: arguments[0], callback: arguments[1]};\n }\n\n nv.render.queue.push(obj);\n\n if (!nv.render.active) {\n nv.render();\n }\n};\n\n// Node/CommonJS exports\nif (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') {\n module.exports = nv;\n}\n\nif (typeof(window) !== 'undefined') {\n window.nv = nv;\n}\n", "/* Facade for queueing DOM write operations\r\n * with Fastdom (https://github.com/wilsonpage/fastdom)\r\n * if available.\r\n * This could easily be extended to support alternate\r\n * implementations in the future.\r\n */\r\nnv.dom.write = function(callback) {\r\n\tif (window.fastdom !== undefined) {\r\n\t\treturn fastdom.mutate(callback);\r\n\t}\r\n\treturn callback();\r\n};\r\n\r\n/* Facade for queueing DOM read operations\r\n * with Fastdom (https://github.com/wilsonpage/fastdom)\r\n * if available.\r\n * This could easily be extended to support alternate\r\n * implementations in the future.\r\n */\r\nnv.dom.read = function(callback) {\r\n\tif (window.fastdom !== undefined) {\r\n\t\treturn fastdom.measure(callback);\r\n\t}\r\n\treturn callback();\r\n};\r\n", "/* Utility class to handle creation of an interactive layer.\n This places a rectangle on top of the chart. When you mouse move over it, it sends a dispatch\n containing the X-coordinate. It can also render a vertical line where the mouse is located.\n\n dispatch.elementMousemove is the important event to latch onto. It is fired whenever the mouse moves over\n the rectangle. The dispatch is given one object which contains the mouseX/Y location.\n It also has 'pointXValue', which is the conversion of mouseX to the x-axis scale.\n */\nnv.interactiveGuideline = function() {\n \"use strict\";\n\n var margin = { left: 0, top: 0 } //Pass the chart's top and left magins. Used to calculate the mouseX/Y.\n , width = null\n , height = null\n , xScale = d3.scale.linear()\n , dispatch = d3.dispatch('elementMousemove', 'elementMouseout', 'elementClick', 'elementDblclick', 'elementMouseDown', 'elementMouseUp')\n , showGuideLine = true\n , svgContainer = null // Must pass the chart's svg, we'll use its mousemove event.\n , tooltip = nv.models.tooltip()\n , isMSIE = window.ActiveXObject// Checkt if IE by looking for activeX. (excludes IE11)\n ;\n\n tooltip\n .duration(0)\n .hideDelay(0)\n .hidden(false);\n\n function layer(selection) {\n selection.each(function(data) {\n var container = d3.select(this);\n var availableWidth = (width || 960), availableHeight = (height || 400);\n var wrap = container.selectAll(\"g.nv-wrap.nv-interactiveLineLayer\")\n .data([data]);\n var wrapEnter = wrap.enter()\n .append(\"g\").attr(\"class\", \" nv-wrap nv-interactiveLineLayer\");\n wrapEnter.append(\"g\").attr(\"class\",\"nv-interactiveGuideLine\");\n\n if (!svgContainer) {\n return;\n }\n\n function mouseHandler() {\n var mouseX = d3.event.clientX - this.getBoundingClientRect().left;\n var mouseY = d3.event.clientY - this.getBoundingClientRect().top;\n\n var subtractMargin = true;\n var mouseOutAnyReason = false;\n if (isMSIE) {\n /*\n D3.js (or maybe SVG.getScreenCTM) has a nasty bug in Internet Explorer 10.\n d3.mouse() returns incorrect X,Y mouse coordinates when mouse moving\n over a rect in IE 10.\n However, d3.event.offsetX/Y also returns the mouse coordinates\n relative to the triggering . So we use offsetX/Y on IE.\n */\n mouseX = d3.event.offsetX;\n mouseY = d3.event.offsetY;\n\n /*\n On IE, if you attach a mouse event listener to the container,\n it will actually trigger it for all the child elements (like , , etc).\n When this happens on IE, the offsetX/Y is set to where ever the child element\n is located.\n As a result, we do NOT need to subtract margins to figure out the mouse X/Y\n position under this scenario. Removing the line below *will* cause\n the interactive layer to not work right on IE.\n */\n if(d3.event.target.tagName !== \"svg\") {\n subtractMargin = false;\n }\n\n if (d3.event.target.className.baseVal.match(\"nv-legend\")) {\n mouseOutAnyReason = true;\n }\n\n }\n\n if(subtractMargin) {\n mouseX -= margin.left;\n mouseY -= margin.top;\n }\n\n /* If mouseX/Y is outside of the chart's bounds,\n trigger a mouseOut event.\n */\n if (d3.event.type === 'mouseout'\n || mouseX < 0 || mouseY < 0\n || mouseX > availableWidth || mouseY > availableHeight\n || (d3.event.relatedTarget && d3.event.relatedTarget.ownerSVGElement === undefined)\n || mouseOutAnyReason\n ) {\n\n if (isMSIE) {\n if (d3.event.relatedTarget\n && d3.event.relatedTarget.ownerSVGElement === undefined\n && (d3.event.relatedTarget.className === undefined\n || d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass))) {\n\n return;\n }\n }\n dispatch.elementMouseout({\n mouseX: mouseX,\n mouseY: mouseY\n });\n layer.renderGuideLine(null); //hide the guideline\n tooltip.hidden(true);\n return;\n } else {\n tooltip.hidden(false);\n }\n\n\n var scaleIsOrdinal = typeof xScale.rangeBands === 'function';\n var pointXValue = undefined;\n\n // Ordinal scale has no invert method\n if (scaleIsOrdinal) {\n var elementIndex = d3.bisect(xScale.range(), mouseX) - 1;\n // Check if mouseX is in the range band\n if (xScale.range()[elementIndex] + xScale.rangeBand() >= mouseX) {\n pointXValue = xScale.domain()[d3.bisect(xScale.range(), mouseX) - 1];\n }\n else {\n dispatch.elementMouseout({\n mouseX: mouseX,\n mouseY: mouseY\n });\n layer.renderGuideLine(null); //hide the guideline\n tooltip.hidden(true);\n return;\n }\n }\n else {\n pointXValue = xScale.invert(mouseX);\n }\n\n dispatch.elementMousemove({\n mouseX: mouseX,\n mouseY: mouseY,\n pointXValue: pointXValue\n });\n\n //If user double clicks the layer, fire a elementDblclick\n if (d3.event.type === \"dblclick\") {\n dispatch.elementDblclick({\n mouseX: mouseX,\n mouseY: mouseY,\n pointXValue: pointXValue\n });\n }\n\n // if user single clicks the layer, fire elementClick\n if (d3.event.type === 'click') {\n dispatch.elementClick({\n mouseX: mouseX,\n mouseY: mouseY,\n pointXValue: pointXValue\n });\n }\n\n // if user presses mouse down the layer, fire elementMouseDown\n if (d3.event.type === 'mousedown') {\n \tdispatch.elementMouseDown({\n \t\tmouseX: mouseX,\n \t\tmouseY: mouseY,\n \t\tpointXValue: pointXValue\n \t});\n }\n\n // if user presses mouse down the layer, fire elementMouseUp\n if (d3.event.type === 'mouseup') {\n \tdispatch.elementMouseUp({\n \t\tmouseX: mouseX,\n \t\tmouseY: mouseY,\n \t\tpointXValue: pointXValue\n \t});\n }\n }\n\n svgContainer\n .on(\"touchmove\",mouseHandler)\n .on(\"mousemove\",mouseHandler, true)\n .on(\"mouseout\" ,mouseHandler,true)\n .on(\"mousedown\" ,mouseHandler,true)\n .on(\"mouseup\" ,mouseHandler,true)\n .on(\"dblclick\" ,mouseHandler)\n .on(\"click\", mouseHandler)\n ;\n\n layer.guideLine = null;\n //Draws a vertical guideline at the given X postion.\n layer.renderGuideLine = function(x) {\n if (!showGuideLine) return;\n if (layer.guideLine && layer.guideLine.attr(\"x1\") === x) return;\n nv.dom.write(function() {\n var line = wrap.select(\".nv-interactiveGuideLine\")\n .selectAll(\"line\")\n .data((x != null) ? [nv.utils.NaNtoZero(x)] : [], String);\n line.enter()\n .append(\"line\")\n .attr(\"class\", \"nv-guideline\")\n .attr(\"x1\", function(d) { return d;})\n .attr(\"x2\", function(d) { return d;})\n .attr(\"y1\", availableHeight)\n .attr(\"y2\",0);\n line.exit().remove();\n });\n }\n });\n }\n\n layer.dispatch = dispatch;\n layer.tooltip = tooltip;\n\n layer.margin = function(_) {\n if (!arguments.length) return margin;\n margin.top = typeof _.top != 'undefined' ? _.top : margin.top;\n margin.left = typeof _.left != 'undefined' ? _.left : margin.left;\n return layer;\n };\n\n layer.width = function(_) {\n if (!arguments.length) return width;\n width = _;\n return layer;\n };\n\n layer.height = function(_) {\n if (!arguments.length) return height;\n height = _;\n return layer;\n };\n\n layer.xScale = function(_) {\n if (!arguments.length) return xScale;\n xScale = _;\n return layer;\n };\n\n layer.showGuideLine = function(_) {\n if (!arguments.length) return showGuideLine;\n showGuideLine = _;\n return layer;\n };\n\n layer.svgContainer = function(_) {\n if (!arguments.length) return svgContainer;\n svgContainer = _;\n return layer;\n };\n\n return layer;\n};\n\n/* Utility class that uses d3.bisect to find the index in a given array, where a search value can be inserted.\n This is different from normal bisectLeft; this function finds the nearest index to insert the search value.\n\n For instance, lets say your array is [1,2,3,5,10,30], and you search for 28.\n Normal d3.bisectLeft will return 4, because 28 is inserted after the number 10. But interactiveBisect will return 5\n because 28 is closer to 30 than 10.\n\n Unit tests can be found in: interactiveBisectTest.html\n\n Has the following known issues:\n * Will not work if the data points move backwards (ie, 10,9,8,7, etc) or if the data points are in random order.\n * Won't work if there are duplicate x coordinate values.\n */\nnv.interactiveBisect = function (values, searchVal, xAccessor) {\n \"use strict\";\n if (! (values instanceof Array)) {\n return null;\n }\n var _xAccessor;\n if (typeof xAccessor !== 'function') {\n _xAccessor = function(d) {\n return d.x;\n }\n } else {\n _xAccessor = xAccessor;\n }\n var _cmp = function(d, v) {\n // Accessors are no longer passed the index of the element along with\n // the element itself when invoked by d3.bisector.\n //\n // Starting at D3 v3.4.4, d3.bisector() started inspecting the\n // function passed to determine if it should consider it an accessor\n // or a comparator. This meant that accessors that take two arguments\n // (expecting an index as the second parameter) are treated as\n // comparators where the second argument is the search value against\n // which the first argument is compared.\n return _xAccessor(d) - v;\n };\n\n var bisect = d3.bisector(_cmp).left;\n var index = d3.max([0, bisect(values,searchVal) - 1]);\n var currentValue = _xAccessor(values[index]);\n\n if (typeof currentValue === 'undefined') {\n currentValue = index;\n }\n\n if (currentValue === searchVal) {\n return index; //found exact match\n }\n\n var nextIndex = d3.min([index+1, values.length - 1]);\n var nextValue = _xAccessor(values[nextIndex]);\n\n if (typeof nextValue === 'undefined') {\n nextValue = nextIndex;\n }\n\n if (Math.abs(nextValue - searchVal) >= Math.abs(currentValue - searchVal)) {\n return index;\n } else {\n return nextIndex\n }\n};\n\n/*\n Returns the index in the array \"values\" that is closest to searchVal.\n Only returns an index if searchVal is within some \"threshold\".\n Otherwise, returns null.\n */\nnv.nearestValueIndex = function (values, searchVal, threshold) {\n \"use strict\";\n var yDistMax = Infinity, indexToHighlight = null;\n values.forEach(function(d,i) {\n var delta = Math.abs(searchVal - d);\n if ( d != null && delta <= yDistMax && delta < threshold) {\n yDistMax = delta;\n indexToHighlight = i;\n }\n });\n return indexToHighlight;\n};\n", "\n/* Model which can be instantiated to handle tooltip rendering.\n Example usage:\n var tip = nv.models.tooltip().gravity('w').distance(23)\n .data(myDataObject);\n\n tip(); //just invoke the returned function to render tooltip.\n */\nnv.models.tooltip = function() {\n \"use strict\";\n\n /*\n Tooltip data. If data is given in the proper format, a consistent tooltip is generated.\n Example Format of data:\n {\n key: \"Date\",\n value: \"August 2009\",\n series: [\n {key: \"Series 1\", value: \"Value 1\", color: \"#000\"},\n {key: \"Series 2\", value: \"Value 2\", color: \"#00f\"}\n ]\n }\n */\n var id = \"nvtooltip-\" + Math.floor(Math.random() * 100000) // Generates a unique id when you create a new tooltip() object.\n , data = null\n , gravity = 'w' // Can be 'n','s','e','w'. Determines how tooltip is positioned.\n , distance = 25 // Distance to offset tooltip from the mouse location.\n , snapDistance = 0 // Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect)\n , classes = null // Attaches additional CSS classes to the tooltip DIV that is created.\n , hidden = true // Start off hidden, toggle with hide/show functions below.\n , hideDelay = 200 // Delay (in ms) before the tooltip hides after calling hide().\n , tooltip = null // d3 select of the tooltip div.\n , lastPosition = { left: null, top: null } // Last position the tooltip was in.\n , enabled = true // True -> tooltips are rendered. False -> don't render tooltips.\n , duration = 100 // Tooltip movement duration, in ms.\n , headerEnabled = true // If is to show the tooltip header.\n , nvPointerEventsClass = \"nv-pointer-events-none\" // CSS class to specify whether element should not have mouse events.\n ;\n\n // Format function for the tooltip values column.\n // d is value,\n // i is series index\n // p is point containing the value\n var valueFormatter = function(d, i, p) {\n return d;\n };\n\n // Format function for the tooltip header value.\n var headerFormatter = function(d) {\n return d;\n };\n\n var keyFormatter = function(d, i) {\n return d;\n };\n\n // By default, the tooltip model renders a beautiful table inside a DIV, returned as HTML\n // You can override this function if a custom tooltip is desired. For instance, you could directly manipulate\n // the DOM by accessing elem and returning false.\n var contentGenerator = function(d, elem) {\n if (d === null) {\n return '';\n }\n\n var table = d3.select(document.createElement(\"table\"));\n if (headerEnabled) {\n var theadEnter = table.selectAll(\"thead\")\n .data([d])\n .enter().append(\"thead\");\n\n theadEnter.append(\"tr\")\n .append(\"td\")\n .attr(\"colspan\", 3)\n .append(\"strong\")\n .classed(\"x-value\", true)\n .html(headerFormatter(d.value));\n }\n\n var tbodyEnter = table.selectAll(\"tbody\")\n .data([d])\n .enter().append(\"tbody\");\n\n var trowEnter = tbodyEnter.selectAll(\"tr\")\n .data(function(p) { return p.series})\n .enter()\n .append(\"tr\")\n .classed(\"highlight\", function(p) { return p.highlight});\n\n trowEnter.append(\"td\")\n .classed(\"legend-color-guide\",true)\n .append(\"div\")\n .style(\"background-color\", function(p) { return p.color});\n\n trowEnter.append(\"td\")\n .classed(\"key\",true)\n .classed(\"total\",function(p) { return !!p.total})\n .html(function(p, i) { return keyFormatter(p.key, i)});\n\n trowEnter.append(\"td\")\n .classed(\"value\",true)\n .html(function(p, i) { return valueFormatter(p.value, i, p) });\n\n trowEnter.filter(function (p,i) { return p.percent !== undefined }).append(\"td\")\n .classed(\"percent\", true)\n .html(function(p, i) { return \"(\" + d3.format('%')(p.percent) + \")\" });\n\n trowEnter.selectAll(\"td\").each(function(p) {\n if (p.highlight) {\n var opacityScale = d3.scale.linear().domain([0,1]).range([\"#fff\",p.color]);\n var opacity = 0.6;\n d3.select(this)\n .style(\"border-bottom-color\", opacityScale(opacity))\n .style(\"border-top-color\", opacityScale(opacity))\n ;\n }\n });\n\n var html = table.node().outerHTML;\n if (d.footer !== undefined)\n html += \"\";\n return html;\n\n };\n\n /*\n Function that returns the position (relative to the viewport/document.body)\n the tooltip should be placed in.\n Should return: {\n left: ,\n top: \n }\n */\n var position = function() {\n var pos = {\n left: d3.event !== null ? d3.event.clientX : 0,\n top: d3.event !== null ? d3.event.clientY : 0\n };\n\n if(getComputedStyle(document.body).transform != 'none') {\n // Take the offset into account, as now the tooltip is relative\n // to document.body.\n var client = document.body.getBoundingClientRect();\n pos.left -= client.left;\n pos.top -= client.top;\n }\n\n return pos;\n };\n\n var dataSeriesExists = function(d) {\n if (d && d.series) {\n if (nv.utils.isArray(d.series)) {\n return true;\n }\n // if object, it's okay just convert to array of the object\n if (nv.utils.isObject(d.series)) {\n d.series = [d.series];\n return true;\n }\n }\n return false;\n };\n\n // Calculates the gravity offset of the tooltip. Parameter is position of tooltip\n // relative to the viewport.\n var calcGravityOffset = function(pos) {\n var height = tooltip.node().offsetHeight,\n width = tooltip.node().offsetWidth,\n clientWidth = document.documentElement.clientWidth, // Don't want scrollbars.\n clientHeight = document.documentElement.clientHeight, // Don't want scrollbars.\n left, top, tmp;\n\n // calculate position based on gravity\n switch (gravity) {\n case 'e':\n left = - width - distance;\n top = - (height / 2);\n if(pos.left + left < 0) left = distance;\n if((tmp = pos.top + top) < 0) top -= tmp;\n if((tmp = pos.top + top + height) > clientHeight) top -= tmp - clientHeight;\n break;\n case 'w':\n left = distance;\n top = - (height / 2);\n if (pos.left + left + width > clientWidth) left = - width - distance;\n if ((tmp = pos.top + top) < 0) top -= tmp;\n if ((tmp = pos.top + top + height) > clientHeight) top -= tmp - clientHeight;\n break;\n case 'n':\n left = - (width / 2) - 5; // - 5 is an approximation of the mouse's height.\n top = distance;\n if (pos.top + top + height > clientHeight) top = - height - distance;\n if ((tmp = pos.left + left) < 0) left -= tmp;\n if ((tmp = pos.left + left + width) > clientWidth) left -= tmp - clientWidth;\n break;\n case 's':\n left = - (width / 2);\n top = - height - distance;\n if (pos.top + top < 0) top = distance;\n if ((tmp = pos.left + left) < 0) left -= tmp;\n if ((tmp = pos.left + left + width) > clientWidth) left -= tmp - clientWidth;\n break;\n case 'center':\n left = - (width / 2);\n top = - (height / 2);\n break;\n default:\n left = 0;\n top = 0;\n break;\n }\n\n return { 'left': left, 'top': top };\n };\n\n /*\n Positions the tooltip in the correct place, as given by the position() function.\n */\n var positionTooltip = function() {\n nv.dom.read(function() {\n var pos = position(),\n gravityOffset = calcGravityOffset(pos),\n left = pos.left + gravityOffset.left,\n top = pos.top + gravityOffset.top;\n\n // delay hiding a bit to avoid flickering\n if (hidden) {\n tooltip\n .interrupt()\n .transition()\n .delay(hideDelay)\n .duration(0)\n .style('opacity', 0);\n } else {\n // using tooltip.style('transform') returns values un-usable for tween\n var old_translate = 'translate(' + lastPosition.left + 'px, ' + lastPosition.top + 'px)';\n var new_translate = 'translate(' + Math.round(left) + 'px, ' + Math.round(top) + 'px)';\n var translateInterpolator = d3.interpolateString(old_translate, new_translate);\n var is_hidden = tooltip.style('opacity') < 0.1;\n\n tooltip\n .interrupt() // cancel running transitions\n .transition()\n .duration(is_hidden ? 0 : duration)\n // using tween since some versions of d3 can't auto-tween a translate on a div\n .styleTween('transform', function (d) {\n return translateInterpolator;\n }, 'important')\n // Safari has its own `-webkit-transform` and does not support `transform`\n .styleTween('-webkit-transform', function (d) {\n return translateInterpolator;\n })\n .style('-ms-transform', new_translate)\n .style('opacity', 1);\n }\n\n lastPosition.left = left;\n lastPosition.top = top;\n });\n };\n\n // Creates new tooltip container, or uses existing one on DOM.\n function initTooltip() {\n if (!tooltip || !tooltip.node()) {\n // Create new tooltip div if it doesn't exist on DOM.\n\n var data = [1];\n tooltip = d3.select(document.body).select('#'+id).data(data);\n\n tooltip.enter().append('div')\n .attr(\"class\", \"nvtooltip \" + (classes ? classes : \"xy-tooltip\"))\n .attr(\"id\", id)\n .style(\"top\", 0).style(\"left\", 0)\n .style('opacity', 0)\n .style('position', 'fixed')\n .selectAll(\"div, table, td, tr\").classed(nvPointerEventsClass, true)\n .classed(nvPointerEventsClass, true);\n\n tooltip.exit().remove()\n }\n }\n\n // Draw the tooltip onto the DOM.\n function nvtooltip() {\n if (!enabled) return;\n if (!dataSeriesExists(data)) return;\n\n nv.dom.write(function () {\n initTooltip();\n // Generate data and set it into tooltip.\n // Bonus - If you override contentGenerator and return false, you can use something like\n // Angular, React or Knockout to bind the data for your tooltip directly to the DOM.\n var newContent = contentGenerator(data, tooltip.node());\n if (newContent) {\n tooltip.node().innerHTML = newContent;\n }\n\n positionTooltip();\n });\n\n return nvtooltip;\n }\n\n nvtooltip.nvPointerEventsClass = nvPointerEventsClass;\n nvtooltip.options = nv.utils.optionsFunc.bind(nvtooltip);\n\n nvtooltip._options = Object.create({}, {\n // simple read/write options\n duration: {get: function(){return duration;}, set: function(_){duration=_;}},\n gravity: {get: function(){return gravity;}, set: function(_){gravity=_;}},\n distance: {get: function(){return distance;}, set: function(_){distance=_;}},\n snapDistance: {get: function(){return snapDistance;}, set: function(_){snapDistance=_;}},\n classes: {get: function(){return classes;}, set: function(_){classes=_;}},\n enabled: {get: function(){return enabled;}, set: function(_){enabled=_;}},\n hideDelay: {get: function(){return hideDelay;}, set: function(_){hideDelay=_;}},\n contentGenerator: {get: function(){return contentGenerator;}, set: function(_){contentGenerator=_;}},\n valueFormatter: {get: function(){return valueFormatter;}, set: function(_){valueFormatter=_;}},\n headerFormatter: {get: function(){return headerFormatter;}, set: function(_){headerFormatter=_;}},\n keyFormatter: {get: function(){return keyFormatter;}, set: function(_){keyFormatter=_;}},\n headerEnabled: {get: function(){return headerEnabled;}, set: function(_){headerEnabled=_;}},\n position: {get: function(){return position;}, set: function(_){position=_;}},\n\n // Deprecated options\n chartContainer: {get: function(){return document.body;}, set: function(_){\n // deprecated after 1.8.3\n nv.deprecated('chartContainer', 'feature removed after 1.8.3');\n }},\n fixedTop: {get: function(){return null;}, set: function(_){\n // deprecated after 1.8.1\n nv.deprecated('fixedTop', 'feature removed after 1.8.1');\n }},\n offset: {get: function(){return {left: 0, top: 0};}, set: function(_){\n // deprecated after 1.8.1\n nv.deprecated('offset', 'use chart.tooltip.distance() instead');\n }},\n\n // options with extra logic\n hidden: {get: function(){return hidden;}, set: function(_){\n if (hidden != _) {\n hidden = !!_;\n nvtooltip();\n }\n }},\n data: {get: function(){return data;}, set: function(_){\n // if showing a single data point, adjust data format with that\n if (_.point) {\n _.value = _.point.x;\n _.series = _.series || {};\n _.series.value = _.point.y;\n _.series.color = _.point.color || _.series.color;\n }\n data = _;\n }},\n\n // read only properties\n node: {get: function(){return tooltip.node();}, set: function(_){}},\n id: {get: function(){return id;}, set: function(_){}}\n });\n\n nv.utils.initOptions(nvtooltip);\n return nvtooltip;\n};\n", "\n\n/*\nGets the browser window size\n\nReturns object with height and width properties\n */\nnv.utils.windowSize = function() {\n // Sane defaults\n var size = {width: 640, height: 480};\n\n // Most recent browsers use\n if (window.innerWidth && window.innerHeight) {\n size.width = window.innerWidth;\n size.height = window.innerHeight;\n return (size);\n }\n\n // IE can use depending on mode it is in\n if (document.compatMode=='CSS1Compat' &&\n document.documentElement &&\n document.documentElement.offsetWidth ) {\n\n size.width = document.documentElement.offsetWidth;\n size.height = document.documentElement.offsetHeight;\n return (size);\n }\n\n // Earlier IE uses Doc.body\n if (document.body && document.body.offsetWidth) {\n size.width = document.body.offsetWidth;\n size.height = document.body.offsetHeight;\n return (size);\n }\n\n return (size);\n};\n\n\n/* handle dumb browser quirks... isinstance breaks if you use frames\ntypeof returns 'object' for null, NaN is a number, etc.\n */\nnv.utils.isArray = Array.isArray;\nnv.utils.isObject = function(a) {\n return a !== null && typeof a === 'object';\n};\nnv.utils.isFunction = function(a) {\n return typeof a === 'function';\n};\nnv.utils.isDate = function(a) {\n return toString.call(a) === '[object Date]';\n};\nnv.utils.isNumber = function(a) {\n return !isNaN(a) && typeof a === 'number';\n};\n\n\n/*\nBinds callback function to run when window is resized\n */\nnv.utils.windowResize = function(handler) {\n if (window.addEventListener) {\n window.addEventListener('resize', handler);\n } else {\n nv.log(\"ERROR: Failed to bind to window.resize with: \", handler);\n }\n // return object with clear function to remove the single added callback.\n return {\n callback: handler,\n clear: function() {\n window.removeEventListener('resize', handler);\n }\n }\n};\n\n\n/*\nBackwards compatible way to implement more d3-like coloring of graphs.\nCan take in nothing, an array, or a function/scale\nTo use a normal scale, get the range and pass that because we must be able\nto take two arguments and use the index to keep backward compatibility\n*/\nnv.utils.getColor = function(color) {\n //if you pass in nothing, get default colors back\n if (color === undefined) {\n return nv.utils.defaultColor();\n\n //if passed an array, turn it into a color scale\n } else if(nv.utils.isArray(color)) {\n var color_scale = d3.scale.ordinal().range(color);\n return function(d, i) {\n var key = i === undefined ? d : i;\n return d.color || color_scale(key);\n };\n\n //if passed a function or scale, return it, or whatever it may be\n //external libs, such as angularjs-nvd3-directives use this\n } else {\n //can't really help it if someone passes rubbish as color\n return color;\n }\n};\n\n\n/*\nDefault color chooser uses a color scale of 20 colors from D3\n https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors\n */\nnv.utils.defaultColor = function() {\n // get range of the scale so we'll turn it into our own function.\n return nv.utils.getColor(d3.scale.category20().range());\n};\n\n\n/*\nReturns a color function that takes the result of 'getKey' for each series and\nlooks for a corresponding color from the dictionary\n*/\nnv.utils.customTheme = function(dictionary, getKey, defaultColors) {\n // use default series.key if getKey is undefined\n getKey = getKey || function(series) { return series.key };\n defaultColors = defaultColors || d3.scale.category20().range();\n\n // start at end of default color list and walk back to index 0\n var defIndex = defaultColors.length;\n\n return function(series, index) {\n var key = getKey(series);\n if (nv.utils.isFunction(dictionary[key])) {\n return dictionary[key]();\n } else if (dictionary[key] !== undefined) {\n return dictionary[key];\n } else {\n // no match in dictionary, use a default color\n if (!defIndex) {\n // used all the default colors, start over\n defIndex = defaultColors.length;\n }\n defIndex = defIndex - 1;\n return defaultColors[defIndex];\n }\n };\n};\n\n\n/*\nFrom the PJAX example on d3js.org, while this is not really directly needed\nit's a very cool method for doing pjax, I may expand upon it a little bit,\nopen to suggestions on anything that may be useful\n*/\nnv.utils.pjax = function(links, content) {\n\n var load = function(href) {\n d3.html(href, function(fragment) {\n var target = d3.select(content).node();\n target.parentNode.replaceChild(\n d3.select(fragment).select(content).node(),\n target);\n nv.utils.pjax(links, content);\n });\n };\n\n d3.selectAll(links).on(\"click\", function() {\n history.pushState(this.href, this.textContent, this.href);\n load(this.href);\n d3.event.preventDefault();\n });\n\n d3.select(window).on(\"popstate\", function() {\n if (d3.event.state) {\n load(d3.event.state);\n }\n });\n};\n\n\n/*\nFor when we want to approximate the width in pixels for an SVG:text element.\nMost common instance is when the element is in a display:none; container.\nForumla is : text.length * font-size * constant_factor\n*/\nnv.utils.calcApproxTextWidth = function (svgTextElem) {\n if (nv.utils.isFunction(svgTextElem.style) && nv.utils.isFunction(svgTextElem.text)) {\n var fontSize = parseInt(svgTextElem.style(\"font-size\").replace(\"px\",\"\"), 10);\n var textLength = svgTextElem.text().length;\n return nv.utils.NaNtoZero(textLength * fontSize * 0.5);\n }\n return 0;\n};\n\n\n/*\nNumbers that are undefined, null or NaN, convert them to zeros.\n*/\nnv.utils.NaNtoZero = function(n) {\n if (!nv.utils.isNumber(n)\n || isNaN(n)\n || n === null\n || n === Infinity\n || n === -Infinity) {\n\n return 0;\n }\n return n;\n};\n\n/*\nAdd a way to watch for d3 transition ends to d3\n*/\nd3.selection.prototype.watchTransition = function(renderWatch){\n var args = [this].concat([].slice.call(arguments, 1));\n return renderWatch.transition.apply(renderWatch, args);\n};\n\n\n/*\nHelper object to watch when d3 has rendered something\n*/\nnv.utils.renderWatch = function(dispatch, duration) {\n if (!(this instanceof nv.utils.renderWatch)) {\n return new nv.utils.renderWatch(dispatch, duration);\n }\n\n var _duration = duration !== undefined ? duration : 250;\n var renderStack = [];\n var self = this;\n\n this.models = function(models) {\n models = [].slice.call(arguments, 0);\n models.forEach(function(model){\n model.__rendered = false;\n (function(m){\n m.dispatch.on('renderEnd', function(arg){\n m.__rendered = true;\n self.renderEnd('model');\n });\n })(model);\n\n if (renderStack.indexOf(model) < 0) {\n renderStack.push(model);\n }\n });\n return this;\n };\n\n this.reset = function(duration) {\n if (duration !== undefined) {\n _duration = duration;\n }\n renderStack = [];\n };\n\n this.transition = function(selection, args, duration) {\n args = arguments.length > 1 ? [].slice.call(arguments, 1) : [];\n\n if (args.length > 1) {\n duration = args.pop();\n } else {\n duration = _duration !== undefined ? _duration : 250;\n }\n selection.__rendered = false;\n\n if (renderStack.indexOf(selection) < 0) {\n renderStack.push(selection);\n }\n\n if (duration === 0) {\n selection.__rendered = true;\n selection.delay = function() { return this; };\n selection.duration = function() { return this; };\n return selection;\n } else {\n if (selection.length === 0) {\n selection.__rendered = true;\n } else if (selection.every( function(d){ return !d.length; } )) {\n selection.__rendered = true;\n } else {\n selection.__rendered = false;\n }\n\n var n = 0;\n return selection\n .transition()\n .duration(duration)\n .each(function(){ ++n; })\n .each('end', function(d, i) {\n if (--n === 0) {\n selection.__rendered = true;\n self.renderEnd.apply(this, args);\n }\n });\n }\n };\n\n this.renderEnd = function() {\n if (renderStack.every( function(d){ return d.__rendered; } )) {\n renderStack.forEach( function(d){ d.__rendered = false; });\n dispatch.renderEnd.apply(this, arguments);\n }\n }\n\n};\n\n\n/*\nTakes multiple objects and combines them into the first one (dst)\nexample: nv.utils.deepExtend({a: 1}, {a: 2, b: 3}, {c: 4});\ngives: {a: 2, b: 3, c: 4}\n*/\nnv.utils.deepExtend = function(dst){\n var sources = arguments.length > 1 ? [].slice.call(arguments, 1) : [];\n sources.forEach(function(source) {\n for (var key in source) {\n var isArray = nv.utils.isArray(dst[key]);\n var isObject = nv.utils.isObject(dst[key]);\n var srcObj = nv.utils.isObject(source[key]);\n\n if (isObject && !isArray && srcObj) {\n nv.utils.deepExtend(dst[key], source[key]);\n } else {\n dst[key] = source[key];\n }\n }\n });\n};\n\n\n/*\nstate utility object, used to track d3 states in the models\n*/\nnv.utils.state = function(){\n if (!(this instanceof nv.utils.state)) {\n return new nv.utils.state();\n }\n var state = {};\n var _self = this;\n var _setState = function(){};\n var _getState = function(){ return {}; };\n var init = null;\n var changed = null;\n\n this.dispatch = d3.dispatch('change', 'set');\n\n this.dispatch.on('set', function(state){\n _setState(state, true);\n });\n\n this.getter = function(fn){\n _getState = fn;\n return this;\n };\n\n this.setter = function(fn, callback) {\n if (!callback) {\n callback = function(){};\n }\n _setState = function(state, update){\n fn(state);\n if (update) {\n callback();\n }\n };\n return this;\n };\n\n this.init = function(state){\n init = init || {};\n nv.utils.deepExtend(init, state);\n };\n\n var _set = function(){\n var settings = _getState();\n\n if (JSON.stringify(settings) === JSON.stringify(state)) {\n return false;\n }\n\n for (var key in settings) {\n if (state[key] === undefined) {\n state[key] = {};\n }\n state[key] = settings[key];\n changed = true;\n }\n return true;\n };\n\n this.update = function(){\n if (init) {\n _setState(init, false);\n init = null;\n }\n if (_set.call(this)) {\n this.dispatch.change(state);\n }\n };\n\n};\n\n\n/*\nSnippet of code you can insert into each nv.models.* to give you the ability to\ndo things like:\nchart.options({\n showXAxis: true,\n tooltips: true\n});\n\nTo enable in the chart:\nchart.options = nv.utils.optionsFunc.bind(chart);\n*/\nnv.utils.optionsFunc = function(args) {\n if (args) {\n d3.map(args).forEach((function(key,value) {\n if (nv.utils.isFunction(this[key])) {\n this[key](value);\n }\n }).bind(this));\n }\n return this;\n};\n\n\n/*\nnumTicks: requested number of ticks\ndata: the chart data\n\nreturns the number of ticks to actually use on X axis, based on chart data\nto avoid duplicate ticks with the same value\n*/\nnv.utils.calcTicksX = function(numTicks, data) {\n // find max number of values from all data streams\n var numValues = 1;\n var i = 0;\n for (i; i < data.length; i += 1) {\n var stream_len = data[i] && data[i].values ? data[i].values.length : 0;\n numValues = stream_len > numValues ? stream_len : numValues;\n }\n nv.log(\"Requested number of ticks: \", numTicks);\n nv.log(\"Calculated max values to be: \", numValues);\n // make sure we don't have more ticks than values to avoid duplicates\n numTicks = numTicks > numValues ? numTicks = numValues - 1 : numTicks;\n // make sure we have at least one tick\n numTicks = numTicks < 1 ? 1 : numTicks;\n // make sure it's an integer\n numTicks = Math.floor(numTicks);\n nv.log(\"Calculating tick count as: \", numTicks);\n return numTicks;\n};\n\n\n/*\nreturns number of ticks to actually use on Y axis, based on chart data\n*/\nnv.utils.calcTicksY = function(numTicks, data) {\n // currently uses the same logic but we can adjust here if needed later\n return nv.utils.calcTicksX(numTicks, data);\n};\n\n\n/*\nAdd a particular option from an options object onto chart\nOptions exposed on a chart are a getter/setter function that returns chart\non set to mimic typical d3 option chaining, e.g. svg.option1('a').option2('b');\n\noption objects should be generated via Object.create() to provide\nthe option of manipulating data via get/set functions.\n*/\nnv.utils.initOption = function(chart, name) {\n // if it's a call option, just call it directly, otherwise do get/set\n if (chart._calls && chart._calls[name]) {\n chart[name] = chart._calls[name];\n } else {\n chart[name] = function (_) {\n if (!arguments.length) return chart._options[name];\n chart._overrides[name] = true;\n chart._options[name] = _;\n return chart;\n };\n // calling the option as _option will ignore if set by option already\n // so nvd3 can set options internally but the stop if set manually\n chart['_' + name] = function(_) {\n if (!arguments.length) return chart._options[name];\n if (!chart._overrides[name]) {\n chart._options[name] = _;\n }\n return chart;\n }\n }\n};\n\n\n/*\nAdd all options in an options object to the chart\n*/\nnv.utils.initOptions = function(chart) {\n chart._overrides = chart._overrides || {};\n var ops = Object.getOwnPropertyNames(chart._options || {});\n var calls = Object.getOwnPropertyNames(chart._calls || {});\n ops = ops.concat(calls);\n for (var i in ops) {\n nv.utils.initOption(chart, ops[i]);\n }\n};\n\n\n/*\nInherit options from a D3 object\nd3.rebind makes calling the function on target actually call it on source\nAlso use _d3options so we can track what we inherit for documentation and chained inheritance\n*/\nnv.utils.inheritOptionsD3 = function(target, d3_source, oplist) {\n target._d3options = oplist.concat(target._d3options || []);\n // Find unique d3 options (string) and update d3options\n target._d3options = (target._d3options || []).filter(function(item, i, ar){ return ar.indexOf(item) === i; });\n oplist.unshift(d3_source);\n oplist.unshift(target);\n d3.rebind.apply(this, oplist);\n};\n\n\n/*\nRemove duplicates from an array\n*/\nnv.utils.arrayUnique = function(a) {\n return a.sort().filter(function(item, pos) {\n return !pos || item != a[pos - 1];\n });\n};\n\n\n/*\nKeeps a list of custom symbols to draw from in addition to d3.svg.symbol\nNecessary since d3 doesn't let you extend its list -_-\nAdd new symbols by doing nv.utils.symbols.set('name', function(size){...});\n*/\nnv.utils.symbolMap = d3.map();\n\n\n/*\nReplaces d3.svg.symbol so that we can look both there and our own map\n */\nnv.utils.symbol = function() {\n var type,\n size = 64;\n function symbol(d,i) {\n var t = type.call(this,d,i);\n var s = size.call(this,d,i);\n if (d3.svg.symbolTypes.indexOf(t) !== -1) {\n return d3.svg.symbol().type(t).size(s)();\n } else {\n return nv.utils.symbolMap.get(t)(s);\n }\n }\n symbol.type = function(_) {\n if (!arguments.length) return type;\n type = d3.functor(_);\n return symbol;\n };\n symbol.size = function(_) {\n if (!arguments.length) return size;\n size = d3.functor(_);\n return symbol;\n };\n return symbol;\n};\n\n\n/*\nInherit option getter/setter functions from source to target\nd3.rebind makes calling the function on target actually call it on source\nAlso track via _inherited and _d3options so we can track what we inherit\nfor documentation generation purposes and chained inheritance\n*/\nnv.utils.inheritOptions = function(target, source) {\n // inherit all the things\n var ops = Object.getOwnPropertyNames(source._options || {});\n var calls = Object.getOwnPropertyNames(source._calls || {});\n var inherited = source._inherited || [];\n var d3ops = source._d3options || [];\n var args = ops.concat(calls).concat(inherited).concat(d3ops);\n args.unshift(source);\n args.unshift(target);\n d3.rebind.apply(this, args);\n // pass along the lists to keep track of them, don't allow duplicates\n target._inherited = nv.utils.arrayUnique(ops.concat(calls).concat(inherited).concat(ops).concat(target._inherited || []));\n target._d3options = nv.utils.arrayUnique(d3ops.concat(target._d3options || []));\n};\n\n\n/*\nRuns common initialize code on the svg before the chart builds\n*/\nnv.utils.initSVG = function(svg) {\n svg.classed({'nvd3-svg':true});\n};\n\n\n/*\nSanitize and provide default for the container height.\n*/\nnv.utils.sanitizeHeight = function(height, container) {\n return (height || parseInt(container.style('height'), 10) || 400);\n};\n\n\n/*\nSanitize and provide default for the container width.\n*/\nnv.utils.sanitizeWidth = function(width, container) {\n return (width || parseInt(container.style('width'), 10) || 960);\n};\n\n\n/*\nCalculate the available height for a chart.\n*/\nnv.utils.availableHeight = function(height, container, margin) {\n return Math.max(0,nv.utils.sanitizeHeight(height, container) - margin.top - margin.bottom);\n};\n\n/*\nCalculate the available width for a chart.\n*/\nnv.utils.availableWidth = function(width, container, margin) {\n return Math.max(0,nv.utils.sanitizeWidth(width, container) - margin.left - margin.right);\n};\n\n/*\nClear any rendered chart components and display a chart's 'noData' message\n*/\nnv.utils.noData = function(chart, container) {\n var opt = chart.options(),\n margin = opt.margin(),\n noData = opt.noData(),\n data = (noData == null) ? [\"No Data Available.\"] : [noData],\n height = nv.utils.availableHeight(null, container, margin),\n width = nv.utils.availableWidth(null, container, margin),\n x = margin.left + width/2,\n y = margin.top + height/2;\n\n //Remove any previously created chart components\n container.selectAll('g').remove();\n\n var noDataText = container.selectAll('.nv-noData').data(data);\n\n noDataText.enter().append('text')\n .attr('class', 'nvd3 nv-noData')\n .attr('dy', '-.7em')\n .style('text-anchor', 'middle');\n\n noDataText\n .attr('x', x)\n .attr('y', y)\n .text(function(t){ return t; });\n};\n\n/*\n Wrap long labels.\n */\nnv.utils.wrapTicks = function (text, width) {\n text.each(function() {\n var text = d3.select(this),\n words = text.text().split(/\\s+/).reverse(),\n word,\n line = [],\n lineNumber = 0,\n lineHeight = 1.1,\n y = text.attr(\"y\"),\n dy = parseFloat(text.attr(\"dy\")),\n tspan = text.text(null).append(\"tspan\").attr(\"x\", 0).attr(\"y\", y).attr(\"dy\", dy + \"em\");\n while (word = words.pop()) {\n line.push(word);\n tspan.text(line.join(\" \"));\n if (tspan.node().getComputedTextLength() > width) {\n line.pop();\n tspan.text(line.join(\" \"));\n line = [word];\n tspan = text.append(\"tspan\").attr(\"x\", 0).attr(\"y\", y).attr(\"dy\", ++lineNumber * lineHeight + dy + \"em\").text(word);\n }\n }\n });\n};\n\n/*\nCheck equality of 2 array\n*/\nnv.utils.arrayEquals = function (array1, array2) {\n if (array1 === array2)\n return true;\n\n if (!array1 || !array2)\n return false;\n\n // compare lengths - can save a lot of time\n if (array1.length != array2.length)\n return false;\n\n for (var i = 0,\n l = array1.length; i < l; i++) {\n // Check if we have nested arrays\n if (array1[i] instanceof Array && array2[i] instanceof Array) {\n // recurse into the nested arrays\n if (!nv.arrayEquals(array1[i], array2[i]))\n return false;\n } else if (array1[i] != array2[i]) {\n // Warning - two different object instances will never be equal: {x:20} != {x:20}\n return false;\n }\n }\n return true;\n};\n\n/*\n Check if a point within an arc\n */\nnv.utils.pointIsInArc = function(pt, ptData, d3Arc) {\n // Center of the arc is assumed to be 0,0\n // (pt.x, pt.y) are assumed to be relative to the center\n var r1 = d3Arc.innerRadius()(ptData), // Note: Using the innerRadius\n r2 = d3Arc.outerRadius()(ptData),\n theta1 = d3Arc.startAngle()(ptData),\n theta2 = d3Arc.endAngle()(ptData);\n\n var dist = pt.x * pt.x + pt.y * pt.y,\n angle = Math.atan2(pt.x, -pt.y); // Note: different coordinate system.\n\n angle = (angle < 0) ? (angle + Math.PI * 2) : angle;\n\n return (r1 * r1 <= dist) && (dist <= r2 * r2) &&\n (theta1 <= angle) && (angle <= theta2);\n};\n\n", "nv.models.axis = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var axis = d3.svg.axis();\n var scale = d3.scale.linear();\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 75 //only used for tickLabel currently\n , height = 60 //only used for tickLabel currently\n , axisLabelText = null\n , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes\n , rotateLabels = 0\n , rotateYLabel = true\n , staggerLabels = false\n , isOrdinal = false\n , ticks = null\n , axisLabelDistance = 0\n , fontSize = undefined\n , duration = 250\n , dispatch = d3.dispatch('renderEnd')\n , tickFormatMaxMin\n ;\n axis\n .scale(scale)\n .orient('bottom')\n .tickFormat(function(d) { return d })\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var scale0;\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n if (ticks !== null)\n axis.ticks(ticks);\n else if (axis.orient() == 'top' || axis.orient() == 'bottom')\n axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100);\n\n //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component\n g.watchTransition(renderWatch, 'axis').call(axis);\n\n scale0 = scale0 || axis.scale();\n\n var fmt = axis.tickFormat();\n if (fmt == null) {\n fmt = scale0.tickFormat();\n }\n\n var axisLabel = g.selectAll('text.nv-axislabel')\n .data([axisLabelText || null]);\n axisLabel.exit().remove();\n\n //only skip when fontSize is undefined so it can be cleared with a null or blank string\n if (fontSize !== undefined) {\n g.selectAll('g').select(\"text\").style('font-size', fontSize);\n }\n\n var xLabelMargin;\n var axisMaxMin;\n var w;\n switch (axis.orient()) {\n case 'top':\n axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n w = 0;\n if (scale.range().length === 1) {\n w = isOrdinal ? scale.range()[0] * 2 + scale.rangeBand() : 0;\n } else if (scale.range().length === 2) {\n w = isOrdinal ? scale.range()[0] + scale.range()[1] + scale.rangeBand() : scale.range()[1];\n } else if ( scale.range().length > 2){\n w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]);\n };\n axisLabel\n .attr('text-anchor', 'middle')\n .attr('y', 0)\n .attr('x', w/2);\n if (showMaxMin) {\n axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n .data(scale.domain());\n axisMaxMin.enter().append('g').attr('class',function(d,i){\n return ['nv-axisMaxMin','nv-axisMaxMin-x',(i == 0 ? 'nv-axisMin-x':'nv-axisMax-x')].join(' ')\n }).append('text');\n axisMaxMin.exit().remove();\n axisMaxMin\n .attr('transform', function(d,i) {\n return 'translate(' + nv.utils.NaNtoZero(scale(d)) + ',0)'\n })\n .select('text')\n .attr('dy', '-0.5em')\n .attr('y', -axis.tickPadding())\n .attr('text-anchor', 'middle')\n .text(function(d,i) {\n var formatter = tickFormatMaxMin || fmt;\n var v = formatter(d);\n return ('' + v).match('NaN') ? '' : v;\n });\n axisMaxMin.watchTransition(renderWatch, 'min-max top')\n .attr('transform', function(d,i) {\n return 'translate(' + nv.utils.NaNtoZero(scale.range()[i]) + ',0)'\n });\n }\n break;\n case 'bottom':\n xLabelMargin = axisLabelDistance + 36;\n var maxTextWidth = 30;\n var textHeight = 0;\n var xTicks = g.selectAll('g').select(\"text\");\n var rotateLabelsRule = '';\n if (rotateLabels%360) {\n //Reset transform on ticks so textHeight can be calculated correctly\n xTicks.attr('transform', '');\n //Calculate the longest xTick width\n xTicks.each(function(d,i){\n var box = this.getBoundingClientRect();\n var width = box.width;\n textHeight = box.height;\n if(width > maxTextWidth) maxTextWidth = width;\n });\n rotateLabelsRule = 'rotate(' + rotateLabels + ' 0,' + (textHeight/2 + axis.tickPadding()) + ')';\n //Convert to radians before calculating sin. Add 30 to margin for healthy padding.\n var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180));\n xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30;\n //Rotate all xTicks\n xTicks\n .attr('transform', rotateLabelsRule)\n .style('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end');\n } else {\n if (staggerLabels) {\n xTicks\n .attr('transform', function(d,i) {\n return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')'\n });\n } else {\n xTicks.attr('transform', \"translate(0,0)\");\n }\n }\n axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n w = 0;\n if (scale.range().length === 1) {\n w = isOrdinal ? scale.range()[0] * 2 + scale.rangeBand() : 0;\n } else if (scale.range().length === 2) {\n w = isOrdinal ? scale.range()[0] + scale.range()[1] + scale.rangeBand() : scale.range()[1];\n } else if ( scale.range().length > 2){\n w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]);\n };\n axisLabel\n .attr('text-anchor', 'middle')\n .attr('y', xLabelMargin)\n .attr('x', w/2);\n if (showMaxMin) {\n //if (showMaxMin && !isOrdinal) {\n axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n //.data(scale.domain())\n .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]);\n axisMaxMin.enter().append('g').attr('class',function(d,i){\n return ['nv-axisMaxMin','nv-axisMaxMin-x',(i == 0 ? 'nv-axisMin-x':'nv-axisMax-x')].join(' ')\n }).append('text');\n axisMaxMin.exit().remove();\n axisMaxMin\n .attr('transform', function(d,i) {\n return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)'\n })\n .select('text')\n .attr('dy', '.71em')\n .attr('y', axis.tickPadding())\n .attr('transform', rotateLabelsRule)\n .style('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle')\n .text(function(d,i) {\n var formatter = tickFormatMaxMin || fmt;\n var v = formatter(d);\n return ('' + v).match('NaN') ? '' : v;\n });\n axisMaxMin.watchTransition(renderWatch, 'min-max bottom')\n .attr('transform', function(d,i) {\n return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)'\n });\n }\n\n break;\n case 'right':\n axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n axisLabel\n .style('text-anchor', rotateYLabel ? 'middle' : 'begin')\n .attr('transform', rotateYLabel ? 'rotate(90)' : '')\n .attr('y', rotateYLabel ? (-Math.max(margin.right, width) + 12 - (axisLabelDistance || 0)) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart\n .attr('x', rotateYLabel ? (d3.max(scale.range()) / 2) : axis.tickPadding());\n if (showMaxMin) {\n axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n .data(scale.domain());\n \taxisMaxMin.enter().append('g').attr('class',function(d,i){\n return ['nv-axisMaxMin','nv-axisMaxMin-y',(i == 0 ? 'nv-axisMin-y':'nv-axisMax-y')].join(' ')\n }).append('text')\n .style('opacity', 0);\n axisMaxMin.exit().remove();\n axisMaxMin\n .attr('transform', function(d,i) {\n return 'translate(0,' + nv.utils.NaNtoZero(scale(d)) + ')'\n })\n .select('text')\n .attr('dy', '.32em')\n .attr('y', 0)\n .attr('x', axis.tickPadding())\n .style('text-anchor', 'start')\n .text(function(d, i) {\n var formatter = tickFormatMaxMin || fmt;\n var v = formatter(d);\n return ('' + v).match('NaN') ? '' : v;\n });\n axisMaxMin.watchTransition(renderWatch, 'min-max right')\n .attr('transform', function(d,i) {\n return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')'\n })\n .select('text')\n .style('opacity', 1);\n }\n break;\n case 'left':\n /*\n //For dynamically placing the label. Can be used with dynamically-sized chart axis margins\n var yTicks = g.selectAll('g').select(\"text\");\n yTicks.each(function(d,i){\n var labelPadding = this.getBoundingClientRect().width + axis.tickPadding() + 16;\n if(labelPadding > width) width = labelPadding;\n });\n */\n axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n axisLabel\n .style('text-anchor', rotateYLabel ? 'middle' : 'end')\n .attr('transform', rotateYLabel ? 'rotate(-90)' : '')\n .attr('y', rotateYLabel ? (-Math.max(margin.left, width) + 25 - (axisLabelDistance || 0)) : -10)\n .attr('x', rotateYLabel ? (-d3.max(scale.range()) / 2) : -axis.tickPadding());\n if (showMaxMin) {\n axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n .data(scale.domain());\n axisMaxMin.enter().append('g').attr('class',function(d,i){\n return ['nv-axisMaxMin','nv-axisMaxMin-y',(i == 0 ? 'nv-axisMin-y':'nv-axisMax-y')].join(' ')\n }).append('text')\n .style('opacity', 0);\n axisMaxMin.exit().remove();\n axisMaxMin\n .attr('transform', function(d,i) {\n return 'translate(0,' + nv.utils.NaNtoZero(scale0(d)) + ')'\n })\n .select('text')\n .attr('dy', '.32em')\n .attr('y', 0)\n .attr('x', -axis.tickPadding())\n .attr('text-anchor', 'end')\n .text(function(d,i) {\n var formatter = tickFormatMaxMin || fmt;\n var v = formatter(d);\n return ('' + v).match('NaN') ? '' : v;\n });\n axisMaxMin.watchTransition(renderWatch, 'min-max right')\n .attr('transform', function(d,i) {\n return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')'\n })\n .select('text')\n .style('opacity', 1);\n }\n break;\n }\n axisLabel.text(function(d) { return d });\n\n if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) {\n //check if max and min overlap other values, if so, hide the values that overlap\n g.selectAll('g') // the g's wrapping each tick\n .each(function(d,i) {\n d3.select(this).select('text').attr('opacity', 1);\n if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it!\n if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL\n d3.select(this).attr('opacity', 0);\n\n d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!!\n }\n });\n\n //if Max and Min = 0 only show min, Issue #281\n if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0) {\n wrap.selectAll('g.nv-axisMaxMin').style('opacity', function (d, i) {\n return !i ? 1 : 0\n });\n }\n }\n\n if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) {\n var maxMinRange = [];\n wrap.selectAll('g.nv-axisMaxMin')\n .each(function(d,i) {\n try {\n if (i) // i== 1, max position\n maxMinRange.push(scale(d) - this.getBoundingClientRect().width - 4); //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)\n else // i==0, min position\n maxMinRange.push(scale(d) + this.getBoundingClientRect().width + 4)\n }catch (err) {\n if (i) // i== 1, max position\n maxMinRange.push(scale(d) - 4); //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)\n else // i==0, min position\n maxMinRange.push(scale(d) + 4);\n }\n });\n // the g's wrapping each tick\n g.selectAll('g').each(function(d, i) {\n if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) {\n if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL\n d3.select(this).remove();\n else\n d3.select(this).select('text').remove(); // Don't remove the ZERO line!!\n }\n });\n }\n\n //Highlight zero tick line\n g.selectAll('.tick')\n .filter(function (d) {\n /*\n The filter needs to return only ticks at or near zero.\n Numbers like 0.00001 need to count as zero as well,\n and the arithmetic trick below solves that.\n */\n return !parseFloat(Math.round(d * 100000) / 1000000) && (d !== undefined)\n })\n .classed('zero', true);\n\n //store old scales for use in transitions on update\n scale0 = scale.copy();\n\n });\n\n renderWatch.renderEnd('axis immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.axis = axis;\n chart.dispatch = dispatch;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n axisLabelDistance: {get: function(){return axisLabelDistance;}, set: function(_){axisLabelDistance=_;}},\n staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n rotateLabels: {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n rotateYLabel: {get: function(){return rotateYLabel;}, set: function(_){rotateYLabel=_;}},\n showMaxMin: {get: function(){return showMaxMin;}, set: function(_){showMaxMin=_;}},\n axisLabel: {get: function(){return axisLabelText;}, set: function(_){axisLabelText=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n ticks: {get: function(){return ticks;}, set: function(_){ticks=_;}},\n width: {get: function(){return width;}, set: function(_){width=_;}},\n fontSize: {get: function(){return fontSize;}, set: function(_){fontSize=_;}},\n tickFormatMaxMin: {get: function(){return tickFormatMaxMin;}, set: function(_){tickFormatMaxMin=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration=_;\n renderWatch.reset(duration);\n }},\n scale: {get: function(){return scale;}, set: function(_){\n scale = _;\n axis.scale(scale);\n isOrdinal = typeof scale.rangeBands === 'function';\n nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']);\n }}\n });\n\n nv.utils.initOptions(chart);\n nv.utils.inheritOptionsD3(chart, axis, ['orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat']);\n nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']);\n\n return chart;\n};\n", "nv.models.boxPlot = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0},\n width = 960,\n height = 500,\n id = Math.floor(Math.random() * 10000), // Create semi-unique ID in case user doesn't select one\n xScale = d3.scale.ordinal(),\n yScale = d3.scale.linear(),\n getX = function(d) { return d.label }, // Default data model selectors.\n getQ1 = function(d) { return d.values.Q1 },\n getQ2 = function(d) { return d.values.Q2 },\n getQ3 = function(d) { return d.values.Q3 },\n getWl = function(d) { return d.values.whisker_low },\n getWh = function(d) { return d.values.whisker_high },\n getColor = function(d) { return d.color },\n getOlItems = function(d) { return d.values.outliers },\n getOlValue = function(d, i, j) { return d },\n getOlLabel = function(d, i, j) { return d },\n getOlColor = function(d, i, j) { return undefined },\n color = nv.utils.defaultColor(),\n container = null,\n xDomain, xRange,\n yDomain, yRange,\n dispatch = d3.dispatch('elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd'),\n duration = 250,\n maxBoxWidth = null;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var xScale0, yScale0;\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup Scales\n xScale.domain(xDomain || data.map(function(d,i) { return getX(d,i); }))\n .rangeBands(xRange || [0, availableWidth], 0.1);\n\n // if we know yDomain, no need to calculate\n var yData = []\n if (!yDomain) {\n // (y-range is based on quartiles, whiskers and outliers)\n var values = [], yMin, yMax;\n data.forEach(function (d, i) {\n var q1 = getQ1(d), q3 = getQ3(d), wl = getWl(d), wh = getWh(d);\n var olItems = getOlItems(d);\n if (olItems) {\n olItems.forEach(function (e, i) {\n values.push(getOlValue(e, i, undefined));\n });\n }\n if (wl) { values.push(wl) }\n if (q1) { values.push(q1) }\n if (q3) { values.push(q3) }\n if (wh) { values.push(wh) }\n });\n yMin = d3.min(values);\n yMax = d3.max(values);\n yData = [ yMin, yMax ] ;\n }\n\n yScale.domain(yDomain || yData);\n yScale.range(yRange || [availableHeight, 0]);\n\n //store old scales if they exist\n xScale0 = xScale0 || xScale;\n yScale0 = yScale0 || yScale.copy().range([yScale(0),yScale(0)]);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap');\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n var boxplots = wrap.selectAll('.nv-boxplot').data(function(d) { return d });\n var boxEnter = boxplots.enter().append('g').style('stroke-opacity', 1e-6).style('fill-opacity', 1e-6);\n boxplots\n .attr('class', 'nv-boxplot')\n .attr('transform', function(d,i,j) { return 'translate(' + (xScale(getX(d,i)) + xScale.rangeBand() * 0.05) + ', 0)'; })\n .classed('hover', function(d) { return d.hover });\n boxplots\n .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n .style('stroke-opacity', 1)\n .style('fill-opacity', 0.75)\n .delay(function(d,i) { return i * duration / data.length })\n .attr('transform', function(d,i) {\n return 'translate(' + (xScale(getX(d,i)) + xScale.rangeBand() * 0.05) + ', 0)';\n });\n boxplots.exit().remove();\n\n // ----- add the SVG elements for each boxPlot -----\n\n // conditionally append whisker lines\n boxEnter.each(function(d,i) {\n var box = d3.select(this);\n [getWl, getWh].forEach(function (f) {\n if (f(d) !== undefined && f(d) !== null) {\n var key = (f === getWl) ? 'low' : 'high';\n box.append('line')\n .style('stroke', getColor(d) || color(d,i))\n .attr('class', 'nv-boxplot-whisker nv-boxplot-' + key);\n box.append('line')\n .style('stroke', getColor(d) || color(d,i))\n .attr('class', 'nv-boxplot-tick nv-boxplot-' + key);\n }\n });\n });\n\n var box_width = function() { return (maxBoxWidth === null ? xScale.rangeBand() * 0.9 : Math.min(75, xScale.rangeBand() * 0.9)); };\n var box_left = function() { return xScale.rangeBand() * 0.45 - box_width()/2; };\n var box_right = function() { return xScale.rangeBand() * 0.45 + box_width()/2; };\n\n // update whisker lines and ticks\n [getWl, getWh].forEach(function (f) {\n var key = (f === getWl) ? 'low' : 'high';\n var endpoint = (f === getWl) ? getQ1 : getQ3;\n boxplots.select('line.nv-boxplot-whisker.nv-boxplot-' + key)\n .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n .attr('x1', xScale.rangeBand() * 0.45 )\n .attr('y1', function(d,i) { return yScale(f(d)); })\n .attr('x2', xScale.rangeBand() * 0.45 )\n .attr('y2', function(d,i) { return yScale(endpoint(d)); });\n boxplots.select('line.nv-boxplot-tick.nv-boxplot-' + key)\n .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n .attr('x1', box_left )\n .attr('y1', function(d,i) { return yScale(f(d)); })\n .attr('x2', box_right )\n .attr('y2', function(d,i) { return yScale(f(d)); });\n });\n\n [getWl, getWh].forEach(function (f) {\n var key = (f === getWl) ? 'low' : 'high';\n boxEnter.selectAll('.nv-boxplot-' + key)\n .on('mouseover', function(d,i,j) {\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n series: { key: f(d), color: getColor(d) || color(d,j) },\n e: d3.event\n });\n })\n .on('mouseout', function(d,i,j) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n series: { key: f(d), color: getColor(d) || color(d,j) },\n e: d3.event\n });\n })\n .on('mousemove', function(d,i) {\n dispatch.elementMousemove({e: d3.event});\n });\n });\n\n // boxes\n boxEnter.append('rect')\n .attr('class', 'nv-boxplot-box')\n // tooltip events\n .on('mouseover', function(d,i) {\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n key: getX(d),\n value: getX(d),\n series: [\n { key: 'Q3', value: getQ3(d), color: getColor(d) || color(d,i) },\n { key: 'Q2', value: getQ2(d), color: getColor(d) || color(d,i) },\n { key: 'Q1', value: getQ1(d), color: getColor(d) || color(d,i) }\n ],\n data: d,\n index: i,\n e: d3.event\n });\n })\n .on('mouseout', function(d,i) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n key: getX(d),\n value: getX(d),\n series: [\n { key: 'Q3', value: getQ3(d), color: getColor(d) || color(d,i) },\n { key: 'Q2', value: getQ2(d), color: getColor(d) || color(d,i) },\n { key: 'Q1', value: getQ1(d), color: getColor(d) || color(d,i) }\n ],\n data: d,\n index: i,\n e: d3.event\n });\n })\n .on('mousemove', function(d,i) {\n dispatch.elementMousemove({e: d3.event});\n });\n\n // box transitions\n boxplots.select('rect.nv-boxplot-box')\n .watchTransition(renderWatch, 'nv-boxplot: boxes')\n .attr('y', function(d,i) { return yScale(getQ3(d)); })\n .attr('width', box_width)\n .attr('x', box_left )\n .attr('height', function(d,i) { return Math.abs(yScale(getQ3(d)) - yScale(getQ1(d))) || 1 })\n .style('fill', function(d,i) { return getColor(d) || color(d,i) })\n .style('stroke', function(d,i) { return getColor(d) || color(d,i) });\n\n // median line\n boxEnter.append('line').attr('class', 'nv-boxplot-median');\n\n boxplots.select('line.nv-boxplot-median')\n .watchTransition(renderWatch, 'nv-boxplot: boxplots line')\n .attr('x1', box_left)\n .attr('y1', function(d,i) { return yScale(getQ2(d)); })\n .attr('x2', box_right)\n .attr('y2', function(d,i) { return yScale(getQ2(d)); });\n\n // outliers\n var outliers = boxplots.selectAll('.nv-boxplot-outlier').data(function(d) {\n return getOlItems(d) || [];\n });\n outliers.enter().append('circle')\n .style('fill', function(d,i,j) { return getOlColor(d,i,j) || color(d,j) })\n .style('stroke', function(d,i,j) { return getOlColor(d,i,j) || color(d,j) })\n .style('z-index', 9000)\n .on('mouseover', function(d,i,j) {\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n series: { key: getOlLabel(d,i,j), color: getOlColor(d,i,j) || color(d,j) },\n e: d3.event\n });\n })\n .on('mouseout', function(d,i,j) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n series: { key: getOlLabel(d,i,j), color: getOlColor(d,i,j) || color(d,j) },\n e: d3.event\n });\n })\n .on('mousemove', function(d,i) {\n dispatch.elementMousemove({e: d3.event});\n });\n outliers.attr('class', 'nv-boxplot-outlier');\n outliers\n .watchTransition(renderWatch, 'nv-boxplot: nv-boxplot-outlier')\n .attr('cx', xScale.rangeBand() * 0.45)\n .attr('cy', function(d,i,j) { return yScale(getOlValue(d,i,j)); })\n .attr('r', '3');\n outliers.exit().remove();\n\n //store old scales for use in transitions on update\n xScale0 = xScale.copy();\n yScale0 = yScale.copy();\n });\n\n renderWatch.renderEnd('nv-boxplot immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n maxBoxWidth: {get: function(){return maxBoxWidth;}, set: function(_){maxBoxWidth=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n q1: {get: function(){return getQ1;}, set: function(_){getQ1=_;}},\n q2: {get: function(){return getQ2;}, set: function(_){getQ2=_;}},\n q3: {get: function(){return getQ3;}, set: function(_){getQ3=_;}},\n wl: {get: function(){return getWl;}, set: function(_){getWl=_;}},\n wh: {get: function(){return getWh;}, set: function(_){getWh=_;}},\n itemColor: {get: function(){return getColor;}, set: function(_){getColor=_;}},\n outliers: {get: function(){return getOlItems;}, set: function(_){getOlItems=_;}},\n outlierValue: {get: function(){return getOlValue;}, set: function(_){getOlValue=_;}},\n outlierLabel: {get: function(){return getOlLabel;}, set: function(_){getOlLabel=_;}},\n outlierColor: {get: function(){return getOlColor;}, set: function(_){getOlColor=_;}},\n xScale: {get: function(){return xScale;}, set: function(_){xScale=_;}},\n yScale: {get: function(){return yScale;}, set: function(_){yScale=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n // rectClass: {get: function(){return rectClass;}, set: function(_){rectClass=_;}},\n y: {\n get: function() {\n console.warn('BoxPlot \\'y\\' chart option is deprecated. Please use model overrides instead.');\n return {};\n },\n set: function(_) {\n console.warn('BoxPlot \\'y\\' chart option is deprecated. Please use model overrides instead.');\n }\n },\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "nv.models.boxPlotChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var boxplot = nv.models.boxPlot(),\n xAxis = nv.models.axis(),\n yAxis = nv.models.axis();\n\n var margin = {top: 15, right: 10, bottom: 50, left: 60},\n width = null,\n height = null,\n color = nv.utils.getColor(),\n showXAxis = true,\n showYAxis = true,\n rightAlignYAxis = false,\n staggerLabels = false,\n tooltip = nv.models.tooltip(),\n x, y,\n noData = 'No Data Available.',\n dispatch = d3.dispatch('beforeUpdate', 'renderEnd'),\n duration = 250;\n\n xAxis\n .orient('bottom')\n .showMaxMin(false)\n .tickFormat(function(d) { return d })\n ;\n yAxis\n .orient((rightAlignYAxis) ? 'right' : 'left')\n .tickFormat(d3.format(',.1f'))\n ;\n\n tooltip.duration(0);\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(boxplot);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this), that = this;\n nv.utils.initSVG(container);\n var availableWidth = (width || parseInt(container.style('width')) || 960) - margin.left - margin.right;\n var availableHeight = (height || parseInt(container.style('height')) || 400) - margin.top - margin.bottom;\n\n chart.update = function() {\n dispatch.beforeUpdate();\n container.transition().duration(duration).call(chart);\n };\n chart.container = this;\n\n // TODO still need to find a way to validate quartile data presence using boxPlot callbacks.\n // Display No Data message if there's nothing to show. (quartiles required at minimum).\n if (!data || !data.length) {\n var noDataText = container.selectAll('.nv-noData').data([noData]);\n\n noDataText.enter().append('text')\n .attr('class', 'nvd3 nv-noData')\n .attr('dy', '-.7em')\n .style('text-anchor', 'middle');\n\n noDataText\n .attr('x', margin.left + availableWidth / 2)\n .attr('y', margin.top + availableHeight / 2)\n .text(function(d) { return d });\n\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = boxplot.xScale();\n y = boxplot.yScale().clamp(true);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-boxPlotWithAxes').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-boxPlotWithAxes').append('g');\n var defsEnter = gEnter.append('defs');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis')\n .append('g').attr('class', 'nv-zeroLine')\n .append('line');\n\n gEnter.append('g').attr('class', 'nv-barsWrap');\n g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n if (rightAlignYAxis) {\n g.select('.nv-y.nv-axis')\n .attr('transform', 'translate(' + availableWidth + ',0)');\n }\n\n // Main Chart Component(s)\n boxplot.width(availableWidth).height(availableHeight);\n\n var barsWrap = g.select('.nv-barsWrap')\n .datum(data.filter(function(d) { return !d.disabled }))\n\n barsWrap.transition().call(boxplot);\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-x-label-clip-' + boxplot.id())\n .append('rect');\n\n g.select('#nv-x-label-clip-' + boxplot.id() + ' rect')\n .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))\n .attr('height', 16)\n .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n .ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis').attr('transform', 'translate(0,' + y.range()[0] + ')');\n g.select('.nv-x.nv-axis').call(xAxis);\n\n var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n if (staggerLabels) {\n xTicks\n .selectAll('text')\n .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 === 0 ? '5' : '17') + ')' })\n }\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n .ticks( Math.floor(availableHeight/36) ) // can't use nv.utils.calcTicksY with Object data\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis').call(yAxis);\n }\n\n // Zero line\n g.select('.nv-zeroLine line')\n .attr('x1',0)\n .attr('x2',availableWidth)\n .attr('y1', y(0))\n .attr('y2', y(0))\n ;\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n });\n\n renderWatch.renderEnd('nv-boxplot chart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n boxplot.dispatch.on('elementMouseover.tooltip', function(evt) {\n tooltip.data(evt).hidden(false);\n });\n\n boxplot.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.data(evt).hidden(true);\n });\n\n boxplot.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.boxplot = boxplot;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n boxplot.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n boxplot.color(color);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( (_) ? 'right' : 'left');\n }}\n });\n\n nv.utils.inheritOptions(chart, boxplot);\n nv.utils.initOptions(chart);\n\n return chart;\n}\n", "\n// Chart design based on the recommendations of Stephen Few. Implementation\n// based on the work of Clint Ivy, Jamie Love, and Jason Davies.\n// http://projects.instantcognition.com/protovis/bulletchart/\n\nnv.models.bullet = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , orient = 'left' // TODO top & bottom\n , reverse = false\n , ranges = function(d) { return d.ranges }\n , markers = function(d) { return d.markers ? d.markers : [] }\n , markerLines = function(d) { return d.markerLines ? d.markerLines : [0] }\n , measures = function(d) { return d.measures }\n , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] }\n , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] }\n , markerLineLabels = function(d) { return d.markerLineLabels ? d.markerLineLabels : [] }\n , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] }\n , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)\n , width = 380\n , height = 30\n , container = null\n , tickFormat = null\n , color = nv.utils.getColor(['#1f77b4'])\n , dispatch = d3.dispatch('elementMouseover', 'elementMouseout', 'elementMousemove')\n , defaultRangeLabels = [\"Maximum\", \"Mean\", \"Minimum\"]\n , legacyRangeClassNames = [\"Max\", \"Avg\", \"Min\"]\n , duration = 1000\n ;\n\n function sortLabels(labels, values){\n var lz = labels.slice();\n labels.sort(function(a, b){\n var iA = lz.indexOf(a);\n var iB = lz.indexOf(b);\n return d3.descending(values[iA], values[iB]);\n });\n };\n\n function chart(selection) {\n selection.each(function(d, i) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n var rangez = ranges.call(this, d, i).slice(),\n markerz = markers.call(this, d, i).slice(),\n markerLinez = markerLines.call(this, d, i).slice(),\n measurez = measures.call(this, d, i).slice(),\n rangeLabelz = rangeLabels.call(this, d, i).slice(),\n markerLabelz = markerLabels.call(this, d, i).slice(),\n markerLineLabelz = markerLineLabels.call(this, d, i).slice(),\n measureLabelz = measureLabels.call(this, d, i).slice();\n\n // Sort labels according to their sorted values\n sortLabels(rangeLabelz, rangez);\n sortLabels(markerLabelz, markerz);\n sortLabels(markerLineLabelz, markerLinez);\n sortLabels(measureLabelz, measurez);\n\n // sort values descending\n rangez.sort(d3.descending);\n markerz.sort(d3.descending);\n markerLinez.sort(d3.descending);\n measurez.sort(d3.descending);\n\n // Setup Scales\n // Compute the new x-scale.\n var x1 = d3.scale.linear()\n .domain( d3.extent(d3.merge([forceX, rangez])) )\n .range(reverse ? [availableWidth, 0] : [0, availableWidth]);\n\n // Retrieve the old x-scale, if this is an update.\n var x0 = this.__chart__ || d3.scale.linear()\n .domain([0, Infinity])\n .range(x1.range());\n\n // Stash the new scale.\n this.__chart__ = x1;\n\n var rangeMin = d3.min(rangez), //rangez[2]\n rangeMax = d3.max(rangez), //rangez[0]\n rangeAvg = rangez[1];\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n for(var i=0,il=rangez.length; i getClose(d, i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i});\n\n var lines = tickGroups.append('line')\n .attr('class', 'nv-candlestick-lines')\n .attr('transform', function(d, i) { return 'translate(' + x(getX(d, i)) + ',0)'; })\n .attr('x1', 0)\n .attr('y1', function(d, i) { return y(getHigh(d, i)); })\n .attr('x2', 0)\n .attr('y2', function(d, i) { return y(getLow(d, i)); });\n\n var rects = tickGroups.append('rect')\n .attr('class', 'nv-candlestick-rects nv-bars')\n .attr('transform', function(d, i) {\n return 'translate(' + (x(getX(d, i)) - barWidth/2) + ','\n + (y(getY(d, i)) - (getOpen(d, i) > getClose(d, i) ? (y(getClose(d, i)) - y(getOpen(d, i))) : 0))\n + ')';\n })\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', barWidth)\n .attr('height', function(d, i) {\n var open = getOpen(d, i);\n var close = getClose(d, i);\n return open > close ? y(close) - y(open) : y(open) - y(close);\n });\n\n ticks.select('.nv-candlestick-lines').transition()\n .attr('transform', function(d, i) { return 'translate(' + x(getX(d, i)) + ',0)'; })\n .attr('x1', 0)\n .attr('y1', function(d, i) { return y(getHigh(d, i)); })\n .attr('x2', 0)\n .attr('y2', function(d, i) { return y(getLow(d, i)); });\n\n ticks.select('.nv-candlestick-rects').transition()\n .attr('transform', function(d, i) {\n return 'translate(' + (x(getX(d, i)) - barWidth/2) + ','\n + (y(getY(d, i)) - (getOpen(d, i) > getClose(d, i) ? (y(getClose(d, i)) - y(getOpen(d, i))) : 0))\n + ')';\n })\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', barWidth)\n .attr('height', function(d, i) {\n var open = getOpen(d, i);\n var close = getClose(d, i);\n return open > close ? y(close) - y(open) : y(open) - y(close);\n });\n });\n\n return chart;\n }\n\n\n //Create methods to allow outside functions to highlight a specific bar.\n chart.highlightPoint = function(pointIndex, isHoverOver) {\n chart.clearHighlights();\n container.select(\".nv-candlestickBar .nv-tick-0-\" + pointIndex)\n .classed(\"hover\", isHoverOver)\n ;\n };\n\n chart.clearHighlights = function() {\n container.select(\".nv-candlestickBar .nv-tick.hover\")\n .classed(\"hover\", false)\n ;\n };\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n padData: {get: function(){return padData;}, set: function(_){padData=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n open: {get: function(){return getOpen();}, set: function(_){getOpen=_;}},\n close: {get: function(){return getClose();}, set: function(_){getClose=_;}},\n high: {get: function(){return getHigh;}, set: function(_){getHigh=_;}},\n low: {get: function(){return getLow;}, set: function(_){getLow=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top != undefined ? _.top : margin.top;\n margin.right = _.right != undefined ? _.right : margin.right;\n margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n margin.left = _.left != undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n return chart;\n};\n", "\nnv.models.cumulativeLineChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var lines = nv.models.line()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend()\n , controls = nv.models.legend()\n , interactiveLayer = nv.interactiveGuideline()\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 30, right: 30, bottom: 50, left: 60}\n , marginTop = null\n , color = nv.utils.defaultColor()\n , width = null\n , height = null\n , showLegend = true\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , showControls = true\n , useInteractiveGuideline = false\n , rescaleY = true\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , id = lines.id()\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , average = function(d) { return d.average }\n , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n , transitionDuration = 250\n , duration = 250\n , noErrorCheck = false //if set to TRUE, will bypass an error check in the indexify function.\n ;\n\n state.index = 0;\n state.rescaleY = rescaleY;\n\n xAxis.orient('bottom').tickPadding(7);\n yAxis.orient((rightAlignYAxis) ? 'right' : 'left');\n\n tooltip.valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n }).headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n controls.updateState(false);\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var dx = d3.scale.linear()\n , index = {i: 0, x: 0}\n , renderWatch = nv.utils.renderWatch(dispatch, duration)\n , currentYDomain\n ;\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled }),\n index: index.i,\n rescaleY: rescaleY\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.index !== undefined)\n index.i = state.index;\n if (state.rescaleY !== undefined)\n rescaleY = state.rescaleY;\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(lines);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n container.classed('nv-chart-' + id, true);\n var that = this;\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() {\n if (duration === 0)\n container.call(chart);\n else\n container.transition().duration(duration).call(chart)\n };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disableddisabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n var indexDrag = d3.behavior.drag()\n .on('dragstart', dragStart)\n .on('drag', dragMove)\n .on('dragend', dragEnd);\n\n\n function dragStart(d,i) {\n d3.select(chart.container)\n .style('cursor', 'ew-resize');\n }\n\n function dragMove(d,i) {\n index.x = d3.event.x;\n index.i = Math.round(dx.invert(index.x));\n updateZero();\n }\n\n function dragEnd(d,i) {\n d3.select(chart.container)\n .style('cursor', 'auto');\n\n // update state and send stateChange with new index\n state.index = index.i;\n dispatch.stateChange(state);\n }\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = lines.xScale();\n y = lines.yScale();\n\n\n dx.domain([0, data[0].values.length - 1]) //Assumes all series have same length\n .range([0, availableWidth])\n .clamp(true);\n\n var data = indexify(index.i, data);\n\n // initialize the starting yDomain for the not-rescale case after indexify (to have calculated point.display)\n if (typeof(currentYDomain) === \"undefined\") {\n currentYDomain = getCurrentYDomain(data);\n }\n\n if (!rescaleY) {\n lines.yDomain(currentYDomain);\n lines.clipEdge(true);\n } else {\n lines.yDomain(null);\n }\n\n // Setup containers and skeleton of chart\n var interactivePointerEvents = (useInteractiveGuideline) ? \"none\" : \"all\";\n var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-interactive');\n gEnter.append('g').attr('class', 'nv-x nv-axis').style(\"pointer-events\",\"none\");\n gEnter.append('g').attr('class', 'nv-y nv-axis');\n gEnter.append('g').attr('class', 'nv-background');\n gEnter.append('g').attr('class', 'nv-linesWrap').style(\"pointer-events\",interactivePointerEvents);\n gEnter.append('g').attr('class', 'nv-avgLinesWrap').style(\"pointer-events\",\"none\");\n gEnter.append('g').attr('class', 'nv-legendWrap');\n gEnter.append('g').attr('class', 'nv-controlsWrap');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth);\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n }\n\n // Controls\n if (!showControls) {\n g.select('.nv-controlsWrap').selectAll('*').remove();\n } else {\n var controlsData = [\n { key: 'Re-scale y-axis', disabled: !rescaleY }\n ];\n\n controls\n .width(140)\n .color(['#444', '#444', '#444'])\n .rightAlign(false)\n .margin({top: 5, right: 0, bottom: 5, left: 20})\n ;\n\n g.select('.nv-controlsWrap')\n .datum(controlsData)\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n .call(controls);\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n // Show error if index point value is 0 (division by zero avoided)\n var tempDisabled = data.filter(function(d) { return d.tempDisabled });\n\n wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates\n if (tempDisabled.length) {\n wrap.append('text').attr('class', 'tempDisabled')\n .attr('x', availableWidth / 2)\n .attr('y', '-.71em')\n .style('text-anchor', 'end')\n .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.');\n }\n\n //Set up interactive layer\n if (useInteractiveGuideline) {\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left:margin.left,top:margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n\n gEnter.select('.nv-background')\n .append('rect');\n\n g.select('.nv-background rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n lines\n //.x(function(d) { return d.x })\n .y(function(d) { return d.display.y })\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; }));\n\n var linesWrap = g.select('.nv-linesWrap')\n .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled }));\n\n linesWrap.call(lines);\n\n //Store a series index number in the data array.\n data.forEach(function(d,i) {\n d.seriesIndex = i;\n });\n\n var avgLineData = data.filter(function(d) {\n return !d.disabled && !!average(d);\n });\n\n var avgLines = g.select(\".nv-avgLinesWrap\").selectAll(\"line\")\n .data(avgLineData, function(d) { return d.key; });\n\n var getAvgLineY = function(d) {\n //If average lines go off the svg element, clamp them to the svg bounds.\n var yVal = y(average(d));\n if (yVal < 0) return 0;\n if (yVal > availableHeight) return availableHeight;\n return yVal;\n };\n\n avgLines.enter()\n .append('line')\n .style('stroke-width',2)\n .style('stroke-dasharray','10,10')\n .style('stroke',function (d,i) {\n return lines.color()(d,d.seriesIndex);\n })\n .attr('x1',0)\n .attr('x2',availableWidth)\n .attr('y1', getAvgLineY)\n .attr('y2', getAvgLineY);\n\n avgLines\n .style('stroke-opacity',function(d){\n //If average lines go offscreen, make them transparent\n var yVal = y(average(d));\n if (yVal < 0 || yVal > availableHeight) return 0;\n return 1;\n })\n .attr('x1',0)\n .attr('x2',availableWidth)\n .attr('y1', getAvgLineY)\n .attr('y2', getAvgLineY);\n\n avgLines.exit().remove();\n\n //Create index line\n var indexLine = linesWrap.selectAll('.nv-indexLine')\n .data([index]);\n indexLine.enter().append('rect').attr('class', 'nv-indexLine')\n .attr('width', 3)\n .attr('x', -2)\n .attr('fill', 'red')\n .attr('fill-opacity', .5)\n .style(\"pointer-events\",\"all\")\n .call(indexDrag);\n\n indexLine\n .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' })\n .attr('height', availableHeight);\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/70, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')');\n g.select('.nv-x.nv-axis')\n .call(xAxis);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis')\n .call(yAxis);\n }\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n function updateZero() {\n indexLine\n .data([index]);\n\n //When dragging the index line, turn off line transitions.\n // Then turn them back on when done dragging.\n var oldDuration = chart.duration();\n chart.duration(0);\n chart.update();\n chart.duration(oldDuration);\n }\n\n g.select('.nv-background rect')\n .on('click', function() {\n index.x = d3.mouse(this)[0];\n index.i = Math.round(dx.invert(index.x));\n\n // update state and send stateChange with new index\n state.index = index.i;\n dispatch.stateChange(state);\n\n updateZero();\n });\n\n lines.dispatch.on('elementClick', function(e) {\n index.i = e.pointIndex;\n index.x = dx(index.i);\n\n // update state and send stateChange with new index\n state.index = index.i;\n dispatch.stateChange(state);\n\n updateZero();\n });\n\n controls.dispatch.on('legendClick', function(d,i) {\n d.disabled = !d.disabled;\n rescaleY = !d.disabled;\n state.rescaleY = rescaleY;\n if (!rescaleY) {\n currentYDomain = getCurrentYDomain(data); // rescale is turned off, so set the currentYDomain\n }\n dispatch.stateChange(state);\n chart.update();\n });\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n lines.clearHighlights();\n var singlePoint, pointIndex, pointXLocation, allData = [];\n\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !(series.disabled || series.tempDisabled);\n })\n .forEach(function(series,i) {\n pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n lines.highlightPoint(i, pointIndex, true);\n var point = series.values[pointIndex];\n if (typeof point === 'undefined') return;\n if (typeof singlePoint === 'undefined') singlePoint = point;\n if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n allData.push({\n key: series.key,\n value: chart.y()(point, pointIndex),\n color: color(series,series.seriesIndex)\n });\n });\n\n //Highlight the tooltip entry based on which point the mouse is closest to.\n if (allData.length > 2) {\n var yValue = chart.yScale().invert(e.mouseY);\n var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]);\n var threshold = 0.03 * domainExtent;\n var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold);\n if (indexToHighlight !== null)\n allData[indexToHighlight].highlight = true;\n }\n\n var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex);\n interactiveLayer.tooltip\n .valueFormatter(function(d,i) {\n return yAxis.tickFormat()(d);\n })\n .data(\n {\n value: xValue,\n series: allData\n }\n )();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n lines.clearHighlights();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n\n state.disabled = e.disabled;\n }\n\n if (typeof e.index !== 'undefined') {\n index.i = e.index;\n index.x = dx(index.i);\n\n state.index = e.index;\n\n indexLine\n .data([index]);\n }\n\n if (typeof e.rescaleY !== 'undefined') {\n rescaleY = e.rescaleY;\n }\n\n chart.update();\n });\n\n });\n\n renderWatch.renderEnd('cumulativeLineChart immediate');\n\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n var point = {\n x: chart.x()(evt.point),\n y: chart.y()(evt.point),\n color: evt.point.color\n };\n evt.point = point;\n tooltip.data(evt).hidden(false);\n });\n\n lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n //============================================================\n // Functions\n //------------------------------------------------------------\n\n var indexifyYGetter = null;\n /* Normalize the data according to an index point. */\n function indexify(idx, data) {\n if (!indexifyYGetter) indexifyYGetter = lines.y();\n return data.map(function(line, i) {\n if (!line.values) {\n return line;\n }\n var indexValue = line.values[idx];\n if (indexValue == null) {\n return line;\n }\n var v = indexifyYGetter(indexValue, idx);\n\n // avoid divide by zero\n if (Math.abs(v) < 0.00001 && !noErrorCheck) {\n line.tempDisabled = true;\n return line;\n }\n\n line.tempDisabled = false;\n\n line.values = line.values.map(function(point, pointIndex) {\n point.display = {'y': (indexifyYGetter(point, pointIndex) - v) / v };\n return point;\n });\n\n return line;\n })\n }\n\n function getCurrentYDomain(data) {\n var seriesDomains = data\n .filter(function(series) { return !(series.disabled || series.tempDisabled)})\n .map(function(series,i) {\n return d3.extent(series.values, function (d) { return d.display.y });\n });\n\n return [\n d3.min(seriesDomains, function(d) { return d[0] }),\n d3.max(seriesDomains, function(d) { return d[1] })\n ];\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.lines = lines;\n chart.legend = legend;\n chart.controls = controls;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.interactiveLayer = interactiveLayer;\n chart.state = state;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n average: {get: function(){return average;}, set: function(_){average=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n noErrorCheck: {get: function(){return noErrorCheck;}, set: function(_){noErrorCheck=_;}},\n\n // options that require extra logic in the setter\n rescaleY: {get: function(){return rescaleY;}, set: function(_){\n rescaleY = _;\n chart.state.rescaleY = _; // also update state\n }},\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n }},\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = _;\n if (_ === true) {\n chart.interactive(false);\n chart.useVoronoi(false);\n }\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( (_) ? 'right' : 'left');\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n lines.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n renderWatch.reset(duration);\n }}\n });\n\n nv.utils.inheritOptions(chart, lines);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "//TODO: consider deprecating by adding necessary features to multiBar model\nnv.models.discreteBar = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 960\n , height = 500\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container\n , x = d3.scale.ordinal()\n , y = d3.scale.linear()\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n , color = nv.utils.defaultColor()\n , showValues = false\n , valueFormat = d3.format(',.2f')\n , xDomain\n , yDomain\n , xRange\n , yRange\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n , rectClass = 'discreteBar'\n , duration = 250\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0;\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n //add series index to each data point for reference\n data.forEach(function(series, i) {\n series.values.forEach(function(point) {\n point.series = i;\n });\n });\n\n // Setup Scales\n // remap and flatten the data for use in calculating the scales' domains\n var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n data.map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i), y0: d.y0 }\n })\n });\n\n x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n .rangeBands(xRange || [0, availableWidth], .1);\n y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY)));\n\n // If showValues, pad the Y axis range to account for label height\n if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]);\n else y.range(yRange || [availableHeight, 0]);\n\n //store old scales if they exist\n x0 = x0 || x;\n y0 = y0 || y.copy().range([y(0),y(0)]);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-groups');\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later\n var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n .data(function(d) { return d }, function(d) { return d.key });\n groups.enter().append('g')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6);\n groups.exit()\n .watchTransition(renderWatch, 'discreteBar: exit groups')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6)\n .remove();\n groups\n .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n .classed('hover', function(d) { return d.hover });\n groups\n .watchTransition(renderWatch, 'discreteBar: groups')\n .style('stroke-opacity', 1)\n .style('fill-opacity', .75);\n\n var bars = groups.selectAll('g.nv-bar')\n .data(function(d) { return d.values });\n bars.exit().remove();\n\n var barsEnter = bars.enter().append('g')\n .attr('transform', function(d,i,j) {\n return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')'\n })\n .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mouseout', function(d,i) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mousemove', function(d,i) {\n dispatch.elementMousemove({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('click', function(d,i) {\n var element = this;\n dispatch.elementClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\"),\n event: d3.event,\n element: element\n });\n d3.event.stopPropagation();\n })\n .on('dblclick', function(d,i) {\n dispatch.elementDblClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n d3.event.stopPropagation();\n });\n\n barsEnter.append('rect')\n .attr('height', 0)\n .attr('width', x.rangeBand() * .9 / data.length )\n\n if (showValues) {\n barsEnter.append('text')\n .attr('text-anchor', 'middle')\n ;\n\n bars.select('text')\n .text(function(d,i) { return valueFormat(getY(d,i)) })\n .watchTransition(renderWatch, 'discreteBar: bars text')\n .attr('x', x.rangeBand() * .9 / 2)\n .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 })\n\n ;\n } else {\n bars.selectAll('text').remove();\n }\n\n bars\n .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' })\n .style('fill', function(d,i) { return d.color || color(d,i) })\n .style('stroke', function(d,i) { return d.color || color(d,i) })\n .select('rect')\n .attr('class', rectClass)\n .watchTransition(renderWatch, 'discreteBar: bars rect')\n .attr('width', x.rangeBand() * .9 / data.length);\n bars.watchTransition(renderWatch, 'discreteBar: bars')\n //.delay(function(d,i) { return i * 1200 / data[0].values.length })\n .attr('transform', function(d,i) {\n var left = x(getX(d,i)) + x.rangeBand() * .05,\n top = getY(d,i) < 0 ?\n y(0) :\n y(0) - y(getY(d,i)) < 1 ?\n y(0) - 1 : //make 1 px positive bars show up above y=0\n y(getY(d,i));\n\n return 'translate(' + left + ', ' + top + ')'\n })\n .select('rect')\n .attr('height', function(d,i) {\n return Math.max(Math.abs(y(getY(d,i)) - y(0)), 1)\n });\n\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n\n });\n\n renderWatch.renderEnd('discreteBar immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n rectClass: {get: function(){return rectClass;}, set: function(_){rectClass=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.discreteBarChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var discretebar = nv.models.discreteBar()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n\t, legend = nv.models.legend()\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 15, right: 10, bottom: 50, left: 60}\n , marginTop = null\n , width = null\n , height = null\n , color = nv.utils.getColor()\n\t, showLegend = false\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , staggerLabels = false\n , wrapLabels = false\n , rotateLabels = 0\n , x\n , y\n , noData = null\n , dispatch = d3.dispatch('beforeUpdate','renderEnd')\n , duration = 250\n ;\n\n xAxis\n .orient('bottom')\n .showMaxMin(false)\n .tickFormat(function(d) { return d })\n ;\n yAxis\n .orient((rightAlignYAxis) ? 'right' : 'left')\n .tickFormat(d3.format(',.1f'))\n ;\n\n tooltip\n .duration(0)\n .headerEnabled(false)\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n })\n .keyFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(discretebar);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() {\n dispatch.beforeUpdate();\n container.transition().duration(duration).call(chart);\n };\n chart.container = this;\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = discretebar.xScale();\n y = discretebar.yScale().clamp(true);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g');\n var defsEnter = gEnter.append('defs');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis')\n .append('g').attr('class', 'nv-zeroLine')\n .append('line');\n\n gEnter.append('g').attr('class', 'nv-barsWrap');\n\t gEnter.append('g').attr('class', 'nv-legendWrap');\n\n g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth);\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n }\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n // Main Chart Component(s)\n discretebar\n .width(availableWidth)\n .height(availableHeight);\n\n var barsWrap = g.select('.nv-barsWrap')\n .datum(data.filter(function(d) { return !d.disabled }));\n\n barsWrap.transition().call(discretebar);\n\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-x-label-clip-' + discretebar.id())\n .append('rect');\n\n g.select('#nv-x-label-clip-' + discretebar.id() + ' rect')\n .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))\n .attr('height', 16)\n .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')');\n g.select('.nv-x.nv-axis').call(xAxis);\n\n var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n if (staggerLabels) {\n xTicks\n .selectAll('text')\n .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })\n }\n\n if (rotateLabels) {\n xTicks\n .selectAll('.tick text')\n .attr('transform', 'rotate(' + rotateLabels + ' 0,0)')\n .style('text-anchor', rotateLabels > 0 ? 'start' : 'end');\n }\n\n if (wrapLabels) {\n g.selectAll('.tick text')\n .call(nv.utils.wrapTicks, chart.xAxis.rangeBand())\n }\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis').call(yAxis);\n }\n\n // Zero line\n g.select(\".nv-zeroLine line\")\n .attr(\"x1\",0)\n .attr(\"x2\",(rightAlignYAxis) ? -availableWidth : availableWidth)\n .attr(\"y1\", y(0))\n .attr(\"y2\", y(0))\n ;\n });\n\n renderWatch.renderEnd('discreteBar chart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n discretebar.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt['series'] = {\n key: chart.x()(evt.data),\n value: chart.y()(evt.data),\n color: evt.color\n };\n tooltip.data(evt).hidden(false);\n });\n\n discretebar.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n discretebar.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.discretebar = discretebar;\n chart.legend = legend;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n\tshowLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n rotateLabels: {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n wrapLabels: {get: function(){return wrapLabels;}, set: function(_){wrapLabels=!!_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n discretebar.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n discretebar.color(color);\n\t legend.color(color);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( (_) ? 'right' : 'left');\n }}\n });\n\n nv.utils.inheritOptions(chart, discretebar);\n nv.utils.initOptions(chart);\n\n return chart;\n}\n", "\nnv.models.distribution = function() {\n \"use strict\";\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 400 //technically width or height depending on x or y....\n , size = 8\n , axis = 'x' // 'x' or 'y'... horizontal or vertical\n , getData = function(d) { return d[axis] } // defaults d.x or d.y\n , color = nv.utils.defaultColor()\n , scale = d3.scale.linear()\n , domain\n , duration = 250\n , dispatch = d3.dispatch('renderEnd')\n ;\n\n //============================================================\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var scale0;\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n //============================================================\n\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom),\n naxis = axis == 'x' ? 'y' : 'x',\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n //------------------------------------------------------------\n // Setup Scales\n\n scale0 = scale0 || scale;\n\n //------------------------------------------------------------\n\n\n //------------------------------------------------------------\n // Setup containers and skeleton of chart\n\n var wrap = container.selectAll('g.nv-distribution').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')\n\n //------------------------------------------------------------\n\n\n var distWrap = g.selectAll('g.nv-dist')\n .data(function(d) { return d }, function(d) { return d.key });\n\n distWrap.enter().append('g');\n distWrap\n .attr('class', function(d,i) { return 'nv-dist nv-series-' + i })\n .style('stroke', function(d,i) { return color(d, i) });\n\n var dist = distWrap.selectAll('line.nv-dist' + axis)\n .data(function(d) { return d.values })\n dist.enter().append('line')\n .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) })\n .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) })\n renderWatch.transition(distWrap.exit().selectAll('line.nv-dist' + axis), 'dist exit')\n // .transition()\n .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })\n .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })\n .style('stroke-opacity', 0)\n .remove();\n dist\n .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i })\n .attr(naxis + '1', 0)\n .attr(naxis + '2', size);\n renderWatch.transition(dist, 'dist')\n // .transition()\n .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })\n .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })\n\n\n scale0 = scale.copy();\n\n });\n renderWatch.renderEnd('distribution immediate');\n return chart;\n }\n\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n chart.options = nv.utils.optionsFunc.bind(chart);\n chart.dispatch = dispatch;\n\n chart.margin = function(_) {\n if (!arguments.length) return margin;\n margin.top = typeof _.top != 'undefined' ? _.top : margin.top;\n margin.right = typeof _.right != 'undefined' ? _.right : margin.right;\n margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;\n margin.left = typeof _.left != 'undefined' ? _.left : margin.left;\n return chart;\n };\n\n chart.width = function(_) {\n if (!arguments.length) return width;\n width = _;\n return chart;\n };\n\n chart.axis = function(_) {\n if (!arguments.length) return axis;\n axis = _;\n return chart;\n };\n\n chart.size = function(_) {\n if (!arguments.length) return size;\n size = _;\n return chart;\n };\n\n chart.getData = function(_) {\n if (!arguments.length) return getData;\n getData = d3.functor(_);\n return chart;\n };\n\n chart.scale = function(_) {\n if (!arguments.length) return scale;\n scale = _;\n return chart;\n };\n\n chart.color = function(_) {\n if (!arguments.length) return color;\n color = nv.utils.getColor(_);\n return chart;\n };\n\n chart.duration = function(_) {\n if (!arguments.length) return duration;\n duration = _;\n renderWatch.reset(duration);\n return chart;\n };\n //============================================================\n\n\n return chart;\n}\n", "nv.models.focus = function(content) {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var content = content || nv.models.line()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , brush = d3.svg.brush()\n ;\n\n var margin = {top: 10, right: 0, bottom: 30, left: 0}\n , color = nv.utils.defaultColor()\n , width = null\n , height = 70\n , showXAxis = true\n , showYAxis = false\n , rightAlignYAxis = false\n , ticks = null\n , x\n , y\n , brushExtent = null\n , duration = 250\n , dispatch = d3.dispatch('brush', 'onBrush', 'renderEnd')\n , syncBrushing = true\n ;\n\n content.interactive(false);\n content.pointActive(function(d) { return false; });\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(content);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = height - margin.top - margin.bottom;\n\n chart.update = function() { \n if( duration === 0 ) {\n container.call( chart );\n } else {\n container.transition().duration(duration).call(chart);\n }\n };\n chart.container = this;\n\n // Setup Scales\n x = content.xScale();\n y = content.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-focus').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-focus').append('g');\n var g = wrap.select('g');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n gEnter.append('g').attr('class', 'nv-background').append('rect');\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis');\n gEnter.append('g').attr('class', 'nv-contentWrap');\n gEnter.append('g').attr('class', 'nv-brushBackground');\n gEnter.append('g').attr('class', 'nv-x nv-brush');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n g.select('.nv-background rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n \n content\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled; }));\n\n var contentWrap = g.select('.nv-contentWrap')\n .datum(data.filter(function(d) { return !d.disabled; }));\n\n d3.transition(contentWrap).call(content);\n \n // Setup Brush\n brush\n .x(x)\n .on('brush', function() {\n onBrush(syncBrushing);\n });\n\n brush.on('brushend', function () {\n if (!syncBrushing) {\n dispatch.onBrush(brush.empty() ? x.domain() : brush.extent());\n }\n });\n\n if (brushExtent) brush.extent(brushExtent);\n\n var brushBG = g.select('.nv-brushBackground').selectAll('g')\n .data([brushExtent || brush.extent()]);\n \n var brushBGenter = brushBG.enter()\n .append('g');\n\n brushBGenter.append('rect')\n .attr('class', 'left')\n .attr('x', 0)\n .attr('y', 0)\n .attr('height', availableHeight);\n\n brushBGenter.append('rect')\n .attr('class', 'right')\n .attr('x', 0)\n .attr('y', 0)\n .attr('height', availableHeight);\n\n var gBrush = g.select('.nv-x.nv-brush')\n .call(brush);\n gBrush.selectAll('rect')\n .attr('height', availableHeight);\n gBrush.selectAll('.resize').append('path').attr('d', resizePath);\n\n onBrush(true);\n\n g.select('.nv-background rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n if (showXAxis) {\n xAxis.scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n \n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')');\n d3.transition(g.select('.nv-x.nv-axis'))\n .call(xAxis);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n d3.transition(g.select('.nv-y.nv-axis'))\n .call(yAxis);\n }\n \n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')');\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n //============================================================\n // Functions\n //------------------------------------------------------------\n \n // Taken from crossfilter (http://square.github.com/crossfilter/)\n function resizePath(d) {\n var e = +(d == 'e'),\n x = e ? 1 : -1,\n y = availableHeight / 3;\n return 'M' + (0.5 * x) + ',' + y\n + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6)\n + 'V' + (2 * y - 6)\n + 'A6,6 0 0 ' + e + ' ' + (0.5 * x) + ',' + (2 * y)\n + 'Z'\n + 'M' + (2.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8)\n + 'M' + (4.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8);\n }\n \n \n function updateBrushBG() {\n if (!brush.empty()) brush.extent(brushExtent);\n brushBG\n .data([brush.empty() ? x.domain() : brushExtent])\n .each(function(d,i) {\n var leftWidth = x(d[0]) - x.range()[0],\n rightWidth = availableWidth - x(d[1]);\n d3.select(this).select('.left')\n .attr('width', leftWidth < 0 ? 0 : leftWidth);\n \n d3.select(this).select('.right')\n .attr('x', x(d[1]))\n .attr('width', rightWidth < 0 ? 0 : rightWidth);\n });\n }\n\n\n function onBrush(shouldDispatch) {\n brushExtent = brush.empty() ? null : brush.extent();\n var extent = brush.empty() ? x.domain() : brush.extent();\n dispatch.brush({extent: extent, brush: brush});\n updateBrushBG();\n if (shouldDispatch) {\n dispatch.onBrush(extent);\n }\n }\n });\n\n renderWatch.renderEnd('focus immediate');\n return chart;\n }\n\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.content = content;\n chart.brush = brush;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n brushExtent: {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}},\n syncBrushing: {get: function(){return syncBrushing;}, set: function(_){syncBrushing=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n content.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n content.color(color);\n }},\n interpolate: {get: function(){return content.interpolate();}, set: function(_){\n content.interpolate(_);\n }},\n xTickFormat: {get: function(){return xAxis.tickFormat();}, set: function(_){\n xAxis.tickFormat(_);\n }},\n yTickFormat: {get: function(){return yAxis.tickFormat();}, set: function(_){\n yAxis.tickFormat(_);\n }},\n x: {get: function(){return content.x();}, set: function(_){\n content.x(_);\n }},\n y: {get: function(){return content.y();}, set: function(_){\n content.y(_);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n }}\n });\n\n nv.utils.inheritOptions(chart, content);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "nv.models.forceDirectedGraph = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n var margin = {top: 2, right: 0, bottom: 2, left: 0}\n , width = 400\n , height = 32\n , container = null\n , dispatch = d3.dispatch('renderEnd')\n , color = nv.utils.getColor(['#000'])\n , tooltip = nv.models.tooltip()\n , noData = null\n // Force directed graph specific parameters [default values]\n , linkStrength = 0.1\n , friction = 0.9\n , linkDist = 30\n , charge = -120\n , gravity = 0.1\n , theta = 0.8\n , alpha = 0.1\n , radius = 5\n // These functions allow to add extra attributes to ndes and links\n ,nodeExtras = function(nodes) { /* Do nothing */ }\n ,linkExtras = function(links) { /* Do nothing */ }\n , getX=d3.functor(0.0)\n , getY=d3.functor(0.0)\n ;\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n function chart(selection) {\n renderWatch.reset();\n\n selection.each(function(data) {\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n container\n .attr(\"width\", availableWidth)\n .attr(\"height\", availableHeight);\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.links || !data.nodes) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n container.selectAll('*').remove();\n\n // Collect names of all fields in the nodes\n var nodeFieldSet = new Set();\n data.nodes.forEach(function(node) {\n var keys = Object.keys(node);\n keys.forEach(function(key) {\n nodeFieldSet.add(key);\n });\n });\n\n var force = d3.layout.force()\n .nodes(data.nodes)\n .links(data.links)\n .size([availableWidth, availableHeight])\n .linkStrength(linkStrength)\n .friction(friction)\n .linkDistance(linkDist)\n .charge(charge)\n .gravity(gravity)\n .theta(theta)\n .alpha(alpha)\n .start();\n\n var link = container.selectAll(\".link\")\n .data(data.links)\n .enter().append(\"line\")\n .attr(\"class\", \"nv-force-link\")\n .style(\"stroke-width\", function(d) { return Math.sqrt(d.value); });\n\n var node = container.selectAll(\".node\")\n .data(data.nodes)\n .enter()\n .append(\"g\")\n .attr(\"class\", \"nv-force-node\")\n .call(force.drag);\n\n node\n .append(\"circle\")\n .attr(\"r\", radius)\n .style(\"fill\", function(d) { return color(d) } )\n .on(\"mouseover\", function(evt) {\n container.select('.nv-series-' + evt.seriesIndex + ' .nv-distx-' + evt.pointIndex)\n .attr('y1', evt.py);\n container.select('.nv-series-' + evt.seriesIndex + ' .nv-disty-' + evt.pointIndex)\n .attr('x2', evt.px);\n\n // Add 'series' object to\n var nodeColor = color(evt);\n evt.series = [];\n nodeFieldSet.forEach(function(field) {\n evt.series.push({\n color: nodeColor,\n key: field,\n value: evt[field]\n });\n });\n tooltip.data(evt).hidden(false);\n })\n .on(\"mouseout\", function(d) {\n tooltip.hidden(true);\n });\n\n tooltip.headerFormatter(function(d) {return \"Node\";});\n\n // Apply extra attributes to nodes and links (if any)\n linkExtras(link);\n nodeExtras(node);\n\n force.on(\"tick\", function() {\n link.attr(\"x1\", function(d) { return d.source.x; })\n .attr(\"y1\", function(d) { return d.source.y; })\n .attr(\"x2\", function(d) { return d.target.x; })\n .attr(\"y2\", function(d) { return d.target.y; });\n\n node.attr(\"transform\", function(d) {\n return \"translate(\" + d.x + \", \" + d.y + \")\";\n });\n });\n });\n\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n\n // Force directed graph specific parameters\n linkStrength:{get: function(){return linkStrength;}, set: function(_){linkStrength=_;}},\n friction: {get: function(){return friction;}, set: function(_){friction=_;}},\n linkDist: {get: function(){return linkDist;}, set: function(_){linkDist=_;}},\n charge: {get: function(){return charge;}, set: function(_){charge=_;}},\n gravity: {get: function(){return gravity;}, set: function(_){gravity=_;}},\n theta: {get: function(){return theta;}, set: function(_){theta=_;}},\n alpha: {get: function(){return alpha;}, set: function(_){alpha=_;}},\n radius: {get: function(){return radius;}, set: function(_){radius=_;}},\n\n //functor options\n x: {get: function(){return getX;}, set: function(_){getX=d3.functor(_);}},\n y: {get: function(){return getY;}, set: function(_){getY=d3.functor(_);}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n nodeExtras: {get: function(){return nodeExtras;}, set: function(_){\n nodeExtras = _;\n }},\n linkExtras: {get: function(){return linkExtras;}, set: function(_){\n linkExtras = _;\n }}\n });\n\n chart.dispatch = dispatch;\n chart.tooltip = tooltip;\n nv.utils.initOptions(chart);\n return chart;\n};\n", "nv.models.furiousLegend = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 5, right: 0, bottom: 5, left: 0}\n , width = 400\n , height = 20\n , getKey = function(d) { return d.key }\n , keyFormatter = function (d) { return d }\n , color = nv.utils.getColor()\n , maxKeyLength = 20 //default value for key lengths\n , align = true\n , padding = 28 //define how much space between legend items. - recommend 32 for furious version\n , rightAlign = true\n , updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch.\n , radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time)\n , expanded = false\n , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange')\n , vers = 'classic' //Options are \"classic\" and \"furious\"\n ;\n\n function chart(selection) {\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-legend').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g');\n var g = wrap.select('g');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n var series = g.selectAll('.nv-series')\n .data(function(d) {\n if(vers != 'furious') return d;\n\n return d.filter(function(n) {\n return expanded ? true : !n.disengaged;\n });\n });\n var seriesEnter = series.enter().append('g').attr('class', 'nv-series')\n\n var seriesShape;\n\n if(vers == 'classic') {\n seriesEnter.append('circle')\n .style('stroke-width', 2)\n .attr('class','nv-legend-symbol')\n .attr('r', 5);\n\n seriesShape = series.select('circle');\n } else if (vers == 'furious') {\n seriesEnter.append('rect')\n .style('stroke-width', 2)\n .attr('class','nv-legend-symbol')\n .attr('rx', 3)\n .attr('ry', 3);\n\n seriesShape = series.select('rect');\n\n seriesEnter.append('g')\n .attr('class', 'nv-check-box')\n .property('innerHTML','')\n .attr('transform', 'translate(-10,-8)scale(0.5)');\n\n var seriesCheckbox = series.select('.nv-check-box');\n\n seriesCheckbox.each(function(d,i) {\n d3.select(this).selectAll('path')\n .attr('stroke', setTextColor(d,i));\n });\n }\n\n seriesEnter.append('text')\n .attr('text-anchor', 'start')\n .attr('class','nv-legend-text')\n .attr('dy', '.32em')\n .attr('dx', '8');\n\n var seriesText = series.select('text.nv-legend-text');\n\n series\n .on('mouseover', function(d,i) {\n dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects\n })\n .on('mouseout', function(d,i) {\n dispatch.legendMouseout(d,i);\n })\n .on('click', function(d,i) {\n dispatch.legendClick(d,i);\n // make sure we re-get data in case it was modified\n var data = series.data();\n if (updateState) {\n if(vers =='classic') {\n if (radioButtonMode) {\n //Radio button mode: set every series to disabled,\n // and enable the clicked series.\n data.forEach(function(series) { series.disabled = true});\n d.disabled = false;\n }\n else {\n d.disabled = !d.disabled;\n if (data.every(function(series) { return series.disabled})) {\n //the default behavior of NVD3 legends is, if every single series\n // is disabled, turn all series' back on.\n data.forEach(function(series) { series.disabled = false});\n }\n }\n } else if(vers == 'furious') {\n if(expanded) {\n d.disengaged = !d.disengaged;\n d.userDisabled = d.userDisabled == undefined ? !!d.disabled : d.userDisabled;\n d.disabled = d.disengaged || d.userDisabled;\n } else if (!expanded) {\n d.disabled = !d.disabled;\n d.userDisabled = d.disabled;\n var engaged = data.filter(function(d) { return !d.disengaged; });\n if (engaged.every(function(series) { return series.userDisabled })) {\n //the default behavior of NVD3 legends is, if every single series\n // is disabled, turn all series' back on.\n data.forEach(function(series) {\n series.disabled = series.userDisabled = false;\n });\n }\n }\n }\n dispatch.stateChange({\n disabled: data.map(function(d) { return !!d.disabled }),\n disengaged: data.map(function(d) { return !!d.disengaged })\n });\n\n }\n })\n .on('dblclick', function(d,i) {\n if(vers == 'furious' && expanded) return;\n dispatch.legendDblclick(d,i);\n if (updateState) {\n // make sure we re-get data in case it was modified\n var data = series.data();\n //the default behavior of NVD3 legends, when double clicking one,\n // is to set all other series' to false, and make the double clicked series enabled.\n data.forEach(function(series) {\n series.disabled = true;\n if(vers == 'furious') series.userDisabled = series.disabled;\n });\n d.disabled = false;\n if(vers == 'furious') d.userDisabled = d.disabled;\n dispatch.stateChange({\n disabled: data.map(function(d) { return !!d.disabled })\n });\n }\n });\n\n series.classed('nv-disabled', function(d) { return d.userDisabled });\n series.exit().remove();\n\n seriesText\n .attr('fill', setTextColor)\n .text(function (d) { return keyFormatter(getKey(d)) });\n\n //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option)\n // NEW ALIGNING CODE, TODO: clean up\n\n var versPadding;\n switch(vers) {\n case 'furious' :\n versPadding = 23;\n break;\n case 'classic' :\n versPadding = 20;\n }\n\n if (align) {\n\n var seriesWidths = [];\n series.each(function(d,i) {\n var legendText;\n if (keyFormatter(getKey(d)) && keyFormatter(getKey(d)).length > maxKeyLength) {\n var trimmedKey = keyFormatter(getKey(d)).substring(0, maxKeyLength);\n legendText = d3.select(this).select('text').text(trimmedKey + \"...\");\n d3.select(this).append(\"svg:title\").text(keyFormatter(getKey(d)));\n } else {\n legendText = d3.select(this).select('text');\n }\n var nodeTextLength;\n try {\n nodeTextLength = legendText.node().getComputedTextLength();\n // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead\n if(nodeTextLength <= 0) throw Error();\n }\n catch(e) {\n nodeTextLength = nv.utils.calcApproxTextWidth(legendText);\n }\n\n seriesWidths.push(nodeTextLength + padding);\n });\n\n var seriesPerRow = 0;\n var legendWidth = 0;\n var columnWidths = [];\n\n while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) {\n columnWidths[seriesPerRow] = seriesWidths[seriesPerRow];\n legendWidth += seriesWidths[seriesPerRow++];\n }\n if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row\n\n while ( legendWidth > availableWidth && seriesPerRow > 1 ) {\n columnWidths = [];\n seriesPerRow--;\n\n for (var k = 0; k < seriesWidths.length; k++) {\n if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) )\n columnWidths[k % seriesPerRow] = seriesWidths[k];\n }\n\n legendWidth = columnWidths.reduce(function(prev, cur, index, array) {\n return prev + cur;\n });\n }\n\n var xPositions = [];\n for (var i = 0, curX = 0; i < seriesPerRow; i++) {\n xPositions[i] = curX;\n curX += columnWidths[i];\n }\n\n series\n .attr('transform', function(d, i) {\n return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * versPadding) + ')';\n });\n\n //position legend as far right as possible within the total width\n if (rightAlign) {\n g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')');\n }\n else {\n g.attr('transform', 'translate(0' + ',' + margin.top + ')');\n }\n\n height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * versPadding);\n\n } else {\n\n var ypos = 5,\n newxpos = 5,\n maxwidth = 0,\n xpos;\n series\n .attr('transform', function(d, i) {\n var length = d3.select(this).select('text').node().getComputedTextLength() + padding;\n xpos = newxpos;\n\n if (width < margin.left + margin.right + xpos + length) {\n newxpos = xpos = 5;\n ypos += versPadding;\n }\n\n newxpos += length;\n if (newxpos > maxwidth) maxwidth = newxpos;\n\n return 'translate(' + xpos + ',' + ypos + ')';\n });\n\n //position legend as far right as possible within the total width\n g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')');\n\n height = margin.top + margin.bottom + ypos + 15;\n }\n\n if(vers == 'furious') {\n // Size rectangles after text is placed\n seriesShape\n .attr('width', function(d,i) {\n return seriesText[0][i].getComputedTextLength() + 27;\n })\n .attr('height', 18)\n .attr('y', -9)\n .attr('x', -15)\n }\n\n seriesShape\n .style('fill', setBGColor)\n .style('stroke', function(d,i) { return d.color || color(d, i) });\n });\n\n function setTextColor(d,i) {\n if(vers != 'furious') return '#000';\n if(expanded) {\n return d.disengaged ? color(d,i) : '#fff';\n } else if (!expanded) {\n return !!d.disabled ? color(d,i) : '#fff';\n }\n }\n\n function setBGColor(d,i) {\n if(expanded && vers == 'furious') {\n return d.disengaged ? '#fff' : color(d,i);\n } else {\n return !!d.disabled ? '#fff' : color(d,i);\n }\n }\n\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n key: {get: function(){return getKey;}, set: function(_){getKey=_;}},\n keyFormatter: {get: function(){return keyFormatter;}, set: function(_){keyFormatter=_;}},\n align: {get: function(){return align;}, set: function(_){align=_;}},\n rightAlign: {get: function(){return rightAlign;}, set: function(_){rightAlign=_;}},\n maxKeyLength: {get: function(){return maxKeyLength;}, set: function(_){maxKeyLength=_;}},\n padding: {get: function(){return padding;}, set: function(_){padding=_;}},\n updateState: {get: function(){return updateState;}, set: function(_){updateState=_;}},\n radioButtonMode:{get: function(){return radioButtonMode;}, set: function(_){radioButtonMode=_;}},\n expanded: {get: function(){return expanded;}, set: function(_){expanded=_;}},\n vers: {get: function(){return vers;}, set: function(_){vers=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "//TODO: consider deprecating and using multibar with single series for this\nnv.models.historicalBar = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = null\n , height = null\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , x = d3.scale.linear()\n , y = d3.scale.linear()\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , forceX = []\n , forceY = [0]\n , padData = false\n , clipEdge = true\n , color = nv.utils.defaultColor()\n , xDomain\n , yDomain\n , xRange\n , yRange\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n , interactive = true\n ;\n\n var renderWatch = nv.utils.renderWatch(dispatch, 0);\n\n function chart(selection) {\n selection.each(function(data) {\n renderWatch.reset();\n\n container = d3.select(this);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n nv.utils.initSVG(container);\n\n // Setup Scales\n x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ));\n\n if (padData)\n x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]);\n else\n x.range(xRange || [0, availableWidth]);\n\n y.domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) ))\n .range(yRange || [availableHeight, 0]);\n\n // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n if (x.domain()[0] === x.domain()[1])\n x.domain()[0] ?\n x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n : x.domain([-1,1]);\n\n if (y.domain()[0] === y.domain()[1])\n y.domain()[0] ?\n y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n : y.domain([-1,1]);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id);\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-bars');\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n container\n .on('click', function(d,i) {\n dispatch.chartClick({\n data: d,\n index: i,\n pos: d3.event,\n id: id\n });\n });\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-chart-clip-path-' + id)\n .append('rect');\n\n wrap.select('#nv-chart-clip-path-' + id + ' rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n g.attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');\n\n var bars = wrap.select('.nv-bars').selectAll('.nv-bar')\n .data(function(d) { return d }, function(d,i) {return getX(d,i)});\n bars.exit().remove();\n\n bars.enter().append('rect')\n .attr('x', 0 )\n .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) })\n .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) })\n .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })\n .on('mouseover', function(d,i) {\n if (!interactive) return;\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n\n })\n .on('mouseout', function(d,i) {\n if (!interactive) return;\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mousemove', function(d,i) {\n if (!interactive) return;\n dispatch.elementMousemove({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('click', function(d,i) {\n if (!interactive) return;\n var element = this;\n dispatch.elementClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\"),\n event: d3.event,\n element: element\n });\n d3.event.stopPropagation();\n })\n .on('dblclick', function(d,i) {\n if (!interactive) return;\n dispatch.elementDblClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n d3.event.stopPropagation();\n });\n\n bars\n .attr('fill', function(d,i) { return color(d, i); })\n .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i })\n .watchTransition(renderWatch, 'bars')\n .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })\n //TODO: better width calculations that don't assume always uniform data spacing;w\n .attr('width', (availableWidth / data[0].values.length) * .9 );\n\n bars.watchTransition(renderWatch, 'bars')\n .attr('y', function(d,i) {\n var rval = getY(d,i) < 0 ?\n y(0) :\n y(0) - y(getY(d,i)) < 1 ?\n y(0) - 1 :\n y(getY(d,i));\n return nv.utils.NaNtoZero(rval);\n })\n .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) });\n\n });\n\n renderWatch.renderEnd('historicalBar immediate');\n return chart;\n }\n\n //Create methods to allow outside functions to highlight a specific bar.\n chart.highlightPoint = function(pointIndex, isHoverOver) {\n container\n .select(\".nv-bars .nv-bar-0-\" + pointIndex)\n .classed(\"hover\", isHoverOver)\n ;\n };\n\n chart.clearHighlights = function() {\n container\n .select(\".nv-bars .nv-bar.hover\")\n .classed(\"hover\", false)\n ;\n };\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n padData: {get: function(){return padData;}, set: function(_){padData=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.historicalBarChart = function(bar_model) {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var bars = bar_model || nv.models.historicalBar()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend()\n , interactiveLayer = nv.interactiveGuideline()\n , tooltip = nv.models.tooltip()\n ;\n\n\n var margin = {top: 30, right: 90, bottom: 50, left: 90}\n , marginTop = null\n , color = nv.utils.defaultColor()\n , width = null\n , height = null\n , showLegend = false\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , useInteractiveGuideline = false\n , x\n , y\n , state = {}\n , defaultState = null\n , noData = null\n , dispatch = d3.dispatch('tooltipHide', 'stateChange', 'changeState', 'renderEnd')\n , transitionDuration = 250\n ;\n\n xAxis.orient('bottom').tickPadding(7);\n yAxis.orient( (rightAlignYAxis) ? 'right' : 'left');\n tooltip\n .duration(0)\n .headerEnabled(false)\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch, 0);\n\n function chart(selection) {\n selection.each(function(data) {\n renderWatch.reset();\n renderWatch.models(bars);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() { container.transition().duration(transitionDuration).call(chart) };\n chart.container = this;\n\n //set state.disabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display noData message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = bars.xScale();\n y = bars.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-historicalBarChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBarChart').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis');\n gEnter.append('g').attr('class', 'nv-barsWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n gEnter.append('g').attr('class', 'nv-interactive');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth);\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n }\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n //Set up interactive layer\n if (useInteractiveGuideline) {\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left:margin.left, top:margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n bars\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled }));\n\n var barsWrap = g.select('.nv-barsWrap')\n .datum(data.filter(function(d) { return !d.disabled }));\n barsWrap.transition().call(bars);\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')');\n g.select('.nv-x.nv-axis')\n .transition()\n .call(xAxis);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis')\n .transition()\n .call(yAxis);\n }\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n bars.clearHighlights();\n\n var singlePoint, pointIndex, pointXLocation, allData = [];\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled;\n })\n .forEach(function(series,i) {\n pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n bars.highlightPoint(pointIndex,true);\n var point = series.values[pointIndex];\n if (point === undefined) return;\n if (singlePoint === undefined) singlePoint = point;\n if (pointXLocation === undefined) pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n allData.push({\n key: series.key,\n value: chart.y()(point, pointIndex),\n color: color(series,series.seriesIndex),\n data: series.values[pointIndex]\n });\n });\n\n var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex));\n interactiveLayer.tooltip\n .valueFormatter(function(d,i) {\n return yAxis.tickFormat()(d);\n })\n .data({\n value: xValue,\n index: pointIndex,\n series: allData\n })();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n dispatch.tooltipHide();\n bars.clearHighlights();\n });\n\n legend.dispatch.on('legendClick', function(d,i) {\n d.disabled = !d.disabled;\n\n if (!data.filter(function(d) { return !d.disabled }).length) {\n data.map(function(d) {\n d.disabled = false;\n wrap.selectAll('.nv-series').classed('disabled', false);\n return d;\n });\n }\n\n state.disabled = data.map(function(d) { return !!d.disabled });\n dispatch.stateChange(state);\n\n selection.transition().call(chart);\n });\n\n legend.dispatch.on('legendDblclick', function(d) {\n //Double clicking should always enable current series, and disabled all others.\n data.forEach(function(d) {\n d.disabled = true;\n });\n d.disabled = false;\n\n state.disabled = data.map(function(d) { return !!d.disabled });\n dispatch.stateChange(state);\n chart.update();\n });\n\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n\n state.disabled = e.disabled;\n }\n\n chart.update();\n });\n });\n\n renderWatch.renderEnd('historicalBarChart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n bars.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt['series'] = {\n key: chart.x()(evt.data),\n value: chart.y()(evt.data),\n color: evt.color\n };\n tooltip.data(evt).hidden(false);\n });\n\n bars.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n bars.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.bars = bars;\n chart.legend = legend;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.interactiveLayer = interactiveLayer;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n bars.color(color);\n }},\n duration: {get: function(){return transitionDuration;}, set: function(_){\n transitionDuration=_;\n renderWatch.reset(transitionDuration);\n yAxis.duration(transitionDuration);\n xAxis.duration(transitionDuration);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( (_) ? 'right' : 'left');\n }},\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = _;\n if (_ === true) {\n chart.interactive(false);\n }\n }}\n });\n\n nv.utils.inheritOptions(chart, bars);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n\n\n// ohlcChart is just a historical chart with ohlc bars and some tweaks\nnv.models.ohlcBarChart = function() {\n var chart = nv.models.historicalBarChart(nv.models.ohlcBar());\n\n // special default tooltip since we show multiple values per x\n chart.useInteractiveGuideline(true);\n chart.interactiveLayer.tooltip.contentGenerator(function(data) {\n // we assume only one series exists for this chart\n var d = data.series[0].data;\n // match line colors as defined in nv.d3.css\n var color = d.open < d.close ? \"2ca02c\" : \"d62728\";\n return '' +\n '

' + data.value + '

' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '
open:' + chart.yAxis.tickFormat()(d.open) + '
close:' + chart.yAxis.tickFormat()(d.close) + '
high' + chart.yAxis.tickFormat()(d.high) + '
low:' + chart.yAxis.tickFormat()(d.low) + '
';\n });\n return chart;\n};\n\n// candlestickChart is just a historical chart with candlestick bars and some tweaks\nnv.models.candlestickBarChart = function() {\n var chart = nv.models.historicalBarChart(nv.models.candlestickBar());\n\n // special default tooltip since we show multiple values per x\n chart.useInteractiveGuideline(true);\n chart.interactiveLayer.tooltip.contentGenerator(function(data) {\n // we assume only one series exists for this chart\n var d = data.series[0].data;\n // match line colors as defined in nv.d3.css\n var color = d.open < d.close ? \"2ca02c\" : \"d62728\";\n return '' +\n '

' + data.value + '

' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '
open:' + chart.yAxis.tickFormat()(d.open) + '
close:' + chart.yAxis.tickFormat()(d.close) + '
high' + chart.yAxis.tickFormat()(d.high) + '
low:' + chart.yAxis.tickFormat()(d.low) + '
';\n });\n return chart;\n};\n", "nv.models.legend = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 5, right: 0, bottom: 5, left: 0}\n , width = 400\n , height = 20\n , getKey = function(d) { return d.key }\n , keyFormatter = function (d) { return d }\n , color = nv.utils.getColor()\n , maxKeyLength = 20 //default value for key lengths\n , align = true\n , padding = 32 //define how much space between legend items. - recommend 32 for furious version\n , rightAlign = true\n , updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch.\n , enableDoubleClick = true //If true, legend will enable double click handling\n , radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time)\n , expanded = false\n , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange')\n , vers = 'classic' //Options are \"classic\" and \"furious\"\n ;\n\n function chart(selection) {\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-legend').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g');\n var g = wrap.select('g');\n\n if (rightAlign)\n wrap.attr('transform', 'translate(' + (- margin.right) + ',' + margin.top + ')');\n else\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n var series = g.selectAll('.nv-series')\n .data(function(d) {\n if(vers != 'furious') return d;\n\n return d.filter(function(n) {\n return expanded ? true : !n.disengaged;\n });\n });\n\n var seriesEnter = series.enter().append('g').attr('class', 'nv-series');\n var seriesShape;\n\n var versPadding;\n switch(vers) {\n case 'furious' :\n versPadding = 23;\n break;\n case 'classic' :\n versPadding = 20;\n }\n\n if(vers == 'classic') {\n seriesEnter.append('circle')\n .style('stroke-width', 2)\n .attr('class','nv-legend-symbol')\n .attr('r', 5);\n\n seriesShape = series.select('.nv-legend-symbol');\n } else if (vers == 'furious') {\n seriesEnter.append('rect')\n .style('stroke-width', 2)\n .attr('class','nv-legend-symbol')\n .attr('rx', 3)\n .attr('ry', 3);\n seriesShape = series.select('.nv-legend-symbol');\n\n seriesEnter.append('g')\n .attr('class', 'nv-check-box')\n .property('innerHTML','')\n .attr('transform', 'translate(-10,-8)scale(0.5)');\n\n var seriesCheckbox = series.select('.nv-check-box');\n\n seriesCheckbox.each(function(d,i) {\n d3.select(this).selectAll('path')\n .attr('stroke', setTextColor(d,i));\n });\n }\n\n seriesEnter.append('text')\n .attr('text-anchor', 'start')\n .attr('class','nv-legend-text')\n .attr('dy', '.32em')\n .attr('dx', '8');\n\n var seriesText = series.select('text.nv-legend-text');\n\n series\n .on('mouseover', function(d,i) {\n dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects\n })\n .on('mouseout', function(d,i) {\n dispatch.legendMouseout(d,i);\n })\n .on('click', function(d,i) {\n dispatch.legendClick(d,i);\n // make sure we re-get data in case it was modified\n var data = series.data();\n if (updateState) {\n if(vers =='classic') {\n if (radioButtonMode) {\n //Radio button mode: set every series to disabled,\n // and enable the clicked series.\n data.forEach(function(series) { series.disabled = true});\n d.disabled = false;\n }\n else {\n d.disabled = !d.disabled;\n if (data.every(function(series) { return series.disabled})) {\n //the default behavior of NVD3 legends is, if every single series\n // is disabled, turn all series' back on.\n data.forEach(function(series) { series.disabled = false});\n }\n }\n } else if(vers == 'furious') {\n if(expanded) {\n d.disengaged = !d.disengaged;\n d.userDisabled = d.userDisabled == undefined ? !!d.disabled : d.userDisabled;\n d.disabled = d.disengaged || d.userDisabled;\n } else if (!expanded) {\n d.disabled = !d.disabled;\n d.userDisabled = d.disabled;\n var engaged = data.filter(function(d) { return !d.disengaged; });\n if (engaged.every(function(series) { return series.userDisabled })) {\n //the default behavior of NVD3 legends is, if every single series\n // is disabled, turn all series' back on.\n data.forEach(function(series) {\n series.disabled = series.userDisabled = false;\n });\n }\n }\n }\n dispatch.stateChange({\n disabled: data.map(function(d) { return !!d.disabled }),\n disengaged: data.map(function(d) { return !!d.disengaged })\n });\n\n }\n })\n .on('dblclick', function(d,i) {\n if (enableDoubleClick) {\n if (vers == 'furious' && expanded) return;\n dispatch.legendDblclick(d, i);\n if (updateState) {\n // make sure we re-get data in case it was modified\n var data = series.data();\n //the default behavior of NVD3 legends, when double clicking one,\n // is to set all other series' to false, and make the double clicked series enabled.\n data.forEach(function (series) {\n series.disabled = true;\n if (vers == 'furious') series.userDisabled = series.disabled;\n });\n d.disabled = false;\n if (vers == 'furious') d.userDisabled = d.disabled;\n dispatch.stateChange({\n disabled: data.map(function (d) {\n return !!d.disabled\n })\n });\n }\n }\n });\n\n series.classed('nv-disabled', function(d) { return d.userDisabled });\n series.exit().remove();\n\n seriesText\n .attr('fill', setTextColor)\n .text(function (d) { return keyFormatter(getKey(d)) });\n\n //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option)\n // NEW ALIGNING CODE, TODO: clean up\n var legendWidth = 0;\n if (align) {\n\n var seriesWidths = [];\n series.each(function(d,i) {\n var legendText;\n if (keyFormatter(getKey(d)) && keyFormatter(getKey(d)).length > maxKeyLength) {\n var trimmedKey = keyFormatter(getKey(d)).substring(0, maxKeyLength);\n legendText = d3.select(this).select('text').text(trimmedKey + \"...\");\n d3.select(this).append(\"svg:title\").text(keyFormatter(getKey(d)));\n } else {\n legendText = d3.select(this).select('text');\n }\n var nodeTextLength;\n try {\n nodeTextLength = legendText.node().getComputedTextLength();\n // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead\n if(nodeTextLength <= 0) throw Error();\n }\n catch(e) {\n nodeTextLength = nv.utils.calcApproxTextWidth(legendText);\n }\n\n seriesWidths.push(nodeTextLength + padding);\n });\n\n var seriesPerRow = 0;\n var columnWidths = [];\n legendWidth = 0;\n\n while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) {\n columnWidths[seriesPerRow] = seriesWidths[seriesPerRow];\n legendWidth += seriesWidths[seriesPerRow++];\n }\n if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row\n\n while ( legendWidth > availableWidth && seriesPerRow > 1 ) {\n columnWidths = [];\n seriesPerRow--;\n\n for (var k = 0; k < seriesWidths.length; k++) {\n if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) )\n columnWidths[k % seriesPerRow] = seriesWidths[k];\n }\n\n legendWidth = columnWidths.reduce(function(prev, cur, index, array) {\n return prev + cur;\n });\n }\n\n var xPositions = [];\n for (var i = 0, curX = 0; i < seriesPerRow; i++) {\n xPositions[i] = curX;\n curX += columnWidths[i];\n }\n\n series\n .attr('transform', function(d, i) {\n return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * versPadding) + ')';\n });\n\n //position legend as far right as possible within the total width\n if (rightAlign) {\n g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')');\n }\n else {\n g.attr('transform', 'translate(0' + ',' + margin.top + ')');\n }\n\n height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * versPadding);\n\n } else {\n\n var ypos = 5,\n newxpos = 5,\n maxwidth = 0,\n xpos;\n series\n .attr('transform', function(d, i) {\n var length = d3.select(this).select('text').node().getComputedTextLength() + padding;\n xpos = newxpos;\n\n if (width < margin.left + margin.right + xpos + length) {\n newxpos = xpos = 5;\n ypos += versPadding;\n }\n\n newxpos += length;\n if (newxpos > maxwidth) maxwidth = newxpos;\n\n if(legendWidth < xpos + maxwidth) {\n legendWidth = xpos + maxwidth;\n }\n return 'translate(' + xpos + ',' + ypos + ')';\n });\n\n //position legend as far right as possible within the total width\n g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')');\n\n height = margin.top + margin.bottom + ypos + 15;\n }\n\n if(vers == 'furious') {\n // Size rectangles after text is placed\n seriesShape\n .attr('width', function(d,i) {\n return seriesText[0][i].getComputedTextLength() + 27;\n })\n .attr('height', 18)\n .attr('y', -9)\n .attr('x', -15);\n\n // The background for the expanded legend (UI)\n gEnter.insert('rect',':first-child')\n .attr('class', 'nv-legend-bg')\n .attr('fill', '#eee')\n // .attr('stroke', '#444')\n .attr('opacity',0);\n\n var seriesBG = g.select('.nv-legend-bg');\n\n seriesBG\n .transition().duration(300)\n .attr('x', -versPadding )\n .attr('width', legendWidth + versPadding - 12)\n .attr('height', height + 10)\n .attr('y', -margin.top - 10)\n .attr('opacity', expanded ? 1 : 0);\n\n\n }\n\n seriesShape\n .style('fill', setBGColor)\n .style('fill-opacity', setBGOpacity)\n .style('stroke', setBGColor);\n });\n\n function setTextColor(d,i) {\n if(vers != 'furious') return '#000';\n if(expanded) {\n return d.disengaged ? '#000' : '#fff';\n } else if (!expanded) {\n if(!d.color) d.color = color(d,i);\n return !!d.disabled ? d.color : '#fff';\n }\n }\n\n function setBGColor(d,i) {\n if(expanded && vers == 'furious') {\n return d.disengaged ? '#eee' : d.color || color(d,i);\n } else {\n return d.color || color(d,i);\n }\n }\n\n\n function setBGOpacity(d,i) {\n if(expanded && vers == 'furious') {\n return 1;\n } else {\n return !!d.disabled ? 0 : 1;\n }\n }\n\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n key: {get: function(){return getKey;}, set: function(_){getKey=_;}},\n keyFormatter: {get: function(){return keyFormatter;}, set: function(_){keyFormatter=_;}},\n align: {get: function(){return align;}, set: function(_){align=_;}},\n maxKeyLength: {get: function(){return maxKeyLength;}, set: function(_){maxKeyLength=_;}},\n rightAlign: {get: function(){return rightAlign;}, set: function(_){rightAlign=_;}},\n padding: {get: function(){return padding;}, set: function(_){padding=_;}},\n updateState: {get: function(){return updateState;}, set: function(_){updateState=_;}},\n enableDoubleClick: {get: function(){return enableDoubleClick;}, set: function(_){enableDoubleClick=_;}},\n radioButtonMode:{get: function(){return radioButtonMode;}, set: function(_){radioButtonMode=_;}},\n expanded: {get: function(){return expanded;}, set: function(_){expanded=_;}},\n vers: {get: function(){return vers;}, set: function(_){vers=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.line = function() {\n \"use strict\";\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var scatter = nv.models.scatter()\n ;\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 960\n , height = 500\n , container = null\n , strokeWidth = 1.5\n , color = nv.utils.defaultColor() // a function that returns a color\n , getX = function(d) { return d.x } // accessor to get the x value from a data point\n , getY = function(d) { return d.y } // accessor to get the y value from a data point\n , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined\n , isArea = function(d) { return d.area } // decides if a line is an area or just a line\n , clipEdge = false // if true, masks lines within x and y scale\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , interpolate = \"linear\" // controls the line interpolation\n , duration = 250\n , dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout', 'renderEnd')\n ;\n\n scatter\n .pointSize(16) // default size\n .pointDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor\n ;\n\n //============================================================\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0 //used to store previous scales\n , renderWatch = nv.utils.renderWatch(dispatch, duration)\n ;\n\n //============================================================\n\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(scatter);\n selection.each(function(data) {\n container = d3.select(this);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n nv.utils.initSVG(container);\n\n // Setup Scales\n x = scatter.xScale();\n y = scatter.yScale();\n\n x0 = x0 || x;\n y0 = y0 || y;\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line');\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-groups');\n gEnter.append('g').attr('class', 'nv-scatterWrap');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n scatter\n .width(availableWidth)\n .height(availableHeight);\n\n var scatterWrap = wrap.select('.nv-scatterWrap');\n scatterWrap.call(scatter);\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-edge-clip-' + scatter.id())\n .append('rect');\n\n wrap.select('#nv-edge-clip-' + scatter.id() + ' rect')\n .attr('width', availableWidth)\n .attr('height', (availableHeight > 0) ? availableHeight : 0);\n\n g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');\n scatterWrap\n .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');\n\n var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n .data(function(d) { return d }, function(d) { return d.key });\n groups.enter().append('g')\n .style('stroke-opacity', 1e-6)\n .style('stroke-width', function(d) { return d.strokeWidth || strokeWidth })\n .style('fill-opacity', 1e-6);\n\n groups.exit().remove();\n\n groups\n .attr('class', function(d,i) {\n return (d.classed || '') + ' nv-group nv-series-' + i;\n })\n .classed('hover', function(d) { return d.hover })\n .style('fill', function(d,i){ return color(d, i) })\n .style('stroke', function(d,i){ return color(d, i)});\n groups.watchTransition(renderWatch, 'line: groups')\n .style('stroke-opacity', 1)\n .style('fill-opacity', function(d) { return d.fillOpacity || .5});\n\n var areaPaths = groups.selectAll('path.nv-area')\n .data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area\n areaPaths.enter().append('path')\n .attr('class', 'nv-area')\n .attr('d', function(d) {\n return d3.svg.area()\n .interpolate(interpolate)\n .defined(defined)\n .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })\n .y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })\n .y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })\n //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this\n .apply(this, [d.values])\n });\n groups.exit().selectAll('path.nv-area')\n .remove();\n\n areaPaths.watchTransition(renderWatch, 'line: areaPaths')\n .attr('d', function(d) {\n return d3.svg.area()\n .interpolate(interpolate)\n .defined(defined)\n .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })\n .y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })\n .y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })\n //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this\n .apply(this, [d.values])\n });\n\n var linePaths = groups.selectAll('path.nv-line')\n .data(function(d) { return [d.values] });\n\n linePaths.enter().append('path')\n .attr('class', 'nv-line')\n .attr('d',\n d3.svg.line()\n .interpolate(interpolate)\n .defined(defined)\n .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })\n .y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })\n );\n\n linePaths.watchTransition(renderWatch, 'line: linePaths')\n .attr('d',\n d3.svg.line()\n .interpolate(interpolate)\n .defined(defined)\n .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })\n .y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })\n );\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n });\n renderWatch.renderEnd('line immediate');\n return chart;\n }\n\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.scatter = scatter;\n // Pass through events\n scatter.dispatch.on('elementClick', function(){ dispatch.elementClick.apply(this, arguments); });\n scatter.dispatch.on('elementMouseover', function(){ dispatch.elementMouseover.apply(this, arguments); });\n scatter.dispatch.on('elementMouseout', function(){ dispatch.elementMouseout.apply(this, arguments); });\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n defined: {get: function(){return defined;}, set: function(_){defined=_;}},\n interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n scatter.duration(duration);\n }},\n isArea: {get: function(){return isArea;}, set: function(_){\n isArea = d3.functor(_);\n }},\n x: {get: function(){return getX;}, set: function(_){\n getX = _;\n scatter.x(_);\n }},\n y: {get: function(){return getY;}, set: function(_){\n getY = _;\n scatter.y(_);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n scatter.color(color);\n }}\n });\n\n nv.utils.inheritOptions(chart, scatter);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "nv.models.lineChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var lines = nv.models.line()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend()\n , interactiveLayer = nv.interactiveGuideline()\n , tooltip = nv.models.tooltip()\n , focus = nv.models.focus(nv.models.line())\n ;\n\n var margin = {top: 30, right: 20, bottom: 50, left: 60}\n , marginTop = null\n , color = nv.utils.defaultColor()\n , width = null\n , height = null\n , showLegend = true\n , legendPosition = 'top'\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , useInteractiveGuideline = false\n , x\n , y\n , focusEnable = false\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n , duration = 250\n ;\n\n // set options on sub-objects for this chart\n xAxis.orient('bottom').tickPadding(7);\n yAxis.orient(rightAlignYAxis ? 'right' : 'left');\n\n lines.clipEdge(true).duration(0);\n\n tooltip.valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n }).headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n interactiveLayer.tooltip.valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n }).headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled; })\n };\n };\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n };\n };\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(lines);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n chart.update = function() {\n if( duration === 0 ) {\n container.call( chart );\n } else {\n container.transition().duration(duration).call(chart);\n }\n };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disabled\n state.disabled = data.map(function(d) { return !!d.disabled; });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display noData message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length; }).length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n /* Update `main' graph on brush update. */\n focus.dispatch.on(\"onBrush\", function(extent) {\n onBrush(extent);\n });\n\n // Setup Scales\n x = lines.xScale();\n y = lines.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-legendWrap');\n\n var focusEnter = gEnter.append('g').attr('class', 'nv-focus');\n focusEnter.append('g').attr('class', 'nv-background').append('rect');\n focusEnter.append('g').attr('class', 'nv-x nv-axis');\n focusEnter.append('g').attr('class', 'nv-y nv-axis');\n focusEnter.append('g').attr('class', 'nv-linesWrap');\n focusEnter.append('g').attr('class', 'nv-interactive');\n\n var contextEnter = gEnter.append('g').attr('class', 'nv-focusWrap');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth);\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (legendPosition === 'bottom') {\n margin.bottom = xAxis.height() + legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (availableHeight + xAxis.height()) +')');\n } else if (legendPosition === 'top') {\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n }\n\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')');\n }\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n //Set up interactive layer\n if (useInteractiveGuideline) {\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left:margin.left, top:margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n\n g.select('.nv-focus .nv-background rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n lines\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled; }));\n\n var linesWrap = g.select('.nv-linesWrap')\n .datum(data.filter(function(d) { return !d.disabled; }));\n\n\n // Setup Main (Focus) Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks(nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n }\n\n //============================================================\n // Update Axes\n //============================================================\n function updateXAxis() {\n if(showXAxis) {\n g.select('.nv-focus .nv-x.nv-axis')\n .transition()\n .duration(duration)\n .call(xAxis)\n ;\n }\n }\n\n function updateYAxis() {\n if(showYAxis) {\n g.select('.nv-focus .nv-y.nv-axis')\n .transition()\n .duration(duration)\n .call(yAxis)\n ;\n }\n }\n\n g.select('.nv-focus .nv-x.nv-axis')\n .attr('transform', 'translate(0,' + availableHeight + ')');\n\n //============================================================\n // Update Focus\n //============================================================\n if (!focusEnable && focus.brush.extent() === null) {\n linesWrap.call(lines);\n updateXAxis();\n updateYAxis();\n } else {\n focus.width(availableWidth);\n g.select('.nv-focusWrap')\n .style('display', focusEnable ? 'initial' : 'none')\n .attr('transform', 'translate(0,' + ( availableHeight + margin.bottom + focus.margin().top) + ')')\n .call(focus);\n var extent = focus.brush.empty() ? focus.xDomain() : focus.brush.extent();\n if (extent !== null) {\n onBrush(extent);\n }\n }\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n lines.clearHighlights();\n var singlePoint, pointIndex, pointXLocation, allData = [];\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled && !series.disableTooltip;\n })\n .forEach(function(series,i) {\n var extent = focus.brush.extent() !== null ? (focus.brush.empty() ? focus.xScale().domain() : focus.brush.extent()) : x.domain();\n var currentValues = series.values.filter(function(d,i) {\n // Checks if the x point is between the extents, handling case where extent[0] is greater than extent[1]\n // (e.g. x domain is manually set to reverse the x-axis)\n if(extent[0] <= extent[1]) {\n return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n } else {\n return lines.x()(d,i) >= extent[1] && lines.x()(d,i) <= extent[0];\n }\n });\n\n pointIndex = nv.interactiveBisect(currentValues, e.pointXValue, lines.x());\n var point = currentValues[pointIndex];\n var pointYValue = chart.y()(point, pointIndex);\n if (pointYValue !== null) {\n lines.highlightPoint(i, pointIndex, true);\n }\n if (point === undefined) return;\n if (singlePoint === undefined) singlePoint = point;\n if (pointXLocation === undefined) pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n allData.push({\n key: series.key,\n value: pointYValue,\n color: color(series,series.seriesIndex),\n data: point\n });\n });\n //Highlight the tooltip entry based on which point the mouse is closest to.\n if (allData.length > 2) {\n var yValue = chart.yScale().invert(e.mouseY);\n var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]);\n var threshold = 0.03 * domainExtent;\n var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value;}),yValue,threshold);\n if (indexToHighlight !== null)\n allData[indexToHighlight].highlight = true;\n }\n\n var defaultValueFormatter = function(d,i) {\n return d == null ? \"N/A\" : yAxis.tickFormat()(d);\n };\n\n interactiveLayer.tooltip\n .valueFormatter(interactiveLayer.tooltip.valueFormatter() || defaultValueFormatter)\n .data({\n value: chart.x()( singlePoint,pointIndex ),\n index: pointIndex,\n series: allData\n })();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n\n });\n\n interactiveLayer.dispatch.on('elementClick', function(e) {\n var pointXLocation, allData = [];\n\n data.filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled;\n }).forEach(function(series) {\n var pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n var point = series.values[pointIndex];\n if (typeof point === 'undefined') return;\n if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n var yPos = chart.yScale()(chart.y()(point,pointIndex));\n allData.push({\n point: point,\n pointIndex: pointIndex,\n pos: [pointXLocation, yPos],\n seriesIndex: series.seriesIndex,\n series: series\n });\n });\n\n lines.dispatch.elementClick(allData);\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n lines.clearHighlights();\n });\n\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n\n state.disabled = e.disabled;\n }\n chart.update();\n });\n\n //============================================================\n // Functions\n //------------------------------------------------------------\n\n // Taken from crossfilter (http://square.github.com/crossfilter/)\n function resizePath(d) {\n var e = +(d == 'e'),\n x = e ? 1 : -1,\n y = availableHeight / 3;\n return 'M' + (0.5 * x) + ',' + y\n + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6)\n + 'V' + (2 * y - 6)\n + 'A6,6 0 0 ' + e + ' ' + (0.5 * x) + ',' + (2 * y)\n + 'Z'\n + 'M' + (2.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8)\n + 'M' + (4.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8);\n }\n\n function onBrush(extent) {\n // Update Main (Focus)\n var focusLinesWrap = g.select('.nv-focus .nv-linesWrap')\n .datum(\n data.filter(function(d) { return !d.disabled; })\n .map(function(d,i) {\n return {\n key: d.key,\n area: d.area,\n classed: d.classed,\n values: d.values.filter(function(d,i) {\n return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n }),\n disableTooltip: d.disableTooltip\n };\n })\n );\n focusLinesWrap.transition().duration(duration).call(lines);\n\n // Update Main (Focus) Axes\n updateXAxis();\n updateYAxis();\n }\n });\n\n renderWatch.renderEnd('lineChart immediate');\n return chart;\n }\n\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n if(!evt.series.disableTooltip){\n tooltip.data(evt).hidden(false);\n }\n });\n\n lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.lines = lines;\n chart.legend = legend;\n chart.focus = focus;\n chart.xAxis = xAxis;\n chart.x2Axis = focus.xAxis\n chart.yAxis = yAxis;\n chart.y2Axis = focus.yAxis\n chart.interactiveLayer = interactiveLayer;\n chart.tooltip = tooltip;\n chart.state = state;\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n // Focus options, mostly passed onto focus model.\n focusEnable: {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}},\n focusHeight: {get: function(){return focus.height();}, set: function(_){focus.height(_);}},\n focusShowAxisX: {get: function(){return focus.showXAxis();}, set: function(_){focus.showXAxis(_);}},\n focusShowAxisY: {get: function(){return focus.showYAxis();}, set: function(_){focus.showYAxis(_);}},\n brushExtent: {get: function(){return focus.brushExtent();}, set: function(_){focus.brushExtent(_);}},\n\n // options that require extra logic in the setter\n focusMargin: {get: function(){return focus.margin}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n focus.margin.right = _.right !== undefined ? _.right : focus.margin.right;\n focus.margin.bottom = _.bottom !== undefined ? _.bottom : focus.margin.bottom;\n focus.margin.left = _.left !== undefined ? _.left : focus.margin.left;\n }},\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n lines.duration(duration);\n focus.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n lines.color(color);\n focus.color(color);\n }},\n interpolate: {get: function(){return lines.interpolate();}, set: function(_){\n lines.interpolate(_);\n focus.interpolate(_);\n }},\n xTickFormat: {get: function(){return xAxis.tickFormat();}, set: function(_){\n xAxis.tickFormat(_);\n focus.xTickFormat(_);\n }},\n yTickFormat: {get: function(){return yAxis.tickFormat();}, set: function(_){\n yAxis.tickFormat(_);\n focus.yTickFormat(_);\n }},\n x: {get: function(){return lines.x();}, set: function(_){\n lines.x(_);\n focus.x(_);\n }},\n y: {get: function(){return lines.y();}, set: function(_){\n lines.y(_);\n focus.y(_);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n }},\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = _;\n if (useInteractiveGuideline) {\n lines.interactive(false);\n lines.useVoronoi(false);\n }\n }}\n });\n\n nv.utils.inheritOptions(chart, lines);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n\nnv.models.lineWithFocusChart = function() {\n return nv.models.lineChart()\n .margin({ bottom: 30 })\n .focusEnable( true );\n};\n", "nv.models.linePlusBarChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var lines = nv.models.line()\n , lines2 = nv.models.line()\n , bars = nv.models.historicalBar()\n , bars2 = nv.models.historicalBar()\n , xAxis = nv.models.axis()\n , x2Axis = nv.models.axis()\n , y1Axis = nv.models.axis()\n , y2Axis = nv.models.axis()\n , y3Axis = nv.models.axis()\n , y4Axis = nv.models.axis()\n , legend = nv.models.legend()\n , brush = d3.svg.brush()\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 30, right: 30, bottom: 30, left: 60}\n , marginTop = null\n , margin2 = {top: 0, right: 30, bottom: 20, left: 60}\n , width = null\n , height = null\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , color = nv.utils.defaultColor()\n , showLegend = true\n , focusEnable = true\n , focusShowAxisY = false\n , focusShowAxisX = true\n , focusHeight = 50\n , extent\n , brushExtent = null\n , x\n , x2\n , y1\n , y2\n , y3\n , y4\n , noData = null\n , dispatch = d3.dispatch('brush', 'stateChange', 'changeState')\n , transitionDuration = 0\n , state = nv.utils.state()\n , defaultState = null\n , legendLeftAxisHint = ' (left axis)'\n , legendRightAxisHint = ' (right axis)'\n , switchYAxisOrder = false\n ;\n\n lines.clipEdge(true);\n lines2.interactive(false);\n // We don't want any points emitted for the focus chart's scatter graph.\n lines2.pointActive(function(d) { return false });\n xAxis.orient('bottom').tickPadding(5);\n y1Axis.orient('left');\n y2Axis.orient('right');\n x2Axis.orient('bottom').tickPadding(5);\n y3Axis.orient('left');\n y4Axis.orient('right');\n\n tooltip.headerEnabled(true).headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var getBarsAxis = function() {\n return switchYAxisOrder\n ? { main: y2Axis, focus: y4Axis }\n : { main: y1Axis, focus: y3Axis }\n }\n\n var getLinesAxis = function() {\n return switchYAxisOrder\n ? { main: y1Axis, focus: y3Axis }\n : { main: y2Axis, focus: y4Axis }\n }\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled })\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n var allDisabled = function(data) {\n return data.every(function(series) {\n return series.disabled;\n });\n }\n\n function chart(selection) {\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight1 = nv.utils.availableHeight(height, container, margin)\n - (focusEnable ? focusHeight : 0),\n availableHeight2 = focusHeight - margin2.top - margin2.bottom;\n\n chart.update = function() { container.transition().duration(transitionDuration).call(chart); };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disableddisabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n var dataBars = data.filter(function(d) { return !d.disabled && d.bar });\n var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240\n\n if (dataBars.length && !switchYAxisOrder) {\n x = bars.xScale();\n } else {\n x = lines.xScale();\n }\n\n x2 = x2Axis.scale();\n\n // select the scales and series based on the position of the yAxis\n y1 = switchYAxisOrder ? lines.yScale() : bars.yScale();\n y2 = switchYAxisOrder ? bars.yScale() : lines.yScale();\n y3 = switchYAxisOrder ? lines2.yScale() : bars2.yScale();\n y4 = switchYAxisOrder ? bars2.yScale() : lines2.yScale();\n\n var series1 = data\n .filter(function(d) { return !d.disabled && (switchYAxisOrder ? !d.bar : d.bar) })\n .map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i) }\n })\n });\n\n var series2 = data\n .filter(function(d) { return !d.disabled && (switchYAxisOrder ? d.bar : !d.bar) })\n .map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i) }\n })\n });\n\n x.range([0, availableWidth]);\n\n x2 .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } ))\n .range([0, availableWidth]);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-legendWrap');\n\n // this is the main chart\n var focusEnter = gEnter.append('g').attr('class', 'nv-focus');\n focusEnter.append('g').attr('class', 'nv-x nv-axis');\n focusEnter.append('g').attr('class', 'nv-y1 nv-axis');\n focusEnter.append('g').attr('class', 'nv-y2 nv-axis');\n focusEnter.append('g').attr('class', 'nv-barsWrap');\n focusEnter.append('g').attr('class', 'nv-linesWrap');\n\n // context chart is where you can focus in\n var contextEnter = gEnter.append('g').attr('class', 'nv-context');\n contextEnter.append('g').attr('class', 'nv-x nv-axis');\n contextEnter.append('g').attr('class', 'nv-y1 nv-axis');\n contextEnter.append('g').attr('class', 'nv-y2 nv-axis');\n contextEnter.append('g').attr('class', 'nv-barsWrap');\n contextEnter.append('g').attr('class', 'nv-linesWrap');\n contextEnter.append('g').attr('class', 'nv-brushBackground');\n contextEnter.append('g').attr('class', 'nv-x nv-brush');\n\n //============================================================\n // Legend\n //------------------------------------------------------------\n\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n var legendWidth = legend.align() ? availableWidth / 2 : availableWidth;\n var legendXPosition = legend.align() ? legendWidth : 0;\n\n legend.width(legendWidth);\n\n g.select('.nv-legendWrap')\n .datum(data.map(function(series) {\n series.originalKey = series.originalKey === undefined ? series.key : series.originalKey;\n if(switchYAxisOrder) {\n series.key = series.originalKey + (series.bar ? legendRightAxisHint : legendLeftAxisHint);\n } else {\n series.key = series.originalKey + (series.bar ? legendLeftAxisHint : legendRightAxisHint);\n }\n return series;\n }))\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n // FIXME: shouldn't this be \"- (focusEnabled ? focusHeight : 0)\"?\n availableHeight1 = nv.utils.availableHeight(height, container, margin) - focusHeight;\n }\n\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(' + legendXPosition + ',' + (-margin.top) +')');\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n //============================================================\n // Context chart (focus chart) components\n //------------------------------------------------------------\n\n // hide or show the focus context chart\n g.select('.nv-context').style('display', focusEnable ? 'initial' : 'none');\n\n bars2\n .width(availableWidth)\n .height(availableHeight2)\n .color(data.map(function (d, i) {\n return d.color || color(d, i);\n }).filter(function (d, i) {\n return !data[i].disabled && data[i].bar\n }));\n lines2\n .width(availableWidth)\n .height(availableHeight2)\n .color(data.map(function (d, i) {\n return d.color || color(d, i);\n }).filter(function (d, i) {\n return !data[i].disabled && !data[i].bar\n }));\n\n var bars2Wrap = g.select('.nv-context .nv-barsWrap')\n .datum(dataBars.length ? dataBars : [\n {values: []}\n ]);\n var lines2Wrap = g.select('.nv-context .nv-linesWrap')\n .datum(allDisabled(dataLines) ?\n [{values: []}] :\n dataLines.filter(function(dataLine) {\n return !dataLine.disabled;\n }));\n\n g.select('.nv-context')\n .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')');\n\n bars2Wrap.transition().call(bars2);\n lines2Wrap.transition().call(lines2);\n\n // context (focus chart) axis controls\n if (focusShowAxisX) {\n x2Axis\n ._ticks( nv.utils.calcTicksX(availableWidth / 100, data))\n .tickSize(-availableHeight2, 0);\n g.select('.nv-context .nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y3.range()[0] + ')');\n g.select('.nv-context .nv-x.nv-axis').transition()\n .call(x2Axis);\n }\n\n if (focusShowAxisY) {\n y3Axis\n .scale(y3)\n ._ticks( availableHeight2 / 36 )\n .tickSize( -availableWidth, 0);\n y4Axis\n .scale(y4)\n ._ticks( availableHeight2 / 36 )\n .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none\n\n g.select('.nv-context .nv-y3.nv-axis')\n .style('opacity', dataBars.length ? 1 : 0)\n .attr('transform', 'translate(0,' + x2.range()[0] + ')');\n g.select('.nv-context .nv-y2.nv-axis')\n .style('opacity', dataLines.length ? 1 : 0)\n .attr('transform', 'translate(' + x2.range()[1] + ',0)');\n\n g.select('.nv-context .nv-y1.nv-axis').transition()\n .call(y3Axis);\n g.select('.nv-context .nv-y2.nv-axis').transition()\n .call(y4Axis);\n }\n\n // Setup Brush\n brush.x(x2).on('brush', onBrush);\n\n if (brushExtent) brush.extent(brushExtent);\n\n var brushBG = g.select('.nv-brushBackground').selectAll('g')\n .data([brushExtent || brush.extent()]);\n\n var brushBGenter = brushBG.enter()\n .append('g');\n\n brushBGenter.append('rect')\n .attr('class', 'left')\n .attr('x', 0)\n .attr('y', 0)\n .attr('height', availableHeight2);\n\n brushBGenter.append('rect')\n .attr('class', 'right')\n .attr('x', 0)\n .attr('y', 0)\n .attr('height', availableHeight2);\n\n var gBrush = g.select('.nv-x.nv-brush')\n .call(brush);\n gBrush.selectAll('rect')\n //.attr('y', -5)\n .attr('height', availableHeight2);\n gBrush.selectAll('.resize').append('path').attr('d', resizePath);\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n state.disabled = e.disabled;\n }\n chart.update();\n });\n\n //============================================================\n // Functions\n //------------------------------------------------------------\n\n // Taken from crossfilter (http://square.github.com/crossfilter/)\n function resizePath(d) {\n var e = +(d == 'e'),\n x = e ? 1 : -1,\n y = availableHeight2 / 3;\n return 'M' + (.5 * x) + ',' + y\n + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6)\n + 'V' + (2 * y - 6)\n + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y)\n + 'Z'\n + 'M' + (2.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8)\n + 'M' + (4.5 * x) + ',' + (y + 8)\n + 'V' + (2 * y - 8);\n }\n\n\n function updateBrushBG() {\n if (!brush.empty()) brush.extent(brushExtent);\n brushBG\n .data([brush.empty() ? x2.domain() : brushExtent])\n .each(function(d,i) {\n var leftWidth = x2(d[0]) - x2.range()[0],\n rightWidth = x2.range()[1] - x2(d[1]);\n d3.select(this).select('.left')\n .attr('width', leftWidth < 0 ? 0 : leftWidth);\n\n d3.select(this).select('.right')\n .attr('x', x2(d[1]))\n .attr('width', rightWidth < 0 ? 0 : rightWidth);\n });\n }\n\n function onBrush() {\n brushExtent = brush.empty() ? null : brush.extent();\n extent = brush.empty() ? x2.domain() : brush.extent();\n dispatch.brush({extent: extent, brush: brush});\n updateBrushBG();\n\n // Prepare Main (Focus) Bars and Lines\n bars\n .width(availableWidth)\n .height(availableHeight1)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled && data[i].bar }));\n\n lines\n .width(availableWidth)\n .height(availableHeight1)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled && !data[i].bar }));\n\n var focusBarsWrap = g.select('.nv-focus .nv-barsWrap')\n .datum(!dataBars.length ? [{values:[]}] :\n dataBars\n .map(function(d,i) {\n return {\n key: d.key,\n values: d.values.filter(function(d,i) {\n return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1];\n })\n }\n })\n );\n\n var focusLinesWrap = g.select('.nv-focus .nv-linesWrap')\n .datum(allDisabled(dataLines) ? [{values:[]}] :\n dataLines\n .filter(function(dataLine) { return !dataLine.disabled; })\n .map(function(d,i) {\n return {\n area: d.area,\n fillOpacity: d.fillOpacity,\n strokeWidth: d.strokeWidth,\n key: d.key,\n values: d.values.filter(function(d,i) {\n return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n })\n }\n })\n );\n\n // Update Main (Focus) X Axis\n if (dataBars.length && !switchYAxisOrder) {\n x = bars.xScale();\n } else {\n x = lines.xScale();\n }\n\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight1, 0);\n\n xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]);\n\n g.select('.nv-x.nv-axis').transition().duration(transitionDuration)\n .call(xAxis);\n\n // Update Main (Focus) Bars and Lines\n focusBarsWrap.transition().duration(transitionDuration).call(bars);\n focusLinesWrap.transition().duration(transitionDuration).call(lines);\n\n // Setup and Update Main (Focus) Y Axes\n g.select('.nv-focus .nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y1.range()[0] + ')');\n\n y1Axis\n .scale(y1)\n ._ticks( nv.utils.calcTicksY(availableHeight1/36, data) )\n .tickSize(-availableWidth, 0);\n y2Axis\n .scale(y2)\n ._ticks( nv.utils.calcTicksY(availableHeight1/36, data) );\n\n // Show the y2 rules only if y1 has none\n if(!switchYAxisOrder) {\n y2Axis.tickSize(dataBars.length ? 0 : -availableWidth, 0);\n } else {\n y2Axis.tickSize(dataLines.length ? 0 : -availableWidth, 0);\n }\n\n // Calculate opacity of the axis\n var barsOpacity = dataBars.length ? 1 : 0;\n var linesOpacity = dataLines.length && !allDisabled(dataLines) ? 1 : 0;\n\n var y1Opacity = switchYAxisOrder ? linesOpacity : barsOpacity;\n var y2Opacity = switchYAxisOrder ? barsOpacity : linesOpacity;\n\n g.select('.nv-focus .nv-y1.nv-axis')\n .style('opacity', y1Opacity);\n g.select('.nv-focus .nv-y2.nv-axis')\n .style('opacity', y2Opacity)\n .attr('transform', 'translate(' + x.range()[1] + ',0)');\n\n g.select('.nv-focus .nv-y1.nv-axis').transition().duration(transitionDuration)\n .call(y1Axis);\n g.select('.nv-focus .nv-y2.nv-axis').transition().duration(transitionDuration)\n .call(y2Axis);\n }\n\n onBrush();\n\n });\n\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n tooltip\n .duration(100)\n .valueFormatter(function(d, i) {\n return getLinesAxis().main.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n });\n\n lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n bars.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt.value = chart.x()(evt.data);\n evt['series'] = {\n value: chart.y()(evt.data),\n color: evt.color\n };\n tooltip\n .duration(0)\n .valueFormatter(function(d, i) {\n return getBarsAxis().main.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n });\n\n bars.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n bars.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.legend = legend;\n chart.lines = lines;\n chart.lines2 = lines2;\n chart.bars = bars;\n chart.bars2 = bars2;\n chart.xAxis = xAxis;\n chart.x2Axis = x2Axis;\n chart.y1Axis = y1Axis;\n chart.y2Axis = y2Axis;\n chart.y3Axis = y3Axis;\n chart.y4Axis = y4Axis;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n brushExtent: {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n focusEnable: {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}},\n focusHeight: {get: function(){return focusHeight;}, set: function(_){focusHeight=_;}},\n focusShowAxisX: {get: function(){return focusShowAxisX;}, set: function(_){focusShowAxisX=_;}},\n focusShowAxisY: {get: function(){return focusShowAxisY;}, set: function(_){focusShowAxisY=_;}},\n legendLeftAxisHint: {get: function(){return legendLeftAxisHint;}, set: function(_){legendLeftAxisHint=_;}},\n legendRightAxisHint: {get: function(){return legendRightAxisHint;}, set: function(_){legendRightAxisHint=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n focusMargin: {get: function(){return margin2;}, set: function(_){\n margin2.top = _.top !== undefined ? _.top : margin2.top;\n margin2.right = _.right !== undefined ? _.right : margin2.right;\n margin2.bottom = _.bottom !== undefined ? _.bottom : margin2.bottom;\n margin2.left = _.left !== undefined ? _.left : margin2.left;\n }},\n duration: {get: function(){return transitionDuration;}, set: function(_){\n transitionDuration = _;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n }},\n x: {get: function(){return getX;}, set: function(_){\n getX = _;\n lines.x(_);\n lines2.x(_);\n bars.x(_);\n bars2.x(_);\n }},\n y: {get: function(){return getY;}, set: function(_){\n getY = _;\n lines.y(_);\n lines2.y(_);\n bars.y(_);\n bars2.y(_);\n }},\n switchYAxisOrder: {get: function(){return switchYAxisOrder;}, set: function(_){\n // Switch the tick format for the yAxis\n if(switchYAxisOrder !== _) {\n var y1 = y1Axis;\n y1Axis = y2Axis;\n y2Axis = y1;\n\n var y3 = y3Axis;\n y3Axis = y4Axis;\n y4Axis = y3;\n }\n switchYAxisOrder=_;\n\n y1Axis.orient('left');\n y2Axis.orient('right');\n y3Axis.orient('left');\n y4Axis.orient('right');\n }}\n });\n\n nv.utils.inheritOptions(chart, lines);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.multiBar = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 960\n , height = 500\n , x = d3.scale.ordinal()\n , y = d3.scale.linear()\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n , clipEdge = true\n , stacked = false\n , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function\n , color = nv.utils.defaultColor()\n , hideable = false\n , barColor = null // adding the ability to set the color for each rather than the whole group\n , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled\n , duration = 500\n , xDomain\n , yDomain\n , xRange\n , yRange\n , groupSpacing = 0.1\n , fillOpacity = 0.75\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0 //used to store previous scales\n , renderWatch = nv.utils.renderWatch(dispatch, duration)\n ;\n\n var last_datalength = 0;\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n var nonStackableCount = 0;\n // This function defines the requirements for render complete\n var endFn = function(d, i) {\n if (d.series === data.length - 1 && i === data[0].values.length - 1)\n return true;\n return false;\n };\n\n if(hideable && data.length) hideable = [{\n values: data[0].values.map(function(d) {\n return {\n x: d.x,\n y: 0,\n series: d.series,\n size: 0.01\n };}\n )}];\n\n if (stacked) {\n var parsed = d3.layout.stack()\n .offset(stackOffset)\n .values(function(d){ return d.values })\n .y(getY)\n (!data.length && hideable ? hideable : data);\n\n parsed.forEach(function(series, i){\n // if series is non-stackable, use un-parsed data\n if (series.nonStackable) {\n data[i].nonStackableSeries = nonStackableCount++;\n parsed[i] = data[i];\n } else {\n // don't stack this seires on top of the nonStackable seriees\n if (i > 0 && parsed[i - 1].nonStackable){\n parsed[i].values.map(function(d,j){\n d.y0 -= parsed[i - 1].values[j].y;\n d.y1 = d.y0 + d.y;\n });\n }\n }\n });\n data = parsed;\n }\n //add series index and key to each data point for reference\n data.forEach(function(series, i) {\n series.values.forEach(function(point) {\n point.series = i;\n point.key = series.key;\n });\n });\n\n // HACK for negative value stacking\n if (stacked && data.length > 0) {\n data[0].values.map(function(d,i) {\n var posBase = 0, negBase = 0;\n data.map(function(d, idx) {\n if (!data[idx].nonStackable) {\n var f = d.values[i]\n f.size = Math.abs(f.y);\n if (f.y<0) {\n f.y1 = negBase;\n negBase = negBase - f.size;\n } else\n {\n f.y1 = f.size + posBase;\n posBase = posBase + f.size;\n }\n }\n\n });\n });\n }\n // Setup Scales\n // remap and flatten the data for use in calculating the scales' domains\n var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n data.map(function(d, idx) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1, idx:idx }\n })\n });\n\n x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n .rangeBands(xRange || [0, availableWidth], groupSpacing);\n\n y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) {\n var domain = d.y;\n // increase the domain range if this series is stackable\n if (stacked && !data[d.idx].nonStackable) {\n if (d.y > 0){\n domain = d.y1\n } else {\n domain = d.y1 + d.y\n }\n }\n return domain;\n }).concat(forceY)))\n .range(yRange || [availableHeight, 0]);\n\n // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n if (x.domain()[0] === x.domain()[1])\n x.domain()[0] ?\n x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n : x.domain([-1,1]);\n\n if (y.domain()[0] === y.domain()[1])\n y.domain()[0] ?\n y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n : y.domain([-1,1]);\n\n x0 = x0 || x;\n y0 = y0 || y;\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar');\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-groups');\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-edge-clip-' + id)\n .append('rect');\n wrap.select('#nv-edge-clip-' + id + ' rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n .data(function(d) { return d }, function(d,i) { return i });\n groups.enter().append('g')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6);\n\n var exitTransition = renderWatch\n .transition(groups.exit().selectAll('rect.nv-bar'), 'multibarExit', Math.min(100, duration))\n .attr('y', function(d, i, j) {\n var yVal = y0(0) || 0;\n if (stacked) {\n if (data[d.series] && !data[d.series].nonStackable) {\n yVal = y0(d.y0);\n }\n }\n return yVal;\n })\n .attr('height', 0)\n .remove();\n if (exitTransition.delay)\n exitTransition.delay(function(d,i) {\n var delay = i * (duration / (last_datalength + 1)) - i;\n return delay;\n });\n groups\n .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n .classed('hover', function(d) { return d.hover })\n .style('fill', function(d,i){ return color(d, i) })\n .style('stroke', function(d,i){ return color(d, i) });\n groups\n .style('stroke-opacity', 1)\n .style('fill-opacity', fillOpacity);\n\n var bars = groups.selectAll('rect.nv-bar')\n .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });\n bars.exit().remove();\n\n var barsEnter = bars.enter().append('rect')\n .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n .attr('x', function(d,i,j) {\n return stacked && !data[j].nonStackable ? 0 : (j * x.rangeBand() / data.length )\n })\n .attr('y', function(d,i,j) { return y0(stacked && !data[j].nonStackable ? d.y0 : 0) || 0 })\n .attr('height', 0)\n .attr('width', function(d,i,j) { return x.rangeBand() / (stacked && !data[j].nonStackable ? 1 : data.length) })\n .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })\n ;\n bars\n .style('fill', function(d,i,j){ return color(d, j, i); })\n .style('stroke', function(d,i,j){ return color(d, j, i); })\n .on('mouseover', function(d,i,j) {\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n data: d,\n index: i,\n series: data[j],\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mouseout', function(d,i,j) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n data: d,\n index: i,\n series: data[j],\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mousemove', function(d,i,j) {\n dispatch.elementMousemove({\n data: d,\n index: i,\n series: data[j],\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('click', function(d,i,j) {\n var element = this;\n dispatch.elementClick({\n data: d,\n index: i,\n series: data[j],\n color: d3.select(this).style(\"fill\"),\n event: d3.event,\n element: element\n });\n d3.event.stopPropagation();\n })\n .on('dblclick', function(d,i,j) {\n dispatch.elementDblClick({\n data: d,\n index: i,\n series: data[j],\n color: d3.select(this).style(\"fill\")\n });\n d3.event.stopPropagation();\n });\n bars\n .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })\n\n if (barColor) {\n if (!disabled) disabled = data.map(function() { return true });\n bars\n .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); })\n .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); });\n }\n\n var barSelection =\n bars.watchTransition(renderWatch, 'multibar', Math.min(250, duration))\n .delay(function(d,i) {\n return i * duration / data[0].values.length;\n });\n if (stacked){\n barSelection\n .attr('y', function(d,i,j) {\n var yVal = 0;\n // if stackable, stack it on top of the previous series\n if (!data[j].nonStackable) {\n yVal = y(d.y1);\n } else {\n if (getY(d,i) < 0){\n yVal = y(0);\n } else {\n if (y(0) - y(getY(d,i)) < -1){\n yVal = y(0) - 1;\n } else {\n yVal = y(getY(d, i)) || 0;\n }\n }\n }\n return yVal;\n })\n .attr('height', function(d,i,j) {\n if (!data[j].nonStackable) {\n return Math.max(Math.abs(y(d.y+d.y0) - y(d.y0)), 0);\n } else {\n return Math.max(Math.abs(y(getY(d,i)) - y(0)), 0) || 0;\n }\n })\n .attr('x', function(d,i,j) {\n var width = 0;\n if (data[j].nonStackable) {\n width = d.series * x.rangeBand() / data.length;\n if (data.length !== nonStackableCount){\n width = data[j].nonStackableSeries * x.rangeBand()/(nonStackableCount*2);\n }\n }\n return width;\n })\n .attr('width', function(d,i,j){\n if (!data[j].nonStackable) {\n return x.rangeBand();\n } else {\n // if all series are nonStacable, take the full width\n var width = (x.rangeBand() / nonStackableCount);\n // otherwise, nonStackable graph will be only taking the half-width\n // of the x rangeBand\n if (data.length !== nonStackableCount) {\n width = x.rangeBand()/(nonStackableCount*2);\n }\n return width;\n }\n });\n }\n else {\n barSelection\n .attr('x', function(d,i) {\n return d.series * x.rangeBand() / data.length;\n })\n .attr('width', x.rangeBand() / data.length)\n .attr('y', function(d,i) {\n return getY(d,i) < 0 ?\n y(0) :\n y(0) - y(getY(d,i)) < 1 ?\n y(0) - 1 :\n y(getY(d,i)) || 0;\n })\n .attr('height', function(d,i) {\n return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0;\n });\n }\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n\n // keep track of the last data value length for transition calculations\n if (data[0] && data[0].values) {\n last_datalength = data[0].values.length;\n }\n\n });\n\n renderWatch.renderEnd('multibar immediate');\n\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}},\n stackOffset: {get: function(){return stackOffset;}, set: function(_){stackOffset=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n disabled: {get: function(){return disabled;}, set: function(_){disabled=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n hideable: {get: function(){return hideable;}, set: function(_){hideable=_;}},\n groupSpacing:{get: function(){return groupSpacing;}, set: function(_){groupSpacing=_;}},\n fillOpacity: {get: function(){return fillOpacity;}, set: function(_){fillOpacity=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n barColor: {get: function(){return barColor;}, set: function(_){\n barColor = _ ? nv.utils.getColor(_) : null;\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "nv.models.multiBarChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var multibar = nv.models.multiBar()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , interactiveLayer = nv.interactiveGuideline()\n , legend = nv.models.legend()\n , controls = nv.models.legend()\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 30, right: 20, bottom: 50, left: 60}\n , marginTop = null\n , width = null\n , height = null\n , color = nv.utils.defaultColor()\n , showControls = true\n , controlLabels = {}\n , showLegend = true\n , legendPosition = null\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , reduceXTicks = true // if false a tick will show for every data point\n , staggerLabels = false\n , wrapLabels = false\n , rotateLabels = 0\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n , controlWidth = function() { return showControls ? 180 : 0 }\n , duration = 250\n , useInteractiveGuideline = false\n ;\n\n state.stacked = false // DEPRECATED Maintained for backward compatibility\n\n multibar.stacked(false);\n xAxis\n .orient('bottom')\n .tickPadding(7)\n .showMaxMin(false)\n .tickFormat(function(d) { return d })\n ;\n yAxis\n .orient((rightAlignYAxis) ? 'right' : 'left')\n .tickFormat(d3.format(',.1f'))\n ;\n\n tooltip\n .duration(0)\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n interactiveLayer.tooltip\n .valueFormatter(function(d, i) {\n return d == null ? \"N/A\" : yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n interactiveLayer.tooltip\n .valueFormatter(function (d, i) {\n return d == null ? \"N/A\" : yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function (d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n interactiveLayer.tooltip\n .duration(0)\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n controls.updateState(false);\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n var stacked = false;\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled }),\n stacked: stacked\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.stacked !== undefined)\n stacked = state.stacked;\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(multibar);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() {\n if (duration === 0)\n container.call(chart);\n else\n container.transition()\n .duration(duration)\n .call(chart);\n };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disableddisabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display noData message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = multibar.xScale();\n y = multibar.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis');\n gEnter.append('g').attr('class', 'nv-barsWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n gEnter.append('g').attr('class', 'nv-controlsWrap');\n gEnter.append('g').attr('class', 'nv-interactive');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n if (legendPosition === 'bottom') {\n legend.width(availableWidth - margin.right);\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n margin.bottom = xAxis.height() + legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (availableHeight + xAxis.height()) +')');\n } else {\n legend.width(availableWidth - controlWidth());\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')');\n }\n }\n\n // Controls\n if (!showControls) {\n g.select('.nv-controlsWrap').selectAll('*').remove();\n } else {\n var controlsData = [\n { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() },\n { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() }\n ];\n\n controls.width(controlWidth()).color(['#444', '#444', '#444']);\n g.select('.nv-controlsWrap')\n .datum(controlsData)\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n .call(controls);\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n // Main Chart Component(s)\n multibar\n .disabled(data.map(function(series) { return series.disabled }))\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled }));\n\n\n var barsWrap = g.select('.nv-barsWrap')\n .datum(data.filter(function(d) { return !d.disabled }));\n\n barsWrap.call(multibar);\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')');\n g.select('.nv-x.nv-axis')\n .call(xAxis);\n\n var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g');\n\n xTicks\n .selectAll('line, text')\n .style('opacity', 1)\n\n if (staggerLabels) {\n var getTranslate = function(x,y) {\n return \"translate(\" + x + \",\" + y + \")\";\n };\n\n var staggerUp = 5, staggerDown = 17; //pixels to stagger by\n // Issue #140\n xTicks\n .selectAll(\"text\")\n .attr('transform', function(d,i,j) {\n return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown));\n });\n\n var totalInBetweenTicks = d3.selectAll(\".nv-x.nv-axis .nv-wrap g g text\")[0].length;\n g.selectAll(\".nv-x.nv-axis .nv-axisMaxMin text\")\n .attr(\"transform\", function(d,i) {\n return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp);\n });\n }\n\n if (wrapLabels) {\n g.selectAll('.tick text')\n .call(nv.utils.wrapTicks, chart.xAxis.rangeBand())\n }\n\n if (reduceXTicks)\n xTicks\n .filter(function(d,i) {\n return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0;\n })\n .selectAll('text, line')\n .style('opacity', 0);\n\n if(rotateLabels)\n xTicks\n .selectAll('.tick text')\n .attr('transform', 'rotate(' + rotateLabels + ' 0,0)')\n .style('text-anchor', rotateLabels > 0 ? 'start' : 'end');\n\n g.select('.nv-x.nv-axis').selectAll('g.nv-axisMaxMin text')\n .style('opacity', 1);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis')\n .call(yAxis);\n }\n\n //Set up interactive layer\n if (useInteractiveGuideline) {\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left:margin.left, top:margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n controls.dispatch.on('legendClick', function(d,i) {\n if (!d.disabled) return;\n controlsData = controlsData.map(function(s) {\n s.disabled = true;\n return s;\n });\n d.disabled = false;\n\n switch (d.key) {\n case 'Grouped':\n case controlLabels.grouped:\n multibar.stacked(false);\n break;\n case 'Stacked':\n case controlLabels.stacked:\n multibar.stacked(true);\n break;\n }\n\n state.stacked = multibar.stacked();\n dispatch.stateChange(state);\n chart.update();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n state.disabled = e.disabled;\n }\n if (typeof e.stacked !== 'undefined') {\n multibar.stacked(e.stacked);\n state.stacked = e.stacked;\n stacked = e.stacked;\n }\n chart.update();\n });\n\n if (useInteractiveGuideline) {\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n if (e.pointXValue == undefined) return;\n\n var singlePoint, pointIndex, pointXLocation, xValue, allData = [];\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled;\n })\n .forEach(function(series,i) {\n pointIndex = x.domain().indexOf(e.pointXValue)\n\n var point = series.values[pointIndex];\n if (point === undefined) return;\n\n xValue = point.x;\n if (singlePoint === undefined) singlePoint = point;\n if (pointXLocation === undefined) pointXLocation = e.mouseX\n allData.push({\n key: series.key,\n value: chart.y()(point, pointIndex),\n color: color(series,series.seriesIndex),\n data: series.values[pointIndex]\n });\n });\n\n interactiveLayer.tooltip\n .data({\n value: xValue,\n index: pointIndex,\n series: allData\n })();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n interactiveLayer.tooltip.hidden(true);\n });\n }\n else {\n multibar.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt.value = chart.x()(evt.data);\n evt['series'] = {\n key: evt.data.key,\n value: chart.y()(evt.data),\n color: evt.color\n };\n tooltip.data(evt).hidden(false);\n });\n\n multibar.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n multibar.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n }\n });\n\n renderWatch.renderEnd('multibarchart immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.multibar = multibar;\n chart.legend = legend;\n chart.controls = controls;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.state = state;\n chart.tooltip = tooltip;\n chart.interactiveLayer = interactiveLayer;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n reduceXTicks: {get: function(){return reduceXTicks;}, set: function(_){reduceXTicks=_;}},\n rotateLabels: {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n wrapLabels: {get: function(){return wrapLabels;}, set: function(_){wrapLabels=!!_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n multibar.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n renderWatch.reset(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n }},\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = _;\n }},\n barColor: {get: function(){return multibar.barColor;}, set: function(_){\n multibar.barColor(_);\n legend.color(function(d,i) {return d3.rgb('#ccc').darker(i * 1.5).toString();})\n }}\n });\n\n nv.utils.inheritOptions(chart, multibar);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.multiBarHorizontal = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 960\n , height = 500\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , x = d3.scale.ordinal()\n , y = d3.scale.linear()\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , getYerr = function(d) { return d.yErr }\n , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n , color = nv.utils.defaultColor()\n , barColor = null // adding the ability to set the color for each rather than the whole group\n , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled\n , stacked = false\n , showValues = false\n , showBarLabels = false\n , valuePadding = 60\n , groupSpacing = 0.1\n , fillOpacity = 0.75\n , valueFormat = d3.format(',.2f')\n , delay = 1200\n , xDomain\n , yDomain\n , xRange\n , yRange\n , duration = 250\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0; //used to store previous scales\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n if (stacked)\n data = d3.layout.stack()\n .offset('zero')\n .values(function(d){ return d.values })\n .y(getY)\n (data);\n\n //add series index and key to each data point for reference\n data.forEach(function(series, i) {\n series.values.forEach(function(point) {\n point.series = i;\n point.key = series.key;\n });\n });\n\n // HACK for negative value stacking\n if (stacked)\n data[0].values.map(function(d,i) {\n var posBase = 0, negBase = 0;\n data.map(function(d) {\n var f = d.values[i]\n f.size = Math.abs(f.y);\n if (f.y<0) {\n f.y1 = negBase - f.size;\n negBase = negBase - f.size;\n } else\n {\n f.y1 = posBase;\n posBase = posBase + f.size;\n }\n });\n });\n\n // Setup Scales\n // remap and flatten the data for use in calculating the scales' domains\n var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n data.map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 }\n })\n });\n\n x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n .rangeBands(xRange || [0, availableHeight], groupSpacing);\n\n y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 + d.y : d.y1 ) : d.y }).concat(forceY)))\n\n if (showValues && !stacked)\n y.range(yRange || [(y.domain()[0] < 0 ? valuePadding : 0), availableWidth - (y.domain()[1] > 0 ? valuePadding : 0) ]);\n else\n y.range(yRange || [0, availableWidth]);\n\n x0 = x0 || x;\n y0 = y0 || d3.scale.linear().domain(y.domain()).range([y(0),y(0)]);\n\n // Setup containers and skeleton of chart\n var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibarHorizontal').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibarHorizontal');\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-groups');\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n .data(function(d) { return d }, function(d,i) { return i });\n groups.enter().append('g')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6);\n groups.exit().watchTransition(renderWatch, 'multibarhorizontal: exit groups')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6)\n .remove();\n groups\n .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n .classed('hover', function(d) { return d.hover })\n .style('fill', function(d,i){ return color(d, i) })\n .style('stroke', function(d,i){ return color(d, i) });\n groups.watchTransition(renderWatch, 'multibarhorizontal: groups')\n .style('stroke-opacity', 1)\n .style('fill-opacity', fillOpacity);\n\n var bars = groups.selectAll('g.nv-bar')\n .data(function(d) { return d.values });\n bars.exit().remove();\n\n var barsEnter = bars.enter().append('g')\n .attr('transform', function(d,i,j) {\n return 'translate(' + y0(stacked ? d.y0 : 0) + ',' + (stacked ? 0 : (j * x.rangeBand() / data.length ) + x(getX(d,i))) + ')'\n });\n\n barsEnter.append('rect')\n .attr('width', 0)\n .attr('height', x.rangeBand() / (stacked ? 1 : data.length) )\n\n bars\n .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here\n d3.select(this).classed('hover', true);\n dispatch.elementMouseover({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mouseout', function(d,i) {\n d3.select(this).classed('hover', false);\n dispatch.elementMouseout({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mouseout', function(d,i) {\n dispatch.elementMouseout({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('mousemove', function(d,i) {\n dispatch.elementMousemove({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n })\n .on('click', function(d,i) {\n var element = this;\n dispatch.elementClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\"),\n event: d3.event,\n element: element\n });\n d3.event.stopPropagation();\n })\n .on('dblclick', function(d,i) {\n dispatch.elementDblClick({\n data: d,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n d3.event.stopPropagation();\n });\n\n if (getYerr(data[0],0)) {\n barsEnter.append('polyline');\n\n bars.select('polyline')\n .attr('fill', 'none')\n .attr('points', function(d,i) {\n var xerr = getYerr(d,i)\n , mid = 0.8 * x.rangeBand() / ((stacked ? 1 : data.length) * 2);\n xerr = xerr.length ? xerr : [-Math.abs(xerr), Math.abs(xerr)];\n xerr = xerr.map(function(e) { return y(e + ((getY(d,i) < 0) ? 0 : getY(d,i))) - y(0); });\n var a = [[xerr[0],-mid], [xerr[0],mid], [xerr[0],0], [xerr[1],0], [xerr[1],-mid], [xerr[1],mid]];\n return a.map(function (path) { return path.join(',') }).join(' ');\n })\n .attr('transform', function(d,i) {\n var mid = x.rangeBand() / ((stacked ? 1 : data.length) * 2);\n return 'translate(0, ' + mid + ')';\n });\n }\n\n barsEnter.append('text');\n\n if (showValues && !stacked) {\n bars.select('text')\n .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'end' : 'start' })\n .attr('y', x.rangeBand() / (data.length * 2))\n .attr('dy', '.32em')\n .text(function(d,i) {\n var t = valueFormat(getY(d,i))\n , yerr = getYerr(d,i);\n if (yerr === undefined)\n return t;\n if (!yerr.length)\n return t + '±' + valueFormat(Math.abs(yerr));\n return t + '+' + valueFormat(Math.abs(yerr[1])) + '-' + valueFormat(Math.abs(yerr[0]));\n });\n bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n .select('text')\n .attr('x', function(d,i) { return getY(d,i) < 0 ? -4 : y(getY(d,i)) - y(0) + 4 })\n } else {\n bars.selectAll('text').text('');\n }\n\n if (showBarLabels && !stacked) {\n barsEnter.append('text').classed('nv-bar-label',true);\n bars.select('text.nv-bar-label')\n .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'start' : 'end' })\n .attr('y', x.rangeBand() / (data.length * 2))\n .attr('dy', '.32em')\n .text(function(d,i) { return getX(d,i) });\n bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n .select('text.nv-bar-label')\n .attr('x', function(d,i) { return getY(d,i) < 0 ? y(0) - y(getY(d,i)) + 4 : -4 });\n }\n else {\n bars.selectAll('text.nv-bar-label').text('');\n }\n\n bars\n .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n\n if (barColor) {\n if (!disabled) disabled = data.map(function() { return true });\n bars\n .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); })\n .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); });\n }\n\n if (stacked)\n bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n .attr('transform', function(d,i) {\n return 'translate(' + y(d.y1) + ',' + x(getX(d,i)) + ')'\n })\n .select('rect')\n .attr('width', function(d,i) {\n return Math.abs(y(getY(d,i) + d.y0) - y(d.y0)) || 0\n })\n .attr('height', x.rangeBand() );\n else\n bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n .attr('transform', function(d,i) {\n //TODO: stacked must be all positive or all negative, not both?\n return 'translate(' +\n (getY(d,i) < 0 ? y(getY(d,i)) : y(0))\n + ',' +\n (d.series * x.rangeBand() / data.length\n +\n x(getX(d,i)) )\n + ')'\n })\n .select('rect')\n .attr('height', x.rangeBand() / data.length )\n .attr('width', function(d,i) {\n return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0\n });\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n\n });\n\n renderWatch.renderEnd('multibarHorizontal immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n yErr: {get: function(){return getYerr;}, set: function(_){getYerr=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}},\n showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}},\n // this shows the group name, seems pointless?\n //showBarLabels: {get: function(){return showBarLabels;}, set: function(_){showBarLabels=_;}},\n disabled: {get: function(){return disabled;}, set: function(_){disabled=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n valuePadding: {get: function(){return valuePadding;}, set: function(_){valuePadding=_;}},\n groupSpacing: {get: function(){return groupSpacing;}, set: function(_){groupSpacing=_;}},\n fillOpacity: {get: function(){return fillOpacity;}, set: function(_){fillOpacity=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n barColor: {get: function(){return barColor;}, set: function(_){\n barColor = _ ? nv.utils.getColor(_) : null;\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.multiBarHorizontalChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var multibar = nv.models.multiBarHorizontal()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend().height(30)\n , controls = nv.models.legend().height(30)\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 30, right: 20, bottom: 50, left: 60}\n , marginTop = null\n , width = null\n , height = null\n , color = nv.utils.defaultColor()\n , showControls = true\n , controlsPosition = 'top' \n , controlLabels = {}\n , showLegend = true\n , legendPosition = 'top'\n , showXAxis = true\n , showYAxis = true\n , stacked = false\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n , controlWidth = function() { return showControls ? 180 : 0 }\n , duration = 250\n ;\n\n state.stacked = false; // DEPRECATED Maintained for backward compatibility\n\n multibar.stacked(stacked);\n\n xAxis\n .orient('left')\n .tickPadding(5)\n .showMaxMin(false)\n .tickFormat(function(d) { return d })\n ;\n yAxis\n .orient('bottom')\n .tickFormat(d3.format(',.1f'))\n ;\n\n tooltip\n .duration(0)\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n })\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n });\n\n controls.updateState(false);\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled }),\n stacked: stacked\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.stacked !== undefined)\n stacked = state.stacked;\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(multibar);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() { container.transition().duration(duration).call(chart) };\n chart.container = this;\n\n stacked = multibar.stacked();\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disableddisabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = multibar.xScale();\n y = multibar.yScale().clamp(true);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarHorizontalChart').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis')\n .append('g').attr('class', 'nv-zeroLine')\n .append('line');\n gEnter.append('g').attr('class', 'nv-barsWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n gEnter.append('g').attr('class', 'nv-controlsWrap');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth - controlWidth());\n\n g.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n if (legendPosition === 'bottom') {\n margin.bottom = xAxis.height() + legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(' + controlWidth() + ',' + (availableHeight + xAxis.height()) +')');\n } else if (legendPosition === 'top') {\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')');\n } \n }\n\n // Controls\n if (!showControls) {\n g.select('.nv-controlsWrap').selectAll('*').remove();\n } else {\n var controlsData = [\n { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() },\n { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() }\n ];\n\n controls.width(controlWidth()).color(['#444', '#444', '#444']);\n\n if (controlsPosition === 'bottom') {\n margin.bottom = xAxis.height() + legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n g.select('.nv-controlsWrap')\n .datum(controlsData)\n .attr('transform', 'translate(0,' + (availableHeight + xAxis.height()) +')')\n .call(controls); \n\n } else if (controlsPosition === 'top') {\n g.select('.nv-controlsWrap')\n .datum(controlsData)\n .attr('transform', 'translate(0,' + (-margin.top) +')')\n .call(controls); \n }\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Main Chart Component(s)\n multibar\n .disabled(data.map(function(series) { return series.disabled }))\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled }));\n\n var barsWrap = g.select('.nv-barsWrap')\n .datum(data.filter(function(d) { return !d.disabled }));\n\n barsWrap.transition().call(multibar);\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksY(availableHeight/24, data) )\n .tickSize(-availableWidth, 0);\n\n g.select('.nv-x.nv-axis').call(xAxis);\n\n var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n\n xTicks\n .selectAll('line, text');\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize( -availableHeight, 0);\n\n g.select('.nv-y.nv-axis')\n .attr('transform', 'translate(0,' + availableHeight + ')');\n g.select('.nv-y.nv-axis').call(yAxis);\n }\n\n // Zero line\n g.select(\".nv-zeroLine line\")\n .attr(\"x1\", y(0))\n .attr(\"x2\", y(0))\n .attr(\"y1\", 0)\n .attr(\"y2\", -availableHeight)\n ;\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n controls.dispatch.on('legendClick', function(d,i) {\n if (!d.disabled) return;\n controlsData = controlsData.map(function(s) {\n s.disabled = true;\n return s;\n });\n d.disabled = false;\n\n switch (d.key) {\n case 'Grouped':\n case controlLabels.grouped:\n multibar.stacked(false);\n break;\n case 'Stacked':\n case controlLabels.stacked:\n multibar.stacked(true);\n break;\n }\n\n state.stacked = multibar.stacked();\n dispatch.stateChange(state);\n stacked = multibar.stacked();\n\n chart.update();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n\n state.disabled = e.disabled;\n }\n\n if (typeof e.stacked !== 'undefined') {\n multibar.stacked(e.stacked);\n state.stacked = e.stacked;\n stacked = e.stacked;\n }\n\n chart.update();\n });\n });\n renderWatch.renderEnd('multibar horizontal chart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n multibar.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt.value = chart.x()(evt.data);\n evt['series'] = {\n key: evt.data.key,\n value: chart.y()(evt.data),\n color: evt.color\n };\n tooltip.data(evt).hidden(false);\n });\n\n multibar.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n multibar.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.multibar = multibar;\n chart.legend = legend;\n chart.controls = controls;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.state = state;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n controlsPosition: {get: function(){return controlsPosition;}, set: function(_){controlsPosition=_;}},\n showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n multibar.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n }},\n barColor: {get: function(){return multibar.barColor;}, set: function(_){\n multibar.barColor(_);\n legend.color(function(d,i) {return d3.rgb('#ccc').darker(i * 1.5).toString();})\n }}\n });\n\n nv.utils.inheritOptions(chart, multibar);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "nv.models.multiChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 30, right: 20, bottom: 50, left: 60},\n marginTop = null,\n color = nv.utils.defaultColor(),\n width = null,\n height = null,\n showLegend = true,\n noData = null,\n yDomain1,\n yDomain2,\n getX = function(d) { return d.x },\n getY = function(d) { return d.y},\n interpolate = 'linear',\n useVoronoi = true,\n interactiveLayer = nv.interactiveGuideline(),\n useInteractiveGuideline = false,\n legendRightAxisHint = ' (right axis)',\n duration = 250\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x = d3.scale.linear(),\n yScale1 = d3.scale.linear(),\n yScale2 = d3.scale.linear(),\n\n lines1 = nv.models.line().yScale(yScale1).duration(duration),\n lines2 = nv.models.line().yScale(yScale2).duration(duration),\n\n scatters1 = nv.models.scatter().yScale(yScale1).duration(duration),\n scatters2 = nv.models.scatter().yScale(yScale2).duration(duration),\n\n bars1 = nv.models.multiBar().stacked(false).yScale(yScale1).duration(duration),\n bars2 = nv.models.multiBar().stacked(false).yScale(yScale2).duration(duration),\n\n stack1 = nv.models.stackedArea().yScale(yScale1).duration(duration),\n stack2 = nv.models.stackedArea().yScale(yScale2).duration(duration),\n\n xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5).duration(duration),\n yAxis1 = nv.models.axis().scale(yScale1).orient('left').duration(duration),\n yAxis2 = nv.models.axis().scale(yScale2).orient('right').duration(duration),\n\n legend = nv.models.legend().height(30),\n tooltip = nv.models.tooltip(),\n dispatch = d3.dispatch();\n\n var charts = [lines1, lines2, scatters1, scatters2, bars1, bars2, stack1, stack2];\n\n function chart(selection) {\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n\n chart.update = function() { container.transition().call(chart); };\n chart.container = this;\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n var dataLines1 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 1});\n var dataLines2 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 2});\n var dataScatters1 = data.filter(function(d) {return d.type == 'scatter' && d.yAxis == 1});\n var dataScatters2 = data.filter(function(d) {return d.type == 'scatter' && d.yAxis == 2});\n var dataBars1 = data.filter(function(d) {return d.type == 'bar' && d.yAxis == 1});\n var dataBars2 = data.filter(function(d) {return d.type == 'bar' && d.yAxis == 2});\n var dataStack1 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 1});\n var dataStack2 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 2});\n\n // Display noData message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n var series1 = data.filter(function(d) {return !d.disabled && d.yAxis == 1})\n .map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d), y: getY(d) }\n })\n });\n\n var series2 = data.filter(function(d) {return !d.disabled && d.yAxis == 2})\n .map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d), y: getY(d) }\n })\n });\n\n x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x }))\n .range([0, availableWidth]);\n\n var wrap = container.selectAll('g.wrap.multiChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g');\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y1 nv-axis');\n gEnter.append('g').attr('class', 'nv-y2 nv-axis');\n gEnter.append('g').attr('class', 'stack1Wrap');\n gEnter.append('g').attr('class', 'stack2Wrap');\n gEnter.append('g').attr('class', 'bars1Wrap');\n gEnter.append('g').attr('class', 'bars2Wrap');\n gEnter.append('g').attr('class', 'scatters1Wrap');\n gEnter.append('g').attr('class', 'scatters2Wrap');\n gEnter.append('g').attr('class', 'lines1Wrap');\n gEnter.append('g').attr('class', 'lines2Wrap');\n gEnter.append('g').attr('class', 'legendWrap');\n gEnter.append('g').attr('class', 'nv-interactive');\n\n var g = wrap.select('g');\n\n var color_array = data.map(function(d,i) {\n return data[i].color || color(d, i);\n });\n\n // Legend\n if (!showLegend) {\n g.select('.legendWrap').selectAll('*').remove();\n } else {\n var legendWidth = legend.align() ? availableWidth / 2 : availableWidth;\n var legendXPosition = legend.align() ? legendWidth : 0;\n\n legend.width(legendWidth);\n legend.color(color_array);\n\n g.select('.legendWrap')\n .datum(data.map(function(series) {\n series.originalKey = series.originalKey === undefined ? series.key : series.originalKey;\n series.key = series.originalKey + (series.yAxis == 1 ? '' : legendRightAxisHint);\n return series;\n }))\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n g.select('.legendWrap')\n .attr('transform', 'translate(' + legendXPosition + ',' + (-margin.top) +')');\n }\n\n lines1\n .width(availableWidth)\n .height(availableHeight)\n .interpolate(interpolate)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'line'}));\n lines2\n .width(availableWidth)\n .height(availableHeight)\n .interpolate(interpolate)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'line'}));\n scatters1\n .width(availableWidth)\n .height(availableHeight)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'scatter'}));\n scatters2\n .width(availableWidth)\n .height(availableHeight)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'scatter'}));\n bars1\n .width(availableWidth)\n .height(availableHeight)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'bar'}));\n bars2\n .width(availableWidth)\n .height(availableHeight)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'bar'}));\n stack1\n .width(availableWidth)\n .height(availableHeight)\n .interpolate(interpolate)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'area'}));\n stack2\n .width(availableWidth)\n .height(availableHeight)\n .interpolate(interpolate)\n .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'area'}));\n\n g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n var lines1Wrap = g.select('.lines1Wrap')\n .datum(dataLines1.filter(function(d){return !d.disabled}));\n var scatters1Wrap = g.select('.scatters1Wrap')\n .datum(dataScatters1.filter(function(d){return !d.disabled}));\n var bars1Wrap = g.select('.bars1Wrap')\n .datum(dataBars1.filter(function(d){return !d.disabled}));\n var stack1Wrap = g.select('.stack1Wrap')\n .datum(dataStack1.filter(function(d){return !d.disabled}));\n var lines2Wrap = g.select('.lines2Wrap')\n .datum(dataLines2.filter(function(d){return !d.disabled}));\n var scatters2Wrap = g.select('.scatters2Wrap')\n .datum(dataScatters2.filter(function(d){return !d.disabled}));\n var bars2Wrap = g.select('.bars2Wrap')\n .datum(dataBars2.filter(function(d){return !d.disabled}));\n var stack2Wrap = g.select('.stack2Wrap')\n .datum(dataStack2.filter(function(d){return !d.disabled}));\n\n var extraValue1BarStacked = [];\n if (bars1.stacked() && dataBars1.length) {\n var extraValue1BarStacked = dataBars1.filter(function(d){return !d.disabled}).map(function(a){return a.values});\n \n if (extraValue1BarStacked.length > 0)\n extraValue1BarStacked = extraValue1BarStacked.reduce(function(a,b){\n return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}})\n });\n }\n if (dataBars1.length) {\n extraValue1BarStacked.push({x:0, y:0});\n }\n \n var extraValue2BarStacked = [];\n if (bars2.stacked() && dataBars2.length) {\n var extraValue2BarStacked = dataBars2.filter(function(d){return !d.disabled}).map(function(a){return a.values});\n \n if (extraValue2BarStacked.length > 0)\n extraValue2BarStacked = extraValue2BarStacked.reduce(function(a,b){\n return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}})\n });\n }\n if (dataBars2.length) {\n extraValue2BarStacked.push({x:0, y:0});\n }\n \n yScale1 .domain(yDomain1 || d3.extent(d3.merge(series1).concat(extraValue1BarStacked), function(d) { return d.y } ))\n .range([0, availableHeight]);\n\n yScale2 .domain(yDomain2 || d3.extent(d3.merge(series2).concat(extraValue2BarStacked), function(d) { return d.y } ))\n .range([0, availableHeight]);\n\n lines1.yDomain(yScale1.domain());\n scatters1.yDomain(yScale1.domain());\n bars1.yDomain(yScale1.domain());\n stack1.yDomain(yScale1.domain());\n\n lines2.yDomain(yScale2.domain());\n scatters2.yDomain(yScale2.domain());\n bars2.yDomain(yScale2.domain());\n stack2.yDomain(yScale2.domain());\n\n if(dataStack1.length){d3.transition(stack1Wrap).call(stack1);}\n if(dataStack2.length){d3.transition(stack2Wrap).call(stack2);}\n\n if(dataBars1.length){d3.transition(bars1Wrap).call(bars1);}\n if(dataBars2.length){d3.transition(bars2Wrap).call(bars2);}\n\n if(dataLines1.length){d3.transition(lines1Wrap).call(lines1);}\n if(dataLines2.length){d3.transition(lines2Wrap).call(lines2);}\n\n if(dataScatters1.length){d3.transition(scatters1Wrap).call(scatters1);}\n if(dataScatters2.length){d3.transition(scatters2Wrap).call(scatters2);}\n\n xAxis\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize(-availableHeight, 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + availableHeight + ')');\n d3.transition(g.select('.nv-x.nv-axis'))\n .call(xAxis);\n\n yAxis1\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n\n d3.transition(g.select('.nv-y1.nv-axis'))\n .call(yAxis1);\n\n yAxis2\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n d3.transition(g.select('.nv-y2.nv-axis'))\n .call(yAxis2);\n\n g.select('.nv-y1.nv-axis')\n .classed('nv-disabled', series1.length ? false : true)\n .attr('transform', 'translate(' + x.range()[0] + ',0)');\n\n g.select('.nv-y2.nv-axis')\n .classed('nv-disabled', series2.length ? false : true)\n .attr('transform', 'translate(' + x.range()[1] + ',0)');\n\n legend.dispatch.on('stateChange', function(newState) {\n chart.update();\n });\n\n if(useInteractiveGuideline){\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left:margin.left, top:margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n\n //============================================================\n // Event Handling/Dispatching\n //------------------------------------------------------------\n\n function mouseover_line(evt) {\n var yaxis = evt.series.yAxis === 2 ? yAxis2 : yAxis1;\n evt.value = evt.point.x;\n evt.series = {\n value: evt.point.y,\n color: evt.point.color,\n key: evt.series.key\n };\n tooltip\n .duration(0)\n .headerFormatter(function(d, i) {\n \treturn xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yaxis.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n }\n\n function mouseover_scatter(evt) {\n var yaxis = evt.series.yAxis === 2 ? yAxis2 : yAxis1;\n evt.value = evt.point.x;\n evt.series = {\n value: evt.point.y,\n color: evt.point.color,\n key: evt.series.key\n };\n tooltip\n .duration(100)\n .headerFormatter(function(d, i) {\n \treturn xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yaxis.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n }\n\n function mouseover_stack(evt) {\n var yaxis = evt.series.yAxis === 2 ? yAxis2 : yAxis1;\n evt.point['x'] = stack1.x()(evt.point);\n evt.point['y'] = stack1.y()(evt.point);\n tooltip\n .duration(0)\n .headerFormatter(function(d, i) {\n \treturn xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yaxis.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n }\n\n function mouseover_bar(evt) {\n var yaxis = evt.series.yAxis === 2 ? yAxis2 : yAxis1;\n\n evt.value = bars1.x()(evt.data);\n evt['series'] = {\n value: bars1.y()(evt.data),\n color: evt.color,\n key: evt.data.key\n };\n tooltip\n .duration(0)\n .headerFormatter(function(d, i) {\n \treturn xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yaxis.tickFormat()(d, i);\n })\n .data(evt)\n .hidden(false);\n }\n\n\n\n function clearHighlights() {\n for(var i=0, il=charts.length; i < il; i++){\n var chart = charts[i];\n try {\n chart.clearHighlights();\n } catch(e){}\n }\n }\n\n function highlightPoint(serieIndex, pointIndex, b){\n for(var i=0, il=charts.length; i < il; i++){\n var chart = charts[i];\n try {\n chart.highlightPoint(serieIndex, pointIndex, b);\n } catch(e){}\n }\n }\n\n if(useInteractiveGuideline){\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n clearHighlights();\n var singlePoint, pointIndex, pointXLocation, allData = [];\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled;\n })\n .forEach(function(series,i) {\n var extent = x.domain();\n var currentValues = series.values.filter(function(d,i) {\n return chart.x()(d,i) >= extent[0] && chart.x()(d,i) <= extent[1];\n });\n\n pointIndex = nv.interactiveBisect(currentValues, e.pointXValue, chart.x());\n var point = currentValues[pointIndex];\n var pointYValue = chart.y()(point, pointIndex);\n if (pointYValue !== null) {\n highlightPoint(i, pointIndex, true);\n }\n if (point === undefined) return;\n if (singlePoint === undefined) singlePoint = point;\n if (pointXLocation === undefined) pointXLocation = x(chart.x()(point,pointIndex));\n allData.push({\n key: series.key,\n value: pointYValue,\n color: color(series,series.seriesIndex),\n data: point,\n yAxis: series.yAxis == 2 ? yAxis2 : yAxis1\n });\n });\n\n var defaultValueFormatter = function(d,i) {\n var yAxis = allData[i].yAxis;\n return d == null ? \"N/A\" : yAxis.tickFormat()(d);\n };\n\n interactiveLayer.tooltip\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n })\n .valueFormatter(interactiveLayer.tooltip.valueFormatter() || defaultValueFormatter)\n .data({\n value: chart.x()( singlePoint,pointIndex ),\n index: pointIndex,\n series: allData\n })();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n clearHighlights();\n });\n } else {\n lines1.dispatch.on('elementMouseover.tooltip', mouseover_line);\n lines2.dispatch.on('elementMouseover.tooltip', mouseover_line);\n lines1.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n lines2.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n scatters1.dispatch.on('elementMouseover.tooltip', mouseover_scatter);\n scatters2.dispatch.on('elementMouseover.tooltip', mouseover_scatter);\n scatters1.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n scatters2.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n stack1.dispatch.on('elementMouseover.tooltip', mouseover_stack);\n stack2.dispatch.on('elementMouseover.tooltip', mouseover_stack);\n stack1.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n stack2.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n bars1.dispatch.on('elementMouseover.tooltip', mouseover_bar);\n bars2.dispatch.on('elementMouseover.tooltip', mouseover_bar);\n\n bars1.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n bars2.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n bars1.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n bars2.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n }\n });\n\n return chart;\n }\n\n //============================================================\n // Global getters and setters\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.legend = legend;\n chart.lines1 = lines1;\n chart.lines2 = lines2;\n chart.scatters1 = scatters1;\n chart.scatters2 = scatters2;\n chart.bars1 = bars1;\n chart.bars2 = bars2;\n chart.stack1 = stack1;\n chart.stack2 = stack2;\n chart.xAxis = xAxis;\n chart.yAxis1 = yAxis1;\n chart.yAxis2 = yAxis2;\n chart.tooltip = tooltip;\n chart.interactiveLayer = interactiveLayer;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n yDomain1: {get: function(){return yDomain1;}, set: function(_){yDomain1=_;}},\n yDomain2: {get: function(){return yDomain2;}, set: function(_){yDomain2=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n legendRightAxisHint: {get: function(){return legendRightAxisHint;}, set: function(_){legendRightAxisHint=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n x: {get: function(){return getX;}, set: function(_){\n getX = _;\n lines1.x(_);\n lines2.x(_);\n scatters1.x(_);\n scatters2.x(_);\n bars1.x(_);\n bars2.x(_);\n stack1.x(_);\n stack2.x(_);\n }},\n y: {get: function(){return getY;}, set: function(_){\n getY = _;\n lines1.y(_);\n lines2.y(_);\n scatters1.y(_);\n scatters2.y(_);\n stack1.y(_);\n stack2.y(_);\n bars1.y(_);\n bars2.y(_);\n }},\n useVoronoi: {get: function(){return useVoronoi;}, set: function(_){\n useVoronoi=_;\n lines1.useVoronoi(_);\n lines2.useVoronoi(_);\n stack1.useVoronoi(_);\n stack2.useVoronoi(_);\n }},\n\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = _;\n if (useInteractiveGuideline) {\n lines1.interactive(false);\n lines1.useVoronoi(false);\n lines2.interactive(false);\n lines2.useVoronoi(false);\n stack1.interactive(false);\n stack1.useVoronoi(false);\n stack2.interactive(false);\n stack2.useVoronoi(false);\n scatters1.interactive(false);\n scatters2.interactive(false);\n }\n }},\n\n duration: {get: function(){return duration;}, set: function(_) {\n duration = _;\n [lines1, lines2, stack1, stack2, scatters1, scatters2, xAxis, yAxis1, yAxis2].forEach(function(model){\n model.duration(duration);\n });\n }}\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.ohlcBar = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = null\n , height = null\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , x = d3.scale.linear()\n , y = d3.scale.linear()\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , getOpen = function(d) { return d.open }\n , getClose = function(d) { return d.close }\n , getHigh = function(d) { return d.high }\n , getLow = function(d) { return d.low }\n , forceX = []\n , forceY = []\n , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart\n , clipEdge = true\n , color = nv.utils.defaultColor()\n , interactive = false\n , xDomain\n , yDomain\n , xRange\n , yRange\n , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd', 'chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove')\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n function chart(selection) {\n selection.each(function(data) {\n container = d3.select(this);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n nv.utils.initSVG(container);\n\n // ohlc bar width.\n var w = (availableWidth / data[0].values.length) * .9;\n\n // Setup Scales\n x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ));\n\n if (padData)\n x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]);\n else\n x.range(xRange || [5 + w/2, availableWidth - w/2 - 5]);\n\n y.domain(yDomain || [\n d3.min(data[0].values.map(getLow).concat(forceY)),\n d3.max(data[0].values.map(getHigh).concat(forceY))\n ]\n ).range(yRange || [availableHeight, 0]);\n\n // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n if (x.domain()[0] === x.domain()[1])\n x.domain()[0] ?\n x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n : x.domain([-1,1]);\n\n if (y.domain()[0] === y.domain()[1])\n y.domain()[0] ?\n y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n : y.domain([-1,1]);\n\n // Setup containers and skeleton of chart\n var wrap = d3.select(this).selectAll('g.nv-wrap.nv-ohlcBar').data([data[0].values]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-ohlcBar');\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-ticks');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n container\n .on('click', function(d,i) {\n dispatch.chartClick({\n data: d,\n index: i,\n pos: d3.event,\n id: id\n });\n });\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-chart-clip-path-' + id)\n .append('rect');\n\n wrap.select('#nv-chart-clip-path-' + id + ' rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');\n\n var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick')\n .data(function(d) { return d });\n ticks.exit().remove();\n\n ticks.enter().append('path')\n .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i })\n .attr('d', function(d,i) {\n return 'm0,0l0,'\n + (y(getOpen(d,i))\n - y(getHigh(d,i)))\n + 'l'\n + (-w/2)\n + ',0l'\n + (w/2)\n + ',0l0,'\n + (y(getLow(d,i)) - y(getOpen(d,i)))\n + 'l0,'\n + (y(getClose(d,i))\n - y(getLow(d,i)))\n + 'l'\n + (w/2)\n + ',0l'\n + (-w/2)\n + ',0z';\n })\n .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; })\n .attr('fill', function(d,i) { return color[0]; })\n .attr('stroke', function(d,i) { return color[0]; })\n .attr('x', 0 )\n .attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) })\n .attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) });\n\n // the bar colors are controlled by CSS currently\n ticks.attr('class', function(d,i,j) {\n return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i;\n });\n\n d3.transition(ticks)\n .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; })\n .attr('d', function(d,i) {\n var w = (availableWidth / data[0].values.length) * .9;\n return 'm0,0l0,'\n + (y(getOpen(d,i))\n - y(getHigh(d,i)))\n + 'l'\n + (-w/2)\n + ',0l'\n + (w/2)\n + ',0l0,'\n + (y(getLow(d,i))\n - y(getOpen(d,i)))\n + 'l0,'\n + (y(getClose(d,i))\n - y(getLow(d,i)))\n + 'l'\n + (w/2)\n + ',0l'\n + (-w/2)\n + ',0z';\n });\n });\n\n return chart;\n }\n\n\n //Create methods to allow outside functions to highlight a specific bar.\n chart.highlightPoint = function(pointIndex, isHoverOver) {\n chart.clearHighlights();\n container.select(\".nv-ohlcBar .nv-tick-0-\" + pointIndex)\n .classed(\"hover\", isHoverOver)\n ;\n };\n\n chart.clearHighlights = function() {\n container.select(\".nv-ohlcBar .nv-tick.hover\")\n .classed(\"hover\", false)\n ;\n };\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n padData: {get: function(){return padData;}, set: function(_){padData=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n y: {get: function(){return getY;}, set: function(_){getY=_;}},\n open: {get: function(){return getOpen();}, set: function(_){getOpen=_;}},\n close: {get: function(){return getClose();}, set: function(_){getClose=_;}},\n high: {get: function(){return getHigh;}, set: function(_){getHigh=_;}},\n low: {get: function(){return getLow;}, set: function(_){getLow=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top != undefined ? _.top : margin.top;\n margin.right = _.right != undefined ? _.right : margin.right;\n margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n margin.left = _.left != undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n return chart;\n};\n", "// Code adapted from Jason Davies' \"Parallel Coordinates\"\n// http://bl.ocks.org/jasondavies/1341281\nnv.models.parallelCoordinates = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 30, right: 0, bottom: 10, left: 0}\n , width = null\n , height = null\n , availableWidth = null\n , availableHeight = null\n , x = d3.scale.ordinal()\n , y = {}\n , undefinedValuesLabel = \"undefined values\"\n , dimensionData = []\n , enabledDimensions = []\n , dimensionNames = []\n , displayBrush = true\n , color = nv.utils.defaultColor()\n , filters = []\n , active = []\n , dragging = []\n , axisWithUndefinedValues = []\n , lineTension = 1\n , foreground\n , background\n , dimensions\n , line = d3.svg.line()\n , axis = d3.svg.axis()\n , dispatch = d3.dispatch('brushstart', 'brush', 'brushEnd', 'dimensionsOrder', \"stateChange\", 'elementClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd', 'activeChanged')\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var container = d3.select(this);\n availableWidth = nv.utils.availableWidth(width, container, margin);\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n nv.utils.initSVG(container);\n\n //Convert old data to new format (name, values)\n if (data[0].values === undefined) {\n var newData = [];\n data.forEach(function (d) {\n var val = {};\n var key = Object.keys(d);\n key.forEach(function (k) { if (k !== \"name\") val[k] = d[k] });\n newData.push({ key: d.name, values: val });\n });\n data = newData;\n }\n\n var dataValues = data.map(function (d) {return d.values});\n if (active.length === 0) {\n active = data;\n }; //set all active before first brush call\n \n dimensionNames = dimensionData.sort(function (a, b) { return a.currentPosition - b.currentPosition; }).map(function (d) { return d.key });\n enabledDimensions = dimensionData.filter(function (d) { return !d.disabled; });\n \n // Setup Scales\n x.rangePoints([0, availableWidth], 1).domain(enabledDimensions.map(function (d) { return d.key; }));\n\n //Set as true if all values on an axis are missing.\n // Extract the list of dimensions and create a scale for each.\n var oldDomainMaxValue = {};\n var displayMissingValuesline = false;\n var currentTicks = [];\n \n dimensionNames.forEach(function(d) {\n var extent = d3.extent(dataValues, function (p) { return +p[d]; });\n var min = extent[0];\n var max = extent[1];\n var onlyUndefinedValues = false;\n //If there is no values to display on an axis, set the extent to 0\n if (isNaN(min) || isNaN(max)) {\n onlyUndefinedValues = true;\n min = 0;\n max = 0;\n }\n //Scale axis if there is only one value\n if (min === max) {\n min = min - 1;\n max = max + 1;\n }\n var f = filters.filter(function (k) { return k.dimension == d; });\n if (f.length !== 0) {\n //If there is only NaN values, keep the existing domain.\n if (onlyUndefinedValues) {\n min = y[d].domain()[0];\n max = y[d].domain()[1];\n }\n //If the brush extent is > max (< min), keep the extent value.\n else if (!f[0].hasOnlyNaN && displayBrush) {\n min = min > f[0].extent[0] ? f[0].extent[0] : min;\n max = max < f[0].extent[1] ? f[0].extent[1] : max;\n }\n //If there is NaN values brushed be sure the brush extent is on the domain.\n else if (f[0].hasNaN) {\n max = max < f[0].extent[1] ? f[0].extent[1] : max;\n oldDomainMaxValue[d] = y[d].domain()[1];\n displayMissingValuesline = true;\n }\n }\n //Use 90% of (availableHeight - 12) for the axis range, 12 reprensenting the space necessary to display \"undefined values\" text.\n //The remaining 10% are used to display the missingValue line.\n y[d] = d3.scale.linear()\n .domain([min, max])\n .range([(availableHeight - 12) * 0.9, 0]);\n\n axisWithUndefinedValues = [];\n y[d].brush = d3.svg.brush().y(y[d]).on('brushstart', brushstart).on('brush', brush).on('brushend', brushend);\n });\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinates').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinates');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-parallelCoordinates background');\n gEnter.append('g').attr('class', 'nv-parallelCoordinates foreground');\n gEnter.append('g').attr('class', 'nv-parallelCoordinates missingValuesline');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n line.interpolate('cardinal').tension(lineTension);\n axis.orient('left');\n var axisDrag = d3.behavior.drag()\n .on('dragstart', dragStart)\n .on('drag', dragMove)\n .on('dragend', dragEnd);\n\n //Add missing value line at the bottom of the chart\n var missingValuesline, missingValueslineText;\n var step = x.range()[1] - x.range()[0];\n step = isNaN(step) ? x.range()[0] : step;\n if (!isNaN(step)) {\n var lineData = [0 + step / 2, availableHeight - 12, availableWidth - step / 2, availableHeight - 12];\n missingValuesline = wrap.select('.missingValuesline').selectAll('line').data([lineData]);\n missingValuesline.enter().append('line');\n missingValuesline.exit().remove();\n missingValuesline.attr(\"x1\", function(d) { return d[0]; })\n .attr(\"y1\", function(d) { return d[1]; })\n .attr(\"x2\", function(d) { return d[2]; })\n .attr(\"y2\", function(d) { return d[3]; });\n \n //Add the text \"undefined values\" under the missing value line\n missingValueslineText = wrap.select('.missingValuesline').selectAll('text').data([undefinedValuesLabel]);\n missingValueslineText.append('text').data([undefinedValuesLabel]);\n missingValueslineText.enter().append('text');\n missingValueslineText.exit().remove();\n missingValueslineText.attr(\"y\", availableHeight)\n //To have the text right align with the missingValues line, substract 92 representing the text size.\n .attr(\"x\", availableWidth - 92 - step / 2)\n .text(function(d) { return d; });\n }\n // Add grey background lines for context.\n background = wrap.select('.background').selectAll('path').data(data);\n background.enter().append('path');\n background.exit().remove();\n background.attr('d', path);\n\n // Add blue foreground lines for focus.\n foreground = wrap.select('.foreground').selectAll('path').data(data);\n foreground.enter().append('path')\n foreground.exit().remove();\n foreground.attr('d', path)\n .style(\"stroke-width\", function (d, i) {\n if (isNaN(d.strokeWidth)) { d.strokeWidth = 1;} return d.strokeWidth;})\n .attr('stroke', function (d, i) { return d.color || color(d, i); });\n foreground.on(\"mouseover\", function (d, i) {\n d3.select(this).classed('hover', true).style(\"stroke-width\", d.strokeWidth + 2 + \"px\").style(\"stroke-opacity\", 1);\n dispatch.elementMouseover({\n label: d.name,\n color: d.color || color(d, i),\n values: d.values,\n dimensions: enabledDimensions\n });\n\n });\n foreground.on(\"mouseout\", function (d, i) {\n d3.select(this).classed('hover', false).style(\"stroke-width\", d.strokeWidth + \"px\").style(\"stroke-opacity\", 0.7);\n dispatch.elementMouseout({\n label: d.name,\n index: i\n });\n });\n foreground.on('mousemove', function (d, i) {\n dispatch.elementMousemove();\n });\n foreground.on('click', function (d) {\n dispatch.elementClick({\n id: d.id\n });\n });\n // Add a group element for each dimension.\n dimensions = g.selectAll('.dimension').data(enabledDimensions);\n var dimensionsEnter = dimensions.enter().append('g').attr('class', 'nv-parallelCoordinates dimension');\n\n dimensions.attr('transform', function(d) { return 'translate(' + x(d.key) + ',0)'; });\n dimensionsEnter.append('g').attr('class', 'nv-axis');\n\n // Add an axis and title.\n dimensionsEnter.append('text')\n .attr('class', 'nv-label')\n .style(\"cursor\", \"move\")\n .attr('dy', '-1em')\n .attr('text-anchor', 'middle')\n .on(\"mouseover\", function(d, i) {\n dispatch.elementMouseover({\n label: d.tooltip || d.key,\n color: d.color \n });\n })\n .on(\"mouseout\", function(d, i) {\n dispatch.elementMouseout({\n label: d.tooltip\n });\n })\n .on('mousemove', function (d, i) {\n dispatch.elementMousemove();\n })\n .call(axisDrag);\n\n dimensionsEnter.append('g').attr('class', 'nv-brushBackground');\n dimensions.exit().remove();\n dimensions.select('.nv-label').text(function (d) { return d.key });\n\n // Add and store a brush for each axis.\n restoreBrush(displayBrush);\n\n var actives = dimensionNames.filter(function (p) { return !y[p].brush.empty(); }),\n extents = actives.map(function (p) { return y[p].brush.extent(); });\n var formerActive = active.slice(0);\n\n //Restore active values\n active = [];\n foreground.style(\"display\", function (d) {\n var isActive = actives.every(function (p, i) {\n if ((isNaN(d.values[p]) || isNaN(parseFloat(d.values[p]))) && extents[i][0] == y[p].brush.y().domain()[0]) {\n return true;\n }\n return (extents[i][0] <= d.values[p] && d.values[p] <= extents[i][1]) && !isNaN(parseFloat(d.values[p]));\n });\n if (isActive)\n active.push(d);\n return !isActive ? \"none\" : null;\n\n });\n\n if (filters.length > 0 || !nv.utils.arrayEquals(active, formerActive)) {\n dispatch.activeChanged(active);\n }\n\n // Returns the path for a given data point.\n function path(d) {\n return line(enabledDimensions.map(function (p) {\n //If value if missing, put the value on the missing value line\n if (isNaN(d.values[p.key]) || isNaN(parseFloat(d.values[p.key])) || displayMissingValuesline) {\n var domain = y[p.key].domain();\n var range = y[p.key].range();\n var min = domain[0] - (domain[1] - domain[0]) / 9;\n\n //If it's not already the case, allow brush to select undefined values\n if (axisWithUndefinedValues.indexOf(p.key) < 0) {\n\n var newscale = d3.scale.linear().domain([min, domain[1]]).range([availableHeight - 12, range[1]]);\n y[p.key].brush.y(newscale);\n axisWithUndefinedValues.push(p.key);\n }\n if (isNaN(d.values[p.key]) || isNaN(parseFloat(d.values[p.key]))) {\n return [x(p.key), y[p.key](min)];\n }\n }\n\n //If parallelCoordinate contain missing values show the missing values line otherwise, hide it.\n if (missingValuesline !== undefined) {\n if (axisWithUndefinedValues.length > 0 || displayMissingValuesline) {\n missingValuesline.style(\"display\", \"inline\");\n missingValueslineText.style(\"display\", \"inline\");\n } else {\n missingValuesline.style(\"display\", \"none\");\n missingValueslineText.style(\"display\", \"none\");\n }\n }\n return [x(p.key), y[p.key](d.values[p.key])];\n }));\n }\n\n function restoreBrush(visible) {\n filters.forEach(function (f) {\n //If filter brushed NaN values, keep the brush on the bottom of the axis.\n var brushDomain = y[f.dimension].brush.y().domain();\n if (f.hasOnlyNaN) {\n f.extent[1] = (y[f.dimension].domain()[1] - brushDomain[0]) * (f.extent[1] - f.extent[0]) / (oldDomainMaxValue[f.dimension] - f.extent[0]) + brushDomain[0];\n }\n if (f.hasNaN) {\n f.extent[0] = brushDomain[0];\n }\n if (visible)\n y[f.dimension].brush.extent(f.extent);\n });\n \n dimensions.select('.nv-brushBackground')\n .each(function (d) {\n d3.select(this).call(y[d.key].brush);\n\n })\n .selectAll('rect')\n .attr('x', -8)\n .attr('width', 16);\n \n updateTicks();\n }\n \n // Handles a brush event, toggling the display of foreground lines.\n function brushstart() {\n //If brush aren't visible, show it before brushing again.\n if (displayBrush === false) {\n displayBrush = true;\n restoreBrush(true);\n }\n }\n \n // Handles a brush event, toggling the display of foreground lines.\n function brush() {\n actives = dimensionNames.filter(function (p) { return !y[p].brush.empty(); });\n extents = actives.map(function(p) { return y[p].brush.extent(); });\n\n filters = []; //erase current filters\n actives.forEach(function(d,i) {\n filters[i] = {\n dimension: d,\n extent: extents[i],\n hasNaN: false,\n hasOnlyNaN: false\n }\n });\n\n active = []; //erase current active list\n foreground.style('display', function(d) {\n var isActive = actives.every(function(p, i) {\n if ((isNaN(d.values[p]) || isNaN(parseFloat(d.values[p]))) && extents[i][0] == y[p].brush.y().domain()[0]) return true;\n return (extents[i][0] <= d.values[p] && d.values[p] <= extents[i][1]) && !isNaN(parseFloat(d.values[p]));\n });\n if (isActive) active.push(d);\n return isActive ? null : 'none';\n });\n \n updateTicks();\n \n dispatch.brush({\n filters: filters,\n active: active\n });\n }\n function brushend() {\n var hasActiveBrush = actives.length > 0 ? true : false;\n filters.forEach(function (f) {\n if (f.extent[0] === y[f.dimension].brush.y().domain()[0] && axisWithUndefinedValues.indexOf(f.dimension) >= 0)\n f.hasNaN = true;\n if (f.extent[1] < y[f.dimension].domain()[0])\n f.hasOnlyNaN = true;\n });\n dispatch.brushEnd(active, hasActiveBrush);\n } \n function updateTicks() {\n dimensions.select('.nv-axis')\n .each(function (d, i) {\n var f = filters.filter(function (k) { return k.dimension == d.key; });\n currentTicks[d.key] = y[d.key].domain();\n \n //If brush are available, display brush extent\n if (f.length != 0 && displayBrush)\n {\n currentTicks[d.key] = [];\n if (f[0].extent[1] > y[d.key].domain()[0]) \n currentTicks[d.key] = [f[0].extent[1]];\n if (f[0].extent[0] >= y[d.key].domain()[0])\n currentTicks[d.key].push(f[0].extent[0]); \n }\n \n d3.select(this).call(axis.scale(y[d.key]).tickFormat(d.format).tickValues(currentTicks[d.key]));\n });\n }\n function dragStart(d) {\n dragging[d.key] = this.parentNode.__origin__ = x(d.key);\n background.attr(\"visibility\", \"hidden\");\n }\n function dragMove(d) {\n dragging[d.key] = Math.min(availableWidth, Math.max(0, this.parentNode.__origin__ += d3.event.x));\n foreground.attr(\"d\", path);\n enabledDimensions.sort(function (a, b) { return dimensionPosition(a.key) - dimensionPosition(b.key); });\n enabledDimensions.forEach(function (d, i) { return d.currentPosition = i; });\n x.domain(enabledDimensions.map(function (d) { return d.key; }));\n dimensions.attr(\"transform\", function(d) { return \"translate(\" + dimensionPosition(d.key) + \")\"; });\n }\n function dragEnd(d, i) {\n delete this.parentNode.__origin__;\n delete dragging[d.key];\n d3.select(this.parentNode).attr(\"transform\", \"translate(\" + x(d.key) + \")\");\n foreground\n .attr(\"d\", path);\n background\n .attr(\"d\", path)\n .attr(\"visibility\", null);\n\n dispatch.dimensionsOrder(enabledDimensions);\n }\n function dimensionPosition(d) {\n var v = dragging[d];\n return v == null ? x(d) : v;\n }\n });\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width= _;}},\n height: {get: function(){return height;}, set: function(_){height= _;}},\n dimensionData: { get: function () { return dimensionData; }, set: function (_) { dimensionData = _; } },\n displayBrush: { get: function () { return displayBrush; }, set: function (_) { displayBrush = _; } },\n filters: { get: function () { return filters; }, set: function (_) { filters = _; } },\n active: { get: function () { return active; }, set: function (_) { active = _; } },\n lineTension: {get: function(){return lineTension;}, set: function(_){lineTension = _;}},\n undefinedValuesLabel : {get: function(){return undefinedValuesLabel;}, set: function(_){undefinedValuesLabel=_;}},\n \n // deprecated options\n dimensions: {get: function () { return dimensionData.map(function (d){return d.key}); }, set: function (_) {\n // deprecated after 1.8.1\n nv.deprecated('dimensions', 'use dimensionData instead');\n if (dimensionData.length === 0) {\n _.forEach(function (k) { dimensionData.push({ key: k }) })\n } else {\n _.forEach(function (k, i) { dimensionData[i].key= k })\n }\n }},\n dimensionNames: {get: function () { return dimensionData.map(function (d){return d.key}); }, set: function (_) {\n // deprecated after 1.8.1\n nv.deprecated('dimensionNames', 'use dimensionData instead');\n dimensionNames = [];\n if (dimensionData.length === 0) {\n _.forEach(function (k) { dimensionData.push({ key: k }) })\n } else {\n _.forEach(function (k, i) { dimensionData[i].key = k })\n }\n \n }},\n dimensionFormats: {get: function () { return dimensionData.map(function (d) { return d.format }); }, set: function (_) {\n // deprecated after 1.8.1\n nv.deprecated('dimensionFormats', 'use dimensionData instead');\n if (dimensionData.length === 0) {\n _.forEach(function (f) { dimensionData.push({ format: f }) })\n } else {\n _.forEach(function (f, i) { dimensionData[i].format = f })\n }\n\n }},\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n nv.utils.initOptions(chart);\n return chart;\n};\n", "nv.models.parallelCoordinatesChart = function () {\n \"use strict\";\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var parallelCoordinates = nv.models.parallelCoordinates()\n var legend = nv.models.legend()\n var tooltip = nv.models.tooltip();\n var dimensionTooltip = nv.models.tooltip();\n\n var margin = { top: 0, right: 0, bottom: 0, left: 0 }\n , marginTop = null\n , width = null\n , height = null\n , showLegend = true\n , color = nv.utils.defaultColor()\n , state = nv.utils.state()\n , dimensionData = []\n , displayBrush = true\n , defaultState = null\n , noData = null\n , nanValue = \"undefined\"\n , dispatch = d3.dispatch('dimensionsOrder', 'brushEnd', 'stateChange', 'changeState', 'renderEnd')\n , controlWidth = function () { return showControls ? 180 : 0 }\n ;\n\n\t //============================================================\n\n\t\t//============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n var stateGetter = function(data) {\n return function() {\n return {\n active: data.map(function(d) { return !d.disabled })\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if(state.active !== undefined) {\n data.forEach(function(series, i) {\n series.disabled = !state.active[i];\n });\n }\n }\n };\n\n tooltip.contentGenerator(function(data) {\n var str = '';\n if(data.series.length !== 0)\n {\n str = str + '';\n data.series.forEach(function(d){\n str = str + '';\n });\n str = str + '';\n }\n str = str + '
' + data.key + '
' + d.key + '' + d.value + '
';\n return str;\n });\n\n //============================================================\n // Chart function\n //------------------------------------------------------------\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(parallelCoordinates);\n\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n\n var that = this;\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() { container.call(chart); };\n chart.container = this;\n\n state.setter(stateSetter(dimensionData), chart.update)\n .getter(stateGetter(dimensionData))\n .update();\n\n //set state.disabled\n state.disabled = dimensionData.map(function (d) { return !!d.disabled });\n\n //Keep dimensions position in memory\n dimensionData = dimensionData.map(function (d) {d.disabled = !!d.disabled; return d});\n dimensionData.forEach(function (d, i) {\n d.originalPosition = isNaN(d.originalPosition) ? i : d.originalPosition;\n d.currentPosition = isNaN(d.currentPosition) ? i : d.currentPosition;\n });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for(key in state) {\n if(state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display No Data message if there's nothing to show.\n if(!data || !data.length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n //------------------------------------------------------------\n // Setup containers and skeleton of chart\n\n var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinatesChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinatesChart').append('g');\n\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-parallelCoordinatesWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n\n g.select(\"rect\")\n .attr(\"width\", availableWidth)\n .attr(\"height\", (availableHeight > 0) ? availableHeight : 0);\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n legend.width(availableWidth)\n .color(function (d) { return \"rgb(188,190,192)\"; });\n\n g.select('.nv-legendWrap')\n .datum(dimensionData.sort(function (a, b) { return a.originalPosition - b.originalPosition; }))\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate( 0 ,' + (-margin.top) + ')');\n }\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Main Chart Component(s)\n parallelCoordinates\n .width(availableWidth)\n .height(availableHeight)\n .dimensionData(dimensionData)\n .displayBrush(displayBrush);\n\n\t\t var parallelCoordinatesWrap = g.select('.nv-parallelCoordinatesWrap ')\n .datum(data);\n\n\t\t parallelCoordinatesWrap.transition().call(parallelCoordinates);\n\n\t\t\t\t//============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n //Display reset brush button\n\t\t parallelCoordinates.dispatch.on('brushEnd', function (active, hasActiveBrush) {\n\t\t if (hasActiveBrush) {\n\t\t displayBrush = true;\n\t\t dispatch.brushEnd(active);\n\t\t } else {\n\n\t\t displayBrush = false;\n\t\t }\n\t\t });\n\n\t\t legend.dispatch.on('stateChange', function(newState) {\n\t\t for(var key in newState) {\n\t\t state[key] = newState[key];\n\t\t }\n\t\t dispatch.stateChange(state);\n\t\t chart.update();\n\t\t });\n\n //Update dimensions order and display reset sorting button\n\t\t parallelCoordinates.dispatch.on('dimensionsOrder', function (e) {\n\t\t dimensionData.sort(function (a, b) { return a.currentPosition - b.currentPosition; });\n\t\t var isSorted = false;\n\t\t dimensionData.forEach(function (d, i) {\n\t\t d.currentPosition = i;\n\t\t if (d.currentPosition !== d.originalPosition)\n\t\t isSorted = true;\n\t\t });\n\t\t dispatch.dimensionsOrder(dimensionData, isSorted);\n\t\t });\n\n\t\t\t\t// Update chart from a state object passed to event handler\n dispatch.on('changeState', function (e) {\n\n if (typeof e.disabled !== 'undefined') {\n dimensionData.forEach(function (series, i) {\n series.disabled = e.disabled[i];\n });\n state.disabled = e.disabled;\n }\n chart.update();\n });\n });\n\n renderWatch.renderEnd('parraleleCoordinateChart immediate');\n return chart;\n }\n\n\t\t//============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n parallelCoordinates.dispatch.on('elementMouseover.tooltip', function (evt) {\n var tp = {\n key: evt.label,\n color: evt.color,\n series: []\n }\n if(evt.values){\n Object.keys(evt.values).forEach(function (d) {\n var dim = evt.dimensions.filter(function (dd) {return dd.key === d;})[0];\n if(dim){\n var v;\n if (isNaN(evt.values[d]) || isNaN(parseFloat(evt.values[d]))) {\n v = nanValue;\n } else {\n v = dim.format(evt.values[d]);\n }\n tp.series.push({ idx: dim.currentPosition, key: d, value: v, color: dim.color });\n }\n });\n tp.series.sort(function(a,b) {return a.idx - b.idx});\n }\n tooltip.data(tp).hidden(false);\n });\n\n parallelCoordinates.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n\n parallelCoordinates.dispatch.on('elementMousemove.tooltip', function () {\n tooltip();\n });\n\t\t //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n\t\t// expose chart's sub-components\n chart.dispatch = dispatch;\n chart.parallelCoordinates = parallelCoordinates;\n chart.legend = legend;\n chart.tooltip = tooltip;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: { get: function () { return width; }, set: function (_) { width = _; } },\n height: { get: function () { return height; }, set: function (_) { height = _; } },\n showLegend: { get: function () { return showLegend; }, set: function (_) { showLegend = _; } },\n defaultState: { get: function () { return defaultState; }, set: function (_) { defaultState = _; } },\n dimensionData: { get: function () { return dimensionData; }, set: function (_) { dimensionData = _; } },\n displayBrush: { get: function () { return displayBrush; }, set: function (_) { displayBrush = _; } },\n noData: { get: function () { return noData; }, set: function (_) { noData = _; } },\n nanValue: { get: function () { return nanValue; }, set: function (_) { nanValue = _; } },\n\n // options that require extra logic in the setter\n margin: {\n get: function () { return margin; },\n set: function (_) {\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }\n },\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n parallelCoordinates.color(color);\n }}\n });\n\n nv.utils.inheritOptions(chart, parallelCoordinates);\n nv.utils.initOptions(chart);\n\n return chart;\n };\n", "nv.models.pie = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 500\n , height = 500\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , color = nv.utils.defaultColor()\n , valueFormat = d3.format(',.2f')\n , showLabels = true\n , labelsOutside = false\n , labelType = \"key\"\n , labelThreshold = .02 //if slice percentage is under this, don't show label\n , hideOverlapLabels = false //Hide labels that don't fit in slice\n , donut = false\n , title = false\n , growOnHover = true\n , titleOffset = 0\n , labelSunbeamLayout = false\n , startAngle = false\n , padAngle = false\n , endAngle = false\n , cornerRadius = 0\n , donutRatio = 0.5\n , duration = 250\n , arcsRadius = []\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n ;\n\n var arcs = [];\n var arcsOver = [];\n\n //============================================================\n // chart function\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right\n , availableHeight = height - margin.top - margin.bottom\n , radius = Math.min(availableWidth, availableHeight) / 2\n , arcsRadiusOuter = []\n , arcsRadiusInner = []\n ;\n\n container = d3.select(this)\n if (arcsRadius.length === 0) {\n var outer = radius - radius / 10;\n var inner = donutRatio * radius;\n for (var i = 0; i < data[0].length; i++) {\n arcsRadiusOuter.push(outer);\n arcsRadiusInner.push(inner);\n }\n } else {\n if(growOnHover){\n arcsRadiusOuter = arcsRadius.map(function (d) { return (d.outer - d.outer / 10) * radius; });\n arcsRadiusInner = arcsRadius.map(function (d) { return (d.inner - d.inner / 10) * radius; });\n donutRatio = d3.min(arcsRadius.map(function (d) { return (d.inner - d.inner / 10); }));\n } else {\n arcsRadiusOuter = arcsRadius.map(function (d) { return d.outer * radius; });\n arcsRadiusInner = arcsRadius.map(function (d) { return d.inner * radius; });\n donutRatio = d3.min(arcsRadius.map(function (d) { return d.inner; }));\n }\n }\n nv.utils.initSVG(container);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('.nv-wrap.nv-pie').data(data);\n var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id);\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n var g_pie = gEnter.append('g').attr('class', 'nv-pie');\n gEnter.append('g').attr('class', 'nv-pieLabels');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n g.select('.nv-pie').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')');\n g.select('.nv-pieLabels').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')');\n\n //\n container.on('click', function(d,i) {\n dispatch.chartClick({\n data: d,\n index: i,\n pos: d3.event,\n id: id\n });\n });\n\n arcs = [];\n arcsOver = [];\n for (var i = 0; i < data[0].length; i++) {\n\n var arc = d3.svg.arc().outerRadius(arcsRadiusOuter[i]);\n var arcOver = d3.svg.arc().outerRadius(arcsRadiusOuter[i] + 5);\n\n if (startAngle !== false) {\n arc.startAngle(startAngle);\n arcOver.startAngle(startAngle);\n }\n if (endAngle !== false) {\n arc.endAngle(endAngle);\n arcOver.endAngle(endAngle);\n }\n if (donut) {\n arc.innerRadius(arcsRadiusInner[i]);\n arcOver.innerRadius(arcsRadiusInner[i]);\n }\n\n if (arc.cornerRadius && cornerRadius) {\n arc.cornerRadius(cornerRadius);\n arcOver.cornerRadius(cornerRadius);\n }\n\n arcs.push(arc);\n arcsOver.push(arcOver);\n }\n\n // Setup the Pie chart and choose the data element\n var pie = d3.layout.pie()\n .sort(null)\n .value(function(d) { return d.disabled ? 0 : getY(d) });\n\n // padAngle added in d3 3.5\n if (pie.padAngle && padAngle) {\n pie.padAngle(padAngle);\n }\n\n // if title is specified and donut, put it in the middle\n if (donut && title) {\n g_pie.append(\"text\").attr('class', 'nv-pie-title');\n\n wrap.select('.nv-pie-title')\n .style(\"text-anchor\", \"middle\")\n .text(function (d) {\n return title;\n })\n .style(\"font-size\", (Math.min(availableWidth, availableHeight)) * donutRatio * 2 / (title.length + 2) + \"px\")\n .attr(\"dy\", \"0.35em\") // trick to vertically center text\n .attr('transform', function(d, i) {\n return 'translate(0, '+ titleOffset + ')';\n });\n }\n\n var slices = wrap.select('.nv-pie').selectAll('.nv-slice').data(pie);\n var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label').data(pie);\n\n slices.exit().remove();\n pieLabels.exit().remove();\n\n var ae = slices.enter().append('g');\n ae.attr('class', 'nv-slice');\n ae.on('mouseover', function(d, i) {\n d3.select(this).classed('hover', true);\n if (growOnHover) {\n d3.select(this).select(\"path\").transition()\n .duration(70)\n .attr(\"d\", arcsOver[i]);\n }\n dispatch.elementMouseover({\n data: d.data,\n index: i,\n color: d3.select(this).style(\"fill\"),\n percent: (d.endAngle - d.startAngle) / (2 * Math.PI)\n });\n });\n ae.on('mouseout', function(d, i) {\n d3.select(this).classed('hover', false);\n if (growOnHover) {\n d3.select(this).select(\"path\").transition()\n .duration(50)\n .attr(\"d\", arcs[i]);\n }\n dispatch.elementMouseout({data: d.data, index: i});\n });\n ae.on('mousemove', function(d, i) {\n dispatch.elementMousemove({data: d.data, index: i});\n });\n ae.on('click', function(d, i) {\n var element = this;\n dispatch.elementClick({\n data: d.data,\n index: i,\n color: d3.select(this).style(\"fill\"),\n event: d3.event,\n element: element\n });\n });\n ae.on('dblclick', function(d, i) {\n dispatch.elementDblClick({\n data: d.data,\n index: i,\n color: d3.select(this).style(\"fill\")\n });\n });\n\n slices.attr('fill', function(d,i) { return color(d.data, i); });\n slices.attr('stroke', function(d,i) { return color(d.data, i); });\n\n var paths = ae.append('path').each(function(d) {\n this._current = d;\n });\n\n slices.select('path')\n .transition()\n .duration(duration)\n .attr('d', function (d, i) { return arcs[i](d); })\n .attrTween('d', arcTween);\n\n if (showLabels) {\n // This does the normal label\n var labelsArc = [];\n for (var i = 0; i < data[0].length; i++) {\n labelsArc.push(arcs[i]);\n\n if (labelsOutside) {\n if (donut) {\n labelsArc[i] = d3.svg.arc().outerRadius(arcs[i].outerRadius());\n if (startAngle !== false) labelsArc[i].startAngle(startAngle);\n if (endAngle !== false) labelsArc[i].endAngle(endAngle);\n }\n } else if (!donut) {\n labelsArc[i].innerRadius(0);\n }\n }\n\n pieLabels.enter().append(\"g\").classed(\"nv-label\",true).each(function(d,i) {\n var group = d3.select(this);\n\n group.attr('transform', function (d, i) {\n if (labelSunbeamLayout) {\n d.outerRadius = arcsRadiusOuter[i] + 10; // Set Outer Coordinate\n d.innerRadius = arcsRadiusOuter[i] + 15; // Set Inner Coordinate\n var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI);\n if ((d.startAngle + d.endAngle) / 2 < Math.PI) {\n rotateAngle -= 90;\n } else {\n rotateAngle += 90;\n }\n return 'translate(' + labelsArc[i].centroid(d) + ') rotate(' + rotateAngle + ')';\n } else {\n d.outerRadius = radius + 10; // Set Outer Coordinate\n d.innerRadius = radius + 15; // Set Inner Coordinate\n return 'translate(' + labelsArc[i].centroid(d) + ')'\n }\n });\n\n group.append('rect')\n .style('stroke', '#fff')\n .style('fill', '#fff')\n .attr(\"rx\", 3)\n .attr(\"ry\", 3);\n\n group.append('text')\n .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned\n .style('fill', '#000')\n });\n\n var labelLocationHash = {};\n var avgHeight = 14;\n var avgWidth = 140;\n var createHashKey = function(coordinates) {\n return Math.floor(coordinates[0]/avgWidth) * avgWidth + ',' + Math.floor(coordinates[1]/avgHeight) * avgHeight;\n };\n var getSlicePercentage = function(d) {\n return (d.endAngle - d.startAngle) / (2 * Math.PI);\n };\n\n pieLabels.watchTransition(renderWatch, 'pie labels').attr('transform', function (d, i) {\n if (labelSunbeamLayout) {\n d.outerRadius = arcsRadiusOuter[i] + 10; // Set Outer Coordinate\n d.innerRadius = arcsRadiusOuter[i] + 15; // Set Inner Coordinate\n var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI);\n if ((d.startAngle + d.endAngle) / 2 < Math.PI) {\n rotateAngle -= 90;\n } else {\n rotateAngle += 90;\n }\n return 'translate(' + labelsArc[i].centroid(d) + ') rotate(' + rotateAngle + ')';\n } else {\n d.outerRadius = radius + 10; // Set Outer Coordinate\n d.innerRadius = radius + 15; // Set Inner Coordinate\n\n /*\n Overlapping pie labels are not good. What this attempts to do is, prevent overlapping.\n Each label location is hashed, and if a hash collision occurs, we assume an overlap.\n Adjust the label's y-position to remove the overlap.\n */\n var center = labelsArc[i].centroid(d);\n var percent = getSlicePercentage(d);\n if (d.value && percent >= labelThreshold) {\n var hashKey = createHashKey(center);\n if (labelLocationHash[hashKey]) {\n center[1] -= avgHeight;\n }\n labelLocationHash[createHashKey(center)] = true;\n }\n return 'translate(' + center + ')'\n }\n });\n\n pieLabels.select(\".nv-label text\")\n .style('text-anchor', function(d,i) {\n //center the text on it's origin or begin/end if orthogonal aligned\n return labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle';\n })\n .text(function(d, i) {\n var percent = getSlicePercentage(d);\n var label = '';\n if (!d.value || percent < labelThreshold) return '';\n\n if(typeof labelType === 'function') {\n label = labelType(d, i, {\n 'key': getX(d.data),\n 'value': getY(d.data),\n 'percent': valueFormat(percent)\n });\n } else {\n switch (labelType) {\n case 'key':\n label = getX(d.data);\n break;\n case 'value':\n label = valueFormat(getY(d.data));\n break;\n case 'percent':\n label = d3.format('%')(percent);\n break;\n }\n }\n return label;\n })\n ;\n\n if (hideOverlapLabels) {\n pieLabels\n .each(function (d, i) {\n if (!this.getBBox) return;\n var bb = this.getBBox(),\n center = labelsArc[i].centroid(d);\n var topLeft = {\n x : center[0] + bb.x,\n y : center[1] + bb.y\n };\n\n var topRight = {\n x : topLeft.x + bb.width,\n y : topLeft.y\n };\n\n var bottomLeft = {\n x : topLeft.x,\n y : topLeft.y + bb.height\n };\n\n var bottomRight = {\n x : topLeft.x + bb.width,\n y : topLeft.y + bb.height\n };\n\n d.visible = nv.utils.pointIsInArc(topLeft, d, arc) &&\n nv.utils.pointIsInArc(topRight, d, arc) &&\n nv.utils.pointIsInArc(bottomLeft, d, arc) &&\n nv.utils.pointIsInArc(bottomRight, d, arc);\n })\n .style('display', function (d) {\n return d.visible ? null : 'none';\n })\n ;\n }\n\n }\n\n\n // Computes the angle of an arc, converting from radians to degrees.\n function angle(d) {\n var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90;\n return a > 90 ? a - 180 : a;\n }\n\n function arcTween(a, idx) {\n a.endAngle = isNaN(a.endAngle) ? 0 : a.endAngle;\n a.startAngle = isNaN(a.startAngle) ? 0 : a.startAngle;\n if (!donut) a.innerRadius = 0;\n var i = d3.interpolate(this._current, a);\n this._current = i(0);\n return function (t) {\n return arcs[idx](i(t));\n };\n }\n });\n\n renderWatch.renderEnd('pie immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n arcsRadius: { get: function () { return arcsRadius; }, set: function (_) { arcsRadius = _; } },\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLabels: {get: function(){return showLabels;}, set: function(_){showLabels=_;}},\n title: {get: function(){return title;}, set: function(_){title=_;}},\n titleOffset: {get: function(){return titleOffset;}, set: function(_){titleOffset=_;}},\n labelThreshold: {get: function(){return labelThreshold;}, set: function(_){labelThreshold=_;}},\n hideOverlapLabels: {get: function(){return hideOverlapLabels;}, set: function(_){hideOverlapLabels=_;}},\n valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n x: {get: function(){return getX;}, set: function(_){getX=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n endAngle: {get: function(){return endAngle;}, set: function(_){endAngle=_;}},\n startAngle: {get: function(){return startAngle;}, set: function(_){startAngle=_;}},\n padAngle: {get: function(){return padAngle;}, set: function(_){padAngle=_;}},\n cornerRadius: {get: function(){return cornerRadius;}, set: function(_){cornerRadius=_;}},\n donutRatio: {get: function(){return donutRatio;}, set: function(_){donutRatio=_;}},\n labelsOutside: {get: function(){return labelsOutside;}, set: function(_){labelsOutside=_;}},\n labelSunbeamLayout: {get: function(){return labelSunbeamLayout;}, set: function(_){labelSunbeamLayout=_;}},\n donut: {get: function(){return donut;}, set: function(_){donut=_;}},\n growOnHover: {get: function(){return growOnHover;}, set: function(_){growOnHover=_;}},\n\n // depreciated after 1.7.1\n pieLabelsOutside: {get: function(){return labelsOutside;}, set: function(_){\n labelsOutside=_;\n nv.deprecated('pieLabelsOutside', 'use labelsOutside instead');\n }},\n // depreciated after 1.7.1\n donutLabelsOutside: {get: function(){return labelsOutside;}, set: function(_){\n labelsOutside=_;\n nv.deprecated('donutLabelsOutside', 'use labelsOutside instead');\n }},\n // deprecated after 1.7.1\n labelFormat: {get: function(){ return valueFormat;}, set: function(_) {\n valueFormat=_;\n nv.deprecated('labelFormat','use valueFormat instead');\n }},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = typeof _.top != 'undefined' ? _.top : margin.top;\n margin.right = typeof _.right != 'undefined' ? _.right : margin.right;\n margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;\n margin.left = typeof _.left != 'undefined' ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }},\n y: {get: function(){return getY;}, set: function(_){\n getY=d3.functor(_);\n }},\n color: {get: function(){return color;}, set: function(_){\n color=nv.utils.getColor(_);\n }},\n labelType: {get: function(){return labelType;}, set: function(_){\n labelType= _ || 'key';\n }}\n });\n\n nv.utils.initOptions(chart);\n return chart;\n};\n", "nv.models.pieChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var pie = nv.models.pie();\n var legend = nv.models.legend();\n var tooltip = nv.models.tooltip();\n\n var margin = {top: 30, right: 20, bottom: 20, left: 20}\n , marginTop = null\n , width = null\n , height = null\n , showTooltipPercent = false\n , showLegend = true\n , legendPosition = \"top\"\n , color = nv.utils.defaultColor()\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , duration = 250\n , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n ;\n\n tooltip\n .duration(0)\n .headerEnabled(false)\n .valueFormatter(function(d, i) {\n return pie.valueFormat()(d, i);\n });\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled })\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.active !== undefined) {\n data.forEach(function (series, i) {\n series.disabled = !state.active[i];\n });\n }\n }\n };\n\n //============================================================\n // Chart function\n //------------------------------------------------------------\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(pie);\n\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n\n var that = this;\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() { container.transition().call(chart); };\n chart.container = this;\n\n state.setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n //set state.disabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-pieWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n if (legendPosition === \"top\") {\n legend.width( availableWidth ).key(pie.x());\n\n wrap.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')');\n } else if (legendPosition === \"right\") {\n var legendWidth = nv.models.legend().width();\n if (availableWidth / 2 < legendWidth) {\n legendWidth = (availableWidth / 2)\n }\n legend.height(availableHeight).key(pie.x());\n legend.width(legendWidth);\n availableWidth -= legend.width();\n\n wrap.select('.nv-legendWrap')\n .datum(data)\n .call(legend)\n .attr('transform', 'translate(' + (availableWidth) +',0)');\n } else if (legendPosition === \"bottom\") {\n legend.width( availableWidth ).key(pie.x());\n wrap.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n margin.bottom = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + availableHeight +')');\n }\n }\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Main Chart Component(s)\n pie.width(availableWidth).height(availableHeight);\n var pieWrap = g.select('.nv-pieWrap').datum([data]);\n d3.transition(pieWrap).call(pie);\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState) {\n state[key] = newState[key];\n }\n dispatch.stateChange(state);\n chart.update();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n state.disabled = e.disabled;\n }\n chart.update();\n });\n });\n\n renderWatch.renderEnd('pieChart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n pie.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt['series'] = {\n key: chart.x()(evt.data),\n value: chart.y()(evt.data),\n color: evt.color,\n percent: evt.percent\n };\n if (!showTooltipPercent) {\n delete evt.percent;\n delete evt.series.percent;\n }\n tooltip.data(evt).hidden(false);\n });\n\n pie.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n pie.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.legend = legend;\n chart.dispatch = dispatch;\n chart.pie = pie;\n chart.tooltip = tooltip;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n // use Object get/set functionality to map between vars and chart functions\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n showTooltipPercent: {get: function(){return showTooltipPercent;}, set: function(_){showTooltipPercent=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n\n // options that require extra logic in the setter\n color: {get: function(){return color;}, set: function(_){\n color = _;\n legend.color(color);\n pie.color(color);\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n pie.duration(duration);\n }},\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }}\n });\n nv.utils.inheritOptions(chart, pie);\n nv.utils.initOptions(chart);\n return chart;\n};\n", "nv.models.sankey = function() {\n 'use strict';\n\n // Sources:\n // - https://bost.ocks.org/mike/sankey/\n // - https://github.com/soxofaan/d3-plugin-captain-sankey\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var sankey = {},\n nodeWidth = 24,\n nodePadding = 8,\n size = [1, 1],\n nodes = [],\n links = [],\n sinksRight = true;\n\n var layout = function(iterations) {\n computeNodeLinks();\n computeNodeValues();\n computeNodeBreadths();\n computeNodeDepths(iterations);\n };\n\n var relayout = function() {\n computeLinkDepths();\n };\n\n // SVG path data generator, to be used as 'd' attribute on 'path' element selection.\n var link = function() {\n var curvature = .5;\n\n function link(d) {\n\n var x0 = d.source.x + d.source.dx,\n x1 = d.target.x,\n xi = d3.interpolateNumber(x0, x1),\n x2 = xi(curvature),\n x3 = xi(1 - curvature),\n y0 = d.source.y + d.sy + d.dy / 2,\n y1 = d.target.y + d.ty + d.dy / 2;\n var linkPath = 'M' + x0 + ',' + y0\n + 'C' + x2 + ',' + y0\n + ' ' + x3 + ',' + y1\n + ' ' + x1 + ',' + y1;\n return linkPath;\n }\n\n link.curvature = function(_) {\n if (!arguments.length) return curvature;\n curvature = +_;\n return link;\n };\n\n return link;\n };\n\n // Y-position of the middle of a node.\n var center = function(node) {\n return node.y + node.dy / 2;\n };\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n // Populate the sourceLinks and targetLinks for each node.\n // Also, if the source and target are not objects, assume they are indices.\n function computeNodeLinks() {\n nodes.forEach(function(node) {\n // Links that have this node as source.\n node.sourceLinks = [];\n // Links that have this node as target.\n node.targetLinks = [];\n });\n links.forEach(function(link) {\n var source = link.source,\n target = link.target;\n if (typeof source === 'number') source = link.source = nodes[link.source];\n if (typeof target === 'number') target = link.target = nodes[link.target];\n source.sourceLinks.push(link);\n target.targetLinks.push(link);\n });\n }\n\n // Compute the value (size) of each node by summing the associated links.\n function computeNodeValues() {\n nodes.forEach(function(node) {\n node.value = Math.max(\n d3.sum(node.sourceLinks, value),\n d3.sum(node.targetLinks, value)\n );\n });\n }\n\n // Iteratively assign the breadth (x-position) for each node.\n // Nodes are assigned the maximum breadth of incoming neighbors plus one;\n // nodes with no incoming links are assigned breadth zero, while\n // nodes with no outgoing links are assigned the maximum breadth.\n function computeNodeBreadths() {\n //\n var remainingNodes = nodes,\n nextNodes,\n x = 0;\n\n // Work from left to right.\n // Keep updating the breath (x-position) of nodes that are target of recently updated nodes.\n //\n while (remainingNodes.length && x < nodes.length) {\n nextNodes = [];\n remainingNodes.forEach(function(node) {\n node.x = x;\n node.dx = nodeWidth;\n node.sourceLinks.forEach(function(link) {\n if (nextNodes.indexOf(link.target) < 0) {\n nextNodes.push(link.target);\n }\n });\n });\n remainingNodes = nextNodes;\n ++x;\n //\n }\n\n // Optionally move pure sinks always to the right.\n if (sinksRight) {\n moveSinksRight(x);\n }\n\n scaleNodeBreadths((size[0] - nodeWidth) / (x - 1));\n }\n\n function moveSourcesRight() {\n nodes.forEach(function(node) {\n if (!node.targetLinks.length) {\n node.x = d3.min(node.sourceLinks, function(d) { return d.target.x; }) - 1;\n }\n });\n }\n\n function moveSinksRight(x) {\n nodes.forEach(function(node) {\n if (!node.sourceLinks.length) {\n node.x = x - 1;\n }\n });\n }\n\n function scaleNodeBreadths(kx) {\n nodes.forEach(function(node) {\n node.x *= kx;\n });\n }\n\n // Compute the depth (y-position) for each node.\n function computeNodeDepths(iterations) {\n // Group nodes by breath.\n var nodesByBreadth = d3.nest()\n .key(function(d) { return d.x; })\n .sortKeys(d3.ascending)\n .entries(nodes)\n .map(function(d) { return d.values; });\n\n //\n initializeNodeDepth();\n resolveCollisions();\n computeLinkDepths();\n for (var alpha = 1; iterations > 0; --iterations) {\n relaxRightToLeft(alpha *= .99);\n resolveCollisions();\n computeLinkDepths();\n relaxLeftToRight(alpha);\n resolveCollisions();\n computeLinkDepths();\n }\n\n function initializeNodeDepth() {\n // Calculate vertical scaling factor.\n var ky = d3.min(nodesByBreadth, function(nodes) {\n return (size[1] - (nodes.length - 1) * nodePadding) / d3.sum(nodes, value);\n });\n\n nodesByBreadth.forEach(function(nodes) {\n nodes.forEach(function(node, i) {\n node.y = i;\n node.dy = node.value * ky;\n });\n });\n\n links.forEach(function(link) {\n link.dy = link.value * ky;\n });\n }\n\n function relaxLeftToRight(alpha) {\n nodesByBreadth.forEach(function(nodes, breadth) {\n nodes.forEach(function(node) {\n if (node.targetLinks.length) {\n // Value-weighted average of the y-position of source node centers linked to this node.\n var y = d3.sum(node.targetLinks, weightedSource) / d3.sum(node.targetLinks, value);\n node.y += (y - center(node)) * alpha;\n }\n });\n });\n\n function weightedSource(link) {\n return (link.source.y + link.sy + link.dy / 2) * link.value;\n }\n }\n\n function relaxRightToLeft(alpha) {\n nodesByBreadth.slice().reverse().forEach(function(nodes) {\n nodes.forEach(function(node) {\n if (node.sourceLinks.length) {\n // Value-weighted average of the y-positions of target nodes linked to this node.\n var y = d3.sum(node.sourceLinks, weightedTarget) / d3.sum(node.sourceLinks, value);\n node.y += (y - center(node)) * alpha;\n }\n });\n });\n\n function weightedTarget(link) {\n return (link.target.y + link.ty + link.dy / 2) * link.value;\n }\n }\n\n function resolveCollisions() {\n nodesByBreadth.forEach(function(nodes) {\n var node,\n dy,\n y0 = 0,\n n = nodes.length,\n i;\n\n // Push any overlapping nodes down.\n nodes.sort(ascendingDepth);\n for (i = 0; i < n; ++i) {\n node = nodes[i];\n dy = y0 - node.y;\n if (dy > 0) node.y += dy;\n y0 = node.y + node.dy + nodePadding;\n }\n\n // If the bottommost node goes outside the bounds, push it back up.\n dy = y0 - nodePadding - size[1];\n if (dy > 0) {\n y0 = node.y -= dy;\n\n // Push any overlapping nodes back up.\n for (i = n - 2; i >= 0; --i) {\n node = nodes[i];\n dy = node.y + node.dy + nodePadding - y0;\n if (dy > 0) node.y -= dy;\n y0 = node.y;\n }\n }\n });\n }\n\n function ascendingDepth(a, b) {\n return a.y - b.y;\n }\n }\n\n // Compute y-offset of the source endpoint (sy) and target endpoints (ty) of links,\n // relative to the source/target node's y-position.\n function computeLinkDepths() {\n nodes.forEach(function(node) {\n node.sourceLinks.sort(ascendingTargetDepth);\n node.targetLinks.sort(ascendingSourceDepth);\n });\n nodes.forEach(function(node) {\n var sy = 0, ty = 0;\n node.sourceLinks.forEach(function(link) {\n link.sy = sy;\n sy += link.dy;\n });\n node.targetLinks.forEach(function(link) {\n link.ty = ty;\n ty += link.dy;\n });\n });\n\n function ascendingSourceDepth(a, b) {\n return a.source.y - b.source.y;\n }\n\n function ascendingTargetDepth(a, b) {\n return a.target.y - b.target.y;\n }\n }\n\n // Value property accessor.\n function value(x) {\n return x.value;\n }\n\n sankey.options = nv.utils.optionsFunc.bind(sankey);\n sankey._options = Object.create({}, {\n nodeWidth: {get: function(){return nodeWidth;}, set: function(_){nodeWidth=+_;}},\n nodePadding: {get: function(){return nodePadding;}, set: function(_){nodePadding=_;}},\n nodes: {get: function(){return nodes;}, set: function(_){nodes=_;}},\n links: {get: function(){return links ;}, set: function(_){links=_;}},\n size: {get: function(){return size;}, set: function(_){size=_;}},\n sinksRight: {get: function(){return sinksRight;}, set: function(_){sinksRight=_;}},\n\n layout: {get: function(){layout(32);}, set: function(_){layout(_);}},\n relayout: {get: function(){relayout();}, set: function(_){}},\n center: {get: function(){return center();}, set: function(_){\n if(typeof _ === 'function'){\n center=_;\n }\n }},\n link: {get: function(){return link();}, set: function(_){\n if(typeof _ === 'function'){\n link=_;\n }\n return link();\n }}\n });\n\n nv.utils.initOptions(sankey);\n\n return sankey;\n};\n", "nv.models.sankeyChart = function() {\n \"use strict\";\n\n // Sources:\n // - https://bost.ocks.org/mike/sankey/\n // - https://github.com/soxofaan/d3-plugin-captain-sankey\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 5, right: 0, bottom: 5, left: 0}\n , sankey = nv.models.sankey()\n , width = 600\n , height = 400\n , nodeWidth = 36\n , nodePadding = 40\n , units = 'units'\n , center = undefined\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var formatNumber = d3.format(',.0f'); // zero decimal places\n var format = function(d) {\n return formatNumber(d) + ' ' + units;\n };\n var color = d3.scale.category20();\n var linkTitle = function(d){\n return d.source.name + ' → ' + d.target.name + '\\n' + format(d.value);\n };\n var nodeFillColor = function(d){\n return d.color = color(d.name.replace(/ .*/, ''));\n };\n var nodeStrokeColor = function(d){\n return d3.rgb(d.color).darker(2);\n };\n var nodeTitle = function(d){\n return d.name + '\\n' + format(d.value);\n };\n\n var showError = function(element, message) {\n element.append('text')\n .attr('x', 0)\n .attr('y', 0)\n .attr('class', 'nvd3-sankey-chart-error')\n .attr('text-anchor', 'middle')\n .text(message);\n };\n\n function chart(selection) {\n selection.each(function(data) {\n\n var testData = {\n nodes:\n [\n {'node': 1, 'name': 'Test 1'},\n {'node': 2, 'name': 'Test 2'},\n {'node': 3, 'name': 'Test 3'},\n {'node': 4, 'name': 'Test 4'},\n {'node': 5, 'name': 'Test 5'},\n {'node': 6, 'name': 'Test 6'}\n ],\n links:\n [\n {'source': 0, 'target': 1, 'value': 2295},\n {'source': 0, 'target': 5, 'value': 1199},\n {'source': 1, 'target': 2, 'value': 1119},\n {'source': 1, 'target': 5, 'value': 1176},\n {'source': 2, 'target': 3, 'value': 487},\n {'source': 2, 'target': 5, 'value': 632},\n {'source': 3, 'target': 4, 'value': 301},\n {'source': 3, 'target': 5, 'value': 186}\n ]\n };\n\n // Error handling\n var isDataValid = false;\n var dataAvailable = false;\n\n // check if data is valid\n if(\n (typeof data['nodes'] === 'object' && data['nodes'].length) >= 0 &&\n (typeof data['links'] === 'object' && data['links'].length) >= 0\n ){\n isDataValid = true;\n }\n\n // check if data is available\n if(\n data['nodes'] && data['nodes'].length > 0 &&\n data['links'] && data['links'].length > 0\n ) {\n dataAvailable = true;\n }\n\n // show error\n if(!isDataValid) {\n console.error('NVD3 Sankey chart error:', 'invalid data format for', data);\n console.info('Valid data format is: ', testData, JSON.stringify(testData));\n showError(selection, 'Error loading chart, data is invalid');\n return false;\n }\n\n // TODO use nv.utils.noData\n if(!dataAvailable) {\n showError(selection, 'No data available');\n return false;\n }\n\n // No errors, continue\n\n // append the svg canvas to the page\n var svg = selection.append('svg')\n .attr('width', width)\n .attr('height', height)\n .append('g')\n .attr('class', 'nvd3 nv-wrap nv-sankeyChart');\n\n // Set the sankey diagram properties\n sankey\n .nodeWidth(nodeWidth)\n .nodePadding(nodePadding)\n .size([width, height]);\n\n var path = sankey.link();\n\n sankey\n .nodes(data.nodes)\n .links(data.links)\n .layout(32)\n .center(center);\n\n // add in the links\n var link = svg.append('g').selectAll('.link')\n .data(data.links)\n .enter().append('path')\n .attr('class', 'link')\n .attr('d', path)\n .style('stroke-width', function(d) { return Math.max(1, d.dy); })\n .sort(function(a,b) { return b.dy - a.dy; });\n\n // add the link titles\n link.append('title')\n .text(linkTitle);\n\n // add in the nodes\n var node = svg.append('g').selectAll('.node')\n .data(data.nodes)\n .enter().append('g')\n .attr('class', 'node')\n .attr('transform', function(d) { return 'translate(' + d.x + ',' + d.y + ')'; })\n .call(\n d3.behavior\n .drag()\n .origin(function(d) { return d; })\n .on('dragstart', function() {\n this.parentNode.appendChild(this);\n })\n .on('drag', dragmove)\n );\n\n // add the rectangles for the nodes\n node.append('rect')\n .attr('height', function(d) { return d.dy; })\n .attr('width', sankey.nodeWidth())\n .style('fill', nodeFillColor)\n .style('stroke', nodeStrokeColor)\n .append('title')\n .text(nodeTitle);\n\n // add in the title for the nodes\n node.append('text')\n .attr('x', -6)\n .attr('y', function(d) { return d.dy / 2; })\n .attr('dy', '.35em')\n .attr('text-anchor', 'end')\n .attr('transform', null)\n .text(function(d) { return d.name; })\n .filter(function(d) { return d.x < width / 2; })\n .attr('x', 6 + sankey.nodeWidth())\n .attr('text-anchor', 'start');\n\n // the function for moving the nodes\n function dragmove(d) {\n d3.select(this).attr('transform',\n 'translate(' + d.x + ',' + (\n d.y = Math.max(0, Math.min(height - d.dy, d3.event.y))\n ) + ')');\n sankey.relayout();\n link.attr('d', path);\n }\n });\n\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n units: {get: function(){return units;}, set: function(_){units=_;}},\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n format: {get: function(){return format;}, set: function(_){format=_;}},\n linkTitle: {get: function(){return linkTitle;}, set: function(_){linkTitle=_;}},\n nodeWidth: {get: function(){return nodeWidth;}, set: function(_){nodeWidth=_;}},\n nodePadding: {get: function(){return nodePadding;}, set: function(_){nodePadding=_;}},\n center: {get: function(){return center}, set: function(_){center=_}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n nodeStyle: {get: function(){return {};}, set: function(_){\n nodeFillColor = _.fillColor !== undefined ? _.fillColor : nodeFillColor;\n nodeStrokeColor = _.strokeColor !== undefined ? _.strokeColor : nodeStrokeColor;\n nodeTitle = _.title !== undefined ? _.title : nodeTitle;\n }}\n\n });\n\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.scatter = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = null\n , height = null\n , color = nv.utils.defaultColor() // chooses color\n , pointBorderColor = null\n , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't select one\n , container = null\n , x = d3.scale.linear()\n , y = d3.scale.linear()\n , z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area\n , getX = function(d) { return d.x } // accessor to get the x value\n , getY = function(d) { return d.y } // accessor to get the y value\n , getSize = function(d) { return d.size || 1} // accessor to get the point size\n , getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape\n , forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)\n , forceY = [] // List of numbers to Force into the Y scale\n , forceSize = [] // List of numbers to Force into the Size scale\n , interactive = true // If true, plots a voronoi overlay for advanced point intersection\n , pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out\n , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart\n , padDataOuter = .1 //outerPadding to imitate ordinal scale outer padding\n , clipEdge = false // if true, masks points within x and y scale\n , clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance\n , showVoronoi = false // display the voronoi areas\n , clipRadius = function() { return 25 } // function to get the radius for voronoi point clips\n , xDomain = null // Override x domain (skips the calculation from data)\n , yDomain = null // Override y domain\n , xRange = null // Override x range\n , yRange = null // Override y range\n , sizeDomain = null // Override point size domain\n , sizeRange = null\n , singlePoint = false\n , dispatch = d3.dispatch('elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd')\n , useVoronoi = true\n , duration = 250\n , interactiveUpdateDelay = 300\n , showLabels = false\n ;\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0, z0 // used to store previous scales\n , xDom, yDom // used to store previous domains\n , width0\n , height0\n , timeoutID\n , needsUpdate = false // Flag for when the points are visually updating, but the interactive layer is behind, to disable tooltips\n , renderWatch = nv.utils.renderWatch(dispatch, duration)\n , _sizeRange_def = [16, 256]\n , _cache = {}\n ;\n\n //============================================================\n // Diff and Cache Utilities\n //------------------------------------------------------------\n // getDiffs is used to filter unchanged points from the update\n // selection. It implicitly updates it's cache when called and\n // therefor the diff is based upon the previous invocation NOT\n // the previous update.\n //\n // getDiffs takes a point as its first argument followed by n\n // key getter pairs (d, [key, get... key, get]) this approach\n // was chosen for efficiency. (The filter will call it a LOT).\n //\n // It is important to call delCache on point exit to prevent a\n // memory leak. It is also needed to prevent invalid caches if\n // a new point uses the same series and point id key.\n //\n // Argument Performance Concerns:\n // - Object property lists for key getter pairs would be very\n // expensive (points * objects for the GC every update).\n // - ES6 function names for implicit keys would be nice but\n // they are not guaranteed to be unique.\n // - function.toString to obtain implicit keys is possible\n // but long object keys are not free (internal hash).\n // - Explicit key without objects are the most efficient.\n\n function getCache(d) {\n var key, val;\n key = d[0].series + ':' + d[1];\n val = _cache[key] = _cache[key] || {};\n return val;\n }\n\n function delCache(d) {\n var key, val;\n key = d[0].series + ':' + d[1];\n delete _cache[key];\n }\n\n function getDiffs(d) {\n var i, key, val,\n cache = getCache(d),\n diffs = false;\n for (i = 1; i < arguments.length; i += 2) {\n key = arguments[i];\n val = arguments[i + 1](d[0], d[1]);\n if (cache[key] !== val || !cache.hasOwnProperty(key)) {\n cache[key] = val;\n diffs = true;\n }\n }\n return diffs;\n }\n\n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n container = d3.select(this);\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n nv.utils.initSVG(container);\n\n //add series index to each data point for reference\n data.forEach(function(series, i) {\n series.values.forEach(function(point) {\n point.series = i;\n });\n });\n\n // Setup Scales\n var logScale = (typeof(chart.yScale().base) === \"function\"); // Only log scale has a method \"base()\"\n // remap and flatten the data for use in calculating the scales' domains\n var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance\n d3.merge(\n data.map(function(d) {\n return d.values.map(function(d,i) {\n return { x: getX(d,i), y: getY(d,i), size: getSize(d,i) }\n })\n })\n );\n\n x .domain(xDomain || d3.extent(seriesData.map(function(d) { return d.x; }).concat(forceX)))\n\n if (padData && data[0])\n x.range(xRange || [(availableWidth * padDataOuter + availableWidth) / (2 *data[0].values.length), availableWidth - availableWidth * (1 + padDataOuter) / (2 * data[0].values.length) ]);\n //x.range([availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]);\n else\n x.range(xRange || [0, availableWidth]);\n\n if (logScale) {\n var min = d3.min(seriesData.map(function(d) { if (d.y !== 0) return d.y; }));\n y.clamp(true)\n .domain(yDomain || d3.extent(seriesData.map(function(d) {\n if (d.y !== 0) return d.y;\n else return min * 0.1;\n }).concat(forceY)))\n .range(yRange || [availableHeight, 0]);\n } else {\n y.domain(yDomain || d3.extent(seriesData.map(function (d) { return d.y;}).concat(forceY)))\n .range(yRange || [availableHeight, 0]);\n }\n\n z .domain(sizeDomain || d3.extent(seriesData.map(function(d) { return d.size }).concat(forceSize)))\n .range(sizeRange || _sizeRange_def);\n\n // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n singlePoint = x.domain()[0] === x.domain()[1] || y.domain()[0] === y.domain()[1];\n\n if (x.domain()[0] === x.domain()[1])\n x.domain()[0] ?\n x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n : x.domain([-1,1]);\n\n if (y.domain()[0] === y.domain()[1])\n y.domain()[0] ?\n y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01])\n : y.domain([-1,1]);\n\n if ( isNaN(x.domain()[0])) {\n x.domain([-1,1]);\n }\n\n if ( isNaN(y.domain()[0])) {\n y.domain([-1,1]);\n }\n\n x0 = x0 || x;\n y0 = y0 || y;\n z0 = z0 || z;\n\n var scaleDiff = x(1) !== x0(1) || y(1) !== y0(1) || z(1) !== z0(1);\n\n width0 = width0 || width;\n height0 = height0 || height;\n\n var sizeDiff = width0 !== width || height0 !== height;\n\n // Domain Diffs\n\n xDom = xDom || [];\n var domainDiff = xDom[0] !== x.domain()[0] || xDom[1] !== x.domain()[1];\n xDom = x.domain();\n\n yDom = yDom || [];\n domainDiff = domainDiff || yDom[0] !== y.domain()[0] || yDom[1] !== y.domain()[1];\n yDom = y.domain();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-scatter').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatter nv-chart-' + id);\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n wrap.classed('nv-single-point', singlePoint);\n gEnter.append('g').attr('class', 'nv-groups');\n gEnter.append('g').attr('class', 'nv-point-paths');\n wrapEnter.append('g').attr('class', 'nv-point-clips');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-edge-clip-' + id)\n .append('rect')\n .attr('transform', 'translate( -10, -10)');\n\n wrap.select('#nv-edge-clip-' + id + ' rect')\n .attr('width', availableWidth + 20)\n .attr('height', (availableHeight > 0) ? availableHeight + 20 : 0);\n\n g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n function updateInteractiveLayer() {\n // Always clear needs-update flag regardless of whether or not\n // we will actually do anything (avoids needless invocations).\n needsUpdate = false;\n\n if (!interactive) return false;\n\n // inject series and point index for reference into voronoi\n if (useVoronoi === true) {\n\n // nuke all voronoi paths on reload and recreate them\n wrap.select('.nv-point-paths').selectAll('path').remove();\n\n var vertices = d3.merge(data.map(function(group, groupIndex) {\n return group.values\n .map(function(point, pointIndex) {\n // *Adding noise to make duplicates very unlikely\n // *Injecting series and point index for reference\n // *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.\n var pX = getX(point,pointIndex);\n var pY = getY(point,pointIndex);\n\n return [nv.utils.NaNtoZero(x(pX)) + Math.random() * 1e-4,\n nv.utils.NaNtoZero(y(pY)) + Math.random() * 1e-4,\n groupIndex,\n pointIndex, point];\n })\n .filter(function(pointArray, pointIndex) {\n return pointActive(pointArray[4], pointIndex); // Issue #237.. move filter to after map, so pointIndex is correct!\n })\n })\n );\n\n if (vertices.length == 0) return false; // No active points, we're done\n if (vertices.length < 3) {\n // Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work\n vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]);\n vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]);\n vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]);\n vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]);\n }\n\n // keep voronoi sections from going more than 10 outside of graph\n // to avoid overlap with other things like legend etc\n var bounds = d3.geom.polygon([\n [-10,-10],\n [-10,height + 10],\n [width + 10,height + 10],\n [width + 10,-10]\n ]);\n\n // delete duplicates from vertices - essential assumption for d3.geom.voronoi\n var epsilon = 1e-4; // Uses 1e-4 to determine equivalence.\n vertices = vertices.sort(function(a,b){return ((a[0] - b[0]) || (a[1] - b[1]))});\n for (var i = 0; i < vertices.length - 1; ) {\n if ((Math.abs(vertices[i][0] - vertices[i+1][0]) < epsilon) &&\n (Math.abs(vertices[i][1] - vertices[i+1][1]) < epsilon)) {\n vertices.splice(i+1, 1);\n } else {\n i++;\n }\n }\n\n var voronoi = d3.geom.voronoi(vertices).map(function(d, i) {\n return {\n 'data': bounds.clip(d),\n 'series': vertices[i][2],\n 'point': vertices[i][3]\n }\n });\n\n var pointPaths = wrap.select('.nv-point-paths').selectAll('path').data(voronoi);\n var vPointPaths = pointPaths\n .enter().append(\"svg:path\")\n .attr(\"d\", function(d) {\n if (!d || !d.data || d.data.length === 0)\n return 'M 0 0';\n else\n return \"M\" + d.data.join(\",\") + \"Z\";\n })\n .attr(\"id\", function(d,i) {\n return \"nv-path-\"+i; })\n .attr(\"clip-path\", function(d,i) { return \"url(#nv-clip-\"+id+\"-\"+i+\")\"; })\n ;\n\n // good for debugging point hover issues\n if (showVoronoi) {\n vPointPaths.style(\"fill\", d3.rgb(230, 230, 230))\n .style('fill-opacity', 0.4)\n .style('stroke-opacity', 1)\n .style(\"stroke\", d3.rgb(200,200,200));\n }\n\n if (clipVoronoi) {\n // voronoi sections are already set to clip,\n // just create the circles with the IDs they expect\n wrap.select('.nv-point-clips').selectAll('*').remove(); // must do * since it has sub-dom\n var pointClips = wrap.select('.nv-point-clips').selectAll('clipPath').data(vertices);\n var vPointClips = pointClips\n .enter().append(\"svg:clipPath\")\n .attr(\"id\", function(d, i) { return \"nv-clip-\"+id+\"-\"+i;})\n .append(\"svg:circle\")\n .attr('cx', function(d) { return d[0]; })\n .attr('cy', function(d) { return d[1]; })\n .attr('r', clipRadius);\n }\n\n var mouseEventCallback = function(el, d, mDispatch) {\n if (needsUpdate) return 0;\n var series = data[d.series];\n if (series === undefined) return;\n var point = series.values[d.point];\n point['color'] = color(series, d.series);\n\n // standardize attributes for tooltip.\n point['x'] = getX(point);\n point['y'] = getY(point);\n\n // can't just get box of event node since it's actually a voronoi polygon\n var box = container.node().getBoundingClientRect();\n var scrollTop = window.pageYOffset || document.documentElement.scrollTop;\n var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;\n\n var pos = {\n left: x(getX(point, d.point)) + box.left + scrollLeft + margin.left + 10,\n top: y(getY(point, d.point)) + box.top + scrollTop + margin.top + 10\n };\n\n mDispatch({\n point: point,\n series: series,\n pos: pos,\n relativePos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top],\n seriesIndex: d.series,\n pointIndex: d.point,\n event: d3.event,\n element: el\n });\n };\n\n pointPaths\n .on('click', function(d) {\n mouseEventCallback(this, d, dispatch.elementClick);\n })\n .on('dblclick', function(d) {\n mouseEventCallback(this, d, dispatch.elementDblClick);\n })\n .on('mouseover', function(d) {\n mouseEventCallback(this, d, dispatch.elementMouseover);\n })\n .on('mouseout', function(d, i) {\n mouseEventCallback(this, d, dispatch.elementMouseout);\n });\n\n } else {\n // add event handlers to points instead voronoi paths\n wrap.select('.nv-groups').selectAll('.nv-group')\n .selectAll('.nv-point')\n //.data(dataWithPoints)\n //.style('pointer-events', 'auto') // recativate events, disabled by css\n .on('click', function(d,i) {\n //nv.log('test', d, i);\n if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n var series = data[d.series],\n point = series.values[i];\n var element = this;\n dispatch.elementClick({\n point: point,\n series: series,\n pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], //TODO: make this pos base on the page\n relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n seriesIndex: d.series,\n pointIndex: i,\n event: d3.event,\n element: element\n });\n })\n .on('dblclick', function(d,i) {\n if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n var series = data[d.series],\n point = series.values[i];\n\n dispatch.elementDblClick({\n point: point,\n series: series,\n pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n seriesIndex: d.series,\n pointIndex: i\n });\n })\n .on('mouseover', function(d,i) {\n if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n var series = data[d.series],\n point = series.values[i];\n\n dispatch.elementMouseover({\n point: point,\n series: series,\n pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n seriesIndex: d.series,\n pointIndex: i,\n color: color(d, i)\n });\n })\n .on('mouseout', function(d,i) {\n if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n var series = data[d.series],\n point = series.values[i];\n\n dispatch.elementMouseout({\n point: point,\n series: series,\n pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n seriesIndex: d.series,\n pointIndex: i,\n color: color(d, i)\n });\n });\n }\n }\n\n needsUpdate = true;\n var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n .data(function(d) { return d }, function(d) { return d.key });\n groups.enter().append('g')\n .style('stroke-opacity', 1e-6)\n .style('fill-opacity', 1e-6);\n groups.exit()\n .remove();\n groups\n .attr('class', function(d,i) {\n return (d.classed || '') + ' nv-group nv-series-' + i;\n })\n .classed('nv-noninteractive', !interactive)\n .classed('hover', function(d) { return d.hover });\n groups.watchTransition(renderWatch, 'scatter: groups')\n .style('fill', function(d,i) { return color(d, i) })\n .style('stroke', function(d,i) { return d.pointBorderColor || pointBorderColor || color(d, i) })\n .style('stroke-opacity', 1)\n .style('fill-opacity', .5);\n\n // create the points, maintaining their IDs from the original data set\n var points = groups.selectAll('path.nv-point')\n .data(function(d) {\n return d.values.map(\n function (point, pointIndex) {\n return [point, pointIndex]\n }).filter(\n function(pointArray, pointIndex) {\n return pointActive(pointArray[0], pointIndex)\n })\n });\n points.enter().append('path')\n .attr('class', function (d) {\n return 'nv-point nv-point-' + d[1];\n })\n .style('fill', function (d) { return d.color })\n .style('stroke', function (d) { return d.color })\n .attr('transform', function(d) {\n return 'translate(' + nv.utils.NaNtoZero(x0(getX(d[0],d[1]))) + ',' + nv.utils.NaNtoZero(y0(getY(d[0],d[1]))) + ')'\n })\n .attr('d',\n nv.utils.symbol()\n .type(function(d) { return getShape(d[0]); })\n .size(function(d) { return z(getSize(d[0],d[1])) })\n );\n points.exit().each(delCache).remove();\n groups.exit().selectAll('path.nv-point')\n .watchTransition(renderWatch, 'scatter exit')\n .attr('transform', function(d) {\n return 'translate(' + nv.utils.NaNtoZero(x(getX(d[0],d[1]))) + ',' + nv.utils.NaNtoZero(y(getY(d[0],d[1]))) + ')'\n })\n .remove();\n\n //============================================================\n // Point Update Optimisation Notes\n //------------------------------------------------------------\n // The following update selections are filtered with getDiffs\n // (defined at the top of this file) this brings a performance\n // benefit for charts with large data sets that accumulate a\n // subset of changes or additions over time.\n //\n // Uneccesary and expensive DOM calls are avoided by culling\n // unchanged points from the selection in exchange for the\n // cheaper overhead of caching and diffing each point first.\n //\n // Due to the way D3 and NVD3 work, other global changes need\n // to be considered in addition to local point properties.\n // This is a potential source of bugs (if any of the global\n // changes that possibly affect points are missed).\n\n // Update Point Positions [x, y]\n points.filter(function (d) {\n // getDiffs must always be called to update cache\n return getDiffs(d, 'x', getX, 'y', getY) ||\n scaleDiff || sizeDiff || domainDiff;\n })\n .watchTransition(renderWatch, 'scatter points')\n .attr('transform', function (d) {\n return 'translate(' +\n nv.utils.NaNtoZero(x(getX(d[0], d[1]))) + ',' +\n nv.utils.NaNtoZero(y(getY(d[0], d[1]))) + ')'\n });\n\n // Update Point Appearance [shape, size]\n points.filter(function (d) {\n // getDiffs must always be called to update cache\n return getDiffs(d, 'shape', getShape, 'size', getSize) ||\n scaleDiff || sizeDiff || domainDiff;\n })\n .watchTransition(renderWatch, 'scatter points')\n .attr('d', nv.utils.symbol()\n .type(function (d) { return getShape(d[0]) })\n .size(function (d) { return z(getSize(d[0], d[1])) })\n );\n\n // add label a label to scatter chart\n if(showLabels)\n {\n var titles = groups.selectAll('.nv-label')\n .data(function(d) {\n return d.values.map(\n function (point, pointIndex) {\n return [point, pointIndex]\n }).filter(\n function(pointArray, pointIndex) {\n return pointActive(pointArray[0], pointIndex)\n })\n });\n\n titles.enter().append('text')\n .style('fill', function (d,i) {\n return d.color })\n .style('stroke-opacity', 0)\n .style('fill-opacity', 1)\n .attr('transform', function(d) {\n var dx = nv.utils.NaNtoZero(x0(getX(d[0],d[1]))) + Math.sqrt(z(getSize(d[0],d[1]))/Math.PI) + 2;\n return 'translate(' + dx + ',' + nv.utils.NaNtoZero(y0(getY(d[0],d[1]))) + ')';\n })\n .text(function(d,i){\n return d[0].label;});\n\n titles.exit().remove();\n groups.exit().selectAll('path.nv-label')\n .watchTransition(renderWatch, 'scatter exit')\n .attr('transform', function(d) {\n var dx = nv.utils.NaNtoZero(x(getX(d[0],d[1])))+ Math.sqrt(z(getSize(d[0],d[1]))/Math.PI)+2;\n return 'translate(' + dx + ',' + nv.utils.NaNtoZero(y(getY(d[0],d[1]))) + ')';\n })\n .remove();\n titles.each(function(d) {\n d3.select(this)\n .classed('nv-label', true)\n .classed('nv-label-' + d[1], false)\n .classed('hover',false);\n });\n titles.watchTransition(renderWatch, 'scatter labels')\n .attr('transform', function(d) {\n var dx = nv.utils.NaNtoZero(x(getX(d[0],d[1])))+ Math.sqrt(z(getSize(d[0],d[1]))/Math.PI)+2;\n return 'translate(' + dx + ',' + nv.utils.NaNtoZero(y(getY(d[0],d[1]))) + ')'\n });\n }\n\n // Delay updating the invisible interactive layer for smoother animation\n if( interactiveUpdateDelay )\n {\n clearTimeout(timeoutID); // stop repeat calls to updateInteractiveLayer\n timeoutID = setTimeout(updateInteractiveLayer, interactiveUpdateDelay );\n }\n else\n {\n updateInteractiveLayer();\n }\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n z0 = z.copy();\n\n width0 = width;\n height0 = height;\n\n });\n renderWatch.renderEnd('scatter immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n // utility function calls provided by this chart\n chart._calls = new function() {\n this.clearHighlights = function () {\n nv.dom.write(function() {\n container.selectAll(\".nv-point.hover\").classed(\"hover\", false);\n });\n return null;\n };\n this.highlightPoint = function (seriesIndex, pointIndex, isHoverOver) {\n nv.dom.write(function() {\n container.select('.nv-groups')\n .selectAll(\".nv-series-\" + seriesIndex)\n .selectAll(\".nv-point-\" + pointIndex)\n .classed(\"hover\", isHoverOver);\n });\n };\n };\n\n // trigger calls from events too\n dispatch.on('elementMouseover.point', function(d) {\n if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,true);\n });\n\n dispatch.on('elementMouseout.point', function(d) {\n if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,false);\n });\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n pointScale: {get: function(){return z;}, set: function(_){z=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n pointDomain: {get: function(){return sizeDomain;}, set: function(_){sizeDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n pointRange: {get: function(){return sizeRange;}, set: function(_){sizeRange=_;}},\n forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}},\n forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}},\n forcePoint: {get: function(){return forceSize;}, set: function(_){forceSize=_;}},\n interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n pointActive: {get: function(){return pointActive;}, set: function(_){pointActive=_;}},\n padDataOuter: {get: function(){return padDataOuter;}, set: function(_){padDataOuter=_;}},\n padData: {get: function(){return padData;}, set: function(_){padData=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n clipVoronoi: {get: function(){return clipVoronoi;}, set: function(_){clipVoronoi=_;}},\n clipRadius: {get: function(){return clipRadius;}, set: function(_){clipRadius=_;}},\n showVoronoi: {get: function(){return showVoronoi;}, set: function(_){showVoronoi=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n interactiveUpdateDelay: {get:function(){return interactiveUpdateDelay;}, set: function(_){interactiveUpdateDelay=_;}},\n showLabels: {get: function(){return showLabels;}, set: function(_){ showLabels = _;}},\n pointBorderColor: {get: function(){return pointBorderColor;}, set: function(_){pointBorderColor=_;}},\n\n // simple functor options\n x: {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}},\n y: {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}},\n pointSize: {get: function(){return getSize;}, set: function(_){getSize = d3.functor(_);}},\n pointShape: {get: function(){return getShape;}, set: function(_){getShape = d3.functor(_);}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n useVoronoi: {get: function(){return useVoronoi;}, set: function(_){\n useVoronoi = _;\n if (useVoronoi === false) {\n clipVoronoi = false;\n }\n }}\n });\n\n nv.utils.initOptions(chart);\n return chart;\n};\n", "\nnv.models.scatterChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var scatter = nv.models.scatter()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend()\n , distX = nv.models.distribution()\n , distY = nv.models.distribution()\n , tooltip = nv.models.tooltip()\n ;\n\n var margin = {top: 30, right: 20, bottom: 50, left: 75}\n , marginTop = null\n , width = null\n , height = null\n , container = null\n , color = nv.utils.defaultColor()\n , x = scatter.xScale()\n , y = scatter.yScale()\n , showDistX = false\n , showDistY = false\n , showLegend = true\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , state = nv.utils.state()\n , defaultState = null\n , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n , noData = null\n , duration = 250\n , showLabels = false\n ;\n\n scatter.xScale(x).yScale(y);\n xAxis.orient('bottom').tickPadding(10);\n yAxis\n .orient((rightAlignYAxis) ? 'right' : 'left')\n .tickPadding(10)\n ;\n distX.axis('x');\n distY.axis('y');\n tooltip\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n });\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var x0, y0\n , renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled })\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(scatter);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n if (showDistX) renderWatch.models(distX);\n if (showDistY) renderWatch.models(distY);\n\n selection.each(function(data) {\n var that = this;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() {\n if (duration === 0)\n container.call(chart);\n else\n container.transition().duration(duration).call(chart);\n };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disableddisabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display noData message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container);\n renderWatch.renderEnd('scatter immediate');\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n // Setup Scales\n x = scatter.xScale();\n y = scatter.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id());\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n // background for pointer events\n gEnter.append('rect').attr('class', 'nvd3 nv-background').style(\"pointer-events\",\"none\");\n\n gEnter.append('g').attr('class', 'nv-x nv-axis');\n gEnter.append('g').attr('class', 'nv-y nv-axis');\n gEnter.append('g').attr('class', 'nv-scatterWrap');\n gEnter.append('g').attr('class', 'nv-regressionLinesWrap');\n gEnter.append('g').attr('class', 'nv-distWrap');\n gEnter.append('g').attr('class', 'nv-legendWrap');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n var legendWidth = availableWidth;\n legend.width(legendWidth);\n\n wrap.select('.nv-legendWrap')\n .datum(data)\n .call(legend);\n\n if (!marginTop && legend.height() !== margin.top) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin);\n }\n\n wrap.select('.nv-legendWrap')\n .attr('transform', 'translate(0' + ',' + (-margin.top) +')');\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Main Chart Component(s)\n scatter\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n d.color = d.color || color(d, i);\n return d.color;\n }).filter(function(d,i) { return !data[i].disabled }))\n .showLabels(showLabels);\n\n wrap.select('.nv-scatterWrap')\n .datum(data.filter(function(d) { return !d.disabled }))\n .call(scatter);\n\n\n wrap.select('.nv-regressionLinesWrap')\n .attr('clip-path', 'url(#nv-edge-clip-' + scatter.id() + ')');\n\n var regWrap = wrap.select('.nv-regressionLinesWrap').selectAll('.nv-regLines')\n .data(function (d) {\n return d;\n });\n\n regWrap.enter().append('g').attr('class', 'nv-regLines');\n\n var regLine = regWrap.selectAll('.nv-regLine')\n .data(function (d) {\n return [d]\n });\n\n regLine.enter()\n .append('line').attr('class', 'nv-regLine')\n .style('stroke-opacity', 0);\n\n // don't add lines unless we have slope and intercept to use\n regLine.filter(function(d) {\n return d.intercept && d.slope;\n })\n .watchTransition(renderWatch, 'scatterPlusLineChart: regline')\n .attr('x1', x.range()[0])\n .attr('x2', x.range()[1])\n .attr('y1', function (d, i) {\n return y(x.domain()[0] * d.slope + d.intercept)\n })\n .attr('y2', function (d, i) {\n return y(x.domain()[1] * d.slope + d.intercept)\n })\n .style('stroke', function (d, i, j) {\n return color(d, j)\n })\n .style('stroke-opacity', function (d, i) {\n return (d.disabled || typeof d.slope === 'undefined' || typeof d.intercept === 'undefined') ? 0 : 1\n });\n\n // Setup Axes\n if (showXAxis) {\n xAxis\n .scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize( -availableHeight , 0);\n\n g.select('.nv-x.nv-axis')\n .attr('transform', 'translate(0,' + y.range()[0] + ')')\n .call(xAxis);\n }\n\n if (showYAxis) {\n yAxis\n .scale(y)\n ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n .tickSize( -availableWidth, 0);\n\n g.select('.nv-y.nv-axis')\n .call(yAxis);\n }\n\n // Setup Distribution\n if (showDistX) {\n distX\n .getData(scatter.x())\n .scale(x)\n .width(availableWidth)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled }));\n gEnter.select('.nv-distWrap').append('g')\n .attr('class', 'nv-distributionX');\n g.select('.nv-distributionX')\n .attr('transform', 'translate(0,' + y.range()[0] + ')')\n .datum(data.filter(function(d) { return !d.disabled }))\n .call(distX);\n }\n\n if (showDistY) {\n distY\n .getData(scatter.y())\n .scale(y)\n .width(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled }));\n gEnter.select('.nv-distWrap').append('g')\n .attr('class', 'nv-distributionY');\n g.select('.nv-distributionY')\n .attr('transform', 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)')\n .datum(data.filter(function(d) { return !d.disabled }))\n .call(distY);\n }\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n if (typeof e.disabled !== 'undefined') {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n state.disabled = e.disabled;\n }\n chart.update();\n });\n\n // mouseover needs availableHeight so we just keep scatter mouse events inside the chart block\n scatter.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n container.select('.nv-chart-' + scatter.id() + ' .nv-series-' + evt.seriesIndex + ' .nv-distx-' + evt.pointIndex)\n .attr('y1', 0);\n container.select('.nv-chart-' + scatter.id() + ' .nv-series-' + evt.seriesIndex + ' .nv-disty-' + evt.pointIndex)\n .attr('x2', distY.size());\n });\n\n scatter.dispatch.on('elementMouseover.tooltip', function(evt) {\n container.select('.nv-series-' + evt.seriesIndex + ' .nv-distx-' + evt.pointIndex)\n .attr('y1', evt.relativePos[1] - availableHeight);\n container.select('.nv-series-' + evt.seriesIndex + ' .nv-disty-' + evt.pointIndex)\n .attr('x2', evt.relativePos[0] + distX.size());\n tooltip.data(evt).hidden(false);\n });\n\n //store old scales for use in transitions on update\n x0 = x.copy();\n y0 = y.copy();\n\n });\n\n renderWatch.renderEnd('scatter with line immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.scatter = scatter;\n chart.legend = legend;\n chart.xAxis = xAxis;\n chart.yAxis = yAxis;\n chart.distX = distX;\n chart.distY = distY;\n chart.tooltip = tooltip;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n container: {get: function(){return container;}, set: function(_){container=_;}},\n showDistX: {get: function(){return showDistX;}, set: function(_){showDistX=_;}},\n showDistY: {get: function(){return showDistY;}, set: function(_){showDistY=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n duration: {get: function(){return duration;}, set: function(_){duration=_;}},\n showLabels: {get: function(){return showLabels;}, set: function(_){showLabels=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( (_) ? 'right' : 'left');\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n distX.color(color);\n distY.color(color);\n }}\n });\n\n nv.utils.inheritOptions(chart, scatter);\n nv.utils.initOptions(chart);\n return chart;\n};\n", "\nnv.models.sparkline = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 2, right: 0, bottom: 2, left: 0}\n , width = 400\n , height = 32\n , container = null\n , animate = true\n , x = d3.scale.linear()\n , y = d3.scale.linear()\n , getX = function(d) { return d.x }\n , getY = function(d) { return d.y }\n , color = nv.utils.getColor(['#000'])\n , xDomain\n , yDomain\n , xRange\n , yRange\n , showMinMaxPoints = true\n , showCurrentPoint = true\n , dispatch = d3.dispatch('renderEnd')\n ;\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n \n function chart(selection) {\n renderWatch.reset();\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup Scales\n x .domain(xDomain || d3.extent(data, getX ))\n .range(xRange || [0, availableWidth]);\n\n y .domain(yDomain || d3.extent(data, getY ))\n .range(yRange || [availableHeight, 0]);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')\n\n var paths = wrap.selectAll('path')\n .data(function(d) { return [d] });\n paths.enter().append('path');\n paths.exit().remove();\n paths\n .style('stroke', function(d,i) { return d.color || color(d, i) })\n .attr('d', d3.svg.line()\n .x(function(d,i) { return x(getX(d,i)) })\n .y(function(d,i) { return y(getY(d,i)) })\n );\n\n // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent)\n var points = wrap.selectAll('circle.nv-point')\n .data(function(data) {\n var yValues = data.map(function(d, i) { return getY(d,i); });\n function pointIndex(index) {\n if (index != -1) {\n var result = data[index];\n result.pointIndex = index;\n return result;\n } else {\n return null;\n }\n }\n var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])),\n minPoint = pointIndex(yValues.indexOf(y.domain()[0])),\n currentPoint = pointIndex(yValues.length - 1);\n return [(showMinMaxPoints ? minPoint : null), (showMinMaxPoints ? maxPoint : null), (showCurrentPoint ? currentPoint : null)].filter(function (d) {return d != null;});\n });\n points.enter().append('circle');\n points.exit().remove();\n points\n .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) })\n .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) })\n .attr('r', 2)\n .attr('class', function(d,i) {\n return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' :\n getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue'\n });\n });\n \n renderWatch.renderEnd('sparkline immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}},\n yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}},\n xScale: {get: function(){return x;}, set: function(_){x=_;}},\n yScale: {get: function(){return y;}, set: function(_){y=_;}},\n animate: {get: function(){return animate;}, set: function(_){animate=_;}},\n showMinMaxPoints: {get: function(){return showMinMaxPoints;}, set: function(_){showMinMaxPoints=_;}},\n showCurrentPoint: {get: function(){return showCurrentPoint;}, set: function(_){showCurrentPoint=_;}},\n\n //functor options\n x: {get: function(){return getX;}, set: function(_){getX=d3.functor(_);}},\n y: {get: function(){return getY;}, set: function(_){getY=d3.functor(_);}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }}\n });\n\n chart.dispatch = dispatch;\n nv.utils.initOptions(chart);\n return chart;\n};\n", "\nnv.models.sparklinePlus = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var sparkline = nv.models.sparkline();\n\n var margin = {top: 15, right: 100, bottom: 10, left: 50}\n , width = null\n , height = null\n , x\n , y\n , index = []\n , paused = false\n , xTickFormat = d3.format(',r')\n , yTickFormat = d3.format(',.2f')\n , showLastValue = true\n , alignValue = true\n , rightAlignValue = false\n , noData = null\n , dispatch = d3.dispatch('renderEnd')\n ;\n \n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(sparkline);\n selection.each(function(data) {\n var container = d3.select(this);\n nv.utils.initSVG(container);\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() { container.call(chart); };\n chart.container = this;\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n var currentValue = sparkline.y()(data[data.length-1], data.length-1);\n\n // Setup Scales\n x = sparkline.xScale();\n y = sparkline.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-sparklineWrap');\n gEnter.append('g').attr('class', 'nv-valueWrap');\n gEnter.append('g').attr('class', 'nv-hoverArea');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n // Main Chart Component(s)\n var sparklineWrap = g.select('.nv-sparklineWrap');\n\n sparkline.width(availableWidth).height(availableHeight);\n sparklineWrap.call(sparkline);\n\n if (showLastValue) {\n var valueWrap = g.select('.nv-valueWrap');\n var value = valueWrap.selectAll('.nv-currentValue')\n .data([currentValue]);\n\n value.enter().append('text').attr('class', 'nv-currentValue')\n .attr('dx', rightAlignValue ? -8 : 8)\n .attr('dy', '.9em')\n .style('text-anchor', rightAlignValue ? 'end' : 'start');\n\n value\n .attr('x', availableWidth + (rightAlignValue ? margin.right : 0))\n .attr('y', alignValue ? function (d) {\n return y(d)\n } : 0)\n .style('fill', sparkline.color()(data[data.length - 1], data.length - 1))\n .text(yTickFormat(currentValue));\n }\n\n gEnter.select('.nv-hoverArea').append('rect')\n .on('mousemove', sparklineHover)\n .on('click', function() { paused = !paused })\n .on('mouseout', function() { index = []; updateValueLine(); });\n\n g.select('.nv-hoverArea rect')\n .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' })\n .attr('width', availableWidth + margin.left + margin.right)\n .attr('height', availableHeight + margin.top);\n\n //index is currently global (within the chart), may or may not keep it that way\n function updateValueLine() {\n if (paused) return;\n\n var hoverValue = g.selectAll('.nv-hoverValue').data(index);\n\n var hoverEnter = hoverValue.enter()\n .append('g').attr('class', 'nv-hoverValue')\n .style('stroke-opacity', 0)\n .style('fill-opacity', 0);\n\n hoverValue.exit()\n .transition().duration(250)\n .style('stroke-opacity', 0)\n .style('fill-opacity', 0)\n .remove();\n\n hoverValue\n .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' })\n .transition().duration(250)\n .style('stroke-opacity', 1)\n .style('fill-opacity', 1);\n\n if (!index.length) return;\n\n hoverEnter.append('line')\n .attr('x1', 0)\n .attr('y1', -margin.top)\n .attr('x2', 0)\n .attr('y2', availableHeight);\n\n hoverEnter.append('text').attr('class', 'nv-xValue')\n .attr('x', -6)\n .attr('y', -margin.top)\n .attr('text-anchor', 'end')\n .attr('dy', '.9em');\n\n g.select('.nv-hoverValue .nv-xValue')\n .text(xTickFormat(sparkline.x()(data[index[0]], index[0])));\n\n hoverEnter.append('text').attr('class', 'nv-yValue')\n .attr('x', 6)\n .attr('y', -margin.top)\n .attr('text-anchor', 'start')\n .attr('dy', '.9em');\n\n g.select('.nv-hoverValue .nv-yValue')\n .text(yTickFormat(sparkline.y()(data[index[0]], index[0])));\n }\n\n function sparklineHover() {\n if (paused) return;\n\n var pos = d3.mouse(this)[0] - margin.left;\n\n function getClosestIndex(data, x) {\n var distance = Math.abs(sparkline.x()(data[0], 0) - x);\n var closestIndex = 0;\n for (var i = 0; i < data.length; i++){\n if (Math.abs(sparkline.x()(data[i], i) - x) < distance) {\n distance = Math.abs(sparkline.x()(data[i], i) - x);\n closestIndex = i;\n }\n }\n return closestIndex;\n }\n\n index = [getClosestIndex(data, Math.round(x.invert(pos)))];\n updateValueLine();\n }\n\n });\n renderWatch.renderEnd('sparklinePlus immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.sparkline = sparkline;\n\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n xTickFormat: {get: function(){return xTickFormat;}, set: function(_){xTickFormat=_;}},\n yTickFormat: {get: function(){return yTickFormat;}, set: function(_){yTickFormat=_;}},\n showLastValue: {get: function(){return showLastValue;}, set: function(_){showLastValue=_;}},\n alignValue: {get: function(){return alignValue;}, set: function(_){alignValue=_;}},\n rightAlignValue: {get: function(){return rightAlignValue;}, set: function(_){rightAlignValue=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }}\n });\n\n nv.utils.inheritOptions(chart, sparkline);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.stackedArea = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 960\n , height = 500\n , color = nv.utils.defaultColor() // a function that computes the color\n , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one\n , container = null\n , getX = function(d) { return d.x } // accessor to get the x value from a data point\n , getY = function(d) { return d.y } // accessor to get the y value from a data point\n , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined\n , style = 'stack'\n , offset = 'zero'\n , order = 'default'\n , interpolate = 'linear' // controls the line interpolation\n , clipEdge = false // if true, masks lines within x and y scale\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , scatter = nv.models.scatter()\n , duration = 250\n , dispatch = d3.dispatch('areaClick', 'areaMouseover', 'areaMouseout','renderEnd', 'elementClick', 'elementMouseover', 'elementMouseout')\n ;\n\n scatter\n .pointSize(2.2) // default size\n .pointDomain([2.2, 2.2]) // all the same size by default\n ;\n\n /************************************\n * offset:\n * 'wiggle' (stream)\n * 'zero' (stacked)\n * 'expand' (normalize to 100%)\n * 'silhouette' (simple centered)\n *\n * order:\n * 'inside-out' (stream)\n * 'default' (input order)\n ************************************/\n\n var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(scatter);\n selection.each(function(data) {\n var availableWidth = width - margin.left - margin.right,\n availableHeight = height - margin.top - margin.bottom;\n\n container = d3.select(this);\n nv.utils.initSVG(container);\n\n // Setup Scales\n x = scatter.xScale();\n y = scatter.yScale();\n\n var dataRaw = data;\n // Injecting point index into each point because d3.layout.stack().out does not give index\n data.forEach(function(aseries, i) {\n aseries.seriesIndex = i;\n aseries.values = aseries.values.map(function(d, j) {\n d.index = j;\n d.seriesIndex = i;\n return d;\n });\n });\n\n var dataFiltered = data.filter(function(series) {\n return !series.disabled;\n });\n\n data = d3.layout.stack()\n .order(order)\n .offset(offset)\n .values(function(d) { return d.values }) //TODO: make values customizeable in EVERY model in this fashion\n .x(getX)\n .y(getY)\n .out(function(d, y0, y) {\n d.display = {\n y: y,\n y0: y0\n };\n })\n (dataFiltered);\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]);\n var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea');\n var defsEnter = wrapEnter.append('defs');\n var gEnter = wrapEnter.append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-areaWrap');\n gEnter.append('g').attr('class', 'nv-scatterWrap');\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n \n // If the user has not specified forceY, make sure 0 is included in the domain\n // Otherwise, use user-specified values for forceY\n if (scatter.forceY().length == 0) {\n scatter.forceY().push(0);\n }\n \n scatter\n .width(availableWidth)\n .height(availableHeight)\n .x(getX)\n .y(function(d) {\n if (d.display !== undefined) { return d.display.y + d.display.y0; }\n })\n .color(data.map(function(d,i) {\n d.color = d.color || color(d, d.seriesIndex);\n return d.color;\n }));\n\n var scatterWrap = g.select('.nv-scatterWrap')\n .datum(data);\n\n scatterWrap.call(scatter);\n\n defsEnter.append('clipPath')\n .attr('id', 'nv-edge-clip-' + id)\n .append('rect');\n\n wrap.select('#nv-edge-clip-' + id + ' rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n var area = d3.svg.area()\n .defined(defined)\n .x(function(d,i) { return x(getX(d,i)) })\n .y0(function(d) {\n return y(d.display.y0)\n })\n .y1(function(d) {\n return y(d.display.y + d.display.y0)\n })\n .interpolate(interpolate);\n\n var zeroArea = d3.svg.area()\n .defined(defined)\n .x(function(d,i) { return x(getX(d,i)) })\n .y0(function(d) { return y(d.display.y0) })\n .y1(function(d) { return y(d.display.y0) });\n\n var path = g.select('.nv-areaWrap').selectAll('path.nv-area')\n .data(function(d) { return d });\n\n path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i })\n .attr('d', function(d,i){\n return zeroArea(d.values, d.seriesIndex);\n })\n .on('mouseover', function(d,i) {\n d3.select(this).classed('hover', true);\n dispatch.areaMouseover({\n point: d,\n series: d.key,\n pos: [d3.event.pageX, d3.event.pageY],\n seriesIndex: d.seriesIndex\n });\n })\n .on('mouseout', function(d,i) {\n d3.select(this).classed('hover', false);\n dispatch.areaMouseout({\n point: d,\n series: d.key,\n pos: [d3.event.pageX, d3.event.pageY],\n seriesIndex: d.seriesIndex\n });\n })\n .on('click', function(d,i) {\n d3.select(this).classed('hover', false);\n dispatch.areaClick({\n point: d,\n series: d.key,\n pos: [d3.event.pageX, d3.event.pageY],\n seriesIndex: d.seriesIndex\n });\n });\n\n path.exit().remove();\n path.style('fill', function(d,i){\n return d.color || color(d, d.seriesIndex)\n })\n .style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) });\n path.watchTransition(renderWatch,'stackedArea path')\n .attr('d', function(d,i) {\n return area(d.values,i)\n });\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n scatter.dispatch.on('elementMouseover.area', function(e) {\n g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true);\n });\n scatter.dispatch.on('elementMouseout.area', function(e) {\n g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false);\n });\n\n //Special offset functions\n chart.d3_stackedOffset_stackPercent = function(stackData) {\n var n = stackData.length, //How many series\n m = stackData[0].length, //how many points per series\n i,\n j,\n o,\n y0 = [];\n\n for (j = 0; j < m; ++j) { //Looping through all points\n for (i = 0, o = 0; i < dataRaw.length; i++) { //looping through all series\n o += getY(dataRaw[i].values[j]); //total y value of all series at a certian point in time.\n }\n\n if (o) for (i = 0; i < n; i++) { //(total y value of all series at point in time i) != 0\n stackData[i][j][1] /= o;\n } else { //(total y value of all series at point in time i) == 0\n for (i = 0; i < n; i++) {\n stackData[i][j][1] = 0;\n }\n }\n }\n for (j = 0; j < m; ++j) y0[j] = 0;\n return y0;\n };\n\n });\n\n renderWatch.renderEnd('stackedArea immediate');\n return chart;\n }\n\n //============================================================\n // Global getters and setters\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.scatter = scatter;\n\n scatter.dispatch.on('elementClick', function(){ dispatch.elementClick.apply(this, arguments); });\n scatter.dispatch.on('elementMouseover', function(){ dispatch.elementMouseover.apply(this, arguments); });\n scatter.dispatch.on('elementMouseout', function(){ dispatch.elementMouseout.apply(this, arguments); });\n\n chart.interpolate = function(_) {\n if (!arguments.length) return interpolate;\n interpolate = _;\n return chart;\n };\n\n chart.duration = function(_) {\n if (!arguments.length) return duration;\n duration = _;\n renderWatch.reset(duration);\n scatter.duration(duration);\n return chart;\n };\n\n chart.dispatch = dispatch;\n chart.scatter = scatter;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n defined: {get: function(){return defined;}, set: function(_){defined=_;}},\n clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n offset: {get: function(){return offset;}, set: function(_){offset=_;}},\n order: {get: function(){return order;}, set: function(_){order=_;}},\n interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n\n // simple functor options\n x: {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}},\n y: {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n }},\n style: {get: function(){return style;}, set: function(_){\n style = _;\n switch (style) {\n case 'stack':\n chart.offset('zero');\n chart.order('default');\n break;\n case 'stream':\n chart.offset('wiggle');\n chart.order('inside-out');\n break;\n case 'stream-center':\n chart.offset('silhouette');\n chart.order('inside-out');\n break;\n case 'expand':\n chart.offset('expand');\n chart.order('default');\n break;\n case 'stack_percent':\n chart.offset(chart.d3_stackedOffset_stackPercent);\n chart.order('default');\n break;\n }\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n scatter.duration(duration);\n }}\n });\n\n nv.utils.inheritOptions(chart, scatter);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n", "\nnv.models.stackedAreaChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var stacked = nv.models.stackedArea()\n , xAxis = nv.models.axis()\n , yAxis = nv.models.axis()\n , legend = nv.models.legend()\n , controls = nv.models.legend()\n , interactiveLayer = nv.interactiveGuideline()\n , tooltip = nv.models.tooltip()\n , focus = nv.models.focus(nv.models.stackedArea())\n ;\n\n var margin = {top: 10, right: 25, bottom: 50, left: 60}\n , marginTop = null\n , width = null\n , height = null\n , color = nv.utils.defaultColor()\n , showControls = true\n , showLegend = true\n , legendPosition = 'top'\n , showXAxis = true\n , showYAxis = true\n , rightAlignYAxis = false\n , focusEnable = false\n , useInteractiveGuideline = false\n , showTotalInTooltip = true\n , totalLabel = 'TOTAL'\n , x //can be accessed via chart.xScale()\n , y //can be accessed via chart.yScale()\n , state = nv.utils.state()\n , defaultState = null\n , noData = null\n , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n , controlWidth = 250\n , controlOptions = ['Stacked','Stream','Expanded']\n , controlLabels = {}\n , duration = 250\n ;\n\n state.style = stacked.style();\n xAxis.orient('bottom').tickPadding(7);\n yAxis.orient((rightAlignYAxis) ? 'right' : 'left');\n\n tooltip\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return yAxis.tickFormat()(d, i);\n });\n\n interactiveLayer.tooltip\n .headerFormatter(function(d, i) {\n return xAxis.tickFormat()(d, i);\n })\n .valueFormatter(function(d, i) {\n return d == null ? \"N/A\" : yAxis.tickFormat()(d, i);\n });\n\n var oldYTickFormat = null,\n oldValueFormatter = null;\n\n controls.updateState(false);\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n var style = stacked.style();\n\n var stateGetter = function(data) {\n return function(){\n return {\n active: data.map(function(d) { return !d.disabled }),\n style: stacked.style()\n };\n }\n };\n\n var stateSetter = function(data) {\n return function(state) {\n if (state.style !== undefined)\n style = state.style;\n if (state.active !== undefined)\n data.forEach(function(series,i) {\n series.disabled = !state.active[i];\n });\n }\n };\n\n var percentFormatter = d3.format('%');\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(stacked);\n if (showXAxis) renderWatch.models(xAxis);\n if (showYAxis) renderWatch.models(yAxis);\n\n selection.each(function(data) {\n var container = d3.select(this),\n that = this;\n nv.utils.initSVG(container);\n\n var availableWidth = nv.utils.availableWidth(width, container, margin),\n availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n\n chart.update = function() { container.transition().duration(duration).call(chart); };\n chart.container = this;\n\n state\n .setter(stateSetter(data), chart.update)\n .getter(stateGetter(data))\n .update();\n\n // DEPRECATED set state.disabled\n state.disabled = data.map(function(d) { return !!d.disabled });\n\n if (!defaultState) {\n var key;\n defaultState = {};\n for (key in state) {\n if (state[key] instanceof Array)\n defaultState[key] = state[key].slice(0);\n else\n defaultState[key] = state[key];\n }\n }\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n nv.utils.noData(chart, container)\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n // Setup Scales\n x = stacked.xScale();\n y = stacked.yScale();\n\n // Setup containers and skeleton of chart\n var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]);\n var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g');\n var g = wrap.select('g');\n\n gEnter.append('g').attr('class', 'nv-legendWrap');\n gEnter.append('g').attr('class', 'nv-controlsWrap');\n\n var focusEnter = gEnter.append('g').attr('class', 'nv-focus');\n focusEnter.append('g').attr('class', 'nv-background').append('rect');\n focusEnter.append('g').attr('class', 'nv-x nv-axis');\n focusEnter.append('g').attr('class', 'nv-y nv-axis');\n focusEnter.append('g').attr('class', 'nv-stackedWrap');\n focusEnter.append('g').attr('class', 'nv-interactive');\n\n // g.select(\"rect\").attr(\"width\",availableWidth).attr(\"height\",availableHeight);\n\n var contextEnter = gEnter.append('g').attr('class', 'nv-focusWrap');\n\n // Legend\n if (!showLegend) {\n g.select('.nv-legendWrap').selectAll('*').remove();\n } else {\n var legendWidth = (showControls && legendPosition === 'top') ? availableWidth - controlWidth : availableWidth;\n\n legend.width(legendWidth);\n g.select('.nv-legendWrap').datum(data).call(legend);\n\n if (legendPosition === 'bottom') {\n \t// constant from axis.js, plus some margin for better layout\n \tvar xAxisHeight = (showXAxis ? 12 : 0) + 10;\n \tmargin.bottom = Math.max(legend.height() + xAxisHeight, margin.bottom);\n \tavailableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n \tvar legendTop = availableHeight + xAxisHeight;\n g.select('.nv-legendWrap')\n .attr('transform', 'translate(0,' + legendTop +')');\n } else if (legendPosition === 'top') {\n if (!marginTop && margin.top != legend.height()) {\n margin.top = legend.height();\n availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n }\n\n g.select('.nv-legendWrap')\n \t.attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')');\n }\n }\n\n // Controls\n if (!showControls) {\n g.select('.nv-controlsWrap').selectAll('*').remove();\n } else {\n var controlsData = [\n {\n key: controlLabels.stacked || 'Stacked',\n metaKey: 'Stacked',\n disabled: stacked.style() != 'stack',\n style: 'stack'\n },\n {\n key: controlLabels.stream || 'Stream',\n metaKey: 'Stream',\n disabled: stacked.style() != 'stream',\n style: 'stream'\n },\n {\n key: controlLabels.expanded || 'Expanded',\n metaKey: 'Expanded',\n disabled: stacked.style() != 'expand',\n style: 'expand'\n },\n {\n key: controlLabels.stack_percent || 'Stack %',\n metaKey: 'Stack_Percent',\n disabled: stacked.style() != 'stack_percent',\n style: 'stack_percent'\n }\n ];\n\n controlWidth = (controlOptions.length/3) * 260;\n controlsData = controlsData.filter(function(d) {\n return controlOptions.indexOf(d.metaKey) !== -1;\n });\n\n controls\n .width( controlWidth )\n .color(['#444', '#444', '#444']);\n\n g.select('.nv-controlsWrap')\n .datum(controlsData)\n .call(controls);\n\n var requiredTop = Math.max(controls.height(), showLegend && (legendPosition === 'top') ? legend.height() : 0);\n\n if ( margin.top != requiredTop ) {\n margin.top = requiredTop;\n availableHeight = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focus.height() : 0);\n }\n\n g.select('.nv-controlsWrap')\n .attr('transform', 'translate(0,' + (-margin.top) +')');\n }\n\n wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n if (rightAlignYAxis) {\n g.select(\".nv-y.nv-axis\")\n .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n }\n\n //Set up interactive layer\n if (useInteractiveGuideline) {\n interactiveLayer\n .width(availableWidth)\n .height(availableHeight)\n .margin({left: margin.left, top: margin.top})\n .svgContainer(container)\n .xScale(x);\n wrap.select(\".nv-interactive\").call(interactiveLayer);\n }\n\n g.select('.nv-focus .nv-background rect')\n .attr('width', availableWidth)\n .attr('height', availableHeight);\n\n stacked\n .width(availableWidth)\n .height(availableHeight)\n .color(data.map(function(d,i) {\n return d.color || color(d, i);\n }).filter(function(d,i) { return !data[i].disabled; }));\n\n var stackedWrap = g.select('.nv-focus .nv-stackedWrap')\n .datum(data.filter(function(d) { return !d.disabled; }));\n\n // Setup Axes\n if (showXAxis) {\n xAxis.scale(x)\n ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n .tickSize( -availableHeight, 0);\n }\n\n if (showYAxis) {\n var ticks;\n if (stacked.offset() === 'wiggle') {\n ticks = 0;\n }\n else {\n ticks = nv.utils.calcTicksY(availableHeight/36, data);\n }\n yAxis.scale(y)\n ._ticks(ticks)\n .tickSize(-availableWidth, 0);\n }\n\n //============================================================\n // Update Axes\n //============================================================\n function updateXAxis() {\n if(showXAxis) {\n g.select('.nv-focus .nv-x.nv-axis')\n .attr('transform', 'translate(0,' + availableHeight + ')')\n .transition()\n .duration(duration)\n .call(xAxis)\n ;\n }\n }\n\n function updateYAxis() {\n if(showYAxis) {\n if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {\n var currentFormat = yAxis.tickFormat();\n\n if ( !oldYTickFormat || currentFormat !== percentFormatter )\n oldYTickFormat = currentFormat;\n\n //Forces the yAxis to use percentage in 'expand' mode.\n yAxis.tickFormat(percentFormatter);\n }\n else {\n if (oldYTickFormat) {\n yAxis.tickFormat(oldYTickFormat);\n oldYTickFormat = null;\n }\n }\n\n g.select('.nv-focus .nv-y.nv-axis')\n .transition().duration(0)\n .call(yAxis);\n }\n }\n\n //============================================================\n // Update Focus\n //============================================================\n if(!focusEnable) {\n stackedWrap.transition().call(stacked);\n updateXAxis();\n updateYAxis();\n } else {\n focus.width(availableWidth);\n g.select('.nv-focusWrap')\n .attr('transform', 'translate(0,' + ( availableHeight + margin.bottom + focus.margin().top) + ')')\n .datum(data.filter(function(d) { return !d.disabled; }))\n .call(focus);\n var extent = focus.brush.empty() ? focus.xDomain() : focus.brush.extent();\n if(extent !== null){\n onBrush(extent);\n }\n }\n\n //============================================================\n // Event Handling/Dispatching (in chart's scope)\n //------------------------------------------------------------\n\n stacked.dispatch.on('areaClick.toggle', function(e) {\n if (data.filter(function(d) { return !d.disabled }).length === 1)\n data.forEach(function(d) {\n d.disabled = false;\n });\n else\n data.forEach(function(d,i) {\n d.disabled = (i != e.seriesIndex);\n });\n\n state.disabled = data.map(function(d) { return !!d.disabled });\n dispatch.stateChange(state);\n\n chart.update();\n });\n\n legend.dispatch.on('stateChange', function(newState) {\n for (var key in newState)\n state[key] = newState[key];\n dispatch.stateChange(state);\n chart.update();\n });\n\n controls.dispatch.on('legendClick', function(d,i) {\n if (!d.disabled) return;\n\n controlsData = controlsData.map(function(s) {\n s.disabled = true;\n return s;\n });\n d.disabled = false;\n\n stacked.style(d.style);\n\n\n state.style = stacked.style();\n dispatch.stateChange(state);\n\n chart.update();\n });\n\n interactiveLayer.dispatch.on('elementMousemove', function(e) {\n stacked.clearHighlights();\n var singlePoint, pointIndex, pointXLocation, allData = [], valueSum = 0, allNullValues = true, atleastOnePoint = false;\n data\n .filter(function(series, i) {\n series.seriesIndex = i;\n return !series.disabled;\n })\n .forEach(function(series,i) {\n pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n var point = series.values[pointIndex];\n var pointYValue = chart.y()(point, pointIndex);\n if (pointYValue != null && pointYValue > 0) {\n stacked.highlightPoint(i, pointIndex, true);\n atleastOnePoint = true;\n }\n \n // Draw at least one point if all values are zero.\n if (i === (data.length - 1) && !atleastOnePoint) {\n stacked.highlightPoint(i, pointIndex, true);\n }\n if (typeof point === 'undefined') return;\n if (typeof singlePoint === 'undefined') singlePoint = point;\n if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n\n //If we are in 'expand' mode, use the stacked percent value instead of raw value.\n var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex);\n allData.push({\n key: series.key,\n value: tooltipValue,\n color: color(series,series.seriesIndex),\n point: point\n });\n\n if (showTotalInTooltip && stacked.style() != 'expand' && tooltipValue != null) {\n valueSum += tooltipValue;\n allNullValues = false;\n };\n });\n\n allData.reverse();\n\n //Highlight the tooltip entry based on which stack the mouse is closest to.\n if (allData.length > 2) {\n var yValue = chart.yScale().invert(e.mouseY);\n var yDistMax = Infinity, indexToHighlight = null;\n allData.forEach(function(series,i) {\n\n //To handle situation where the stacked area chart is negative, we need to use absolute values\n //when checking if the mouse Y value is within the stack area.\n yValue = Math.abs(yValue);\n var stackedY0 = Math.abs(series.point.display.y0);\n var stackedY = Math.abs(series.point.display.y);\n if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0))\n {\n indexToHighlight = i;\n return;\n }\n });\n if (indexToHighlight != null)\n allData[indexToHighlight].highlight = true;\n }\n\n //If we are not in 'expand' mode, add a 'Total' row to the tooltip.\n if (showTotalInTooltip && stacked.style() != 'expand' && allData.length >= 2 && !allNullValues) {\n allData.push({\n key: totalLabel,\n value: valueSum,\n total: true\n });\n }\n\n var xValue = chart.x()(singlePoint,pointIndex);\n\n var valueFormatter = interactiveLayer.tooltip.valueFormatter();\n // Keeps track of the tooltip valueFormatter if the chart changes to expanded view\n if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {\n if ( !oldValueFormatter ) {\n oldValueFormatter = valueFormatter;\n }\n //Forces the tooltip to use percentage in 'expand' mode.\n valueFormatter = d3.format(\".1%\");\n }\n else {\n if (oldValueFormatter) {\n valueFormatter = oldValueFormatter;\n oldValueFormatter = null;\n }\n }\n\n interactiveLayer.tooltip\n .valueFormatter(valueFormatter)\n .data(\n {\n value: xValue,\n series: allData\n }\n )();\n\n interactiveLayer.renderGuideLine(pointXLocation);\n\n });\n\n interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n stacked.clearHighlights();\n });\n\n /* Update `main' graph on brush update. */\n focus.dispatch.on(\"onBrush\", function(extent) {\n onBrush(extent);\n });\n\n // Update chart from a state object passed to event handler\n dispatch.on('changeState', function(e) {\n\n if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) {\n data.forEach(function(series,i) {\n series.disabled = e.disabled[i];\n });\n\n state.disabled = e.disabled;\n }\n\n if (typeof e.style !== 'undefined') {\n stacked.style(e.style);\n style = e.style;\n }\n\n chart.update();\n });\n\n //============================================================\n // Functions\n //------------------------------------------------------------\n\n function onBrush(extent) {\n // Update Main (Focus)\n var stackedWrap = g.select('.nv-focus .nv-stackedWrap')\n .datum(\n data.filter(function(d) { return !d.disabled; })\n .map(function(d,i) {\n return {\n key: d.key,\n area: d.area,\n classed: d.classed,\n values: d.values.filter(function(d,i) {\n return stacked.x()(d,i) >= extent[0] && stacked.x()(d,i) <= extent[1];\n }),\n disableTooltip: d.disableTooltip\n };\n })\n );\n stackedWrap.transition().duration(duration).call(stacked);\n\n // Update Main (Focus) Axes\n updateXAxis();\n updateYAxis();\n }\n\n });\n\n renderWatch.renderEnd('stacked Area chart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n stacked.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt.point['x'] = stacked.x()(evt.point);\n evt.point['y'] = stacked.y()(evt.point);\n tooltip.data(evt).hidden(false);\n });\n\n stacked.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true)\n });\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.stacked = stacked;\n chart.legend = legend;\n chart.controls = controls;\n chart.xAxis = xAxis;\n chart.x2Axis = focus.xAxis;\n chart.yAxis = yAxis;\n chart.y2Axis = focus.yAxis;\n chart.interactiveLayer = interactiveLayer;\n chart.tooltip = tooltip;\n chart.focus = focus;\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n controlOptions: {get: function(){return controlOptions;}, set: function(_){controlOptions=_;}},\n showTotalInTooltip: {get: function(){return showTotalInTooltip;}, set: function(_){showTotalInTooltip=_;}},\n totalLabel: {get: function(){return totalLabel;}, set: function(_){totalLabel=_;}},\n focusEnable: {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}},\n focusHeight: {get: function(){return focus.height();}, set: function(_){focus.height(_);}},\n brushExtent: {get: function(){return focus.brushExtent();}, set: function(_){focus.brushExtent(_);}},\n\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n if (_.top !== undefined) {\n margin.top = _.top;\n marginTop = _.top;\n }\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n }},\n focusMargin: {get: function(){return focus.margin}, set: function(_){\n focus.margin.top = _.top !== undefined ? _.top : focus.margin.top;\n focus.margin.right = _.right !== undefined ? _.right : focus.margin.right;\n focus.margin.bottom = _.bottom !== undefined ? _.bottom : focus.margin.bottom;\n focus.margin.left = _.left !== undefined ? _.left : focus.margin.left;\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n stacked.duration(duration);\n xAxis.duration(duration);\n yAxis.duration(duration);\n }},\n color: {get: function(){return color;}, set: function(_){\n color = nv.utils.getColor(_);\n legend.color(color);\n stacked.color(color);\n focus.color(color);\n }},\n x: {get: function(){return stacked.x();}, set: function(_){\n stacked.x(_);\n focus.x(_);\n }},\n y: {get: function(){return stacked.y();}, set: function(_){\n stacked.y(_);\n focus.y(_);\n }},\n rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n rightAlignYAxis = _;\n yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n }},\n useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n useInteractiveGuideline = !!_;\n chart.interactive(!_);\n chart.useVoronoi(!_);\n stacked.scatter.interactive(!_);\n }}\n });\n\n nv.utils.inheritOptions(chart, stacked);\n nv.utils.initOptions(chart);\n\n return chart;\n};\n\nnv.models.stackedAreaWithFocusChart = function() {\n return nv.models.stackedAreaChart()\n .margin({ bottom: 30 })\n .focusEnable( true );\n};\n", "// based on http://bl.ocks.org/kerryrodden/477c1bfb081b783f80ad\nnv.models.sunburst = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var margin = {top: 0, right: 0, bottom: 0, left: 0}\n , width = 600\n , height = 600\n , mode = \"count\"\n , modes = {count: function(d) { return 1; }, value: function(d) { return d.value || d.size }, size: function(d) { return d.value || d.size }}\n , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n , container = null\n , color = nv.utils.defaultColor()\n , showLabels = false\n , labelFormat = function(d){if(mode === 'count'){return d.name + ' #' + d.value}else{return d.name + ' ' + (d.value || d.size)}}\n , labelThreshold = 0.02\n , sort = function(d1, d2){return d1.name > d2.name;}\n , key = function(d,i){\n if (d.parent !== undefined) {\n return d.name + '-' + d.parent.name + '-' + i;\n } else {\n return d.name;\n }\n }\n , groupColorByParent = true\n , duration = 500\n , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMousemove', 'elementMouseover', 'elementMouseout', 'renderEnd');\n\n //============================================================\n // aux functions and setup\n //------------------------------------------------------------\n\n var x = d3.scale.linear().range([0, 2 * Math.PI]);\n var y = d3.scale.sqrt();\n\n var partition = d3.layout.partition().sort(sort);\n\n var node, availableWidth, availableHeight, radius;\n var prevPositions = {};\n\n var arc = d3.svg.arc()\n .startAngle(function(d) {return Math.max(0, Math.min(2 * Math.PI, x(d.x))) })\n .endAngle(function(d) {return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))) })\n .innerRadius(function(d) {return Math.max(0, y(d.y)) })\n .outerRadius(function(d) {return Math.max(0, y(d.y + d.dy)) });\n\n function rotationToAvoidUpsideDown(d) {\n var centerAngle = computeCenterAngle(d);\n if(centerAngle > 90){\n return 180;\n }\n else {\n return 0;\n }\n }\n\n function computeCenterAngle(d) {\n var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));\n var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));\n var centerAngle = (((startAngle + endAngle) / 2) * (180 / Math.PI)) - 90;\n return centerAngle;\n }\n\n function computeNodePercentage(d) {\n var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));\n var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));\n return (endAngle - startAngle) / (2 * Math.PI);\n }\n\n function labelThresholdMatched(d) {\n var startAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x)));\n var endAngle = Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));\n\n var size = endAngle - startAngle;\n return size > labelThreshold;\n }\n\n // When zooming: interpolate the scales.\n function arcTweenZoom(e,i) {\n var xd = d3.interpolate(x.domain(), [node.x, node.x + node.dx]),\n yd = d3.interpolate(y.domain(), [node.y, 1]),\n yr = d3.interpolate(y.range(), [node.y ? 20 : 0, radius]);\n\n if (i === 0) {\n return function() {return arc(e);}\n }\n else {\n return function (t) {\n x.domain(xd(t));\n y.domain(yd(t)).range(yr(t));\n return arc(e);\n }\n };\n }\n\n function arcTweenUpdate(d) {\n var ipo = d3.interpolate({x: d.x0, dx: d.dx0, y: d.y0, dy: d.dy0}, d);\n\n return function (t) {\n var b = ipo(t);\n\n d.x0 = b.x;\n d.dx0 = b.dx;\n d.y0 = b.y;\n d.dy0 = b.dy;\n\n return arc(b);\n };\n }\n\n function updatePrevPosition(node) {\n var k = key(node);\n if(! prevPositions[k]) prevPositions[k] = {};\n var pP = prevPositions[k];\n pP.dx = node.dx;\n pP.x = node.x;\n pP.dy = node.dy;\n pP.y = node.y;\n }\n\n function storeRetrievePrevPositions(nodes) {\n nodes.forEach(function(n){\n var k = key(n);\n var pP = prevPositions[k];\n //console.log(k,n,pP);\n if( pP ){\n n.dx0 = pP.dx;\n n.x0 = pP.x;\n n.dy0 = pP.dy;\n n.y0 = pP.y;\n }\n else {\n n.dx0 = n.dx;\n n.x0 = n.x;\n n.dy0 = n.dy;\n n.y0 = n.y;\n }\n updatePrevPosition(n);\n });\n }\n\n function zoomClick(d) {\n var labels = container.selectAll('text')\n var path = container.selectAll('path')\n\n // fade out all text elements\n labels.transition().attr(\"opacity\",0);\n\n // to allow reference to the new center node\n node = d;\n\n path.transition()\n .duration(duration)\n .attrTween(\"d\", arcTweenZoom)\n .each('end', function(e) {\n // partially taken from here: http://bl.ocks.org/metmajer/5480307\n // check if the animated element's data e lies within the visible angle span given in d\n if(e.x >= d.x && e.x < (d.x + d.dx) ){\n if(e.depth >= d.depth){\n // get a selection of the associated text element\n var parentNode = d3.select(this.parentNode);\n var arcText = parentNode.select('text');\n\n // fade in the text element and recalculate positions\n arcText.transition().duration(duration)\n .text( function(e){return labelFormat(e) })\n .attr(\"opacity\", function(d){\n if(labelThresholdMatched(d)) {\n return 1;\n }\n else {\n return 0;\n }\n })\n .attr(\"transform\", function() {\n var width = this.getBBox().width;\n if(e.depth === 0)\n return \"translate(\" + (width / 2 * - 1) + \",0)\";\n else if(e.depth === d.depth){\n return \"translate(\" + (y(e.y) + 5) + \",0)\";\n }\n else {\n var centerAngle = computeCenterAngle(e);\n var rotation = rotationToAvoidUpsideDown(e);\n if (rotation === 0) {\n return 'rotate('+ centerAngle +')translate(' + (y(e.y) + 5) + ',0)';\n }\n else {\n return 'rotate('+ centerAngle +')translate(' + (y(e.y) + width + 5) + ',0)rotate(' + rotation + ')';\n }\n }\n });\n }\n }\n })\n }\n\n //============================================================\n // chart function\n //------------------------------------------------------------\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n function chart(selection) {\n renderWatch.reset();\n\n selection.each(function(data) {\n container = d3.select(this);\n availableWidth = nv.utils.availableWidth(width, container, margin);\n availableHeight = nv.utils.availableHeight(height, container, margin);\n radius = Math.min(availableWidth, availableHeight) / 2;\n\n y.range([0, radius]);\n\n // Setup containers and skeleton of chart\n var wrap = container.select('g.nvd3.nv-wrap.nv-sunburst');\n if( !wrap[0][0] ) {\n wrap = container.append('g')\n .attr('class', 'nvd3 nv-wrap nv-sunburst nv-chart-' + id)\n .attr('transform', 'translate(' + ((availableWidth / 2) + margin.left + margin.right) + ',' + ((availableHeight / 2) + margin.top + margin.bottom) + ')');\n } else {\n wrap.attr('transform', 'translate(' + ((availableWidth / 2) + margin.left + margin.right) + ',' + ((availableHeight / 2) + margin.top + margin.bottom) + ')');\n }\n\n container.on('click', function (d, i) {\n dispatch.chartClick({\n data: d,\n index: i,\n pos: d3.event,\n id: id\n });\n });\n\n partition.value(modes[mode] || modes[\"count\"]);\n\n //reverse the drawing order so that the labels of inner\n //arcs are drawn on top of the outer arcs.\n var nodes = partition.nodes(data[0]).reverse()\n\n storeRetrievePrevPositions(nodes);\n var cG = wrap.selectAll('.arc-container').data(nodes, key)\n\n //handle new datapoints\n var cGE = cG.enter()\n .append(\"g\")\n .attr(\"class\",'arc-container')\n\n cGE.append(\"path\")\n .attr(\"d\", arc)\n .style(\"fill\", function (d) {\n if (d.color) {\n return d.color;\n }\n else if (groupColorByParent) {\n return color((d.children ? d : d.parent).name);\n }\n else {\n return color(d.name);\n }\n })\n .style(\"stroke\", \"#FFF\")\n .on(\"click\", function(d,i){\n zoomClick(d);\n dispatch.elementClick({\n data: d,\n index: i\n })\n })\n .on('mouseover', function(d,i){\n d3.select(this).classed('hover', true).style('opacity', 0.8);\n dispatch.elementMouseover({\n data: d,\n color: d3.select(this).style(\"fill\"),\n percent: computeNodePercentage(d)\n });\n })\n .on('mouseout', function(d,i){\n d3.select(this).classed('hover', false).style('opacity', 1);\n dispatch.elementMouseout({\n data: d\n });\n })\n .on('mousemove', function(d,i){\n dispatch.elementMousemove({\n data: d\n });\n });\n\n ///Iterating via each and selecting based on the this\n ///makes it work ... a cG.selectAll('path') doesn't.\n ///Without iteration the data (in the element) didn't update.\n cG.each(function(d){\n d3.select(this).select('path')\n .transition()\n .duration(duration)\n .attrTween('d', arcTweenUpdate);\n });\n\n if(showLabels){\n //remove labels first and add them back\n cG.selectAll('text').remove();\n\n //this way labels are on top of newly added arcs\n cG.append('text')\n .text( function(e){ return labelFormat(e)})\n .transition()\n .duration(duration)\n .attr(\"opacity\", function(d){\n if(labelThresholdMatched(d)) {\n return 1;\n }\n else {\n return 0;\n }\n })\n .attr(\"transform\", function(d) {\n var width = this.getBBox().width;\n if(d.depth === 0){\n return \"rotate(0)translate(\" + (width / 2 * -1) + \",0)\";\n }\n else {\n var centerAngle = computeCenterAngle(d);\n var rotation = rotationToAvoidUpsideDown(d);\n if (rotation === 0) {\n return 'rotate('+ centerAngle +')translate(' + (y(d.y) + 5) + ',0)';\n }\n else {\n return 'rotate('+ centerAngle +')translate(' + (y(d.y) + width + 5) + ',0)rotate(' + rotation + ')';\n }\n }\n });\n }\n\n //zoom out to the center when the data is updated.\n zoomClick(nodes[nodes.length - 1])\n\n\n //remove unmatched elements ...\n cG.exit()\n .transition()\n .duration(duration)\n .attr('opacity',0)\n .each('end',function(d){\n var k = key(d);\n prevPositions[k] = undefined;\n })\n .remove();\n });\n\n\n renderWatch.renderEnd('sunburst immediate');\n return chart;\n }\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n chart.dispatch = dispatch;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n width: {get: function(){return width;}, set: function(_){width=_;}},\n height: {get: function(){return height;}, set: function(_){height=_;}},\n mode: {get: function(){return mode;}, set: function(_){mode=_;}},\n id: {get: function(){return id;}, set: function(_){id=_;}},\n duration: {get: function(){return duration;}, set: function(_){duration=_;}},\n groupColorByParent: {get: function(){return groupColorByParent;}, set: function(_){groupColorByParent=!!_;}},\n showLabels: {get: function(){return showLabels;}, set: function(_){showLabels=!!_}},\n labelFormat: {get: function(){return labelFormat;}, set: function(_){labelFormat=_}},\n labelThreshold: {get: function(){return labelThreshold;}, set: function(_){labelThreshold=_}},\n sort: {get: function(){return sort;}, set: function(_){sort=_}},\n key: {get: function(){return key;}, set: function(_){key=_}},\n // options that require extra logic in the setter\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top != undefined ? _.top : margin.top;\n margin.right = _.right != undefined ? _.right : margin.right;\n margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n margin.left = _.left != undefined ? _.left : margin.left;\n }},\n color: {get: function(){return color;}, set: function(_){\n color=nv.utils.getColor(_);\n }}\n });\n\n nv.utils.initOptions(chart);\n return chart;\n};\n", "nv.models.sunburstChart = function() {\n \"use strict\";\n\n //============================================================\n // Public Variables with Default Settings\n //------------------------------------------------------------\n\n var sunburst = nv.models.sunburst();\n var tooltip = nv.models.tooltip();\n\n var margin = {top: 30, right: 20, bottom: 20, left: 20}\n , width = null\n , height = null\n , color = nv.utils.defaultColor()\n , showTooltipPercent = false\n , id = Math.round(Math.random() * 100000)\n , defaultState = null\n , noData = null\n , duration = 250\n , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd');\n\n\n //============================================================\n // Private Variables\n //------------------------------------------------------------\n\n var renderWatch = nv.utils.renderWatch(dispatch);\n\n tooltip\n .duration(0)\n .headerEnabled(false)\n .valueFormatter(function(d){return d;});\n\n //============================================================\n // Chart function\n //------------------------------------------------------------\n\n function chart(selection) {\n renderWatch.reset();\n renderWatch.models(sunburst);\n\n selection.each(function(data) {\n var container = d3.select(this);\n\n nv.utils.initSVG(container);\n\n var availableWidth = nv.utils.availableWidth(width, container, margin);\n var availableHeight = nv.utils.availableHeight(height, container, margin);\n\n chart.update = function() {\n if (duration === 0) {\n container.call(chart);\n } else {\n container.transition().duration(duration).call(chart);\n }\n };\n chart.container = container;\n\n // Display No Data message if there's nothing to show.\n if (!data || !data.length) {\n nv.utils.noData(chart, container);\n return chart;\n } else {\n container.selectAll('.nv-noData').remove();\n }\n\n sunburst.width(availableWidth).height(availableHeight).margin(margin);\n container.call(sunburst);\n });\n\n renderWatch.renderEnd('sunburstChart immediate');\n return chart;\n }\n\n //============================================================\n // Event Handling/Dispatching (out of chart's scope)\n //------------------------------------------------------------\n\n sunburst.dispatch.on('elementMouseover.tooltip', function(evt) {\n evt.series = {\n key: evt.data.name,\n value: (evt.data.value || evt.data.size),\n color: evt.color,\n percent: evt.percent\n };\n if (!showTooltipPercent) {\n delete evt.percent;\n delete evt.series.percent;\n }\n tooltip.data(evt).hidden(false);\n });\n\n sunburst.dispatch.on('elementMouseout.tooltip', function(evt) {\n tooltip.hidden(true);\n });\n\n sunburst.dispatch.on('elementMousemove.tooltip', function(evt) {\n tooltip();\n });\n\n //============================================================\n // Expose Public Variables\n //------------------------------------------------------------\n\n // expose chart's sub-components\n chart.dispatch = dispatch;\n chart.sunburst = sunburst;\n chart.tooltip = tooltip;\n chart.options = nv.utils.optionsFunc.bind(chart);\n\n // use Object get/set functionality to map between vars and chart functions\n chart._options = Object.create({}, {\n // simple options, just get/set the necessary values\n noData: {get: function(){return noData;}, set: function(_){noData=_;}},\n defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n showTooltipPercent: {get: function(){return showTooltipPercent;}, set: function(_){showTooltipPercent=_;}},\n\n // options that require extra logic in the setter\n color: {get: function(){return color;}, set: function(_){\n color = _;\n sunburst.color(color);\n }},\n duration: {get: function(){return duration;}, set: function(_){\n duration = _;\n renderWatch.reset(duration);\n sunburst.duration(duration);\n }},\n margin: {get: function(){return margin;}, set: function(_){\n margin.top = _.top !== undefined ? _.top : margin.top;\n margin.right = _.right !== undefined ? _.right : margin.right;\n margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n margin.left = _.left !== undefined ? _.left : margin.left;\n sunburst.margin(margin);\n }}\n });\n nv.utils.inheritOptions(chart, sunburst);\n nv.utils.initOptions(chart);\n return chart;\n\n};\n", "export * from \"./enums.js\";\nexport * from \"./modifiers/index.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport { popperGenerator, detectOverflow, createPopper as createPopperBase } from \"./createPopper.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper } from \"./popper.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper as createPopperLite } from \"./popper-lite.js\";", "export var top = 'top';\nexport var bottom = 'bottom';\nexport var right = 'right';\nexport var left = 'left';\nexport var auto = 'auto';\nexport var basePlacements = [top, bottom, right, left];\nexport var start = 'start';\nexport var end = 'end';\nexport var clippingParents = 'clippingParents';\nexport var viewport = 'viewport';\nexport var popper = 'popper';\nexport var reference = 'reference';\nexport var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {\n return acc.concat([placement + \"-\" + start, placement + \"-\" + end]);\n}, []);\nexport var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {\n return acc.concat([placement, placement + \"-\" + start, placement + \"-\" + end]);\n}, []); // modifiers that need to read the DOM\n\nexport var beforeRead = 'beforeRead';\nexport var read = 'read';\nexport var afterRead = 'afterRead'; // pure-logic modifiers\n\nexport var beforeMain = 'beforeMain';\nexport var main = 'main';\nexport var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)\n\nexport var beforeWrite = 'beforeWrite';\nexport var write = 'write';\nexport var afterWrite = 'afterWrite';\nexport var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];", "export default function getNodeName(element) {\n return element ? (element.nodeName || '').toLowerCase() : null;\n}", "export default function getWindow(node) {\n if (node == null) {\n return window;\n }\n\n if (node.toString() !== '[object Window]') {\n var ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}", "import getWindow from \"./getWindow.js\";\n\nfunction isElement(node) {\n var OwnElement = getWindow(node).Element;\n return node instanceof OwnElement || node instanceof Element;\n}\n\nfunction isHTMLElement(node) {\n var OwnElement = getWindow(node).HTMLElement;\n return node instanceof OwnElement || node instanceof HTMLElement;\n}\n\nfunction isShadowRoot(node) {\n // IE 11 has no ShadowRoot\n if (typeof ShadowRoot === 'undefined') {\n return false;\n }\n\n var OwnElement = getWindow(node).ShadowRoot;\n return node instanceof OwnElement || node instanceof ShadowRoot;\n}\n\nexport { isElement, isHTMLElement, isShadowRoot };", "import getNodeName from \"../dom-utils/getNodeName.js\";\nimport { isHTMLElement } from \"../dom-utils/instanceOf.js\"; // This modifier takes the styles prepared by the `computeStyles` modifier\n// and applies them to the HTMLElements such as popper and arrow\n\nfunction applyStyles(_ref) {\n var state = _ref.state;\n Object.keys(state.elements).forEach(function (name) {\n var style = state.styles[name] || {};\n var attributes = state.attributes[name] || {};\n var element = state.elements[name]; // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n } // Flow doesn't support to extend this property, but it's the most\n // effective way to apply styles to an HTMLElement\n // $FlowFixMe[cannot-write]\n\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (name) {\n var value = attributes[name];\n\n if (value === false) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value === true ? '' : value);\n }\n });\n });\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state;\n var initialStyles = {\n popper: {\n position: state.options.strategy,\n left: '0',\n top: '0',\n margin: '0'\n },\n arrow: {\n position: 'absolute'\n },\n reference: {}\n };\n Object.assign(state.elements.popper.style, initialStyles.popper);\n state.styles = initialStyles;\n\n if (state.elements.arrow) {\n Object.assign(state.elements.arrow.style, initialStyles.arrow);\n }\n\n return function () {\n Object.keys(state.elements).forEach(function (name) {\n var element = state.elements[name];\n var attributes = state.attributes[name] || {};\n var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them\n\n var style = styleProperties.reduce(function (style, property) {\n style[property] = '';\n return style;\n }, {}); // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n }\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (attribute) {\n element.removeAttribute(attribute);\n });\n });\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'applyStyles',\n enabled: true,\n phase: 'write',\n fn: applyStyles,\n effect: effect,\n requires: ['computeStyles']\n};", "import { auto } from \"../enums.js\";\nexport default function getBasePlacement(placement) {\n return placement.split('-')[0];\n}", "export var max = Math.max;\nexport var min = Math.min;\nexport var round = Math.round;", "export default function getUAString() {\n var uaData = navigator.userAgentData;\n\n if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {\n return uaData.brands.map(function (item) {\n return item.brand + \"/\" + item.version;\n }).join(' ');\n }\n\n return navigator.userAgent;\n}", "import getUAString from \"../utils/userAgent.js\";\nexport default function isLayoutViewport() {\n return !/^((?!chrome|android).)*safari/i.test(getUAString());\n}", "import { isElement, isHTMLElement } from \"./instanceOf.js\";\nimport { round } from \"../utils/math.js\";\nimport getWindow from \"./getWindow.js\";\nimport isLayoutViewport from \"./isLayoutViewport.js\";\nexport default function getBoundingClientRect(element, includeScale, isFixedStrategy) {\n if (includeScale === void 0) {\n includeScale = false;\n }\n\n if (isFixedStrategy === void 0) {\n isFixedStrategy = false;\n }\n\n var clientRect = element.getBoundingClientRect();\n var scaleX = 1;\n var scaleY = 1;\n\n if (includeScale && isHTMLElement(element)) {\n scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;\n scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;\n }\n\n var _ref = isElement(element) ? getWindow(element) : window,\n visualViewport = _ref.visualViewport;\n\n var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;\n var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;\n var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;\n var width = clientRect.width / scaleX;\n var height = clientRect.height / scaleY;\n return {\n width: width,\n height: height,\n top: y,\n right: x + width,\n bottom: y + height,\n left: x,\n x: x,\n y: y\n };\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\"; // Returns the layout rect of an element relative to its offsetParent. Layout\n// means it doesn't take into account transforms.\n\nexport default function getLayoutRect(element) {\n var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.\n // Fixes https://github.com/popperjs/popper-core/issues/1223\n\n var width = element.offsetWidth;\n var height = element.offsetHeight;\n\n if (Math.abs(clientRect.width - width) <= 1) {\n width = clientRect.width;\n }\n\n if (Math.abs(clientRect.height - height) <= 1) {\n height = clientRect.height;\n }\n\n return {\n x: element.offsetLeft,\n y: element.offsetTop,\n width: width,\n height: height\n };\n}", "import { isShadowRoot } from \"./instanceOf.js\";\nexport default function contains(parent, child) {\n var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method\n\n if (parent.contains(child)) {\n return true;\n } // then fallback to custom implementation with Shadow DOM support\n else if (rootNode && isShadowRoot(rootNode)) {\n var next = child;\n\n do {\n if (next && parent.isSameNode(next)) {\n return true;\n } // $FlowFixMe[prop-missing]: need a better way to handle this...\n\n\n next = next.parentNode || next.host;\n } while (next);\n } // Give up, the result is false\n\n\n return false;\n}", "import getWindow from \"./getWindow.js\";\nexport default function getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}", "import getNodeName from \"./getNodeName.js\";\nexport default function isTableElement(element) {\n return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;\n}", "import { isElement } from \"./instanceOf.js\";\nexport default function getDocumentElement(element) {\n // $FlowFixMe[incompatible-return]: assume body is always available\n return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]\n element.document) || window.document).documentElement;\n}", "import getNodeName from \"./getNodeName.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport { isShadowRoot } from \"./instanceOf.js\";\nexport default function getParentNode(element) {\n if (getNodeName(element) === 'html') {\n return element;\n }\n\n return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle\n // $FlowFixMe[incompatible-return]\n // $FlowFixMe[prop-missing]\n element.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n element.parentNode || ( // DOM Element detected\n isShadowRoot(element) ? element.host : null) || // ShadowRoot detected\n // $FlowFixMe[incompatible-call]: HTMLElement is a Node\n getDocumentElement(element) // fallback\n\n );\n}", "import getWindow from \"./getWindow.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isHTMLElement, isShadowRoot } from \"./instanceOf.js\";\nimport isTableElement from \"./isTableElement.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getUAString from \"../utils/userAgent.js\";\n\nfunction getTrueOffsetParent(element) {\n if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837\n getComputedStyle(element).position === 'fixed') {\n return null;\n }\n\n return element.offsetParent;\n} // `.offsetParent` reports `null` for fixed elements, while absolute elements\n// return the containing block\n\n\nfunction getContainingBlock(element) {\n var isFirefox = /firefox/i.test(getUAString());\n var isIE = /Trident/i.test(getUAString());\n\n if (isIE && isHTMLElement(element)) {\n // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport\n var elementCss = getComputedStyle(element);\n\n if (elementCss.position === 'fixed') {\n return null;\n }\n }\n\n var currentNode = getParentNode(element);\n\n if (isShadowRoot(currentNode)) {\n currentNode = currentNode.host;\n }\n\n while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {\n var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {\n return currentNode;\n } else {\n currentNode = currentNode.parentNode;\n }\n }\n\n return null;\n} // Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\n\n\nexport default function getOffsetParent(element) {\n var window = getWindow(element);\n var offsetParent = getTrueOffsetParent(element);\n\n while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {\n offsetParent = getTrueOffsetParent(offsetParent);\n }\n\n if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {\n return window;\n }\n\n return offsetParent || getContainingBlock(element) || window;\n}", "export default function getMainAxisFromPlacement(placement) {\n return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';\n}", "import { max as mathMax, min as mathMin } from \"./math.js\";\nexport function within(min, value, max) {\n return mathMax(min, mathMin(value, max));\n}\nexport function withinMaxClamp(min, value, max) {\n var v = within(min, value, max);\n return v > max ? max : v;\n}", "export default function getFreshSideObject() {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n };\n}", "import getFreshSideObject from \"./getFreshSideObject.js\";\nexport default function mergePaddingObject(paddingObject) {\n return Object.assign({}, getFreshSideObject(), paddingObject);\n}", "export default function expandToHashMap(value, keys) {\n return keys.reduce(function (hashMap, key) {\n hashMap[key] = value;\n return hashMap;\n }, {});\n}", "import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport contains from \"../dom-utils/contains.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport { within } from \"../utils/within.js\";\nimport mergePaddingObject from \"../utils/mergePaddingObject.js\";\nimport expandToHashMap from \"../utils/expandToHashMap.js\";\nimport { left, right, basePlacements, top, bottom } from \"../enums.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar toPaddingObject = function toPaddingObject(padding, state) {\n padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {\n placement: state.placement\n })) : padding;\n return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));\n};\n\nfunction arrow(_ref) {\n var _state$modifiersData$;\n\n var state = _ref.state,\n name = _ref.name,\n options = _ref.options;\n var arrowElement = state.elements.arrow;\n var popperOffsets = state.modifiersData.popperOffsets;\n var basePlacement = getBasePlacement(state.placement);\n var axis = getMainAxisFromPlacement(basePlacement);\n var isVertical = [left, right].indexOf(basePlacement) >= 0;\n var len = isVertical ? 'height' : 'width';\n\n if (!arrowElement || !popperOffsets) {\n return;\n }\n\n var paddingObject = toPaddingObject(options.padding, state);\n var arrowRect = getLayoutRect(arrowElement);\n var minProp = axis === 'y' ? top : left;\n var maxProp = axis === 'y' ? bottom : right;\n var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];\n var startDiff = popperOffsets[axis] - state.rects.reference[axis];\n var arrowOffsetParent = getOffsetParent(arrowElement);\n var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;\n var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is\n // outside of the popper bounds\n\n var min = paddingObject[minProp];\n var max = clientSize - arrowRect[len] - paddingObject[maxProp];\n var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;\n var offset = within(min, center, max); // Prevents breaking syntax highlighting...\n\n var axisProp = axis;\n state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state,\n options = _ref2.options;\n var _options$element = options.element,\n arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;\n\n if (arrowElement == null) {\n return;\n } // CSS selector\n\n\n if (typeof arrowElement === 'string') {\n arrowElement = state.elements.popper.querySelector(arrowElement);\n\n if (!arrowElement) {\n return;\n }\n }\n\n if (!contains(state.elements.popper, arrowElement)) {\n return;\n }\n\n state.elements.arrow = arrowElement;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'arrow',\n enabled: true,\n phase: 'main',\n fn: arrow,\n effect: effect,\n requires: ['popperOffsets'],\n requiresIfExists: ['preventOverflow']\n};", "export default function getVariation(placement) {\n return placement.split('-')[1];\n}", "import { top, left, right, bottom, end } from \"../enums.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getWindow from \"../dom-utils/getWindow.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport getComputedStyle from \"../dom-utils/getComputedStyle.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getVariation from \"../utils/getVariation.js\";\nimport { round } from \"../utils/math.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar unsetSides = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto'\n}; // Round the offsets to the nearest suitable subpixel based on the DPR.\n// Zooming can change the DPR, but it seems to report a value that will\n// cleanly divide the values into the appropriate subpixels.\n\nfunction roundOffsetsByDPR(_ref, win) {\n var x = _ref.x,\n y = _ref.y;\n var dpr = win.devicePixelRatio || 1;\n return {\n x: round(x * dpr) / dpr || 0,\n y: round(y * dpr) / dpr || 0\n };\n}\n\nexport function mapToStyles(_ref2) {\n var _Object$assign2;\n\n var popper = _ref2.popper,\n popperRect = _ref2.popperRect,\n placement = _ref2.placement,\n variation = _ref2.variation,\n offsets = _ref2.offsets,\n position = _ref2.position,\n gpuAcceleration = _ref2.gpuAcceleration,\n adaptive = _ref2.adaptive,\n roundOffsets = _ref2.roundOffsets,\n isFixed = _ref2.isFixed;\n var _offsets$x = offsets.x,\n x = _offsets$x === void 0 ? 0 : _offsets$x,\n _offsets$y = offsets.y,\n y = _offsets$y === void 0 ? 0 : _offsets$y;\n\n var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({\n x: x,\n y: y\n }) : {\n x: x,\n y: y\n };\n\n x = _ref3.x;\n y = _ref3.y;\n var hasX = offsets.hasOwnProperty('x');\n var hasY = offsets.hasOwnProperty('y');\n var sideX = left;\n var sideY = top;\n var win = window;\n\n if (adaptive) {\n var offsetParent = getOffsetParent(popper);\n var heightProp = 'clientHeight';\n var widthProp = 'clientWidth';\n\n if (offsetParent === getWindow(popper)) {\n offsetParent = getDocumentElement(popper);\n\n if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {\n heightProp = 'scrollHeight';\n widthProp = 'scrollWidth';\n }\n } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it\n\n\n offsetParent = offsetParent;\n\n if (placement === top || (placement === left || placement === right) && variation === end) {\n sideY = bottom;\n var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]\n offsetParent[heightProp];\n y -= offsetY - popperRect.height;\n y *= gpuAcceleration ? 1 : -1;\n }\n\n if (placement === left || (placement === top || placement === bottom) && variation === end) {\n sideX = right;\n var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]\n offsetParent[widthProp];\n x -= offsetX - popperRect.width;\n x *= gpuAcceleration ? 1 : -1;\n }\n }\n\n var commonStyles = Object.assign({\n position: position\n }, adaptive && unsetSides);\n\n var _ref4 = roundOffsets === true ? roundOffsetsByDPR({\n x: x,\n y: y\n }, getWindow(popper)) : {\n x: x,\n y: y\n };\n\n x = _ref4.x;\n y = _ref4.y;\n\n if (gpuAcceleration) {\n var _Object$assign;\n\n return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? \"translate(\" + x + \"px, \" + y + \"px)\" : \"translate3d(\" + x + \"px, \" + y + \"px, 0)\", _Object$assign));\n }\n\n return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + \"px\" : '', _Object$assign2[sideX] = hasX ? x + \"px\" : '', _Object$assign2.transform = '', _Object$assign2));\n}\n\nfunction computeStyles(_ref5) {\n var state = _ref5.state,\n options = _ref5.options;\n var _options$gpuAccelerat = options.gpuAcceleration,\n gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,\n _options$adaptive = options.adaptive,\n adaptive = _options$adaptive === void 0 ? true : _options$adaptive,\n _options$roundOffsets = options.roundOffsets,\n roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;\n var commonStyles = {\n placement: getBasePlacement(state.placement),\n variation: getVariation(state.placement),\n popper: state.elements.popper,\n popperRect: state.rects.popper,\n gpuAcceleration: gpuAcceleration,\n isFixed: state.options.strategy === 'fixed'\n };\n\n if (state.modifiersData.popperOffsets != null) {\n state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {\n offsets: state.modifiersData.popperOffsets,\n position: state.options.strategy,\n adaptive: adaptive,\n roundOffsets: roundOffsets\n })));\n }\n\n if (state.modifiersData.arrow != null) {\n state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {\n offsets: state.modifiersData.arrow,\n position: 'absolute',\n adaptive: false,\n roundOffsets: roundOffsets\n })));\n }\n\n state.attributes.popper = Object.assign({}, state.attributes.popper, {\n 'data-popper-placement': state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'computeStyles',\n enabled: true,\n phase: 'beforeWrite',\n fn: computeStyles,\n data: {}\n};", "import getWindow from \"../dom-utils/getWindow.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar passive = {\n passive: true\n};\n\nfunction effect(_ref) {\n var state = _ref.state,\n instance = _ref.instance,\n options = _ref.options;\n var _options$scroll = options.scroll,\n scroll = _options$scroll === void 0 ? true : _options$scroll,\n _options$resize = options.resize,\n resize = _options$resize === void 0 ? true : _options$resize;\n var window = getWindow(state.elements.popper);\n var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);\n\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.addEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.addEventListener('resize', instance.update, passive);\n }\n\n return function () {\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.removeEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.removeEventListener('resize', instance.update, passive);\n }\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'eventListeners',\n enabled: true,\n phase: 'write',\n fn: function fn() {},\n effect: effect,\n data: {}\n};", "var hash = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nexport default function getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, function (matched) {\n return hash[matched];\n });\n}", "var hash = {\n start: 'end',\n end: 'start'\n};\nexport default function getOppositeVariationPlacement(placement) {\n return placement.replace(/start|end/g, function (matched) {\n return hash[matched];\n });\n}", "import getWindow from \"./getWindow.js\";\nexport default function getWindowScroll(node) {\n var win = getWindow(node);\n var scrollLeft = win.pageXOffset;\n var scrollTop = win.pageYOffset;\n return {\n scrollLeft: scrollLeft,\n scrollTop: scrollTop\n };\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScroll from \"./getWindowScroll.js\";\nexport default function getWindowScrollBarX(element) {\n // If has a CSS width greater than the viewport, then this will be\n // incorrect for RTL.\n // Popper 1 is broken in this case and never had a bug report so let's assume\n // it's not an issue. I don't think anyone ever specifies width on \n // anyway.\n // Browsers where the left scrollbar doesn't cause an issue report `0` for\n // this (e.g. Edge 2019, IE11, Safari)\n return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;\n}", "import getWindow from \"./getWindow.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport isLayoutViewport from \"./isLayoutViewport.js\";\nexport default function getViewportRect(element, strategy) {\n var win = getWindow(element);\n var html = getDocumentElement(element);\n var visualViewport = win.visualViewport;\n var width = html.clientWidth;\n var height = html.clientHeight;\n var x = 0;\n var y = 0;\n\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height;\n var layoutViewport = isLayoutViewport();\n\n if (layoutViewport || !layoutViewport && strategy === 'fixed') {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n\n return {\n width: width,\n height: height,\n x: x + getWindowScrollBarX(element),\n y: y\n };\n}", "import getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getWindowScroll from \"./getWindowScroll.js\";\nimport { max } from \"../utils/math.js\"; // Gets the entire size of the scrollable document area, even extending outside\n// of the `` and `` rect bounds if horizontally scrollable\n\nexport default function getDocumentRect(element) {\n var _element$ownerDocumen;\n\n var html = getDocumentElement(element);\n var winScroll = getWindowScroll(element);\n var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;\n var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);\n var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);\n var x = -winScroll.scrollLeft + getWindowScrollBarX(element);\n var y = -winScroll.scrollTop;\n\n if (getComputedStyle(body || html).direction === 'rtl') {\n x += max(html.clientWidth, body ? body.clientWidth : 0) - width;\n }\n\n return {\n width: width,\n height: height,\n x: x,\n y: y\n };\n}", "import getComputedStyle from \"./getComputedStyle.js\";\nexport default function isScrollParent(element) {\n // Firefox wants us to check `-x` and `-y` variations as well\n var _getComputedStyle = getComputedStyle(element),\n overflow = _getComputedStyle.overflow,\n overflowX = _getComputedStyle.overflowX,\n overflowY = _getComputedStyle.overflowY;\n\n return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);\n}", "import getParentNode from \"./getParentNode.js\";\nimport isScrollParent from \"./isScrollParent.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nexport default function getScrollParent(node) {\n if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {\n // $FlowFixMe[incompatible-return]: assume body is always available\n return node.ownerDocument.body;\n }\n\n if (isHTMLElement(node) && isScrollParent(node)) {\n return node;\n }\n\n return getScrollParent(getParentNode(node));\n}", "import getScrollParent from \"./getScrollParent.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getWindow from \"./getWindow.js\";\nimport isScrollParent from \"./isScrollParent.js\";\n/*\ngiven a DOM element, return the list of all scroll parents, up the list of ancesors\nuntil we get to the top window object. This list is what we attach scroll listeners\nto, because if any of these parent elements scroll, we'll need to re-calculate the\nreference element's position.\n*/\n\nexport default function listScrollParents(element, list) {\n var _element$ownerDocumen;\n\n if (list === void 0) {\n list = [];\n }\n\n var scrollParent = getScrollParent(element);\n var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);\n var win = getWindow(scrollParent);\n var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;\n var updatedList = list.concat(target);\n return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here\n updatedList.concat(listScrollParents(getParentNode(target)));\n}", "export default function rectToClientRect(rect) {\n return Object.assign({}, rect, {\n left: rect.x,\n top: rect.y,\n right: rect.x + rect.width,\n bottom: rect.y + rect.height\n });\n}", "import { viewport } from \"../enums.js\";\nimport getViewportRect from \"./getViewportRect.js\";\nimport getDocumentRect from \"./getDocumentRect.js\";\nimport listScrollParents from \"./listScrollParents.js\";\nimport getOffsetParent from \"./getOffsetParent.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isElement, isHTMLElement } from \"./instanceOf.js\";\nimport getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport contains from \"./contains.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport rectToClientRect from \"../utils/rectToClientRect.js\";\nimport { max, min } from \"../utils/math.js\";\n\nfunction getInnerBoundingClientRect(element, strategy) {\n var rect = getBoundingClientRect(element, false, strategy === 'fixed');\n rect.top = rect.top + element.clientTop;\n rect.left = rect.left + element.clientLeft;\n rect.bottom = rect.top + element.clientHeight;\n rect.right = rect.left + element.clientWidth;\n rect.width = element.clientWidth;\n rect.height = element.clientHeight;\n rect.x = rect.left;\n rect.y = rect.top;\n return rect;\n}\n\nfunction getClientRectFromMixedType(element, clippingParent, strategy) {\n return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));\n} // A \"clipping parent\" is an overflowable container with the characteristic of\n// clipping (or hiding) overflowing elements with a position different from\n// `initial`\n\n\nfunction getClippingParents(element) {\n var clippingParents = listScrollParents(getParentNode(element));\n var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;\n var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;\n\n if (!isElement(clipperElement)) {\n return [];\n } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414\n\n\n return clippingParents.filter(function (clippingParent) {\n return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';\n });\n} // Gets the maximum area that the element is visible in due to any number of\n// clipping parents\n\n\nexport default function getClippingRect(element, boundary, rootBoundary, strategy) {\n var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);\n var clippingParents = [].concat(mainClippingParents, [rootBoundary]);\n var firstClippingParent = clippingParents[0];\n var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {\n var rect = getClientRectFromMixedType(element, clippingParent, strategy);\n accRect.top = max(rect.top, accRect.top);\n accRect.right = min(rect.right, accRect.right);\n accRect.bottom = min(rect.bottom, accRect.bottom);\n accRect.left = max(rect.left, accRect.left);\n return accRect;\n }, getClientRectFromMixedType(element, firstClippingParent, strategy));\n clippingRect.width = clippingRect.right - clippingRect.left;\n clippingRect.height = clippingRect.bottom - clippingRect.top;\n clippingRect.x = clippingRect.left;\n clippingRect.y = clippingRect.top;\n return clippingRect;\n}", "import getBasePlacement from \"./getBasePlacement.js\";\nimport getVariation from \"./getVariation.js\";\nimport getMainAxisFromPlacement from \"./getMainAxisFromPlacement.js\";\nimport { top, right, bottom, left, start, end } from \"../enums.js\";\nexport default function computeOffsets(_ref) {\n var reference = _ref.reference,\n element = _ref.element,\n placement = _ref.placement;\n var basePlacement = placement ? getBasePlacement(placement) : null;\n var variation = placement ? getVariation(placement) : null;\n var commonX = reference.x + reference.width / 2 - element.width / 2;\n var commonY = reference.y + reference.height / 2 - element.height / 2;\n var offsets;\n\n switch (basePlacement) {\n case top:\n offsets = {\n x: commonX,\n y: reference.y - element.height\n };\n break;\n\n case bottom:\n offsets = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n\n case right:\n offsets = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n\n case left:\n offsets = {\n x: reference.x - element.width,\n y: commonY\n };\n break;\n\n default:\n offsets = {\n x: reference.x,\n y: reference.y\n };\n }\n\n var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;\n\n if (mainAxis != null) {\n var len = mainAxis === 'y' ? 'height' : 'width';\n\n switch (variation) {\n case start:\n offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);\n break;\n\n case end:\n offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);\n break;\n\n default:\n }\n }\n\n return offsets;\n}", "import getClippingRect from \"../dom-utils/getClippingRect.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport getBoundingClientRect from \"../dom-utils/getBoundingClientRect.js\";\nimport computeOffsets from \"./computeOffsets.js\";\nimport rectToClientRect from \"./rectToClientRect.js\";\nimport { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from \"../enums.js\";\nimport { isElement } from \"../dom-utils/instanceOf.js\";\nimport mergePaddingObject from \"./mergePaddingObject.js\";\nimport expandToHashMap from \"./expandToHashMap.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport default function detectOverflow(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n _options$placement = _options.placement,\n placement = _options$placement === void 0 ? state.placement : _options$placement,\n _options$strategy = _options.strategy,\n strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,\n _options$boundary = _options.boundary,\n boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,\n _options$rootBoundary = _options.rootBoundary,\n rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,\n _options$elementConte = _options.elementContext,\n elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,\n _options$altBoundary = _options.altBoundary,\n altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,\n _options$padding = _options.padding,\n padding = _options$padding === void 0 ? 0 : _options$padding;\n var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));\n var altContext = elementContext === popper ? reference : popper;\n var popperRect = state.rects.popper;\n var element = state.elements[altBoundary ? altContext : elementContext];\n var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);\n var referenceClientRect = getBoundingClientRect(state.elements.reference);\n var popperOffsets = computeOffsets({\n reference: referenceClientRect,\n element: popperRect,\n strategy: 'absolute',\n placement: placement\n });\n var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));\n var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect\n // 0 or negative = within the clipping rect\n\n var overflowOffsets = {\n top: clippingClientRect.top - elementClientRect.top + paddingObject.top,\n bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,\n left: clippingClientRect.left - elementClientRect.left + paddingObject.left,\n right: elementClientRect.right - clippingClientRect.right + paddingObject.right\n };\n var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element\n\n if (elementContext === popper && offsetData) {\n var offset = offsetData[placement];\n Object.keys(overflowOffsets).forEach(function (key) {\n var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;\n var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';\n overflowOffsets[key] += offset[axis] * multiply;\n });\n }\n\n return overflowOffsets;\n}", "import getVariation from \"./getVariation.js\";\nimport { variationPlacements, basePlacements, placements as allPlacements } from \"../enums.js\";\nimport detectOverflow from \"./detectOverflow.js\";\nimport getBasePlacement from \"./getBasePlacement.js\";\nexport default function computeAutoPlacement(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n placement = _options.placement,\n boundary = _options.boundary,\n rootBoundary = _options.rootBoundary,\n padding = _options.padding,\n flipVariations = _options.flipVariations,\n _options$allowedAutoP = _options.allowedAutoPlacements,\n allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;\n var variation = getVariation(placement);\n var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {\n return getVariation(placement) === variation;\n }) : basePlacements;\n var allowedPlacements = placements.filter(function (placement) {\n return allowedAutoPlacements.indexOf(placement) >= 0;\n });\n\n if (allowedPlacements.length === 0) {\n allowedPlacements = placements;\n } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...\n\n\n var overflows = allowedPlacements.reduce(function (acc, placement) {\n acc[placement] = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding\n })[getBasePlacement(placement)];\n return acc;\n }, {});\n return Object.keys(overflows).sort(function (a, b) {\n return overflows[a] - overflows[b];\n });\n}", "import getOppositePlacement from \"../utils/getOppositePlacement.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getOppositeVariationPlacement from \"../utils/getOppositeVariationPlacement.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport computeAutoPlacement from \"../utils/computeAutoPlacement.js\";\nimport { bottom, top, start, right, left, auto } from \"../enums.js\";\nimport getVariation from \"../utils/getVariation.js\"; // eslint-disable-next-line import/no-unused-modules\n\nfunction getExpandedFallbackPlacements(placement) {\n if (getBasePlacement(placement) === auto) {\n return [];\n }\n\n var oppositePlacement = getOppositePlacement(placement);\n return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];\n}\n\nfunction flip(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n\n if (state.modifiersData[name]._skip) {\n return;\n }\n\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,\n specifiedFallbackPlacements = options.fallbackPlacements,\n padding = options.padding,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n _options$flipVariatio = options.flipVariations,\n flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,\n allowedAutoPlacements = options.allowedAutoPlacements;\n var preferredPlacement = state.options.placement;\n var basePlacement = getBasePlacement(preferredPlacement);\n var isBasePlacement = basePlacement === preferredPlacement;\n var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));\n var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {\n return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n flipVariations: flipVariations,\n allowedAutoPlacements: allowedAutoPlacements\n }) : placement);\n }, []);\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var checksMap = new Map();\n var makeFallbackChecks = true;\n var firstFittingPlacement = placements[0];\n\n for (var i = 0; i < placements.length; i++) {\n var placement = placements[i];\n\n var _basePlacement = getBasePlacement(placement);\n\n var isStartVariation = getVariation(placement) === start;\n var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;\n var len = isVertical ? 'width' : 'height';\n var overflow = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n altBoundary: altBoundary,\n padding: padding\n });\n var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;\n\n if (referenceRect[len] > popperRect[len]) {\n mainVariationSide = getOppositePlacement(mainVariationSide);\n }\n\n var altVariationSide = getOppositePlacement(mainVariationSide);\n var checks = [];\n\n if (checkMainAxis) {\n checks.push(overflow[_basePlacement] <= 0);\n }\n\n if (checkAltAxis) {\n checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);\n }\n\n if (checks.every(function (check) {\n return check;\n })) {\n firstFittingPlacement = placement;\n makeFallbackChecks = false;\n break;\n }\n\n checksMap.set(placement, checks);\n }\n\n if (makeFallbackChecks) {\n // `2` may be desired in some cases \u2013 research later\n var numberOfChecks = flipVariations ? 3 : 1;\n\n var _loop = function _loop(_i) {\n var fittingPlacement = placements.find(function (placement) {\n var checks = checksMap.get(placement);\n\n if (checks) {\n return checks.slice(0, _i).every(function (check) {\n return check;\n });\n }\n });\n\n if (fittingPlacement) {\n firstFittingPlacement = fittingPlacement;\n return \"break\";\n }\n };\n\n for (var _i = numberOfChecks; _i > 0; _i--) {\n var _ret = _loop(_i);\n\n if (_ret === \"break\") break;\n }\n }\n\n if (state.placement !== firstFittingPlacement) {\n state.modifiersData[name]._skip = true;\n state.placement = firstFittingPlacement;\n state.reset = true;\n }\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'flip',\n enabled: true,\n phase: 'main',\n fn: flip,\n requiresIfExists: ['offset'],\n data: {\n _skip: false\n }\n};", "import { top, bottom, left, right } from \"../enums.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\n\nfunction getSideOffsets(overflow, rect, preventedOffsets) {\n if (preventedOffsets === void 0) {\n preventedOffsets = {\n x: 0,\n y: 0\n };\n }\n\n return {\n top: overflow.top - rect.height - preventedOffsets.y,\n right: overflow.right - rect.width + preventedOffsets.x,\n bottom: overflow.bottom - rect.height + preventedOffsets.y,\n left: overflow.left - rect.width - preventedOffsets.x\n };\n}\n\nfunction isAnySideFullyClipped(overflow) {\n return [top, right, bottom, left].some(function (side) {\n return overflow[side] >= 0;\n });\n}\n\nfunction hide(_ref) {\n var state = _ref.state,\n name = _ref.name;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var preventedOffsets = state.modifiersData.preventOverflow;\n var referenceOverflow = detectOverflow(state, {\n elementContext: 'reference'\n });\n var popperAltOverflow = detectOverflow(state, {\n altBoundary: true\n });\n var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);\n var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);\n var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);\n var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);\n state.modifiersData[name] = {\n referenceClippingOffsets: referenceClippingOffsets,\n popperEscapeOffsets: popperEscapeOffsets,\n isReferenceHidden: isReferenceHidden,\n hasPopperEscaped: hasPopperEscaped\n };\n state.attributes.popper = Object.assign({}, state.attributes.popper, {\n 'data-popper-reference-hidden': isReferenceHidden,\n 'data-popper-escaped': hasPopperEscaped\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'hide',\n enabled: true,\n phase: 'main',\n requiresIfExists: ['preventOverflow'],\n fn: hide\n};", "import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport { top, left, right, placements } from \"../enums.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport function distanceAndSkiddingToXY(placement, rects, offset) {\n var basePlacement = getBasePlacement(placement);\n var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;\n\n var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {\n placement: placement\n })) : offset,\n skidding = _ref[0],\n distance = _ref[1];\n\n skidding = skidding || 0;\n distance = (distance || 0) * invertDistance;\n return [left, right].indexOf(basePlacement) >= 0 ? {\n x: distance,\n y: skidding\n } : {\n x: skidding,\n y: distance\n };\n}\n\nfunction offset(_ref2) {\n var state = _ref2.state,\n options = _ref2.options,\n name = _ref2.name;\n var _options$offset = options.offset,\n offset = _options$offset === void 0 ? [0, 0] : _options$offset;\n var data = placements.reduce(function (acc, placement) {\n acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);\n return acc;\n }, {});\n var _data$state$placement = data[state.placement],\n x = _data$state$placement.x,\n y = _data$state$placement.y;\n\n if (state.modifiersData.popperOffsets != null) {\n state.modifiersData.popperOffsets.x += x;\n state.modifiersData.popperOffsets.y += y;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'offset',\n enabled: true,\n phase: 'main',\n requires: ['popperOffsets'],\n fn: offset\n};", "import computeOffsets from \"../utils/computeOffsets.js\";\n\nfunction popperOffsets(_ref) {\n var state = _ref.state,\n name = _ref.name;\n // Offsets are the actual position the popper needs to have to be\n // properly positioned near its reference element\n // This is the most basic placement, and will be adjusted by\n // the modifiers in the next step\n state.modifiersData[name] = computeOffsets({\n reference: state.rects.reference,\n element: state.rects.popper,\n strategy: 'absolute',\n placement: state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'popperOffsets',\n enabled: true,\n phase: 'read',\n fn: popperOffsets,\n data: {}\n};", "export default function getAltAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}", "import { top, left, right, bottom, start } from \"../enums.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport getAltAxis from \"../utils/getAltAxis.js\";\nimport { within, withinMaxClamp } from \"../utils/within.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport getVariation from \"../utils/getVariation.js\";\nimport getFreshSideObject from \"../utils/getFreshSideObject.js\";\nimport { min as mathMin, max as mathMax } from \"../utils/math.js\";\n\nfunction preventOverflow(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n padding = options.padding,\n _options$tether = options.tether,\n tether = _options$tether === void 0 ? true : _options$tether,\n _options$tetherOffset = options.tetherOffset,\n tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;\n var overflow = detectOverflow(state, {\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n altBoundary: altBoundary\n });\n var basePlacement = getBasePlacement(state.placement);\n var variation = getVariation(state.placement);\n var isBasePlacement = !variation;\n var mainAxis = getMainAxisFromPlacement(basePlacement);\n var altAxis = getAltAxis(mainAxis);\n var popperOffsets = state.modifiersData.popperOffsets;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {\n placement: state.placement\n })) : tetherOffset;\n var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {\n mainAxis: tetherOffsetValue,\n altAxis: tetherOffsetValue\n } : Object.assign({\n mainAxis: 0,\n altAxis: 0\n }, tetherOffsetValue);\n var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;\n var data = {\n x: 0,\n y: 0\n };\n\n if (!popperOffsets) {\n return;\n }\n\n if (checkMainAxis) {\n var _offsetModifierState$;\n\n var mainSide = mainAxis === 'y' ? top : left;\n var altSide = mainAxis === 'y' ? bottom : right;\n var len = mainAxis === 'y' ? 'height' : 'width';\n var offset = popperOffsets[mainAxis];\n var min = offset + overflow[mainSide];\n var max = offset - overflow[altSide];\n var additive = tether ? -popperRect[len] / 2 : 0;\n var minLen = variation === start ? referenceRect[len] : popperRect[len];\n var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go\n // outside the reference bounds\n\n var arrowElement = state.elements.arrow;\n var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {\n width: 0,\n height: 0\n };\n var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();\n var arrowPaddingMin = arrowPaddingObject[mainSide];\n var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want\n // to include its full size in the calculation. If the reference is small\n // and near the edge of a boundary, the popper can overflow even if the\n // reference is not overflowing as well (e.g. virtual elements with no\n // width or height)\n\n var arrowLen = within(0, referenceRect[len], arrowRect[len]);\n var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;\n var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;\n var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);\n var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;\n var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;\n var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;\n var tetherMax = offset + maxOffset - offsetModifierValue;\n var preventedOffset = within(tether ? mathMin(min, tetherMin) : min, offset, tether ? mathMax(max, tetherMax) : max);\n popperOffsets[mainAxis] = preventedOffset;\n data[mainAxis] = preventedOffset - offset;\n }\n\n if (checkAltAxis) {\n var _offsetModifierState$2;\n\n var _mainSide = mainAxis === 'x' ? top : left;\n\n var _altSide = mainAxis === 'x' ? bottom : right;\n\n var _offset = popperOffsets[altAxis];\n\n var _len = altAxis === 'y' ? 'height' : 'width';\n\n var _min = _offset + overflow[_mainSide];\n\n var _max = _offset - overflow[_altSide];\n\n var isOriginSide = [top, left].indexOf(basePlacement) !== -1;\n\n var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;\n\n var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;\n\n var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;\n\n var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);\n\n popperOffsets[altAxis] = _preventedOffset;\n data[altAxis] = _preventedOffset - _offset;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'preventOverflow',\n enabled: true,\n phase: 'main',\n fn: preventOverflow,\n requiresIfExists: ['offset']\n};", "export default function getHTMLElementScroll(element) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n}", "import getWindowScroll from \"./getWindowScroll.js\";\nimport getWindow from \"./getWindow.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getHTMLElementScroll from \"./getHTMLElementScroll.js\";\nexport default function getNodeScroll(node) {\n if (node === getWindow(node) || !isHTMLElement(node)) {\n return getWindowScroll(node);\n } else {\n return getHTMLElementScroll(node);\n }\n}", "import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getNodeScroll from \"./getNodeScroll.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport isScrollParent from \"./isScrollParent.js\";\nimport { round } from \"../utils/math.js\";\n\nfunction isElementScaled(element) {\n var rect = element.getBoundingClientRect();\n var scaleX = round(rect.width) / element.offsetWidth || 1;\n var scaleY = round(rect.height) / element.offsetHeight || 1;\n return scaleX !== 1 || scaleY !== 1;\n} // Returns the composite rect of an element relative to its offsetParent.\n// Composite means it takes into account transforms as well as layout.\n\n\nexport default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n\n var isOffsetParentAnElement = isHTMLElement(offsetParent);\n var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);\n var documentElement = getDocumentElement(offsetParent);\n var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);\n var scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n var offsets = {\n x: 0,\n y: 0\n };\n\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078\n isScrollParent(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n\n if (isHTMLElement(offsetParent)) {\n offsets = getBoundingClientRect(offsetParent, true);\n offsets.x += offsetParent.clientLeft;\n offsets.y += offsetParent.clientTop;\n } else if (documentElement) {\n offsets.x = getWindowScrollBarX(documentElement);\n }\n }\n\n return {\n x: rect.left + scroll.scrollLeft - offsets.x,\n y: rect.top + scroll.scrollTop - offsets.y,\n width: rect.width,\n height: rect.height\n };\n}", "import { modifierPhases } from \"../enums.js\"; // source: https://stackoverflow.com/questions/49875255\n\nfunction order(modifiers) {\n var map = new Map();\n var visited = new Set();\n var result = [];\n modifiers.forEach(function (modifier) {\n map.set(modifier.name, modifier);\n }); // On visiting object, check for its dependencies and visit them recursively\n\n function sort(modifier) {\n visited.add(modifier.name);\n var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);\n requires.forEach(function (dep) {\n if (!visited.has(dep)) {\n var depModifier = map.get(dep);\n\n if (depModifier) {\n sort(depModifier);\n }\n }\n });\n result.push(modifier);\n }\n\n modifiers.forEach(function (modifier) {\n if (!visited.has(modifier.name)) {\n // check for visited object\n sort(modifier);\n }\n });\n return result;\n}\n\nexport default function orderModifiers(modifiers) {\n // order based on dependencies\n var orderedModifiers = order(modifiers); // order based on phase\n\n return modifierPhases.reduce(function (acc, phase) {\n return acc.concat(orderedModifiers.filter(function (modifier) {\n return modifier.phase === phase;\n }));\n }, []);\n}", "export default function debounce(fn) {\n var pending;\n return function () {\n if (!pending) {\n pending = new Promise(function (resolve) {\n Promise.resolve().then(function () {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}", "export default function mergeByName(modifiers) {\n var merged = modifiers.reduce(function (merged, current) {\n var existing = merged[current.name];\n merged[current.name] = existing ? Object.assign({}, existing, current, {\n options: Object.assign({}, existing.options, current.options),\n data: Object.assign({}, existing.data, current.data)\n }) : current;\n return merged;\n }, {}); // IE11 does not support Object.values\n\n return Object.keys(merged).map(function (key) {\n return merged[key];\n });\n}", "import getCompositeRect from \"./dom-utils/getCompositeRect.js\";\nimport getLayoutRect from \"./dom-utils/getLayoutRect.js\";\nimport listScrollParents from \"./dom-utils/listScrollParents.js\";\nimport getOffsetParent from \"./dom-utils/getOffsetParent.js\";\nimport orderModifiers from \"./utils/orderModifiers.js\";\nimport debounce from \"./utils/debounce.js\";\nimport mergeByName from \"./utils/mergeByName.js\";\nimport detectOverflow from \"./utils/detectOverflow.js\";\nimport { isElement } from \"./dom-utils/instanceOf.js\";\nvar DEFAULT_OPTIONS = {\n placement: 'bottom',\n modifiers: [],\n strategy: 'absolute'\n};\n\nfunction areValidElements() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return !args.some(function (element) {\n return !(element && typeof element.getBoundingClientRect === 'function');\n });\n}\n\nexport function popperGenerator(generatorOptions) {\n if (generatorOptions === void 0) {\n generatorOptions = {};\n }\n\n var _generatorOptions = generatorOptions,\n _generatorOptions$def = _generatorOptions.defaultModifiers,\n defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,\n _generatorOptions$def2 = _generatorOptions.defaultOptions,\n defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;\n return function createPopper(reference, popper, options) {\n if (options === void 0) {\n options = defaultOptions;\n }\n\n var state = {\n placement: 'bottom',\n orderedModifiers: [],\n options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),\n modifiersData: {},\n elements: {\n reference: reference,\n popper: popper\n },\n attributes: {},\n styles: {}\n };\n var effectCleanupFns = [];\n var isDestroyed = false;\n var instance = {\n state: state,\n setOptions: function setOptions(setOptionsAction) {\n var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;\n cleanupModifierEffects();\n state.options = Object.assign({}, defaultOptions, state.options, options);\n state.scrollParents = {\n reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],\n popper: listScrollParents(popper)\n }; // Orders the modifiers based on their dependencies and `phase`\n // properties\n\n var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers\n\n state.orderedModifiers = orderedModifiers.filter(function (m) {\n return m.enabled;\n });\n runModifierEffects();\n return instance.update();\n },\n // Sync update \u2013 it will always be executed, even if not necessary. This\n // is useful for low frequency updates where sync behavior simplifies the\n // logic.\n // For high frequency updates (e.g. `resize` and `scroll` events), always\n // prefer the async Popper#update method\n forceUpdate: function forceUpdate() {\n if (isDestroyed) {\n return;\n }\n\n var _state$elements = state.elements,\n reference = _state$elements.reference,\n popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements\n // anymore\n\n if (!areValidElements(reference, popper)) {\n return;\n } // Store the reference and popper rects to be read by modifiers\n\n\n state.rects = {\n reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),\n popper: getLayoutRect(popper)\n }; // Modifiers have the ability to reset the current update cycle. The\n // most common use case for this is the `flip` modifier changing the\n // placement, which then needs to re-run all the modifiers, because the\n // logic was previously ran for the previous placement and is therefore\n // stale/incorrect\n\n state.reset = false;\n state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier\n // is filled with the initial data specified by the modifier. This means\n // it doesn't persist and is fresh on each update.\n // To ensure persistent data, use `${name}#persistent`\n\n state.orderedModifiers.forEach(function (modifier) {\n return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);\n });\n\n for (var index = 0; index < state.orderedModifiers.length; index++) {\n if (state.reset === true) {\n state.reset = false;\n index = -1;\n continue;\n }\n\n var _state$orderedModifie = state.orderedModifiers[index],\n fn = _state$orderedModifie.fn,\n _state$orderedModifie2 = _state$orderedModifie.options,\n _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,\n name = _state$orderedModifie.name;\n\n if (typeof fn === 'function') {\n state = fn({\n state: state,\n options: _options,\n name: name,\n instance: instance\n }) || state;\n }\n }\n },\n // Async and optimistically optimized update \u2013 it will not be executed if\n // not necessary (debounced to run at most once-per-tick)\n update: debounce(function () {\n return new Promise(function (resolve) {\n instance.forceUpdate();\n resolve(state);\n });\n }),\n destroy: function destroy() {\n cleanupModifierEffects();\n isDestroyed = true;\n }\n };\n\n if (!areValidElements(reference, popper)) {\n return instance;\n }\n\n instance.setOptions(options).then(function (state) {\n if (!isDestroyed && options.onFirstUpdate) {\n options.onFirstUpdate(state);\n }\n }); // Modifiers have the ability to execute arbitrary code before the first\n // update cycle runs. They will be executed in the same order as the update\n // cycle. This is useful when a modifier adds some persistent data that\n // other modifiers need to use, but the modifier is run after the dependent\n // one.\n\n function runModifierEffects() {\n state.orderedModifiers.forEach(function (_ref) {\n var name = _ref.name,\n _ref$options = _ref.options,\n options = _ref$options === void 0 ? {} : _ref$options,\n effect = _ref.effect;\n\n if (typeof effect === 'function') {\n var cleanupFn = effect({\n state: state,\n name: name,\n instance: instance,\n options: options\n });\n\n var noopFn = function noopFn() {};\n\n effectCleanupFns.push(cleanupFn || noopFn);\n }\n });\n }\n\n function cleanupModifierEffects() {\n effectCleanupFns.forEach(function (fn) {\n return fn();\n });\n effectCleanupFns = [];\n }\n\n return instance;\n };\n}\nexport var createPopper = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules\n\nexport { detectOverflow };", "import { popperGenerator, detectOverflow } from \"./createPopper.js\";\nimport eventListeners from \"./modifiers/eventListeners.js\";\nimport popperOffsets from \"./modifiers/popperOffsets.js\";\nimport computeStyles from \"./modifiers/computeStyles.js\";\nimport applyStyles from \"./modifiers/applyStyles.js\";\nvar defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles];\nvar createPopper = /*#__PURE__*/popperGenerator({\n defaultModifiers: defaultModifiers\n}); // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper, popperGenerator, defaultModifiers, detectOverflow };", "import { popperGenerator, detectOverflow } from \"./createPopper.js\";\nimport eventListeners from \"./modifiers/eventListeners.js\";\nimport popperOffsets from \"./modifiers/popperOffsets.js\";\nimport computeStyles from \"./modifiers/computeStyles.js\";\nimport applyStyles from \"./modifiers/applyStyles.js\";\nimport offset from \"./modifiers/offset.js\";\nimport flip from \"./modifiers/flip.js\";\nimport preventOverflow from \"./modifiers/preventOverflow.js\";\nimport arrow from \"./modifiers/arrow.js\";\nimport hide from \"./modifiers/hide.js\";\nvar defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles, offset, flip, preventOverflow, arrow, hide];\nvar createPopper = /*#__PURE__*/popperGenerator({\n defaultModifiers: defaultModifiers\n}); // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper, popperGenerator, defaultModifiers, detectOverflow }; // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper as createPopperLite } from \"./popper-lite.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport * from \"./modifiers/index.js\";", "/**\n * --------------------------------------------------------------------------\n * Bootstrap dom/data.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\n/**\n * Constants\n */\n\nconst elementMap = new Map()\n\nexport default {\n set(element, key, instance) {\n if (!elementMap.has(element)) {\n elementMap.set(element, new Map())\n }\n\n const instanceMap = elementMap.get(element)\n\n // make it clear we only want one instance per element\n // can be removed later when multiple key/instances are fine to be used\n if (!instanceMap.has(key) && instanceMap.size !== 0) {\n // eslint-disable-next-line no-console\n console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`)\n return\n }\n\n instanceMap.set(key, instance)\n },\n\n get(element, key) {\n if (elementMap.has(element)) {\n return elementMap.get(element).get(key) || null\n }\n\n return null\n },\n\n remove(element, key) {\n if (!elementMap.has(element)) {\n return\n }\n\n const instanceMap = elementMap.get(element)\n\n instanceMap.delete(key)\n\n // free up element references if there are no instances left for an element\n if (instanceMap.size === 0) {\n elementMap.delete(element)\n }\n }\n}\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/index.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst MAX_UID = 1_000_000\nconst MILLISECONDS_MULTIPLIER = 1000\nconst TRANSITION_END = 'transitionend'\n\n/**\n * Properly escape IDs selectors to handle weird IDs\n * @param {string} selector\n * @returns {string}\n */\nconst parseSelector = selector => {\n if (selector && window.CSS && window.CSS.escape) {\n // document.querySelector needs escaping to handle IDs (html5+) containing for instance /\n selector = selector.replace(/#([^\\s\"#']+)/g, (match, id) => `#${CSS.escape(id)}`)\n }\n\n return selector\n}\n\n// Shout-out Angus Croll (https://goo.gl/pxwQGp)\nconst toType = object => {\n if (object === null || object === undefined) {\n return `${object}`\n }\n\n return Object.prototype.toString.call(object).match(/\\s([a-z]+)/i)[1].toLowerCase()\n}\n\n/**\n * Public Util API\n */\n\nconst getUID = prefix => {\n do {\n prefix += Math.floor(Math.random() * MAX_UID)\n } while (document.getElementById(prefix))\n\n return prefix\n}\n\nconst getTransitionDurationFromElement = element => {\n if (!element) {\n return 0\n }\n\n // Get transition-duration of the element\n let { transitionDuration, transitionDelay } = window.getComputedStyle(element)\n\n const floatTransitionDuration = Number.parseFloat(transitionDuration)\n const floatTransitionDelay = Number.parseFloat(transitionDelay)\n\n // Return 0 if element or transition duration is not found\n if (!floatTransitionDuration && !floatTransitionDelay) {\n return 0\n }\n\n // If multiple durations are defined, take the first\n transitionDuration = transitionDuration.split(',')[0]\n transitionDelay = transitionDelay.split(',')[0]\n\n return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER\n}\n\nconst triggerTransitionEnd = element => {\n element.dispatchEvent(new Event(TRANSITION_END))\n}\n\nconst isElement = object => {\n if (!object || typeof object !== 'object') {\n return false\n }\n\n if (typeof object.jquery !== 'undefined') {\n object = object[0]\n }\n\n return typeof object.nodeType !== 'undefined'\n}\n\nconst getElement = object => {\n // it's a jQuery object or a node element\n if (isElement(object)) {\n return object.jquery ? object[0] : object\n }\n\n if (typeof object === 'string' && object.length > 0) {\n return document.querySelector(parseSelector(object))\n }\n\n return null\n}\n\nconst isVisible = element => {\n if (!isElement(element) || element.getClientRects().length === 0) {\n return false\n }\n\n const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'\n // Handle `details` element as its content may falsie appear visible when it is closed\n const closedDetails = element.closest('details:not([open])')\n\n if (!closedDetails) {\n return elementIsVisible\n }\n\n if (closedDetails !== element) {\n const summary = element.closest('summary')\n if (summary && summary.parentNode !== closedDetails) {\n return false\n }\n\n if (summary === null) {\n return false\n }\n }\n\n return elementIsVisible\n}\n\nconst isDisabled = element => {\n if (!element || element.nodeType !== Node.ELEMENT_NODE) {\n return true\n }\n\n if (element.classList.contains('disabled')) {\n return true\n }\n\n if (typeof element.disabled !== 'undefined') {\n return element.disabled\n }\n\n return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'\n}\n\nconst findShadowRoot = element => {\n if (!document.documentElement.attachShadow) {\n return null\n }\n\n // Can find the shadow root otherwise it'll return the document\n if (typeof element.getRootNode === 'function') {\n const root = element.getRootNode()\n return root instanceof ShadowRoot ? root : null\n }\n\n if (element instanceof ShadowRoot) {\n return element\n }\n\n // when we don't find a shadow root\n if (!element.parentNode) {\n return null\n }\n\n return findShadowRoot(element.parentNode)\n}\n\nconst noop = () => {}\n\n/**\n * Trick to restart an element's animation\n *\n * @param {HTMLElement} element\n * @return void\n *\n * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation\n */\nconst reflow = element => {\n element.offsetHeight // eslint-disable-line no-unused-expressions\n}\n\nconst getjQuery = () => {\n if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {\n return window.jQuery\n }\n\n return null\n}\n\nconst DOMContentLoadedCallbacks = []\n\nconst onDOMContentLoaded = callback => {\n if (document.readyState === 'loading') {\n // add listener on the first call when the document is in loading state\n if (!DOMContentLoadedCallbacks.length) {\n document.addEventListener('DOMContentLoaded', () => {\n for (const callback of DOMContentLoadedCallbacks) {\n callback()\n }\n })\n }\n\n DOMContentLoadedCallbacks.push(callback)\n } else {\n callback()\n }\n}\n\nconst isRTL = () => document.documentElement.dir === 'rtl'\n\nconst defineJQueryPlugin = plugin => {\n onDOMContentLoaded(() => {\n const $ = getjQuery()\n /* istanbul ignore if */\n if ($) {\n const name = plugin.NAME\n const JQUERY_NO_CONFLICT = $.fn[name]\n $.fn[name] = plugin.jQueryInterface\n $.fn[name].Constructor = plugin\n $.fn[name].noConflict = () => {\n $.fn[name] = JQUERY_NO_CONFLICT\n return plugin.jQueryInterface\n }\n }\n })\n}\n\nconst execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {\n return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue\n}\n\nconst executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {\n if (!waitForTransition) {\n execute(callback)\n return\n }\n\n const durationPadding = 5\n const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding\n\n let called = false\n\n const handler = ({ target }) => {\n if (target !== transitionElement) {\n return\n }\n\n called = true\n transitionElement.removeEventListener(TRANSITION_END, handler)\n execute(callback)\n }\n\n transitionElement.addEventListener(TRANSITION_END, handler)\n setTimeout(() => {\n if (!called) {\n triggerTransitionEnd(transitionElement)\n }\n }, emulatedDuration)\n}\n\n/**\n * Return the previous/next element of a list.\n *\n * @param {array} list The list of elements\n * @param activeElement The active element\n * @param shouldGetNext Choose to get next or previous element\n * @param isCycleAllowed\n * @return {Element|elem} The proper element\n */\nconst getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {\n const listLength = list.length\n let index = list.indexOf(activeElement)\n\n // if the element does not exist in the list return an element\n // depending on the direction and if cycle is allowed\n if (index === -1) {\n return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]\n }\n\n index += shouldGetNext ? 1 : -1\n\n if (isCycleAllowed) {\n index = (index + listLength) % listLength\n }\n\n return list[Math.max(0, Math.min(index, listLength - 1))]\n}\n\nexport {\n defineJQueryPlugin,\n execute,\n executeAfterTransition,\n findShadowRoot,\n getElement,\n getjQuery,\n getNextActiveElement,\n getTransitionDurationFromElement,\n getUID,\n isDisabled,\n isElement,\n isRTL,\n isVisible,\n noop,\n onDOMContentLoaded,\n parseSelector,\n reflow,\n triggerTransitionEnd,\n toType\n}\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap dom/event-handler.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport { getjQuery } from '../util/index.js'\n\n/**\n * Constants\n */\n\nconst namespaceRegex = /[^.]*(?=\\..*)\\.|.*/\nconst stripNameRegex = /\\..*/\nconst stripUidRegex = /::\\d+$/\nconst eventRegistry = {} // Events storage\nlet uidEvent = 1\nconst customEvents = {\n mouseenter: 'mouseover',\n mouseleave: 'mouseout'\n}\n\nconst nativeEvents = new Set([\n 'click',\n 'dblclick',\n 'mouseup',\n 'mousedown',\n 'contextmenu',\n 'mousewheel',\n 'DOMMouseScroll',\n 'mouseover',\n 'mouseout',\n 'mousemove',\n 'selectstart',\n 'selectend',\n 'keydown',\n 'keypress',\n 'keyup',\n 'orientationchange',\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'touchcancel',\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n 'pointerleave',\n 'pointercancel',\n 'gesturestart',\n 'gesturechange',\n 'gestureend',\n 'focus',\n 'blur',\n 'change',\n 'reset',\n 'select',\n 'submit',\n 'focusin',\n 'focusout',\n 'load',\n 'unload',\n 'beforeunload',\n 'resize',\n 'move',\n 'DOMContentLoaded',\n 'readystatechange',\n 'error',\n 'abort',\n 'scroll'\n])\n\n/**\n * Private methods\n */\n\nfunction makeEventUid(element, uid) {\n return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++\n}\n\nfunction getElementEvents(element) {\n const uid = makeEventUid(element)\n\n element.uidEvent = uid\n eventRegistry[uid] = eventRegistry[uid] || {}\n\n return eventRegistry[uid]\n}\n\nfunction bootstrapHandler(element, fn) {\n return function handler(event) {\n hydrateObj(event, { delegateTarget: element })\n\n if (handler.oneOff) {\n EventHandler.off(element, event.type, fn)\n }\n\n return fn.apply(element, [event])\n }\n}\n\nfunction bootstrapDelegationHandler(element, selector, fn) {\n return function handler(event) {\n const domElements = element.querySelectorAll(selector)\n\n for (let { target } = event; target && target !== this; target = target.parentNode) {\n for (const domElement of domElements) {\n if (domElement !== target) {\n continue\n }\n\n hydrateObj(event, { delegateTarget: target })\n\n if (handler.oneOff) {\n EventHandler.off(element, event.type, selector, fn)\n }\n\n return fn.apply(target, [event])\n }\n }\n }\n}\n\nfunction findHandler(events, callable, delegationSelector = null) {\n return Object.values(events)\n .find(event => event.callable === callable && event.delegationSelector === delegationSelector)\n}\n\nfunction normalizeParameters(originalTypeEvent, handler, delegationFunction) {\n const isDelegated = typeof handler === 'string'\n // TODO: tooltip passes `false` instead of selector, so we need to check\n const callable = isDelegated ? delegationFunction : (handler || delegationFunction)\n let typeEvent = getTypeEvent(originalTypeEvent)\n\n if (!nativeEvents.has(typeEvent)) {\n typeEvent = originalTypeEvent\n }\n\n return [isDelegated, callable, typeEvent]\n}\n\nfunction addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {\n if (typeof originalTypeEvent !== 'string' || !element) {\n return\n }\n\n let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction)\n\n // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position\n // this prevents the handler from being dispatched the same way as mouseover or mouseout does\n if (originalTypeEvent in customEvents) {\n const wrapFunction = fn => {\n return function (event) {\n if (!event.relatedTarget || (event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget))) {\n return fn.call(this, event)\n }\n }\n }\n\n callable = wrapFunction(callable)\n }\n\n const events = getElementEvents(element)\n const handlers = events[typeEvent] || (events[typeEvent] = {})\n const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null)\n\n if (previousFunction) {\n previousFunction.oneOff = previousFunction.oneOff && oneOff\n\n return\n }\n\n const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''))\n const fn = isDelegated ?\n bootstrapDelegationHandler(element, handler, callable) :\n bootstrapHandler(element, callable)\n\n fn.delegationSelector = isDelegated ? handler : null\n fn.callable = callable\n fn.oneOff = oneOff\n fn.uidEvent = uid\n handlers[uid] = fn\n\n element.addEventListener(typeEvent, fn, isDelegated)\n}\n\nfunction removeHandler(element, events, typeEvent, handler, delegationSelector) {\n const fn = findHandler(events[typeEvent], handler, delegationSelector)\n\n if (!fn) {\n return\n }\n\n element.removeEventListener(typeEvent, fn, Boolean(delegationSelector))\n delete events[typeEvent][fn.uidEvent]\n}\n\nfunction removeNamespacedHandlers(element, events, typeEvent, namespace) {\n const storeElementEvent = events[typeEvent] || {}\n\n for (const [handlerKey, event] of Object.entries(storeElementEvent)) {\n if (handlerKey.includes(namespace)) {\n removeHandler(element, events, typeEvent, event.callable, event.delegationSelector)\n }\n }\n}\n\nfunction getTypeEvent(event) {\n // allow to get the native events from namespaced events ('click.bs.button' --> 'click')\n event = event.replace(stripNameRegex, '')\n return customEvents[event] || event\n}\n\nconst EventHandler = {\n on(element, event, handler, delegationFunction) {\n addHandler(element, event, handler, delegationFunction, false)\n },\n\n one(element, event, handler, delegationFunction) {\n addHandler(element, event, handler, delegationFunction, true)\n },\n\n off(element, originalTypeEvent, handler, delegationFunction) {\n if (typeof originalTypeEvent !== 'string' || !element) {\n return\n }\n\n const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction)\n const inNamespace = typeEvent !== originalTypeEvent\n const events = getElementEvents(element)\n const storeElementEvent = events[typeEvent] || {}\n const isNamespace = originalTypeEvent.startsWith('.')\n\n if (typeof callable !== 'undefined') {\n // Simplest case: handler is passed, remove that listener ONLY.\n if (!Object.keys(storeElementEvent).length) {\n return\n }\n\n removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null)\n return\n }\n\n if (isNamespace) {\n for (const elementEvent of Object.keys(events)) {\n removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1))\n }\n }\n\n for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {\n const handlerKey = keyHandlers.replace(stripUidRegex, '')\n\n if (!inNamespace || originalTypeEvent.includes(handlerKey)) {\n removeHandler(element, events, typeEvent, event.callable, event.delegationSelector)\n }\n }\n },\n\n trigger(element, event, args) {\n if (typeof event !== 'string' || !element) {\n return null\n }\n\n const $ = getjQuery()\n const typeEvent = getTypeEvent(event)\n const inNamespace = event !== typeEvent\n\n let jQueryEvent = null\n let bubbles = true\n let nativeDispatch = true\n let defaultPrevented = false\n\n if (inNamespace && $) {\n jQueryEvent = $.Event(event, args)\n\n $(element).trigger(jQueryEvent)\n bubbles = !jQueryEvent.isPropagationStopped()\n nativeDispatch = !jQueryEvent.isImmediatePropagationStopped()\n defaultPrevented = jQueryEvent.isDefaultPrevented()\n }\n\n const evt = hydrateObj(new Event(event, { bubbles, cancelable: true }), args)\n\n if (defaultPrevented) {\n evt.preventDefault()\n }\n\n if (nativeDispatch) {\n element.dispatchEvent(evt)\n }\n\n if (evt.defaultPrevented && jQueryEvent) {\n jQueryEvent.preventDefault()\n }\n\n return evt\n }\n}\n\nfunction hydrateObj(obj, meta = {}) {\n for (const [key, value] of Object.entries(meta)) {\n try {\n obj[key] = value\n } catch {\n Object.defineProperty(obj, key, {\n configurable: true,\n get() {\n return value\n }\n })\n }\n }\n\n return obj\n}\n\nexport default EventHandler\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap dom/manipulator.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nfunction normalizeData(value) {\n if (value === 'true') {\n return true\n }\n\n if (value === 'false') {\n return false\n }\n\n if (value === Number(value).toString()) {\n return Number(value)\n }\n\n if (value === '' || value === 'null') {\n return null\n }\n\n if (typeof value !== 'string') {\n return value\n }\n\n try {\n return JSON.parse(decodeURIComponent(value))\n } catch {\n return value\n }\n}\n\nfunction normalizeDataKey(key) {\n return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)\n}\n\nconst Manipulator = {\n setDataAttribute(element, key, value) {\n element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value)\n },\n\n removeDataAttribute(element, key) {\n element.removeAttribute(`data-bs-${normalizeDataKey(key)}`)\n },\n\n getDataAttributes(element) {\n if (!element) {\n return {}\n }\n\n const attributes = {}\n const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'))\n\n for (const key of bsKeys) {\n let pureKey = key.replace(/^bs/, '')\n pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length)\n attributes[pureKey] = normalizeData(element.dataset[key])\n }\n\n return attributes\n },\n\n getDataAttribute(element, key) {\n return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`))\n }\n}\n\nexport default Manipulator\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/config.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Manipulator from '../dom/manipulator.js'\nimport { isElement, toType } from './index.js'\n\n/**\n * Class definition\n */\n\nclass Config {\n // Getters\n static get Default() {\n return {}\n }\n\n static get DefaultType() {\n return {}\n }\n\n static get NAME() {\n throw new Error('You have to implement the static method \"NAME\", for each component!')\n }\n\n _getConfig(config) {\n config = this._mergeConfigObj(config)\n config = this._configAfterMerge(config)\n this._typeCheckConfig(config)\n return config\n }\n\n _configAfterMerge(config) {\n return config\n }\n\n _mergeConfigObj(config, element) {\n const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {} // try to parse\n\n return {\n ...this.constructor.Default,\n ...(typeof jsonConfig === 'object' ? jsonConfig : {}),\n ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),\n ...(typeof config === 'object' ? config : {})\n }\n }\n\n _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {\n for (const [property, expectedTypes] of Object.entries(configTypes)) {\n const value = config[property]\n const valueType = isElement(value) ? 'element' : toType(value)\n\n if (!new RegExp(expectedTypes).test(valueType)) {\n throw new TypeError(\n `${this.constructor.NAME.toUpperCase()}: Option \"${property}\" provided type \"${valueType}\" but expected type \"${expectedTypes}\".`\n )\n }\n }\n }\n}\n\nexport default Config\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap base-component.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Data from './dom/data.js'\nimport EventHandler from './dom/event-handler.js'\nimport Config from './util/config.js'\nimport { executeAfterTransition, getElement } from './util/index.js'\n\n/**\n * Constants\n */\n\nconst VERSION = '5.3.3'\n\n/**\n * Class definition\n */\n\nclass BaseComponent extends Config {\n constructor(element, config) {\n super()\n\n element = getElement(element)\n if (!element) {\n return\n }\n\n this._element = element\n this._config = this._getConfig(config)\n\n Data.set(this._element, this.constructor.DATA_KEY, this)\n }\n\n // Public\n dispose() {\n Data.remove(this._element, this.constructor.DATA_KEY)\n EventHandler.off(this._element, this.constructor.EVENT_KEY)\n\n for (const propertyName of Object.getOwnPropertyNames(this)) {\n this[propertyName] = null\n }\n }\n\n _queueCallback(callback, element, isAnimated = true) {\n executeAfterTransition(callback, element, isAnimated)\n }\n\n _getConfig(config) {\n config = this._mergeConfigObj(config, this._element)\n config = this._configAfterMerge(config)\n this._typeCheckConfig(config)\n return config\n }\n\n // Static\n static getInstance(element) {\n return Data.get(getElement(element), this.DATA_KEY)\n }\n\n static getOrCreateInstance(element, config = {}) {\n return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null)\n }\n\n static get VERSION() {\n return VERSION\n }\n\n static get DATA_KEY() {\n return `bs.${this.NAME}`\n }\n\n static get EVENT_KEY() {\n return `.${this.DATA_KEY}`\n }\n\n static eventName(name) {\n return `${name}${this.EVENT_KEY}`\n }\n}\n\nexport default BaseComponent\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap dom/selector-engine.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport { isDisabled, isVisible, parseSelector } from '../util/index.js'\n\nconst getSelector = element => {\n let selector = element.getAttribute('data-bs-target')\n\n if (!selector || selector === '#') {\n let hrefAttribute = element.getAttribute('href')\n\n // The only valid content that could double as a selector are IDs or classes,\n // so everything starting with `#` or `.`. If a \"real\" URL is used as the selector,\n // `document.querySelector` will rightfully complain it is invalid.\n // See https://github.com/twbs/bootstrap/issues/32273\n if (!hrefAttribute || (!hrefAttribute.includes('#') && !hrefAttribute.startsWith('.'))) {\n return null\n }\n\n // Just in case some CMS puts out a full URL with the anchor appended\n if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {\n hrefAttribute = `#${hrefAttribute.split('#')[1]}`\n }\n\n selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null\n }\n\n return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null\n}\n\nconst SelectorEngine = {\n find(selector, element = document.documentElement) {\n return [].concat(...Element.prototype.querySelectorAll.call(element, selector))\n },\n\n findOne(selector, element = document.documentElement) {\n return Element.prototype.querySelector.call(element, selector)\n },\n\n children(element, selector) {\n return [].concat(...element.children).filter(child => child.matches(selector))\n },\n\n parents(element, selector) {\n const parents = []\n let ancestor = element.parentNode.closest(selector)\n\n while (ancestor) {\n parents.push(ancestor)\n ancestor = ancestor.parentNode.closest(selector)\n }\n\n return parents\n },\n\n prev(element, selector) {\n let previous = element.previousElementSibling\n\n while (previous) {\n if (previous.matches(selector)) {\n return [previous]\n }\n\n previous = previous.previousElementSibling\n }\n\n return []\n },\n // TODO: this is now unused; remove later along with prev()\n next(element, selector) {\n let next = element.nextElementSibling\n\n while (next) {\n if (next.matches(selector)) {\n return [next]\n }\n\n next = next.nextElementSibling\n }\n\n return []\n },\n\n focusableChildren(element) {\n const focusables = [\n 'a',\n 'button',\n 'input',\n 'textarea',\n 'select',\n 'details',\n '[tabindex]',\n '[contenteditable=\"true\"]'\n ].map(selector => `${selector}:not([tabindex^=\"-\"])`).join(',')\n\n return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el))\n },\n\n getSelectorFromElement(element) {\n const selector = getSelector(element)\n\n if (selector) {\n return SelectorEngine.findOne(selector) ? selector : null\n }\n\n return null\n },\n\n getElementFromSelector(element) {\n const selector = getSelector(element)\n\n return selector ? SelectorEngine.findOne(selector) : null\n },\n\n getMultipleElementsFromSelector(element) {\n const selector = getSelector(element)\n\n return selector ? SelectorEngine.find(selector) : []\n }\n}\n\nexport default SelectorEngine\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/component-functions.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport EventHandler from '../dom/event-handler.js'\nimport SelectorEngine from '../dom/selector-engine.js'\nimport { isDisabled } from './index.js'\n\nconst enableDismissTrigger = (component, method = 'hide') => {\n const clickEvent = `click.dismiss${component.EVENT_KEY}`\n const name = component.NAME\n\n EventHandler.on(document, clickEvent, `[data-bs-dismiss=\"${name}\"]`, function (event) {\n if (['A', 'AREA'].includes(this.tagName)) {\n event.preventDefault()\n }\n\n if (isDisabled(this)) {\n return\n }\n\n const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`)\n const instance = component.getOrCreateInstance(target)\n\n // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method\n instance[method]()\n })\n}\n\nexport {\n enableDismissTrigger\n}\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap alert.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport { enableDismissTrigger } from './util/component-functions.js'\nimport { defineJQueryPlugin } from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'alert'\nconst DATA_KEY = 'bs.alert'\nconst EVENT_KEY = `.${DATA_KEY}`\n\nconst EVENT_CLOSE = `close${EVENT_KEY}`\nconst EVENT_CLOSED = `closed${EVENT_KEY}`\nconst CLASS_NAME_FADE = 'fade'\nconst CLASS_NAME_SHOW = 'show'\n\n/**\n * Class definition\n */\n\nclass Alert extends BaseComponent {\n // Getters\n static get NAME() {\n return NAME\n }\n\n // Public\n close() {\n const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE)\n\n if (closeEvent.defaultPrevented) {\n return\n }\n\n this._element.classList.remove(CLASS_NAME_SHOW)\n\n const isAnimated = this._element.classList.contains(CLASS_NAME_FADE)\n this._queueCallback(() => this._destroyElement(), this._element, isAnimated)\n }\n\n // Private\n _destroyElement() {\n this._element.remove()\n EventHandler.trigger(this._element, EVENT_CLOSED)\n this.dispose()\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Alert.getOrCreateInstance(this)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config](this)\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nenableDismissTrigger(Alert, 'close')\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Alert)\n\nexport default Alert\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap button.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport { defineJQueryPlugin } from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'button'\nconst DATA_KEY = 'bs.button'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\nconst CLASS_NAME_ACTIVE = 'active'\nconst SELECTOR_DATA_TOGGLE = '[data-bs-toggle=\"button\"]'\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\n\n/**\n * Class definition\n */\n\nclass Button extends BaseComponent {\n // Getters\n static get NAME() {\n return NAME\n }\n\n // Public\n toggle() {\n // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method\n this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE))\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Button.getOrCreateInstance(this)\n\n if (config === 'toggle') {\n data[config]()\n }\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {\n event.preventDefault()\n\n const button = event.target.closest(SELECTOR_DATA_TOGGLE)\n const data = Button.getOrCreateInstance(button)\n\n data.toggle()\n})\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Button)\n\nexport default Button\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/swipe.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport EventHandler from '../dom/event-handler.js'\nimport Config from './config.js'\nimport { execute } from './index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'swipe'\nconst EVENT_KEY = '.bs.swipe'\nconst EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`\nconst EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`\nconst EVENT_TOUCHEND = `touchend${EVENT_KEY}`\nconst EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`\nconst EVENT_POINTERUP = `pointerup${EVENT_KEY}`\nconst POINTER_TYPE_TOUCH = 'touch'\nconst POINTER_TYPE_PEN = 'pen'\nconst CLASS_NAME_POINTER_EVENT = 'pointer-event'\nconst SWIPE_THRESHOLD = 40\n\nconst Default = {\n endCallback: null,\n leftCallback: null,\n rightCallback: null\n}\n\nconst DefaultType = {\n endCallback: '(function|null)',\n leftCallback: '(function|null)',\n rightCallback: '(function|null)'\n}\n\n/**\n * Class definition\n */\n\nclass Swipe extends Config {\n constructor(element, config) {\n super()\n this._element = element\n\n if (!element || !Swipe.isSupported()) {\n return\n }\n\n this._config = this._getConfig(config)\n this._deltaX = 0\n this._supportPointerEvents = Boolean(window.PointerEvent)\n this._initEvents()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n dispose() {\n EventHandler.off(this._element, EVENT_KEY)\n }\n\n // Private\n _start(event) {\n if (!this._supportPointerEvents) {\n this._deltaX = event.touches[0].clientX\n\n return\n }\n\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX\n }\n }\n\n _end(event) {\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX - this._deltaX\n }\n\n this._handleSwipe()\n execute(this._config.endCallback)\n }\n\n _move(event) {\n this._deltaX = event.touches && event.touches.length > 1 ?\n 0 :\n event.touches[0].clientX - this._deltaX\n }\n\n _handleSwipe() {\n const absDeltaX = Math.abs(this._deltaX)\n\n if (absDeltaX <= SWIPE_THRESHOLD) {\n return\n }\n\n const direction = absDeltaX / this._deltaX\n\n this._deltaX = 0\n\n if (!direction) {\n return\n }\n\n execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback)\n }\n\n _initEvents() {\n if (this._supportPointerEvents) {\n EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event))\n EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event))\n\n this._element.classList.add(CLASS_NAME_POINTER_EVENT)\n } else {\n EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event))\n EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event))\n EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event))\n }\n }\n\n _eventIsPointerPenTouch(event) {\n return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)\n }\n\n // Static\n static isSupported() {\n return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0\n }\n}\n\nexport default Swipe\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap carousel.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport Manipulator from './dom/manipulator.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport {\n defineJQueryPlugin,\n getNextActiveElement,\n isRTL,\n isVisible,\n reflow,\n triggerTransitionEnd\n} from './util/index.js'\nimport Swipe from './util/swipe.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'carousel'\nconst DATA_KEY = 'bs.carousel'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\nconst ARROW_LEFT_KEY = 'ArrowLeft'\nconst ARROW_RIGHT_KEY = 'ArrowRight'\nconst TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch\n\nconst ORDER_NEXT = 'next'\nconst ORDER_PREV = 'prev'\nconst DIRECTION_LEFT = 'left'\nconst DIRECTION_RIGHT = 'right'\n\nconst EVENT_SLIDE = `slide${EVENT_KEY}`\nconst EVENT_SLID = `slid${EVENT_KEY}`\nconst EVENT_KEYDOWN = `keydown${EVENT_KEY}`\nconst EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`\nconst EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`\nconst EVENT_DRAG_START = `dragstart${EVENT_KEY}`\nconst EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\n\nconst CLASS_NAME_CAROUSEL = 'carousel'\nconst CLASS_NAME_ACTIVE = 'active'\nconst CLASS_NAME_SLIDE = 'slide'\nconst CLASS_NAME_END = 'carousel-item-end'\nconst CLASS_NAME_START = 'carousel-item-start'\nconst CLASS_NAME_NEXT = 'carousel-item-next'\nconst CLASS_NAME_PREV = 'carousel-item-prev'\n\nconst SELECTOR_ACTIVE = '.active'\nconst SELECTOR_ITEM = '.carousel-item'\nconst SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM\nconst SELECTOR_ITEM_IMG = '.carousel-item img'\nconst SELECTOR_INDICATORS = '.carousel-indicators'\nconst SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'\nconst SELECTOR_DATA_RIDE = '[data-bs-ride=\"carousel\"]'\n\nconst KEY_TO_DIRECTION = {\n [ARROW_LEFT_KEY]: DIRECTION_RIGHT,\n [ARROW_RIGHT_KEY]: DIRECTION_LEFT\n}\n\nconst Default = {\n interval: 5000,\n keyboard: true,\n pause: 'hover',\n ride: false,\n touch: true,\n wrap: true\n}\n\nconst DefaultType = {\n interval: '(number|boolean)', // TODO:v6 remove boolean support\n keyboard: 'boolean',\n pause: '(string|boolean)',\n ride: '(boolean|string)',\n touch: 'boolean',\n wrap: 'boolean'\n}\n\n/**\n * Class definition\n */\n\nclass Carousel extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n this._interval = null\n this._activeElement = null\n this._isSliding = false\n this.touchTimeout = null\n this._swipeHelper = null\n\n this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element)\n this._addEventListeners()\n\n if (this._config.ride === CLASS_NAME_CAROUSEL) {\n this.cycle()\n }\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n next() {\n this._slide(ORDER_NEXT)\n }\n\n nextWhenVisible() {\n // FIXME TODO use `document.visibilityState`\n // Don't call next when the page isn't visible\n // or the carousel or its parent isn't visible\n if (!document.hidden && isVisible(this._element)) {\n this.next()\n }\n }\n\n prev() {\n this._slide(ORDER_PREV)\n }\n\n pause() {\n if (this._isSliding) {\n triggerTransitionEnd(this._element)\n }\n\n this._clearInterval()\n }\n\n cycle() {\n this._clearInterval()\n this._updateInterval()\n\n this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval)\n }\n\n _maybeEnableCycle() {\n if (!this._config.ride) {\n return\n }\n\n if (this._isSliding) {\n EventHandler.one(this._element, EVENT_SLID, () => this.cycle())\n return\n }\n\n this.cycle()\n }\n\n to(index) {\n const items = this._getItems()\n if (index > items.length - 1 || index < 0) {\n return\n }\n\n if (this._isSliding) {\n EventHandler.one(this._element, EVENT_SLID, () => this.to(index))\n return\n }\n\n const activeIndex = this._getItemIndex(this._getActive())\n if (activeIndex === index) {\n return\n }\n\n const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV\n\n this._slide(order, items[index])\n }\n\n dispose() {\n if (this._swipeHelper) {\n this._swipeHelper.dispose()\n }\n\n super.dispose()\n }\n\n // Private\n _configAfterMerge(config) {\n config.defaultInterval = config.interval\n return config\n }\n\n _addEventListeners() {\n if (this._config.keyboard) {\n EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event))\n }\n\n if (this._config.pause === 'hover') {\n EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause())\n EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle())\n }\n\n if (this._config.touch && Swipe.isSupported()) {\n this._addTouchEventListeners()\n }\n }\n\n _addTouchEventListeners() {\n for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {\n EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault())\n }\n\n const endCallBack = () => {\n if (this._config.pause !== 'hover') {\n return\n }\n\n // If it's a touch-enabled device, mouseenter/leave are fired as\n // part of the mouse compatibility events on first tap - the carousel\n // would stop cycling until user tapped out of it;\n // here, we listen for touchend, explicitly pause the carousel\n // (as if it's the second time we tap on it, mouseenter compat event\n // is NOT fired) and after a timeout (to allow for mouse compatibility\n // events to fire) we explicitly restart cycling\n\n this.pause()\n if (this.touchTimeout) {\n clearTimeout(this.touchTimeout)\n }\n\n this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval)\n }\n\n const swipeConfig = {\n leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),\n rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),\n endCallback: endCallBack\n }\n\n this._swipeHelper = new Swipe(this._element, swipeConfig)\n }\n\n _keydown(event) {\n if (/input|textarea/i.test(event.target.tagName)) {\n return\n }\n\n const direction = KEY_TO_DIRECTION[event.key]\n if (direction) {\n event.preventDefault()\n this._slide(this._directionToOrder(direction))\n }\n }\n\n _getItemIndex(element) {\n return this._getItems().indexOf(element)\n }\n\n _setActiveIndicatorElement(index) {\n if (!this._indicatorsElement) {\n return\n }\n\n const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement)\n\n activeIndicator.classList.remove(CLASS_NAME_ACTIVE)\n activeIndicator.removeAttribute('aria-current')\n\n const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to=\"${index}\"]`, this._indicatorsElement)\n\n if (newActiveIndicator) {\n newActiveIndicator.classList.add(CLASS_NAME_ACTIVE)\n newActiveIndicator.setAttribute('aria-current', 'true')\n }\n }\n\n _updateInterval() {\n const element = this._activeElement || this._getActive()\n\n if (!element) {\n return\n }\n\n const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10)\n\n this._config.interval = elementInterval || this._config.defaultInterval\n }\n\n _slide(order, element = null) {\n if (this._isSliding) {\n return\n }\n\n const activeElement = this._getActive()\n const isNext = order === ORDER_NEXT\n const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap)\n\n if (nextElement === activeElement) {\n return\n }\n\n const nextElementIndex = this._getItemIndex(nextElement)\n\n const triggerEvent = eventName => {\n return EventHandler.trigger(this._element, eventName, {\n relatedTarget: nextElement,\n direction: this._orderToDirection(order),\n from: this._getItemIndex(activeElement),\n to: nextElementIndex\n })\n }\n\n const slideEvent = triggerEvent(EVENT_SLIDE)\n\n if (slideEvent.defaultPrevented) {\n return\n }\n\n if (!activeElement || !nextElement) {\n // Some weirdness is happening, so we bail\n // TODO: change tests that use empty divs to avoid this check\n return\n }\n\n const isCycling = Boolean(this._interval)\n this.pause()\n\n this._isSliding = true\n\n this._setActiveIndicatorElement(nextElementIndex)\n this._activeElement = nextElement\n\n const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END\n const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV\n\n nextElement.classList.add(orderClassName)\n\n reflow(nextElement)\n\n activeElement.classList.add(directionalClassName)\n nextElement.classList.add(directionalClassName)\n\n const completeCallBack = () => {\n nextElement.classList.remove(directionalClassName, orderClassName)\n nextElement.classList.add(CLASS_NAME_ACTIVE)\n\n activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName)\n\n this._isSliding = false\n\n triggerEvent(EVENT_SLID)\n }\n\n this._queueCallback(completeCallBack, activeElement, this._isAnimated())\n\n if (isCycling) {\n this.cycle()\n }\n }\n\n _isAnimated() {\n return this._element.classList.contains(CLASS_NAME_SLIDE)\n }\n\n _getActive() {\n return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)\n }\n\n _getItems() {\n return SelectorEngine.find(SELECTOR_ITEM, this._element)\n }\n\n _clearInterval() {\n if (this._interval) {\n clearInterval(this._interval)\n this._interval = null\n }\n }\n\n _directionToOrder(direction) {\n if (isRTL()) {\n return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT\n }\n\n return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV\n }\n\n _orderToDirection(order) {\n if (isRTL()) {\n return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT\n }\n\n return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Carousel.getOrCreateInstance(this, config)\n\n if (typeof config === 'number') {\n data.to(config)\n return\n }\n\n if (typeof config === 'string') {\n if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config]()\n }\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {\n const target = SelectorEngine.getElementFromSelector(this)\n\n if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {\n return\n }\n\n event.preventDefault()\n\n const carousel = Carousel.getOrCreateInstance(target)\n const slideIndex = this.getAttribute('data-bs-slide-to')\n\n if (slideIndex) {\n carousel.to(slideIndex)\n carousel._maybeEnableCycle()\n return\n }\n\n if (Manipulator.getDataAttribute(this, 'slide') === 'next') {\n carousel.next()\n carousel._maybeEnableCycle()\n return\n }\n\n carousel.prev()\n carousel._maybeEnableCycle()\n})\n\nEventHandler.on(window, EVENT_LOAD_DATA_API, () => {\n const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)\n\n for (const carousel of carousels) {\n Carousel.getOrCreateInstance(carousel)\n }\n})\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Carousel)\n\nexport default Carousel\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap collapse.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport {\n defineJQueryPlugin,\n getElement,\n reflow\n} from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'collapse'\nconst DATA_KEY = 'bs.collapse'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\nconst EVENT_SHOW = `show${EVENT_KEY}`\nconst EVENT_SHOWN = `shown${EVENT_KEY}`\nconst EVENT_HIDE = `hide${EVENT_KEY}`\nconst EVENT_HIDDEN = `hidden${EVENT_KEY}`\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\n\nconst CLASS_NAME_SHOW = 'show'\nconst CLASS_NAME_COLLAPSE = 'collapse'\nconst CLASS_NAME_COLLAPSING = 'collapsing'\nconst CLASS_NAME_COLLAPSED = 'collapsed'\nconst CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`\nconst CLASS_NAME_HORIZONTAL = 'collapse-horizontal'\n\nconst WIDTH = 'width'\nconst HEIGHT = 'height'\n\nconst SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'\nconst SELECTOR_DATA_TOGGLE = '[data-bs-toggle=\"collapse\"]'\n\nconst Default = {\n parent: null,\n toggle: true\n}\n\nconst DefaultType = {\n parent: '(null|element)',\n toggle: 'boolean'\n}\n\n/**\n * Class definition\n */\n\nclass Collapse extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n this._isTransitioning = false\n this._triggerArray = []\n\n const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE)\n\n for (const elem of toggleList) {\n const selector = SelectorEngine.getSelectorFromElement(elem)\n const filterElement = SelectorEngine.find(selector)\n .filter(foundElement => foundElement === this._element)\n\n if (selector !== null && filterElement.length) {\n this._triggerArray.push(elem)\n }\n }\n\n this._initializeChildren()\n\n if (!this._config.parent) {\n this._addAriaAndCollapsedClass(this._triggerArray, this._isShown())\n }\n\n if (this._config.toggle) {\n this.toggle()\n }\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n toggle() {\n if (this._isShown()) {\n this.hide()\n } else {\n this.show()\n }\n }\n\n show() {\n if (this._isTransitioning || this._isShown()) {\n return\n }\n\n let activeChildren = []\n\n // find active children\n if (this._config.parent) {\n activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES)\n .filter(element => element !== this._element)\n .map(element => Collapse.getOrCreateInstance(element, { toggle: false }))\n }\n\n if (activeChildren.length && activeChildren[0]._isTransitioning) {\n return\n }\n\n const startEvent = EventHandler.trigger(this._element, EVENT_SHOW)\n if (startEvent.defaultPrevented) {\n return\n }\n\n for (const activeInstance of activeChildren) {\n activeInstance.hide()\n }\n\n const dimension = this._getDimension()\n\n this._element.classList.remove(CLASS_NAME_COLLAPSE)\n this._element.classList.add(CLASS_NAME_COLLAPSING)\n\n this._element.style[dimension] = 0\n\n this._addAriaAndCollapsedClass(this._triggerArray, true)\n this._isTransitioning = true\n\n const complete = () => {\n this._isTransitioning = false\n\n this._element.classList.remove(CLASS_NAME_COLLAPSING)\n this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW)\n\n this._element.style[dimension] = ''\n\n EventHandler.trigger(this._element, EVENT_SHOWN)\n }\n\n const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1)\n const scrollSize = `scroll${capitalizedDimension}`\n\n this._queueCallback(complete, this._element, true)\n this._element.style[dimension] = `${this._element[scrollSize]}px`\n }\n\n hide() {\n if (this._isTransitioning || !this._isShown()) {\n return\n }\n\n const startEvent = EventHandler.trigger(this._element, EVENT_HIDE)\n if (startEvent.defaultPrevented) {\n return\n }\n\n const dimension = this._getDimension()\n\n this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`\n\n reflow(this._element)\n\n this._element.classList.add(CLASS_NAME_COLLAPSING)\n this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW)\n\n for (const trigger of this._triggerArray) {\n const element = SelectorEngine.getElementFromSelector(trigger)\n\n if (element && !this._isShown(element)) {\n this._addAriaAndCollapsedClass([trigger], false)\n }\n }\n\n this._isTransitioning = true\n\n const complete = () => {\n this._isTransitioning = false\n this._element.classList.remove(CLASS_NAME_COLLAPSING)\n this._element.classList.add(CLASS_NAME_COLLAPSE)\n EventHandler.trigger(this._element, EVENT_HIDDEN)\n }\n\n this._element.style[dimension] = ''\n\n this._queueCallback(complete, this._element, true)\n }\n\n _isShown(element = this._element) {\n return element.classList.contains(CLASS_NAME_SHOW)\n }\n\n // Private\n _configAfterMerge(config) {\n config.toggle = Boolean(config.toggle) // Coerce string values\n config.parent = getElement(config.parent)\n return config\n }\n\n _getDimension() {\n return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT\n }\n\n _initializeChildren() {\n if (!this._config.parent) {\n return\n }\n\n const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE)\n\n for (const element of children) {\n const selected = SelectorEngine.getElementFromSelector(element)\n\n if (selected) {\n this._addAriaAndCollapsedClass([element], this._isShown(selected))\n }\n }\n }\n\n _getFirstLevelChildren(selector) {\n const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent)\n // remove children if greater depth\n return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element))\n }\n\n _addAriaAndCollapsedClass(triggerArray, isOpen) {\n if (!triggerArray.length) {\n return\n }\n\n for (const element of triggerArray) {\n element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen)\n element.setAttribute('aria-expanded', isOpen)\n }\n }\n\n // Static\n static jQueryInterface(config) {\n const _config = {}\n if (typeof config === 'string' && /show|hide/.test(config)) {\n _config.toggle = false\n }\n\n return this.each(function () {\n const data = Collapse.getOrCreateInstance(this, _config)\n\n if (typeof config === 'string') {\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config]()\n }\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n // preventDefault only for elements (which change the URL) not inside the collapsible element\n if (event.target.tagName === 'A' || (event.delegateTarget && event.delegateTarget.tagName === 'A')) {\n event.preventDefault()\n }\n\n for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {\n Collapse.getOrCreateInstance(element, { toggle: false }).toggle()\n }\n})\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Collapse)\n\nexport default Collapse\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap dropdown.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport * as Popper from '@popperjs/core'\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport Manipulator from './dom/manipulator.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport {\n defineJQueryPlugin,\n execute,\n getElement,\n getNextActiveElement,\n isDisabled,\n isElement,\n isRTL,\n isVisible,\n noop\n} from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'dropdown'\nconst DATA_KEY = 'bs.dropdown'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\nconst ESCAPE_KEY = 'Escape'\nconst TAB_KEY = 'Tab'\nconst ARROW_UP_KEY = 'ArrowUp'\nconst ARROW_DOWN_KEY = 'ArrowDown'\nconst RIGHT_MOUSE_BUTTON = 2 // MouseEvent.button value for the secondary button, usually the right button\n\nconst EVENT_HIDE = `hide${EVENT_KEY}`\nconst EVENT_HIDDEN = `hidden${EVENT_KEY}`\nconst EVENT_SHOW = `show${EVENT_KEY}`\nconst EVENT_SHOWN = `shown${EVENT_KEY}`\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`\n\nconst CLASS_NAME_SHOW = 'show'\nconst CLASS_NAME_DROPUP = 'dropup'\nconst CLASS_NAME_DROPEND = 'dropend'\nconst CLASS_NAME_DROPSTART = 'dropstart'\nconst CLASS_NAME_DROPUP_CENTER = 'dropup-center'\nconst CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center'\n\nconst SELECTOR_DATA_TOGGLE = '[data-bs-toggle=\"dropdown\"]:not(.disabled):not(:disabled)'\nconst SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`\nconst SELECTOR_MENU = '.dropdown-menu'\nconst SELECTOR_NAVBAR = '.navbar'\nconst SELECTOR_NAVBAR_NAV = '.navbar-nav'\nconst SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'\n\nconst PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'\nconst PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'\nconst PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'\nconst PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'\nconst PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'\nconst PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'\nconst PLACEMENT_TOPCENTER = 'top'\nconst PLACEMENT_BOTTOMCENTER = 'bottom'\n\nconst Default = {\n autoClose: true,\n boundary: 'clippingParents',\n display: 'dynamic',\n offset: [0, 2],\n popperConfig: null,\n reference: 'toggle'\n}\n\nconst DefaultType = {\n autoClose: '(boolean|string)',\n boundary: '(string|element)',\n display: 'string',\n offset: '(array|string|function)',\n popperConfig: '(null|object|function)',\n reference: '(string|element|object)'\n}\n\n/**\n * Class definition\n */\n\nclass Dropdown extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n this._popper = null\n this._parent = this._element.parentNode // dropdown wrapper\n // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/\n this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] ||\n SelectorEngine.prev(this._element, SELECTOR_MENU)[0] ||\n SelectorEngine.findOne(SELECTOR_MENU, this._parent)\n this._inNavbar = this._detectNavbar()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n toggle() {\n return this._isShown() ? this.hide() : this.show()\n }\n\n show() {\n if (isDisabled(this._element) || this._isShown()) {\n return\n }\n\n const relatedTarget = {\n relatedTarget: this._element\n }\n\n const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget)\n\n if (showEvent.defaultPrevented) {\n return\n }\n\n this._createPopper()\n\n // If this is a touch-enabled device we add extra\n // empty mouseover listeners to the body's immediate children;\n // only needed because of broken event delegation on iOS\n // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html\n if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {\n for (const element of [].concat(...document.body.children)) {\n EventHandler.on(element, 'mouseover', noop)\n }\n }\n\n this._element.focus()\n this._element.setAttribute('aria-expanded', true)\n\n this._menu.classList.add(CLASS_NAME_SHOW)\n this._element.classList.add(CLASS_NAME_SHOW)\n EventHandler.trigger(this._element, EVENT_SHOWN, relatedTarget)\n }\n\n hide() {\n if (isDisabled(this._element) || !this._isShown()) {\n return\n }\n\n const relatedTarget = {\n relatedTarget: this._element\n }\n\n this._completeHide(relatedTarget)\n }\n\n dispose() {\n if (this._popper) {\n this._popper.destroy()\n }\n\n super.dispose()\n }\n\n update() {\n this._inNavbar = this._detectNavbar()\n if (this._popper) {\n this._popper.update()\n }\n }\n\n // Private\n _completeHide(relatedTarget) {\n const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget)\n if (hideEvent.defaultPrevented) {\n return\n }\n\n // If this is a touch-enabled device we remove the extra\n // empty mouseover listeners we added for iOS support\n if ('ontouchstart' in document.documentElement) {\n for (const element of [].concat(...document.body.children)) {\n EventHandler.off(element, 'mouseover', noop)\n }\n }\n\n if (this._popper) {\n this._popper.destroy()\n }\n\n this._menu.classList.remove(CLASS_NAME_SHOW)\n this._element.classList.remove(CLASS_NAME_SHOW)\n this._element.setAttribute('aria-expanded', 'false')\n Manipulator.removeDataAttribute(this._menu, 'popper')\n EventHandler.trigger(this._element, EVENT_HIDDEN, relatedTarget)\n }\n\n _getConfig(config) {\n config = super._getConfig(config)\n\n if (typeof config.reference === 'object' && !isElement(config.reference) &&\n typeof config.reference.getBoundingClientRect !== 'function'\n ) {\n // Popper virtual elements require a getBoundingClientRect method\n throw new TypeError(`${NAME.toUpperCase()}: Option \"reference\" provided type \"object\" without a required \"getBoundingClientRect\" method.`)\n }\n\n return config\n }\n\n _createPopper() {\n if (typeof Popper === 'undefined') {\n throw new TypeError('Bootstrap\\'s dropdowns require Popper (https://popper.js.org)')\n }\n\n let referenceElement = this._element\n\n if (this._config.reference === 'parent') {\n referenceElement = this._parent\n } else if (isElement(this._config.reference)) {\n referenceElement = getElement(this._config.reference)\n } else if (typeof this._config.reference === 'object') {\n referenceElement = this._config.reference\n }\n\n const popperConfig = this._getPopperConfig()\n this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig)\n }\n\n _isShown() {\n return this._menu.classList.contains(CLASS_NAME_SHOW)\n }\n\n _getPlacement() {\n const parentDropdown = this._parent\n\n if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {\n return PLACEMENT_RIGHT\n }\n\n if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {\n return PLACEMENT_LEFT\n }\n\n if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {\n return PLACEMENT_TOPCENTER\n }\n\n if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {\n return PLACEMENT_BOTTOMCENTER\n }\n\n // We need to trim the value because custom properties can also include spaces\n const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end'\n\n if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {\n return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP\n }\n\n return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM\n }\n\n _detectNavbar() {\n return this._element.closest(SELECTOR_NAVBAR) !== null\n }\n\n _getOffset() {\n const { offset } = this._config\n\n if (typeof offset === 'string') {\n return offset.split(',').map(value => Number.parseInt(value, 10))\n }\n\n if (typeof offset === 'function') {\n return popperData => offset(popperData, this._element)\n }\n\n return offset\n }\n\n _getPopperConfig() {\n const defaultBsPopperConfig = {\n placement: this._getPlacement(),\n modifiers: [{\n name: 'preventOverflow',\n options: {\n boundary: this._config.boundary\n }\n },\n {\n name: 'offset',\n options: {\n offset: this._getOffset()\n }\n }]\n }\n\n // Disable Popper if we have a static display or Dropdown is in Navbar\n if (this._inNavbar || this._config.display === 'static') {\n Manipulator.setDataAttribute(this._menu, 'popper', 'static') // TODO: v6 remove\n defaultBsPopperConfig.modifiers = [{\n name: 'applyStyles',\n enabled: false\n }]\n }\n\n return {\n ...defaultBsPopperConfig,\n ...execute(this._config.popperConfig, [defaultBsPopperConfig])\n }\n }\n\n _selectMenuItem({ key, target }) {\n const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element))\n\n if (!items.length) {\n return\n }\n\n // if target isn't included in items (e.g. when expanding the dropdown)\n // allow cycling to get the last item in case key equals ARROW_UP_KEY\n getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus()\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Dropdown.getOrCreateInstance(this, config)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config]()\n })\n }\n\n static clearMenus(event) {\n if (event.button === RIGHT_MOUSE_BUTTON || (event.type === 'keyup' && event.key !== TAB_KEY)) {\n return\n }\n\n const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN)\n\n for (const toggle of openToggles) {\n const context = Dropdown.getInstance(toggle)\n if (!context || context._config.autoClose === false) {\n continue\n }\n\n const composedPath = event.composedPath()\n const isMenuTarget = composedPath.includes(context._menu)\n if (\n composedPath.includes(context._element) ||\n (context._config.autoClose === 'inside' && !isMenuTarget) ||\n (context._config.autoClose === 'outside' && isMenuTarget)\n ) {\n continue\n }\n\n // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu\n if (context._menu.contains(event.target) && ((event.type === 'keyup' && event.key === TAB_KEY) || /input|select|option|textarea|form/i.test(event.target.tagName))) {\n continue\n }\n\n const relatedTarget = { relatedTarget: context._element }\n\n if (event.type === 'click') {\n relatedTarget.clickEvent = event\n }\n\n context._completeHide(relatedTarget)\n }\n }\n\n static dataApiKeydownHandler(event) {\n // If not an UP | DOWN | ESCAPE key => not a dropdown command\n // If input/textarea && if key is other than ESCAPE => not a dropdown command\n\n const isInput = /input|textarea/i.test(event.target.tagName)\n const isEscapeEvent = event.key === ESCAPE_KEY\n const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)\n\n if (!isUpOrDownEvent && !isEscapeEvent) {\n return\n }\n\n if (isInput && !isEscapeEvent) {\n return\n }\n\n event.preventDefault()\n\n // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/\n const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ?\n this :\n (SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0] ||\n SelectorEngine.next(this, SELECTOR_DATA_TOGGLE)[0] ||\n SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode))\n\n const instance = Dropdown.getOrCreateInstance(getToggleButton)\n\n if (isUpOrDownEvent) {\n event.stopPropagation()\n instance.show()\n instance._selectMenuItem(event)\n return\n }\n\n if (instance._isShown()) { // else is escape and we check if it is shown\n event.stopPropagation()\n instance.hide()\n getToggleButton.focus()\n }\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler)\nEventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler)\nEventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus)\nEventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus)\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n event.preventDefault()\n Dropdown.getOrCreateInstance(this).toggle()\n})\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Dropdown)\n\nexport default Dropdown\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/backdrop.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport EventHandler from '../dom/event-handler.js'\nimport Config from './config.js'\nimport {\n execute, executeAfterTransition, getElement, reflow\n} from './index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'backdrop'\nconst CLASS_NAME_FADE = 'fade'\nconst CLASS_NAME_SHOW = 'show'\nconst EVENT_MOUSEDOWN = `mousedown.bs.${NAME}`\n\nconst Default = {\n className: 'modal-backdrop',\n clickCallback: null,\n isAnimated: false,\n isVisible: true, // if false, we use the backdrop helper without adding any element to the dom\n rootElement: 'body' // give the choice to place backdrop under different elements\n}\n\nconst DefaultType = {\n className: 'string',\n clickCallback: '(function|null)',\n isAnimated: 'boolean',\n isVisible: 'boolean',\n rootElement: '(element|string)'\n}\n\n/**\n * Class definition\n */\n\nclass Backdrop extends Config {\n constructor(config) {\n super()\n this._config = this._getConfig(config)\n this._isAppended = false\n this._element = null\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n show(callback) {\n if (!this._config.isVisible) {\n execute(callback)\n return\n }\n\n this._append()\n\n const element = this._getElement()\n if (this._config.isAnimated) {\n reflow(element)\n }\n\n element.classList.add(CLASS_NAME_SHOW)\n\n this._emulateAnimation(() => {\n execute(callback)\n })\n }\n\n hide(callback) {\n if (!this._config.isVisible) {\n execute(callback)\n return\n }\n\n this._getElement().classList.remove(CLASS_NAME_SHOW)\n\n this._emulateAnimation(() => {\n this.dispose()\n execute(callback)\n })\n }\n\n dispose() {\n if (!this._isAppended) {\n return\n }\n\n EventHandler.off(this._element, EVENT_MOUSEDOWN)\n\n this._element.remove()\n this._isAppended = false\n }\n\n // Private\n _getElement() {\n if (!this._element) {\n const backdrop = document.createElement('div')\n backdrop.className = this._config.className\n if (this._config.isAnimated) {\n backdrop.classList.add(CLASS_NAME_FADE)\n }\n\n this._element = backdrop\n }\n\n return this._element\n }\n\n _configAfterMerge(config) {\n // use getElement() with the default \"body\" to get a fresh Element on each instantiation\n config.rootElement = getElement(config.rootElement)\n return config\n }\n\n _append() {\n if (this._isAppended) {\n return\n }\n\n const element = this._getElement()\n this._config.rootElement.append(element)\n\n EventHandler.on(element, EVENT_MOUSEDOWN, () => {\n execute(this._config.clickCallback)\n })\n\n this._isAppended = true\n }\n\n _emulateAnimation(callback) {\n executeAfterTransition(callback, this._getElement(), this._config.isAnimated)\n }\n}\n\nexport default Backdrop\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/focustrap.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport EventHandler from '../dom/event-handler.js'\nimport SelectorEngine from '../dom/selector-engine.js'\nimport Config from './config.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'focustrap'\nconst DATA_KEY = 'bs.focustrap'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst EVENT_FOCUSIN = `focusin${EVENT_KEY}`\nconst EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY}`\n\nconst TAB_KEY = 'Tab'\nconst TAB_NAV_FORWARD = 'forward'\nconst TAB_NAV_BACKWARD = 'backward'\n\nconst Default = {\n autofocus: true,\n trapElement: null // The element to trap focus inside of\n}\n\nconst DefaultType = {\n autofocus: 'boolean',\n trapElement: 'element'\n}\n\n/**\n * Class definition\n */\n\nclass FocusTrap extends Config {\n constructor(config) {\n super()\n this._config = this._getConfig(config)\n this._isActive = false\n this._lastTabNavDirection = null\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n activate() {\n if (this._isActive) {\n return\n }\n\n if (this._config.autofocus) {\n this._config.trapElement.focus()\n }\n\n EventHandler.off(document, EVENT_KEY) // guard against infinite focus loop\n EventHandler.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event))\n EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event))\n\n this._isActive = true\n }\n\n deactivate() {\n if (!this._isActive) {\n return\n }\n\n this._isActive = false\n EventHandler.off(document, EVENT_KEY)\n }\n\n // Private\n _handleFocusin(event) {\n const { trapElement } = this._config\n\n if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {\n return\n }\n\n const elements = SelectorEngine.focusableChildren(trapElement)\n\n if (elements.length === 0) {\n trapElement.focus()\n } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {\n elements[elements.length - 1].focus()\n } else {\n elements[0].focus()\n }\n }\n\n _handleKeydown(event) {\n if (event.key !== TAB_KEY) {\n return\n }\n\n this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD\n }\n}\n\nexport default FocusTrap\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/scrollBar.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Manipulator from '../dom/manipulator.js'\nimport SelectorEngine from '../dom/selector-engine.js'\nimport { isElement } from './index.js'\n\n/**\n * Constants\n */\n\nconst SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'\nconst SELECTOR_STICKY_CONTENT = '.sticky-top'\nconst PROPERTY_PADDING = 'padding-right'\nconst PROPERTY_MARGIN = 'margin-right'\n\n/**\n * Class definition\n */\n\nclass ScrollBarHelper {\n constructor() {\n this._element = document.body\n }\n\n // Public\n getWidth() {\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes\n const documentWidth = document.documentElement.clientWidth\n return Math.abs(window.innerWidth - documentWidth)\n }\n\n hide() {\n const width = this.getWidth()\n this._disableOverFlow()\n // give padding to element to balance the hidden scrollbar width\n this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width)\n // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth\n this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width)\n this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width)\n }\n\n reset() {\n this._resetElementAttributes(this._element, 'overflow')\n this._resetElementAttributes(this._element, PROPERTY_PADDING)\n this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING)\n this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN)\n }\n\n isOverflowing() {\n return this.getWidth() > 0\n }\n\n // Private\n _disableOverFlow() {\n this._saveInitialAttribute(this._element, 'overflow')\n this._element.style.overflow = 'hidden'\n }\n\n _setElementAttributes(selector, styleProperty, callback) {\n const scrollbarWidth = this.getWidth()\n const manipulationCallBack = element => {\n if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {\n return\n }\n\n this._saveInitialAttribute(element, styleProperty)\n const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty)\n element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`)\n }\n\n this._applyManipulationCallback(selector, manipulationCallBack)\n }\n\n _saveInitialAttribute(element, styleProperty) {\n const actualValue = element.style.getPropertyValue(styleProperty)\n if (actualValue) {\n Manipulator.setDataAttribute(element, styleProperty, actualValue)\n }\n }\n\n _resetElementAttributes(selector, styleProperty) {\n const manipulationCallBack = element => {\n const value = Manipulator.getDataAttribute(element, styleProperty)\n // We only want to remove the property if the value is `null`; the value can also be zero\n if (value === null) {\n element.style.removeProperty(styleProperty)\n return\n }\n\n Manipulator.removeDataAttribute(element, styleProperty)\n element.style.setProperty(styleProperty, value)\n }\n\n this._applyManipulationCallback(selector, manipulationCallBack)\n }\n\n _applyManipulationCallback(selector, callBack) {\n if (isElement(selector)) {\n callBack(selector)\n return\n }\n\n for (const sel of SelectorEngine.find(selector, this._element)) {\n callBack(sel)\n }\n }\n}\n\nexport default ScrollBarHelper\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap modal.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport Backdrop from './util/backdrop.js'\nimport { enableDismissTrigger } from './util/component-functions.js'\nimport FocusTrap from './util/focustrap.js'\nimport {\n defineJQueryPlugin, isRTL, isVisible, reflow\n} from './util/index.js'\nimport ScrollBarHelper from './util/scrollbar.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'modal'\nconst DATA_KEY = 'bs.modal'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\nconst ESCAPE_KEY = 'Escape'\n\nconst EVENT_HIDE = `hide${EVENT_KEY}`\nconst EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`\nconst EVENT_HIDDEN = `hidden${EVENT_KEY}`\nconst EVENT_SHOW = `show${EVENT_KEY}`\nconst EVENT_SHOWN = `shown${EVENT_KEY}`\nconst EVENT_RESIZE = `resize${EVENT_KEY}`\nconst EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`\nconst EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`\nconst EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\n\nconst CLASS_NAME_OPEN = 'modal-open'\nconst CLASS_NAME_FADE = 'fade'\nconst CLASS_NAME_SHOW = 'show'\nconst CLASS_NAME_STATIC = 'modal-static'\n\nconst OPEN_SELECTOR = '.modal.show'\nconst SELECTOR_DIALOG = '.modal-dialog'\nconst SELECTOR_MODAL_BODY = '.modal-body'\nconst SELECTOR_DATA_TOGGLE = '[data-bs-toggle=\"modal\"]'\n\nconst Default = {\n backdrop: true,\n focus: true,\n keyboard: true\n}\n\nconst DefaultType = {\n backdrop: '(boolean|string)',\n focus: 'boolean',\n keyboard: 'boolean'\n}\n\n/**\n * Class definition\n */\n\nclass Modal extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element)\n this._backdrop = this._initializeBackDrop()\n this._focustrap = this._initializeFocusTrap()\n this._isShown = false\n this._isTransitioning = false\n this._scrollBar = new ScrollBarHelper()\n\n this._addEventListeners()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n toggle(relatedTarget) {\n return this._isShown ? this.hide() : this.show(relatedTarget)\n }\n\n show(relatedTarget) {\n if (this._isShown || this._isTransitioning) {\n return\n }\n\n const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {\n relatedTarget\n })\n\n if (showEvent.defaultPrevented) {\n return\n }\n\n this._isShown = true\n this._isTransitioning = true\n\n this._scrollBar.hide()\n\n document.body.classList.add(CLASS_NAME_OPEN)\n\n this._adjustDialog()\n\n this._backdrop.show(() => this._showElement(relatedTarget))\n }\n\n hide() {\n if (!this._isShown || this._isTransitioning) {\n return\n }\n\n const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)\n\n if (hideEvent.defaultPrevented) {\n return\n }\n\n this._isShown = false\n this._isTransitioning = true\n this._focustrap.deactivate()\n\n this._element.classList.remove(CLASS_NAME_SHOW)\n\n this._queueCallback(() => this._hideModal(), this._element, this._isAnimated())\n }\n\n dispose() {\n EventHandler.off(window, EVENT_KEY)\n EventHandler.off(this._dialog, EVENT_KEY)\n\n this._backdrop.dispose()\n this._focustrap.deactivate()\n\n super.dispose()\n }\n\n handleUpdate() {\n this._adjustDialog()\n }\n\n // Private\n _initializeBackDrop() {\n return new Backdrop({\n isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value,\n isAnimated: this._isAnimated()\n })\n }\n\n _initializeFocusTrap() {\n return new FocusTrap({\n trapElement: this._element\n })\n }\n\n _showElement(relatedTarget) {\n // try to append dynamic modal\n if (!document.body.contains(this._element)) {\n document.body.append(this._element)\n }\n\n this._element.style.display = 'block'\n this._element.removeAttribute('aria-hidden')\n this._element.setAttribute('aria-modal', true)\n this._element.setAttribute('role', 'dialog')\n this._element.scrollTop = 0\n\n const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)\n if (modalBody) {\n modalBody.scrollTop = 0\n }\n\n reflow(this._element)\n\n this._element.classList.add(CLASS_NAME_SHOW)\n\n const transitionComplete = () => {\n if (this._config.focus) {\n this._focustrap.activate()\n }\n\n this._isTransitioning = false\n EventHandler.trigger(this._element, EVENT_SHOWN, {\n relatedTarget\n })\n }\n\n this._queueCallback(transitionComplete, this._dialog, this._isAnimated())\n }\n\n _addEventListeners() {\n EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {\n if (event.key !== ESCAPE_KEY) {\n return\n }\n\n if (this._config.keyboard) {\n this.hide()\n return\n }\n\n this._triggerBackdropTransition()\n })\n\n EventHandler.on(window, EVENT_RESIZE, () => {\n if (this._isShown && !this._isTransitioning) {\n this._adjustDialog()\n }\n })\n\n EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {\n // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks\n EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {\n if (this._element !== event.target || this._element !== event2.target) {\n return\n }\n\n if (this._config.backdrop === 'static') {\n this._triggerBackdropTransition()\n return\n }\n\n if (this._config.backdrop) {\n this.hide()\n }\n })\n })\n }\n\n _hideModal() {\n this._element.style.display = 'none'\n this._element.setAttribute('aria-hidden', true)\n this._element.removeAttribute('aria-modal')\n this._element.removeAttribute('role')\n this._isTransitioning = false\n\n this._backdrop.hide(() => {\n document.body.classList.remove(CLASS_NAME_OPEN)\n this._resetAdjustments()\n this._scrollBar.reset()\n EventHandler.trigger(this._element, EVENT_HIDDEN)\n })\n }\n\n _isAnimated() {\n return this._element.classList.contains(CLASS_NAME_FADE)\n }\n\n _triggerBackdropTransition() {\n const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)\n if (hideEvent.defaultPrevented) {\n return\n }\n\n const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight\n const initialOverflowY = this._element.style.overflowY\n // return if the following background transition hasn't yet completed\n if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {\n return\n }\n\n if (!isModalOverflowing) {\n this._element.style.overflowY = 'hidden'\n }\n\n this._element.classList.add(CLASS_NAME_STATIC)\n this._queueCallback(() => {\n this._element.classList.remove(CLASS_NAME_STATIC)\n this._queueCallback(() => {\n this._element.style.overflowY = initialOverflowY\n }, this._dialog)\n }, this._dialog)\n\n this._element.focus()\n }\n\n /**\n * The following methods are used to handle overflowing modals\n */\n\n _adjustDialog() {\n const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight\n const scrollbarWidth = this._scrollBar.getWidth()\n const isBodyOverflowing = scrollbarWidth > 0\n\n if (isBodyOverflowing && !isModalOverflowing) {\n const property = isRTL() ? 'paddingLeft' : 'paddingRight'\n this._element.style[property] = `${scrollbarWidth}px`\n }\n\n if (!isBodyOverflowing && isModalOverflowing) {\n const property = isRTL() ? 'paddingRight' : 'paddingLeft'\n this._element.style[property] = `${scrollbarWidth}px`\n }\n }\n\n _resetAdjustments() {\n this._element.style.paddingLeft = ''\n this._element.style.paddingRight = ''\n }\n\n // Static\n static jQueryInterface(config, relatedTarget) {\n return this.each(function () {\n const data = Modal.getOrCreateInstance(this, config)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config](relatedTarget)\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n const target = SelectorEngine.getElementFromSelector(this)\n\n if (['A', 'AREA'].includes(this.tagName)) {\n event.preventDefault()\n }\n\n EventHandler.one(target, EVENT_SHOW, showEvent => {\n if (showEvent.defaultPrevented) {\n // only register focus restorer if modal will actually get shown\n return\n }\n\n EventHandler.one(target, EVENT_HIDDEN, () => {\n if (isVisible(this)) {\n this.focus()\n }\n })\n })\n\n // avoid conflict when clicking modal toggler while another one is open\n const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)\n if (alreadyOpen) {\n Modal.getInstance(alreadyOpen).hide()\n }\n\n const data = Modal.getOrCreateInstance(target)\n\n data.toggle(this)\n})\n\nenableDismissTrigger(Modal)\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Modal)\n\nexport default Modal\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap offcanvas.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport Backdrop from './util/backdrop.js'\nimport { enableDismissTrigger } from './util/component-functions.js'\nimport FocusTrap from './util/focustrap.js'\nimport {\n defineJQueryPlugin,\n isDisabled,\n isVisible\n} from './util/index.js'\nimport ScrollBarHelper from './util/scrollbar.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'offcanvas'\nconst DATA_KEY = 'bs.offcanvas'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\nconst EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`\nconst ESCAPE_KEY = 'Escape'\n\nconst CLASS_NAME_SHOW = 'show'\nconst CLASS_NAME_SHOWING = 'showing'\nconst CLASS_NAME_HIDING = 'hiding'\nconst CLASS_NAME_BACKDROP = 'offcanvas-backdrop'\nconst OPEN_SELECTOR = '.offcanvas.show'\n\nconst EVENT_SHOW = `show${EVENT_KEY}`\nconst EVENT_SHOWN = `shown${EVENT_KEY}`\nconst EVENT_HIDE = `hide${EVENT_KEY}`\nconst EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`\nconst EVENT_HIDDEN = `hidden${EVENT_KEY}`\nconst EVENT_RESIZE = `resize${EVENT_KEY}`\nconst EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`\nconst EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`\n\nconst SELECTOR_DATA_TOGGLE = '[data-bs-toggle=\"offcanvas\"]'\n\nconst Default = {\n backdrop: true,\n keyboard: true,\n scroll: false\n}\n\nconst DefaultType = {\n backdrop: '(boolean|string)',\n keyboard: 'boolean',\n scroll: 'boolean'\n}\n\n/**\n * Class definition\n */\n\nclass Offcanvas extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n this._isShown = false\n this._backdrop = this._initializeBackDrop()\n this._focustrap = this._initializeFocusTrap()\n this._addEventListeners()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n toggle(relatedTarget) {\n return this._isShown ? this.hide() : this.show(relatedTarget)\n }\n\n show(relatedTarget) {\n if (this._isShown) {\n return\n }\n\n const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, { relatedTarget })\n\n if (showEvent.defaultPrevented) {\n return\n }\n\n this._isShown = true\n this._backdrop.show()\n\n if (!this._config.scroll) {\n new ScrollBarHelper().hide()\n }\n\n this._element.setAttribute('aria-modal', true)\n this._element.setAttribute('role', 'dialog')\n this._element.classList.add(CLASS_NAME_SHOWING)\n\n const completeCallBack = () => {\n if (!this._config.scroll || this._config.backdrop) {\n this._focustrap.activate()\n }\n\n this._element.classList.add(CLASS_NAME_SHOW)\n this._element.classList.remove(CLASS_NAME_SHOWING)\n EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget })\n }\n\n this._queueCallback(completeCallBack, this._element, true)\n }\n\n hide() {\n if (!this._isShown) {\n return\n }\n\n const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)\n\n if (hideEvent.defaultPrevented) {\n return\n }\n\n this._focustrap.deactivate()\n this._element.blur()\n this._isShown = false\n this._element.classList.add(CLASS_NAME_HIDING)\n this._backdrop.hide()\n\n const completeCallback = () => {\n this._element.classList.remove(CLASS_NAME_SHOW, CLASS_NAME_HIDING)\n this._element.removeAttribute('aria-modal')\n this._element.removeAttribute('role')\n\n if (!this._config.scroll) {\n new ScrollBarHelper().reset()\n }\n\n EventHandler.trigger(this._element, EVENT_HIDDEN)\n }\n\n this._queueCallback(completeCallback, this._element, true)\n }\n\n dispose() {\n this._backdrop.dispose()\n this._focustrap.deactivate()\n super.dispose()\n }\n\n // Private\n _initializeBackDrop() {\n const clickCallback = () => {\n if (this._config.backdrop === 'static') {\n EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)\n return\n }\n\n this.hide()\n }\n\n // 'static' option will be translated to true, and booleans will keep their value\n const isVisible = Boolean(this._config.backdrop)\n\n return new Backdrop({\n className: CLASS_NAME_BACKDROP,\n isVisible,\n isAnimated: true,\n rootElement: this._element.parentNode,\n clickCallback: isVisible ? clickCallback : null\n })\n }\n\n _initializeFocusTrap() {\n return new FocusTrap({\n trapElement: this._element\n })\n }\n\n _addEventListeners() {\n EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {\n if (event.key !== ESCAPE_KEY) {\n return\n }\n\n if (this._config.keyboard) {\n this.hide()\n return\n }\n\n EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)\n })\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Offcanvas.getOrCreateInstance(this, config)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config](this)\n })\n }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n const target = SelectorEngine.getElementFromSelector(this)\n\n if (['A', 'AREA'].includes(this.tagName)) {\n event.preventDefault()\n }\n\n if (isDisabled(this)) {\n return\n }\n\n EventHandler.one(target, EVENT_HIDDEN, () => {\n // focus on trigger when it is closed\n if (isVisible(this)) {\n this.focus()\n }\n })\n\n // avoid conflict when clicking a toggler of an offcanvas, while another is open\n const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)\n if (alreadyOpen && alreadyOpen !== target) {\n Offcanvas.getInstance(alreadyOpen).hide()\n }\n\n const data = Offcanvas.getOrCreateInstance(target)\n data.toggle(this)\n})\n\nEventHandler.on(window, EVENT_LOAD_DATA_API, () => {\n for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {\n Offcanvas.getOrCreateInstance(selector).show()\n }\n})\n\nEventHandler.on(window, EVENT_RESIZE, () => {\n for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {\n if (getComputedStyle(element).position !== 'fixed') {\n Offcanvas.getOrCreateInstance(element).hide()\n }\n }\n})\n\nenableDismissTrigger(Offcanvas)\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Offcanvas)\n\nexport default Offcanvas\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/sanitizer.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\n// js-docs-start allow-list\nconst ARIA_ATTRIBUTE_PATTERN = /^aria-[\\w-]*$/i\n\nexport const DefaultAllowlist = {\n // Global attributes allowed on any supplied element below.\n '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],\n a: ['target', 'href', 'title', 'rel'],\n area: [],\n b: [],\n br: [],\n col: [],\n code: [],\n dd: [],\n div: [],\n dl: [],\n dt: [],\n em: [],\n hr: [],\n h1: [],\n h2: [],\n h3: [],\n h4: [],\n h5: [],\n h6: [],\n i: [],\n img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],\n li: [],\n ol: [],\n p: [],\n pre: [],\n s: [],\n small: [],\n span: [],\n sub: [],\n sup: [],\n strong: [],\n u: [],\n ul: []\n}\n// js-docs-end allow-list\n\nconst uriAttributes = new Set([\n 'background',\n 'cite',\n 'href',\n 'itemtype',\n 'longdesc',\n 'poster',\n 'src',\n 'xlink:href'\n])\n\n/**\n * A pattern that recognizes URLs that are safe wrt. XSS in URL navigation\n * contexts.\n *\n * Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38\n */\n// eslint-disable-next-line unicorn/better-regex\nconst SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i\n\nconst allowedAttribute = (attribute, allowedAttributeList) => {\n const attributeName = attribute.nodeName.toLowerCase()\n\n if (allowedAttributeList.includes(attributeName)) {\n if (uriAttributes.has(attributeName)) {\n return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue))\n }\n\n return true\n }\n\n // Check if a regular expression validates the attribute.\n return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp)\n .some(regex => regex.test(attributeName))\n}\n\nexport function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {\n if (!unsafeHtml.length) {\n return unsafeHtml\n }\n\n if (sanitizeFunction && typeof sanitizeFunction === 'function') {\n return sanitizeFunction(unsafeHtml)\n }\n\n const domParser = new window.DOMParser()\n const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')\n const elements = [].concat(...createdDocument.body.querySelectorAll('*'))\n\n for (const element of elements) {\n const elementName = element.nodeName.toLowerCase()\n\n if (!Object.keys(allowList).includes(elementName)) {\n element.remove()\n continue\n }\n\n const attributeList = [].concat(...element.attributes)\n const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || [])\n\n for (const attribute of attributeList) {\n if (!allowedAttribute(attribute, allowedAttributes)) {\n element.removeAttribute(attribute.nodeName)\n }\n }\n }\n\n return createdDocument.body.innerHTML\n}\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap util/template-factory.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport SelectorEngine from '../dom/selector-engine.js'\nimport Config from './config.js'\nimport { DefaultAllowlist, sanitizeHtml } from './sanitizer.js'\nimport { execute, getElement, isElement } from './index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'TemplateFactory'\n\nconst Default = {\n allowList: DefaultAllowlist,\n content: {}, // { selector : text , selector2 : text2 , }\n extraClass: '',\n html: false,\n sanitize: true,\n sanitizeFn: null,\n template: '
'\n}\n\nconst DefaultType = {\n allowList: 'object',\n content: 'object',\n extraClass: '(string|function)',\n html: 'boolean',\n sanitize: 'boolean',\n sanitizeFn: '(null|function)',\n template: 'string'\n}\n\nconst DefaultContentType = {\n entry: '(string|element|function|null)',\n selector: '(string|element)'\n}\n\n/**\n * Class definition\n */\n\nclass TemplateFactory extends Config {\n constructor(config) {\n super()\n this._config = this._getConfig(config)\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n getContent() {\n return Object.values(this._config.content)\n .map(config => this._resolvePossibleFunction(config))\n .filter(Boolean)\n }\n\n hasContent() {\n return this.getContent().length > 0\n }\n\n changeContent(content) {\n this._checkContent(content)\n this._config.content = { ...this._config.content, ...content }\n return this\n }\n\n toHtml() {\n const templateWrapper = document.createElement('div')\n templateWrapper.innerHTML = this._maybeSanitize(this._config.template)\n\n for (const [selector, text] of Object.entries(this._config.content)) {\n this._setContent(templateWrapper, text, selector)\n }\n\n const template = templateWrapper.children[0]\n const extraClass = this._resolvePossibleFunction(this._config.extraClass)\n\n if (extraClass) {\n template.classList.add(...extraClass.split(' '))\n }\n\n return template\n }\n\n // Private\n _typeCheckConfig(config) {\n super._typeCheckConfig(config)\n this._checkContent(config.content)\n }\n\n _checkContent(arg) {\n for (const [selector, content] of Object.entries(arg)) {\n super._typeCheckConfig({ selector, entry: content }, DefaultContentType)\n }\n }\n\n _setContent(template, content, selector) {\n const templateElement = SelectorEngine.findOne(selector, template)\n\n if (!templateElement) {\n return\n }\n\n content = this._resolvePossibleFunction(content)\n\n if (!content) {\n templateElement.remove()\n return\n }\n\n if (isElement(content)) {\n this._putElementInTemplate(getElement(content), templateElement)\n return\n }\n\n if (this._config.html) {\n templateElement.innerHTML = this._maybeSanitize(content)\n return\n }\n\n templateElement.textContent = content\n }\n\n _maybeSanitize(arg) {\n return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg\n }\n\n _resolvePossibleFunction(arg) {\n return execute(arg, [this])\n }\n\n _putElementInTemplate(element, templateElement) {\n if (this._config.html) {\n templateElement.innerHTML = ''\n templateElement.append(element)\n return\n }\n\n templateElement.textContent = element.textContent\n }\n}\n\nexport default TemplateFactory\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap tooltip.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport * as Popper from '@popperjs/core'\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport Manipulator from './dom/manipulator.js'\nimport {\n defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop\n} from './util/index.js'\nimport { DefaultAllowlist } from './util/sanitizer.js'\nimport TemplateFactory from './util/template-factory.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'tooltip'\nconst DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn'])\n\nconst CLASS_NAME_FADE = 'fade'\nconst CLASS_NAME_MODAL = 'modal'\nconst CLASS_NAME_SHOW = 'show'\n\nconst SELECTOR_TOOLTIP_INNER = '.tooltip-inner'\nconst SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`\n\nconst EVENT_MODAL_HIDE = 'hide.bs.modal'\n\nconst TRIGGER_HOVER = 'hover'\nconst TRIGGER_FOCUS = 'focus'\nconst TRIGGER_CLICK = 'click'\nconst TRIGGER_MANUAL = 'manual'\n\nconst EVENT_HIDE = 'hide'\nconst EVENT_HIDDEN = 'hidden'\nconst EVENT_SHOW = 'show'\nconst EVENT_SHOWN = 'shown'\nconst EVENT_INSERTED = 'inserted'\nconst EVENT_CLICK = 'click'\nconst EVENT_FOCUSIN = 'focusin'\nconst EVENT_FOCUSOUT = 'focusout'\nconst EVENT_MOUSEENTER = 'mouseenter'\nconst EVENT_MOUSELEAVE = 'mouseleave'\n\nconst AttachmentMap = {\n AUTO: 'auto',\n TOP: 'top',\n RIGHT: isRTL() ? 'left' : 'right',\n BOTTOM: 'bottom',\n LEFT: isRTL() ? 'right' : 'left'\n}\n\nconst Default = {\n allowList: DefaultAllowlist,\n animation: true,\n boundary: 'clippingParents',\n container: false,\n customClass: '',\n delay: 0,\n fallbackPlacements: ['top', 'right', 'bottom', 'left'],\n html: false,\n offset: [0, 6],\n placement: 'top',\n popperConfig: null,\n sanitize: true,\n sanitizeFn: null,\n selector: false,\n template: '
' +\n '
' +\n '
' +\n '
',\n title: '',\n trigger: 'hover focus'\n}\n\nconst DefaultType = {\n allowList: 'object',\n animation: 'boolean',\n boundary: '(string|element)',\n container: '(string|element|boolean)',\n customClass: '(string|function)',\n delay: '(number|object)',\n fallbackPlacements: 'array',\n html: 'boolean',\n offset: '(array|string|function)',\n placement: '(string|function)',\n popperConfig: '(null|object|function)',\n sanitize: 'boolean',\n sanitizeFn: '(null|function)',\n selector: '(string|boolean)',\n template: 'string',\n title: '(string|element|function)',\n trigger: 'string'\n}\n\n/**\n * Class definition\n */\n\nclass Tooltip extends BaseComponent {\n constructor(element, config) {\n if (typeof Popper === 'undefined') {\n throw new TypeError('Bootstrap\\'s tooltips require Popper (https://popper.js.org)')\n }\n\n super(element, config)\n\n // Private\n this._isEnabled = true\n this._timeout = 0\n this._isHovered = null\n this._activeTrigger = {}\n this._popper = null\n this._templateFactory = null\n this._newContent = null\n\n // Protected\n this.tip = null\n\n this._setListeners()\n\n if (!this._config.selector) {\n this._fixTitle()\n }\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n enable() {\n this._isEnabled = true\n }\n\n disable() {\n this._isEnabled = false\n }\n\n toggleEnabled() {\n this._isEnabled = !this._isEnabled\n }\n\n toggle() {\n if (!this._isEnabled) {\n return\n }\n\n this._activeTrigger.click = !this._activeTrigger.click\n if (this._isShown()) {\n this._leave()\n return\n }\n\n this._enter()\n }\n\n dispose() {\n clearTimeout(this._timeout)\n\n EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)\n\n if (this._element.getAttribute('data-bs-original-title')) {\n this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'))\n }\n\n this._disposePopper()\n super.dispose()\n }\n\n show() {\n if (this._element.style.display === 'none') {\n throw new Error('Please use show on visible elements')\n }\n\n if (!(this._isWithContent() && this._isEnabled)) {\n return\n }\n\n const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW))\n const shadowRoot = findShadowRoot(this._element)\n const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element)\n\n if (showEvent.defaultPrevented || !isInTheDom) {\n return\n }\n\n // TODO: v6 remove this or make it optional\n this._disposePopper()\n\n const tip = this._getTipElement()\n\n this._element.setAttribute('aria-describedby', tip.getAttribute('id'))\n\n const { container } = this._config\n\n if (!this._element.ownerDocument.documentElement.contains(this.tip)) {\n container.append(tip)\n EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED))\n }\n\n this._popper = this._createPopper(tip)\n\n tip.classList.add(CLASS_NAME_SHOW)\n\n // If this is a touch-enabled device we add extra\n // empty mouseover listeners to the body's immediate children;\n // only needed because of broken event delegation on iOS\n // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html\n if ('ontouchstart' in document.documentElement) {\n for (const element of [].concat(...document.body.children)) {\n EventHandler.on(element, 'mouseover', noop)\n }\n }\n\n const complete = () => {\n EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN))\n\n if (this._isHovered === false) {\n this._leave()\n }\n\n this._isHovered = false\n }\n\n this._queueCallback(complete, this.tip, this._isAnimated())\n }\n\n hide() {\n if (!this._isShown()) {\n return\n }\n\n const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE))\n if (hideEvent.defaultPrevented) {\n return\n }\n\n const tip = this._getTipElement()\n tip.classList.remove(CLASS_NAME_SHOW)\n\n // If this is a touch-enabled device we remove the extra\n // empty mouseover listeners we added for iOS support\n if ('ontouchstart' in document.documentElement) {\n for (const element of [].concat(...document.body.children)) {\n EventHandler.off(element, 'mouseover', noop)\n }\n }\n\n this._activeTrigger[TRIGGER_CLICK] = false\n this._activeTrigger[TRIGGER_FOCUS] = false\n this._activeTrigger[TRIGGER_HOVER] = false\n this._isHovered = null // it is a trick to support manual triggering\n\n const complete = () => {\n if (this._isWithActiveTrigger()) {\n return\n }\n\n if (!this._isHovered) {\n this._disposePopper()\n }\n\n this._element.removeAttribute('aria-describedby')\n EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN))\n }\n\n this._queueCallback(complete, this.tip, this._isAnimated())\n }\n\n update() {\n if (this._popper) {\n this._popper.update()\n }\n }\n\n // Protected\n _isWithContent() {\n return Boolean(this._getTitle())\n }\n\n _getTipElement() {\n if (!this.tip) {\n this.tip = this._createTipElement(this._newContent || this._getContentForTemplate())\n }\n\n return this.tip\n }\n\n _createTipElement(content) {\n const tip = this._getTemplateFactory(content).toHtml()\n\n // TODO: remove this check in v6\n if (!tip) {\n return null\n }\n\n tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW)\n // TODO: v6 the following can be achieved with CSS only\n tip.classList.add(`bs-${this.constructor.NAME}-auto`)\n\n const tipId = getUID(this.constructor.NAME).toString()\n\n tip.setAttribute('id', tipId)\n\n if (this._isAnimated()) {\n tip.classList.add(CLASS_NAME_FADE)\n }\n\n return tip\n }\n\n setContent(content) {\n this._newContent = content\n if (this._isShown()) {\n this._disposePopper()\n this.show()\n }\n }\n\n _getTemplateFactory(content) {\n if (this._templateFactory) {\n this._templateFactory.changeContent(content)\n } else {\n this._templateFactory = new TemplateFactory({\n ...this._config,\n // the `content` var has to be after `this._config`\n // to override config.content in case of popover\n content,\n extraClass: this._resolvePossibleFunction(this._config.customClass)\n })\n }\n\n return this._templateFactory\n }\n\n _getContentForTemplate() {\n return {\n [SELECTOR_TOOLTIP_INNER]: this._getTitle()\n }\n }\n\n _getTitle() {\n return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title')\n }\n\n // Private\n _initializeOnDelegatedTarget(event) {\n return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig())\n }\n\n _isAnimated() {\n return this._config.animation || (this.tip && this.tip.classList.contains(CLASS_NAME_FADE))\n }\n\n _isShown() {\n return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW)\n }\n\n _createPopper(tip) {\n const placement = execute(this._config.placement, [this, tip, this._element])\n const attachment = AttachmentMap[placement.toUpperCase()]\n return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))\n }\n\n _getOffset() {\n const { offset } = this._config\n\n if (typeof offset === 'string') {\n return offset.split(',').map(value => Number.parseInt(value, 10))\n }\n\n if (typeof offset === 'function') {\n return popperData => offset(popperData, this._element)\n }\n\n return offset\n }\n\n _resolvePossibleFunction(arg) {\n return execute(arg, [this._element])\n }\n\n _getPopperConfig(attachment) {\n const defaultBsPopperConfig = {\n placement: attachment,\n modifiers: [\n {\n name: 'flip',\n options: {\n fallbackPlacements: this._config.fallbackPlacements\n }\n },\n {\n name: 'offset',\n options: {\n offset: this._getOffset()\n }\n },\n {\n name: 'preventOverflow',\n options: {\n boundary: this._config.boundary\n }\n },\n {\n name: 'arrow',\n options: {\n element: `.${this.constructor.NAME}-arrow`\n }\n },\n {\n name: 'preSetPlacement',\n enabled: true,\n phase: 'beforeMain',\n fn: data => {\n // Pre-set Popper's placement attribute in order to read the arrow sizes properly.\n // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement\n this._getTipElement().setAttribute('data-popper-placement', data.state.placement)\n }\n }\n ]\n }\n\n return {\n ...defaultBsPopperConfig,\n ...execute(this._config.popperConfig, [defaultBsPopperConfig])\n }\n }\n\n _setListeners() {\n const triggers = this._config.trigger.split(' ')\n\n for (const trigger of triggers) {\n if (trigger === 'click') {\n EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {\n const context = this._initializeOnDelegatedTarget(event)\n context.toggle()\n })\n } else if (trigger !== TRIGGER_MANUAL) {\n const eventIn = trigger === TRIGGER_HOVER ?\n this.constructor.eventName(EVENT_MOUSEENTER) :\n this.constructor.eventName(EVENT_FOCUSIN)\n const eventOut = trigger === TRIGGER_HOVER ?\n this.constructor.eventName(EVENT_MOUSELEAVE) :\n this.constructor.eventName(EVENT_FOCUSOUT)\n\n EventHandler.on(this._element, eventIn, this._config.selector, event => {\n const context = this._initializeOnDelegatedTarget(event)\n context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true\n context._enter()\n })\n EventHandler.on(this._element, eventOut, this._config.selector, event => {\n const context = this._initializeOnDelegatedTarget(event)\n context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] =\n context._element.contains(event.relatedTarget)\n\n context._leave()\n })\n }\n }\n\n this._hideModalHandler = () => {\n if (this._element) {\n this.hide()\n }\n }\n\n EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)\n }\n\n _fixTitle() {\n const title = this._element.getAttribute('title')\n\n if (!title) {\n return\n }\n\n if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {\n this._element.setAttribute('aria-label', title)\n }\n\n this._element.setAttribute('data-bs-original-title', title) // DO NOT USE IT. Is only for backwards compatibility\n this._element.removeAttribute('title')\n }\n\n _enter() {\n if (this._isShown() || this._isHovered) {\n this._isHovered = true\n return\n }\n\n this._isHovered = true\n\n this._setTimeout(() => {\n if (this._isHovered) {\n this.show()\n }\n }, this._config.delay.show)\n }\n\n _leave() {\n if (this._isWithActiveTrigger()) {\n return\n }\n\n this._isHovered = false\n\n this._setTimeout(() => {\n if (!this._isHovered) {\n this.hide()\n }\n }, this._config.delay.hide)\n }\n\n _setTimeout(handler, timeout) {\n clearTimeout(this._timeout)\n this._timeout = setTimeout(handler, timeout)\n }\n\n _isWithActiveTrigger() {\n return Object.values(this._activeTrigger).includes(true)\n }\n\n _getConfig(config) {\n const dataAttributes = Manipulator.getDataAttributes(this._element)\n\n for (const dataAttribute of Object.keys(dataAttributes)) {\n if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {\n delete dataAttributes[dataAttribute]\n }\n }\n\n config = {\n ...dataAttributes,\n ...(typeof config === 'object' && config ? config : {})\n }\n config = this._mergeConfigObj(config)\n config = this._configAfterMerge(config)\n this._typeCheckConfig(config)\n return config\n }\n\n _configAfterMerge(config) {\n config.container = config.container === false ? document.body : getElement(config.container)\n\n if (typeof config.delay === 'number') {\n config.delay = {\n show: config.delay,\n hide: config.delay\n }\n }\n\n if (typeof config.title === 'number') {\n config.title = config.title.toString()\n }\n\n if (typeof config.content === 'number') {\n config.content = config.content.toString()\n }\n\n return config\n }\n\n _getDelegateConfig() {\n const config = {}\n\n for (const [key, value] of Object.entries(this._config)) {\n if (this.constructor.Default[key] !== value) {\n config[key] = value\n }\n }\n\n config.selector = false\n config.trigger = 'manual'\n\n // In the future can be replaced with:\n // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])\n // `Object.fromEntries(keysWithDifferentValues)`\n return config\n }\n\n _disposePopper() {\n if (this._popper) {\n this._popper.destroy()\n this._popper = null\n }\n\n if (this.tip) {\n this.tip.remove()\n this.tip = null\n }\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Tooltip.getOrCreateInstance(this, config)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config]()\n })\n }\n}\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Tooltip)\n\nexport default Tooltip\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap popover.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Tooltip from './tooltip.js'\nimport { defineJQueryPlugin } from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'popover'\n\nconst SELECTOR_TITLE = '.popover-header'\nconst SELECTOR_CONTENT = '.popover-body'\n\nconst Default = {\n ...Tooltip.Default,\n content: '',\n offset: [0, 8],\n placement: 'right',\n template: '
' +\n '
' +\n '

' +\n '
' +\n '
',\n trigger: 'click'\n}\n\nconst DefaultType = {\n ...Tooltip.DefaultType,\n content: '(null|string|element|function)'\n}\n\n/**\n * Class definition\n */\n\nclass Popover extends Tooltip {\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Overrides\n _isWithContent() {\n return this._getTitle() || this._getContent()\n }\n\n // Private\n _getContentForTemplate() {\n return {\n [SELECTOR_TITLE]: this._getTitle(),\n [SELECTOR_CONTENT]: this._getContent()\n }\n }\n\n _getContent() {\n return this._resolvePossibleFunction(this._config.content)\n }\n\n // Static\n static jQueryInterface(config) {\n return this.each(function () {\n const data = Popover.getOrCreateInstance(this, config)\n\n if (typeof config !== 'string') {\n return\n }\n\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`)\n }\n\n data[config]()\n })\n }\n}\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Popover)\n\nexport default Popover\n", "/**\n * --------------------------------------------------------------------------\n * Bootstrap scrollspy.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport BaseComponent from './base-component.js'\nimport EventHandler from './dom/event-handler.js'\nimport SelectorEngine from './dom/selector-engine.js'\nimport {\n defineJQueryPlugin, getElement, isDisabled, isVisible\n} from './util/index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'scrollspy'\nconst DATA_KEY = 'bs.scrollspy'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\nconst EVENT_ACTIVATE = `activate${EVENT_KEY}`\nconst EVENT_CLICK = `click${EVENT_KEY}`\nconst EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`\n\nconst CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'\nconst CLASS_NAME_ACTIVE = 'active'\n\nconst SELECTOR_DATA_SPY = '[data-bs-spy=\"scroll\"]'\nconst SELECTOR_TARGET_LINKS = '[href]'\nconst SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'\nconst SELECTOR_NAV_LINKS = '.nav-link'\nconst SELECTOR_NAV_ITEMS = '.nav-item'\nconst SELECTOR_LIST_ITEMS = '.list-group-item'\nconst SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`\nconst SELECTOR_DROPDOWN = '.dropdown'\nconst SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'\n\nconst Default = {\n offset: null, // TODO: v6 @deprecated, keep it for backwards compatibility reasons\n rootMargin: '0px 0px -25%',\n smoothScroll: false,\n target: null,\n threshold: [0.1, 0.5, 1]\n}\n\nconst DefaultType = {\n offset: '(number|null)', // TODO v6 @deprecated, keep it for backwards compatibility reasons\n rootMargin: 'string',\n smoothScroll: 'boolean',\n target: 'element',\n threshold: 'array'\n}\n\n/**\n * Class definition\n */\n\nclass ScrollSpy extends BaseComponent {\n constructor(element, config) {\n super(element, config)\n\n // this._element is the observablesContainer and config.target the menu links wrapper\n this._targetLinks = new Map()\n this._observableSections = new Map()\n this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element\n this._activeTarget = null\n this._observer = null\n this._previousScrollData = {\n visibleEntryTop: 0,\n parentScrollTop: 0\n }\n this.refresh() // initialize\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n refresh() {\n this._initializeTargetsAndObservables()\n this._maybeEnableSmoothScroll()\n\n if (this._observer) {\n this._observer.disconnect()\n } else {\n this._observer = this._getNewObserver()\n }\n\n for (const section of this._observableSections.values()) {\n this._observer.observe(section)\n }\n }\n\n dispose() {\n this._observer.disconnect()\n super.dispose()\n }\n\n // Private\n _configAfterMerge(config) {\n // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case\n config.target = getElement(config.target) || document.body\n\n // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only\n config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin\n\n if (typeof config.threshold === 'string') {\n config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value))\n }\n\n return config\n }\n\n _maybeEnableSmoothScroll() {\n if (!this._config.smoothScroll) {\n return\n }\n\n // unregister any previous listeners\n EventHandler.off(this._config.target, EVENT_CLICK)\n\n EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {\n const observableSection = this._observableSections.get(event.target.hash)\n if (observableSection) {\n event.preventDefault()\n const root = this._rootElement || window\n const height = observableSection.offsetTop - this._element.offsetTop\n if (root.scrollTo) {\n root.scrollTo({ top: height, behavior: 'smooth' })\n return\n }\n\n // Chrome 60 doesn't support `scrollTo`\n root.scrollTop = height\n }\n })\n }\n\n _getNewObserver() {\n const options = {\n root: this._rootElement,\n threshold: this._config.threshold,\n rootMargin: this._config.rootMargin\n }\n\n return new IntersectionObserver(entries => this._observerCallback(entries), options)\n }\n\n // The logic of selection\n _observerCallback(entries) {\n const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`)\n const activate = entry => {\n this._previousScrollData.visibleEntryTop = entry.target.offsetTop\n this._process(targetElement(entry))\n }\n\n const parentScrollTop = (this._rootElement || document.documentElement).scrollTop\n const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop\n this._previousScrollData.parentScrollTop = parentScrollTop\n\n for (const entry of entries) {\n if (!entry.isIntersecting) {\n this._activeTarget = null\n this._clearActiveClass(targetElement(entry))\n\n continue\n }\n\n const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop\n // if we are scrolling down, pick the bigger offsetTop\n if (userScrollsDown && entryIsLowerThanPrevious) {\n activate(entry)\n // if parent isn't scrolled, let's keep the first visible item, breaking the iteration\n if (!parentScrollTop) {\n return\n }\n\n continue\n }\n\n // if we are scrolling up, pick the smallest offsetTop\n if (!userScrollsDown && !entryIsLowerThanPrevious) {\n activate(entry)\n }\n }\n }\n\n _initializeTargetsAndObservables() {\n this._targetLinks = new Map()\n this._observableSections = new Map()\n\n const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target)\n\n for (const anchor of targetLinks) {\n // ensure that the anchor has an id and is not disabled\n if (!anchor.hash || isDisabled(anchor)) {\n continue\n }\n\n const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element)\n\n // ensure that the observableSection exists & is visible\n if (isVisible(observableSection)) {\n this._targetLinks.set(decodeURI(anchor.hash), anchor)\n this._observableSections.set(anchor.hash, observableSection)\n }\n }\n }\n\n _process(target) {\n if (this._activeTarget === target) {\n return\n }\n\n this._clearActiveClass(this._config.target)\n this._activeTarget = target\n target.classList.add(CLASS_NAME_ACTIVE)\n this._activateParents(target)\n\n EventHandler.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target })\n }\n\n _activateParents(target) {\n // Activate dropdown parents\n if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {\n SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE, target.closest(SELECTOR_DROPDOWN))\n .classList.add(CLASS_NAME_ACTIVE)\n return\n }\n\n for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {\n // Set triggered links parents as active\n // With both
    and