diff --git a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm index 1aea7617..44147703 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm @@ -14,7 +14,7 @@ ajax '/ajax/content/device/netmap' => require_login sub { template 'ajax/device/netmap.tt', {}, { layout => undef }; }; -ajax '/ajax/data/device/alldevicelinks' => require_login sub { +ajax '/ajax/data/device/netmap' => require_login sub { my $q = param('q'); my %data = ( nodes => [], links => [] ); diff --git a/share/public/css/d3-force.css b/share/public/css/d3-force.css new file mode 100644 index 00000000..20c63963 --- /dev/null +++ b/share/public/css/d3-force.css @@ -0,0 +1,197 @@ +.net_gobrechts_d3_force, +.net_gobrechts_d3_force_customize, +.net_gobrechts_d3_force_customize td, +.net_gobrechts_d3_force_tooltip { + box-sizing: content-box; + font-family: Arial, Helvetica, Sans Serif; + font-size: 10px; + background-color: #fff +} +.net_gobrechts_d3_force.border { + border: 1px solid silver; + border-radius: 5px; +} +.net_gobrechts_d3_force circle.highlighted { + stroke: #555; + stroke-width: 2px; + stroke-opacity: 1.0; +} +.net_gobrechts_d3_force circle.selected { + stroke: #555; + stroke-width: 4px; + stroke-dasharray: 4 2; + stroke-opacity: 1.0; +} +.net_gobrechts_d3_force text.label, +.net_gobrechts_d3_force text.labelCircular { + fill: black; + font-size: 10px; + letter-spacing: 0; + pointer-events: none; +} +.net_gobrechts_d3_force text.label{ + text-anchor: middle; +} +.net_gobrechts_d3_force text.highlighted { + font-size: 12px; + font-weight: bold; +} +.net_gobrechts_d3_force text.link { + font-size: 12px; + fill: blue; + cursor: pointer; +} +.net_gobrechts_d3_force line.link, +.net_gobrechts_d3_force path.link { + fill: none; + stroke: #bbb; + stroke-width: 1.5px; + stroke-opacity: 0.8; +} +.net_gobrechts_d3_force line.dotted, +.net_gobrechts_d3_force path.dotted { + stroke-dasharray: .01 3; + stroke-linecap: round; +} +.net_gobrechts_d3_force line.dashed, +.net_gobrechts_d3_force path.dashed { + stroke-dasharray: 4 2; +} +.net_gobrechts_d3_force line.highlighted, +.net_gobrechts_d3_force path.highlighted { + stroke: #555 !important; + stroke-opacity: 1.0; +} +.net_gobrechts_d3_force marker.normal { + stroke: none; + fill: #bbb; +} +.net_gobrechts_d3_force marker.highlighted { + stroke: none; + fill: #555; +} +.net_gobrechts_d3_force .graphOverlay, +.net_gobrechts_d3_force .graphOverlaySizeHelper { + fill: none; + pointer-events: all; +} +.net_gobrechts_d3_force .lasso path { + stroke: #505050; + stroke-width: 2px; +} +.net_gobrechts_d3_force .lasso .drawn { + fill-opacity: 0.05 ; +} +.net_gobrechts_d3_force .lasso .loop_close { + fill: none; + stroke-dasharray: 4,4; +} +.net_gobrechts_d3_force .lasso .origin { + fill: #3399FF; + fill-opacity: 0.5; +} +.net_gobrechts_d3_force .loading rect { + fill: black; + fill-opacity: 0.2; +} +.net_gobrechts_d3_force .loading text { + fill: white; + font-size: 36px; + text-anchor: middle; +} +.net_gobrechts_d3_force_tooltip { + position: absolute; + border-radius: 5px; + padding: 5px; + background-color: silver; + opacity: 0.9; + width: 150px; + overflow: auto; + font-size: 12px; + z-index: 100000; + pointer-events: none; + display: none; +} +.net_gobrechts_d3_force_customize { + border: 1px solid silver; + border-radius: 5px; + font-size: 12px; + position: absolute; + padding: 5px; + background-color:white; + box-shadow: 1px 1px 6px #666; + z-index: 200000; +} +.net_gobrechts_d3_force_customize .drag { + border: 1px dashed silver; + border-radius: 3px; + display: block; + cursor: move; + font-weight: bold; + height: 24px; + margin-bottom: 5px; +} +.net_gobrechts_d3_force_customize .title { + position: absolute; + top: 10px; + left: 10px; +} +.net_gobrechts_d3_force_customize .close { + position: absolute; + top: 10px; + right: 10px; +} +.net_gobrechts_d3_force_customize table { + border-collapse: collapse; + border-spacing: 0; + border: none; + margin:0; + padding:0; +} +.net_gobrechts_d3_force_customize tr.hidden { + display: none; +} +.net_gobrechts_d3_force_customize td { + padding: 1px; + font-size: 12px; + vertical-align: middle; + border: none; +} +.net_gobrechts_d3_force_customize .label { + text-align: right; +} +.net_gobrechts_d3_force_customize .warning { + background-color: orange; +} +.net_gobrechts_d3_force_customize input, +.net_gobrechts_d3_force_customize select, +.net_gobrechts_d3_force_customize textarea, +.net_gobrechts_d3_force_customize a { + border: 1px solid silver; + margin: 0; + padding: 0; + height: auto; +} +.net_gobrechts_d3_force_customize a { + border: 1px solid transparent; + color: blue; + text-decoration: none; + cursor: pointer; +} +.net_gobrechts_d3_force_customize input:focus, +.net_gobrechts_d3_force_customize select:focus, +.net_gobrechts_d3_force_customize textarea:focus, +.net_gobrechts_d3_force_customize a:focus { + outline: none !important; + border: 1px solid blue !important; + background-color: yellow !important; + box-shadow: none !important; +} +.net_gobrechts_d3_force_customize textarea { + font-size: 10px !important; + padding: 2px; + width: 160px; + height: 85px; + background-color: white; + color: black; +} diff --git a/share/public/javascripts/d3-force.js b/share/public/javascripts/d3-force.js new file mode 100644 index 00000000..4a7d6cce --- /dev/null +++ b/share/public/javascripts/d3-force.js @@ -0,0 +1,4175 @@ +/*********************************************************************************************************************** + * D3 Force Implementation, Playground and Oracle APEX Plugin: https://github.com/ogobrecht/d3-force-apex-plugin + * + * @param pDomContainerId The DOM container, where the graph should be rendered + * @param pOptions The configuration object to configure the graph, see also the API reference + * @param pApexPluginId If used as APEX plugin, this ID is the plugin identifier for the AJAX calls + * @param pApexPageItemsToSubmit If used as APEX plugin, these page items are submitted before the AJAX call + * @returns {graph} The graph function is returned to allow method chaining + */ +function netGobrechtsD3Force(pDomContainerId, pOptions, pApexPluginId, pApexPageItemsToSubmit) { // jshint ignore:line + /* exported netGobrechtsD3Force */ + /* globals apex, $v, navigator, d3, document, console, window, clearInterval, ActiveXObject, DOMParser */ + + "use strict"; + + // setup graph variable + var v = { + "conf": {}, + "confDefaults": {}, + "data": {}, + "dom": {}, + "events": {}, + "lib": {}, + "main": {}, + "status": {}, + "tools": {}, + "version": "2.0.3" + }; + + + /******************************************************************************************************************* + * MAIN: INIT + */ + v.main.init = function() { + + // save parameter for later use + v.dom.containerId = pDomContainerId || "D3Force" + Math.floor(Math.random() * 1000000); + v.confUser = pOptions || {}; + v.status.apexPluginId = pApexPluginId; + //v.status.apexPageItemsToSubmit = (pApexPageItemsToSubmit === "" ? false : + // pApexPageItemsToSubmit.replace(/\s/g,"").split(",")); + + // initialize the graph function + v.main.setupConfiguration(); + v.main.setupDom(); + v.main.setupFunctionReferences(); + }; + + + /******************************************************************************************************************* + * MAIN: SETUP CONFIGURATION + */ + v.main.setupConfiguration = function() { + /* jshint -W074, -W071 */ + // configure debug mode for APEX, can be overwritten by users configuration object + // or later on with the API debug method + v.conf.debug = (v.status.apexPluginId && apex.jQuery("#pdebug").length === 1); + v.status.debugPrefix = "D3 Force in DOM container #" + v.dom.containerId + ": "; + + // status variables + v.status.customize = false; + v.status.customizeCurrentMenu = "nodes"; + v.status.customizeCurrentTabPosition = null; + v.status.forceTickCounter = 0; + v.status.forceStartTime = 0; + v.status.forceRunning = false; + v.status.graphStarted = false; + v.status.graphRendering = false; + v.status.graphReady = false; + v.status.graphOldPositions = null; + v.status.sampleData = false; + + // default configuration + v.confDefaults.minNodeRadius = { + "display": true, + "relation": "node", + "type": "number", + "val": 6, + "options": [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + }; + v.confDefaults.maxNodeRadius = { + "display": true, + "relation": "node", + "type": "number", + "val": 18, + "options": [36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12] + }; + v.confDefaults.colorScheme = { + "display": true, + "relation": "node", + "type": "text", + "val": "color20", + "options": ["color20", "color20b", "color20c", "color10", "direct"] + }; + v.confDefaults.dragMode = { + "display": true, + "relation": "node", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.pinMode = { + "display": true, + "relation": "node", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.nodeEventToStopPinMode = { + "display": true, + "relation": "node", + "type": "text", + "val": "contextmenu", + "options": ["none", "dblclick", "contextmenu"] + }; + v.confDefaults.onNodeContextmenuPreventDefault = { + "display": true, + "relation": "node", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.nodeEventToOpenLink = { + "display": true, + "relation": "node", + "type": "text", + "val": "dblclick", + "options": ["none", "click", "dblclick", "contextmenu"] + }; + v.confDefaults.nodeLinkTarget = { + "display": true, + "relation": "node", + "type": "text", + "val": "_blank", + "options": ["none", "_blank", "nodeID", "domContainerID"] + }; + v.confDefaults.showLabels = { + "display": true, + "relation": "node", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.labelsCircular = { + "display": true, + "relation": "node", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.labelDistance = { + "display": true, + "relation": "node", + "type": "number", + "val": 12, + "options": [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2] + }; + v.confDefaults.preventLabelOverlappingOnForceEnd = { + "display": true, + "relation": "node", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.labelPlacementIterations = { + "display": true, + "relation": "node", + "type": "number", + "val": 250, + "options": [2000, 1000, 500, 250, 125] + }; + v.confDefaults.showTooltips = { + "display": true, + "relation": "node", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.tooltipPosition = { + "display": true, + "relation": "node", + "type": "text", + "val": "svgTopRight", + "options": ["node", "svgTopLeft", "svgTopRight"] + }; + v.confDefaults.alignFixedNodesToGrid = { + "display": true, + "relation": "node", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.gridSize = { + "display": true, + "relation": "node", + "type": "number", + "val": 50, + "options": [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10] + }; + + v.confDefaults.linkDistance = { + "display": true, + "relation": "link", + "type": "number", + "val": 80, + "options": [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20] + }; + v.confDefaults.showLinkDirection = { + "display": true, + "relation": "link", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.showSelfLinks = { + "display": true, + "relation": "link", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.selfLinkDistance = { + "display": true, + "relation": "link", + "type": "number", + "val": 20, + "options": [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8] + }; + + v.confDefaults.useDomParentWidth = { + "display": true, + "relation": "graph", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.width = { + "display": true, + "relation": "graph", + "type": "number", + "val": 1200, + "options": [1200, 1150, 1100, 1050, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, + 300 + ] + }; + v.confDefaults.height = { + "display": true, + "relation": "graph", + "type": "number", + "val": 650, + "options": [1200, 1150, 1100, 1050, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, + 300 + ] + }; + v.confDefaults.setDomParentPaddingToZero = { + "display": true, + "relation": "graph", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.showBorder = { + "display": true, + "relation": "graph", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.showLegend = { + "display": true, + "relation": "graph", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.showLoadingIndicatorOnAjaxCall = { + "display": true, + "relation": "graph", + "type": "bool", + "val": true, + "options": [true, false] + }; + v.confDefaults.lassoMode = { + "display": true, + "relation": "graph", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.zoomMode = { + "display": true, + "relation": "graph", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.minZoomFactor = { + "display": true, + "relation": "graph", + "type": "number", + "val": 0.2, + "options": [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1] + }; + v.confDefaults.maxZoomFactor = { + "display": true, + "relation": "graph", + "type": "number", + "val": 5, + "options": [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + }; + v.confDefaults.transform = { + "display": false, + "relation": "graph", + "type": "object", + "val": { + "translate": [0, 0], + "scale": 1 + } + }; + v.confDefaults.autoRefresh = { + "display": true, + "relation": "graph", + "type": "bool", + "val": false, + "options": [true, false] + }; + v.confDefaults.refreshInterval = { + "display": true, + "relation": "graph", + "type": "number", + "val": 5000, + "options": [60000, 30000, 15000, 10000, 5000, 2500] + }; + v.confDefaults.chargeDistance = { + "display": false, + "relation": "graph", + "type": "number", + "val": Infinity, + "options": [Infinity, 25600, 12800, 6400, 3200, 1600, 800, 400, 200, 100], + "internal": true + }; + v.confDefaults.charge = { + "display": true, + "relation": "graph", + "type": "number", + "val": -350, + "options": [-1000, -950, -900, -850, -800, -750, -700, -650, -600, -550, -500, -450, -400, -350, -300, -250, + -200, -150, -100, -50, 0], + "internal": true + }; + v.confDefaults.gravity = { + "display": true, + "relation": "graph", + "type": "number", + "val": 0.1, + "options": [1.00, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50, 0.45, 0.40, 0.35, 0.30, 0.25, + 0.20, 0.15, 0.1, 0.05, 0.00 + ], + "internal": true + }; + v.confDefaults.linkStrength = { + "display": true, + "relation": "graph", + "type": "number", + "val": 1, + "options": [1.00, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50, 0.45, 0.40, 0.35, 0.30, 0.25, + 0.20, 0.15, 0.10, 0.05, 0.00 + ], + "internal": true + }; + v.confDefaults.friction = { + "display": true, + "relation": "graph", + "type": "number", + "val": 0.9, + "options": [1.00, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.65, 0.60, 0.55, 0.50, 0.45, 0.40, 0.35, 0.30, 0.25, + 0.20, 0.15, 0.10, 0.05, 0.00 + ], + "internal": true + }; + v.confDefaults.theta = { + "display": true, + "relation": "graph", + "type": "number", + "val": 0.8, + "options": [1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, + 0.1, 0.05, 0 + ], + "internal": true + }; + + // create intial configuration + v.conf.debug = (typeof v.confUser.debug !== "undefined" ? v.tools.parseBool(v.confUser.debug) : false); + + v.conf.minNodeRadius = v.confUser.minNodeRadius || v.confDefaults.minNodeRadius.val; + v.conf.maxNodeRadius = v.confUser.maxNodeRadius || v.confDefaults.maxNodeRadius.val; + v.conf.colorScheme = v.confUser.colorScheme || v.confDefaults.colorScheme.val; + v.conf.dragMode = (typeof v.confUser.dragMode !== "undefined" ? v.tools.parseBool(v.confUser.dragMode) : + v.confDefaults.dragMode.val); + v.conf.pinMode = (typeof v.confUser.pinMode !== "undefined" ? v.tools.parseBool(v.confUser.pinMode) : + v.confDefaults.pinMode.val); + v.conf.nodeEventToStopPinMode = v.confUser.nodeEventToStopPinMode || v.confDefaults.nodeEventToStopPinMode.val; + v.conf.onNodeContextmenuPreventDefault = (typeof v.confUser.onNodeContextmenuPreventDefault !== "undefined" ? + v.tools.parseBool(v.confUser.onNodeContextmenuPreventDefault) : + v.confDefaults.onNodeContextmenuPreventDefault.val); + v.conf.nodeEventToOpenLink = v.confUser.nodeEventToOpenLink || v.confDefaults.nodeEventToOpenLink.val; + v.conf.nodeLinkTarget = v.confUser.nodeLinkTarget || v.confDefaults.nodeLinkTarget.val; + v.conf.showLabels = (typeof v.confUser.showLabels !== "undefined" ? v.tools.parseBool(v.confUser.showLabels) : + v.confDefaults.showLabels.val); + v.conf.labelsCircular = (typeof v.confUser.labelsCircular !== "undefined" ? + v.tools.parseBool(v.confUser.labelsCircular) : v.confDefaults.labelsCircular.val); + v.conf.labelDistance = v.confUser.labelDistance || v.confDefaults.labelDistance.val; + v.conf.preventLabelOverlappingOnForceEnd = + (typeof v.confUser.preventLabelOverlappingOnForceEnd !== "undefined" ? + v.tools.parseBool(v.confUser.preventLabelOverlappingOnForceEnd) : + v.confDefaults.preventLabelOverlappingOnForceEnd.val); + v.conf.labelPlacementIterations = v.confUser.labelPlacementIterations || + v.confDefaults.labelPlacementIterations.val; + v.conf.showTooltips = (typeof v.confUser.showTooltips !== "undefined" ? + v.tools.parseBool(v.confUser.showTooltips) : v.confDefaults.showTooltips.val); + v.conf.tooltipPosition = v.confUser.tooltipPosition || v.confDefaults.tooltipPosition.val; + v.conf.alignFixedNodesToGrid = (typeof v.confUser.alignFixedNodesToGrid !== "undefined" ? + v.tools.parseBool(v.confUser.alignFixedNodesToGrid) : v.confDefaults.alignFixedNodesToGrid.val); + v.conf.gridSize = (v.confUser.gridSize && v.confUser.gridSize > 0 ? + v.confUser.gridSize : v.confDefaults.gridSize.val); + + v.conf.linkDistance = v.confUser.linkDistance || v.confDefaults.linkDistance.val; + v.conf.showLinkDirection = (typeof v.confUser.showLinkDirection !== "undefined" ? + v.tools.parseBool(v.confUser.showLinkDirection) : v.confDefaults.showLinkDirection.val); + v.conf.showSelfLinks = (typeof v.confUser.showSelfLinks !== "undefined" ? + v.tools.parseBool(v.confUser.showSelfLinks) : v.confDefaults.showSelfLinks.val); + v.conf.selfLinkDistance = v.confUser.selfLinkDistance || v.confDefaults.selfLinkDistance.val; + + v.conf.useDomParentWidth = (typeof v.confUser.useDomParentWidth !== "undefined" ? + v.tools.parseBool(v.confUser.useDomParentWidth) : v.confDefaults.useDomParentWidth.val); + v.conf.width = v.confUser.width || v.confDefaults.width.val; + v.conf.height = v.confUser.height || v.confDefaults.height.val; + v.conf.setDomParentPaddingToZero = (typeof v.confUser.setDomParentPaddingToZero !== "undefined" ? + v.tools.parseBool(v.confUser.setDomParentPaddingToZero) : v.confDefaults.setDomParentPaddingToZero.val); + v.conf.showBorder = (typeof v.confUser.showBorder !== "undefined" ? v.tools.parseBool(v.confUser.showBorder) : + v.confDefaults.showBorder.val); + v.conf.showLegend = (typeof v.confUser.showLegend !== "undefined" ? v.tools.parseBool(v.confUser.showLegend) : + v.confDefaults.showLegend.val); + v.conf.showLoadingIndicatorOnAjaxCall = (typeof v.confUser.showLoadingIndicatorOnAjaxCall !== "undefined" ? + v.tools.parseBool(v.confUser.showLoadingIndicatorOnAjaxCall) : + v.confDefaults.showLoadingIndicatorOnAjaxCall.val); + v.conf.lassoMode = (typeof v.confUser.lassoMode !== "undefined" ? v.tools.parseBool(v.confUser.lassoMode) : + v.confDefaults.lassoMode.val); + v.conf.zoomMode = (typeof v.confUser.zoomMode !== "undefined" ? v.tools.parseBool(v.confUser.zoomMode) : + v.confDefaults.zoomMode.val); + v.conf.minZoomFactor = v.confUser.minZoomFactor || v.confDefaults.minZoomFactor.val; + v.conf.maxZoomFactor = v.confUser.maxZoomFactor || v.confDefaults.maxZoomFactor.val; + v.conf.transform = v.confUser.transform || v.confDefaults.transform.val; + v.conf.autoRefresh = (typeof v.confUser.autoRefresh !== "undefined" ? + v.tools.parseBool(v.confUser.autoRefresh) : v.confDefaults.autoRefresh.val); + v.conf.refreshInterval = v.confUser.refreshInterval || v.confDefaults.refreshInterval.val; + v.conf.chargeDistance = v.confUser.chargeDistance || Infinity; + v.conf.charge = v.confUser.charge || v.confDefaults.charge.val; + v.conf.gravity = v.confUser.gravity || v.confDefaults.gravity.val; + v.conf.linkStrength = v.confUser.linkStrength || v.confDefaults.linkStrength.val; + v.conf.friction = v.confUser.friction || v.confDefaults.friction.val; + v.conf.theta = v.confUser.theta || v.confDefaults.theta.val; + + v.conf.onNodeMouseenterFunction = v.confUser.onNodeMouseenterFunction || null; + v.conf.onNodeMouseleaveFunction = v.confUser.onNodeMouseleaveFunction || null; + v.conf.onNodeClickFunction = v.confUser.onNodeClickFunction || null; + v.conf.onNodeDblclickFunction = v.confUser.onNodeDblclickFunction || null; + v.conf.onNodeContextmenuFunction = v.confUser.onNodeContextmenuFunction || null; + v.conf.onLinkClickFunction = v.confUser.onLinkClickFunction || null; + v.conf.onLassoStartFunction = v.confUser.onLassoStartFunction || null; + v.conf.onLassoEndFunction = v.confUser.onLassoEndFunction || null; + + // initialize sample data + /* jshint -W110 */ + v.data.sampleData = '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; + /* jshint +W110 */ + + // check user agent: http://stackoverflow.com/questions/16135814/check-for-ie-10 + v.status.userAgent = navigator.userAgent; + v.status.userAgentIe9To11 = false; + // Hello IE 9 - 11 + if (navigator.appVersion.indexOf("MSIE 9") !== -1 || + navigator.appVersion.indexOf("MSIE 10") !== -1 || + v.status.userAgent.indexOf("Trident") !== -1 && v.status.userAgent.indexOf("rv:11") !== -1) { + v.status.userAgentIe9To11 = true; + v.tools.logError("Houston, we have a problem - user agent is IE 9, 10 or 11 - we have to provide a fix " + + "for markers: " + + "http://stackoverflow.com/questions/15588478/internet-explorer-10-not-showing-svg-path-d3-js-graph"); + } + + }; // --> END v.main.setupConfiguration + + /******************************************************************************************************************* + * MAIN: SETUP DOM + */ + v.main.setupDom = function() { + + // create reference to body + v.dom.body = d3.select("body"); + + // create DOM container element, if not existing (if we have an APEX context, it is already created from the + // APEX engine ) + if (document.querySelector("#" + v.dom.containerId) === null) { + v.dom.container = v.dom.body.append("div") + .attr("id", v.dom.containerId); + } else { + v.dom.container = d3.select("#" + v.dom.containerId); + d3.selectAll("#" + v.dom.containerId + "_tooltip, #" + v.dom.containerId + "_customizing").remove(); + } + + // create SVG element, if not existing (if we have an APEX context, it is already created from the APEX plugin ) + if (document.querySelector("#" + v.dom.containerId + " svg") === null) { + v.dom.svg = v.dom.container.append("svg"); + } else { + v.dom.svg = d3.select("#" + v.dom.containerId + " svg"); + d3.selectAll("#" + v.dom.containerId + " svg *").remove(); + } + + v.dom.svgParent = d3.select(v.dom.svg.node().parentNode); + if (v.conf.setDomParentPaddingToZero) { + v.dom.svgParent.style("padding", "0"); + } + + // configure SVG element + v.dom.svg + .attr("class", "net_gobrechts_d3_force") + .classed("border", v.conf.showBorder) + .attr("width", v.conf.width) + .attr("height", v.conf.height); + + // calculate width of SVG parent + v.dom.containerWidth = v.tools.getSvgParentInnerWidth(); + if (v.conf.useDomParentWidth) { + v.dom.svg.attr("width", v.dom.containerWidth); + } + + // create definitions element inside the SVG element + v.dom.defs = v.dom.svg.append("defs"); + + // create overlay element to fetch events for lasso & zoom + v.dom.graphOverlay = v.dom.svg.append("g").attr("class", "graphOverlay"); + + // create element for resizing the overlay g element + v.dom.graphOverlaySizeHelper = v.dom.graphOverlay.append("rect").attr("class", "graphOverlaySizeHelper"); + + // create graph group element for zoom and pan + v.dom.graph = v.dom.graphOverlay.append("g").attr("class", "graph"); + + // create legend group element + v.dom.legend = v.dom.svg.append("g").attr("class", "legend"); + + // create loading indicator + v.dom.loading = v.dom.svg.append("svg:g") + .attr("class", "loading") + .style("display", "none"); + v.dom.loadingRect = v.dom.loading + .append("svg:rect") + .attr("width", v.tools.getGraphWidth()) + .attr("height", v.conf.height); + v.dom.loadingText = v.dom.loading + .append("svg:text") + .attr("x", v.tools.getGraphWidth() / 2) + .attr("y", v.conf.height / 2) + .text("Loading..."); + + // create marker definitions + v.dom.defs + .append("svg:marker") + .attr("id", v.dom.containerId + "_highlighted") + .attr("class", "highlighted") + .attr("viewBox", "0 0 10 10") + .attr("refX", 10) + .attr("refY", 5) + .attr("markerWidth", 5) + .attr("markerHeight", 5) + .attr("orient", "auto") + .attr("markerUnits", "strokeWidth") + .append("svg:path") + .attr("d", "M0,0 L10,5 L0,10"); + + v.dom.defs + .append("svg:marker") + .attr("id", v.dom.containerId + "_normal") + .attr("class", "normal") + .attr("viewBox", "0 0 10 10") + .attr("refX", 10) + .attr("refY", 5) + .attr("markerWidth", 5) + .attr("markerHeight", 5) + .attr("orient", "auto") + .attr("markerUnits", "strokeWidth") + .append("svg:path") + .attr("d", "M0,0 L10,5 L0,10"); + + // create tooltip container + if (document.querySelector("#" + v.dom.containerId + "_tooltip") === null) { + v.dom.tooltip = v.dom.body.append("div") + .attr("id", v.dom.containerId + "_tooltip") + .attr("class", "net_gobrechts_d3_force_tooltip") + .style("top", "0px") + .style("left", "0px"); + } else { + v.dom.tooltip = d3.select("#" + v.dom.containerId + "_tooltip"); + } + + }; // --> END v.main.setupDom + + + /******************************************************************************************************************* + * MAIN: SETUP FUNCTION REFERENCES + */ + v.main.setupFunctionReferences = function() { + + // create force reference + v.main.force = d3.layout.force() + .on("start", function() { + v.tools.log("Force started."); + if (v.status.customize && v.dom.customizePositions) { + v.dom.customizePositions.text("Force started - wait for end event to show positions..."); + } + v.status.forceTickCounter = 0; + v.status.forceStartTime = new Date().getTime(); + v.status.forceRunning = true; + }) + .on("tick", function() { + // hello IE 9 - 11: + // http://stackoverflow.com/questions/15588478/internet-explorer-10-not-showing-svg-path-d3-js-graph + if (v.status.userAgentIe9To11 && v.conf.showLinkDirection) { + v.main.links.each(function() { + this.parentNode.insertBefore(this, this); + }); + v.main.selfLinks.each(function() { + this.parentNode.insertBefore(this, this); + }); + } + v.main.selfLinks + .attr("transform", function(l) { + return "translate(" + l.source.x + "," + l.source.y + ")"; + }); + v.main.links + .attr("x1", function(l) { + return v.tools.adjustSourceX(l); + }) + .attr("y1", function(l) { + return v.tools.adjustSourceY(l); + }) + .attr("x2", function(l) { + return v.tools.adjustTargetX(l); + }) + .attr("y2", function(l) { + return v.tools.adjustTargetY(l); + }); + if (v.conf.showLabels) { + v.main.labels + .attr("x", function(l) { + return l.x; + }) + .attr("y", function(l) { + return l.y - l.radius - v.conf.labelDistance; + }); + v.main.labelPaths + .attr("transform", function(n) { + return "translate(" + n.x + "," + n.y + ")"; + }); + } + v.main.nodes + .attr("cx", function(n) { + return n.x; + }) + .attr("cy", function(n) { + return n.y; + }); + v.status.forceTickCounter += 1; + }) + .on("end", function() { + if (v.conf.showLabels && v.conf.preventLabelOverlappingOnForceEnd) { + v.data.simulatedAnnealingLabels = []; + v.data.simulatedAnnealingAnchors = []; + v.main.labels.each(function(l, i) { + v.data.simulatedAnnealingLabels[i] = { + width: this.getBBox().width, + height: this.getBBox().height, + x: l.x, + y: l.y - l.radius - v.conf.labelDistance + }; + }); + v.main.nodes.filter(function(n) { + return !n.LABELCIRCULAR && !v.conf.labelsCircular; + }).each(function(n, i) { + v.data.simulatedAnnealingAnchors[i] = { + x: n.x, + y: n.y - n.radius - v.conf.labelDistance, // set anchors to the same positions as the label + r: 0.5 //fake radius for labeler plugin, because our labels are already outside of the nodes + }; + }); + v.lib.labelerPlugin() + .label(v.data.simulatedAnnealingLabels) + .anchor(v.data.simulatedAnnealingAnchors) + .width(v.tools.getGraphWidth()) + .height(v.conf.height) + .start(v.conf.labelPlacementIterations); + v.main.labels.each(function(l, i) { + d3.select(this) + .transition() + .duration(800) + .attr("x", v.data.simulatedAnnealingLabels[i].x) + .attr("y", v.data.simulatedAnnealingLabels[i].y); + }); + } + v.status.forceRunning = false; + var milliseconds = new Date().getTime() - v.status.forceStartTime; + var seconds = (milliseconds / 1000).toFixed(1); + var ticksPerSecond = Math.round(v.status.forceTickCounter / (milliseconds / 1000)); + var millisecondsPerTick = Math.round(milliseconds / v.status.forceTickCounter); + if (v.status.customize && v.dom.customizePositions) { + v.dom.customizePositions.text(JSON.stringify(graph.positions())); + } + v.tools.log("Force ended."); + v.tools.log(seconds + " seconds, " + v.status.forceTickCounter + " ticks to cool down (" + + ticksPerSecond + " ticks/s, " + millisecondsPerTick + " ms/tick)."); + }); + + // create drag reference + v.main.drag = v.main.force.drag(); + + // create lasso reference + v.main.lasso = v.lib.lassoPlugin() + .closePathDistance(100) // max distance for the lasso loop to be closed + .closePathSelect(true) // can items be selected by closing the path? + .hoverSelect(true) // can items by selected by hovering over them? + .area(v.dom.graphOverlay) // area where the lasso can be started + .pathContainer(v.dom.svg); // Container for the path + + // create zoom reference + v.main.zoom = d3.behavior.zoom(); + + }; // --> END v.main.setupFunctionReferences + + + /******************************************************************************************************************* + * HELPER FUNCTIONS + */ + + // helper to check boolean values + v.tools.parseBool = function(value) { + switch (String(value).trim().toLowerCase()) { + case "true": + case "yes": + case "1": + return true; + case "false": + case "no": + case "0": + case "": + return false; + default: + return false; + } + }; + + // parse XML string to XML + v.tools.parseXml = function(xml) { + var dom = null; + if (xml) { + if (window.DOMParser) { + try { + dom = (new DOMParser()).parseFromString(xml, "text/xml"); + } catch (e) { + dom = null; + v.tools.logError("DOMParser - unable to parse XML: " + e.message); + } + } else if (window.ActiveXObject) { + try { + dom = new ActiveXObject("Microsoft.XMLDOM"); + dom.async = false; + // parse error ... + if (!dom.loadXML(xml)) { + v.tools.logError("Microsoft.XMLDOM - unable to parse XML: " + dom.parseError.reason + + dom.parseError.srcText); + } + } catch (e) { + dom = null; + v.tools.logError("Microsoft.XMLDOM - unable to parse XML: " + e.message); + } + } + } + return dom; + }; + + // convert XML to JSON: modified version of http://davidwalsh.name/convert-xml-json + v.tools.xmlToJson = function(xml) { + var obj = null, subobj, item, subItem, nodeName, attribute; + var convertItemToJson = function(item) { + subobj = {}; + if (item.attributes.length > 0) { + for (var i = 0; i < item.attributes.length; i++) { + attribute = item.attributes.item(i); + subobj[attribute.nodeName] = attribute.nodeValue; + } + } + if (item.hasChildNodes()) { + for(var j = 0; j < item.childNodes.length; j++) { + subItem = item.childNodes.item(j); + // check, if subItem has minimum one child (hopefully a textnode) inside + if (subItem.hasChildNodes()) { subobj[subItem.nodeName] = subItem.childNodes.item(0).nodeValue; } + else { subobj[subItem.nodeName] = ""; } + } + } + return subobj; + }; + if (xml) { + obj = {}; + obj.data = {}; + obj.data.nodes = []; + obj.data.links = []; + if (xml.childNodes.item(0).hasChildNodes()) { + for(var i = 0; i < xml.childNodes.item(0).childNodes.length; i++) { + subobj = null; + item = xml.childNodes.item(0).childNodes.item(i); + nodeName = item.nodeName; + if (nodeName === "nodes" || nodeName === "node") { + obj.data.nodes.push(convertItemToJson(item)); + } + else if (nodeName === "links" || nodeName === "link") { + obj.data.links.push(convertItemToJson(item)); + } + } + } + } + return obj; + }; + + // get inner width for the SVG parents element + v.tools.getSvgParentInnerWidth = function() { + return parseInt(v.dom.svgParent.style("width")) - + parseInt(v.dom.svgParent.style("padding-left")) - + parseInt(v.dom.svgParent.style("padding-right")) - + (v.dom.svg.style("border-width") ? parseInt(v.dom.svg.style("border-width")) : 1) * 2; + }; + + // helper function to get effective graph width + v.tools.getGraphWidth = function() { + return (v.conf.useDomParentWidth ? v.dom.containerWidth : v.conf.width); + }; + + // log function for debug mode + v.tools.log = function(message, omitDebugPrefix) { + if (v.conf.debug) { + if (omitDebugPrefix) { + console.log(message); + } else { + console.log(v.status.debugPrefix + message); + } + } + if (v.status.customize && v.dom.customizeLog) { + v.dom.customizeLog.text(message + "\n" + v.dom.customizeLog.text()); + } + }; + + // log error function + v.tools.logError = function(message) { + console.log(v.status.debugPrefix + "ERROR: " + message); + if (v.status.customize && v.dom.customizeLog) { + v.dom.customizeLog.text("ERROR: " + message + "\n" + v.dom.customizeLog.text()); + } + }; + + // trigger APEX events, if we have an APEX context + v.tools.triggerApexEvent = function(domNode, event, data) { + if (v.status.apexPluginId) { + apex.event.trigger(domNode, event, data); + } + }; + + // helper function to calculate node radius from "SIZEVALUE" attribute + v.tools.setRadiusFunction = function() { + v.tools.radius = d3.scale.sqrt() + .range([v.conf.minNodeRadius, v.conf.maxNodeRadius]) + .domain(d3.extent(v.data.nodes, function(n) { + return parseFloat(n.SIZEVALUE); + })); + }; + + // helper function to calculate node fill color from COLORVALUE attribute + v.tools.setColorFunction = function() { + if (v.conf.colorScheme === "color20") { + v.tools.color = d3.scale.category20(); + } else if (v.conf.colorScheme === "color20b") { + v.tools.color = d3.scale.category20b(); + } else if (v.conf.colorScheme === "color20c") { + v.tools.color = d3.scale.category20c(); + } else if (v.conf.colorScheme === "color10") { + v.tools.color = d3.scale.category10(); + } else if (v.conf.colorScheme === "direct") { + v.tools.color = function(d) { + return d; + }; + } else { + v.conf.colorScheme = "color20"; + v.tools.color = d3.scale.category20(); + } + }; + + // check, if two nodes are neighbors + v.tools.neighboring = function(a, b) { + return (v.data.neighbors.indexOf(a.ID + ":" + b.ID) > -1 || + v.data.neighbors.indexOf(b.ID + ":" + a.ID) > -1); + }; + + // get nearest grid position + v.tools.getNearestGridPosition = function(currentPos, maxPos) { + var offset, position; + // no size limit for calculated positions, if zoomMode is set to true + if (v.conf.zoomMode) { + offset = currentPos % v.conf.gridSize; + position = (offset > v.conf.gridSize / 2 ? currentPos - offset + v.conf.gridSize : currentPos - offset); + } + // size limit for calculated positions is SVG size, if zoomMode is set to false + else { + if (currentPos >= maxPos) { + offset = maxPos % v.conf.gridSize; + position = maxPos - offset; + if (position === maxPos) { + position = position - v.conf.gridSize; + } + } else if (currentPos <= v.conf.gridSize / 2) { + position = v.conf.gridSize; + } else { + offset = currentPos % v.conf.gridSize; + position = (offset > v.conf.gridSize / 2 ? currentPos - offset + v.conf.gridSize : currentPos - offset); + if (position >= maxPos) { + position = position - v.conf.gridSize; + } + } + } + return position; + }; + + // adjust link x/y + v.tools.adjustSourceX = function(l) { + return l.source.x + Math.cos(v.tools.calcAngle(l)) * (l.source.radius); + }; + v.tools.adjustSourceY = function(l) { + return l.source.y + Math.sin(v.tools.calcAngle(l)) * (l.source.radius); + }; + v.tools.adjustTargetX = function(l) { + return l.target.x - Math.cos(v.tools.calcAngle(l)) * (l.target.radius); + }; + v.tools.adjustTargetY = function(l) { + return l.target.y - Math.sin(v.tools.calcAngle(l)) * (l.target.radius); + }; + v.tools.calcAngle = function(l) { + return Math.atan2(l.target.y - l.source.y, l.target.x - l.source.x); + }; + + // create a path for self links + v.tools.getSelfLinkPath = function(l) { + var ri = l.source.radius; + var ro = l.source.radius + v.conf.selfLinkDistance; + var x = 0; // we position the path later with transform/translate + var y = 0; + var pathStart = { + "source": { + "x": 0, + "y": 0, + "radius": ri + }, + "target": { + "x": (x + ro / 2), + "y": (y + ro), + "radius": ri + } + }; + var pathEnd = { + "source": { + "x": (x - ro / 2), + "y": (y + ro), + "radius": ri + }, + "target": { + "x": x, + "y": y, + "radius": ri + } + }; + var path = "M" + v.tools.adjustSourceX(pathStart) + "," + v.tools.adjustSourceY(pathStart); + path += " L" + (x + ro / 2) + "," + (y + ro); + path += " A" + ro + "," + ro + " 0 0,1 " + (x - ro / 2) + "," + (y + ro); + path += " L" + v.tools.adjustTargetX(pathEnd) + "," + v.tools.adjustTargetY(pathEnd); + return path; + }; + + // create a path for labels - example: d="M100,100 a20,20 0 0,1 40,0" + v.tools.getLabelPath = function(n) { + var r = n.radius + v.conf.labelDistance; + var x = 0; // we position the path later with transform/translate + var y = 0; + var path = "M" + (x - r) + "," + y; + //path += " a" + r + "," + r + " 0 0,1 " + (r * 2) + ",0"; + path += " a" + r + "," + r + " 0 0,1 " + (r * 2) + ",0"; + path += " a" + r + "," + r + " 0 0,1 -" + (r * 2) + ",0"; + return path; + }; + + // open link function + v.tools.openLink = function(node) { + var win; + if (v.conf.nodeLinkTarget === "none") { + window.location.assign(node.LINK); + } else if (v.conf.nodeLinkTarget === "nodeID") { + win = window.open(node.LINK, node.ID); + win.focus(); + } else if (v.conf.nodeLinkTarget === "domContainerID") { + win = window.open(node.LINK, v.dom.containerId); + win.focus(); + } else { + win = window.open(node.LINK, v.conf.nodeLinkTarget); + win.focus(); + } + }; + + v.tools.applyConfigurationObject = function(confObject) { + var key; + for (key in confObject) { + if (confObject.hasOwnProperty(key) && + v.conf.hasOwnProperty(key) && + confObject[key] !== v.conf[key]) { + graph[key](confObject[key]); + } + } + }; + + // http://stackoverflow.com/questions/13713528/how-to-disable-pan-for-d3-behavior-zoom + // http://stackoverflow.com/questions/11786023/how-to-disable-double-click-zoom-for-d3-behavior-zoom + // zoom event proxy + v.tools.zoomEventProxy = function(fn) { + return function() { + if ( + (!v.conf.dragMode || v.conf.dragMode && d3.event.target.tagName !== "circle") && + v.conf.zoomMode && + (!d3.event.altKey && !d3.event.shiftKey) + ) { + fn.apply(this, arguments); + } + }; + }; + // lasso event proxy + v.tools.lassoEventProxy = function(fn) { + return function() { + if ( + (!v.conf.dragMode || d3.event.target.tagName !== "circle") && + v.conf.lassoMode && + (!v.conf.zoomMode || d3.event.altKey || d3.event.shiftKey) + ) { + fn.apply(this, arguments); + } + }; + }; + + // show tooltip + v.tools.showTooltip = function(text) { + var position; + v.dom.tooltip.html(text).style("display", "block"); + if (v.conf.tooltipPosition === "svgTopLeft") { + position = v.tools.getOffsetRect(v.dom.svg.node()); + v.dom.tooltip + .style("top", position.top + + (v.dom.svg.style("border-width") ? parseInt(v.dom.svg.style("border-width")) : 1) + + "px") + .style("left", position.left + + (v.dom.svg.style("border-width") ? parseInt(v.dom.svg.style("border-width")) : 1) + + "px"); + } else if (v.conf.tooltipPosition === "svgTopRight") { + position = v.tools.getOffsetRect(v.dom.svg.node()); + v.dom.tooltip + .style("top", position.top + + parseInt((v.dom.svg.style("border-width") ? parseInt(v.dom.svg.style("border-width")) : 1)) + + "px") + .style("left", position.left + + parseInt(v.dom.svg.style("width")) + + parseInt((v.dom.svg.style("border-width") ? parseInt(v.dom.svg.style("border-width")) : 1)) - + parseInt(v.dom.tooltip.style("width")) - + 2 * parseInt( + (v.dom.tooltip.style("border-width") ? parseInt(v.dom.tooltip.style("border-width")) : 0) + ) - + parseInt(v.dom.tooltip.style("padding-left")) - + parseInt(v.dom.tooltip.style("padding-right")) + + "px"); + } else { + v.dom.tooltip + .style("left", d3.event.pageX + 10 + "px") + .style("top", d3.event.pageY + "px"); + } + }; + + // hide tooltip + v.tools.hideTooltip = function() { + v.dom.tooltip.style("display", "none"); + }; + + // on link click function + v.tools.onLinkClick = function(link) { + if (d3.event.defaultPrevented) { // ignore drag + return null; + } else { + v.tools.log("Event link_click triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_linkclick", link); + if (typeof(v.conf.onLinkClickFunction) === "function") { + v.conf.onLinkClickFunction.call(this, d3.event, link); + } + } + }; + // get marker URL + v.tools.getMarkerUrl = function(l) { + if (v.conf.showLinkDirection) { + return "url(#" + v.dom.containerId + "_" + (l.COLOR ? l.COLOR : "normal") + ")"; + } else { + return null; + } + }; + v.tools.getMarkerUrlHighlighted = function() { + if (v.conf.showLinkDirection) { + return "url(#" + v.dom.containerId + "_highlighted)"; + } else { + return null; + } + }; + + // on link mouseenter function + v.tools.onLinkMouseenter = function(link) { + if (v.conf.showTooltips && link.INFOSTRING) { + v.tools.showTooltip(link.INFOSTRING); + } + }; + + // on link mouseleave function + v.tools.onLinkMouseleave = function() { + if (v.conf.showTooltips) { + v.tools.hideTooltip(); + } + }; + + // on node mouse enter function + v.tools.onNodeMouseenter = function(node) { + v.main.nodes.classed("highlighted", function(n) { + return v.tools.neighboring(n, node); + }); + v.main.links + .classed("highlighted", function(l) { + return l.source.ID === node.ID || l.target.ID === node.ID; + }) + .style("marker-end", function(l) { + if (l.source.ID === node.ID || l.target.ID === node.ID) { + return v.tools.getMarkerUrlHighlighted(l); + } else { + return v.tools.getMarkerUrl(l); + } + }); + v.main.selfLinks + .classed("highlighted", function(l) { + return l.FROMID === node.ID; + }) + .style("marker-end", function(l) { + if (l.source.ID === node.ID || l.target.ID === node.ID) { + return v.tools.getMarkerUrlHighlighted(l); + } else { + return v.tools.getMarkerUrl(l); + } + }); + if (v.conf.showLabels) { + v.main.labels.classed("highlighted", function (l) { + return l.ID === node.ID; + }); + v.main.labelsCircular.classed("highlighted", function (l) { + return l.ID === node.ID; + }); + } + d3.select(this).classed("highlighted", true); + v.tools.log("Event node_mouseenter triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_mouseenter", node); + if (typeof(v.conf.onNodeMouseenterFunction) === "function") { + v.conf.onNodeMouseenterFunction.call(this, d3.event, node); + } + if (v.conf.showTooltips && node.INFOSTRING) { + v.tools.showTooltip(node.INFOSTRING); + } + }; + + // on node mouse leave function + v.tools.onNodeMouseleave = function(node) { + v.main.nodes.classed("highlighted", false); + v.main.links + .classed("highlighted", false) + .style("marker-end", v.tools.getMarkerUrl); + v.main.selfLinks + .classed("highlighted", false) + .style("marker-end", v.tools.getMarkerUrl); + if (v.conf.showLabels) { + v.main.labels.classed("highlighted", false); + v.main.labelsCircular.classed("highlighted", false); + } + v.tools.log("Event node_mouseleave triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_mouseleave", node); + if (typeof(v.conf.onNodeMouseleaveFunction) === "function") { + v.conf.onNodeMouseleaveFunction.call(this, d3.event, node); + } + if (v.conf.showTooltips) { + v.tools.hideTooltip(); + } + }; + + // on node click function + v.tools.onNodeClick = function(node) { + if (d3.event.defaultPrevented) { // ignore drag + return null; + } else { + if (node.LINK && v.conf.nodeEventToOpenLink === "click") { + v.tools.openLink(node); + } + if (v.conf.nodeEventToStopPinMode === "click") { + d3.select(this).classed("fixed", node.fixed = 0); + } + v.tools.log("Event node_click triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_click", node); + if (typeof(v.conf.onNodeClickFunction) === "function") { + v.conf.onNodeClickFunction.call(this, d3.event, node); + } + } + }; + + // on node double click function + v.tools.onNodeDblclick = function(node) { + if (node.LINK && v.conf.nodeEventToOpenLink === "dblclick") { + v.tools.openLink(node); + } + if (v.conf.nodeEventToStopPinMode === "dblclick") { + d3.select(this).classed("fixed", node.fixed = 0); + } + v.tools.log("Event node_dblclick triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_dblclick", node); + if (typeof(v.conf.onNodeDblclickFunction) === "function") { + v.conf.onNodeDblclickFunction.call(this, d3.event, node); + } + }; + + // on node contextmenu function + v.tools.onNodeContextmenu = function(node) { + if (v.conf.onNodeContextmenuPreventDefault) { + d3.event.preventDefault(); + } + if (node.LINK && v.conf.nodeEventToOpenLink === "contextmenu") { + v.tools.openLink(node); + } + if (v.conf.nodeEventToStopPinMode === "contextmenu") { + d3.select(this).classed("fixed", node.fixed = 0); + } + v.tools.log("Event node_contextmenu triggered."); + v.tools.triggerApexEvent(this, "net_gobrechts_d3_force_contextmenu", node); + if (typeof(v.conf.onNodeContextmenuFunction) === "function") { + v.conf.onNodeContextmenuFunction.call(this, d3.event, node); + } + }; + + // on lasso start function + v.tools.onLassoStart = function(nodes) { + var data = {}; + data.numberOfSelectedNodes = 0; + data.idsOfSelectedNodes = null; + data.numberOfNodes = nodes.size(); + data.nodes = nodes; + v.tools.log("Event lasso_start triggered."); + v.tools.triggerApexEvent(document.querySelector("#" + v.dom.containerId), + "net_gobrechts_d3_force_lassostart", + data + ); + if (typeof(v.conf.onLassoStartFunction) === "function") { + v.conf.onLassoStartFunction.call(v.dom.svg, d3.event, data); + } + }; + + // on lasso end function + v.tools.onLassoEnd = function(nodes) { + var data = {}; + data.numberOfSelectedNodes = 0; + data.idsOfSelectedNodes = ""; + data.numberOfNodes = nodes.size(); + data.nodes = nodes; + nodes.each(function(n) { + if (n.selected) { + data.idsOfSelectedNodes += (n.ID + ":"); + data.numberOfSelectedNodes++; + } + }); + data.idsOfSelectedNodes = + (data.idsOfSelectedNodes.length > 0 ? + data.idsOfSelectedNodes.substr(0, data.idsOfSelectedNodes.length - 1) : + null); + v.tools.log("Event lasso_end triggered."); + v.tools.triggerApexEvent(document.querySelector("#" + v.dom.containerId), + "net_gobrechts_d3_force_lassoend", data); + if (typeof(v.conf.onLassoEndFunction) === "function") { + v.conf.onLassoEndFunction.call(v.dom.svg, d3.event, data); + } + }; + + // get offset for an element relative to the document: http://javascript.info/tutorial/coordinates + v.tools.getOffsetRect = function(elem) { + var box = elem.getBoundingClientRect(); + var body = document.body; + var docElem = document.documentElement; + var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop; + var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft; + var clientTop = docElem.clientTop || body.clientTop || 0; + var clientLeft = docElem.clientLeft || body.clientLeft || 0; + var top = box.top + scrollTop - clientTop; + var left = box.left + scrollLeft - clientLeft; + return { + top: Math.round(top), + left: Math.round(left) + }; + }; + + // create legend + v.tools.createLegend = function() { + v.data.distinctNodeColorValues.forEach(function(colorString, i) { + var color = colorString.split(";"); + v.dom.legend + .append("circle") + .attr("cx", 11) + .attr("cy", v.conf.height - ((i + 1) * 14 - 3)) + .attr("r", 6) + .attr("fill", v.tools.color(color[1])); + v.dom.legend + .append("text") + .attr("x", 21) + .attr("y", v.conf.height - ((i + 1) * 14 - 6)) + .text((color[0] ? color[0] : color[1])); + }); + }; + + // remove legend + v.tools.removeLegend = function() { + v.dom.legend.selectAll("*").remove(); + }; + + // write conf object into customization wizard + v.tools.writeConfObjectIntoWizard = function() { + if (v.status.customize) { + v.dom.customizeConfObject.text(JSON.stringify(graph.optionsCustomizationWizard(), null, " ")); + } + }; + + // create customize link + v.tools.createCustomizeLink = function() { + if (!v.status.customize && + (v.conf.debug || document.querySelector("#apex-dev-toolbar") || document.querySelector("#apexDevToolbar")) + ) { + if (document.querySelector("#" + v.dom.containerId + " svg text.link") === null) { + v.dom.svg.append("svg:text") + .attr("class", "link") + .attr("x", 5) + .attr("y", 15) + .attr("text-anchor", "start") + .text("Customize Me") + .on("click", function() { + graph.customize(true); + }); + } + } + }; + + // remove customize link + v.tools.removeCustomizeLink = function() { + v.dom.svg.select("#" + v.dom.containerId + " svg text.link").remove(); + }; + + // dragability for customizing container + v.tools.customizeDrag = d3.behavior.drag() + .on("dragstart", function() { + var mouseToBody = d3.mouse(document.body); + v.dom.customizePosition = v.tools.getOffsetRect(document.querySelector("#" + v.dom.containerId + + "_customizing")); + v.dom.customizePosition.mouseLeft = mouseToBody[0] - v.dom.customizePosition.left; + v.dom.customizePosition.mouseTop = mouseToBody[1] - v.dom.customizePosition.top; + }) + .on("drag", function() { + var mouseToBody = d3.mouse(document.body); + v.dom.customize + .style("left", Math.max(0, + mouseToBody[0] - v.dom.customizePosition.mouseLeft) + "px") + .style("top", Math.max(0, + mouseToBody[1] - v.dom.customizePosition.mouseTop) + "px"); + }) + .on("dragend", function() { + //v.dom.customizePosition = v.tools.getOffsetRect(document.querySelector("#" + v.dom.containerId + + //"_customizing")); + v.dom.customizePosition = v.tools.getOffsetRect(v.dom.customize.node()); + }); + + // create customize wizard, if graph not rendering + v.tools.createCustomizeWizardIfNotRendering = function() { + if (v.status.customize && !v.status.graphRendering) { + v.tools.createCustomizeWizard(); + } + }; + + // customize wizard + v.tools.createCustomizeWizard = function() { + /* jshint -W074, -W071 */ + var grid, gridRow, gridCell, row, td, form, i = 4, + currentOption, valueInOptions, key; + var releaseFixedNodesAndResume = function() { + graph.releaseFixedNodes().resume(); + }; + var onSelectChange = function() { + v.status.customizeCurrentTabPosition = this.id; + if (v.confDefaults[this.name].type === "text") { + graph[this.name](this.options[this.selectedIndex].value).render(); + } else if (v.confDefaults[this.name].type === "number") { + graph[this.name](parseFloat(this.options[this.selectedIndex].value)).render(); + } else if (v.confDefaults[this.name].type === "bool") { + graph[this.name]((this.options[this.selectedIndex].value === "true")).render(); + } + }; + var appendOptionsToSelect = function(key) { + v.confDefaults[key].options.forEach(function(option) { + currentOption = option; + form.append("option") + .attr("value", option) + .attr("selected", function() { + if (v.confDefaults[key].type === "text" || v.confDefaults[key].type === "bool") { + if (currentOption === v.conf[key]) { + valueInOptions = true; + return "selected"; + } else { + return null; + } + } else if (v.confDefaults[key].type === "number") { + if (parseFloat(currentOption) === v.conf[key]) { + valueInOptions = true; + return "selected"; + } else { + return null; + } + } + }) + .text(option); + }); + }; + // render customization wizard only if we have the right status, otherwise remove the wizard + if (!v.status.customize) { + v.tools.removeCustomizeWizard(); + v.tools.createCustomizeLink(); + } else { + v.tools.removeCustomizeLink(); + // set initial position + if (!v.dom.customizePosition) { + v.dom.customizePosition = v.tools.getOffsetRect(v.dom.svg.node()); + v.dom.customizePosition.left = v.dom.customizePosition.left + v.conf.width + 8; + } + if (document.querySelector("#" + v.dom.containerId + "_customizing") !== null) { + v.dom.customize.remove(); + } + v.dom.customize = v.dom.body.insert("div") + .attr("id", v.dom.containerId + "_customizing") + .attr("class", "net_gobrechts_d3_force_customize") + .style("left", v.dom.customizePosition.left + "px") + .style("top", v.dom.customizePosition.top + "px"); + v.dom.customize.append("span") + .attr("class", "drag") + .call(v.tools.customizeDrag) + .append("span") + .attr("class", "title") + .text("Customize \"" + v.dom.containerId + "\""); + v.dom.customize.append("a") + .attr("class", "close focus") + .attr("tabindex", 1) + .text("Close") + .on("click", function() { + v.status.customize = false; + v.tools.removeCustomizeWizard(); + v.tools.createCustomizeLink(); + }) + .on("keydown", function() { + if (d3.event.keyCode === 13) { + v.status.customize = false; + v.tools.removeCustomizeWizard(); + v.tools.createCustomizeLink(); + } + }); + grid = v.dom.customize.append("table"); + gridRow = grid.append("tr"); + gridCell = gridRow.append("td").style("vertical-align", "top"); + v.dom.customizeMenu = gridCell.append("span"); + v.dom.customizeOptionsTable = gridCell.append("table"); + for (key in v.confDefaults) { + if (v.confDefaults.hasOwnProperty(key) && v.confDefaults[key].display) { + i += 1; + row = v.dom.customizeOptionsTable.append("tr") + .attr("class", v.confDefaults[key].relation + "-related"); + row.append("td") + .attr("class", "label") + .html("" + + key + ""); + td = row.append("td"); + form = td.append("select") + .attr("id", v.dom.containerId + "_" + key) + .attr("name", key) + .attr("value", v.conf[key]) + .attr("tabindex", i + 1) + .classed("warning", v.confDefaults[key].internal) + .on("change", onSelectChange); + valueInOptions = false; + appendOptionsToSelect(key); + // append current value if not existing in default options + if (!valueInOptions) { + form.append("option") + .attr("value", v.conf[key]) + .attr("selected", "selected") + .text(v.conf[key]); + v.confDefaults[key].options.push(v.conf[key]); + } + // add short link to release all fixed (pinned) nodes + if (key === "pinMode") { + td.append("a") + .text("release all") + .attr("href", null) + .on("click", releaseFixedNodesAndResume); + } + } + } + v.dom.customizeOptionsTable.style("width", d3.select(v.dom.customizeOptionsTable).node()[0][0].clientWidth + + "px"); + gridCell.append("span").html("
"); + gridCell = gridRow.append("td") + .style("vertical-align", "top") + .style("padding-left", "5px"); + gridCell.append("span") + .html("Your Configuration Object

" + + (v.status.apexPluginId ? + "To save your options please copy
this to your plugin region attributes.
" + + "Only non-default options are shown.

" : + "Use this to initialize your graph.
Only non-default options are shown.

") + ); + v.dom.customizeConfObject = gridCell.append("textarea") + .attr("tabindex", i + 5) + .attr("readonly", "readonly"); + gridCell.append("span").html("

Current Positions
"); + v.dom.customizePositions = gridCell.append("textarea") + .attr("tabindex", i + 6) + .attr("readonly", "readonly") + .text((v.status.forceRunning ? "Force started - wait for end event to show positions..." : + JSON.stringify(graph.positions()))); + gridCell.append("span").html("

Debug Log (descending)
"); + v.dom.customizeLog = gridCell.append("textarea") + .attr("tabindex", i + 7) + .attr("readonly", "readonly"); + gridRow = grid.append("tr"); + gridCell = gridRow.append("td") + .attr("colspan", 2) + .html("Copyrights:"); + gridRow = grid.append("tr"); + gridCell = gridRow.append("td") + .attr("colspan", 2) + .html("
" + + "D3 Force APEX Plugin (" + v.version + + ")
Ottmar Gobrecht
" + + "D3.js (" + d3.version + ") and " + + "D3 Lasso Plugin (modified)
Mike Bostock" + + "
" + + "D3 Labeler Plugin (automatic label placement using simulated annealing)" + + "
Evan Wang
"); // https://github.com/tinker10/D3-Labeler + v.tools.createCustomizeMenu(v.status.customizeCurrentMenu); + v.tools.writeConfObjectIntoWizard(); + if (v.status.customizeCurrentTabPosition) { + document.getElementById(v.status.customizeCurrentTabPosition).focus(); + } + } + }; + + v.tools.removeCustomizeWizard = function() { + d3.select("#" + v.dom.containerId + "_customizing").remove(); + }; + + v.tools.createCustomizeMenu = function(relation) { + v.status.customizeCurrentMenu = relation; + v.dom.customizeMenu.selectAll("*").remove(); + v.dom.customizeMenu.append("span").text("Show options for:"); + if (v.status.customizeCurrentMenu === "nodes") { + v.dom.customizeMenu.append("span").style("font-weight", "bold").style("margin-left", "10px").text("NODES"); + v.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.link-related,tr.graph-related").classed("hidden", true); + } else { + v.dom.customizeMenu.append("a") + .style("font-weight", "bold") + .style("margin-left", "10px") + .text("NODES") + .attr("tabindex", 2) + .on("click", function() { + v.tools.createCustomizeMenu("nodes"); + v.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.link-related,tr.graph-related").classed("hidden", true); + }) + .on("keydown", function() { + if (d3.event.keyCode === 13) { + v.tools.createCustomizeMenu("nodes"); + v.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.link-related,tr.graph-related") + .classed("hidden", true); + } + }); + } + if (v.status.customizeCurrentMenu === "links") { + v.dom.customizeMenu.append("span").style("font-weight", "bold").style("margin-left", "10px").text("LINKS"); + v.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.graph-related").classed("hidden", true); + } else { + v.dom.customizeMenu.append("a") + .style("font-weight", "bold") + .style("margin-left", "10px") + .text("LINKS") + .attr("tabindex", 3) + .on("click", function() { + v.tools.createCustomizeMenu("links"); + v.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.graph-related").classed("hidden", true); + }) + .on("keydown", function() { + if (d3.event.keyCode === 13) { + v.tools.createCustomizeMenu("links"); + v.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.graph-related") + .classed("hidden", true); + } + }); + } + if (v.status.customizeCurrentMenu === "graph") { + v.dom.customizeMenu.append("span").style("font-weight", "bold").style("margin-left", "10px").text("GRAPH"); + v.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related").classed("hidden", true); + } else { + v.dom.customizeMenu.append("a") + .style("font-weight", "bold") + .style("margin-left", "10px") + .text("GRAPH") + .attr("tabindex", 4) + .on("click", function() { + v.tools.createCustomizeMenu("graph"); + v.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related").classed("hidden", true); + }) + .on("keydown", function() { + if (d3.event.keyCode === 13) { + v.tools.createCustomizeMenu("graph"); + v.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden", false); + v.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related") + .classed("hidden", true); + } + }); + } + v.dom.customizeMenu.append("span").html("

"); + }; + + /******************************************************************************************************************* + * LIBRARIES + */ + + // D3 labeler plugin + /* Source Code: https://github.com/tinker10/D3-Labeler + The MIT License (MIT) + + Copyright (c) 2013 Evan Wang + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ + v.lib.labelerPlugin = function() { + /* jshint -W106 */ + var lab = [], + anc = [], + w = 1, // box width + h = 1, // box width + labeler = {}; + + var max_move = 5, //5.0, + max_angle = 0.5, //0.5, + acc = 0, + rej = 0; + + // weights + var w_len = 0.2, // leader line length + w_inter = 1.0, // leader line intersection + w_lab2 = 30.0, // label-label overlap + w_lab_anc = 30.0, // label-anchor overlap + w_orient = 1.0; //3.0; // orientation bias + + // booleans for user defined functions + var user_energy = false, + user_schedule = false; + + var user_defined_energy, + user_defined_schedule; + + var energy = function(index) { + /* jshint -W071 */ + // energy function, tailored for label placement + + var m = lab.length, + ener = 0, + dx = lab[index].x - anc[index].x, + dy = anc[index].y - lab[index].y, + dist = Math.sqrt(dx * dx + dy * dy), + overlap = true; + + // penalty for length of leader line + if (dist > 0) { + ener += dist * w_len; + } + + // label orientation bias + dx /= dist; + dy /= dist; + if (dx > 0 && dy > 0) { + ener += 0; + } else if (dx < 0 && dy > 0) { + ener += w_orient; + } else if (dx < 0 && dy < 0) { + ener += 2 * w_orient; + } else { + ener += 3 * w_orient; + } + + var x21 = lab[index].x, + y21 = lab[index].y - lab[index].height + 2.0, + x22 = lab[index].x + lab[index].width, + y22 = lab[index].y + 2.0; + var x11, x12, y11, y12, x_overlap, y_overlap, overlap_area; + + for (var i = 0; i < m; i++) { + if (i !== index) { + + // penalty for intersection of leader lines + overlap = intersect(anc[index].x, lab[index].x, anc[i].x, lab[i].x, + anc[index].y, lab[index].y, anc[i].y, lab[i].y); + if (overlap) { + ener += w_inter; + } + + // penalty for label-label overlap + x11 = lab[i].x; + y11 = lab[i].y - lab[i].height + 2.0; + x12 = lab[i].x + lab[i].width; + y12 = lab[i].y + 2.0; + x_overlap = Math.max(0, Math.min(x12, x22) - Math.max(x11, x21)); + y_overlap = Math.max(0, Math.min(y12, y22) - Math.max(y11, y21)); + overlap_area = x_overlap * y_overlap; + ener += (overlap_area * w_lab2); + } + + // penalty for label-anchor overlap + x11 = anc[i].x - anc[i].r; + y11 = anc[i].y - anc[i].r; + x12 = anc[i].x + anc[i].r; + y12 = anc[i].y + anc[i].r; + x_overlap = Math.max(0, Math.min(x12, x22) - Math.max(x11, x21)); + y_overlap = Math.max(0, Math.min(y12, y22) - Math.max(y11, y21)); + overlap_area = x_overlap * y_overlap; + ener += (overlap_area * w_lab_anc); + + } + return ener; + }; + + var mcmove = function(currT) { + // Monte Carlo translation move + + // select a random label + var i = Math.floor(Math.random() * lab.length); + + // save old coordinates + var x_old = lab[i].x; + var y_old = lab[i].y; + + // old energy + var old_energy; + if (user_energy) { + old_energy = user_defined_energy(i, lab, anc); + } else { + old_energy = energy(i); + } + + // random translation + lab[i].x += (Math.random() - 0.5) * max_move; + lab[i].y += (Math.random() - 0.5) * max_move; + + // hard wall boundaries + if (lab[i].x > w) { + lab[i].x = x_old; + } + if (lab[i].x < 0) { + lab[i].x = x_old; + } + if (lab[i].y > h) { + lab[i].y = y_old; + } + if (lab[i].y < 0) { + lab[i].y = y_old; + } + + // new energy + var new_energy; + if (user_energy) { + new_energy = user_defined_energy(i, lab, anc); + } else { + new_energy = energy(i); + } + + // delta E + var delta_energy = new_energy - old_energy; + + if (Math.random() < Math.exp(-delta_energy / currT)) { + acc += 1; + } else { + // move back to old coordinates + lab[i].x = x_old; + lab[i].y = y_old; + rej += 1; + } + + }; + + var mcrotate = function(currT) { + /* jshint -W071 */ + // Monte Carlo rotation move + + // select a random label + var i = Math.floor(Math.random() * lab.length); + + // save old coordinates + var x_old = lab[i].x; + var y_old = lab[i].y; + + // old energy + var old_energy; + if (user_energy) { + old_energy = user_defined_energy(i, lab, anc); + } else { + old_energy = energy(i); + } + + // random angle + var angle = (Math.random() - 0.5) * max_angle; + + var s = Math.sin(angle); + var c = Math.cos(angle); + + // translate label (relative to anchor at origin): + lab[i].x -= anc[i].x; + lab[i].y -= anc[i].y; + + // rotate label + var x_new = lab[i].x * c - lab[i].y * s, + y_new = lab[i].x * s + lab[i].y * c; + + // translate label back + lab[i].x = x_new + anc[i].x; + lab[i].y = y_new + anc[i].y; + + // hard wall boundaries + if (lab[i].x > w) { + lab[i].x = x_old; + } + if (lab[i].x < 0) { + lab[i].x = x_old; + } + if (lab[i].y > h) { + lab[i].y = y_old; + } + if (lab[i].y < 0) { + lab[i].y = y_old; + } + + // new energy + var new_energy; + if (user_energy) { + new_energy = user_defined_energy(i, lab, anc); + } else { + new_energy = energy(i); + } + + // delta E + var delta_energy = new_energy - old_energy; + + if (Math.random() < Math.exp(-delta_energy / currT)) { + acc += 1; + } else { + // move back to old coordinates + lab[i].x = x_old; + lab[i].y = y_old; + rej += 1; + } + + }; + + var intersect = function(x1, x2, x3, x4, y1, y2, y3, y4) { + // returns true if two lines intersect, else false + // from http://paulbourke.net/geometry/lineline2d/ + + var mua, mub; + var denom, numera, numerb; + + denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + numera = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + numerb = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + + /* Is the intersection along the the segments */ + mua = numera / denom; + mub = numerb / denom; + return !(mua < 0 || mua > 1 || mub < 0 || mub > 1); + + }; + + var cooling_schedule = function(currT, initialT, nsweeps) { + // linear cooling + return (currT - (initialT / nsweeps)); + }; + + labeler.start = function(nsweeps) { + // main simulated annealing function + var m = lab.length, + currT = 1.0, + initialT = 1.0; + + for (var i = 0; i < nsweeps; i++) { + for (var j = 0; j < m; j++) { + if (Math.random() < 0.5) { + mcmove(currT); + } else { + mcrotate(currT); + } + } + currT = cooling_schedule(currT, initialT, nsweeps); + } + }; + + labeler.width = function(x) { + // users insert graph width + if (!arguments.length) { + return w; + } + w = x; + return labeler; + }; + + labeler.height = function(x) { + // users insert graph height + if (!arguments.length) { + return h; + } + h = x; + return labeler; + }; + + labeler.label = function(x) { + // users insert label positions + if (!arguments.length) { + return lab; + } + lab = x; + return labeler; + }; + + labeler.anchor = function(x) { + // users insert anchor positions + if (!arguments.length) { + return anc; + } + anc = x; + return labeler; + }; + + labeler.alt_energy = function(x) { + // user defined energy + if (!arguments.length) { + return energy; + } + user_defined_energy = x; + user_energy = true; + return labeler; + }; + + labeler.alt_schedule = function(x) { + // user defined cooling_schedule + if (!arguments.length) { + return cooling_schedule; + } + user_defined_schedule = x; + user_schedule = true; + return labeler; + }; + + return labeler; + }; + + // D3 lasso plugin + /* Source Code: https://github.com/d3/d3-plugins/blob/master/lasso/lasso.js + Copyright (c) 2012-2014, Michael Bostock + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name Michael Bostock may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + v.lib.lassoPlugin = function() { + /* jshint -W040, -W106 */ + var items = null, + closePathDistance = 75, + closePathSelect = true, + isPathClosed = false, + hoverSelect = true, + area = null, + pathContainer = null, + on = { + start: function() {}, + draw: function() {}, + end: function() {} + }; + + function lasso() { + var _this = d3.select(this[0][0]); + /* START MODIFICATION ------------------------------------------------------> + * Reuse lasso path group element, if possible. In my D3 force implementation + * I provide the possibility to enable or disable the lasso. After enabling + * the lasso I get always a new lasso element. I prefer to reuse the existing + * one. + * */ + // + var g, dyn_path, close_path, complete_path, path, origin, last_known_point, path_length_start, drag; + pathContainer = pathContainer || _this; // if not set then defaults to _this + if (pathContainer.selectAll("g.lasso").size() === 0) { + g = pathContainer.append("g").attr("class", "lasso"); + dyn_path = g.append("path").attr("class", "drawn"); + close_path = g.append("path").attr("class", "loop_close"); + complete_path = g.append("path").attr("class", "complete_path").attr("display", "none"); + } else { + g = pathContainer.select("g.lasso"); + dyn_path = g.select("path.drawn"); + close_path = g.select("path.loop_close"); + complete_path = g.select("path.complete_path"); + } + /* <-------------------------------------------------------- END MODIFICATION */ + + function dragstart() { + // Reset blank lasso path + path = ""; + dyn_path.attr("d", null); + close_path.attr("d", null); + // Set path length start + path_length_start = 0; + // Set every item to have a false selection and reset their center point and counters + items[0].forEach(function(d) { + d.hoverSelected = false; + d.loopSelected = false; + var cur_box = d.getBBox(); + /* START MODIFICATION ------------------------------------------------------> + * Implement correct values after zoom and pan based on the following article: + * http://stackoverflow.com/questions/18554224/getting-screen-positions-of-d3-nodes-after-transform + * */ + var ctm = d.getCTM(); + d.lassoPoint = { + cx: Math.round((cur_box.x + cur_box.width / 2) * ctm.a + ctm.e), + cy: Math.round((cur_box.y + cur_box.height / 2) * ctm.d + ctm.f), + /* <-------------------------------------------------------- END MODIFICATION */ + edges: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + close_edges: { + left: 0, + right: 0 + } + }; + }); + + // if hover is on, add hover function + if (hoverSelect === true) { + items.on("mouseover.lasso", function() { + // if hovered, change lasso selection attribute to true + d3.select(this)[0][0].hoverSelected = true; + }); + } + + // Run user defined start function + on.start(); + } + + function dragmove() { + /* jshint -W071 */ + var x = d3.mouse(this)[0], + y = d3.mouse(this)[1], + distance, + close_draw_path, + complete_path_d, + close_path_node, + close_path_length, + close_path_edges, + path_node, + path_length_end, + i, + last_pos, + prior_pos, + prior_pos_obj, + cur_pos, + cur_pos_obj, + calcLassoPointEdges = function(d) { + if (cur_pos_obj.x > d.lassoPoint.cx) { + d.lassoPoint.edges.right = d.lassoPoint.edges.right + 1; + } + if (cur_pos_obj.x < d.lassoPoint.cx) { + d.lassoPoint.edges.left = d.lassoPoint.edges.left + 1; + } + }, + calcLassoPointCloseEdges = function(d) { + if (Math.round(cur_pos.y) !== Math.round(prior_pos.y) && + Math.round(cur_pos.x) > d.lassoPoint.cx) { + d.lassoPoint.close_edges.right = 1; + } + if (Math.round(cur_pos.y) !== Math.round(prior_pos.y) && + Math.round(cur_pos.x) < d.lassoPoint.cx) { + d.lassoPoint.close_edges.left = 1; + } + }, + ckeckIfNodeYequalsCurrentPosY = function(d) { + return d.lassoPoint.cy === Math.round(cur_pos.y); + }, + ckeckIfNodeYequalsCurrentPriorPosY = function(d) { + var a; + if (d.lassoPoint.cy === cur_pos_obj.y && d.lassoPoint.cy !== prior_pos_obj.y) { + last_known_point = { + x: prior_pos_obj.x, + y: prior_pos_obj.y + }; + a = false; + } else if (d.lassoPoint.cy === cur_pos_obj.y && d.lassoPoint.cy === prior_pos_obj.y) { + a = false; + } else if (d.lassoPoint.cy === prior_pos_obj.y && d.lassoPoint.cy !== cur_pos_obj.y) { + a = sign(d.lassoPoint.cy - cur_pos_obj.y) !== sign(d.lassoPoint.cy - last_known_point.y); + } else { + last_known_point = { + x: prior_pos_obj.x, + y: prior_pos_obj.y + }; + a = sign(d.lassoPoint.cy - cur_pos_obj.y) !== sign(d.lassoPoint.cy - prior_pos_obj.y); + } + return a; + }; + + // Initialize the path or add the latest point to it + if (path === "") { + path = path + "M " + x + " " + y; + origin = [x, y]; + } else { + path = path + " L " + x + " " + y; + } + + // Reset closed edges counter + items[0].forEach(function(d) { + d.lassoPoint.close_edges = { + left: 0, + right: 0 + }; + }); + + // Calculate the current distance from the lasso origin + distance = Math.sqrt(Math.pow(x - origin[0], 2) + Math.pow(y - origin[1], 2)); + + // Set the closed path line + close_draw_path = "M " + x + " " + y + " L " + origin[0] + " " + origin[1]; + + // Draw the lines + dyn_path.attr("d", path); + + // If within the closed path distance parameter, show the closed path. otherwise, hide it + if (distance <= closePathDistance) { + close_path.attr("display", null); + } else { + close_path.attr("display", "none"); + } + + isPathClosed = distance <= closePathDistance; + + // create complete path + complete_path_d = d3.select("path")[0][0].attributes.d.value + "Z"; + complete_path.attr("d", complete_path_d); + + // get path length + path_node = dyn_path.node(); + path_length_end = path_node.getTotalLength(); + last_pos = path_node.getPointAtLength(path_length_start - 1); + + for (i = path_length_start; i <= path_length_end; i++) { + cur_pos = path_node.getPointAtLength(i); + cur_pos_obj = { + x: Math.round(cur_pos.x * 100) / 100, + y: Math.round(cur_pos.y * 100) / 100 + }; + prior_pos = path_node.getPointAtLength(i - 1); + prior_pos_obj = { + x: Math.round(prior_pos.x * 100) / 100, + y: Math.round(prior_pos.y * 100) / 100 + }; + + items[0].filter(ckeckIfNodeYequalsCurrentPriorPosY).forEach(calcLassoPointEdges); + } + + if (isPathClosed === true && closePathSelect === true) { + close_path.attr("d", close_draw_path); + close_path_node = close_path.node(); + close_path_length = close_path_node.getTotalLength(); + close_path_edges = { + left: 0, + right: 0 + }; + for (i = 0; i <= close_path_length; i++) { + cur_pos = close_path_node.getPointAtLength(i); + prior_pos = close_path_node.getPointAtLength(i - 1); + items[0].filter(ckeckIfNodeYequalsCurrentPosY).forEach(calcLassoPointCloseEdges); + } + items[0].forEach(function(a) { + if ((a.lassoPoint.edges.left + a.lassoPoint.close_edges.left) > 0 && + (a.lassoPoint.edges.right + a.lassoPoint.close_edges.right) % 2 === 1) { + a.loopSelected = true; + } else { + a.loopSelected = false; + } + }); + } else { + items[0].forEach(function(d) { + d.loopSelected = false; + }); + } + + // Tag possible items + d3.selectAll(items[0].filter(function(d) { + return (d.loopSelected && isPathClosed) || d.hoverSelected; + })) + .attr("d", function(d) { + d.possible = true; + return d.possible; + }); + + d3.selectAll(items[0].filter(function(d) { + return !((d.loopSelected && isPathClosed) || d.hoverSelected); + })) + .attr("d", function(d) { + d.possible = false; + return d.possible; + }); + + on.draw(); + + // Continue drawing path from where it left off + path_length_start = path_length_end + 1; + } + + function dragend() { + // Remove mouseover tagging function + items.on("mouseover.lasso", null); + + // Tag selected items + items.filter(function(d) { + return d.possible === true; + }) + .attr("d", function(d) { + d.selected = true; + return d.selected; + }); + + items.filter(function(d) { + return d.possible === false; + }) + .attr("d", function(d) { + d.selected = false; + return d.selected; + }); + + // Reset possible items + items.attr("d", function(d) { + d.possible = false; + return d.possible; + }); + + // Clear lasso + dyn_path.attr("d", null); + close_path.attr("d", null); + + // Run user defined end function + on.end(); + + } + drag = d3.behavior.drag() + .on("dragstart", dragstart) + .on("drag", dragmove) + .on("dragend", dragend); + area.call(drag); + } + + lasso.items = function(_) { + + if (!arguments.length) { + return items; + } + items = _; + items[0].forEach(function(d) { + var item = d3.select(d); + if (typeof item.datum() === "undefined") { + item.datum({ + possible: false, + selected: false + }); + } else { + item.attr("d", function(e) { + e.possible = false; + e.selected = false; + return e; + }); + } + }); + return lasso; + }; + + lasso.closePathDistance = function(_) { + if (!arguments.length) { + return closePathDistance; + } + closePathDistance = _; + return lasso; + }; + + lasso.closePathSelect = function(_) { + if (!arguments.length) { + return closePathSelect; + } + closePathSelect = _ === true; + return lasso; + }; + + lasso.isPathClosed = function(_) { + if (!arguments.length) { + return isPathClosed; + } + isPathClosed = _ === true; + return lasso; + }; + + lasso.hoverSelect = function(_) { + if (!arguments.length) { + return hoverSelect; + } + hoverSelect = _ === true; + return lasso; + }; + + lasso.on = function(type, _) { + if (!arguments.length) { + return on; + } + if (arguments.length === 1) { + return on[type]; + } + var types = ["start", "draw", "end"]; + if (types.indexOf(type) > -1) { + on[type] = _; + } + return lasso; + }; + + lasso.area = function(_) { + if (!arguments.length) { + return area; + } + area = _; + return lasso; + }; + + /* START MODIFICATION ------------------------------------------------------> + * Allow different container for lasso path than area, where lasso can be started + * */ + lasso.pathContainer = function(_) { + if (!arguments.length) { + return pathContainer; + } + pathContainer = d3.select(_[0][0]); + return lasso; + }; + /* <-------------------------------------------------------- END MODIFICATION */ + + function sign(x) { + return x ? x < 0 ? -1 : 1 : 0; + } + + return lasso; + }; + + + /******************************************************************************************************************* + * MAIN + */ + + v.main.init(); + + + /******************************************************************************************************************* + * PUBLIC GRAPH FUNCTION AND API METHODS + */ + + function graph() {} + + // public start function: get data and start visualization + graph.start = function(pData) { + var firstChar; + // try to use the input data - this means also, we can overwrite the data from APEX with raw data (textarea or + // whatever you like...) + if (pData) { + graph.render(pData); + } + // if we have no data, then we try to use the APEX context (if APEX plugin ID is set) + else if (v.status.apexPluginId) { + if (v.conf.showLoadingIndicatorOnAjaxCall) { + graph.showLoadingIndicator(true); + } + apex.server.plugin( + v.status.apexPluginId, { + p_debug: $v("pdebug"), //jshint ignore:line + pageItems: v.status.apexPageItemsToSubmit + }, { + success: function(dataString) { + // dataString starts NOT with "<" or "{", when there are no queries defined in APEX or + // when the queries returns empty data or when a error occurs on the APEX backend side + if (v.conf.showLoadingIndicatorOnAjaxCall) { + graph.showLoadingIndicator(false); + } + firstChar = dataString.trim().substr(0, 1); + if (firstChar === "<" || firstChar === "{") { + graph.render(dataString); + } else if (dataString.trim().substr(0, 16) === "no_query_defined") { + // this will keep the old data or using the sample data, if no old data existing + graph.render(); + v.tools.logError("No query defined."); + } else if (dataString.trim().substr(0, 22) === "query_returned_no_data") { + graph.render({ + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: No data.", + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }); + v.tools.logError("Query returned no data."); + } else { + graph.render({ + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + dataString + ".", + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }); + v.tools.logError(dataString); + } + }, + error: function(xhr, status, errorThrown) { + graph.render({ + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "AJAX call terminated with errors.", + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }); + v.tools.logError("AJAX call terminated with errors: " + errorThrown + "."); + }, + dataType: "text" + } + ); + } + // if we have no raw data and no APEX context, then we start to render without data (the render function will + // then provide sample data) + else { + graph.render(); + } + return graph; + }; + + graph.render = function(pData) { + /* jshint -W074, -W071 */ + var message; + v.status.graphStarted = true; + v.status.graphRendering = true; + + v.tools.triggerApexEvent(document.querySelector("#" + v.dom.containerId), "apexbeforerefresh"); + + // if we start the rendering the first time and there is no input data, then provide sample data + if (!pData && !v.status.graphReady) { + v.tools.logError("Houston, we have a problem - we have to provide sample data."); + v.status.sampleData = true; + pData = v.data.sampleData; + } else if (pData) { + v.status.sampleData = false; + } + + // if we have incoming data, than we do our transformations here, otherwise we use the existing data + if (pData) { + + if (v.status.graphReady) { + v.status.graphOldPositions = graph.positions(); + } + + // data is an object + if (pData.constructor === Object) { + v.data.dataConverted = pData; + if (v.conf.debug) { + v.tools.log("Data object:"); + v.tools.log(v.data.dataConverted, true); + } + } + // data is a string + else if (pData.constructor === String) { + // convert incoming data depending on type + if (pData.trim().substr(0, 1) === "<") { + try { + v.data.dataConverted = v.tools.xmlToJson(v.tools.parseXml(pData)); + if (v.data.dataConverted === null) { + message = "Unable to convert XML string."; + v.tools.logError(message); + v.data.dataConverted = { + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }; + } + } catch (e) { + message = "Unable to convert XML string: " + e.message + "."; + v.tools.logError(message); + v.data.dataConverted = { + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }; + } + } else if (pData.trim().substr(0, 1) === "{") { + try { + v.data.dataConverted = JSON.parse(pData); + } catch (e) { + message = "Unable to parse JSON string: " + e.message + "."; + v.tools.logError(message); + v.data.dataConverted = { + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }; + } + } else { + message = "Your data string is not starting with \"<\" or \"{\" - parsing not possible."; + v.tools.logError(message); + v.data.dataConverted = { + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }; + } + if (v.conf.debug) { + v.tools.log("Data string:"); + v.tools.log(pData, true); + v.tools.log("Converted data object:"); + v.tools.log(v.data.dataConverted, true); + } + } + // data has unknown format + else { + message = "Unable to parse your data - input data can be a XML string, " + + "JSON string or JavaScript object."; + v.tools.logError(message); + v.data.dataConverted = { + "data": { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + } + }; + } + + // create references to our new data + if (v.data.dataConverted !== null) { + if (v.data.dataConverted.hasOwnProperty("data") && v.data.dataConverted.data !== null) { + if (v.data.dataConverted.data.hasOwnProperty("nodes") && v.data.dataConverted.data.nodes !== null) { + v.data.nodes = v.data.dataConverted.data.nodes; + if (v.data.nodes.length === 0) { + message = "Your data contains an empty nodes array."; + v.tools.logError(message); + v.data.nodes = [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }]; + } + } else { + message = "Your data contains no nodes."; + v.tools.logError(message); + v.data.nodes = [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }]; + } + if (v.data.dataConverted.data.hasOwnProperty("links") && v.data.dataConverted.data.links !== null) { + v.data.links = v.data.dataConverted.data.links; + } else { + v.data.links = []; + } + } else { + message = "Missing root element named data."; + v.tools.logError(message); + v.data = { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + }; + } + } else { + message = "Unable to parse your data - please consult the API reference for possible data formats."; + v.tools.logError(message); + v.data = { + "nodes": [{ + "ID": "1", + "LABEL": "ERROR: " + message, + "COLORVALUE": "1", + "SIZEVALUE": "1" + }], + "links": [] + }; + } + + // switch links to point to node objects instead of id's (needed for force layout) and calculate attributes + v.data.idLookup = []; // helper array to lookup node objects by id's + v.data.nodes.forEach(function(n) { + n.SIZEVALUE = parseFloat(n.SIZEVALUE); // convert size to float value + n.LABELCIRCULAR = v.tools.parseBool(n.LABELCIRCULAR); // convert labelCircular to boolean + if (n.fixed) { + n.fixed = v.tools.parseBool(n.fixed); + } // convert fixed to boolean + if (n.x) { + n.x = parseFloat(n.x); + } // convert X position to float value + if (n.y) { + n.y = parseFloat(n.y); + } // convert Y position to float value + v.data.idLookup[n.ID] = n; // add object reference to lookup array + }); + v.data.links.forEach(function(l) { + l.source = v.data.idLookup[l.FROMID]; // add attribute source as a node reference to the link + l.target = v.data.idLookup[l.TOID]; // add attribute target as a node reference to the link + }); + + // sort out links with invalid node references + v.data.links = v.data.links.filter(function(l) { + return typeof l.source !== "undefined" && typeof l.target !== "undefined"; + }); + + // create helper array to lookup if nodes are neighbors + v.data.neighbors = v.data.links.map(function(l) { + return l.FROMID + ":" + l.TOID; + }); + + // calculate distinct node colors for the legend + v.data.distinctNodeColorValues = v.data.nodes + .map(function(n) { + return (n.COLORLABEL ? n.COLORLABEL : "") + ";" + n.COLORVALUE; + }) + // http://stackoverflow.com/questions/1960473/unique-values-in-an-array + .filter(function(value, index, self) { + return self.indexOf(value) === index; + }) + .sort(function(a, b) { // http://www.sitepoint.com/sophisticated-sorting-in-javascript/ + var x = a.toLowerCase(), + y = b.toLowerCase(); + return x < y ? 1 : x > y ? -1 : 0; + }); + + // calculate distinct link colors for the markers + v.data.distinctLinkColorValues = v.data.links + .map(function(l) { + return l.COLOR; + }) + // http://stackoverflow.com/questions/28607451/removing-undefined-values-from-array + // http://stackoverflow.com/questions/1960473/unique-values-in-an-array + .filter(Boolean) + .filter(function(value, index, self) { + return self.indexOf(value) === index; + }) + .sort(function(a, b) { // http://www.sitepoint.com/sophisticated-sorting-in-javascript/ + var x = a.toLowerCase(), + y = b.toLowerCase(); + return x < y ? 1 : x > y ? -1 : 0; + }); + + // apply user provided positions once (new data has priority) + if (v.conf.positions) { + if (v.conf.positions.constructor === Array) { + v.conf.positions.forEach(function(n) { + if (v.data.idLookup[n.ID] !== undefined) { + if (!v.data.idLookup[n.ID].fixed) { + v.data.idLookup[n.ID].fixed = n.fixed; + } + if (!v.data.idLookup[n.ID].x) { + v.data.idLookup[n.ID].x = v.data.idLookup[n.ID].px = n.x; + } + if (!v.data.idLookup[n.ID].y) { + v.data.idLookup[n.ID].y = v.data.idLookup[n.ID].py = n.y; + } + } + }); + } else { + v.tools.logError("Unable to set node positions: positions method parameter must be an array of " + + "node positions"); + } + } + // apply old positions (new data has priority - if graph was ready, than user provided positions are + // already present in old positions) - see also graph.positions method + else if (v.status.graphOldPositions) { + v.status.graphOldPositions.forEach(function(n) { + if (v.data.idLookup[n.ID] !== undefined) { + if (!v.data.idLookup[n.ID].fixed) { + v.data.idLookup[n.ID].fixed = n.fixed; + } + if (!v.data.idLookup[n.ID].x) { + v.data.idLookup[n.ID].x = v.data.idLookup[n.ID].px = n.x; + } + if (!v.data.idLookup[n.ID].y) { + v.data.idLookup[n.ID].y = v.data.idLookup[n.ID].py = n.y; + } + } + }); + } + // clear positions + v.conf.positions = null; + v.status.graphOldPositions = null; + + } //END: if (pData) + + // set color and radius function and calculate nodes radius + v.tools.setColorFunction(); + v.tools.setRadiusFunction(); + v.data.nodes.forEach(function(n) { + n.radius = v.tools.radius(n.SIZEVALUE); + }); + + // MARKERS + v.main.markers = v.dom.defs.selectAll("marker.custom") + .data(v.data.distinctLinkColorValues, + function(m) { + return m; + }); // distinctLinkColorValues is a simple array, we return the "whole" color value string + v.main.markers.enter().append("svg:marker") + .attr("id", function(m) { + return v.dom.containerId + "_" + m; + }) + .attr("class", "custom") + .attr("stroke", "none") + .attr("fill", function(m) { + return m; + }) + .attr("viewBox", "0 0 10 10") + .attr("refX", 10) + .attr("refY", 5) + .attr("markerWidth", 5) + .attr("markerHeight", 5) + .attr("orient", "auto") + .attr("markerUnits", "strokeWidth") + .append("svg:path") + .attr("d", "M0,0 L10,5 L0,10"); + v.main.markers.exit().remove(); + + // LINKS + v.main.links = v.dom.graph.selectAll("line.link") + .data(v.data.links.filter(function(l) { + return l.FROMID !== l.TOID; + }), + function(l) { + return l.FROMID + "_" + l.TOID; + }); + v.main.links.enter().append("svg:line") + .attr("class", "link") + .on("mouseenter", v.tools.onLinkMouseenter) + .on("mouseleave", v.tools.onLinkMouseleave) + .on("click", v.tools.onLinkClick); + v.main.links.exit().remove(); + // update all + v.main.links + .style("marker-end", v.tools.getMarkerUrl) + .classed("dotted", function(l) { + return (l.STYLE === "dotted"); + }) + .classed("dashed", function(l) { + return (l.STYLE === "dashed"); + }) + .style("stroke", function(l) { + return (l.COLOR ? l.COLOR : null); + }); + + // SELFLINKS + v.main.selfLinks = v.dom.graph.selectAll("path.link") + .data(v.data.links.filter(function(l) { + return l.FROMID === l.TOID && v.conf.showSelfLinks; + }), + function(l) { + return l.FROMID + "_" + l.TOID; + }); + v.main.selfLinks.enter().append("svg:path") + .attr("id", function(l) { + return v.dom.containerId + "_link_" + l.FROMID + "_" + l.TOID; + }) + .attr("class", "link") + .on("mouseenter", v.tools.onLinkMouseenter) + .on("mouseleave", v.tools.onLinkMouseleave) + .on("click", v.tools.onLinkClick); + v.main.selfLinks.exit().remove(); + // update all + v.main.selfLinks + .attr("d", function(l) { + return v.tools.getSelfLinkPath(l); + }) + .style("marker-end", v.tools.getMarkerUrl) + .classed("dotted", function(l) { + return (l.STYLE === "dotted"); + }) + .classed("dashed", function(l) { + return (l.STYLE === "dashed"); + }) + .style("stroke", function(l) { + return (l.COLOR ? l.COLOR : null); + }); + + // PATTERN for nodes with image attribute set + v.main.patterns = v.dom.defs.selectAll("pattern") + .data(v.data.nodes.filter(function(n) { + return (n.IMAGE ? true : false); + }), + function(n) { + return n.ID; + }); + v.main.patterns.enter().append("svg:pattern") + .attr("id", function(n) { + return v.dom.containerId + "_pattern_" + n.ID; + }) + .append("svg:image"); + v.main.patterns.exit().remove(); + // update all + v.main.patterns.each(function() { + d3.select(this) + .attr("x", 0) + .attr("y", 0) + .attr("height", function(n) { + return n.radius * 2; + }) + .attr("width", function(n) { + return n.radius * 2; + }); + d3.select(this.firstChild) + .attr("x", 0) + .attr("y", 0) + .attr("height", function(n) { + return n.radius * 2; + }) + .attr("width", function(n) { + return n.radius * 2; + }) + .attr("xlink:href", function(n) { + return n.IMAGE; + }); + }); + + // NODES + v.main.nodes = v.dom.graph.selectAll("circle.node") + .data(v.data.nodes, + function(n) { + return n.ID; + }); + v.main.nodes.enter().append("svg:circle") + .attr("class", "node") + .attr("cx", function(n) { + if (!n.fixed && !n.x) { + n.x = Math.floor((Math.random() * v.tools.getGraphWidth()) + 1); + return n.x; + } + }) + .attr("cy", function(n) { + if (!n.fixed && !n.y) { + n.y = Math.floor((Math.random() * v.conf.height) + 1); + return n.y; + } + }) + .on("mouseenter", v.tools.onNodeMouseenter) + .on("mouseleave", v.tools.onNodeMouseleave) + .on("click", v.tools.onNodeClick) + .on("dblclick", v.tools.onNodeDblclick) + .on("contextmenu", v.tools.onNodeContextmenu); + v.main.nodes.exit().remove(); + // update all + v.main.nodes + .attr("r", function(n) { + return n.radius; + }) + .attr("fill", function(n) { + return (n.IMAGE ? "url(#" + v.dom.containerId + "_pattern_" + n.ID + ")" : v.tools.color(n.COLORVALUE)); + }); + + + // LABELS + + if (v.conf.showLabels) { + + // normal text labels + v.main.labels = v.dom.graph.selectAll("text.label") + .data(v.data.nodes.filter(function(n) { + return !n.LABELCIRCULAR && !v.conf.labelsCircular; + }), + function(n) { + return n.ID; + }); + v.main.labels.enter().append("svg:text") + .attr("class", "label"); + v.main.labels.exit().remove(); + // update all + v.main.labels.text(function(n) { + return n.LABEL; + }); + + // paths for circular labels + v.main.labelPaths = v.dom.defs.selectAll("path.label") + .data(v.data.nodes.filter(function(n) { + return n.LABELCIRCULAR || v.conf.labelsCircular; + }), + function(n) { + return n.ID; + }); + v.main.labelPaths.enter().append("svg:path") + .attr("id", function(n) { + return v.dom.containerId + "_textPath_" + n.ID; + }) + .attr("class", "label"); + v.main.labelPaths.exit().remove(); + // update all + v.main.labelPaths.attr("d", function(n) { + return v.tools.getLabelPath(n); + }); + + // circular labels + v.main.labelsCircular = v.dom.graph.selectAll("text.labelCircular") + .data(v.data.nodes.filter(function(n) { + return n.LABELCIRCULAR || v.conf.labelsCircular; + }), + function(n) { + return n.ID; + }); + v.main.labelsCircular.enter().append("svg:text") + .attr("class", "labelCircular") + .append("svg:textPath") + .attr("xlink:href", function(n) { + return "#" + v.dom.containerId + "_textPath_" + n.ID; + }); + v.main.labelsCircular.exit().remove(); + // update all + v.main.labelsCircular.each(function(n) { + d3.select(this.firstChild).text(n.LABEL); + }); + } else { + v.dom.defs.selectAll("path.label").remove(); + v.dom.graph.selectAll("text.label,text.labelCircular").remove(); + } + + // initialize the graph (some options implicit initializes v.main.force, e.g. linkDistance, charge, ...) + graph + .debug(v.conf.debug) + .showBorder(v.conf.showBorder) + .setDomParentPaddingToZero(v.conf.setDomParentPaddingToZero) + .useDomParentWidth(v.conf.useDomParentWidth) + .width(v.conf.width) + .height(v.conf.height) + .alignFixedNodesToGrid(v.conf.alignFixedNodesToGrid) + .dragMode(v.conf.dragMode) + .pinMode(v.conf.pinMode) + .lassoMode(v.conf.lassoMode) + .zoomMode(v.conf.zoomMode) + .transform(v.conf.transform) + .autoRefresh(v.conf.autoRefresh) + .linkDistance(v.conf.linkDistance) + .charge(v.conf.charge) + .chargeDistance(v.conf.chargeDistance) + .gravity(v.conf.gravity) + .linkStrength(v.conf.linkStrength) + .friction(v.conf.friction) + .theta(v.conf.theta); + + // start visualization + v.main.force + .nodes(v.data.nodes) + .links(v.data.links) + .start(); + + if (v.status.customize) { + v.tools.createCustomizeWizard(); + } else { + v.tools.createCustomizeLink(); + } + + v.status.graphReady = true; + v.status.graphRendering = false; + + v.tools.triggerApexEvent(document.querySelector("#" + v.dom.containerId), "apexafterrefresh"); + + return graph; + }; + + graph.resume = function() { + v.main.force.resume(); + v.tools.createCustomizeWizardIfNotRendering(); + return graph; + }; + + graph.showBorder = function(value) { + if (!arguments.length) { + return v.conf.showBorder; + } + v.conf.showBorder = value; + if (v.status.graphStarted) { + v.dom.svg.classed("border", v.conf.showBorder); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.showLegend = function(value) { + if (!arguments.length) { + return v.conf.showLegend; + } + v.conf.showLegend = value; + if (v.status.graphStarted) { + if (v.conf.showLegend) { + v.tools.removeLegend(); + v.tools.createLegend(); + } else { + v.tools.removeLegend(); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.showSelfLinks = function(value) { + if (!arguments.length) { + return v.conf.showSelfLinks; + } + v.conf.showSelfLinks = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.showLinkDirection = function(value) { + if (!arguments.length) { + return v.conf.showLinkDirection; + } + v.conf.showLinkDirection = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.showTooltips = function(value) { + if (!arguments.length) { + return v.conf.showTooltips; + } + v.conf.showTooltips = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.tooltipPosition = function(value) { + if (!arguments.length) { + return v.conf.tooltipPosition; + } + v.conf.tooltipPosition = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.colorScheme = function(value) { + if (!arguments.length) { + return v.conf.colorScheme; + } + v.conf.colorScheme = value; + v.tools.setColorFunction(); + if (v.status.graphStarted) { + v.main.nodes + .attr("fill", function(n) { + return (n.IMAGE ? "url(#" + v.dom.containerId + "_pattern_" + n.ID + ")" : + v.tools.color(n.COLORVALUE)); + }); + if (v.conf.showLegend) { + v.tools.removeLegend(); + v.tools.createLegend(); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.showLabels = function(value) { + if (!arguments.length) { + return v.conf.showLabels; + } + v.conf.showLabels = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.labelsCircular = function(value) { + if (!arguments.length) { + return v.conf.labelsCircular; + } + v.conf.labelsCircular = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.preventLabelOverlappingOnForceEnd = function(value) { + if (!arguments.length) { + return v.conf.preventLabelOverlappingOnForceEnd; + } + v.conf.preventLabelOverlappingOnForceEnd = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.labelPlacementIterations = function(value) { + if (!arguments.length) { + return v.conf.labelPlacementIterations; + } + v.conf.labelPlacementIterations = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.dragMode = function(value) { + if (!arguments.length) { + return v.conf.dragMode; + } + v.conf.dragMode = value; + if (v.status.graphStarted) { + if (v.conf.dragMode) { + v.main.nodes.call(v.main.drag); + } else { + // http://stackoverflow.com/questions/13136355/d3-js-remove-force-drag-from-a-selection + v.main.nodes.on("mousedown.drag", null); + v.main.nodes.on("touchstart.drag", null); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.pinMode = function(value) { + if (!arguments.length) { + return v.conf.pinMode; + } + v.conf.pinMode = value; + if (v.status.graphStarted) { + if (v.conf.pinMode) { + v.main.drag.on("dragstart", function(n) { + d3.select(this).classed("fixed", n.fixed = 1); + }); + } else { + v.main.drag.on("dragstart", null); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.lassoMode = function(value) { + if (!arguments.length) { + return v.conf.lassoMode; + } + v.conf.lassoMode = value; + if (v.status.graphStarted) { + if (v.conf.lassoMode) { + v.dom.graphOverlay.call(v.main.lasso); + v.main.lasso.items(v.main.nodes); + v.main.lasso.on("start", function() { + v.main.lasso.items().classed("selected", false); + v.tools.onLassoStart(v.main.lasso.items()); + }); + v.main.lasso.on("draw", function() { + v.main.lasso.items().filter(function(d) { + return d.possible === true; + }) + .classed("selected", true); + v.main.lasso.items().filter(function(d) { + return d.possible === false; + }) + .classed("selected", false); + }); + v.main.lasso.on("end", function() { + v.main.lasso.items().filter(function(d) { + return d.selected === true; + }) + .classed("selected", true); + v.main.lasso.items().filter(function(d) { + return d.selected === false; + }) + .classed("selected", false); + v.tools.onLassoEnd(v.main.lasso.items()); + }); + // save lasso event for use in event proxy + v.events.mousedownLasso = v.dom.graphOverlay.on("mousedown.drag"); + v.events.touchstartLasso = v.dom.graphOverlay.on("touchstart.drag"); + //v.events.touchmoveDrag = v.dom.graphOverlay.on("touchmove.drag"); + //v.events.touchendDrag = v.dom.graphOverlay.on("touchend.drag"); + + // register event proxy for relevant lasso events who conflict with force functions -> see also + // v.tools.lassoEventProxy + v.dom.graphOverlay.on("mousedown.drag", v.tools.lassoEventProxy(v.events.mousedownLasso)); + v.dom.graphOverlay.on("touchstart.drag", v.tools.lassoEventProxy(v.events.touchstartLasso)); + //v.dom.graphOverlay.on("touchmove.drag", v.tools.lassoEventProxy(v.events.touchmoveDrag)); + //v.dom.graphOverlay.on("touchend.drag", v.tools.lassoEventProxy(v.events.touchendDrag)); + } else { + v.dom.graphOverlay.on(".drag", null); + v.main.nodes.classed("selected", false); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.transform = function(value) { + if (!arguments.length) { + return { + "translate": v.main.zoom.translate(), + "scale": v.main.zoom.scale() + }; + } else { + v.main.zoom.translate(value.translate); + v.main.zoom.scale(value.scale); + v.conf.transform = { + "translate": v.main.zoom.translate(), + "scale": v.main.zoom.scale() + }; + if (v.conf.zoomMode && v.status.graphStarted) { + v.dom.graph.attr("transform", "translate(" + v.main.zoom.translate() + ")scale(" + + v.main.zoom.scale() + ")"); + v.tools.writeConfObjectIntoWizard(); + } + } + return graph; + }; + + graph.zoomMode = function(value) { + if (!arguments.length) { + return v.conf.zoomMode; + } + v.conf.zoomMode = value; + if (v.status.graphStarted) { + if (v.conf.zoomMode) { + v.dom.graphOverlay.call(v.main.zoom); + v.main.zoom.scaleExtent([v.conf.minZoomFactor, v.conf.maxZoomFactor]) + .size([v.tools.getGraphWidth(), v.conf.height]) + .on("zoom", function() { + v.main.zoom.translate(d3.event.translate); + v.main.zoom.scale(d3.event.scale); + v.conf.transform = { + "translate": v.main.zoom.translate(), + "scale": v.main.zoom.scale() + }; + v.dom.graph.attr("transform", "translate(" + v.main.zoom.translate() + ")scale(" + + v.main.zoom.scale() + ")"); + v.tools.writeConfObjectIntoWizard(); + }); + // save zoom events for use in event proxy + v.events.dblclickZoom = v.dom.graphOverlay.on("dblclick.zoom"); + v.events.mousedownZoom = v.dom.graphOverlay.on("mousedown.zoom"); + v.events.touchstartZoom = v.dom.graphOverlay.on("touchstart.zoom"); + //v.events.touchmoveZoom = v.dom.graphOverlay.on("touchmove.zoom"); + //v.events.touchendZoom = v.dom.graphOverlay.on("touchend.zoom"); + + // register event proxy for relevant zoom events who conflicts with force functions -> see also + // v.tools.zoomEventProxy + v.dom.graphOverlay.on("dblclick.zoom", v.tools.zoomEventProxy(v.events.dblclickZoom)); + v.dom.graphOverlay.on("mousedown.zoom", v.tools.zoomEventProxy(v.events.mousedownZoom)); + v.dom.graphOverlay.on("touchstart.zoom", v.tools.zoomEventProxy(v.events.touchstartZoom)); + //v.dom.graphOverlay.on("touchmove.zoom", v.tools.zoomEventProxy(v.events.touchmoveZoom)); + //v.dom.graphOverlay.on("touchend.zoom", v.tools.zoomEventProxy(v.events.touchendZoom)); + + // transform graph, if conf is not default + if (JSON.stringify(v.conf.transform) !== JSON.stringify(v.confDefaults.transform)) { + v.dom.graph.attr("transform", "translate(" + v.main.zoom.translate() + ")scale(" + + v.main.zoom.scale() + ")"); + v.tools.writeConfObjectIntoWizard(); + } + } else { + // http://stackoverflow.com/questions/22302919/ + // unregister-zoom-listener-and-restore-scroll-ability-in-d3-js/22303160?noredirect=1#22303160 + v.dom.graphOverlay.on(".zoom", null); + v.main.zoom.translate([0, 0]); + v.main.zoom.scale(1); + v.conf.transform = { + "translate": [0, 0], + "scale": 1 + }; + v.dom.graph.attr("transform", "translate(0,0)scale(1)"); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.minZoomFactor = function(value) { + if (!arguments.length) { + return v.conf.minZoomFactor; + } + v.conf.minZoomFactor = value; + if (v.status.graphReady) { + graph.zoomMode(v.conf.zoomMode); + } + return graph; + }; + + graph.maxZoomFactor = function(value) { + if (!arguments.length) { + return v.conf.maxZoomFactor; + } + v.conf.maxZoomFactor = value; + if (v.status.graphReady) { + graph.zoomMode(v.conf.zoomMode); + } + return graph; + }; + + graph.zoom = function(centerX, centerY, viewportWidth) { + if (v.conf.zoomMode) { + var width = v.tools.getGraphWidth(); + if (!centerX) { + centerX = width / 2; + } + if (!centerY) { + centerY = v.conf.height / 2; + } + if (!viewportWidth) { + viewportWidth = width; + } + v.main.zoom.scale(width / viewportWidth); + if (v.main.zoom.scale() < v.conf.minZoomFactor) { + v.main.zoom.scale(v.conf.minZoomFactor); + } + if (v.main.zoom.scale() > v.conf.maxZoomFactor) { + v.main.zoom.scale(v.conf.maxZoomFactor); + } + v.main.zoom.translate([ + (width / 2 - centerX * v.main.zoom.scale()), (v.conf.height / 2 - centerY * v.main.zoom.scale()) + ]); + v.conf.transform = { + "translate": v.main.zoom.translate(), + "scale": v.main.zoom.scale() + }; + v.main.zoom.event(v.dom.graphOverlay); + v.tools.writeConfObjectIntoWizard(); + } + return graph; + }; + + graph.zoomSmooth = function(centerX, centerY, viewportWidth, duration) { + if (v.conf.zoomMode) { + var width = v.tools.getGraphWidth(); + if (!centerX) { + centerX = width / 2; + } + if (!centerY) { + centerY = v.conf.height / 2; + } + if (!viewportWidth) { + viewportWidth = width; + } + if (!duration) { + duration = 1500; + } + v.main.zoom.scale(width / viewportWidth); + if (v.main.zoom.scale() < v.conf.minZoomFactor) { + v.main.zoom.scale(v.conf.minZoomFactor); + } + if (v.main.zoom.scale() > v.conf.maxZoomFactor) { + v.main.zoom.scale(v.conf.maxZoomFactor); + } + v.main.zoom.translate([ + (width / 2 - centerX * v.main.zoom.scale()), (v.conf.height / 2 - centerY * v.main.zoom.scale()) + ]); + v.conf.translate = { + "translate": v.main.zoom.translate(), + "scale": v.main.zoom.scale() + }; + v.dom.graphOverlay.transition() + .duration(duration) + .call(v.main.zoom.event); + v.tools.writeConfObjectIntoWizard(); + } + return graph; + }; + + graph.showLoadingIndicatorOnAjaxCall = function(value) { + if (!arguments.length) { + return v.conf.showLoadingIndicatorOnAjaxCall; + } + v.conf.showLoadingIndicatorOnAjaxCall = value; + return graph; + }; + + graph.showLoadingIndicator = function(value) { + if (v.tools.parseBool(value)) { + v.dom.loading.style("display", "block"); + } else { + v.dom.loading.style("display", "none"); + } + return graph; + }; + + graph.alignFixedNodesToGrid = function(value) { + if (!arguments.length) { + return v.conf.alignFixedNodesToGrid; + } + v.conf.alignFixedNodesToGrid = value; + if (v.status.graphStarted) { + // align fixed nodes to grid + if (v.conf.alignFixedNodesToGrid) { + // NO aligning on the very first start: this would overwrite user defined positions + if (v.status.graphReady) { + v.main.nodes.each(function(n) { + if (n.fixed) { + n.x = n.px = v.tools.getNearestGridPosition(n.x, v.conf.width); + n.y = n.py = v.tools.getNearestGridPosition(n.y, v.conf.height); + } + }); + } + v.main.drag.on("dragend", function(n) { + n.x = n.px = v.tools.getNearestGridPosition(n.x, v.conf.width); + n.y = n.py = v.tools.getNearestGridPosition(n.y, v.conf.height); + }); + } else { + v.main.drag.on("dragend", null); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.moveFixedNodes = function(x, y) { + if (v.status.graphStarted) { + if (!x) { + x = 0; + } + if (!y) { + y = 0; + } + if (x !== 0 || y !== 0) { + v.main.nodes.each(function(n) { + if (n.fixed) { + n.x = n.px = (v.conf.alignFixedNodesToGrid ? + v.tools.getNearestGridPosition(n.x + x, v.conf.width) : n.x + x); + n.y = n.py = (v.conf.alignFixedNodesToGrid ? + v.tools.getNearestGridPosition(n.y + y, v.conf.width) : n.y + y); + } + }); + } + } + return graph; + }; + + graph.gridSize = function(value) { + if (!arguments.length) { + return v.conf.gridSize; + } + v.conf.gridSize = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.nodeEventToStopPinMode = function(value) { + if (!arguments.length) { + return v.conf.nodeEventToStopPinMode; + } + v.conf.nodeEventToStopPinMode = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.onNodeContextmenuPreventDefault = function(value) { + if (!arguments.length) { + return v.conf.onNodeContextmenuPreventDefault; + } + v.conf.onNodeContextmenuPreventDefault = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.nodeEventToOpenLink = function(value) { + if (!arguments.length) { + return v.conf.nodeEventToOpenLink; + } + v.conf.nodeEventToOpenLink = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.nodeLinkTarget = function(value) { + if (!arguments.length) { + return v.conf.nodeLinkTarget; + } + v.conf.nodeLinkTarget = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.autoRefresh = function(value) { + if (!arguments.length) { + return v.conf.autoRefresh; + } + v.conf.autoRefresh = value; + if (v.status.graphStarted) { + if (v.conf.autoRefresh && v.conf.refreshInterval && !v.conf.interval) { + v.conf.interval = window.setInterval(function() { + graph.start(); + }, v.conf.refreshInterval); + v.tools.log("Auto refresh started with an interval of " + v.conf.refreshInterval + " milliseconds."); + } else if (!v.conf.autoRefresh && v.conf.interval) { + clearInterval(v.conf.interval); + v.conf.interval = null; + v.tools.log("Auto refresh stopped."); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.refreshInterval = function(value) { + if (!arguments.length) { + return v.conf.refreshInterval; + } + v.conf.refreshInterval = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.useDomParentWidth = function(value) { + if (!arguments.length) { + return v.conf.useDomParentWidth; + } + v.conf.useDomParentWidth = value; + if (v.status.graphStarted) { + if (v.conf.useDomParentWidth) { + v.dom.containerWidth = v.tools.getSvgParentInnerWidth(); + d3.select(window).on("resize", function() { + var oldWidth = v.dom.containerWidth; + var newWidth = v.tools.getSvgParentInnerWidth(); + if (oldWidth !== newWidth) { + v.dom.containerWidth = newWidth; + graph.width(v.conf.width).resume(); + } + }); + } else { + d3.select(window).on("resize", null); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.setDomParentPaddingToZero = function(value) { + if (!arguments.length) { + return v.conf.setDomParentPaddingToZero; + } + v.conf.setDomParentPaddingToZero = value; + if (v.status.graphStarted) { + if (v.conf.setDomParentPaddingToZero) { + v.dom.svgParent.style("padding", "0"); + } else { + v.dom.svgParent.style("padding", null); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.domParentWidth = function() { + return v.dom.containerWidth || v.tools.getSvgParentInnerWidth(); + }; + + graph.width = function(value) { + if (!arguments.length) { + return v.conf.width; + } + v.conf.width = value; + if (v.status.graphStarted) { + v.dom.svg.attr("width", v.tools.getGraphWidth()); + v.dom.graphOverlaySizeHelper.attr("width", v.tools.getGraphWidth()); + v.dom.loadingRect.attr("width", v.tools.getGraphWidth()); + v.dom.loadingText.attr("x", v.tools.getGraphWidth() / 2); + v.main.force.size([v.tools.getGraphWidth(), v.conf.height]); + if (v.conf.zoomMode) { + v.main.zoom.size([v.tools.getGraphWidth(), v.conf.height]); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.height = function(value) { + if (!arguments.length) { + return v.conf.height; + } + v.conf.height = value; + if (v.status.graphStarted) { + v.dom.svg.attr("height", v.conf.height); + v.dom.graphOverlaySizeHelper.attr("height", v.conf.height); + v.dom.loadingRect.attr("height", v.conf.height); + v.dom.loadingText.attr("y", v.conf.height / 2); + v.main.force.size([v.tools.getGraphWidth(), v.conf.height]); + if (v.conf.showLegend) { + v.tools.removeLegend(); + v.tools.createLegend(); + } + if (v.conf.zoomMode) { + v.main.zoom.size([v.tools.getGraphWidth(), v.conf.height]); + } + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.minNodeRadius = function(value) { + if (!arguments.length) { + return v.conf.minNodeRadius; + } + v.conf.minNodeRadius = value; + if (v.status.graphReady) { + v.tools.setRadiusFunction(); + v.main.nodes.each(function(n) { + n.radius = v.tools.radius(n.SIZEVALUE); + }); + v.main.nodes.attr("r", function(n) { + return n.radius; + }); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.maxNodeRadius = function(value) { + if (!arguments.length) { + return v.conf.maxNodeRadius; + } + v.conf.maxNodeRadius = value; + if (v.status.graphReady) { + v.tools.setRadiusFunction(); + v.main.nodes.each(function(n) { + n.radius = v.tools.radius(n.SIZEVALUE); + }); + v.main.nodes.attr("r", function(n) { + return n.radius; + }); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.labelDistance = function(value) { + if (!arguments.length) { + return v.conf.labelDistance; + } + v.conf.labelDistance = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.selfLinkDistance = function(value) { + if (!arguments.length) { + return v.conf.selfLinkDistance; + } + v.conf.selfLinkDistance = value; + if (v.status.graphStarted) { + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.linkDistance = function(value) { + if (!arguments.length) { + return v.conf.linkDistance; + } + v.conf.linkDistance = value; + if (v.status.graphStarted) { + v.main.force.linkDistance(v.conf.linkDistance); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.charge = function(value) { + if (!arguments.length) { + return v.conf.charge; + } + v.conf.charge = value; + if (v.status.graphStarted) { + v.main.force.charge(v.conf.charge); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.chargeDistance = function(value) { + if (!arguments.length) { + return v.conf.chargeDistance; + } + v.conf.chargeDistance = value; + if (v.status.graphStarted) { + v.main.force.chargeDistance(v.conf.chargeDistance); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.gravity = function(value) { + if (!arguments.length) { + return v.conf.gravity; + } + v.conf.gravity = value; + if (v.status.graphStarted) { + v.main.force.gravity(v.conf.gravity); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.linkStrength = function(value) { + if (!arguments.length) { + return v.conf.linkStrength; + } + v.conf.linkStrength = value; + if (v.status.graphStarted) { + v.main.force.linkStrength(v.conf.linkStrength); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.friction = function(value) { + if (!arguments.length) { + return v.conf.friction; + } + v.conf.friction = value; + if (v.status.graphStarted) { + v.main.force.friction(v.conf.friction); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.theta = function(value) { + if (!arguments.length) { + return v.conf.theta; + } + v.conf.theta = value; + if (v.status.graphStarted) { + v.main.force.theta(v.conf.theta); + v.tools.createCustomizeWizardIfNotRendering(); + } + return graph; + }; + + graph.positions = function(value) { + if (!arguments.length) { + var positions = []; + v.data.nodes.forEach(function(n) { + positions.push({ + "ID": n.ID, + "x": Math.round(n.x), + "y": Math.round(n.y), + "fixed": (n.fixed ? 1 : 0) + }); + }); + return positions; + } else { + if (v.status.graphReady) { + if (value.constructor === Array) { + value.forEach(function(n) { + if (v.data.idLookup[n.ID] !== undefined) { + v.data.idLookup[n.ID].fixed = v.tools.parseBool(n.fixed); + v.data.idLookup[n.ID].x = v.data.idLookup[n.ID].px = n.x; + v.data.idLookup[n.ID].y = v.data.idLookup[n.ID].py = n.y; + } + }); + } else { + v.tools.logError("Unable to set node positions: positions method parameter must be an array of " + + "node positions"); + } + } else { + v.conf.positions = value; // we do positioning later after start() is called + } + return graph; + } + }; + + graph.onLinkClickFunction = function(value) { + if (!arguments.length) { + return v.conf.onLinkClickFunction; + } + v.conf.onLinkClickFunction = value; + return graph; + }; + + graph.onNodeMouseenterFunction = function(value) { + if (!arguments.length) { + return v.conf.onNodeMouseenterFunction; + } + v.conf.onNodeMouseenterFunction = value; + return graph; + }; + + graph.onNodeMouseleaveFunction = function(value) { + if (!arguments.length) { + return v.conf.onNodeMouseleaveFunction; + } + v.conf.onNodeMouseleaveFunction = value; + return graph; + }; + + graph.onNodeClickFunction = function(value) { + if (!arguments.length) { + return v.conf.onNodeClickFunction; + } + v.conf.onNodeClickFunction = value; + return graph; + }; + + graph.onNodeDblclickFunction = function(value) { + if (!arguments.length) { + return v.conf.onNodeDblclickFunction; + } + v.conf.onNodeDblclickFunction = value; + return graph; + }; + + graph.onNodeContextmenuFunction = function(value) { + if (!arguments.length) { + return v.conf.onNodeContextmenuFunction; + } + v.conf.onNodeContextmenuFunction = value; + return graph; + }; + + graph.onLassoStartFunction = function(value) { + if (!arguments.length) { + return v.conf.onLassoStartFunction; + } + v.conf.onLassoStartFunction = value; + return graph; + }; + + graph.onLassoEndFunction = function(value) { + if (!arguments.length) { + return v.conf.onLassoEndFunction; + } + v.conf.onLassoEndFunction = value; + return graph; + }; + + graph.sampleData = function(value) { + if (!arguments.length) { + return v.data.sampleData; + } + v.data.sampleData = value; + return graph; + }; + + graph.data = function() { + return v.data.dataConverted; + }; + + graph.nodeDataById = function(ID) { + return v.data.idLookup[ID]; + }; + + graph.options = function(value) { + var key; + if (!arguments.length) { + var conf = {}; + for (key in v.conf) { + if (v.conf.hasOwnProperty(key)) { + if (v.confDefaults.hasOwnProperty(key)) { + if ((v.confDefaults[key].type === "bool" || + v.confDefaults[key].type === "number" || + v.confDefaults[key].type === "text") && + v.confDefaults[key].val !== v.conf[key]) { + conf[key] = v.conf[key]; + } else if (v.confDefaults[key].type === "object" && + JSON.stringify(v.confDefaults[key].val) !== JSON.stringify(v.conf[key])) { + conf[key] = v.conf[key]; + } + } else if (!v.confDefaults.hasOwnProperty(key) && + v.conf[key] !== undefined && + v.conf[key] !== null) { + conf[key] = v.conf[key]; + } + } + } + return conf; + } else { + v.tools.applyConfigurationObject(value); + return graph; + } + }; + + graph.optionsCustomizationWizard = function(value) { + var key; + if (!arguments.length) { + var conf = {}; + for (key in v.confDefaults) { + if (v.confDefaults.hasOwnProperty(key)) { + if ((v.confDefaults[key].type === "bool" || + v.confDefaults[key].type === "number" || + v.confDefaults[key].type === "text") && + v.confDefaults[key].val !== v.conf[key]) { + conf[key] = v.conf[key]; + } else if (v.confDefaults[key].type === "object" && + JSON.stringify(v.confDefaults[key].val) !== JSON.stringify(v.conf[key])) { + conf[key] = v.conf[key]; + } + } + } + return conf; + } else { + v.tools.applyConfigurationObject(value); + return graph; + } + }; + + graph.customize = function(value) { + if (!arguments.length) { + return v.status.customize; + } + v.status.customize = value; + if (v.status.graphStarted) { + if (v.status.customize) { + v.tools.createCustomizeWizard(); + } else { + v.tools.removeCustomizeWizard(); + } + } + return graph; + }; + + graph.debug = function(value) { + if (!arguments.length) { + return v.conf.debug; + } + v.conf.debug = value; + if (v.status.graphStarted) { + if (v.conf.debug) { + v.tools.createCustomizeLink(); + } else { + v.tools.removeCustomizeLink(); + } + } + return graph; + }; + + graph.releaseFixedNodes = function() { + if (v.status.graphStarted) { + v.main.nodes.each(function(n) { + n.fixed = 0; + }); + } + return graph; + }; + + graph.userAgent = function() { + return v.status.userAgent; + }; + + // public inspect function: to inspect the global object, which holds all data, functions and references + graph.inspect = function() { + return v; + }; + + graph.version = function() { + return v.version; + }; + + /******************************************************************************************************************* + * Startup code - runs one time after the initialization of a new chart - example: + * var myChart = net_gobrechts_d3_force( pDomContainerId, pConf, pApexPluginId ).start(); + */ + + // bind to the apexrefresh event, so that this region can be refreshed by a dynamic action + if (v.status.apexPluginId) { + apex.jQuery("#" + v.dom.containerId).bind("apexrefresh", function() { + graph.start(); + }); + } + + // final return + return graph; + +} diff --git a/share/public/javascripts/d3.min.js b/share/public/javascripts/d3.min.js index 1ac1f498..1984d172 100644 --- a/share/public/javascripts/d3.min.js +++ b/share/public/javascripts/d3.min.js @@ -1,4 +1,5 @@ -(function(){function t(){return 0}function n(t){return t.target}function e(t){return t.source}function r(t,n){try{for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}catch(r){t.prototype=n}}function i(t){var n=-1,e=t.length,r=[];while(e>++n)r.push(t[n]);return r}function u(t){return Array.prototype.slice.call(t)}function a(){}function o(t){return t}function l(){return!0}function c(t){return typeof t=="function"?t:function(){return t}}function s(t,n,e){return function(){var r=e.apply(n,arguments);return arguments.length?t:r}}function f(t){return t!=null&&!isNaN(t)}function h(t){return t.length}function d(t){return t.trim().replace(/\s+/g," ")}function g(t){var n=1;while(t*n%1)n*=10;return n}function p(t){return t.responseText}function m(t){return JSON.parse(t.responseText)}function v(t){var n=document.createRange();return n.selectNode(document.body),n.createContextualFragment(t.responseText)}function y(t){return t.responseXML}function M(){}function b(t){function n(){var n,r=e,i=-1,u=r.length;while(u>++i)(n=r[i].on)&&n.apply(this,arguments);return t}var e=[],r=new a;return n.on=function(n,i){var u,a=r.get(n);return 2>arguments.length?a&&a.on:(a&&(a.on=null,e=e.slice(0,u=e.indexOf(a)).concat(e.slice(u+1)),r.remove(n)),i&&e.push(r.set(n,{on:i})),t)},n}function x(t,n){return n-(t?1+Math.floor(Math.log(t+Math.pow(10,1+Math.floor(Math.log(t)/Math.LN10)-n))/Math.LN10):1)}function w(t){return t+""}function _(t,n){var e=Math.pow(10,Math.abs(8-n)*3);return{scale:n>8?function(t){return t/e}:function(t){return t*e},symbol:t}}function k(t){return function(n){return 0>=n?0:n>=1?1:t(n)}}function T(t){return function(n){return 1-t(1-n)}}function S(t){return function(n){return.5*(.5>n?t(2*n):2-t(2-2*n))}}function A(t){return t*t}function N(t){return t*t*t}function C(t){if(0>=t)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(.5>t?e:3*(t-n)+e-.75)}function q(t){return function(n){return Math.pow(n,t)}}function z(t){return 1-Math.cos(t*_u/2)}function E(t){return Math.pow(2,10*(t-1))}function D(t){return 1-Math.sqrt(1-t*t)}function P(t,n){var e;return 2>arguments.length&&(n=.45),arguments.length?e=n/(2*_u)*Math.asin(1/t):(t=1,e=n/4),function(r){return 1+t*Math.pow(2,10*-r)*Math.sin((r-e)*2*_u/n)}}function L(t){return t||(t=1.70158),function(n){return n*n*((t+1)*n-t)}}function F(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function H(){d3.event.stopPropagation(),d3.event.preventDefault()}function j(){var t,n=d3.event;while(t=n.sourceEvent)n=t;return n}function O(t){var n=new M,e=0,r=arguments.length;while(r>++e)n[arguments[e]]=b(n);return n.of=function(e,r){return function(i){try{var u=i.sourceEvent=d3.event;i.target=t,d3.event=i,n[i.type].apply(e,r)}finally{d3.event=u}}},n}function R(t){var n=[t.a,t.b],e=[t.c,t.d],r=U(n),i=Y(n,e),u=U(I(e,n,-i))||0;e[0]*n[1]>n[0]*e[1]&&(n[0]*=-1,n[1]*=-1,r*=-1,i*=-1),this.rotate=(r?Math.atan2(n[1],n[0]):Math.atan2(-e[0],e[1]))*Au,this.translate=[t.e,t.f],this.scale=[r,u],this.skew=u?Math.atan2(i,u)*Au:0}function Y(t,n){return t[0]*n[0]+t[1]*n[1]}function U(t){var n=Math.sqrt(Y(t,t));return n&&(t[0]/=n,t[1]/=n),n}function I(t,n,e){return t[0]+=e*n[0],t[1]+=e*n[1],t}function V(t){return t=="transform"?d3.interpolateTransform:d3.interpolate}function Z(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return(e-t)*n}}function B(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return Math.max(0,Math.min(1,(e-t)*n))}}function X(){}function $(t,n,e){return new G(t,n,e)}function G(t,n,e){this.r=t,this.g=n,this.b=e}function J(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function K(t,n,e){var r,i,u,a=0,o=0,l=0;if(r=/([a-z]+)\((.*)\)/i.exec(t))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(nn(i[0]),nn(i[1]),nn(i[2]))}return(u=Xu.get(t))?n(u.r,u.g,u.b):(t!=null&&t.charAt(0)==="#"&&(t.length===4?(a=t.charAt(1),a+=a,o=t.charAt(2),o+=o,l=t.charAt(3),l+=l):t.length===7&&(a=t.substring(1,3),o=t.substring(3,5),l=t.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),l=parseInt(l,16)),n(a,o,l))}function W(t,n,e){var r,i,u=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),o=a-u,l=(a+u)/2;return o?(i=.5>l?o/(a+u):o/(2-a-u),r=t==a?(n-e)/o+(e>n?6:0):n==a?(e-t)/o+2:(t-n)/o+4,r*=60):i=r=0,en(r,i,l)}function Q(t,n,e){t=tn(t),n=tn(n),e=tn(e);var r=gn((.4124564*t+.3575761*n+.1804375*e)/Ku),i=gn((.2126729*t+.7151522*n+.072175*e)/Wu),u=gn((.0193339*t+.119192*n+.9503041*e)/Qu);return cn(116*i-16,500*(r-i),200*(i-u))}function tn(t){return.04045>=(t/=255)?t/12.92:Math.pow((t+.055)/1.055,2.4)}function nn(t){var n=parseFloat(t);return t.charAt(t.length-1)==="%"?Math.round(n*2.55):n}function en(t,n,e){return new rn(t,n,e)}function rn(t,n,e){this.h=t,this.s=n,this.l=e}function un(t,n,e){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?u+(a-u)*t/60:180>t?a:240>t?u+(a-u)*(240-t)/60:u}function i(t){return Math.round(r(t)*255)}var u,a;return t%=360,0>t&&(t+=360),n=0>n?0:n>1?1:n,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+n):e+n-e*n,u=2*e-a,$(i(t+120),i(t),i(t-120))}function an(t,n,e){return new on(t,n,e)}function on(t,n,e){this.h=t,this.c=n,this.l=e}function ln(t,n,e){return cn(e,Math.cos(t*=Su)*n,Math.sin(t)*n)}function cn(t,n,e){return new sn(t,n,e)}function sn(t,n,e){this.l=t,this.a=n,this.b=e}function fn(t,n,e){var r=(t+16)/116,i=r+n/500,u=r-e/200;return i=dn(i)*Ku,r=dn(r)*Wu,u=dn(u)*Qu,$(pn(3.2404542*i-1.5371385*r-.4985314*u),pn(-.969266*i+1.8760108*r+.041556*u),pn(.0556434*i-.2040259*r+1.0572252*u))}function hn(t,n,e){return an(Math.atan2(e,n)/_u*180,Math.sqrt(n*n+e*e),t)}function dn(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function gn(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function pn(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function mn(t){return qu(t,aa),t}function vn(t){return function(){return na(t,this)}}function yn(t){return function(){return ea(t,this)}}function Mn(t,n){function e(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,n)}function u(){this.setAttributeNS(t.space,t.local,n)}function a(){var e=n.apply(this,arguments);e==null?this.removeAttribute(t):this.setAttribute(t,e)}function o(){var e=n.apply(this,arguments);e==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}return t=d3.ns.qualify(t),n==null?t.local?r:e:typeof n=="function"?t.local?o:a:t.local?u:i}function bn(t){return RegExp("(?:^|\\s+)"+d3.requote(t)+"(?:\\s+|$)","g")}function xn(t,n){function e(){var e=-1;while(i>++e)t[e](this,n)}function r(){var e=-1,r=n.apply(this,arguments);while(i>++e)t[e](this,r)}t=t.trim().split(/\s+/).map(wn);var i=t.length;return typeof n=="function"?r:e}function wn(t){var n=bn(t);return function(e,r){if(i=e.classList)return r?i.add(t):i.remove(t);var i=e.className,u=i.baseVal!=null,a=u?i.baseVal:i;r?(n.lastIndex=0,n.test(a)||(a=d(a+" "+t),u?i.baseVal=a:e.className=a)):a&&(a=d(a.replace(n," ")),u?i.baseVal=a:e.className=a)}}function _n(t,n,e){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,n,e)}function u(){var r=n.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,e)}return n==null?r:typeof n=="function"?u:i}function kn(t,n){function e(){delete this[t]}function r(){this[t]=n}function i(){var e=n.apply(this,arguments);e==null?delete this[t]:this[t]=e}return n==null?e:typeof n=="function"?i:r}function Tn(t){return{__data__:t}}function Sn(t){return function(){return ua(this,t)}}function An(t){return arguments.length||(t=d3.ascending),function(n,e){return t(n&&n.__data__,e&&e.__data__)}}function Nn(t,n,e){function r(){var n=this[u];n&&(this.removeEventListener(t,n,n.$),delete this[u])}function i(){function i(t){var e=d3.event;d3.event=t,o[0]=a.__data__;try{n.apply(a,o)}finally{d3.event=e}}var a=this,o=Nu(arguments);r.call(this),this.addEventListener(t,this[u]=i,i.$=e),i._=n}var u="__on"+t,a=t.indexOf(".");return a>0&&(t=t.substring(0,a)),n?i:r}function Cn(t,n){for(var e=0,r=t.length;r>e;e++)for(var i,u=t[e],a=0,o=u.length;o>a;a++)(i=u[a])&&n(i,a,e);return t}function qn(t){return qu(t,la),t}function zn(t,n){return qu(t,sa),t.id=n,t}function En(t,n,e,r){var i=t.__transition__||(t.__transition__={active:0,count:0}),u=i[e];if(!u){var o=r.time;return u=i[e]={tween:new a,event:d3.dispatch("start","end"),time:o,ease:r.ease,delay:r.delay,duration:r.duration},++i.count,d3.timer(function(r){function a(r){return i.active>e?c():(i.active=e,h.start.call(t,s,n),u.tween.forEach(function(e,r){(r=r.call(t,s,n))&&p.push(r)}),l(r)||d3.timer(l,0,o),1)}function l(r){if(i.active!==e)return c();var u=(r-d)/g,a=f(u),o=p.length;while(o>0)p[--o].call(t,a);return u>=1?(c(),h.end.call(t,s,n),1):void 0}function c(){return--i.count?delete i[e]:delete t.__transition__,1}var s=t.__data__,f=u.ease,h=u.event,d=u.delay,g=u.duration,p=[];return r>=d?a(r):d3.timer(a,d,o),1},0,o),u}}function Dn(t){return t==null&&(t=""),function(){this.textContent=t}}function Pn(t,n,e,r){var i=t.id;return Cn(t,typeof e=="function"?function(t,u,a){t.__transition__[i].tween.set(n,r(e.call(t,t.__data__,u,a)))}:(e=r(e),function(t){t.__transition__[i].tween.set(n,e)}))}function Ln(){var t,n=Date.now(),e=va;while(e)t=n-e.then,t>=e.delay&&(e.flush=e.callback(t)),e=e.next;var r=Fn()-n;r>24?(isFinite(r)&&(clearTimeout(ga),ga=setTimeout(Ln,r)),da=0):(da=1,ya(Ln))}function Fn(){var t=null,n=va,e=1/0;while(n)n.flush?(delete ma[n.callback.id],n=t?t.next=n.next:va=n.next):(e=Math.min(e,n.then+n.delay),n=(t=n).next);return e}function Hn(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>Ma&&(window.scrollX||window.scrollY)){e=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=e[0][0].getScreenCTM();Ma=!(i.f||i.e),e.remove()}return Ma?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[n.clientX-u.left-t.clientLeft,n.clientY-u.top-t.clientTop]}function jn(){}function On(t){var n=t[0],e=t[t.length-1];return e>n?[n,e]:[e,n]}function Rn(t){return t.rangeExtent?t.rangeExtent():On(t.range())}function Yn(t,n){var e,r=0,i=t.length-1,u=t[r],a=t[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),(n=n(a-u))&&(t[r]=n.floor(u),t[i]=n.ceil(a)),t}function Un(){return Math}function In(t,n,e,r){function i(){var i=Math.min(t.length,n.length)>2?Jn:Gn,l=r?B:Z;return a=i(t,n,l,e),o=i(n,t,l,d3.interpolate),u}function u(t){return a(t)}var a,o;return u.invert=function(t){return o(t)},u.domain=function(n){return arguments.length?(t=n.map(Number),i()):t},u.range=function(t){return arguments.length?(n=t,i()):n},u.rangeRound=function(t){return u.range(t).interpolate(d3.interpolateRound)},u.clamp=function(t){return arguments.length?(r=t,i()):r},u.interpolate=function(t){return arguments.length?(e=t,i()):e},u.ticks=function(n){return Xn(t,n)},u.tickFormat=function(n){return $n(t,n)},u.nice=function(){return Yn(t,Zn),i()},u.copy=function(){return In(t,n,e,r)},i()}function Vn(t,n){return d3.rebind(t,n,"range","rangeRound","interpolate","clamp")}function Zn(t){return t=Math.pow(10,Math.round(Math.log(t)/Math.LN10)-1),t&&{floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}}}function Bn(t,n){var e=On(t),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/n)/Math.LN10)),u=n/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+i*.5,e[2]=i,e}function Xn(t,n){return d3.range.apply(d3,Bn(t,n))}function $n(t,n){return d3.format(",."+Math.max(0,-Math.floor(Math.log(Bn(t,n)[2])/Math.LN10+.01))+"f")}function Gn(t,n,e,r){var i=e(t[0],t[1]),u=r(n[0],n[1]);return function(t){return u(i(t))}}function Jn(t,n,e,r){var i=[],u=[],a=0,o=Math.min(t.length,n.length)-1;t[0]>t[o]&&(t=t.slice().reverse(),n=n.slice().reverse());while(o>=++a)i.push(e(t[a-1],t[a])),u.push(r(n[a-1],n[a]));return function(n){var e=d3.bisect(t,n,1,o)-1;return u[e](i[e](n))}}function Kn(t,n){function e(e){return t(n(e))}var r=n.pow;return e.invert=function(n){return r(t.invert(n))},e.domain=function(i){return arguments.length?(n=0>i[0]?Qn:Wn,r=n.pow,t.domain(i.map(n)),e):t.domain().map(r)},e.nice=function(){return t.domain(Yn(t.domain(),Un)),e},e.ticks=function(){var e=On(t.domain()),i=[];if(e.every(isFinite)){var u=Math.floor(e[0]),a=Math.ceil(e[1]),o=r(e[0]),l=r(e[1]);if(n===Qn)for(i.push(r(u));a>u++;)for(var c=9;c>0;c--)i.push(r(u)*c);else{for(;a>u;u++)for(var c=1;10>c;c++)i.push(r(u)*c);i.push(r(u))}for(u=0;o>i[u];u++);for(a=i.length;i[a-1]>l;a--);i=i.slice(u,a)}return i},e.tickFormat=function(t,i){if(2>arguments.length&&(i=ba),!arguments.length)return i;var u,a=Math.max(.1,t/e.ticks().length),o=n===Qn?(u=-1e-12,Math.floor):(u=1e-12,Math.ceil);return function(t){return a>=t/r(o(n(t)+u))?i(t):""}},e.copy=function(){return Kn(t.copy(),n)},Vn(e,t)}function Wn(t){return Math.log(0>t?0:t)/Math.LN10}function Qn(t){return-Math.log(t>0?0:-t)/Math.LN10}function te(t,n){function e(n){return t(r(n))}var r=ne(n),i=ne(1/n);return e.invert=function(n){return i(t.invert(n))},e.domain=function(n){return arguments.length?(t.domain(n.map(r)),e):t.domain().map(i)},e.ticks=function(t){return Xn(e.domain(),t)},e.tickFormat=function(t){return $n(e.domain(),t)},e.nice=function(){return e.domain(Yn(e.domain(),Zn))},e.exponent=function(t){if(!arguments.length)return n;var u=e.domain();return r=ne(n=t),i=ne(1/n),e.domain(u)},e.copy=function(){return te(t.copy(),n)},Vn(e,t)}function ne(t){return function(n){return 0>n?-Math.pow(-n,t):Math.pow(n,t)}}function ee(t,n){function e(n){return u[((i.get(n)||i.set(n,t.push(n)))-1)%u.length]}function r(n,e){return d3.range(t.length).map(function(t){return n+e*t})}var i,u,o;return e.domain=function(r){if(!arguments.length)return t;t=[],i=new a;var u,o=-1,l=r.length;while(l>++o)i.has(u=r[o])||i.set(u,t.push(u));return e[n.t].apply(e,n.a)},e.range=function(t){return arguments.length?(u=t,o=0,n={t:"range",a:arguments},e):u},e.rangePoints=function(i,a){2>arguments.length&&(a=0);var l=i[0],c=i[1],s=(c-l)/(Math.max(1,t.length-1)+a);return u=r(2>t.length?(l+c)/2:l+s*a/2,s),o=0,n={t:"rangePoints",a:arguments},e},e.rangeBands=function(i,a,l){2>arguments.length&&(a=0),3>arguments.length&&(l=a);var c=i[0]>i[1],s=i[c-0],f=i[1-c],h=(f-s)/(t.length-a+2*l);return u=r(s+h*l,h),c&&u.reverse(),o=h*(1-a),n={t:"rangeBands",a:arguments},e},e.rangeRoundBands=function(i,a,l){2>arguments.length&&(a=0),3>arguments.length&&(l=a);var c=i[0]>i[1],s=i[c-0],f=i[1-c],h=Math.floor((f-s)/(t.length-a+2*l)),d=f-s-(t.length-a)*h;return u=r(s+Math.round(d/2),h),c&&u.reverse(),o=Math.round(h*(1-a)),n={t:"rangeRoundBands",a:arguments},e},e.rangeBand=function(){return o},e.rangeExtent=function(){return On(n.a[0])},e.copy=function(){return ee(t,n)},e.domain(t)}function re(t,n){function e(){var e=0,u=n.length;i=[];while(u>++e)i[e-1]=d3.quantile(t,e/u);return r}function r(t){return isNaN(t=+t)?0/0:n[d3.bisect(i,t)]}var i;return r.domain=function(n){return arguments.length?(t=n.filter(function(t){return!isNaN(t)}).sort(d3.ascending),e()):t},r.range=function(t){return arguments.length?(n=t,e()):n},r.quantiles=function(){return i},r.copy=function(){return re(t,n)},e()}function ie(t,n,e){function r(n){return e[Math.max(0,Math.min(a,Math.floor(u*(n-t))))]}function i(){return u=e.length/(n-t),a=e.length-1,r}var u,a;return r.domain=function(e){return arguments.length?(t=+e[0],n=+e[e.length-1],i()):[t,n]},r.range=function(t){return arguments.length?(e=t,i()):e},r.copy=function(){return ie(t,n,e)},i()}function ue(t,n){function e(e){return n[d3.bisect(t,e)]}return e.domain=function(n){return arguments.length?(t=n,e):t},e.range=function(t){return arguments.length?(n=t,e):n},e.copy=function(){return ue(t,n)},e}function ae(t){function n(t){return+t}return n.invert=n,n.domain=n.range=function(e){return arguments.length?(t=e.map(n),n):t},n.ticks=function(n){return Xn(t,n)},n.tickFormat=function(n){return $n(t,n)},n.copy=function(){return ae(t)},n}function oe(t){return t.innerRadius}function le(t){return t.outerRadius}function ce(t){return t.startAngle}function se(t){return t.endAngle}function fe(t){function n(n){function a(){s.push("M",u(t(f),o))}var l,s=[],f=[],h=-1,d=n.length,g=c(e),p=c(r);while(d>++h)i.call(this,l=n[h],h)?f.push([+g.call(this,l,h),+p.call(this,l,h)]):f.length&&(a(),f=[]);return f.length&&a(),s.length?s.join(""):null}var e=he,r=de,i=l,u=ge,a=u.key,o=.7;return n.x=function(t){return arguments.length?(e=t,n):e},n.y=function(t){return arguments.length?(r=t,n):r},n.defined=function(t){return arguments.length?(i=t,n):i},n.interpolate=function(t){return arguments.length?(a=typeof t=="function"?u=t:(u=Aa.get(t)||ge).key,n):a},n.tension=function(t){return arguments.length?(o=t,n):o},n}function he(t){return t[0]}function de(t){return t[1]}function ge(t){return t.join("L")}function pe(t){return ge(t)+"Z"}function me(t){var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];while(e>++n)i.push("V",(r=t[n])[1],"H",r[0]);return i.join("")}function ve(t){var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];while(e>++n)i.push("H",(r=t[n])[0],"V",r[1]);return i.join("")}function ye(t,n){return 4>t.length?ge(t):t[1]+xe(t.slice(1,t.length-1),we(t,n))}function Me(t,n){return 3>t.length?ge(t):t[0]+xe((t.push(t[0]),t),we([t[t.length-2]].concat(t,[t[1]]),n))}function be(t,n){return 3>t.length?ge(t):t[0]+xe(t,we(t,n))}function xe(t,n){if(1>n.length||t.length!=n.length&&t.length!=n.length+2)return ge(t);var e=t.length!=n.length,r="",i=t[0],u=t[1],a=n[0],o=a,l=1;if(e&&(r+="Q"+(u[0]-a[0]*2/3)+","+(u[1]-a[1]*2/3)+","+u[0]+","+u[1],i=t[1],l=2),n.length>1){o=n[1],u=t[l],l++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var c=2;n.length>c;c++,l++)u=t[l],o=n[c],r+="S"+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1]}if(e){var s=t[l];r+="Q"+(u[0]+o[0]*2/3)+","+(u[1]+o[1]*2/3)+","+s[0]+","+s[1]}return r}function we(t,n){var e,r=[],i=(1-n)/2,u=t[0],a=t[1],o=1,l=t.length;while(l>++o)e=u,u=a,a=t[o],r.push([i*(a[0]-e[0]),i*(a[1]-e[1])]);return r}function _e(t){if(3>t.length)return ge(t);var n=1,e=t.length,r=t[0],i=r[0],u=r[1],a=[i,i,i,(r=t[1])[0]],o=[u,u,u,r[1]],l=[i,",",u];Ne(l,a,o);while(e>++n)r=t[n],a.shift(),a.push(r[0]),o.shift(),o.push(r[1]),Ne(l,a,o);n=-1;while(2>++n)a.shift(),a.push(r[0]),o.shift(),o.push(r[1]),Ne(l,a,o);return l.join("")}function ke(t){if(4>t.length)return ge(t);var n,e=[],r=-1,i=t.length,u=[0],a=[0];while(3>++r)n=t[r],u.push(n[0]),a.push(n[1]);e.push(Ae(qa,u)+","+Ae(qa,a)),--r;while(i>++r)n=t[r],u.shift(),u.push(n[0]),a.shift(),a.push(n[1]),Ne(e,u,a);return e.join("")}function Te(t){var n,e,r=-1,i=t.length,u=i+4,a=[],o=[];while(4>++r)e=t[r%i],a.push(e[0]),o.push(e[1]);n=[Ae(qa,a),",",Ae(qa,o)],--r;while(u>++r)e=t[r%i],a.shift(),a.push(e[0]),o.shift(),o.push(e[1]),Ne(n,a,o);return n.join("")}function Se(t,n){var e=t.length-1;if(e){var r,i,u=t[0][0],a=t[0][1],o=t[e][0]-u,l=t[e][1]-a,c=-1;while(e>=++c)r=t[c],i=c/e,r[0]=n*r[0]+(1-n)*(u+i*o),r[1]=n*r[1]+(1-n)*(a+i*l)}return _e(t)}function Ae(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]*n[3]}function Ne(t,n,e){t.push("C",Ae(Na,n),",",Ae(Na,e),",",Ae(Ca,n),",",Ae(Ca,e),",",Ae(qa,n),",",Ae(qa,e))}function Ce(t,n){return(n[1]-t[1])/(n[0]-t[0])}function qe(t){var n=0,e=t.length-1,r=[],i=t[0],u=t[1],a=r[0]=Ce(i,u);while(e>++n)r[n]=(a+(a=Ce(i=u,u=t[n+1])))/2;return r[n]=a,r}function ze(t){var n,e,r,i,u=[],a=qe(t),o=-1,l=t.length-1;while(l>++o)n=Ce(t[o],t[o+1]),1e-6>Math.abs(n)?a[o]=a[o+1]=0:(e=a[o]/n,r=a[o+1]/n,i=e*e+r*r,i>9&&(i=n*3/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));o=-1;while(l>=++o)i=(t[Math.min(l,o+1)][0]-t[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}function Ee(t){return 3>t.length?ge(t):t[0]+xe(t,ze(t))}function De(t){var n,e,r,i=-1,u=t.length;while(u>++i)n=t[i],e=n[0],r=n[1]+Ta,n[0]=e*Math.cos(r),n[1]=e*Math.sin(r);return t}function Pe(t){function n(n){function l(){m.push("M",o(t(y),d),h,f(t(v.reverse()),d),"Z")}var s,g,p,m=[],v=[],y=[],M=-1,b=n.length,x=c(e),w=c(i),_=e===r?function(){return g}:c(r),k=i===u?function(){return p}:c(u);while(b>++M)a.call(this,s=n[M],M)?(v.push([g=+x.call(this,s,M),p=+w.call(this,s,M)]),y.push([+_.call(this,s,M),+k.call(this,s,M)])):v.length&&(l(),v=[],y=[]);return v.length&&l(),m.length?m.join(""):null}var e=he,r=he,i=0,u=de,a=l,o=ge,s=o.key,f=o,h="L",d=.7;return n.x=function(t){return arguments.length?(e=r=t,n):r},n.x0=function(t){return arguments.length?(e=t,n):e},n.x1=function(t){return arguments.length?(r=t,n):r},n.y=function(t){return arguments.length?(i=u=t,n):u},n.y0=function(t){return arguments.length?(i=t,n):i},n.y1=function(t){return arguments.length?(u=t,n):u},n.defined=function(t){return arguments.length?(a=t,n):a},n.interpolate=function(t){return arguments.length?(s=typeof t=="function"?o=t:(o=Aa.get(t)||ge).key,f=o.reverse||o,h=o.closed?"M":"L",n):s},n.tension=function(t){return arguments.length?(d=t,n):d},n}function Le(t){return t.radius}function Fe(t){return[t.x,t.y]}function He(t){return function(){var n=t.apply(this,arguments),e=n[0],r=n[1]+Ta;return[e*Math.cos(r),e*Math.sin(r)]}}function je(){return 64}function Oe(){return"circle"}function Re(t){var n=Math.sqrt(t/_u);return"M0,"+n+"A"+n+","+n+" 0 1,1 0,"+-n+"A"+n+","+n+" 0 1,1 0,"+n+"Z"}function Ye(t,n){t.attr("transform",function(t){return"translate("+n(t)+",0)"})}function Ue(t,n){t.attr("transform",function(t){return"translate(0,"+n(t)+")"})}function Ie(t,n,e){if(r=[],e&&n.length>1){var r,i,u,a=On(t.domain()),o=-1,l=n.length,c=(n[1]-n[0])/++e;while(l>++o)for(i=e;--i>0;)(u=+n[o]-i*c)>=a[0]&&r.push(u);for(--o,i=0;e>++i&&a[1]>(u=+n[o]+i*c);)r.push(u)}return r}function Ve(){Fa||(Fa=d3.select("body").append("div").style("visibility","hidden").style("top",0).style("height",0).style("width",0).style("overflow-y","scroll").append("div").style("height","2000px").node().parentNode);var t,n=d3.event;try{Fa.scrollTop=1e3,Fa.dispatchEvent(n),t=1e3-Fa.scrollTop}catch(e){t=n.wheelDelta||-n.detail*5}return t}function Ze(t){var n=t.source,e=t.target,r=Xe(n,e),i=[n];while(n!==r)n=n.parent,i.push(n);var u=i.length;while(e!==r)i.splice(u,0,e),e=e.parent;return i}function Be(t){var n=[],e=t.parent;while(e!=null)n.push(t),t=e,e=e.parent;return n.push(t),n}function Xe(t,n){if(t===n)return t;var e=Be(t),r=Be(n),i=e.pop(),u=r.pop(),a=null;while(i===u)a=i,i=e.pop(),u=r.pop();return a}function $e(t){t.fixed|=2}function Ge(t){t.fixed&=1}function Je(t){t.fixed|=4}function Ke(t){t.fixed&=3}function We(t,n,e){var r=0,i=0;if(t.charge=0,!t.leaf){var u,a=t.nodes,o=a.length,l=-1;while(o>++l)u=a[l],u!=null&&(We(u,n,e),t.charge+=u.charge,r+=u.charge*u.cx,i+=u.charge*u.cy)}if(t.point){t.leaf||(t.point.x+=Math.random()-.5,t.point.y+=Math.random()-.5);var c=n*e[t.point.index];t.charge+=t.pointCharge=c,r+=c*t.point.x,i+=c*t.point.y}t.cx=r/t.charge,t.cy=i/t.charge}function Qe(){return 20}function tr(){return 1}function nr(t){return t.x}function er(t){return t.y}function rr(t,n,e){t.y0=n,t.y=e}function ir(t){return d3.range(t.length)}function ur(t){var n=-1,e=t[0].length,r=[];while(e>++n)r[n]=0;return r}function ar(t){for(var n,e=1,r=0,i=t[0][1],u=t.length;u>e;++e)(n=t[e][1])>i&&(r=e,i=n);return r}function or(t){return t.reduce(lr,0)}function lr(t,n){return t+n[1]}function cr(t,n){return sr(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function sr(t,n){var e=-1,r=+t[0],i=(t[1]-r)/n,u=[];while(n>=++e)u[e]=i*e+r;return u}function fr(t){return[d3.min(t),d3.max(t)]}function hr(t,n){return d3.rebind(t,n,"sort","children","value"),t.links=mr,t.nodes=function(n){return Ya=!0,(t.nodes=t)(n)},t}function dr(t){return t.children}function gr(t){return t.value}function pr(t,n){return n.value-t.value}function mr(t){return d3.merge(t.map(function(t){return(t.children||[]).map(function(n){return{source:t,target:n}})}))}function vr(t,n){return t.value-n.value}function yr(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function Mr(t,n){t._pack_next=n,n._pack_prev=t}function br(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return i*i-e*e-r*r>.001}function xr(t){function n(t){s=Math.min(t.x-t.r,s),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((e=t.children)&&(c=e.length)){var e,r,i,u,a,o,l,c,s=1/0,f=-1/0,h=1/0,d=-1/0;if(e.forEach(wr),r=e[0],r.x=-r.r,r.y=0,n(r),c>1&&(i=e[1],i.x=i.r,i.y=0,n(i),c>2))for(u=e[2],Tr(r,i,u),n(u),yr(r,u),r._pack_prev=u,yr(u,i),i=r._pack_next,a=3;c>a;a++){Tr(r,i,u=e[a]);var g=0,p=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,p++)if(br(o,u)){g=1;break}if(g==1)for(l=r._pack_prev;l!==o._pack_prev;l=l._pack_prev,m++)if(br(l,u))break;g?(m>p||p==m&&r.r>i.r?Mr(r,i=o):Mr(r=l,i),a--):(yr(r,u),i=u,n(u))}var v=(s+f)/2,y=(h+d)/2,M=0;for(a=0;c>a;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));t.r=M,e.forEach(_r)}}function wr(t){t._pack_next=t._pack_prev=t}function _r(t){delete t._pack_next,delete t._pack_prev}function kr(t,n,e,r){var i=t.children;if(t.x=n+=r*t.x,t.y=e+=r*t.y,t.r*=r,i){var u=-1,a=i.length;while(a>++u)kr(i[u],n,e,r)}}function Tr(t,n,e){var r=t.r+e.r,i=n.x-t.x,u=n.y-t.y;if(r&&(i||u)){var a=n.r+e.r,o=i*i+u*u;a*=a,r*=r;var l=.5+(r-a)/(2*o),c=Math.sqrt(Math.max(0,2*a*(r+o)-(r-=o)*r-a*a))/(2*o);e.x=t.x+l*i+c*u,e.y=t.y+l*u-c*i}else e.x=t.x+r,e.y=t.y}function Sr(t){return 1+d3.max(t,function(t){return t.y})}function Ar(t){return t.reduce(function(t,n){return t+n.x},0)/t.length}function Nr(t){var n=t.children;return n&&n.length?Nr(n[0]):t}function Cr(t){var n,e=t.children;return e&&(n=e.length)?Cr(e[n-1]):t}function qr(t,n){return t.parent==n.parent?1:2}function zr(t){var n=t.children;return n&&n.length?n[0]:t._tree.thread}function Er(t){var n,e=t.children;return e&&(n=e.length)?e[n-1]:t._tree.thread}function Dr(t,n){var e=t.children;if(e&&(i=e.length)){var r,i,u=-1;while(i>++u)n(r=Dr(e[u],n),t)>0&&(t=r)}return t}function Pr(t,n){return t.x-n.x}function Lr(t,n){return n.x-t.x}function Fr(t,n){return t.depth-n.depth}function Hr(t,n){function e(t,r){var i=t.children;if(i&&(a=i.length)){var u,a,o=null,l=-1;while(a>++l)u=i[l],e(u,o),o=u}n(t,r)}e(t,null)}function jr(t){var n,e=0,r=0,i=t.children,u=i.length;while(--u>=0)n=i[u]._tree,n.prelim+=e,n.mod+=e,e+=n.shift+(r+=n.change)}function Or(t,n,e){t=t._tree,n=n._tree;var r=e/(n.number-t.number);t.change+=r,n.change-=r,n.shift+=e,n.prelim+=e,n.mod+=e}function Rr(t,n,e){return t._tree.ancestor.parent==n.parent?t._tree.ancestor:e}function Yr(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Ur(t,n){var e=t.x+n[3],r=t.y+n[0],i=t.dx-n[1]-n[3],u=t.dy-n[0]-n[2];return 0>i&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Ir(t,n){function e(t,e){return d3.xhr(t,n,e).response(r)}function r(t){return e.parse(t.responseText)}function i(n){return n.map(u).join(t)}function u(t){return a.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var a=RegExp('["'+t+"\n]"),o=t.charCodeAt(0);return e.parse=function(t){var n;return e.parseRows(t,function(t){return n?n(t):(n=Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}"),void 0)})},e.parseRows=function(t,n){function e(){if(s>=c)return a;if(i)return i=!1,u;var n=s;if(t.charCodeAt(n)===34){var e=n;while(c>e++)if(t.charCodeAt(e)===34){if(t.charCodeAt(e+1)!==34)break;++e}s=e+2;var r=t.charCodeAt(e+1);return r===13?(i=!0,t.charCodeAt(e+2)===10&&++s):r===10&&(i=!0),t.substring(n+1,e).replace(/""/g,'"')}while(c>s){var r=t.charCodeAt(s++),l=1;if(r===10)i=!0;else if(r===13)i=!0,t.charCodeAt(s)===10&&(++s,++l);else if(r!==o)continue;return t.substring(n,s-l)}return t.substring(n)}var r,i,u={},a={},l=[],c=t.length,s=0,f=0;while((r=e())!==a){var h=[];while(r!==u&&r!==a)h.push(r),r=e();(!n||(h=n(h,f++)))&&l.push(h)}return l},e.format=function(t){return t.map(i).join("\n")},e}function Vr(t){for(var n in Ua)n in t||(t[n]=Ua[n]);return t}function Zr(t,n){function e(t,n){var e=Math.sqrt(u-2*i*Math.sin(n))/i;return[e*Math.sin(t*=i),a-e*Math.cos(t)]}var r=Math.sin(t),i=(r+Math.sin(n))/2,u=1+r*(2*i-r),a=Math.sqrt(u)/i;return e.invert=function(t,n){var e=a-n;return[Math.atan2(t,e)/i,Math.asin((u-(t*t+e*e)*i*i)/(2*i))]},e}function Br(t){var n,e,r,i,u=Vr({point:function(u){u=t(u);var a=u[0],o=u[1];n>a&&(n=a),a>r&&(r=a),e>o&&(e=o),o>i&&(i=o)},polygon:function(t){this.line(t[0])}});return function(t){return i=r=-(n=e=1/0),u.object(t),[[n,e],[r,i]]}}function Xr(t,n){function e(t){return Math.cos(t[1])*Math.cos(t[0])>a}function r(t,r,u){if(o=t.length){var a,o,l,c,s=n(t[0]),f=e(s),h=u!=null,d=h&&f;f&&r.moveTo((l=s)[0],s[1]);for(var g=1;o>g;g++){var p=n(t[g]),m=e(p);m!==f&&((f=m)?(a=i(p,s),(!c||Math.abs(c[0]-a[0])>ku||Math.abs(c[1]-a[1])>ku)&&(l&&(h=!1),r.moveTo((l=a)[0],a[1])),h&&(u+=oi(a,p)),s=a):(c=a=i(s,p),r.lineTo(a[0],a[1]),h&&(Math.abs(l[0]-a[0])>ku||Math.abs(l[1]-a[1])>ku?h=!1:u+=oi(s,l)),s=a)),h&&(u+=oi(s,p)),m&&r.lineTo(p[0],p[1]),s=p}return d&&m&&r.closePath(),h&&(!l||ku>Math.abs(l[0]-s[0])&&ku>Math.abs(l[1]-s[1]))&&u}}function i(t,n){var e=Qr(t,[0,0,0]),r=Qr(n,[0,0,0]),i=[1,0,0],u=ei(e,r),o=ni(u,u),l=u[0],c=o-l*l;if(!c)return t;var s=a*o/c,f=-a*l/c,h=ei(i,u),d=ii(i,s),g=ii(u,f);ri(d,g);var p=h,m=ni(d,p),v=ni(p,p),y=Math.sqrt(m*m-v*(ni(d,d)-1)),M=ii(p,(-m-y)/v);return ri(M,d),ti(M)}var u=t*Su,a=Math.cos(u),o=[a,0,0],l=Wr(o),c=$r(u,6*Su);return{point:function(t,r){e(t=n(t))&&r.point(t[0],t[1])},line:function(t,n){r(t,n)},polygon:function(t,n){Gr(t,n,r,c,l)}}}function $r(t,n){var e=Math.cos(t),r=Math.sin(t);return function(t,i,u,a){var o=u*n;t=t.angle,i=i.angle,i>t&&(t+=2*_u);for(var o=n,l=t;u>0?l>i:i>l;l-=o){var c=Math.cos(l),s=Math.sin(l),f=ti([e,-r*c,-r*s]);a.lineTo(f[0],f[1])}}}function Gr(t,n,e,r,i){var u=[],a=[],o=[],l=ai(e),c=0,s=0;if(t.forEach(function(t){var e=l(t,n),r=e[1];c+=e[0];var i=r.length;if(i){if(s+=i,typeof e[0]=="number"){var u=r[0],a=u[0],i=u.length-1,f=0;n.moveTo(a[0],a[1]);while(i>++f)n.lineTo((a=u[f])[0],a[1]);return n.closePath(),void 0}o=o.concat(r)}}),s?c>0:0>c){var f=!1;li(r,{lineTo:function(t,e){(f?n.lineTo:(f=!0,n.moveTo))(t,e)}}),n.closePath()}if(o.forEach(function(t){var n=t[0],e=t[t.length-1],r={point:n,points:t,other:null,visited:!1,entry:!0,subject:!0},o={point:n,angle:i(n),points:[n],other:r,visited:!1,entry:!1,subject:!1};r.other=o,u.push(r),a.push(o),r={point:e,points:[e],other:null,visited:!1,entry:!1,subject:!0},o={point:e,angle:i(e),points:[e],other:r,visited:!1,entry:!0,subject:!1},r.other=o,u.push(r),a.push(o)}),a.sort(Kr),Jr(u),Jr(a),u.length)for(var h,d,g,p=u[0];;){h=p;while(h.visited)if((h=h.next)===p)return;d=h.points,n.moveTo((g=d.shift())[0],g[1]);do{if(h.visited=h.other.visited=!0,h.entry){if(h.subject)for(var m=0;d.length>m;m++)n.lineTo((g=d[m])[0],g[1]);else r(h,h.next,1,n);h=h.next}else{if(h.subject){d=h.prev.points;for(var m=d.length;--m>=0;)n.lineTo((g=d[m])[0],g[1])}else r(h,h.prev,-1,n);h=h.prev}h=h.other,d=h.points}while(!h.visited);n.closePath()}}function Jr(t){for(var n,e=0,r=t[0],i=t.length;i>e;)r.next=n=t[++e%i],n.prev=r,r=n}function Kr(t,n){return n.angle-t.angle}function Wr(t){return function(n){var e=Qr(n,t);ui(e);var r=Math.acos(Math.max(-1,Math.min(1,-e[1])));return((0>-e[2]?-r:r)+2*Math.PI)%(2*Math.PI)}}function Qr(t,n){var e=t[0],r=t[1],i=Math.cos(r);return[i*Math.cos(e)-n[0],i*Math.sin(e)-n[1],Math.sin(r)-n[2]]}function ti(t){return[Math.atan2(t[1],t[0]),Math.asin(Math.max(-1,Math.min(1,t[2])))]}function ni(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ei(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function ri(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function ii(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function ui(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function ai(t){return function(n){var e,r=[];return[t(n,{point:jn,moveTo:function(t,n){r.push(e=[[t,n]])},lineTo:function(t,n){e.push([t,n])},closePath:function(){2>r.length||(r.pop(),r.push(e=e.concat(r.shift())))}},0),r]}}function oi(t,n){var e=Math.cos(t[1]),r=1+Math.cos(t[0])*e,i=Math.cos(n[1]),u=1+Math.cos(n[0])*i;if(t=[e*Math.sin(t[0])/r,Math.sin(t[1])/r],n=[i*Math.sin(n[0])/u,Math.sin(n[1])/u],0>=t[1]){if(n[1]>0&&(t[0]-n[0])*t[1]+t[0]*(n[1]-t[1])>0)return 1 -}else if(0>=n[1]&&0>(t[0]-n[0])*t[1]+t[0]*(n[1]-t[1]))return-1;return 0}function li(t,n){for(var e=0;4>e;e++)t({angle:-e*_u/2},{angle:-(e+1)*_u/2},1,n)}function ci(t,n){function e(e,r){var i=t(e,r);return n(i[0],i[1])}return t===si?n:n===si?t:(t.invert&&n.invert&&(e.invert=function(e,r){var i=n.invert(e,r);return t.invert(i[0],i[1])}),e)}function si(t,n){return[t,n]}function fi(t,n,e){var r=d3.range(t,n-ku,e).concat(n);return function(t){return r.map(function(n){return[t,n]})}}function hi(t,n,e){var r=d3.range(t,n-ku,e).concat(n);return function(t){return r.map(function(n){return[n,t]})}}function di(){function t(t){var n=Math.sin(t*=d)*g,e=Math.sin(d-t)*g,r=e*u+n*f,o=e*a+n*h,l=e*i+n*s;return[Math.atan2(o,r)/Su,Math.atan2(l,Math.sqrt(r*r+o*o))/Su]}var n,e,r,i,u,a,o,l,c,s,f,h,d,g;return t.distance=function(){return d==null&&(g=1/Math.sin(d=Math.acos(Math.max(-1,Math.min(1,i*s+r*c*Math.cos(o-n)))))),d},t.source=function(o){var l=Math.cos(n=o[0]*Su),c=Math.sin(n);return r=Math.cos(e=o[1]*Su),i=Math.sin(e),u=r*l,a=r*c,d=null,t},t.target=function(n){var e=Math.cos(o=n[0]*Su),r=Math.sin(o);return c=Math.cos(l=n[1]*Su),s=Math.sin(l),f=c*e,h=c*r,d=null,t},t}function gi(t,n){return[t/(2*_u),Math.max(-.5,Math.min(.5,Math.log(Math.tan(_u/4+n/2))/(2*_u)))]}function pi(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function mi(t){return function(n){var e=[0,0],r=t(e,n.coordinates,0);return r?(e[0]/=r,e[1]/=r,e):null}}function vi(t){return function(n){for(var e=[0,0],r=0,i=n.coordinates,u=0,a=i.length;a>u;++u)r+=t(e,i[u],u);return r?(e[0]/=r,e[1]/=r,e):null}}function yi(t){return function(n){for(var e=[0,0],r=0,i=n.coordinates,u=0,a=i.length;a>u;++u)for(var o=i[u],l=0,c=o.length;c>l;++l)r+=t(e,o[l],l);return r?(e[0]/=r,e[1]/=r,e):null}}function Mi(t){return bi(function(){return t})()}function bi(t){function n(t){return t=d(t[0]*Su,t[1]*Su),[t[0]*p+_,k-t[1]*p]}function e(t){return t=d.invert((t[0]-_)/p,(k-t[1])/p),[t[0]*Au,t[1]*Au]}function r(t,n){var e=c(t,n);g.point(e[0],e[1])}function i(t,n){var e=c(N=q=t,C=n);z=Math.sin(n),E=Math.cos(n),g.moveTo(D=e[0],P=e[1])}function u(t,n){var e=c(t,n);a(D,P,q,z,E,D=e[0],P=e[1],q=t,z=Math.sin(n),E=Math.cos(n),L),g.lineTo(D,P)}function a(t,n,e,r,i,u,o,l,s,f,h){var d=u-t,p=o-n,m=d*d+p*p;if(m>4*T&&h--){var v=r*s+i*f*Math.cos(l-e),y=1/(Math.SQRT2*Math.sqrt(1+v)),M=y*(i*Math.cos(e)+f*Math.cos(l)),b=y*(i*Math.sin(e)+f*Math.sin(l)),x=Math.max(-1,Math.min(1,y*(r+s))),w=Math.asin(x),_=Math.abs(Math.abs(x)-1),k=ku>_||Tu>_&&(Tu>Math.abs(i)||Tu>Math.abs(f))?(e+l)/2:Math.atan2(b,M),S=c(k,w),A=S[0],N=S[1],C=t-A,q=n-N,z=d*q-p*C;if(z*z/m>T){var E=Math.cos(w);a(t,n,e,r,i,A,N,k,x,E,h),g.lineTo(A,N),a(A,N,k,x,E,u,o,l,s,f,h)}}}function o(){var t=c(N,C);a(D,P,q,z,E,t[0],t[1],N,Math.sin(C),Math.cos(C),L),g.closePath()}function l(t){return h(t[0]*Su,t[1]*Su)}function c(t,n){var e=f(t,n);return[e[0]*p+_,k-e[1]*p]}function s(){d=ci(h=Ti(b,x,w),f);var t=f(y,M);return _=m-t[0]*p,k=v+t[1]*p,n}var f,h,d,g,p=150,m=480,v=250,y=0,M=0,b=0,x=0,w=0,_=m,k=v,T=.5,S=wi(l),A=null;n.point=function(t,n){g=n,S.point(t,F),g=null},n.line=function(t,n){g=n,S.line(t,F),g=null},n.polygon=function(t,n){g=n,S.polygon(t,F),g=null},n.clipAngle=function(t){return arguments.length?(S=t==null?(A=t,wi(l)):Xr(A=+t,l),n):A};var N,C,q,z,E,D,P,L=16,F={point:r,moveTo:i,lineTo:u,closePath:o};return n.scale=function(t){return arguments.length?(p=+t,s()):p},n.translate=function(t){return arguments.length?(m=+t[0],v=+t[1],s()):[m,v]},n.center=function(t){return arguments.length?(y=t[0]%360*Su,M=t[1]%360*Su,s()):[y*Au,M*Au]},n.rotate=function(t){return arguments.length?(b=t[0]%360*Su,x=t[1]%360*Su,w=t.length>2?t[2]%360*Su:0,s()):[b*Au,x*Au,w*Au]},n.precision=function(t){return arguments.length?(L=(T=t*t)>0&&16,n):Math.sqrt(T)},function(){return f=t.apply(this,arguments),n.invert=f.invert&&e,s()}}function xi(t,n,e,r){var i,u,a=Math.sin(t-e);return Math.abs(a)>ku?Math.atan((Math.sin(n)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*u*a)):(n+r)/2}function wi(t){var n={point:function(n,e){var r=t(n);e.point(r[0],r[1])},line:function(n,e,r){if(l=n.length){var i,u,a,o,l,c=t(n[0]),s=!0,f=c[0],h=c[1],d=f>0?_u:-_u,g=0;e.moveTo(f,h);while(l>++g)c=t(n[g]),i=c[0],u=c[1],a=i>0?_u:-_u,o=Math.abs(i-f),ku>Math.abs(o-_u)?(e.lineTo(f,h=(h+u)/2>0?_u/2:-_u/2),e.lineTo(d,h),e.moveTo(a,h),e.lineTo(i,h),e.lineTo(f=i,h=u),s=!1):d!==a&&o>=_u?(h=xi(f,h,i,u),Math.abs(f-d)>ku&&e.lineTo(d,h),Math.abs(i-a)>ku?(e.moveTo(a,h),e.lineTo(f=i,h=u)):e.moveTo(f=i,h=u),s=!1):e.lineTo(f=i,h=u),d=a;return r!=null&&e.closePath(),s&&r}},polygon:function(t,e){Gr(t,e,n.line,ki,_i)}};return n}function _i(t){return-(0>t[0]?t[1]-_u/2:_u/2-t[1])}function ki(t,n,e,r){if(t=t.point,n=n.point,Math.abs(t[0]-n[0])>ku){var i=(n[0]>t[0]?1:-1)*e*_u,u=i/2;r.lineTo(-i,u),r.lineTo(0,u),r.lineTo(i,u)}else r.lineTo(n[0],n[1])}function Ti(t,n,e){return t?n||e?ci(Ni(t),Ci(n,e)):Ni(t):n||e?Ci(n,e):Si}function Si(t,n){return[t>_u?t-2*_u:-_u>t?t+2*_u:t,n]}function Ai(t){return function(n,e){return[(n+=t)>_u?n-2*_u:-_u>n?n+2*_u:n,e]}}function Ni(t){var n=Ai(t);return n.invert=Ai(-t),n}function Ci(t,n){function e(t,n){var e=Math.cos(n),o=Math.cos(t)*e,l=Math.sin(t)*e,c=Math.sin(n),s=c*r+o*i;return[Math.atan2(l*u-s*a,o*r-c*i),Math.asin(Math.max(-1,Math.min(1,s*u+l*a)))]}var r=Math.cos(t),i=Math.sin(t),u=Math.cos(n),a=Math.sin(n);return e.invert=function(t,n){var e=Math.cos(n),o=Math.cos(t)*e,l=Math.sin(t)*e,c=Math.sin(n),s=c*u-l*a;return[Math.atan2(l*u+c*a,o*r+s*i),Math.asin(Math.max(-1,Math.min(1,s*r-o*i)))]},e}function qi(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),u=t(r*i);return[u*i*Math.sin(n),u*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*u,r*a),Math.asin(r&&e*u/r)]},e}function zi(t,n,e,r){var i,u,a,o,l,c,s;return i=r[t],u=i[0],a=i[1],i=r[n],o=i[0],l=i[1],i=r[e],c=i[0],s=i[1],(s-a)*(o-u)-(l-a)*(c-u)>0}function Ei(t,n,e){return(e[1]-n[1])*(t[0]-n[0])>(e[0]-n[0])*(t[1]-n[1])}function Di(t,n,e,r){var i=t[0],u=e[0],a=n[0]-i,o=r[0]-u,l=t[1],c=e[1],s=n[1]-l,f=r[1]-c,h=(o*(l-c)-f*(i-u))/(f*a-o*s);return[i+h*a,l+h*s]}function Pi(t,n){var e={list:t.map(function(t,n){return{index:n,x:t[0],y:t[1]}}).sort(function(t,n){return n.y>t.y?-1:t.y>n.y?1:n.x>t.x?-1:t.x>n.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(t,n){return{edge:t,side:n,vertex:null,l:null,r:null}},insert:function(t,n){n.l=t,n.r=t.r,t.r.l=n,t.r=n},leftBound:function(t){var n=r.leftEnd;do n=n.r;while(n!=r.rightEnd&&i.rightOf(n,t));return n=n.l},del:function(t){t.l.r=t.r,t.r.l=t.l,t.edge=null},right:function(t){return t.r},left:function(t){return t.l},leftRegion:function(t){return t.edge==null?e.bottomSite:t.edge.region[t.side]},rightRegion:function(t){return t.edge==null?e.bottomSite:t.edge.region[Ja[t.side]]}},i={bisect:function(t,n){var e={region:{l:t,r:n},ep:{l:null,r:null}},r=n.x-t.x,i=n.y-t.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=t.x*r+t.y*i+(r*r+i*i)*.5,u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(t,n){var e=t.edge,r=n.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(1e-10>Math.abs(i))return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,l=(r.c*e.a-e.c*r.a)/i,c=e.region.r,s=r.region.r;s.y>c.y||c.y==s.y&&s.x>c.x?(u=t,a=e):(u=n,a=r);var f=o>=a.region.r.x;return f&&u.side==="l"||!f&&u.side==="r"?null:{x:o,y:l}},rightOf:function(t,n){var e=t.edge,r=e.region.r,i=n.x>r.x;if(i&&t.side==="l")return 1;if(!i&&t.side==="r")return 0;if(e.a===1){var u=n.y-r.y,a=n.x-r.x,o=0,l=0;if(!i&&0>e.b||i&&e.b>=0?l=o=u>=e.b*a:(l=n.x+n.y*e.b>e.c,0>e.b&&(l=!l),l||(o=1)),!o){var c=r.x-e.region.l.x;l=c*u*(1+2*a/c+e.b*e.b)>e.b*(a*a-u*u),0>e.b&&(l=!l)}}else{var s=e.c-e.a*n.x,f=n.y-s,h=n.x-r.x,d=s-r.y;l=f*f>h*h+d*d}return t.side==="l"?l:!l},endPoint:function(t,e,r){t.ep[e]=r,t.ep[Ja[e]]&&n(t)},distance:function(t,n){var e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(t,n,e){t.vertex=n,t.ystar=n.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(t.ystar>o.ystar||t.ystar==o.ystar&&n.x>o.vertex.x))break}i.splice(r,0,t)},del:function(t){for(var n=0,e=u.list,r=e.length;r>n&&e[n]!=t;++n);e.splice(n,1)},empty:function(){return u.list.length===0},nextEvent:function(t){for(var n=0,e=u.list,r=e.length;r>n;++n)if(e[n]==t)return e[n+1];return null},min:function(){var t=u.list[0];return{x:t.vertex.x,y:t.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,l,c,s,f,h,d,g,p,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||a.y>M.y||M.y==a.y&&a.x>M.x))o=r.leftBound(M),l=r.right(o),h=r.rightRegion(o),v=i.bisect(h,M),f=r.createHalfEdge(v,"l"),r.insert(o,f),p=i.intersect(o,f),p&&(u.del(o),u.insert(o,p,i.distance(p,M))),o=f,f=r.createHalfEdge(v,"r"),r.insert(o,f),p=i.intersect(f,l),p&&u.insert(f,p,i.distance(p,M)),M=e.list.shift();else{if(u.empty())break;o=u.extractMin(),c=r.left(o),l=r.right(o),s=r.right(l),h=r.leftRegion(o),d=r.rightRegion(l),m=o.vertex,i.endPoint(o.edge,o.side,m),i.endPoint(l.edge,l.side,m),r.del(o),u.del(l),r.del(l),y="l",h.y>d.y&&(g=h,h=d,d=g,y="r"),v=i.bisect(h,d),f=r.createHalfEdge(v,y),r.insert(c,f),i.endPoint(v,Ja[y],m),p=i.intersect(c,f),p&&(u.del(c),u.insert(c,p,i.distance(p,h))),p=i.intersect(f,s),p&&u.insert(f,p,i.distance(p,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))n(o.edge)}function Li(){return{leaf:!0,nodes:[],point:null}}function Fi(t,n,e,r,i,u){if(!t(n,e,r,i,u)){var a=(e+i)*.5,o=(r+u)*.5,l=n.nodes;l[0]&&Fi(t,l[0],e,r,a,o),l[1]&&Fi(t,l[1],a,r,i,o),l[2]&&Fi(t,l[2],e,o,a,u),l[3]&&Fi(t,l[3],a,o,i,u)}}function Hi(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function ji(t,n,e,r){var i,u,a=0,o=n.length,l=e.length;while(o>a){if(r>=l)return-1;if(i=n.charCodeAt(a++),i===37){if(u=mo[n.charAt(a++)],!u||0>(r=u(t,e,r)))return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function Oi(t){return RegExp("^(?:"+t.map(d3.requote).join("|")+")","i")}function Ri(t){var n=new a,e=-1,r=t.length;while(r>++e)n.set(t[e].toLowerCase(),e);return n}function Yi(t,n,e){t+="";var r=t.length;return e>r?Array(e-r+1).join(n)+t:t}function Ui(t,n,e){lo.lastIndex=0;var r=lo.exec(n.substring(e));return r?e+=r[0].length:-1}function Ii(t,n,e){oo.lastIndex=0;var r=oo.exec(n.substring(e));return r?e+=r[0].length:-1}function Vi(t,n,e){fo.lastIndex=0;var r=fo.exec(n.substring(e));return r?(t.m=ho.get(r[0].toLowerCase()),e+=r[0].length):-1}function Zi(t,n,e){co.lastIndex=0;var r=co.exec(n.substring(e));return r?(t.m=so.get(r[0].toLowerCase()),e+=r[0].length):-1}function Bi(t,n,e){return ji(t,po.c+"",n,e)}function Xi(t,n,e){return ji(t,po.x+"",n,e)}function $i(t,n,e){return ji(t,po.X+"",n,e)}function Gi(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+4));return r?(t.y=+r[0],e+=r[0].length):-1}function Ji(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.y=Ki(+r[0]),e+=r[0].length):-1}function Ki(t){return t+(t>68?1900:2e3)}function Wi(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.m=r[0]-1,e+=r[0].length):-1}function Qi(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.d=+r[0],e+=r[0].length):-1}function tu(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.H=+r[0],e+=r[0].length):-1}function nu(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.M=+r[0],e+=r[0].length):-1}function eu(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+2));return r?(t.S=+r[0],e+=r[0].length):-1}function ru(t,n,e){vo.lastIndex=0;var r=vo.exec(n.substring(e,e+3));return r?(t.L=+r[0],e+=r[0].length):-1}function iu(t,n,e){var r=yo.get(n.substring(e,e+=2).toLowerCase());return r==null?-1:(t.p=r,e)}function uu(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=~~(Math.abs(n)/60),i=Math.abs(n)%60;return e+Yi(r,"0",2)+Yi(i,"0",2)}function au(t){return t.toISOString()}function ou(t,n,e){function r(n){var e=t(n),r=u(e,1);return r-n>n-e?e:r}function i(e){return n(e=t(new Ka(e-1)),1),e}function u(t,e){return n(t=new Ka(+t),e),t}function a(t,r,u){var a=i(t),o=[];if(u>1)while(r>a)e(a)%u||o.push(new Date(+a)),n(a,1);else while(r>a)o.push(new Date(+a)),n(a,1);return o}function o(t,n,e){try{Ka=Hi;var r=new Hi;return r._=t,a(r,n,e)}finally{Ka=Date}}t.floor=t,t.round=r,t.ceil=i,t.offset=u,t.range=a;var l=t.utc=lu(t);return l.floor=l,l.round=lu(r),l.ceil=lu(i),l.offset=lu(u),l.range=o,t}function lu(t){return function(n,e){try{Ka=Hi;var r=new Hi;return r._=n,t(r,e)._}finally{Ka=Date}}}function cu(t,n,e){function r(n){return t(n)}return r.invert=function(n){return fu(t.invert(n))},r.domain=function(n){return arguments.length?(t.domain(n),r):t.domain().map(fu)},r.nice=function(t){return r.domain(Yn(r.domain(),function(){return t}))},r.ticks=function(e,i){var u=su(r.domain());if(typeof e!="function"){var a=u[1]-u[0],o=a/e,l=d3.bisect(bo,o);if(l==bo.length)return n.year(u,e);if(!l)return t.ticks(e).map(fu);Math.log(bo[l]/o)>Math.log(o/bo[l-1])&&--l,e=n[l],i=e[1],e=e[0].range}return e(u[0],new Date(+u[1]+1),i)},r.tickFormat=function(){return e},r.copy=function(){return cu(t.copy(),n,e)},d3.rebind(r,t,"range","rangeRound","interpolate","clamp")}function su(t){var n=t[0],e=t[t.length-1];return e>n?[n,e]:[e,n]}function fu(t){return new Date(t)}function hu(t){return function(n){var e=t.length-1,r=t[e];while(!r[1](n))r=t[--e];return r[0](n)}}function du(t){var n=new Date(t,0,1);return n.setFullYear(t),n}function gu(t){var n=t.getFullYear(),e=du(n),r=du(n+1);return n+(t-e)/(r-e)}function pu(t){var n=new Date(Date.UTC(t,0,1));return n.setUTCFullYear(t),n}function mu(t){var n=t.getUTCFullYear(),e=pu(n),r=pu(n+1);return n+(t-e)/(r-e)}var vu=".",yu=",",Mu=[3,3];Date.now||(Date.now=function(){return+new Date});try{document.createElement("div").style.setProperty("opacity",0,"")}catch(bu){var xu=CSSStyleDeclaration.prototype,wu=xu.setProperty;xu.setProperty=function(t,n,e){wu.call(this,t,n+"",e)}}d3={version:"3.0.0pre"};var _u=Math.PI,ku=1e-6,Tu=.001,Su=_u/180,Au=180/_u,Nu=u;try{Nu(document.documentElement.childNodes)[0].nodeType}catch(Cu){Nu=i}var qu=[].__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};d3.map=function(t){var n=new a;for(var e in t)n.set(e,t[e]);return n},r(a,{has:function(t){return zu+t in this},get:function(t){return this[zu+t]},set:function(t,n){return this[zu+t]=n},remove:function(t){return t=zu+t,t in this&&delete this[t]},keys:function(){var t=[];return this.forEach(function(n){t.push(n)}),t},values:function(){var t=[];return this.forEach(function(n,e){t.push(e)}),t},entries:function(){var t=[];return this.forEach(function(n,e){t.push({key:n,value:e})}),t},forEach:function(t){for(var n in this)n.charCodeAt(0)===Eu&&t.call(this,n.substring(1),this[n])}});var zu="\0",Eu=zu.charCodeAt(0);d3.functor=c,d3.rebind=function(t,n){var e,r=1,i=arguments.length;while(i>++r)t[e=arguments[r]]=s(t,n,n[e]);return t},d3.ascending=function(t,n){return n>t?-1:t>n?1:t>=n?0:0/0},d3.descending=function(t,n){return t>n?-1:n>t?1:n>=t?0:0/0},d3.mean=function(t,n){var e,r=t.length,i=0,u=-1,a=0;if(arguments.length===1)while(r>++u)f(e=t[u])&&(i+=(e-i)/++a);else while(r>++u)f(e=n.call(t,t[u],u))&&(i+=(e-i)/++a);return a?i:void 0},d3.median=function(t,n){return arguments.length>1&&(t=t.map(n)),t=t.filter(f),t.length?d3.quantile(t.sort(d3.ascending),.5):void 0},d3.min=function(t,n){var e,r,i=-1,u=t.length;if(arguments.length===1){while(u>++i&&((e=t[i])==null||e!=e))e=void 0;while(u>++i)(r=t[i])!=null&&e>r&&(e=r)}else{while(u>++i&&((e=n.call(t,t[i],i))==null||e!=e))e=void 0;while(u>++i)(r=n.call(t,t[i],i))!=null&&e>r&&(e=r)}return e},d3.max=function(t,n){var e,r,i=-1,u=t.length;if(arguments.length===1){while(u>++i&&((e=t[i])==null||e!=e))e=void 0;while(u>++i)(r=t[i])!=null&&r>e&&(e=r)}else{while(u>++i&&((e=n.call(t,t[i],i))==null||e!=e))e=void 0;while(u>++i)(r=n.call(t,t[i],i))!=null&&r>e&&(e=r)}return e},d3.extent=function(t,n){var e,r,i,u=-1,a=t.length;if(arguments.length===1){while(a>++u&&((e=i=t[u])==null||e!=e))e=i=void 0;while(a>++u)(r=t[u])!=null&&(e>r&&(e=r),r>i&&(i=r))}else{while(a>++u&&((e=i=n.call(t,t[u],u))==null||e!=e))e=void 0;while(a>++u)(r=n.call(t,t[u],u))!=null&&(e>r&&(e=r),r>i&&(i=r))}return[e,i]},d3.random={normal:function(t,n){var e=arguments.length;return 2>e&&(n=1),1>e&&(t=0),function(){var e,r,i;do e=Math.random()*2-1,r=Math.random()*2-1,i=e*e+r*r;while(!i||i>1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(t,n){var e=arguments.length;2>e&&(n=1),1>e&&(t=0);var r=d3.random.normal();return function(){return Math.exp(t+n*r())}},irwinHall:function(t){return function(){for(var n=0,e=0;t>e;e++)n+=Math.random();return n/t}}},d3.sum=function(t,n){var e,r=0,i=t.length,u=-1;if(arguments.length===1)while(i>++u)isNaN(e=+t[u])||(r+=e);else while(i>++u)isNaN(e=+n.call(t,t[u],u))||(r+=e);return r},d3.quantile=function(t,n){var e=(t.length-1)*n+1,r=Math.floor(e),i=t[r-1],u=e-r;return u?i+u*(t[r]-i):i},d3.transpose=function(t){return d3.zip.apply(d3,t)},d3.zip=function(){if(!(r=arguments.length))return[];for(var t=-1,n=d3.min(arguments,h),e=Array(n);n>++t;)for(var r,i=-1,u=e[t]=Array(r);r>++i;)u[i]=arguments[i][t];return e},d3.bisector=function(t){return{left:function(n,e,r,i){3>arguments.length&&(r=0),4>arguments.length&&(i=n.length);while(i>r){var u=r+i>>>1;e>t.call(n,n[u],u)?r=u+1:i=u}return r},right:function(n,e,r,i){3>arguments.length&&(r=0),4>arguments.length&&(i=n.length);while(i>r){var u=r+i>>>1;t.call(n,n[u],u)>e?i=u:r=u+1}return r}}};var Du=d3.bisector(function(t){return t});d3.bisectLeft=Du.left,d3.bisect=d3.bisectRight=Du.right,d3.nest=function(){function t(n,o){if(o>=u.length)return r?r.call(i,n):e?n.sort(e):n;var l,c,s,f=-1,h=n.length,d=u[o++],g=new a,p={};while(h>++f)(s=g.get(l=d(c=n[f])))?s.push(c):g.set(l,[c]);return g.forEach(function(n,e){p[n]=t(e,o)}),p}function n(t,e){if(e>=u.length)return t;var r,i=[],a=o[e++];for(r in t)i.push({key:r,values:n(t[r],e)});return a&&i.sort(function(t,n){return a(t.key,n.key)}),i}var e,r,i={},u=[],o=[];return i.map=function(n){return t(n,0)},i.entries=function(e){return n(t(e,0),0)},i.key=function(t){return u.push(t),i},i.sortKeys=function(t){return o[u.length-1]=t,i},i.sortValues=function(t){return e=t,i},i.rollup=function(t){return r=t,i},i},d3.keys=function(t){var n=[];for(var e in t)n.push(e);return n},d3.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},d3.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},d3.permute=function(t,n){var e=[],r=-1,i=n.length;while(i>++r)e[r]=t[n[r]];return e},d3.merge=function(t){return Array.prototype.concat.apply([],t)},d3.range=function(t,n,e){if(3>arguments.length&&(e=1,2>arguments.length&&(n=t,t=0)),(n-t)/e===1/0)throw Error("infinite range");var r,i=[],u=g(Math.abs(e)),a=-1;if(t*=u,n*=u,e*=u,0>e)while((r=t+e*++a)>n)i.push(r/u);else while(n>(r=t+e*++a))i.push(r/u);return i},d3.requote=function(t){return t.replace(Pu,"\\$&")};var Pu=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(t,n){return n?Math.round(t*(n=Math.pow(10,n)))/n:Math.round(t)},d3.xhr=function(t,n,e){var r={},i=d3.dispatch("progress","load","error"),u={},a=o,l=new XMLHttpRequest;return l.onreadystatechange=function(){if(l.readyState===4){var t=l.status;!t&&l.response||t>=200&&300>t||t===304?i.load.call(r,a.call(r,l)):i.error.call(r,l)}},l.onprogress=function(t){var n=d3.event;d3.event=t;try{i.progress.call(r,l)}finally{d3.event=n}},r.header=function(t,n){return t=(t+"").toLowerCase(),2>arguments.length?u[t]:(n==null?delete u[t]:u[t]=n+"",r)},r.mimeType=function(t){return arguments.length?(n=t==null?null:t+"",r):n},r.response=function(t){return a=t,r},["get","post"].forEach(function(t){r[t]=function(){return r.send.apply(r,[t].concat(Nu(arguments)))}}),r.send=function(e,i,a){arguments.length===2&&typeof i=="function"&&(a=i,i=null),l.open(e,t,!0),n==null||"accept"in u||(u.accept=n+",*/*");for(var o in u)l.setRequestHeader(o,u[o]);return n!=null&&l.overrideMimeType&&l.overrideMimeType(n),a!=null&&r.on("error",a).on("load",function(t){a(null,t)}),l.send(i==null?null:i),r},r.abort=function(){return l.abort(),r},d3.rebind(r,i,"on"),arguments.length===2&&typeof n=="function"&&(e=n,n=null),e==null?r:r.get(e)},d3.text=function(){return d3.xhr.apply(d3,arguments).response(p)},d3.json=function(t,n){return d3.xhr(t,"application/json",n).response(m)},d3.html=function(t,n){return d3.xhr(t,"text/html",n).response(v)},d3.xml=function(){return d3.xhr.apply(d3,arguments).response(y)};var Lu={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d3.ns={prefix:Lu,qualify:function(t){var n=t.indexOf(":"),e=t;return n>=0&&(e=t.substring(0,n),t=t.substring(n+1)),Lu.hasOwnProperty(e)?{space:Lu[e],local:t}:t}},d3.dispatch=function(){var t=new M,n=-1,e=arguments.length;while(e>++n)t[arguments[n]]=b(t);return t},M.prototype.on=function(t,n){var e=t.indexOf("."),r="";return e>0&&(r=t.substring(e+1),t=t.substring(0,e)),2>arguments.length?this[t].on(r):this[t].on(r,n)},d3.format=function(t){var n=Fu.exec(t),e=n[1]||" ",r=n[2]||">",i=n[3]||"",u=n[4]||"",a=n[5],o=+n[6],l=n[7],c=n[8],s=n[9],f=1,h="",d=!1;switch(c&&(c=+c.substring(1)),(a||e==="0"&&r==="=")&&(a=e="0",r="=",l&&(o-=Math.floor((o-1)/4))),s){case"n":l=!0,s="g";break;case"%":f=100,h="%",s="f";break;case"p":f=100,h="%",s="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+s.toLowerCase());case"c":case"d":d=!0,c=0;break;case"s":f=-1,s="r"}u==="#"&&(u=""),s!="r"||c||(s="g"),s=Hu.get(s)||w;var g=a&&l;return function(t){if(d&&t%1)return"";var n=0>t||t===0&&0>1/t?(t=-t,"-"):i;if(0>f){var p=d3.formatPrefix(t,c);t=p.scale(t),h=p.symbol}else t*=f;t=s(t,c),!a&&l&&(t=ju(t));var m=u.length+t.length+(g?0:n.length),v=o>m?Array(m=o-m+1).join(e):"";return g&&(t=ju(v+t)),vu&&t.replace(".",vu),n+=u,(r==="<"?n+t+v:r===">"?v+n+t:r==="^"?v.substring(0,m>>=1)+n+t+v.substring(m):n+(g?t:v+t))+h}};var Fu=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,Hu=d3.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(t,n){return d3.round(t,n=x(t,n)).toFixed(Math.max(0,Math.min(20,n)))}}),ju=o;if(Mu){var Ou=Mu.length;ju=function(t){var n=t.lastIndexOf("."),e=n>=0?"."+t.substring(n+1):(n=t.length,""),r=[],i=0,u=Mu[0];while(n>0&&u>0)r.push(t.substring(n-=u,n+u)),u=Mu[i=(i+1)%Ou];return r.reverse().join(yu||"")+e}}var Ru=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(_);d3.formatPrefix=function(t,n){var e=0;return t&&(0>t&&(t*=-1),n&&(t=d3.round(t,x(t,n))),e=1+Math.floor(1e-12+Math.log(t)/Math.LN10),e=Math.max(-24,Math.min(24,Math.floor((0>=e?e+1:e-1)/3)*3))),Ru[8+e/3]};var Yu=function(){return o},Uu=d3.map({linear:Yu,poly:q,quad:function(){return A},cubic:function(){return N},sin:function(){return z},exp:function(){return E},circle:function(){return D},elastic:P,back:L,bounce:function(){return F}}),Iu=d3.map({"in":o,out:T,"in-out":S,"out-in":function(t){return S(T(t))}});d3.ease=function(t){var n=t.indexOf("-"),e=n>=0?t.substring(0,n):t,r=n>=0?t.substring(n+1):"in";return e=Uu.get(e)||Yu,r=Iu.get(r)||o,k(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(t){var n=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate();return new R(e?e.matrix:Vu)})(t)},R.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var Vu={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(t,n){var e,r=d3.interpolators.length;while(--r>=0&&!(e=d3.interpolators[r](t,n)));return e},d3.interpolateNumber=function(t,n){return n-=t,function(e){return t+n*e}},d3.interpolateRound=function(t,n){return n-=t,function(e){return Math.round(t+n*e)}},d3.interpolateString=function(t,n){var e,r,i,u,a,o=0,l=0,c=[],s=[];for(Zu.lastIndex=0,r=0;e=Zu.exec(n);++r)e.index&&c.push(n.substring(o,l=e.index)),s.push({i:c.length,x:e[0]}),c.push(null),o=Zu.lastIndex;for(n.length>o&&c.push(n.substring(o)),r=0,u=s.length;(e=Zu.exec(t))&&u>r;++r)if(a=s[r],a.x==e[0]){if(a.i)if(c[a.i+1]==null)for(c[a.i-1]+=a.x,c.splice(a.i,1),i=r+1;u>i;++i)s[i].i--;else for(c[a.i-1]+=a.x+c[a.i+1],c.splice(a.i,2),i=r+1;u>i;++i)s[i].i-=2;else if(c[a.i+1]==null)c[a.i]=a.x;else for(c[a.i]=a.x+c[a.i+1],c.splice(a.i+1,1),i=r+1;u>i;++i)s[i].i--;s.splice(r,1),u--,r--}else a.x=d3.interpolateNumber(parseFloat(e[0]),parseFloat(a.x));while(u>r)a=s.pop(),c[a.i+1]==null?c[a.i]=a.x:(c[a.i]=a.x+c[a.i+1],c.splice(a.i+1,1)),u--;return c.length===1?c[0]==null?s[0].x:function(){return n}:function(t){for(r=0;u>r;++r)c[(a=s[r]).i]=a.x(t);return c.join("")}},d3.interpolateTransform=function(t,n){var e,r=[],i=[],u=d3.transform(t),a=d3.transform(n),o=u.translate,l=a.translate,c=u.rotate,s=a.rotate,f=u.skew,h=a.skew,d=u.scale,g=a.scale;return o[0]!=l[0]||o[1]!=l[1]?(r.push("translate(",null,",",null,")"),i.push({i:1,x:d3.interpolateNumber(o[0],l[0])},{i:3,x:d3.interpolateNumber(o[1],l[1])})):l[0]||l[1]?r.push("translate("+l+")"):r.push(""),c!=s?(c-s>180?s+=360:s-c>180&&(c+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(c,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),d[0]!=g[0]||d[1]!=g[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:d3.interpolateNumber(d[0],g[0])},{i:e-2,x:d3.interpolateNumber(d[1],g[1])})):(g[0]!=1||g[1]!=1)&&r.push(r.pop()+"scale("+g+")"),e=i.length,function(t){var n,u=-1;while(e>++u)r[(n=i[u]).i]=n.x(t);return r.join("")}},d3.interpolateRgb=function(t,n){t=d3.rgb(t),n=d3.rgb(n);var e=t.r,r=t.g,i=t.b,u=n.r-e,a=n.g-r,o=n.b-i;return function(t){return"#"+J(Math.round(e+u*t))+J(Math.round(r+a*t))+J(Math.round(i+o*t))}},d3.interpolateHsl=function(t,n){t=d3.hsl(t),n=d3.hsl(n);var e=t.h,r=t.s,i=t.l,u=n.h-e,a=n.s-r,o=n.l-i;return u>180?u-=360:-180>u&&(u+=360),function(t){return un(e+u*t,r+a*t,i+o*t)+""}},d3.interpolateLab=function(t,n){t=d3.lab(t),n=d3.lab(n);var e=t.l,r=t.a,i=t.b,u=n.l-e,a=n.a-r,o=n.b-i;return function(t){return fn(e+u*t,r+a*t,i+o*t)+""}},d3.interpolateHcl=function(t,n){t=d3.hcl(t),n=d3.hcl(n);var e=t.h,r=t.c,i=t.l,u=n.h-e,a=n.c-r,o=n.l-i;return u>180?u-=360:-180>u&&(u+=360),function(t){return ln(e+u*t,r+a*t,i+o*t)+""}},d3.interpolateArray=function(t,n){var e,r=[],i=[],u=t.length,a=n.length,o=Math.min(t.length,n.length);for(e=0;o>e;++e)r.push(d3.interpolate(t[e],n[e]));for(;u>e;++e)i[e]=t[e];for(;a>e;++e)i[e]=n[e];return function(t){for(e=0;o>e;++e)i[e]=r[e](t);return i}},d3.interpolateObject=function(t,n){var e,r={},i={};for(e in t)e in n?r[e]=V(e)(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}};var Zu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;d3.interpolators=[d3.interpolateObject,function(t,n){return n instanceof Array&&d3.interpolateArray(t,n)},function(t,n){return(typeof t=="string"||typeof n=="string")&&d3.interpolateString(t+"",n+"")},function(t,n){return(typeof n=="string"?Xu.has(n)||/^(#|rgb\(|hsl\()/.test(n):n instanceof X)&&d3.interpolateRgb(t,n)},function(t,n){return!isNaN(t=+t)&&!isNaN(n=+n)&&d3.interpolateNumber(t,n)}],X.prototype.toString=function(){return this.rgb()+""},d3.rgb=function(t,n,e){return arguments.length===1?t instanceof G?$(t.r,t.g,t.b):K(""+t,$,un):$(~~t,~~n,~~e)};var Bu=G.prototype=new X;Bu.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&i>n&&(n=i),e&&i>e&&(e=i),r&&i>r&&(r=i),$(Math.min(255,Math.floor(n/t)),Math.min(255,Math.floor(e/t)),Math.min(255,Math.floor(r/t)))):$(i,i,i)},Bu.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),$(Math.floor(t*this.r),Math.floor(t*this.g),Math.floor(t*this.b))},Bu.hsl=function(){return W(this.r,this.g,this.b)},Bu.toString=function(){return"#"+J(this.r)+J(this.g)+J(this.b)};var Xu=d3.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});Xu.forEach(function(t,n){Xu.set(t,K(n,$,un))}),d3.hsl=function(t,n,e){return arguments.length===1?t instanceof rn?en(t.h,t.s,t.l):K(""+t,W,en):en(+t,+n,+e)};var $u=rn.prototype=new X;$u.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),en(this.h,this.s,this.l/t)},$u.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),en(this.h,this.s,t*this.l)},$u.rgb=function(){return un(this.h,this.s,this.l)},d3.hcl=function(t,n,e){return arguments.length===1?t instanceof on?an(t.h,t.c,t.l):t instanceof sn?hn(t.l,t.a,t.b):hn((t=Q((t=d3.rgb(t)).r,t.g,t.b)).l,t.a,t.b):an(+t,+n,+e) -};var Gu=on.prototype=new X;Gu.brighter=function(t){return an(this.h,this.c,Math.min(100,this.l+Ju*(arguments.length?t:1)))},Gu.darker=function(t){return an(this.h,this.c,Math.max(0,this.l-Ju*(arguments.length?t:1)))},Gu.rgb=function(){return ln(this.h,this.c,this.l).rgb()},d3.lab=function(t,n,e){return arguments.length===1?t instanceof sn?cn(t.l,t.a,t.b):t instanceof on?ln(t.l,t.c,t.h):Q((t=d3.rgb(t)).r,t.g,t.b):cn(+t,+n,+e)};var Ju=18,Ku=.95047,Wu=1,Qu=1.08883,ta=sn.prototype=new X;ta.brighter=function(t){return cn(Math.min(100,this.l+Ju*(arguments.length?t:1)),this.a,this.b)},ta.darker=function(t){return cn(Math.max(0,this.l-Ju*(arguments.length?t:1)),this.a,this.b)},ta.rgb=function(){return fn(this.l,this.a,this.b)};var na=function(t,n){return n.querySelector(t)},ea=function(t,n){return n.querySelectorAll(t)},ra=document.documentElement,ia=ra.matchesSelector||ra.webkitMatchesSelector||ra.mozMatchesSelector||ra.msMatchesSelector||ra.oMatchesSelector,ua=function(t,n){return ia.call(t,n)};typeof Sizzle=="function"&&(na=function(t,n){return Sizzle(t,n)[0]||null},ea=function(t,n){return Sizzle.uniqueSort(Sizzle(t,n))},ua=Sizzle.matchesSelector);var aa=[];d3.selection=function(){return oa},d3.selection.prototype=aa,aa.select=function(t){var n,e,r,i,u=[];typeof t!="function"&&(t=vn(t));for(var a=-1,o=this.length;o>++a;){u.push(n=[]),n.parentNode=(r=this[a]).parentNode;for(var l=-1,c=r.length;c>++l;)(i=r[l])?(n.push(e=t.call(i,i.__data__,l)),e&&"__data__"in i&&(e.__data__=i.__data__)):n.push(null)}return mn(u)},aa.selectAll=function(t){var n,e,r=[];typeof t!="function"&&(t=yn(t));for(var i=-1,u=this.length;u>++i;)for(var a=this[i],o=-1,l=a.length;l>++o;)(e=a[o])&&(r.push(n=Nu(t.call(e,e.__data__,o))),n.parentNode=e);return mn(r)},aa.attr=function(t,n){if(2>arguments.length){if(typeof t=="string"){var e=this.node();return t=d3.ns.qualify(t),t.local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)}for(n in t)this.each(Mn(n,t[n]));return this}return this.each(Mn(t,n))},aa.classed=function(t,n){if(2>arguments.length){if(typeof t=="string"){var e=this.node(),r=(t=t.trim().split(/^|\s+/g)).length,i=-1;if(n=e.classList){while(r>++i)if(!n.contains(t[i]))return!1}else{n=e.className,n.baseVal!=null&&(n=n.baseVal);while(r>++i)if(!bn(t[i]).test(n))return!1}return!0}for(n in t)this.each(xn(n,t[n]));return this}return this.each(xn(t,n))},aa.style=function(t,n,e){var r=arguments.length;if(3>r){if(typeof t!="string"){2>r&&(n="");for(e in t)this.each(_n(e,t[e],n));return this}if(2>r)return getComputedStyle(this.node(),null).getPropertyValue(t);e=""}return this.each(_n(t,n,e))},aa.property=function(t,n){if(2>arguments.length){if(typeof t=="string")return this.node()[t];for(n in t)this.each(kn(n,t[n]));return this}return this.each(kn(t,n))},aa.text=function(t){return arguments.length?this.each(typeof t=="function"?function(){var n=t.apply(this,arguments);this.textContent=n==null?"":n}:t==null?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},aa.html=function(t){return arguments.length?this.each(typeof t=="function"?function(){var n=t.apply(this,arguments);this.innerHTML=n==null?"":n}:t==null?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},aa.append=function(t){function n(){return this.appendChild(document.createElementNS(this.namespaceURI,t))}function e(){return this.appendChild(document.createElementNS(t.space,t.local))}return t=d3.ns.qualify(t),this.select(t.local?e:n)},aa.insert=function(t,n){function e(){return this.insertBefore(document.createElementNS(this.namespaceURI,t),na(n,this))}function r(){return this.insertBefore(document.createElementNS(t.space,t.local),na(n,this))}return t=d3.ns.qualify(t),this.select(t.local?r:e)},aa.remove=function(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})},aa.data=function(t,n){function e(t,e){var r,i,u,o=t.length,f=e.length,h=Math.min(o,f),d=Math.max(o,f),g=[],p=[],m=[];if(n){var v,y=new a,M=[],b=e.length;for(r=-1;o>++r;)v=n.call(i=t[r],i.__data__,r),y.has(v)?m[b++]=i:y.set(v,i),M.push(v);for(r=-1;f>++r;)v=n.call(e,u=e[r],r),y.has(v)?(g[r]=i=y.get(v),i.__data__=u,p[r]=m[r]=null):(p[r]=Tn(u),g[r]=m[r]=null),y.remove(v);for(r=-1;o>++r;)y.has(M[r])&&(m[r]=t[r])}else{for(r=-1;h>++r;)i=t[r],u=e[r],i?(i.__data__=u,g[r]=i,p[r]=m[r]=null):(p[r]=Tn(u),g[r]=m[r]=null);for(;f>r;++r)p[r]=Tn(e[r]),g[r]=m[r]=null;for(;d>r;++r)m[r]=t[r],p[r]=g[r]=null}p.update=g,p.parentNode=g.parentNode=m.parentNode=t.parentNode,l.push(p),c.push(g),s.push(m)}var r,i,u=-1,o=this.length;if(!arguments.length){t=Array(o=(r=this[0]).length);while(o>++u)(i=r[u])&&(t[u]=i.__data__);return t}var l=qn([]),c=mn([]),s=mn([]);if(typeof t=="function")while(o>++u)e(r=this[u],t.call(r,r.parentNode.__data__,u));else while(o>++u)e(r=this[u],t);return c.enter=function(){return l},c.exit=function(){return s},c},aa.datum=function(t){return arguments.length?this.property("__data__",t):this.property("__data__")},aa.filter=function(t){var n,e,r,i=[];typeof t!="function"&&(t=Sn(t));for(var u=0,a=this.length;a>u;u++){i.push(n=[]),n.parentNode=(e=this[u]).parentNode;for(var o=0,l=e.length;l>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return mn(i)},aa.order=function(){for(var t=-1,n=this.length;n>++t;)for(var e,r=this[t],i=r.length-1,u=r[i];--i>=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},aa.sort=function(t){t=An.apply(this,arguments);for(var n=-1,e=this.length;e>++n;)this[n].sort(t);return this.order()},aa.on=function(t,n,e){var r=arguments.length;if(3>r){if(typeof t!="string"){2>r&&(n=!1);for(e in t)this.each(Nn(e,t[e],n));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;e=!1}return this.each(Nn(t,n,e))},aa.each=function(t){return Cn(this,function(n,e,r){t.call(n,n.__data__,e,r)})},aa.call=function(t){var n=Nu(arguments);return t.apply(n[0]=this,n),this},aa.empty=function(){return!this.node()},aa.node=function(){for(var t=0,n=this.length;n>t;t++)for(var e=this[t],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},aa.transition=function(){var t,n,e=ca||++fa,r=[],i=Object.create(ha);i.time=Date.now();for(var u=-1,a=this.length;a>++u;){r.push(t=[]);for(var o=this[u],l=-1,c=o.length;c>++l;)(n=o[l])&&En(n,l,e,i),t.push(n)}return zn(r,e)};var oa=mn([[document]]);oa[0].parentNode=ra,d3.select=function(t){return typeof t=="string"?oa.select(t):mn([[t]])},d3.selectAll=function(t){return typeof t=="string"?oa.selectAll(t):mn([Nu(t)])};var la=[];d3.selection.enter=qn,d3.selection.enter.prototype=la,la.append=aa.append,la.insert=aa.insert,la.empty=aa.empty,la.node=aa.node,la.select=function(t){for(var n,e,r,i,u,a=[],o=-1,l=this.length;l>++o;){r=(i=this[o]).update,a.push(n=[]),n.parentNode=i.parentNode;for(var c=-1,s=i.length;s>++c;)(u=i[c])?(n.push(r[c]=e=t.call(i.parentNode,u.__data__,c)),e.__data__=u.__data__):n.push(null)}return mn(a)};var ca,sa=[],fa=0,ha={ease:C,delay:0,duration:250};sa.call=aa.call,sa.empty=aa.empty,sa.node=aa.node,d3.transition=function(t){return arguments.length?ca?t.transition():t:oa.transition()},d3.transition.prototype=sa,sa.select=function(t){var n,e,r,i=this.id,u=[];typeof t!="function"&&(t=vn(t));for(var a=-1,o=this.length;o>++a;){u.push(n=[]);for(var l=this[a],c=-1,s=l.length;s>++c;)(r=l[c])&&(e=t.call(r,r.__data__,c))?("__data__"in r&&(e.__data__=r.__data__),En(e,c,i,r.__transition__[i]),n.push(e)):n.push(null)}return zn(u,i)},sa.selectAll=function(t){var n,e,r,i,u,a=this.id,o=[];typeof t!="function"&&(t=yn(t));for(var l=-1,c=this.length;c>++l;)for(var s=this[l],f=-1,h=s.length;h>++f;)if(r=s[f]){u=r.__transition__[a],e=t.call(r,r.__data__,f),o.push(n=[]);for(var d=-1,g=e.length;g>++d;)En(i=e[d],d,a,u),n.push(i)}return zn(o,a)},sa.filter=function(t){var n,e,r,i=[];typeof t!="function"&&(t=Sn(t));for(var u=0,a=this.length;a>u;u++){i.push(n=[]);for(var e=this[u],o=0,l=e.length;l>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return zn(i,this.id,this.time).ease(this.ease())},sa.attr=function(t,n){function e(){this.removeAttribute(u)}function r(){this.removeAttributeNS(u.space,u.local)}if(2>arguments.length){for(n in t)this.attr(n,t[n]);return this}var i=V(t),u=d3.ns.qualify(t);return Pn(this,"attr."+t,n,function(t){function n(){var n,e=this.getAttribute(u);return e!==t&&(n=i(e,t),function(t){this.setAttribute(u,n(t))})}function a(){var n,e=this.getAttributeNS(u.space,u.local);return e!==t&&(n=i(e,t),function(t){this.setAttributeNS(u.space,u.local,n(t))})}return t==null?u.local?r:e:(t+="",u.local?a:n)})},sa.attrTween=function(t,n){function e(t,e){var r=n.call(this,t,e,this.getAttribute(i));return r&&function(t){this.setAttribute(i,r(t))}}function r(t,e){var r=n.call(this,t,e,this.getAttributeNS(i.space,i.local));return r&&function(t){this.setAttributeNS(i.space,i.local,r(t))}}var i=d3.ns.qualify(t);return this.tween("attr."+t,i.local?r:e)},sa.style=function(t,n,e){function r(){this.style.removeProperty(t)}var i=arguments.length;if(3>i){if(typeof t!="string"){2>i&&(n="");for(e in t)this.style(e,t[e],n);return this}e=""}var u=V(t);return Pn(this,"style."+t,n,function(n){function i(){var r,i=getComputedStyle(this,null).getPropertyValue(t);return i!==n&&(r=u(i,n),function(n){this.style.setProperty(t,r(n),e)})}return n==null?r:(n+="",i)})},sa.styleTween=function(t,n,e){return 3>arguments.length&&(e=""),this.tween("style."+t,function(r,i){var u=n.call(this,r,i,getComputedStyle(this,null).getPropertyValue(t));return u&&function(n){this.style.setProperty(t,u(n),e)}})},sa.text=function(t){return Pn(this,"text",t,Dn)},sa.remove=function(){return this.each("end.transition",function(){var t;!this.__transition__&&(t=this.parentNode)&&t.removeChild(this)})},sa.ease=function(t){var n=this.id;return 1>arguments.length?this.node().__transition__[n].ease:(typeof t!="function"&&(t=d3.ease.apply(d3,arguments)),Cn(this,function(e){e.__transition__[n].ease=t}))},sa.delay=function(t){var n=this.id;return Cn(this,typeof t=="function"?function(e,r,i){e.__transition__[n].delay=t.call(e,e.__data__,r,i)|0}:(t|=0,function(e){e.__transition__[n].delay=t}))},sa.duration=function(t){var n=this.id;return Cn(this,typeof t=="function"?function(e,r,i){e.__transition__[n].duration=Math.max(1,t.call(e,e.__data__,r,i)|0)}:(t=Math.max(1,t|0),function(e){e.__transition__[n].duration=t}))},sa.each=function(t,n){var e=this.id;if(2>arguments.length){var r=ha,i=ca;ca=e,Cn(this,function(n,r,i){ha=n.__transition__[e],t.call(n,n.__data__,r,i)}),ha=r,ca=i}else Cn(this,function(r){r.__transition__[e].event.on(t,n)});return this},sa.transition=function(){for(var t,n,e,r,i=this.id,u=++fa,a=[],o=0,l=this.length;l>o;o++){a.push(t=[]);for(var n=this[o],c=0,s=n.length;s>c;c++)(e=n[c])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,En(e,c,u,r)),t.push(e)}return zn(a,u)},sa.tween=function(t,n){var e=this.id;return 2>arguments.length?this.node().__transition__[e].tween.get(t):Cn(this,n==null?function(n){n.__transition__[e].tween.remove(t)}:function(r){r.__transition__[e].tween.set(t,n)})};var da,ga,pa=0,ma={},va=null;d3.timer=function(t,n,e){if(3>arguments.length){if(2>arguments.length)n=0;else if(!isFinite(n))return;e=Date.now()}var r=ma[t.id];r&&r.callback===t?(r.then=e,r.delay=n):ma[t.id=++pa]=va={callback:t,then:e,delay:n,next:va},da||(ga=clearTimeout(ga),da=1,ya(Ln))},d3.timer.flush=function(){var t,n=Date.now(),e=va;while(e)t=n-e.then,e.delay||(e.flush=e.callback(t)),e=e.next;Fn()};var ya=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,17)};d3.mouse=function(t){return Hn(t,j())};var Ma=/WebKit/.test(navigator.userAgent)?-1:0;d3.touches=function(t,n){return 2>arguments.length&&(n=j().touches),n?Nu(n).map(function(n){var e=Hn(t,n);return e.identifier=n.identifier,e}):[]},d3.scale={},d3.scale.linear=function(){return In([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return Kn(d3.scale.linear(),Wn)};var ba=d3.format(".0e");Wn.pow=function(t){return Math.pow(10,t)},Qn.pow=function(t){return-Math.pow(10,-t)},d3.scale.pow=function(){return te(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return ee([],{t:"range",a:[[]]})},d3.scale.category10=function(){return d3.scale.ordinal().range(xa)},d3.scale.category20=function(){return d3.scale.ordinal().range(wa)},d3.scale.category20b=function(){return d3.scale.ordinal().range(_a)},d3.scale.category20c=function(){return d3.scale.ordinal().range(ka)};var xa=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],wa=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],_a=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],ka=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return re([],[])},d3.scale.quantize=function(){return ie(0,1,[0,1])},d3.scale.threshold=function(){return ue([.5],[0,1])},d3.scale.identity=function(){return ae([0,1])},d3.svg={},d3.svg.arc=function(){function t(){var t=n.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+Ta,o=i.apply(this,arguments)+Ta,l=(a>o&&(l=a,a=o,o=l),o-a),c=_u>l?"0":"1",s=Math.cos(a),f=Math.sin(a),h=Math.cos(o),d=Math.sin(o);return l>=Sa?t?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":t?"M"+u*s+","+u*f+"A"+u+","+u+" 0 "+c+",1 "+u*h+","+u*d+"L"+t*h+","+t*d+"A"+t+","+t+" 0 "+c+",0 "+t*s+","+t*f+"Z":"M"+u*s+","+u*f+"A"+u+","+u+" 0 "+c+",1 "+u*h+","+u*d+"L0,0"+"Z"}var n=oe,e=le,r=ce,i=se;return t.innerRadius=function(e){return arguments.length?(n=c(e),t):n},t.outerRadius=function(n){return arguments.length?(e=c(n),t):e},t.startAngle=function(n){return arguments.length?(r=c(n),t):r},t.endAngle=function(n){return arguments.length?(i=c(n),t):i},t.centroid=function(){var t=(n.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+Ta;return[Math.cos(u)*t,Math.sin(u)*t]},t};var Ta=-_u/2,Sa=2*_u-1e-6;d3.svg.line=function(){return fe(o)};var Aa=d3.map({linear:ge,"linear-closed":pe,"step-before":me,"step-after":ve,basis:_e,"basis-open":ke,"basis-closed":Te,bundle:Se,cardinal:be,"cardinal-open":ye,"cardinal-closed":Me,monotone:Ee});Aa.forEach(function(t,n){n.key=t,n.closed=/-closed$/.test(t)});var Na=[0,2/3,1/3,0],Ca=[0,1/3,2/3,0],qa=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var t=fe(De);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},me.reverse=ve,ve.reverse=me,d3.svg.area=function(){return Pe(o)},d3.svg.area.radial=function(){var t=Pe(De);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},d3.svg.chord=function(){function t(t,n){var e=r(this,o,t,n),c=r(this,l,t,n);return"M"+e.p0+u(e.r,e.p1,e.a1-e.a0)+(i(e,c)?a(e.r,e.p1,e.r,e.p0):a(e.r,e.p1,c.r,c.p0)+u(c.r,c.p1,c.a1-c.a0)+a(c.r,c.p1,e.r,e.p0))+"Z"}function r(t,n,e,r){var i=n.call(t,e,r),u=s.call(t,i,r),a=f.call(t,i,r)+Ta,o=h.call(t,i,r)+Ta;return{r:u,a0:a,a1:o,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(o),u*Math.sin(o)]}}function i(t,n){return t.a0==n.a0&&t.a1==n.a1}function u(t,n,e){return"A"+t+","+t+" 0 "+ +(e>_u)+",1 "+n}function a(t,n,e,r){return"Q 0,0 "+r}var o=e,l=n,s=Le,f=ce,h=se;return t.radius=function(n){return arguments.length?(s=c(n),t):s},t.source=function(n){return arguments.length?(o=c(n),t):o},t.target=function(n){return arguments.length?(l=c(n),t):l},t.startAngle=function(n){return arguments.length?(f=c(n),t):f},t.endAngle=function(n){return arguments.length?(h=c(n),t):h},t},d3.svg.diagonal=function(){function t(t,n){var e=r.call(this,t,n),a=i.call(this,t,n),o=(e.y+a.y)/2,l=[e,{x:e.x,y:o},{x:a.x,y:o},a];return l=l.map(u),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var r=e,i=n,u=Fe;return t.source=function(n){return arguments.length?(r=c(n),t):r},t.target=function(n){return arguments.length?(i=c(n),t):i},t.projection=function(n){return arguments.length?(u=n,t):u},t},d3.svg.diagonal.radial=function(){var t=d3.svg.diagonal(),n=Fe,e=t.projection;return t.projection=function(t){return arguments.length?e(He(n=t)):n},t},d3.svg.symbol=function(){function t(t,r){return(za.get(n.call(this,t,r))||Re)(e.call(this,t,r))}var n=Oe,e=je;return t.type=function(e){return arguments.length?(n=c(e),t):n},t.size=function(n){return arguments.length?(e=c(n),t):e},t};var za=d3.map({circle:Re,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*Da)),e=n*Da;return"M0,"+-n+"L"+e+",0"+" 0,"+n+" "+-e+",0"+"Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/Ea),e=n*Ea/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/Ea),e=n*Ea/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});d3.svg.symbolTypes=za.keys();var Ea=Math.sqrt(3),Da=Math.tan(30*Su);d3.svg.axis=function(){function t(t){t.each(function(){var t,f=d3.select(this),h=c==null?e.ticks?e.ticks.apply(e,l):e.domain():c,d=n==null?e.tickFormat?e.tickFormat.apply(e,l):String:n,g=Ie(e,h,s),p=f.selectAll(".minor").data(g,String),m=p.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),v=d3.transition(p.exit()).style("opacity",1e-6).remove(),y=d3.transition(p).style("opacity",1),M=f.selectAll("g").data(h,String),b=M.enter().insert("g","path").style("opacity",1e-6),x=d3.transition(M.exit()).style("opacity",1e-6).remove(),w=d3.transition(M).style("opacity",1),_=Rn(e),k=f.selectAll(".domain").data([0]),T=d3.transition(k),S=e.copy(),A=this.__chart__||S;this.__chart__=S,k.enter().append("path").attr("class","domain"),b.append("line").attr("class","tick"),b.append("text");var N=b.select("line"),C=w.select("line"),q=M.select("text").text(d),z=b.select("text"),E=w.select("text");switch(r){case"bottom":t=Ye,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),z.attr("y",Math.max(i,0)+o),C.attr("x2",0).attr("y2",i),E.attr("x",0).attr("y",Math.max(i,0)+o),q.attr("dy",".71em").style("text-anchor","middle"),T.attr("d","M"+_[0]+","+a+"V0H"+_[1]+"V"+a);break;case"top":t=Ye,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),z.attr("y",-(Math.max(i,0)+o)),C.attr("x2",0).attr("y2",-i),E.attr("x",0).attr("y",-(Math.max(i,0)+o)),q.attr("dy","0em").style("text-anchor","middle"),T.attr("d","M"+_[0]+","+-a+"V0H"+_[1]+"V"+-a);break;case"left":t=Ue,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),z.attr("x",-(Math.max(i,0)+o)),C.attr("x2",-i).attr("y2",0),E.attr("x",-(Math.max(i,0)+o)).attr("y",0),q.attr("dy",".32em").style("text-anchor","end"),T.attr("d","M"+-a+","+_[0]+"H0V"+_[1]+"H"+-a);break;case"right":t=Ue,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),z.attr("x",Math.max(i,0)+o),C.attr("x2",i).attr("y2",0),E.attr("x",Math.max(i,0)+o).attr("y",0),q.attr("dy",".32em").style("text-anchor","start"),T.attr("d","M"+a+","+_[0]+"H0V"+_[1]+"H"+a)}if(e.ticks)b.call(t,A),w.call(t,S),x.call(t,S),m.call(t,A),y.call(t,S),v.call(t,S);else{var D=S.rangeBand()/2,P=function(t){return S(t)+D};b.call(t,P),w.call(t,P)}})}var n,e=d3.scale.linear(),r="bottom",i=6,u=6,a=6,o=3,l=[10],c=null,s=0;return t.scale=function(n){return arguments.length?(e=n,t):e},t.orient=function(n){return arguments.length?(r=n,t):r},t.ticks=function(){return arguments.length?(l=arguments,t):l},t.tickValues=function(n){return arguments.length?(c=n,t):c},t.tickFormat=function(e){return arguments.length?(n=e,t):n},t.tickSize=function(n,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+n,u=r>1?+e:i,a=r>0?+arguments[r]:i,t},t.tickPadding=function(n){return arguments.length?(o=+n,t):o},t.tickSubdivide=function(n){return arguments.length?(s=+n,t):s},t},d3.svg.brush=function(){function t(u){u.each(function(){var u,a=d3.select(this),s=a.selectAll(".background").data([0]),f=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(c,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),s.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),f.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Pa[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",t.empty()?"none":null),h.exit().remove(),o&&(u=Rn(o),s.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),l&&(u=Rn(l),s.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),n(a)})}function n(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+s[+/e$/.test(t)][0]+","+s[+/^s/.test(t)][1]+")"})}function e(t){t.select(".extent").attr("x",s[0][0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1][0]-s[0][0])}function r(t){t.select(".extent").attr("y",s[0][1]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1][1]-s[0][1])}function i(){function i(){var t=d3.event.changedTouches;return t?d3.touches(v,t)[0]:d3.mouse(v)}function c(){d3.event.keyCode==32&&(k||(p=null,T[0]-=s[1][0],T[1]-=s[1][1],k=2),H())}function f(){d3.event.keyCode==32&&k==2&&(T[0]+=s[1][0],T[1]+=s[1][1],k=0,H())}function h(){var t=i(),u=!1;m&&(t[0]+=m[0],t[1]+=m[1]),k||(d3.event.altKey?(p||(p=[(s[0][0]+s[1][0])/2,(s[0][1]+s[1][1])/2]),T[0]=s[+(p[0]>t[0])][0],T[1]=s[+(p[1]>t[1])][1]):p=null),w&&d(t,o,0)&&(e(b),u=!0),_&&d(t,l,1)&&(r(b),u=!0),u&&(n(b),M({type:"brush",mode:k?"move":"resize"}))}function d(t,n,e){var r,i,a=Rn(n),o=a[0],l=a[1],c=T[e],f=s[1][e]-s[0][e];return k&&(o-=c,l-=f+c),r=Math.max(o,Math.min(l,t[e])),k?i=(r+=c)+f:(p&&(c=Math.max(o,Math.min(l,2*p[e]-r))),r>c?(i=r,r=c):i=c),s[0][e]!==r||s[1][e]!==i?(u=null,s[0][e]=r,s[1][e]=i,!0):void 0}function g(){h(),b.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),d3.select("body").style("cursor",null),S.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),M({type:"brushend"}),H()}var p,m,v=this,y=d3.select(d3.event.target),M=a.of(v,arguments),b=d3.select(v),x=y.datum(),w=!/^(n|s)$/.test(x)&&o,_=!/^(e|w)$/.test(x)&&l,k=y.classed("extent"),T=i(),S=d3.select(window).on("mousemove.brush",h).on("mouseup.brush",g).on("touchmove.brush",h).on("touchend.brush",g).on("keydown.brush",c).on("keyup.brush",f);if(k)T[0]=s[0][0]-T[0],T[1]=s[0][1]-T[1];else if(x){var A=+/w$/.test(x),N=+/^n/.test(x);m=[s[1-A][0]-T[0],s[1-N][1]-T[1]],T[0]=s[A][0],T[1]=s[N][1]}else d3.event.altKey&&(p=T.slice());b.style("pointer-events","none").selectAll(".resize").style("display",null),d3.select("body").style("cursor",y.style("cursor")),M({type:"brushstart"}),h(),H()}var u,a=O(t,"brushstart","brush","brushend"),o=null,l=null,c=La[0],s=[[0,0],[0,0]];return t.x=function(n){return arguments.length?(o=n,c=La[!o<<1|!l],t):o},t.y=function(n){return arguments.length?(l=n,c=La[!o<<1|!l],t):l},t.extent=function(n){var e,r,i,a,c;return arguments.length?(u=[[0,0],[0,0]],o&&(e=n[0],r=n[1],l&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(c=e,e=r,r=c),s[0][0]=e|0,s[1][0]=r|0),l&&(i=n[0],a=n[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,l.invert&&(i=l(i),a=l(a)),i>a&&(c=i,i=a,a=c),s[0][1]=i|0,s[1][1]=a|0),t):(n=u||s,o&&(e=n[0][0],r=n[1][0],u||(e=s[0][0],r=s[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(c=e,e=r,r=c))),l&&(i=n[0][1],a=n[1][1],u||(i=s[0][1],a=s[1][1],l.invert&&(i=l.invert(i),a=l.invert(a)),i>a&&(c=i,i=a,a=c))),o&&l?[[e,i],[r,a]]:o?[e,r]:l&&[i,a])},t.clear=function(){return u=null,s[0][0]=s[0][1]=s[1][0]=s[1][1]=0,t},t.empty=function(){return o&&s[0][0]===s[1][0]||l&&s[0][1]===s[1][1]},d3.rebind(t,a,"on")};var Pa={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},La=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];d3.behavior={},d3.behavior.drag=function(){function t(){this.on("mousedown.drag",n).on("touchstart.drag",n)}function n(){function t(){var t=o.parentNode;return s?d3.touches(t).filter(function(t){return t.identifier===s})[0]:d3.mouse(t)}function n(){if(!o.parentNode)return i();var n=t(),e=n[0]-f[0],r=n[1]-f[1];h|=e|r,f=n,H(),l({type:"drag",x:n[0]+a[0],y:n[1]+a[1],dx:e,dy:r})}function i(){l({type:"dragend"}),h&&(H(),d3.event.target===c&&d.on("click.drag",u,!0)),d.on(s?"touchmove.drag-"+s:"mousemove.drag",null).on(s?"touchend.drag-"+s:"mouseup.drag",null)}function u(){H(),d.on("click.drag",null)}var a,o=this,l=e.of(o,arguments),c=d3.event.target,s=d3.event.touches&&d3.event.changedTouches[0].identifier,f=t(),h=0,d=d3.select(window).on(s?"touchmove.drag-"+s:"mousemove.drag",n).on(s?"touchend.drag-"+s:"mouseup.drag",i,!0);r?(a=r.apply(o,arguments),a=[a.x-f[0],a.y-f[1]]):a=[0,0],s||H(),l({type:"dragstart"})}var e=O(t,"drag","dragstart","dragend"),r=null;return t.origin=function(n){return arguments.length?(r=n,t):r},d3.rebind(t,e,"on")},d3.behavior.zoom=function(){function t(){this.on("mousedown.zoom",o).on("mousewheel.zoom",l).on("mousemove.zoom",c).on("DOMMouseScroll.zoom",l).on("dblclick.zoom",s).on("touchstart.zoom",f).on("touchmove.zoom",h).on("touchend.zoom",f)}function n(t){return[(t[0]-b[0])/x,(t[1]-b[1])/x]}function e(t){return[t[0]*x+b[0],t[1]*x+b[1]]}function r(t){x=Math.max(w[0],Math.min(w[1],t))}function i(t,n){n=e(n),b[0]+=t[0]-n[0],b[1]+=t[1]-n[1]}function u(){m&&m.domain(p.range().map(function(t){return(t-b[0])/x}).map(p.invert)),y&&y.domain(v.range().map(function(t){return(t-b[1])/x}).map(v.invert))}function a(t){u(),d3.event.preventDefault(),t({type:"zoom",scale:x,translate:b})}function o(){function t(){c=1,i(d3.mouse(u),f),a(o)}function e(){c&&H(),s.on("mousemove.zoom",null).on("mouseup.zoom",null),c&&d3.event.target===l&&s.on("click.zoom",r,!0)}function r(){H(),s.on("click.zoom",null)}var u=this,o=_.of(u,arguments),l=d3.event.target,c=0,s=d3.select(window).on("mousemove.zoom",t).on("mouseup.zoom",e),f=n(d3.mouse(u));window.focus(),H()}function l(){d||(d=n(d3.mouse(this))),r(Math.pow(2,Ve()*.002)*x),i(d3.mouse(this),d),a(_.of(this,arguments))}function c(){d=null}function s(){var t=d3.mouse(this),e=n(t);r(d3.event.shiftKey?x/2:x*2),i(t,e),a(_.of(this,arguments))}function f(){var t=d3.touches(this),e=Date.now();if(g=x,d={},t.forEach(function(t){d[t.identifier]=n(t)}),H(),t.length===1){if(500>e-M){var u=t[0],o=n(t[0]);r(x*2),i(u,o),a(_.of(this,arguments))}M=e}}function h(){var t=d3.touches(this),n=t[0],e=d[n.identifier];if(u=t[1]){var u,o=d[u.identifier];n=[(n[0]+u[0])/2,(n[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r(d3.event.scale*g)}i(n,e),M=null,a(_.of(this,arguments))}var d,g,p,m,v,y,M,b=[0,0],x=1,w=Ha,_=O(t,"zoom");return t.translate=function(n){return arguments.length?(b=n.map(Number),u(),t):b},t.scale=function(n){return arguments.length?(x=+n,u(),t):x},t.scaleExtent=function(n){return arguments.length?(w=n==null?Ha:n.map(Number),t):w},t.x=function(n){return arguments.length?(m=n,p=n.copy(),b=[0,0],x=1,t):m},t.y=function(n){return arguments.length?(y=n,v=n.copy(),b=[0,0],x=1,t):y},d3.rebind(t,_,"on")};var Fa,Ha=[0,1/0];d3.layout={},d3.layout.bundle=function(){return function(t){var n=[],e=-1,r=t.length;while(r>++e)n.push(Ze(t[e]));return n}},d3.layout.chord=function(){function t(){var t,c,f,h,d,g={},p=[],m=d3.range(u),v=[];e=[],r=[],t=0,h=-1;while(u>++h){c=0,d=-1;while(u>++d)c+=i[h][d];p.push(c),v.push(d3.range(u)),t+=c}a&&m.sort(function(t,n){return a(p[t],p[n])}),o&&v.forEach(function(t,n){t.sort(function(t,e){return o(i[n][t],i[n][e])})}),t=(2*_u-s*u)/t,c=0,h=-1;while(u>++h){f=c,d=-1;while(u>++d){var y=m[h],M=v[y][d],b=i[y][M],x=c,w=c+=b*t;g[y+"-"+M]={index:y,subindex:M,startAngle:x,endAngle:w,value:b}}r[y]={index:y,startAngle:f,endAngle:c,value:(c-f)/t},c+=s}h=-1;while(u>++h){d=h-1;while(u>++d){var _=g[h+"-"+d],k=g[d+"-"+h];(_.value||k.value)&&e.push(k.value>_.value?{source:k,target:_}:{source:_,target:k})}}l&&n()}function n(){e.sort(function(t,n){return l((t.source.value+t.target.value)/2,(n.source.value+n.target.value)/2)})}var e,r,i,u,a,o,l,c={},s=0;return c.matrix=function(t){return arguments.length?(u=(i=t)&&i.length,e=r=null,c):i},c.padding=function(t){return arguments.length?(s=t,e=r=null,c):s},c.sortGroups=function(t){return arguments.length?(a=t,e=r=null,c):a},c.sortSubgroups=function(t){return arguments.length?(o=t,e=null,c):o},c.sortChords=function(t){return arguments.length?(l=t,e&&n(),c):l},c.chords=function(){return e||t(),e},c.groups=function(){return r||t(),r},c},d3.layout.force=function(){function t(t){return function(n,e,r,i){if(n.point!==t){var u=n.cx-t.x,a=n.cy-t.y,o=1/Math.sqrt(u*u+a*a);if(v>(i-e)*o){var l=n.charge*o*o;return t.px-=u*l,t.py-=a*l,!0}if(n.point&&isFinite(o)){var l=n.pointCharge*o*o;t.px-=u*l,t.py-=a*l}}return!n.charge}}function n(t){t.px=d3.event.x,t.py=d3.event.y,l.resume()}var e,r,i,u,a,l={},s=d3.dispatch("start","tick","end"),f=[1,1],h=.9,d=Qe,g=tr,p=-30,m=.1,v=.8,y=[],M=[];return l.tick=function(){if(.005>(r*=.99))return s.end({type:"end",alpha:r=0}),!0;var n,e,o,l,c,d,g,v,b,x=y.length,w=M.length;for(e=0;w>e;++e)o=M[e],l=o.source,c=o.target,v=c.x-l.x,b=c.y-l.y,(d=v*v+b*b)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,v*=d,b*=d,c.x-=v*(g=l.weight/(c.weight+l.weight)),c.y-=b*g,l.x+=v*(g=1-g),l.y+=b*g);if((g=r*m)&&(v=f[0]/2,b=f[1]/2,e=-1,g))while(x>++e)o=y[e],o.x+=(v-o.x)*g,o.y+=(b-o.y)*g;if(p){We(n=d3.geom.quadtree(y),r,a),e=-1;while(x>++e)(o=y[e]).fixed||n.visit(t(o))}e=-1;while(x>++e)o=y[e],o.fixed?(o.x=o.px,o.y=o.py):(o.x-=(o.px-(o.px=o.x))*h,o.y-=(o.py-(o.py=o.y))*h);s.tick({type:"tick",alpha:r})},l.nodes=function(t){return arguments.length?(y=t,l):y},l.links=function(t){return arguments.length?(M=t,l):M},l.size=function(t){return arguments.length?(f=t,l):f},l.linkDistance=function(t){return arguments.length?(d=c(t),l):d},l.distance=l.linkDistance,l.linkStrength=function(t){return arguments.length?(g=c(t),l):g},l.friction=function(t){return arguments.length?(h=t,l):h},l.charge=function(t){return arguments.length?(p=typeof t=="function"?t:+t,l):p},l.gravity=function(t){return arguments.length?(m=t,l):m},l.theta=function(t){return arguments.length?(v=t,l):v},l.alpha=function(t){return arguments.length?(r?r=t>0?t:0:t>0&&(s.start({type:"start",alpha:r=t}),d3.timer(l.tick)),l):r},l.start=function(){function t(t,r){var i,u=n(e),a=-1,o=u.length;while(o>++a)if(!isNaN(i=u[a][t]))return i;return Math.random()*r}function n(){if(!o){for(o=[],r=0;s>r;++r)o[r]=[];for(r=0;h>r;++r){var t=M[r];o[t.source.index].push(t.target),o[t.target.index].push(t.source)}}return o[e]}var e,r,o,c,s=y.length,h=M.length,m=f[0],v=f[1];for(e=0;s>e;++e)(c=y[e]).index=e,c.weight=0;for(i=[],u=[],e=0;h>e;++e)c=M[e],typeof c.source=="number"&&(c.source=y[c.source]),typeof c.target=="number"&&(c.target=y[c.target]),i[e]=d.call(this,c,e),u[e]=g.call(this,c,e),++c.source.weight,++c.target.weight;for(e=0;s>e;++e)c=y[e],isNaN(c.x)&&(c.x=t("x",m)),isNaN(c.y)&&(c.y=t("y",v)),isNaN(c.px)&&(c.px=c.x),isNaN(c.py)&&(c.py=c.y);if(a=[],typeof p=="function")for(e=0;s>e;++e)a[e]=+p.call(this,y[e],e);else for(e=0;s>e;++e)a[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){e||(e=d3.behavior.drag().origin(o).on("dragstart",$e).on("drag",n).on("dragend",Ge)),this.on("mouseover.force",Je).on("mouseout.force",Ke).call(e) -},d3.rebind(l,s,"on")},d3.layout.partition=function(){function t(n,e,r,i){var u=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,u&&(a=u.length)){var a,o,l,c=-1;r=n.value?r/n.value:0;while(a>++c)t(o=u[c],e,l=o.value*r,i),e+=l}}function n(t){var e=t.children,r=0;if(e&&(i=e.length)){var i,u=-1;while(i>++u)r=Math.max(r,n(e[u]))}return 1+r}function e(e,u){var a=r.call(this,e,u);return t(a[0],0,i[0],i[1]/n(a[0])),a}var r=d3.layout.hierarchy(),i=[1,1];return e.size=function(t){return arguments.length?(i=t,e):i},hr(e,r)},d3.layout.pie=function(){function t(u){var a=u.map(function(e,r){return+n.call(t,e,r)}),o=+(typeof r=="function"?r.apply(this,arguments):r),l=((typeof i=="function"?i.apply(this,arguments):i)-r)/d3.sum(a),c=d3.range(u.length);e!=null&&c.sort(e===ja?function(t,n){return a[n]-a[t]}:function(t,n){return e(u[t],u[n])});var s=[];return c.forEach(function(t){var n;s[t]={data:u[t],value:n=a[t],startAngle:o,endAngle:o+=n*l}}),s}var n=Number,e=ja,r=0,i=2*_u;return t.value=function(e){return arguments.length?(n=e,t):n},t.sort=function(n){return arguments.length?(e=n,t):e},t.startAngle=function(n){return arguments.length?(r=n,t):r},t.endAngle=function(n){return arguments.length?(i=n,t):i},t};var ja={};d3.layout.stack=function(){function t(o,l){var c=o.map(function(e,r){return n.call(t,e,r)}),s=c.map(function(n){return n.map(function(n,e){return[u.call(t,n,e),a.call(t,n,e)]})}),f=e.call(t,s,l);c=d3.permute(c,f),s=d3.permute(s,f);var h,d,g,p=r.call(t,s,l),m=c.length,v=c[0].length;for(d=0;v>d;++d)for(i.call(t,c[0][d],g=p[d],s[0][d][1]),h=1;m>h;++h)i.call(t,c[h][d],g+=s[h-1][d][1],s[h][d][1]);return o}var n=o,e=ir,r=ur,i=rr,u=nr,a=er;return t.values=function(e){return arguments.length?(n=e,t):n},t.order=function(n){return arguments.length?(e=typeof n=="function"?n:Oa.get(n)||ir,t):e},t.offset=function(n){return arguments.length?(r=typeof n=="function"?n:Ra.get(n)||ur,t):r},t.x=function(n){return arguments.length?(u=n,t):u},t.y=function(n){return arguments.length?(a=n,t):a},t.out=function(n){return arguments.length?(i=n,t):i},t};var Oa=d3.map({"inside-out":function(t){var n,e,r=t.length,i=t.map(ar),u=t.map(or),a=d3.range(r).sort(function(t,n){return i[t]-i[n]}),o=0,l=0,c=[],s=[];for(n=0;r>n;++n)e=a[n],l>o?(o+=u[e],c.push(e)):(l+=u[e],s.push(e));return s.reverse().concat(c)},reverse:function(t){return d3.range(t.length).reverse()},"default":ir}),Ra=d3.map({silhouette:function(t){var n,e,r,i=t.length,u=t[0].length,a=[],o=0,l=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)l[e]=(o-a[e])/2;return l},wiggle:function(t){var n,e,r,i,u,a,o,l,c,s=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,e=1;h>e;++e){for(n=0,i=0;s>n;++n)i+=t[n][e][1];for(n=0,u=0,o=f[e][0]-f[e-1][0];s>n;++n){for(r=0,a=(t[n][e][1]-t[n][e-1][1])/(2*o);n>r;++r)a+=(t[r][e][1]-t[r][e-1][1])/o;u+=a*t[n][e][1]}d[e]=l-=i?u/i*o:0,c>l&&(c=l)}for(e=0;h>e;++e)d[e]-=c;return d},expand:function(t){var n,e,r,i=t.length,u=t[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];if(r)for(n=0;i>n;n++)t[n][e][1]/=r;else for(n=0;i>n;n++)t[n][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:ur});d3.layout.histogram=function(){function t(t,u){var a,o,l=[],c=t.map(e,this),s=r.call(this,c,u),f=i.call(this,s,c,u),u=-1,h=c.length,d=f.length-1,g=n?1:1/h;while(d>++u)a=l[u]=[],a.dx=f[u+1]-(a.x=f[u]),a.y=0;if(d>0){u=-1;while(h>++u)o=c[u],o>=s[0]&&s[1]>=o&&(a=l[d3.bisect(f,o,1,d)-1],a.y+=g,a.push(t[u]))}return l}var n=!0,e=Number,r=fr,i=cr;return t.value=function(n){return arguments.length?(e=n,t):e},t.range=function(n){return arguments.length?(r=c(n),t):r},t.bins=function(n){return arguments.length?(i=typeof n=="number"?function(t){return sr(t,n)}:c(n),t):i},t.frequency=function(e){return arguments.length?(n=!!e,t):n},t},d3.layout.hierarchy=function(){function t(n,a,o){var l=i.call(e,n,a),c=Ya?n:{data:n};if(c.depth=a,o.push(c),l&&(s=l.length)){var s,f,h=-1,d=c.children=[],g=0,p=a+1;while(s>++h)f=t(l[h],p,o),f.parent=c,d.push(f),g+=f.value;r&&d.sort(r),u&&(c.value=g)}else u&&(c.value=+u.call(e,n,a)||0);return c}function n(t,r){var i=t.children,a=0;if(i&&(o=i.length)){var o,l=-1,c=r+1;while(o>++l)a+=n(i[l],c)}else u&&(a=+u.call(e,Ya?t:t.data,r)||0);return u&&(t.value=a),a}function e(n){var e=[];return t(n,0,e),e}var r=pr,i=dr,u=gr;return e.sort=function(t){return arguments.length?(r=t,e):r},e.children=function(t){return arguments.length?(i=t,e):i},e.value=function(t){return arguments.length?(u=t,e):u},e.revalue=function(t){return n(t,0),t},e};var Ya=!1;d3.layout.pack=function(){function t(t,i){var u=n.call(this,t,i),a=u[0];a.x=0,a.y=0,Hr(a,function(t){t.r=Math.sqrt(t.value)}),Hr(a,xr);var o=r[0],l=r[1],c=Math.max(2*a.r/o,2*a.r/l);if(e>0){var s=e*c/2;Hr(a,function(t){t.r+=s}),Hr(a,xr),Hr(a,function(t){t.r-=s}),c=Math.max(2*a.r/o,2*a.r/l)}return kr(a,o/2,l/2,1/c),u}var n=d3.layout.hierarchy().sort(vr),e=0,r=[1,1];return t.size=function(n){return arguments.length?(r=n,t):r},t.padding=function(n){return arguments.length?(e=+n,t):e},hr(t,n)},d3.layout.cluster=function(){function t(t,i){var u,a=n.call(this,t,i),o=a[0],l=0;Hr(o,function(t){var n=t.children;n&&n.length?(t.x=Ar(n),t.y=Sr(n)):(t.x=u?l+=e(t,u):0,t.y=0,u=t)});var c=Nr(o),s=Cr(o),f=c.x-e(c,s)/2,h=s.x+e(s,c)/2;return Hr(o,function(t){t.x=(t.x-f)/(h-f)*r[0],t.y=(1-(o.y?t.y/o.y:1))*r[1]}),a}var n=d3.layout.hierarchy().sort(null).value(null),e=qr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},hr(t,n)},d3.layout.tree=function(){function t(t,i){function u(t,n){var r=t.children,i=t._tree;if(r&&(a=r.length)){var a,l,c,s=r[0],f=s,h=-1;while(a>++h)c=r[h],u(c,l),f=o(c,l,f),l=c;jr(t);var d=.5*(s._tree.prelim+c._tree.prelim);n?(i.prelim=n._tree.prelim+e(t,n),i.mod=i.prelim-d):i.prelim=d}else n&&(i.prelim=n._tree.prelim+e(t,n))}function a(t,n){t.x=t._tree.prelim+n;var e=t.children;if(e&&(r=e.length)){var r,i=-1;n+=t._tree.mod;while(r>++i)a(e[i],n)}}function o(t,n,r){if(n){var i,u=t,a=t,o=n,l=t.parent.children[0],c=u._tree.mod,s=a._tree.mod,f=o._tree.mod,h=l._tree.mod;while(o=Er(o),u=zr(u),o&&u)l=zr(l),a=Er(a),a._tree.ancestor=t,i=o._tree.prelim+f-u._tree.prelim-c+e(o,u),i>0&&(Or(Rr(o,t,r),t,i),c+=i,s+=i),f+=o._tree.mod,c+=u._tree.mod,h+=l._tree.mod,s+=a._tree.mod;o&&!Er(a)&&(a._tree.thread=o,a._tree.mod+=f-s),u&&!zr(l)&&(l._tree.thread=u,l._tree.mod+=c-h,r=t)}return r}var l=n.call(this,t,i),c=l[0];Hr(c,function(t,n){t._tree={ancestor:t,prelim:0,mod:0,change:0,shift:0,number:n?n._tree.number+1:0}}),u(c),a(c,-c._tree.prelim);var s=Dr(c,Lr),f=Dr(c,Pr),h=Dr(c,Fr),d=s.x-e(s,f)/2,g=f.x+e(f,s)/2,p=h.depth||1;return Hr(c,function(t){t.x=(t.x-d)/(g-d)*r[0],t.y=t.depth/p*r[1],delete t._tree}),l}var n=d3.layout.hierarchy().sort(null).value(null),e=qr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},hr(t,n)},d3.layout.treemap=function(){function t(t,n){var e,r,i=-1,u=t.length;while(u>++i)r=(e=t[i]).value*(0>n?0:n),e.area=isNaN(r)||0>=r?0:r}function n(e){var u=e.children;if(u&&u.length){var a,o,l,c=f(e),s=[],h=u.slice(),g=1/0,p=d==="slice"?c.dx:d==="dice"||d==="slice-dice"&&e.depth&1?c.dy:Math.min(c.dx,c.dy);t(h,c.dx*c.dy/e.value),s.area=0;while((l=h.length)>0)s.push(a=h[l-1]),s.area+=a.area,d!=="squarify"||g>=(o=r(s,p))?(h.pop(),g=o):(s.area-=s.pop().area,i(s,p,c,!1),p=Math.min(c.dx,c.dy),s.length=s.area=0,g=1/0);s.length&&(i(s,p,c,!0),s.length=s.area=0),u.forEach(n)}}function e(n){var r=n.children;if(r&&r.length){var u,a=f(n),o=r.slice(),l=[];t(o,a.dx*a.dy/n.value),l.area=0;while(u=o.pop())l.push(u),l.area+=u.area,u.z!=null&&(i(l,u.z?a.dx:a.dy,a,!o.length),l.length=l.area=0);r.forEach(e)}}function r(t,n){var e,r=t.area,i=0,u=1/0,a=-1,o=t.length;while(o>++a)(e=t[a].area)&&(u>e&&(u=e),e>i&&(i=e));return r*=r,n*=n,r?Math.max(n*i*g/r,r/(n*u*g)):1/0}function i(t,n,e,r){var i,u=-1,a=t.length,o=e.x,c=e.y,s=n?l(t.area/n):0;if(n==e.dx){(r||s>e.dy)&&(s=e.dy);while(a>++u)i=t[u],i.x=o,i.y=c,i.dy=s,o+=i.dx=Math.min(e.x+e.dx-o,s?l(i.area/s):0);i.z=!0,i.dx+=e.x+e.dx-o,e.y+=s,e.dy-=s}else{(r||s>e.dx)&&(s=e.dx);while(a>++u)i=t[u],i.x=o,i.y=c,i.dx=s,c+=i.dy=Math.min(e.y+e.dy-c,s?l(i.area/s):0);i.z=!1,i.dy+=e.y+e.dy-c,e.x+=s,e.dx-=s}}function u(r){var i=a||o(r),u=i[0];return u.x=0,u.y=0,u.dx=c[0],u.dy=c[1],a&&o.revalue(u),t([u],u.dx*u.dy/u.value),(a?e:n)(u),h&&(a=i),i}var a,o=d3.layout.hierarchy(),l=Math.round,c=[1,1],s=null,f=Yr,h=!1,d="squarify",g=.5*(1+Math.sqrt(5));return u.size=function(t){return arguments.length?(c=t,u):c},u.padding=function(t){function n(n){var e=t.call(u,n,n.depth);return e==null?Yr(n):Ur(n,typeof e=="number"?[e,e,e,e]:e)}function e(n){return Ur(n,t)}if(!arguments.length)return s;var r;return f=(s=t)==null?Yr:(r=typeof t)=="function"?n:r==="number"?(t=[t,t,t,t],e):e,u},u.round=function(t){return arguments.length?(l=t?Math.round:Number,u):l!=Number},u.sticky=function(t){return arguments.length?(h=t,a=null,u):h},u.ratio=function(t){return arguments.length?(g=t,u):g},u.mode=function(t){return arguments.length?(d=t+"",u):d},hr(u,o)},d3.csv=Ir(",","text/csv"),d3.tsv=Ir(" ","text/tab-separated-values"),d3.geo={};var Ua={Feature:function(t){this.geometry(t.geometry)},FeatureCollection:function(t){var n=t.features,e=-1,r=n.length;while(r>++e)this.Feature(n[e])},GeometryCollection:function(t){var n=t.geometries,e=-1,r=n.length;while(r>++e)this.geometry(n[e])},LineString:function(t){this.line(t.coordinates)},MultiLineString:function(t){var n=t.coordinates,e=-1,r=n.length;while(r>++e)this.line(n[e])},MultiPoint:function(t){var n=t.coordinates,e=-1,r=n.length;while(r>++e)this.point(n[e])},MultiPolygon:function(t){var n=t.coordinates,e=-1,r=n.length;while(r>++e)this.polygon(n[e])},Point:function(t){this.point(t.coordinates)},Polygon:function(t){this.polygon(t.coordinates)},object:function(t){return Va.hasOwnProperty(t.type)?this[t.type](t):this.geometry(t)},geometry:function(t){return Ia.hasOwnProperty(t.type)?this[t.type](t):null},point:jn,line:function(t){var n=-1,e=t.length;while(e>++n)this.point(t[n])},polygon:function(t){var n=-1,e=t.length;while(e>++n)this.line(t[n])}},Ia={LineString:1,MultiLineString:1,MultiPoint:1,MultiPolygon:1,Point:1,Polygon:1},Va={Feature:1,FeatureCollection:1,GeometryCollection:1};d3.geo.albersUsa=function(){function t(t){return n(t)(t)}function n(t){var n=t[0],a=t[1];return a>50?r:-140>n?i:21>a?u:e}var e=d3.geo.albers(),r=d3.geo.albers().rotate([160,0]).center([0,60]).parallels([55,65]),i=d3.geo.albers().rotate([160,0]).center([0,20]).parallels([8,18]),u=d3.geo.albers().rotate([60,0]).center([0,10]).parallels([8,18]);return t.point=function(t,e){return n(t).point(t,e)},t.line=function(t,e){return n(t[0]).line(t,e)},t.polygon=function(t,e){return n(t[0][0]).polygon(t,e)},t.scale=function(n){return arguments.length?(e.scale(n),r.scale(n*.6),i.scale(n),u.scale(n*1.5),t.translate(e.translate())):e.scale()},t.translate=function(n){if(!arguments.length)return e.translate();var a=e.scale(),o=n[0],l=n[1];return e.translate(n),r.translate([o-.4*a,l+.17*a]),i.translate([o-.19*a,l+.2*a]),u.translate([o+.58*a,l+.43*a]),t},t.scale(e.scale())},(d3.geo.albers=function(){var t=29.5*Su,n=45.5*Su,e=bi(Zr),r=e(t,n);return r.parallels=function(r){return arguments.length?e(t=r[0]*Su,n=r[1]*Su):[t*Au,n*Au]},r.rotate([98,0]).center([0,38]).scale(1e3)}).raw=Zr;var Za=qi(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(d3.geo.azimuthalEqualArea=function(){return Mi(Za)}).raw=Za;var Ba=qi(function(t){var n=Math.acos(t);return n&&n/Math.sin(n)},o);(d3.geo.azimuthalEquidistant=function(){return Mi(Ba)}).raw=Ba,d3.geo.bounds=Br(o),d3.geo.circle=function(){function t(){var t=typeof i=="function"?i.apply(this,arguments):i;e=Ti(-t[0]*Su,-t[1]*Su,0);var n=[];return li(r,{lineTo:function(t,r){var i=e.invert(t,r);i[0]*=Au,i[1]*=Au,n.push(i)}}),{type:"Polygon",coordinates:[n]}}var n,e,r,i=[0,0],u=6;return t.origin=function(n){return arguments.length?(i=n,t):i},t.angle=function(e){return arguments.length?(r=$r((n=+e)*Su,u*Su),t):n},t.precision=function(n){return arguments.length?(r=$r(radians,(u=+n)*Su),t):u},t.angle(90)},(d3.geo.equirectangular=function(){return Mi(si).scale(250/_u)}).raw=si.invert=si;var Xa=qi(function(t){return 1/t},Math.atan);(d3.geo.gnomonic=function(){return Mi(Xa)}).raw=Xa,d3.geo.graticule=function(){function t(){return{type:"GeometryCollection",geometries:t.lines()}}var n,e,r,i,u,a,o=22.5,l=o,c=2.5;return t.lines=function(){return d3.range(Math.ceil(e/o)*o,n,o).map(u).concat(d3.range(Math.ceil(i/l)*l,r,l).map(a)).map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[u(e).concat(a(r).slice(1),u(n).reverse().slice(1),a(i).reverse().slice(1))]}},t.extent=function(u){return arguments.length?(e=+u[0][0],n=+u[1][0],i=+u[0][1],r=+u[1][1],e>n&&(u=e,e=n,n=u),i>r&&(u=i,i=r,r=u),t.precision(c)):[[e,i],[n,r]]},t.step=function(n){return arguments.length?(o=+n[0],l=+n[1],t):[o,l]},t.precision=function(o){return arguments.length?(c=+o,u=fi(i,r,c),a=hi(e,n,c),t):c},t.extent([[-180+ku,-90+ku],[180-ku,90-ku]])},d3.geo.greatArc=function(){function t(){var n=t.distance.apply(this,arguments),e=0,u=o/n,a=[r];while(1>(e+=u))a.push(l(e));return a.push(i),{type:"LineString",coordinates:a}}var r,i,u=e,a=n,o=6*Su,l=di();return t.distance=function(){return typeof u=="function"&&l.source(r=u.apply(this,arguments)),typeof a=="function"&&l.target(i=a.apply(this,arguments)),l.distance()},t.source=function(n){return arguments.length?(u=n,typeof u!="function"&&l.source(r=u),t):u},t.target=function(n){return arguments.length?(a=n,typeof a!="function"&&l.target(i=a),t):a},t.precision=function(n){return arguments.length?(o=n*Su,t):o/Su},t},gi.invert=function(t,n){return[2*_u*t,2*Math.atan(Math.exp(2*_u*n))-_u/2]},(d3.geo.mercator=function(){return Mi(gi).scale(500)}).raw=gi;var $a=qi(function(){return 1},Math.asin);(d3.geo.orthographic=function(){return Mi($a)}).raw=$a,d3.geo.path=function(){function n(t){var n=null;return t!=n&&(typeof l=="function"&&(c=pi(l.apply(this,arguments))),g.object(t),f.length&&(n=f.join(""),f=[])),n}function e(t){return Math.abs(d3.geom.polygon(t.map(s)).area())}function r(t){return e(t[0])-d3.sum(t.slice(1),e)}function i(t,n){return n=s(n),t[0]+=n[0],t[1]+=n[1],1}function u(t,n){if(!(e=n.length))return 0;var e,r,i,u,a,o,l=s(n[0]),c=l[0],f=l[1],h=0,d=0;while(e>++h)l=s(n[h]),r=l[0],i=l[1],u=r-c,a=i-f,d+=o=Math.sqrt(u*u+a*a),t[0]+=o*(c+r)/2,t[1]+=o*(f+i)/2,c=r,f=i;return d}function a(t,n,e){var r=d3.geom.polygon(n.map(s)),i=r.area(),u=r.centroid(0>i?(i*=-1,1):-1);return t[0]+=u[0],t[1]+=u[1],i*(e>0?-6:6)}var o,l=4.5,c=pi(l),s=d3.geo.albersUsa(),f=[],h={point:function(t,n){f.push("M",t,",",n,c)},moveTo:function(t,n){f.push("M",t,",",n)},lineTo:function(t,n){f.push("L",t,",",n)},closePath:function(){f.push("Z")}},d=h,g=Vr({line:function(t){s.line(t,d)},polygon:function(t){s.polygon(t,d)},point:function(t){s.point(t,d)}}),p=Vr({Feature:function(t){return p.geometry(t.geometry)},FeatureCollection:function(t){return d3.sum(t.features,p.Feature)},GeometryCollection:function(t){return d3.sum(t.geometries,p.geometry)},LineString:t,MultiLineString:t,MultiPoint:t,MultiPolygon:function(t){return d3.sum(t.coordinates,r)},Point:t,Polygon:function(t){return r(t.coordinates)}});n.area=function(t){return p.object(t)};var m=Vr({Feature:function(t){return m.geometry(t.geometry)},LineString:mi(u),MultiLineString:vi(u),MultiPoint:vi(i),MultiPolygon:yi(a),Point:mi(i),Polygon:vi(a)});return n.bounds=function(t){return(o||(o=Br(s)))(t)},n.centroid=function(t){return m.object(t)},n.projection=function(t){return arguments.length?(s=t,o=null,n):s},n.context=function(t){return arguments.length?(d=t,d==null&&(d=h),n):d===h?null:d},n.pointRadius=function(t){return arguments.length?(typeof t=="function"?l=t:c=pi(l=+t),n):l},n},d3.geo.projection=Mi,d3.geo.projectionMutator=bi,Si.invert=function(t,n){return[t,n]};var Ga=qi(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(d3.geo.stereographic=function(){return Mi(Ga)}).raw=Ga,d3.geom={},d3.geom.hull=function(t){if(3>t.length)return[];var n,e,r,i,u,a,o,l,c,s,f=t.length,h=f-1,d=[],g=[],p=0;for(n=1;f>n;++n)t[p][1]>t[n][1]?p=n:t[n][1]==t[p][1]&&(p=t[p][0]>t[n][0]?n:p);for(n=0;f>n;++n)n!==p&&(i=t[n][1]-t[p][1],r=t[n][0]-t[p][0],d.push({angle:Math.atan2(i,r),index:n}));for(d.sort(function(t,n){return t.angle-n.angle}),c=d[0].angle,l=d[0].index,o=0,n=1;h>n;++n)e=d[n].index,c==d[n].angle?(r=t[l][0]-t[p][0],i=t[l][1]-t[p][1],u=t[e][0]-t[p][0],a=t[e][1]-t[p][1],r*r+i*i>=u*u+a*a?d[n].index=-1:(d[o].index=-1,c=d[n].angle,o=n,l=e)):(c=d[n].angle,o=n,l=e);for(g.push(p),n=0,e=0;2>n;++e)d[e].index!==-1&&(g.push(d[e].index),n++);for(s=g.length;h>e;++e)if(d[e].index!==-1){while(!zi(g[s-2],g[s-1],d[e].index,t))--s;g[s++]=d[e].index}var m=[];for(n=0;s>n;++n)m.push(t[g[n]]);return m},d3.geom.polygon=function(t){return t.area=function(){var n=0,e=t.length,r=t[e-1][0]*t[0][1],i=t[e-1][1]*t[0][0];while(e>++n)r+=t[n-1][0]*t[n][1],i+=t[n-1][1]*t[n][0];return(i-r)*.5},t.centroid=function(n){var e,r,i=-1,u=t.length,a=0,o=0,l=t[u-1];arguments.length||(n=-1/(6*t.area()));while(u>++i)e=l,l=t[i],r=e[0]*l[1]-l[0]*e[1],a+=(e[0]+l[0])*r,o+=(e[1]+l[1])*r;return[a*n,o*n]},t.clip=function(n){var e,r,i,u,a,o,l=-1,c=t.length,s=t[c-1];while(c>++l){e=n.slice(),n.length=0,u=t[l],a=e[(i=e.length)-1],r=-1;while(i>++r)o=e[r],Ei(o,s,u)?(Ei(a,s,u)||n.push(Di(a,o,s,u)),n.push(o)):Ei(a,s,u)&&n.push(Di(a,o,s,u)),a=o;s=u}return n},t},d3.geom.voronoi=function(t){var n=t.map(function(){return[]}),e=1e6;return Pi(t,function(t){var r,i,u,a,o,l;t.a===1&&t.b>=0?(r=t.ep.r,i=t.ep.l):(r=t.ep.l,i=t.ep.r),t.a===1?(o=r?r.y:-e,u=t.c-t.b*o,l=i?i.y:e,a=t.c-t.b*l):(u=r?r.x:-e,o=t.c-t.a*u,a=i?i.x:e,l=t.c-t.a*a);var c=[u,o],s=[a,l];n[t.region.l.index].push(c,s),n[t.region.r.index].push(c,s)}),n=n.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(t){return Math.atan2(t[0]-r,t[1]-i)});return d3.range(n.length).sort(function(t,n){return u[t]-u[n]}).filter(function(t,n,e){return!n||u[t]-u[e[n-1]]>ku}).map(function(t){return n[t]})}),n.forEach(function(n,r){var i=n.length;if(!i)return n.push([-e,-e],[-e,e],[e,e],[e,-e]);if(!(i>2)){var u=t[r],a=n[0],o=n[1],l=u[0],c=u[1],s=a[0],f=a[1],h=o[0],d=o[1],g=Math.abs(h-s),p=d-f;if(ku>Math.abs(p)){var m=f>c?-e:e;n.push([-e,m],[e,m])}else if(ku>g){var v=s>l?-e:e;n.push([v,-e],[v,e])}else{var m=(s-l)*(d-f)>(h-s)*(f-c)?e:-e,y=Math.abs(p)-g;ku>Math.abs(y)?n.push([0>p?m:-m,m]):(y>0&&(m*=-1),n.push([-e,m],[e,m]))}}}),n};var Ja={l:"r",r:"l"};d3.geom.delaunay=function(t){var n=t.map(function(){return[]}),e=[];return Pi(t,function(e){n[e.region.l.index].push(t[e.region.r.index])}),n.forEach(function(n,r){var i=t[r],u=i[0],a=i[1];n.forEach(function(t){t.angle=Math.atan2(t[0]-u,t[1]-a)}),n.sort(function(t,n){return t.angle-n.angle});for(var o=0,l=n.length-1;l>o;o++)e.push([i,n[o],n[o+1]])}),e},d3.geom.quadtree=function(t,n,e,r,i){function u(t,n,e,r,i,u){if(!isNaN(n.x)&&!isNaN(n.y))if(t.leaf){var o=t.point;o?.01>Math.abs(o.x-n.x)+Math.abs(o.y-n.y)?a(t,n,e,r,i,u):(t.point=null,a(t,o,e,r,i,u),a(t,n,e,r,i,u)):t.point=n}else a(t,n,e,r,i,u)}function a(t,n,e,r,i,a){var o=(e+i)*.5,l=(r+a)*.5,c=n.x>=o,s=n.y>=l,f=(s<<1)+c;t.leaf=!1,t=t.nodes[f]||(t.nodes[f]=Li()),c?e=o:i=o,s?r=l:a=l,u(t,n,e,r,i,a)}var o,l=-1,c=t.length;if(5>arguments.length)if(arguments.length===3)i=e,r=n,e=n=0;else{n=e=1/0,r=i=-1/0;while(c>++l)o=t[l],n>o.x&&(n=o.x),e>o.y&&(e=o.y),o.x>r&&(r=o.x),o.y>i&&(i=o.y)}var s=r-n,f=i-e;s>f?i=e+s:r=n+f;var h=Li();return h.add=function(t){u(h,t,n,e,r,i)},h.visit=function(t){Fi(t,h,n,e,r,i)},t.forEach(h.add),h},d3.time={};var Ka=Date,Wa=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Hi.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Qa.setUTCDate.apply(this._,arguments)},setDay:function(){Qa.setUTCDay.apply(this._,arguments)},setFullYear:function(){Qa.setUTCFullYear.apply(this._,arguments)},setHours:function(){Qa.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Qa.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Qa.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Qa.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Qa.setUTCSeconds.apply(this._,arguments)},setTime:function(){Qa.setTime.apply(this._,arguments)}};var Qa=Date.prototype,to="%a %b %e %X %Y",no="%m/%d/%Y",eo="%H:%M:%S",ro=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],io=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],uo=["January","February","March","April","May","June","July","August","September","October","November","December"],ao=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];d3.time.format=function(t){function n(n){var r,i,u,a=[],o=-1,l=0;while(e>++o)t.charCodeAt(o)===37&&(a.push(t.substring(l,o)),(i=go[r=t.charAt(++o)])!=null&&(r=t.charAt(++o)),(u=po[r])&&(r=u(n,i==null?r==="e"?" ":"0":i)),a.push(r),l=o+1);return a.push(t.substring(l,o)),a.join("")}var e=t.length;return n.parse=function(n){var e={y:1900,m:0,d:1,H:0,M:0,S:0,L:0},r=ji(e,t,n,0);if(r!=n.length)return null;"p"in e&&(e.H=e.H%12+e.p*12);var i=new Ka;return i.setFullYear(e.y,e.m,e.d),i.setHours(e.H,e.M,e.S,e.L),i},n.toString=function(){return t},n};var oo=Oi(ro),lo=Oi(io),co=Oi(uo),so=Ri(uo),fo=Oi(ao),ho=Ri(ao),go={"-":"",_:" ",0:"0"},po={a:function(t){return io[t.getDay()]},A:function(t){return ro[t.getDay()]},b:function(t){return ao[t.getMonth()]},B:function(t){return uo[t.getMonth()]},c:d3.time.format(to),d:function(t,n){return Yi(t.getDate(),n,2)},e:function(t,n){return Yi(t.getDate(),n,2)},H:function(t,n){return Yi(t.getHours(),n,2)},I:function(t,n){return Yi(t.getHours()%12||12,n,2)},j:function(t,n){return Yi(1+d3.time.dayOfYear(t),n,3)},L:function(t,n){return Yi(t.getMilliseconds(),n,3)},m:function(t,n){return Yi(t.getMonth()+1,n,2)},M:function(t,n){return Yi(t.getMinutes(),n,2)},p:function(t){return t.getHours()>=12?"PM":"AM"},S:function(t,n){return Yi(t.getSeconds(),n,2)},U:function(t,n){return Yi(d3.time.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return Yi(d3.time.mondayOfYear(t),n,2)},x:d3.time.format(no),X:d3.time.format(eo),y:function(t,n){return Yi(t.getFullYear()%100,n,2)},Y:function(t,n){return Yi(t.getFullYear()%1e4,n,4)},Z:uu,"%":function(){return"%"}},mo={a:Ui,A:Ii,b:Vi,B:Zi,c:Bi,d:Qi,e:Qi,H:tu,I:tu,L:ru,m:Wi,M:nu,p:iu,S:eu,x:Xi,X:$i,y:Ji,Y:Gi},vo=/^\s*\d+/,yo=d3.map({am:0,pm:1});d3.time.format.utc=function(t){function n(t){try{Ka=Hi;var n=new Ka;return n._=t,e(n)}finally{Ka=Date}}var e=d3.time.format(t);return n.parse=function(t){try{Ka=Hi;var n=e.parse(t);return n&&n._}finally{Ka=Date}},n.toString=e.toString,n};var Mo=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?au:Mo,au.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},au.toString=Mo.toString,d3.time.second=ou(function(t){return new Ka(Math.floor(t/1e3)*1e3)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*1e3)},function(t){return t.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=ou(function(t){return new Ka(Math.floor(t/6e4)*6e4)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*6e4)},function(t){return t.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=ou(function(t){var n=t.getTimezoneOffset()/60;return new Ka((Math.floor(t/36e5-n)+n)*36e5)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*36e5)},function(t){return t.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=ou(function(t){var n=new Ka(1970,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n},function(t,n){t.setDate(t.getDate()+n)},function(t){return t.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(t){var n=d3.time.year(t);return Math.floor((t-n-(t.getTimezoneOffset()-n.getTimezoneOffset())*6e4)/864e5)},Wa.forEach(function(t,n){t=t.toLowerCase(),n=7-n;var e=d3.time[t]=ou(function(t){return(t=d3.time.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t},function(t,n){t.setDate(t.getDate()+Math.floor(n)*7)},function(t){var e=d3.time.year(t).getDay();return Math.floor((d3.time.dayOfYear(t)+(e+n)%7)/7)-(e!==n)});d3.time[t+"s"]=e.range,d3.time[t+"s"].utc=e.utc.range,d3.time[t+"OfYear"]=function(t){var e=d3.time.year(t).getDay();return Math.floor((d3.time.dayOfYear(t)+(e+n)%7)/7)}}),d3.time.week=d3.time.sunday,d3.time.weeks=d3.time.sunday.range,d3.time.weeks.utc=d3.time.sunday.utc.range,d3.time.weekOfYear=d3.time.sundayOfYear,d3.time.month=ou(function(t){return t=d3.time.day(t),t.setDate(1),t},function(t,n){t.setMonth(t.getMonth()+n)},function(t){return t.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=ou(function(t){return t=d3.time.day(t),t.setMonth(0,1),t},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t){return t.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var bo=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],xo=[[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]],wo=[[d3.time.format("%Y"),l],[d3.time.format("%B"),function(t){return t.getMonth()}],[d3.time.format("%b %d"),function(t){return t.getDate()!=1}],[d3.time.format("%a %d"),function(t){return t.getDay()&&t.getDate()!=1}],[d3.time.format("%I %p"),function(t){return t.getHours()}],[d3.time.format("%I:%M"),function(t){return t.getMinutes()}],[d3.time.format(":%S"),function(t){return t.getSeconds()}],[d3.time.format(".%L"),function(t){return t.getMilliseconds()}]],_o=d3.scale.linear(),ko=hu(wo);xo.year=function(t,n){return _o.domain(t.map(gu)).ticks(n).map(du)},d3.time.scale=function(){return cu(d3.scale.linear(),xo,ko)};var To=xo.map(function(t){return[t[0].utc,t[1]]}),So=[[d3.time.format.utc("%Y"),l],[d3.time.format.utc("%B"),function(t){return t.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(t){return t.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(t){return t.getUTCDay()&&t.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(t){return t.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(t){return t.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(t){return t.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(t){return t.getUTCMilliseconds()}]],Ao=hu(So);To.year=function(t,n){return _o.domain(t.map(mu)).ticks(n).map(pu)},d3.time.scale.utc=function(){return cu(d3.scale.linear(),To,Ao)}})() \ No newline at end of file +!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function r(n){return null===n?0/0:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function c(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function l(){this._=Object.create(null)}function s(n){return(n+="")===pa||n[0]===va?va+n:n}function f(n){return(n+="")[0]===va?n.slice(1):n}function h(n){return s(n)in this._}function g(n){return(n=s(n))in this._&&delete this._[n]}function p(){var n=[];for(var t in this._)n.push(f(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function m(){this._=Object.create(null)}function y(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=da.length;r>e;++e){var u=da[e]+t;if(u in n)return u}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function Z(n){return ya(n,Sa),n}function V(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var l=ka.get(n);return l&&(n=l,c=B),a?t?u:r:t?b:i}function $(n,t){return function(e){var r=ta.event;ta.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ta.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Aa,u="click"+r,i=ta.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==Ea&&(Ea="onselectstart"in e?!1:x(e.style,"userSelect")),Ea){var o=n(e).style,a=o[Ea];o[Ea]="none"}return function(n){if(i.on(r,null),Ea&&(o[Ea]=a),n){var t=function(){i.on(u,null)};i.on(u,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var u=r.createSVGPoint();if(0>Na){var i=t(n);if(i.scrollX||i.scrollY){r=ta.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Na=!(o.f||o.e),r.remove()}}return Na?(u.x=e.pageX,u.y=e.pageY):(u.x=e.clientX,u.y=e.clientY),u=u.matrixTransform(n.getScreenCTM().inverse()),[u.x,u.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return ta.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nt(n){return n>1?0:-1>n?qa:Math.acos(n)}function tt(n){return n>1?Ra:-1>n?-Ra:Math.asin(n)}function et(n){return((n=Math.exp(n))-1/n)/2}function rt(n){return((n=Math.exp(n))+1/n)/2}function ut(n){return((n=Math.exp(2*n))-1)/(n+1)}function it(n){return(n=Math.sin(n/2))*n}function ot(){}function at(n,t,e){return this instanceof at?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof at?new at(n.h,n.s,n.l):bt(""+n,_t,at):new at(n,t,e)}function ct(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new mt(u(n+120),u(n),u(n-120))}function lt(n,t,e){return this instanceof lt?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof lt?new lt(n.h,n.c,n.l):n instanceof ft?gt(n.l,n.a,n.b):gt((n=wt((n=ta.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new lt(n,t,e)}function st(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new ft(e,Math.cos(n*=Da)*t,Math.sin(n)*t)}function ft(n,t,e){return this instanceof ft?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof ft?new ft(n.l,n.a,n.b):n instanceof lt?st(n.h,n.c,n.l):wt((n=mt(n)).r,n.g,n.b):new ft(n,t,e)}function ht(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=pt(u)*Xa,r=pt(r)*$a,i=pt(i)*Ba,new mt(dt(3.2404542*u-1.5371385*r-.4985314*i),dt(-.969266*u+1.8760108*r+.041556*i),dt(.0556434*u-.2040259*r+1.0572252*i))}function gt(n,t,e){return n>0?new lt(Math.atan2(e,t)*Pa,Math.sqrt(t*t+e*e),n):new lt(0/0,0/0,n)}function pt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function vt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function dt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function mt(n,t,e){return this instanceof mt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof mt?new mt(n.r,n.g,n.b):bt(""+n,mt,ct):new mt(n,t,e)}function yt(n){return new mt(n>>16,n>>8&255,255&n)}function Mt(n){return yt(n)+""}function xt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function bt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(kt(u[0]),kt(u[1]),kt(u[2]))}return(i=Ga.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function _t(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new at(r,u,c)}function wt(n,t,e){n=St(n),t=St(t),e=St(e);var r=vt((.4124564*n+.3575761*t+.1804375*e)/Xa),u=vt((.2126729*n+.7151522*t+.072175*e)/$a),i=vt((.0193339*n+.119192*t+.9503041*e)/Ba);return ft(116*u-16,500*(r-u),200*(u-i))}function St(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function kt(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function Et(n){return"function"==typeof n?n:function(){return n}}function At(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Nt(t,e,n,r)}}function Nt(n,t,e,r){function u(){var n,t=c.status;if(!t&&zt(c)||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return void o.error.call(i,r)}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=ta.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,l=null;return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=ta.event;ta.event=n;try{o.progress.call(i,c)}finally{ta.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(l=n,i):l},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(ra(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var s in a)c.setRequestHeader(s,a[s]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},ta.rebind(i,o,"on"),null==r?i:i.get(Ct(r))}function Ct(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zt(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qt(){var n=Lt(),t=Tt()-n;t>24?(isFinite(t)&&(clearTimeout(tc),tc=setTimeout(qt,t)),nc=0):(nc=1,rc(qt))}function Lt(){var n=Date.now();for(ec=Ka;ec;)n>=ec.t&&(ec.f=ec.c(n-ec.t)),ec=ec.n;return n}function Tt(){for(var n,t=Ka,e=1/0;t;)t.f?t=n?n.n=t.n:Ka=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Pt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],c=0;u>0&&a>0&&(c+a+1>t&&(a=Math.max(1,t-c)),i.push(n.substring(u-=a,u+a)),!((c+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:y;return function(n){var e=ic.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",c=e[4]||"",l=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(l||"0"===r&&"="===o)&&(l=r="0",o="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=oc.get(g)||Ut;var M=l&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var c=ta.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=y?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!l&&f&&(x=i(x,1/0));var S=v.length+x.length+b.length+(M?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return M&&(x=i(k+x,k.length?s-b.length:1/0)),u+=v,n=x+b,("<"===o?u+n+k:">"===o?k+u+n:"^"===o?k.substring(0,S>>=1)+u+n+k.substring(S):u+(M?n:k+n))+e}}}function Ut(n){return n+""}function jt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ft(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new cc(e-1)),1),e}function i(n,e){return t(n=new cc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{cc=jt;var r=new jt;return r._=n,o(r,t,e)}finally{cc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Ht(n);return c.floor=c,c.round=Ht(r),c.ceil=Ht(u),c.offset=Ht(i),c.range=a,n}function Ht(n){return function(t,e){try{cc=jt;var r=new jt;return r._=t,n(r,e)._}finally{cc=Date}}}function Ot(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=l)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=C[o in sc?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.slice(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,N.c.toString(),t,r)}function c(n,t,r){return e(n,N.x.toString(),t,r)}function l(n,t,r){return e(n,N.X.toString(),t,r)}function s(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{cc=jt;var t=new cc;return t._=n,r(t)}finally{cc=Date}}var r=t(n);return e.parse=function(n){try{cc=jt;var t=r.parse(n);return t&&t._}finally{cc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ae;var M=ta.map(),x=Yt(v),b=Zt(v),_=Yt(d),w=Zt(d),S=Yt(m),k=Zt(m),E=Yt(y),A=Zt(y);p.forEach(function(n,t){M.set(n.toLowerCase(),t)});var N={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return It(n.getDate(),t,2)},e:function(n,t){return It(n.getDate(),t,2)},H:function(n,t){return It(n.getHours(),t,2)},I:function(n,t){return It(n.getHours()%12||12,t,2)},j:function(n,t){return It(1+ac.dayOfYear(n),t,3)},L:function(n,t){return It(n.getMilliseconds(),t,3)},m:function(n,t){return It(n.getMonth()+1,t,2)},M:function(n,t){return It(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return It(n.getSeconds(),t,2)},U:function(n,t){return It(ac.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return It(ac.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return It(n.getFullYear()%100,t,2)},Y:function(n,t){return It(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},C={a:r,A:u,b:i,B:o,c:a,d:Qt,e:Qt,H:te,I:te,j:ne,L:ue,m:Kt,M:ee,p:s,S:re,U:Xt,w:Vt,W:$t,x:c,X:l,y:Wt,Y:Bt,Z:Jt,"%":oe};return t}function It(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function Yt(n){return new RegExp("^(?:"+n.map(ta.requote).join("|")+")","i")}function Zt(n){for(var t=new l,e=-1,r=n.length;++e68?1900:2e3)}function Kt(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Qt(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function ne(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function te(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ee(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function re(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ue(n,t,e){fc.lastIndex=0;var r=fc.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=ga(t)/60|0,u=ga(t)%60;return e+It(r,"0",2)+It(u,"0",2)}function oe(n,t,e){hc.lastIndex=0;var r=hc.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ae(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),l=Math.sin(t),s=i*l,f=u*c+s*Math.cos(a),h=s*o*Math.sin(a);yc.add(Math.atan2(h,f)),r=n,u=c,i=l}var t,e,r,u,i;Mc.point=function(o,a){Mc.point=n,r=(t=o)*Da,u=Math.cos(a=(e=a)*Da/2+qa/4),i=Math.sin(a)},Mc.lineEnd=function(){n(t,e)}}function pe(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ve(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function de(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function me(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function ye(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function Me(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function xe(n){return[Math.atan2(n[1],n[0]),tt(n[2])]}function be(n,t){return ga(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return void u.lineEnd()}var c=new qe(e,n,null,!0),l=new qe(e,null,c,!1);c.o=l,i.push(c),o.push(l),c=new qe(r,n,null,!1),l=new qe(r,null,c,!0),c.o=l,i.push(c),o.push(l)}}),o.sort(t),ze(i),ze(o),i.length){for(var a=0,c=e,l=o.length;l>a;++a)o[a].e=c=!c;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,l=s.length;l>a;++a)u.point((f=s[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var a=s.length-1;a>=0;--a)u.point((f=s[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function ze(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(b||(i.polygonStart(),b=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Te))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:l,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=l,g=ta.merge(g);var n=Fe(m,p);g.length?(b||(i.polygonStart(),b=!0),Ce(g,De,n,e,i)):n&&(b||(i.polygonStart(),b=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),b&&(i.polygonEnd(),b=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},M=Re(),x=t(M),b=!1;return y}}function Te(n){return n.length>1}function Re(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function De(n,t){return((n=n.x)[0]<0?n[1]-Ra-Ca:Ra-n[1])-((t=t.x)[0]<0?t[1]-Ra-Ca:Ra-t[1])}function Pe(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?qa:-qa,c=ga(i-e);ga(c-qa)0?Ra:-Ra),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=qa&&(ga(e-u)Ca?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function je(n,t,e,r){var u;if(null==n)u=e*Ra,r.point(-qa,u),r.point(0,u),r.point(qa,u),r.point(qa,0),r.point(qa,-u),r.point(0,-u),r.point(-qa,-u),r.point(-qa,0),r.point(-qa,u);else if(ga(n[0]-t[0])>Ca){var i=n[0]a;++a){var l=t[a],s=l.length;if(s)for(var f=l[0],h=f[0],g=f[1]/2+qa/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=l[d];var m=n[0],y=n[1]/2+qa/4,M=Math.sin(y),x=Math.cos(y),b=m-h,_=b>=0?1:-1,w=_*b,S=w>qa,k=p*M;if(yc.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),i+=S?b+_*La:b,S^h>=e^m>=e){var E=de(pe(f),pe(n));Me(E);var A=de(u,E);Me(A);var N=(S^b>=0?-1:1)*tt(A[2]);(r>N||r===N&&(E[0]||E[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=m,p=M,v=x,f=n}}return(-Ca>i||Ca>i&&0>yc)^1&o}function He(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,c,l,s;return{lineStart:function(){l=c=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?qa:-qa),h):0;if(!e&&(l=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(be(e,g)||be(p,g))&&(p[0]+=Ca,p[1]+=Ca,v=t(p[0],p[1]))),v!==c)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(s=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&be(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return s|(l&&c)<<1}}}function r(n,t,e){var r=pe(n),u=pe(t),o=[1,0,0],a=de(r,u),c=ve(a,a),l=a[0],s=c-l*l;if(!s)return!e&&n;var f=i*c/s,h=-i*l/s,g=de(o,a),p=ye(o,f),v=ye(a,h);me(p,v);var d=g,m=ve(p,d),y=ve(d,d),M=m*m-y*(ve(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=ye(d,(-m-x)/y);if(me(b,p),b=xe(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=ga(A-qa)A;if(!N&&k>E&&(_=k,k=E,E=_),C?N?k+E>0^b[1]<(ga(b[0]-w)qa^(w<=b[0]&&b[0]<=S)){var z=ye(d,(-m+x)/y);return me(z,p),[b,xe(z)]}}}function u(t,e){var r=o?n:qa-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=ga(i)>Ca,c=gr(n,6*Da);return Le(t,e,c,o?[0,-n]:[-qa,n-qa])}function Oe(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,l=o.y,s=a.x,f=a.y,h=0,g=1,p=s-c,v=f-l;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-l,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-l,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:l+h*v}),1>g&&(u.b={x:c+g*p,y:l+g*v}),u}}}}}}function Ie(n,t,e,r){function u(r,u){return ga(r[0]-n)0?0:3:ga(r[0]-e)0?2:1:ga(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&Q(l,i,n)>0&&++t:i[1]<=r&&Q(l,i,n)<0&&--t,l=i;return 0!==t}function l(i,a,c,l){var s=0,f=0;if(null==i||(s=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do l.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+c+4)%4)!==f)}else l.point(a[0],a[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&a.point(n,t)}function h(){C.point=p,d&&d.push(m=[]),S=!0,w=!1,b=_=0/0}function g(){v&&(p(y,M),x&&w&&A.rejoin(),v.push(A.buffer())),C.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-Tc,Math.min(Tc,n)),t=Math.max(-Tc,Math.min(Tc,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};N(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,m,y,M,x,b,_,w,S,k,E=a,A=Re(),N=Oe(n,t,e,r),C={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=ta.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Ce(v,i,t,l,a),a.polygonEnd()),v=d=m=null}};return C}}function Ye(n){var t=0,e=qa/3,r=ir(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*qa/180,e=n[1]*qa/180):[t/qa*180,e/qa*180]},u}function Ze(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,tt((i-(n*n+e*e)*u*u)/(2*u))]},e}function Ve(){function n(n,t){Dc+=u*n-r*t,r=n,u=t}var t,e,r,u;Hc.point=function(i,o){Hc.point=n,t=r=i,e=u=o},Hc.lineEnd=function(){n(t,e)}}function Xe(n,t){Pc>n&&(Pc=n),n>jc&&(jc=n),Uc>t&&(Uc=t),t>Fc&&(Fc=t)}function $e(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Be(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Be(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Be(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function We(n,t){_c+=n,wc+=t,++Sc}function Je(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);kc+=o*(t+n)/2,Ec+=o*(e+r)/2,Ac+=o,We(t=n,e=r)}var t,e;Ic.point=function(r,u){Ic.point=n,We(t=r,e=u)}}function Ge(){Ic.point=We}function Ke(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);kc+=o*(r+n)/2,Ec+=o*(u+t)/2,Ac+=o,o=u*n-r*t,Nc+=o*(r+n),Cc+=o*(u+t),zc+=3*o,We(r=n,u=t)}var t,e,r,u;Ic.point=function(i,o){Ic.point=n,We(t=r=i,e=u=o)},Ic.lineEnd=function(){n(t,e)}}function Qe(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,La)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:b};return a}function nr(n){function t(n){return(a?r:e)(n)}function e(t){return rr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=0/0,S.point=i,t.lineStart()}function i(e,r){var i=pe([e,r]),o=n(e,r);u(M,x,y,b,_,w,M=o[0],x=o[1],y=e,b=i[0],_=i[1],w=i[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=l,S.lineEnd=s}function l(n,t){i(f=n,h=t),g=M,p=x,v=b,d=_,m=w,S.point=i}function s(){u(M,x,y,b,_,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c +},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,l,s,f,h,g,p,v,d,m){var y=s-t,M=f-e,x=y*y+M*M;if(x>4*i&&d--){var b=a+g,_=c+p,w=l+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),E=ga(ga(w)-1)i||ga((y*z+M*q)/x-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,N,C,E,b/=S,_/=S,w,d,m),m.point(N,C),u(N,C,E,b,_,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Da),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Pa,e*Pa])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*Da,n[1]*Da),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Pa,n[1]*Pa]}function r(){a=Ae(o=lr(m,M,x),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,M=0,x=0,b=Lc,_=y,w=null,S=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(b(o,f(_(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Lc):He((w=+n)*Da),u()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Ie(n[0][0],n[0][1],n[1][0],n[1][1]):y,u()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Da,d=n[1]%360*Da,r()):[v*Pa,d*Pa]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Da,M=n[1]%360*Da,x=n.length>2?n[2]%360*Da:0,r()):[m*Pa,M*Pa,x*Pa]},ta.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*Da,e*Da)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>qa?n-La:-qa>n?n+La:n,t]}function lr(n,t,e){return n?t||e?Ae(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>qa?t-La:-qa>t?t+La:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),tt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),tt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*La)):(u=n+o*La,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=xe([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,Me(e);var r=nt(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ca)%(2*Math.PI)}function vr(n,t,e){var r=ta.range(n,t-Ca,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=ta.range(n,t-Ca,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function Mr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(it(r-t)+u*o*it(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Pa,Math.atan2(o,Math.sqrt(r*r+u*u))*Pa]}:function(){return[n*Pa,t*Pa]};return p.distance=h,p}function xr(){function n(n,u){var i=Math.sin(u*=Da),o=Math.cos(u),a=ga((n*=Da)-t),c=Math.cos(a);Yc+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Zc.point=function(u,i){t=u*Da,e=Math.sin(i*=Da),r=Math.cos(i),Zc.point=n},Zc.lineEnd=function(){Zc.point=Zc.lineEnd=b}}function br(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function _r(n,t){function e(n,t){o>0?-Ra+Ca>t&&(t=-Ra+Ca):t>Ra-Ca&&(t=Ra-Ca);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(qa/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=K(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ra]},e):Sr}function wr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return ga(u)u;u++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function zr(n,t){return n[0]-t[0]||n[1]-t[1]}function qr(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Lr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],l=e[1],s=t[1]-c,f=r[1]-l,h=(a*(c-l)-f*(u-i))/(f*o-a*s);return[u+h*o,c+h*s]}function Tr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Rr(){tu(this),this.edge=this.site=this.circle=null}function Dr(n){var t=el.pop()||new Rr;return t.site=n,t}function Pr(n){Xr(n),Qc.remove(n),el.push(n),tu(n)}function Ur(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Pr(n);for(var c=i;c.circle&&ga(e-c.circle.x)s;++s)l=a[s],c=a[s-1],Kr(l.edge,c.site,l.site,u);c=a[0],l=a[f-1],l.edge=Jr(c.site,l.site,null,u),Vr(c),Vr(l)}function jr(n){for(var t,e,r,u,i=n.x,o=n.y,a=Qc._;a;)if(r=Fr(a,o)-i,r>Ca)a=a.L;else{if(u=i-Hr(a,o),!(u>Ca)){r>-Ca?(t=a.P,e=a):u>-Ca?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Dr(n);if(Qc.insert(t,c),t||e){if(t===e)return Xr(t),e=Dr(t.site),Qc.insert(c,e),c.edge=e.edge=Jr(t.site,c.site),Vr(t),void Vr(e);if(!e)return void(c.edge=Jr(t.site,c.site));Xr(t),Xr(e);var l=t.site,s=l.x,f=l.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,M=v*v+d*d,x={x:(d*y-g*M)/m+s,y:(h*M-v*y)/m+f};Kr(e.edge,l,p,x),c.edge=Jr(l,n,null,x),e.edge=Jr(n,p,null,x),Vr(t),Vr(e)}}function Fr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,l=c-t;if(!l)return a;var s=a-r,f=1/i-1/l,h=s/l;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*l)-c+l/2+u-i/2)))/f+r:(r+a)/2}function Hr(n,t){var e=n.N;if(e)return Fr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Or(n){this.site=n,this.edges=[]}function Ir(n){for(var t,e,r,u,i,o,a,c,l,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=Kc,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)s=a[o].end(),r=s.x,u=s.y,l=a[++o%c].start(),t=l.x,e=l.y,(ga(r-t)>Ca||ga(u-e)>Ca)&&(a.splice(o,0,new Qr(Gr(i.site,s,ga(r-f)Ca?{x:f,y:ga(t-f)Ca?{x:ga(e-p)Ca?{x:h,y:ga(t-h)Ca?{x:ga(e-g)=-za)){var g=c*c+l*l,p=s*s+f*f,v=(f*g-l*p)/h,d=(c*p-s*g)/h,f=d+a,m=rl.pop()||new Zr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,M=tl._;M;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=l)return}else i={x:d,y:c};e={x:d,y:l}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=l)return}else i={x:(c-u)/r,y:c};e={x:(l-u)/r,y:l}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi||f>o||r>h||u>g)){if(p=n.point){var p,v=t-n.x,d=e-n.y,m=v*v+d*d;if(c>m){var y=Math.sqrt(c=m);r=t-y,u=e-y,i=t+y,o=e+y,a=p}}for(var M=n.nodes,x=.5*(s+h),b=.5*(f+g),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:l(n,s,f,x,b);break;case 1:l(n,x,f,h,b);break;case 2:l(n,s,b,x,g);break;case 3:l(n,x,b,h,g)}}}(n,r,u,i,o),a}function gu(n,t){n=ta.rgb(n),t=ta.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,o=t.g-r,a=t.b-u;return function(n){return"#"+xt(Math.round(e+i*n))+xt(Math.round(r+o*n))+xt(Math.round(u+a*n))}}function pu(n,t){var e,r={},u={};for(e in n)e in t?r[e]=mu(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function vu(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function du(n,t){var e,r,u,i=il.lastIndex=ol.lastIndex=0,o=-1,a=[],c=[];for(n+="",t+="";(e=il.exec(n))&&(r=ol.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:vu(e,r)})),i=ol.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function mu(n,t){for(var e,r=ta.interpolators.length;--r>=0&&!(e=ta.interpolators[r](n,t)););return e}function yu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(mu(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function Mu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function xu(n){return function(t){return 1-n(1-t)}}function bu(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function _u(n){return n*n}function wu(n){return n*n*n}function Su(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function ku(n){return function(t){return Math.pow(t,n)}}function Eu(n){return 1-Math.cos(n*Ra)}function Au(n){return Math.pow(2,10*(n-1))}function Nu(n){return 1-Math.sqrt(1-n*n)}function Cu(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/La*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*La/t)}}function zu(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function qu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Lu(n,t){n=ta.hcl(n),t=ta.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return st(e+i*n,r+o*n,u+a*n)+""}}function Tu(n,t){n=ta.hsl(n),t=ta.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return ct(e+i*n,r+o*n,u+a*n)+""}}function Ru(n,t){n=ta.lab(n),t=ta.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ht(e+i*n,r+o*n,u+a*n)+""}}function Du(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Pu(n){var t=[n.a,n.b],e=[n.c,n.d],r=ju(t),u=Uu(t,e),i=ju(Fu(e,t,-u))||0;t[0]*e[1]180?s+=360:s-l>180&&(l+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:vu(l,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:vu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:vu(g[0],p[0])},{i:e-2,x:vu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Qu(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function si(n){return n.reduce(fi,0)}function fi(n,t){return n+t[1]}function hi(n,t){return gi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function gi(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function pi(n){return[ta.min(n),ta.max(n)]}function vi(n,t){return n.value-t.value}function di(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function mi(n,t){n._pack_next=t,t._pack_prev=n}function yi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function Mi(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,u,i,o,a,c,l,s=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(xi),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(u=e[1],u.x=u.r,u.y=0,t(u),l>2))for(i=e[2],wi(r,u,i),t(i),di(r,i),r._pack_prev=i,di(i,u),u=r._pack_next,o=3;l>o;o++){wi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(yi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!yi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,M=Math.max(M,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=M,e.forEach(bi)}}function xi(n){n._pack_next=n._pack_prev=n}function bi(n){delete n._pack_next,delete n._pack_prev}function _i(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Ci(n,t,e){return n.a.parent===t.parent?n.a:e}function zi(n){return 1+ta.max(n,function(n){return n.y})}function qi(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Li(n){var t=n.children;return t&&t.length?Li(t[0]):n}function Ti(n){var t,e=n.children;return e&&(t=e.length)?Ti(e[t-1]):n}function Ri(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Di(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Pi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Ui(n){return n.rangeExtent?n.rangeExtent():Pi(n.range())}function ji(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Fi(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Hi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:ml}function Oi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Oi:ji,c=r?Iu:Ou;return o=u(n,t,c,e),a=u(t,n,c,mu),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Du)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Xi(n,t)},i.tickFormat=function(t,e){return $i(n,t,e)},i.nice=function(t){return Zi(n,t),u()},i.copy=function(){return Ii(n,t,e,r)},u()}function Yi(n,t){return ta.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Zi(n,t){return Fi(n,Hi(Vi(n,t)[2]))}function Vi(n,t){null==t&&(t=10);var e=Pi(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Xi(n,t){return ta.range.apply(ta,Vi(n,t))}function $i(n,t,e){var r=Vi(n,t);if(e){var u=ic.exec(e);if(u.shift(),"s"===u[8]){var i=ta.formatPrefix(Math.max(ga(r[0]),ga(r[1])));return u[7]||(u[7]="."+Bi(i.scale(r[2]))),u[8]="f",e=ta.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Wi(u[8],r)),e=u.join("")}else e=",."+Bi(r[2])+"f";return ta.format(e)}function Bi(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Wi(n,t){var e=Bi(t[2]);return n in yl?Math.abs(e-Bi(Math.max(ga(t[0]),ga(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Ji(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Fi(r.map(u),e?Math:xl);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Pi(r),o=[],a=n[0],c=n[1],l=Math.floor(u(a)),s=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(s-l)){if(e){for(;s>l;l++)for(var h=1;f>h;h++)o.push(i(l)*h);o.push(i(l))}else for(o.push(i(l));l++0;h--)o.push(i(l)*h);for(l=0;o[l]c;s--);o=o.slice(l,s)}return o},o.tickFormat=function(n,t){if(!arguments.length)return Ml;arguments.length<2?t=Ml:"function"!=typeof t&&(t=ta.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Ji(n.copy(),t,e,r)},Yi(o,n)}function Gi(n,t,e){function r(t){return n(u(t))}var u=Ki(t),i=Ki(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Xi(e,n)},r.tickFormat=function(n,t){return $i(e,n,t)},r.nice=function(n){return r.domain(Zi(e,n))},r.exponent=function(o){return arguments.length?(u=Ki(t=o),i=Ki(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Gi(n.copy(),t,e)},Yi(r,n)}function Ki(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Qi(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return ta.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new l;for(var i,o=-1,a=r.length;++oe?[0/0,0/0]:[e>0?a[e-1]:n[0],et?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return to(n,t,e)},u()}function eo(n,t){function e(e){return e>=e?t[ta.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return eo(n,t)},e}function ro(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Xi(n,t)},t.tickFormat=function(t,e){return $i(n,t,e)},t.copy=function(){return ro(n)},t}function uo(){return 0}function io(n){return n.innerRadius}function oo(n){return n.outerRadius}function ao(n){return n.startAngle}function co(n){return n.endAngle}function lo(n){return n&&n.padAngle}function so(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function fo(n,t,e,r,u){var i=n[0]-t[0],o=n[1]-t[1],a=(u?r:-r)/Math.sqrt(i*i+o*o),c=a*o,l=-a*i,s=n[0]+c,f=n[1]+l,h=t[0]+c,g=t[1]+l,p=(s+h)/2,v=(f+g)/2,d=h-s,m=g-f,y=d*d+m*m,M=e-r,x=s*g-h*f,b=(0>m?-1:1)*Math.sqrt(M*M*y-x*x),_=(x*m-d*b)/y,w=(-x*d-m*b)/y,S=(x*m+d*b)/y,k=(-x*d+m*b)/y,E=_-p,A=w-v,N=S-p,C=k-v;return E*E+A*A>N*N+C*C&&(_=S,w=k),[[_-c,w-l],[_*e/M,w*e/M]]}function ho(n){function t(t){function o(){l.push("M",i(n(s),a))}for(var c,l=[],s=[],f=-1,h=t.length,g=Et(e),p=Et(r);++f1&&u.push("H",r[0]),u.join("")}function mo(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var l=2;l9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function To(n){return n.length<3?go(n):n[0]+_o(n,Lo(n))}function Ro(n){for(var t,e,r,u=-1,i=n.length;++ur)return s();var u=i[i.active];u&&(--i.count,delete i[i.active],u.event&&u.event.interrupt.call(n,n.__data__,u.index)),i.active=r,o.event&&o.event.start.call(n,n.__data__,t),o.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&v.push(r)}),h=o.ease,f=o.duration,ta.timer(function(){return p.c=l(e||1)?Ne:l,1},0,a)}function l(e){if(i.active!==r)return 1;for(var u=e/f,a=h(u),c=v.length;c>0;)v[--c].call(n,a);return u>=1?(o.event&&o.event.end.call(n,n.__data__,t),s()):void 0}function s(){return--i.count?delete i[r]:delete n[e],1}var f,h,g=o.delay,p=ec,v=[];return p.t=g+a,u>=g?c(u-g):void(p.c=c)},0,a)}}function Bo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Wo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Jo(n){return n.toISOString()}function Go(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=ta.bisect(Vl,u);return i==Vl.length?[t.year,Vi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Vl[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Ko(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Ko(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Pi(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Ko(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Go(n.copy(),t,e)},Yi(r,n)}function Ko(n){return new Date(n)}function Qo(n){return JSON.parse(n.responseText)}function na(n){var t=ua.createRange();return t.selectNode(ua.body),t.createContextualFragment(n.responseText)}var ta={version:"3.5.6"},ea=[].slice,ra=function(n){return ea.call(n)},ua=this.document;if(ua)try{ra(ua.documentElement.childNodes)[0].nodeType}catch(ia){ra=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),ua)try{ua.createElement("DIV").style.setProperty("opacity",0,"")}catch(oa){var aa=this.Element.prototype,ca=aa.setAttribute,la=aa.setAttributeNS,sa=this.CSSStyleDeclaration.prototype,fa=sa.setProperty;aa.setAttribute=function(n,t){ca.call(this,n,t+"")},aa.setAttributeNS=function(n,t,e){la.call(this,n,t,e+"")},sa.setProperty=function(n,t,e){fa.call(this,n,t+"",e)}}ta.ascending=e,ta.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ta.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},ta.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},ta.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},ta.sum=function(n,t){var e,r=0,i=n.length,o=-1;if(1===arguments.length)for(;++o1?c/(s-1):void 0},ta.deviation=function(){var n=ta.variance.apply(this,arguments);return n?Math.sqrt(n):n};var ha=i(e);ta.bisectLeft=ha.left,ta.bisect=ta.bisectRight=ha.right,ta.bisector=function(n){return i(1===n.length?function(t,r){return e(n(t),r)}:n)},ta.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=Math.random()*i--|0,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},ta.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ta.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},ta.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=ta.min(arguments,o),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ga=Math.abs;ta.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,u=[],i=a(ga(e)),o=-1;if(n*=i,t*=i,e*=i,0>e)for(;(r=n+e*++o)>t;)u.push(r/i);else for(;(r=n+e*++o)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var c,s,f,h,g=-1,p=o.length,v=i[a++],d=new l;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(ta.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},ta.set=function(n){var t=new m;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},c(m,{has:h,add:function(n){return this._[s(n+="")]=!0,n},remove:g,values:p,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,f(t))}}),ta.behavior={},ta.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ta.event=null,ta.requote=function(n){return n.replace(ma,"\\$&")};var ma=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ya={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},Ma=function(n,t){return t.querySelector(n)},xa=function(n,t){return t.querySelectorAll(n)},ba=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(ba=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(Ma=function(n,t){return Sizzle(n,t)[0]||null},xa=Sizzle,ba=Sizzle.matchesSelector),ta.selection=function(){return ta.select(ua.documentElement)};var _a=ta.selection.prototype=[];_a.select=function(n){var t,e,r,u,i=[];n=N(n);for(var o=-1,a=this.length;++o=0&&(e=n.slice(0,t),n=n.slice(t+1)),wa.hasOwnProperty(e)?{space:wa[e],local:n}:n}},_a.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ta.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},_a.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,u=-1;if(t=e.classList){for(;++uu){if("string"!=typeof n){2>u&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>u){var i=this.node();return t(i).getComputedStyle(i,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},_a.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},_a.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},_a.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},_a.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},_a.insert=function(n,t){return n=j(n),t=N(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},_a.remove=function(){return this.each(F)},_a.data=function(n,t){function e(n,e){var r,u,i,o=n.length,f=e.length,h=Math.min(o,f),g=new Array(f),p=new Array(f),v=new Array(o);if(t){var d,m=new l,y=new Array(o);for(r=-1;++rr;++r)p[r]=H(e[r]);for(;o>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,a.push(p),c.push(g),s.push(v)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return A(u)},_a.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},_a.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},_a.size=function(){var n=0;return Y(this,function(){++n}),n};var Sa=[];ta.selection.enter=Z,ta.selection.enter.prototype=Sa,Sa.append=_a.append,Sa.empty=_a.empty,Sa.node=_a.node,Sa.call=_a.call,Sa.size=_a.size,Sa.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var ka=ta.map({mouseenter:"mouseover",mouseleave:"mouseout"});ua&&ka.forEach(function(n){"on"+n in ua&&ka.remove(n)});var Ea,Aa=0;ta.mouse=function(n){return J(n,k())};var Na=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ta.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return J(n,r)},ta.behavior.drag=function(){function n(){this.on("mousedown.drag",i).on("touchstart.drag",o)}function e(n,t,e,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],p|=n|e,M=r,g({type:"drag",x:r[0]+l[0],y:r[1]+l[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&ta.event.target===f),g({type:"dragend"}))}var l,s=this,f=ta.event.target,h=s.parentNode,g=r.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=ta.select(e(f)).on(i+d,a).on(o+d,c),y=W(f),M=t(h,v);u?(l=u.apply(s,arguments),l=[l.x-M[0],l.y-M[1]]):l=[0,0],g({type:"dragstart"})}}var r=E(n,"drag","dragstart","dragend"),u=null,i=e(b,ta.mouse,t,"mousemove","mouseup"),o=e(G,ta.touch,y,"touchmove","touchend");return n.origin=function(t){return arguments.length?(u=t,n):u},ta.rebind(n,r,"on")},ta.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?ra(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Ca=1e-6,za=Ca*Ca,qa=Math.PI,La=2*qa,Ta=La-Ca,Ra=qa/2,Da=qa/180,Pa=180/qa,Ua=Math.SQRT2,ja=2,Fa=4;ta.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=rt(v),o=i/(ja*h)*(e*ut(Ua*t+v)-et(v));return[r+o*l,u+o*s,i*e/rt(Ua*t+v)]}return[r+n*l,u+n*s,i*Math.exp(Ua*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],l=o-r,s=a-u,f=l*l+s*s,h=Math.sqrt(f),g=(c*c-i*i+Fa*f)/(2*i*ja*h),p=(c*c-i*i-Fa*f)/(2*c*ja*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/Ua;return e.duration=1e3*y,e},ta.behavior.zoom=function(){function n(n){n.on(q,f).on(Oa+".zoom",g).on("dblclick.zoom",p).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function u(n){k.k=Math.max(N[0],Math.min(N[1],n))}function i(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:k.x,y:k.y,k:k.k},u(Math.pow(2,o)),i(d=e,r),t=ta.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function a(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function c(n){z++||n({type:"zoomstart"})}function l(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function s(n){--z||(n({type:"zoomend"}),d=null)}function f(){function n(){f=1,i(ta.mouse(u),g),l(a)}function r(){h.on(L,null).on(T,null),p(f&&ta.event.target===o),s(a)}var u=this,o=ta.event.target,a=D.of(u,arguments),f=0,h=ta.select(t(u)).on(L,n).on(T,r),g=e(ta.mouse(u)),p=W(u);Dl.call(u),c(a)}function h(){function n(){var n=ta.touches(p);return g=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=ta.event.target;ta.select(t).on(x,r).on(b,a),_.push(t);for(var e=ta.event.changedTouches,u=0,i=e.length;i>u;++u)d[e[u].identifier]=null;var c=n(),l=Date.now();if(1===c.length){if(500>l-M){var s=c[0];o(p,s,d[s.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=l}else if(c.length>1){var s=c[0],f=c[1],h=s[0]-f[0],g=s[1]-f[1];m=h*h+g*g}}function r(){var n,t,e,r,o=ta.touches(p);Dl.call(p);for(var a=0,c=o.length;c>a;++a,r=null)if(e=o[a],r=d[e.identifier]){if(t)break;n=e,t=r}if(r){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=m&&Math.sqrt(s/m);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],u(f*g)}M=null,i(n,t),l(v)}function a(){if(ta.event.touches.length){for(var t=ta.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var u in d)return void n()}ta.selectAll(_).on(y,null),w.on(q,f).on(R,h),E(),s(v)}var g,p=this,v=D.of(p,arguments),d={},m=0,y=".zoom-"+ta.event.changedTouches[0].identifier,x="touchmove"+y,b="touchend"+y,_=[],w=ta.select(p),E=W(p);t(),c(v),w.on(q,null).on(R,t)}function g(){var n=D.of(this,arguments);y?clearTimeout(y):(Dl.call(this),v=e(d=m||ta.mouse(this)),c(n)),y=setTimeout(function(){y=null,s(n)},50),S(),u(Math.pow(2,.002*Ha())*k.k),i(d,v),l(n)}function p(){var n=ta.mouse(this),t=Math.log(k.k)/Math.LN2;o(this,n,e(n),ta.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,m,y,M,x,b,_,w,k={x:0,y:0,k:1},A=[960,500],N=Ia,C=250,z=0,q="mousedown.zoom",L="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoom",D=E(n,"zoomstart","zoom","zoomend");return Oa||(Oa="onwheel"in ua?(Ha=function(){return-ta.event.deltaY*(ta.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ua?(Ha=function(){return ta.event.wheelDelta},"mousewheel"):(Ha=function(){return-ta.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Tl?ta.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},c(n)}).tween("zoom:zoom",function(){var e=A[0],r=A[1],u=d?d[0]:e/2,i=d?d[1]:r/2,o=ta.interpolateZoom([(u-k.x)/k.k,(i-k.y)/k.k,e/k.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:u-r[0]*a,y:i-r[1]*a,k:a},l(n)}}).each("interrupt.zoom",function(){s(n)}).each("end.zoom",function(){s(n)}):(this.__chart__=k,c(n),l(n),s(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:+t},a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(N=null==t?Ia:[+t[0],+t[1]],n):N},n.center=function(t){return arguments.length?(m=t&&[+t[0],+t[1]],n):m},n.size=function(t){return arguments.length?(A=t&&[+t[0],+t[1]],n):A},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},ta.rebind(n,D,"on")};var Ha,Oa,Ia=[0,1/0];ta.color=ot,ot.prototype.toString=function(){return this.rgb()+""},ta.hsl=at;var Ya=at.prototype=new ot;Ya.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new at(this.h,this.s,this.l/n)},Ya.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new at(this.h,this.s,n*this.l)},Ya.rgb=function(){return ct(this.h,this.s,this.l)},ta.hcl=lt;var Za=lt.prototype=new ot;Za.brighter=function(n){return new lt(this.h,this.c,Math.min(100,this.l+Va*(arguments.length?n:1)))},Za.darker=function(n){return new lt(this.h,this.c,Math.max(0,this.l-Va*(arguments.length?n:1)))},Za.rgb=function(){return st(this.h,this.c,this.l).rgb()},ta.lab=ft;var Va=18,Xa=.95047,$a=1,Ba=1.08883,Wa=ft.prototype=new ot;Wa.brighter=function(n){return new ft(Math.min(100,this.l+Va*(arguments.length?n:1)),this.a,this.b)},Wa.darker=function(n){return new ft(Math.max(0,this.l-Va*(arguments.length?n:1)),this.a,this.b)},Wa.rgb=function(){return ht(this.l,this.a,this.b)},ta.rgb=mt;var Ja=mt.prototype=new ot;Ja.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new mt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new mt(u,u,u)},Ja.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new mt(n*this.r,n*this.g,n*this.b)},Ja.hsl=function(){return _t(this.r,this.g,this.b)},Ja.toString=function(){return"#"+xt(this.r)+xt(this.g)+xt(this.b)};var Ga=ta.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Ga.forEach(function(n,t){Ga.set(n,yt(t))}),ta.functor=Et,ta.xhr=At(y),ta.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=Nt(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=l)return o;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++a);else if(r!==c)continue;return n.slice(t,s-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],l=n.length,s=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,f++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new m,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},ta.csv=ta.dsv(",","text/csv"),ta.tsv=ta.dsv(" ","text/tab-separated-values");var Ka,Qa,nc,tc,ec,rc=this[x(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ta.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};Qa?Qa.n=i:Ka=i,Qa=i,nc||(tc=clearTimeout(tc),nc=1,rc(qt))},ta.timer.flush=function(){Lt(),Tt()},ta.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var uc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Dt);ta.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=ta.round(n,Rt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),uc[8+e/3]};var ic=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,oc=ta.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ta.round(n,Rt(n,t))).toFixed(Math.max(0,Math.min(20,Rt(n*(1+1e-15),t))))}}),ac=ta.time={},cc=Date;jt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){lc.setUTCDate.apply(this._,arguments)},setDay:function(){lc.setUTCDay.apply(this._,arguments)},setFullYear:function(){lc.setUTCFullYear.apply(this._,arguments)},setHours:function(){lc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){lc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){lc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){lc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){lc.setUTCSeconds.apply(this._,arguments)},setTime:function(){lc.setTime.apply(this._,arguments)}};var lc=Date.prototype;ac.year=Ft(function(n){return n=ac.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ac.years=ac.year.range,ac.years.utc=ac.year.utc.range,ac.day=Ft(function(n){var t=new cc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ac.days=ac.day.range,ac.days.utc=ac.day.utc.range,ac.dayOfYear=function(n){var t=ac.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=ac[n]=Ft(function(n){return(n=ac.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=ac.year(n).getDay();return Math.floor((ac.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ac[n+"s"]=e.range,ac[n+"s"].utc=e.utc.range,ac[n+"OfYear"]=function(n){var e=ac.year(n).getDay();return Math.floor((ac.dayOfYear(n)+(e+t)%7)/7)}}),ac.week=ac.sunday,ac.weeks=ac.sunday.range,ac.weeks.utc=ac.sunday.utc.range,ac.weekOfYear=ac.sundayOfYear;var sc={"-":"",_:" ",0:"0"},fc=/^\s*\d+/,hc=/^%/;ta.locale=function(n){return{numberFormat:Pt(n),timeFormat:Ot(n)}};var gc=ta.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ta.format=gc.numberFormat,ta.geo={},ce.prototype={s:0,t:0,add:function(n){le(n,this.t,pc),le(pc.s,this.s,this),this.s?this.t+=pc.t:this.s=pc.t +},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var pc=new ce;ta.geo.stream=function(n,t){n&&vc.hasOwnProperty(n.type)?vc[n.type](n,t):se(n,t)};var vc={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*qa+n:n,Mc.lineStart=Mc.lineEnd=Mc.point=b}};ta.geo.bounds=function(){function n(n,t){M.push(x=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*Da,e*Da]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);Me(o),o=xe(o);var c=t-p,l=c>0?1:-1,v=o[0]*Pa*l,d=ga(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Pa;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Pa;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){b.point=t}function r(){x[0]=s,x[1]=h,b.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=ga(r)>180?r+(r>0?360:-360):r}else v=n,d=e;Mc.point(n,e),t(n,e)}function i(){Mc.lineStart()}function o(){u(v,d),Mc.lineEnd(),ga(y)>Ca&&(s=-(h=180)),x[0]=s,x[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nyc?(s=-(h=180),f=-(g=90)):y>Ca?g=90:-Ca>y&&(f=-90),x[0]=s,x[1]=h}};return function(n){g=h=-(s=f=1/0),M=[],ta.geo.stream(n,b);var t=M.length;if(t){M.sort(c);for(var e,r=1,u=M[0],i=[u];t>r;++r)e=M[r],l(e[0],u)||l(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,s=e[0],h=u[1])}return M=x=null,1/0===s||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[s,f],[h,g]]}}(),ta.geo.centroid=function(n){xc=bc=_c=wc=Sc=kc=Ec=Ac=Nc=Cc=zc=0,ta.geo.stream(n,qc);var t=Nc,e=Cc,r=zc,u=t*t+e*e+r*r;return za>u&&(t=kc,e=Ec,r=Ac,Ca>bc&&(t=_c,e=wc,r=Sc),u=t*t+e*e+r*r,za>u)?[0/0,0/0]:[Math.atan2(e,t)*Pa,tt(r/Math.sqrt(u))*Pa]};var xc,bc,_c,wc,Sc,kc,Ec,Ac,Nc,Cc,zc,qc={sphere:b,point:_e,lineStart:Se,lineEnd:ke,polygonStart:function(){qc.lineStart=Ee},polygonEnd:function(){qc.lineStart=Se}},Lc=Le(Ne,Pe,je,[-qa,-qa/2]),Tc=1e9;ta.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Ie(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ta.geo.conicEqualArea=function(){return Ye(Ze)}).raw=Ze,ta.geo.albers=function(){return ta.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ta.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=ta.geo.albers(),o=ta.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ta.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var l=i.scale(),s=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[s-.455*l,f-.238*l],[s+.455*l,f+.238*l]]).stream(c).point,r=o.translate([s-.307*l,f+.201*l]).clipExtent([[s-.425*l+Ca,f+.12*l+Ca],[s-.214*l-Ca,f+.234*l-Ca]]).stream(c).point,u=a.translate([s-.205*l,f+.212*l]).clipExtent([[s-.214*l+Ca,f+.166*l+Ca],[s-.115*l-Ca,f+.234*l-Ca]]).stream(c).point,n},n.scale(1070)};var Rc,Dc,Pc,Uc,jc,Fc,Hc={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Dc=0,Hc.lineStart=Ve},polygonEnd:function(){Hc.lineStart=Hc.lineEnd=Hc.point=b,Rc+=ga(Dc/2)}},Oc={point:Xe,lineStart:b,lineEnd:b,polygonStart:b,polygonEnd:b},Ic={point:We,lineStart:Je,lineEnd:Ge,polygonStart:function(){Ic.lineStart=Ke},polygonEnd:function(){Ic.point=We,Ic.lineStart=Je,Ic.lineEnd=Ge}};ta.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),ta.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return Rc=0,ta.geo.stream(n,u(Hc)),Rc},n.centroid=function(n){return _c=wc=Sc=kc=Ec=Ac=Nc=Cc=zc=0,ta.geo.stream(n,u(Ic)),zc?[Nc/zc,Cc/zc]:Ac?[kc/Ac,Ec/Ac]:Sc?[_c/Sc,wc/Sc]:[0/0,0/0]},n.bounds=function(n){return jc=Fc=-(Pc=Uc=1/0),ta.geo.stream(n,u(Oc)),[[Pc,Uc],[jc,Fc]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||tr(n):y,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new $e:new Qe(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(ta.geo.albersUsa()).context(null)},ta.geo.transform=function(n){return{stream:function(t){var e=new er(t);for(var r in n)e[r]=n[r];return e}}},er.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ta.geo.projection=ur,ta.geo.projectionMutator=ir,(ta.geo.equirectangular=function(){return ur(ar)}).raw=ar.invert=ar,ta.geo.rotation=function(n){function t(t){return t=n(t[0]*Da,t[1]*Da),t[0]*=Pa,t[1]*=Pa,t}return n=lr(n[0]%360*Da,n[1]*Da,n.length>2?n[2]*Da:0),t.invert=function(t){return t=n.invert(t[0]*Da,t[1]*Da),t[0]*=Pa,t[1]*=Pa,t},t},cr.invert=ar,ta.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=lr(-n[0]*Da,-n[1]*Da,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Pa,n[1]*=Pa}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=gr((t=+r)*Da,u*Da),n):t},n.precision=function(r){return arguments.length?(e=gr(t*Da,(u=+r)*Da),n):u},n.angle(90)},ta.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Da,u=n[1]*Da,i=t[1]*Da,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),l=Math.cos(u),s=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=l*s-c*f*a)*e),c*s+l*f*a)},ta.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ta.range(Math.ceil(i/d)*d,u,d).map(h).concat(ta.range(Math.ceil(l/m)*m,c,m).map(g)).concat(ta.range(Math.ceil(r/p)*p,e,p).filter(function(n){return ga(n%d)>Ca}).map(s)).concat(ta.range(Math.ceil(a/v)*v,o,v).filter(function(n){return ga(n%m)>Ca}).map(f))}var e,r,u,i,o,a,c,l,s,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],l=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[i,l],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,s=vr(a,o,90),f=dr(r,e,y),h=vr(l,c,90),g=dr(i,u,y),n):y},n.majorExtent([[-180,-90+Ca],[180,90-Ca]]).minorExtent([[-180,-80-Ca],[180,80+Ca]])},ta.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=mr,u=yr;return n.distance=function(){return ta.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},ta.geo.interpolate=function(n,t){return Mr(n[0]*Da,n[1]*Da,t[0]*Da,t[1]*Da)},ta.geo.length=function(n){return Yc=0,ta.geo.stream(n,Zc),Yc};var Yc,Zc={sphere:b,point:b,lineStart:xr,lineEnd:b,polygonStart:b,polygonEnd:b},Vc=br(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ta.geo.azimuthalEqualArea=function(){return ur(Vc)}).raw=Vc;var Xc=br(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},y);(ta.geo.azimuthalEquidistant=function(){return ur(Xc)}).raw=Xc,(ta.geo.conicConformal=function(){return Ye(_r)}).raw=_r,(ta.geo.conicEquidistant=function(){return Ye(wr)}).raw=wr;var $c=br(function(n){return 1/n},Math.atan);(ta.geo.gnomonic=function(){return ur($c)}).raw=$c,Sr.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Ra]},(ta.geo.mercator=function(){return kr(Sr)}).raw=Sr;var Bc=br(function(){return 1},Math.asin);(ta.geo.orthographic=function(){return ur(Bc)}).raw=Bc;var Wc=br(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ta.geo.stereographic=function(){return ur(Wc)}).raw=Wc,Er.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Ra]},(ta.geo.transverseMercator=function(){var n=kr(Er),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Er,ta.geom={},ta.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=Et(e),i=Et(r),o=n.length,a=[],c=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(zr),t=0;o>t;t++)c.push([a[t][0],-a[t][1]]);var l=Cr(a),s=Cr(c),f=s[0]===l[0],h=s[s.length-1]===l[l.length-1],g=[];for(t=l.length-1;t>=0;--t)g.push(n[a[l[t]][2]]);for(t=+f;t=r&&l.x<=i&&l.y>=u&&l.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];s.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Ca)*Ca,y:Math.round(o(n,t)/Ca)*Ca,i:t}})}var r=Ar,u=Nr,i=r,o=u,a=ul;return n?t(n):(t.links=function(n){return iu(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return iu(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(Yr),c=-1,l=a.length,s=a[l-1].edge,f=s.l===o?s.r:s.l;++c=l,h=r>=s,g=h<<1|f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=su()),f?u=l:a=l,h?o=s:c=s,i(n,t,e,r,u,o,a,c)}var s,f,h,g,p,v,d,m,y,M=Et(a),x=Et(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)s=n[g],s.xm&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var b=+M(s=n[g],g),_=+x(s,g);v>b&&(v=b),d>_&&(d=_),b>m&&(m=b),_>y&&(y=_),f.push(b),h.push(_)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=su();if(k.add=function(n){i(k,n,+M(n,++g),+x(n,g),v,d,m,y)},k.visit=function(n){fu(n,k,v,d,m,y)},k.find=function(n){return hu(k,n[0],n[1],v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=cl.get(e)||al,r=ll.get(r)||y,Mu(r(e.apply(null,ea.call(arguments,1))))},ta.interpolateHcl=Lu,ta.interpolateHsl=Tu,ta.interpolateLab=Ru,ta.interpolateRound=Du,ta.transform=function(n){var t=ua.createElementNS(ta.ns.prefix.svg,"g");return(ta.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Pu(e?e.matrix:sl)})(n)},Pu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var sl={a:1,b:0,c:0,d:1,e:0,f:0};ta.interpolateTransform=Hu,ta.layout={},ta.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var l=t.charge/c;n.px-=i*l,n.py-=o*l}return!0}if(t.point&&c&&p>c){var l=t.pointCharge/c;n.px-=i*l,n.py-=o*l}}return!t.charge}}function t(n){n.px=ta.event.x,n.py=ta.event.y,a.resume()}var e,r,u,i,o,a={},c=ta.dispatch("start","tick","end"),l=[1,1],s=.9,f=fl,h=hl,g=-30,p=gl,v=.1,d=.64,m=[],M=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,y,x,b=m.length,_=M.length;for(e=0;_>e;++e)a=M[e],f=a.source,h=a.target,y=h.x-f.x,x=h.y-f.y,(p=y*y+x*x)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,y*=p,x*=p,h.x-=y*(d=f.weight/(h.weight+f.weight)),h.y-=x*d,f.x+=y*(d=1-d),f.y+=x*d);if((d=r*v)&&(y=l[0]/2,x=l[1]/2,e=-1,d))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ta.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;s>a;++a){var u=M[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,l=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;s>t;++t)r=M[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;s>t;++t)u[t]=+f.call(this,M[t],t);else for(t=0;s>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;s>t;++t)i[t]=+h.call(this,M[t],t);else for(t=0;s>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=ta.behavior.drag().origin(y).on("dragstart.force",Xu).on("drag.force",t).on("dragend.force",$u)),arguments.length?void this.on("mouseover.force",Bu).on("mouseout.force",Wu).call(e):e},ta.rebind(a,c,"on")};var fl=20,hl=1,gl=1/0;ta.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(l=e.call(n,i,i.depth))&&(c=l.length)){for(var c,l,s;--c>=0;)o.push(s=l[c]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=l}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Qu(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=ei,e=ni,r=ti;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ku(t,function(n){n.children&&(n.value=0)}),Qu(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ta.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),p=(f-c*g)/ta.sum(l),v=ta.range(c),d=[];return null!=e&&v.sort(e===pl?function(n,t){return l[t]-l[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){d[n]={data:o[n],value:a=l[n],startAngle:s,endAngle:s+=a*p+g,padAngle:h}}),d}var t=Number,e=pl,r=0,u=La,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var pl={};ta.layout.stack=function(){function n(a,c){if(!(h=a.length))return a;var l=a.map(function(e,r){return t.call(n,e,r)}),s=l.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),f=e.call(n,s,c);l=ta.permute(l,f),s=ta.permute(s,f);var h,g,p,v,d=r.call(n,s,c),m=l[0].length;for(p=0;m>p;++p)for(u.call(n,l[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,l[g][p],v+=s[g-1][p][1],s[g][p][1]);return a}var t=y,e=ai,r=ci,u=oi,i=ui,o=ii;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:vl.get(t)||ai,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:dl.get(t)||ci,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var vl=ta.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(li),i=n.map(si),o=ta.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,l=[],s=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],l.push(e)):(c+=i[e],s.push(e));return s.reverse().concat(l)},reverse:function(n){return ta.range(n.length).reverse()},"default":ai}),dl=ta.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,l,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];s>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ci});ta.layout.histogram=function(){function n(n,i){for(var o,a,c=[],l=n.map(e,this),s=r.call(this,l,i),f=u.call(this,s,l,i),i=-1,h=l.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&a<=s[1]&&(o=c[ta.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=pi,u=hi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=Et(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return gi(n,t)}:Et(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ta.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],l=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Qu(a,function(n){n.r=+s(n.value)}),Qu(a,Mi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/l))/2;Qu(a,function(n){n.r+=f}),Qu(a,Mi),Qu(a,function(n){n.r-=f})}return _i(a,c/2,l/2,t?1:1/Math.max(2*a.r/c,2*a.r/l)),o}var t,e=ta.layout.hierarchy().sort(vi),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Gu(n,e)},ta.layout.tree=function(){function n(n,u){var s=o.call(this,n,u),f=s[0],h=t(f);if(Qu(h,e),h.parent.m=-h.z,Ku(h,r),l)Ku(f,i);else{var g=f,p=f,v=f;Ku(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);Ku(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Ni(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],l=u.m,s=i.m,f=o.m,h=c.m;o=Ei(o),u=ki(u),o&&u;)c=ki(c),i=Ei(i),i.a=n,r=o.z+f-u.z-l+a(o._,u._),r>0&&(Ai(Ci(o,n,e),n,r),l+=r,s+=r),f+=o.m,l+=u.m,h+=c.m,s+=i.m;o&&!Ei(i)&&(i.t=o,i.m+=f-s),u&&!ki(c)&&(c.t=u,c.m+=l-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=ta.layout.hierarchy().sort(null).value(null),a=Si,c=[1,1],l=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(l=null==(c=t)?i:null,n):l?null:c},n.nodeSize=function(t){return arguments.length?(l=null==(c=t)?null:i,n):l?c:null},Gu(n,o)},ta.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],l=0;Qu(c,function(n){var t=n.children;t&&t.length?(n.x=qi(t),n.y=zi(t)):(n.x=o?l+=e(n,o):0,n.y=0,o=n)});var s=Li(c),f=Ti(c),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return Qu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=ta.layout.hierarchy().sort(null).value(null),e=Si,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Gu(n,t)},ta.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,l=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),s.area=0;(c=h.length)>0;)s.push(o=h[c-1]),s.area+=o.area,"squarify"!==g||(a=r(s,v))<=p?(h.pop(),p=a):(s.area-=s.pop().area,u(s,v,l,!1),v=Math.min(l.dx,l.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,l,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,l=e.y,s=t?c(n.area/t):0;if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=ta.random.normal.apply(ta,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ta.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ta.scale={};var ml={floor:y,ceil:y};ta.scale.linear=function(){return Ii([0,1],[0,1],mu,!1)};var yl={s:1,g:1,p:1,r:1,e:1};ta.scale.log=function(){return Ji(ta.scale.linear().domain([0,1]),10,!0,[1,10])};var Ml=ta.format(".0e"),xl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ta.scale.pow=function(){return Gi(ta.scale.linear(),1,[0,1])},ta.scale.sqrt=function(){return ta.scale.pow().exponent(.5)},ta.scale.ordinal=function(){return Qi([],{t:"range",a:[[]]})},ta.scale.category10=function(){return ta.scale.ordinal().range(bl)},ta.scale.category20=function(){return ta.scale.ordinal().range(_l)},ta.scale.category20b=function(){return ta.scale.ordinal().range(wl)},ta.scale.category20c=function(){return ta.scale.ordinal().range(Sl)};var bl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(Mt),_l=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(Mt),wl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(Mt),Sl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(Mt);ta.scale.quantile=function(){return no([],[])},ta.scale.quantize=function(){return to(0,1,[0,1])},ta.scale.threshold=function(){return eo([.5],[0,1])},ta.scale.identity=function(){return ro([0,1])},ta.svg={},ta.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),s=o.apply(this,arguments)-Ra,f=a.apply(this,arguments)-Ra,h=Math.abs(f-s),g=s>f?0:1;if(n>l&&(p=l,l=n,n=p),h>=Ta)return t(l,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,E=0,A=0,N=[];if((m=(+c.apply(this,arguments)||0)/2)&&(d=i===kl?Math.sqrt(n*n+l*l):+i.apply(this,arguments),g||(A*=-1),l&&(A=tt(d/l*Math.sin(m))),n&&(E=tt(d/n*Math.sin(m)))),l){y=l*Math.cos(s+A),M=l*Math.sin(s+A),x=l*Math.cos(f-A),b=l*Math.sin(f-A);var C=Math.abs(f-s-2*A)<=qa?0:1;if(A&&so(y,M,x,b)===g^C){var z=(s+f)/2;y=l*Math.cos(z),M=l*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-E),w=n*Math.sin(f-E),S=n*Math.cos(s+E),k=n*Math.sin(s+E);var q=Math.abs(s-f+2*E)<=qa?0:1;if(E&&so(_,w,S,k)===1-g^q){var L=(s+f)/2;_=n*Math.cos(L),w=n*Math.sin(L),S=k=null}}else _=w=0;if((p=Math.min(Math.abs(l-n)/2,+u.apply(this,arguments)))>.001){v=l>n^g?0:1;var T=null==S?[_,w]:null==x?[y,M]:Lr([y,M],[S,k],[x,b],[_,w]),R=y-T[0],D=M-T[1],P=x-T[0],U=b-T[1],j=1/Math.sin(Math.acos((R*P+D*U)/(Math.sqrt(R*R+D*D)*Math.sqrt(P*P+U*U)))/2),F=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(null!=x){var H=Math.min(p,(l-F)/(j+1)),O=fo(null==S?[_,w]:[S,k],[y,M],l,H,g),I=fo([x,b],[_,w],l,H,g);p===H?N.push("M",O[0],"A",H,",",H," 0 0,",v," ",O[1],"A",l,",",l," 0 ",1-g^so(O[1][0],O[1][1],I[1][0],I[1][1]),",",g," ",I[1],"A",H,",",H," 0 0,",v," ",I[0]):N.push("M",O[0],"A",H,",",H," 0 1,",v," ",I[0])}else N.push("M",y,",",M);if(null!=S){var Y=Math.min(p,(n-F)/(j-1)),Z=fo([y,M],[S,k],n,-Y,g),V=fo([_,w],null==x?[y,M]:[x,b],n,-Y,g);p===Y?N.push("L",V[0],"A",Y,",",Y," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^so(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",Y,",",Y," 0 0,",v," ",Z[0]):N.push("L",V[0],"A",Y,",",Y," 0 0,",v," ",Z[0])}else N.push("L",_,",",w)}else N.push("M",y,",",M),null!=x&&N.push("A",l,",",l," 0 ",C,",",g," ",x,",",b),N.push("L",_,",",w),null!=S&&N.push("A",n,",",n," 0 ",q,",",1-g," ",S,",",k);return N.push("Z"),N.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=io,r=oo,u=uo,i=kl,o=ao,a=co,c=lo;return n.innerRadius=function(t){return arguments.length?(e=Et(t),n):e},n.outerRadius=function(t){return arguments.length?(r=Et(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=Et(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==kl?kl:Et(t),n):i},n.startAngle=function(t){return arguments.length?(o=Et(t),n):o},n.endAngle=function(t){return arguments.length?(a=Et(t),n):a},n.padAngle=function(t){return arguments.length?(c=Et(t),n):c},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Ra;return[Math.cos(t)*n,Math.sin(t)*n]},n};var kl="auto";ta.svg.line=function(){return ho(y)};var El=ta.map({linear:go,"linear-closed":po,step:vo,"step-before":mo,"step-after":yo,basis:So,"basis-open":ko,"basis-closed":Eo,bundle:Ao,cardinal:bo,"cardinal-open":Mo,"cardinal-closed":xo,monotone:To});El.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Al=[0,2/3,1/3,0],Nl=[0,1/3,2/3,0],Cl=[0,1/6,2/3,1/6];ta.svg.line.radial=function(){var n=ho(Ro);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},mo.reverse=yo,yo.reverse=mo,ta.svg.area=function(){return Do(y)},ta.svg.area.radial=function(){var n=Do(Ro);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ta.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),l=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+u(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)-Ra,s=l.call(n,u,r)-Ra;return{r:i,a0:o,a1:s,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>qa)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=mr,o=yr,a=Po,c=ao,l=co;return n.radius=function(t){return arguments.length?(a=Et(t),n):a},n.source=function(t){return arguments.length?(i=Et(t),n):i},n.target=function(t){return arguments.length?(o=Et(t),n):o},n.startAngle=function(t){return arguments.length?(c=Et(t),n):c},n.endAngle=function(t){return arguments.length?(l=Et(t),n):l},n},ta.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=mr,e=yr,r=Uo;return n.source=function(e){return arguments.length?(t=Et(e),n):t},n.target=function(t){return arguments.length?(e=Et(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ta.svg.diagonal.radial=function(){var n=ta.svg.diagonal(),t=Uo,e=n.projection;return n.projection=function(n){return arguments.length?e(jo(t=n)):t},n},ta.svg.symbol=function(){function n(n,r){return(zl.get(t.call(this,n,r))||Oo)(e.call(this,n,r))}var t=Ho,e=Fo;return n.type=function(e){return arguments.length?(t=Et(e),n):t},n.size=function(t){return arguments.length?(e=Et(t),n):e},n};var zl=ta.map({circle:Oo,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ll)),e=t*Ll;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/ql),e=t*ql/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/ql),e=t*ql/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ta.svg.symbolTypes=zl.keys();var ql=Math.sqrt(3),Ll=Math.tan(30*Da);_a.transition=function(n){for(var t,e,r=Tl||++Ul,u=Xo(n),i=[],o=Rl||{time:Date.now(),ease:Su,delay:0,duration:250},a=-1,c=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Yo(u,this.namespace,this.id)},Pl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):Y(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Pl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Hu:mu,a=ta.ns.qualify(n);return Zo(this,"attr."+n,t,a.local?i:u)},Pl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=ta.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Pl.style=function(n,e,r){function u(){this.style.removeProperty(n)}function i(e){return null==e?u:(e+="",function(){var u,i=t(this).getComputedStyle(this,null).getPropertyValue(n);return i!==e&&(u=mu(i,e),function(t){this.style.setProperty(n,u(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return Zo(this,"style."+n,e,i)},Pl.styleTween=function(n,e,r){function u(u,i){var o=e.call(this,u,i,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,u)},Pl.text=function(n){return Zo(this,"text",n,Vo)},Pl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Pl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ta.ease.apply(ta,arguments)),Y(this,function(r){r[e][t].ease=n}))},Pl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:Y(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Pl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:Y(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Pl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=Rl,i=Tl;try{Tl=e,Y(this,function(t,u,i){Rl=t[r][e],n.call(t,t.__data__,u,i)})}finally{Rl=u,Tl=i}}else Y(this,function(u){var i=u[r][e];(i.event||(i.event=ta.dispatch("start","end","interrupt"))).on(n,t)});return this},Pl.transition=function(){for(var n,t,e,r,u=this.id,i=++Ul,o=this.namespace,a=[],c=0,l=this.length;l>c;c++){a.push(n=[]);for(var t=this[c],s=0,f=t.length;f>s;s++)(e=t[s])&&(r=e[o][u],$o(e,s,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Yo(a,o,i)},ta.svg.axis=function(){function n(n){n.each(function(){var n,l=ta.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):y:t,p=l.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Ca),d=ta.transition(p.exit()).style("opacity",Ca).remove(),m=ta.transition(p.order()).style("opacity",1),M=Math.max(u,0)+o,x=Ui(f),b=l.selectAll(".domain").data([0]),_=(b.enter().append("path").attr("class","domain"),ta.transition(b));v.append("line"),v.append("text");var w,S,k,E,A=v.select("line"),N=m.select("line"),C=p.select("text").text(g),z=v.select("text"),q=m.select("text"),L="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Bo,w="x",k="y",S="x2",E="y2",C.attr("dy",0>L?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+L*i+"V0H"+x[1]+"V"+L*i)):(n=Wo,w="y",k="x",S="y2",E="x2",C.attr("dy",".32em").style("text-anchor",0>L?"end":"start"),_.attr("d","M"+L*i+","+x[0]+"H0V"+x[1]+"H"+L*i)),A.attr(E,L*u),z.attr(k,L*M),N.attr(S,0).attr(E,L*u),q.attr(w,0).attr(k,L*M),f.rangeBand){var T=f,R=T.rangeBand()/2;s=f=function(n){return T(n)+R}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=ta.scale.linear(),r=jl,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Fl?t+"":jl,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var jl="bottom",Fl={top:1,right:1,bottom:1,left:1};ta.svg.brush=function(){function n(t){t.each(function(){var t=ta.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",i).on("touchstart.brush",i),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(v,y);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Hl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var c,f=ta.transition(t),h=ta.transition(o);l&&(c=Ui(l),h.attr("x",c[0]).attr("width",c[1]-c[0]),r(f)),s&&(c=Ui(s),h.attr("y",c[0]).attr("height",c[1]-c[0]),u(f)),e(f)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+f[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",f[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function u(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function i(){function i(){32==ta.event.keyCode&&(C||(M=null,q[0]-=f[1],q[1]-=h[1],C=2),S())}function v(){32==ta.event.keyCode&&2==C&&(q[0]+=f[1],q[1]+=h[1],C=0,S())}function d(){var n=ta.mouse(b),t=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(ta.event.altKey?(M||(M=[(f[0]+f[1])/2,(h[0]+h[1])/2]),q[0]=f[+(n[0]s?(u=r,r=s):u=s),v[0]!=r||v[1]!=u?(e?a=null:o=null,v[0]=r,v[1]=u,!0):void 0}function y(){d(),k.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ta.select("body").style("cursor",null),L.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),z(),w({type:"brushend"})}var M,x,b=this,_=ta.select(ta.event.target),w=c.of(b,arguments),k=ta.select(b),E=_.datum(),A=!/^(n|s)$/.test(E)&&l,N=!/^(e|w)$/.test(E)&&s,C=_.classed("extent"),z=W(b),q=ta.mouse(b),L=ta.select(t(b)).on("keydown.brush",i).on("keyup.brush",v);if(ta.event.changedTouches?L.on("touchmove.brush",d).on("touchend.brush",y):L.on("mousemove.brush",d).on("mouseup.brush",y),k.interrupt().selectAll("*").interrupt(),C)q[0]=f[0]-q[0],q[1]=h[0]-q[1];else if(E){var T=+/w$/.test(E),R=+/^n/.test(E);x=[f[1-T]-q[0],h[1-R]-q[1]],q[0]=f[T],q[1]=h[R]}else ta.event.altKey&&(M=q.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),ta.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),d()}var o,a,c=E(n,"brushstart","brush","brushend"),l=null,s=null,f=[0,0],h=[0,0],g=!0,p=!0,v=Ol[0];return n.event=function(n){n.each(function(){var n=c.of(this,arguments),t={x:f,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Tl?ta.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,f=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=yu(f,t.x),r=yu(h,t.y);return o=a=null,function(u){f=t.x=e(u),h=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(l=t,v=Ol[!l<<1|!s],n):l},n.y=function(t){return arguments.length?(s=t,v=Ol[!l<<1|!s],n):s},n.clamp=function(t){return arguments.length?(l&&s?(g=!!t[0],p=!!t[1]):l?g=!!t:s&&(p=!!t),n):l&&s?[g,p]:l?g:s?p:null},n.extent=function(t){var e,r,u,i,c;return arguments.length?(l&&(e=t[0],r=t[1],s&&(e=e[0],r=r[0]),o=[e,r],l.invert&&(e=l(e),r=l(r)),e>r&&(c=e,e=r,r=c),(e!=f[0]||r!=f[1])&&(f=[e,r])),s&&(u=t[0],i=t[1],l&&(u=u[1],i=i[1]),a=[u,i],s.invert&&(u=s(u),i=s(i)),u>i&&(c=u,u=i,i=c),(u!=h[0]||i!=h[1])&&(h=[u,i])),n):(l&&(o?(e=o[0],r=o[1]):(e=f[0],r=f[1],l.invert&&(e=l.invert(e),r=l.invert(r)),e>r&&(c=e,e=r,r=c))),s&&(a?(u=a[0],i=a[1]):(u=h[0],i=h[1],s.invert&&(u=s.invert(u),i=s.invert(i)),u>i&&(c=u,u=i,i=c))),l&&s?[[e,u],[r,i]]:l?[e,r]:s&&[u,i])},n.clear=function(){return n.empty()||(f=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!l&&f[0]==f[1]||!!s&&h[0]==h[1]},ta.rebind(n,c,"on")};var Hl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ol=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Il=ac.format=gc.timeFormat,Yl=Il.utc,Zl=Yl("%Y-%m-%dT%H:%M:%S.%LZ");Il.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Jo:Zl,Jo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Jo.toString=Zl.toString,ac.second=Ft(function(n){return new cc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ac.seconds=ac.second.range,ac.seconds.utc=ac.second.utc.range,ac.minute=Ft(function(n){return new cc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ac.minutes=ac.minute.range,ac.minutes.utc=ac.minute.utc.range,ac.hour=Ft(function(n){var t=n.getTimezoneOffset()/60;return new cc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ac.hours=ac.hour.range,ac.hours.utc=ac.hour.utc.range,ac.month=Ft(function(n){return n=ac.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ac.months=ac.month.range,ac.months.utc=ac.month.utc.range;var Vl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Xl=[[ac.second,1],[ac.second,5],[ac.second,15],[ac.second,30],[ac.minute,1],[ac.minute,5],[ac.minute,15],[ac.minute,30],[ac.hour,1],[ac.hour,3],[ac.hour,6],[ac.hour,12],[ac.day,1],[ac.day,2],[ac.week,1],[ac.month,1],[ac.month,3],[ac.year,1]],$l=Il.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Ne]]),Bl={range:function(n,t,e){return ta.range(Math.ceil(n/e)*e,+t,e).map(Ko)},floor:y,ceil:y};Xl.year=ac.year,ac.scale=function(){return Go(ta.scale.linear(),Xl,$l)};var Wl=Xl.map(function(n){return[n[0].utc,n[1]]}),Jl=Yl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Ne]]);Wl.year=ac.year.utc,ac.scale.utc=function(){return Go(ta.scale.linear(),Wl,Jl)},ta.text=At(function(n){return n.responseText}),ta.json=function(n,t){return Nt(n,"application/json",Qo,t)},ta.html=function(n,t){return Nt(n,"text/html",na,t)},ta.xml=At(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(ta):"object"==typeof module&&module.exports&&(module.exports=ta),this.d3=ta}(); \ No newline at end of file diff --git a/share/views/ajax/device/netmap.tt b/share/views/ajax/device/netmap.tt index ccf623cf..ba4986f8 100644 --- a/share/views/ajax/device/netmap.tt +++ b/share/views/ajax/device/netmap.tt @@ -1,184 +1,28 @@ + @@ -52,6 +53,7 @@ +