1!function() { 2 var d3 = { 3 version: "3.4.1" 4 }; 5 if (!Date.now) Date.now = function() { 6 return +new Date(); 7 }; 8 var d3_arraySlice = [].slice, d3_array = function(list) { 9 return d3_arraySlice.call(list); 10 }; 11 var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window; 12 try { 13 d3_array(d3_documentElement.childNodes)[0].nodeType; 14 } catch (e) { 15 d3_array = function(list) { 16 var i = list.length, array = new Array(i); 17 while (i--) array[i] = list[i]; 18 return array; 19 }; 20 } 21 try { 22 d3_document.createElement("div").style.setProperty("opacity", 0, ""); 23 } catch (error) { 24 var d3_element_prototype = d3_window.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty; 25 d3_element_prototype.setAttribute = function(name, value) { 26 d3_element_setAttribute.call(this, name, value + ""); 27 }; 28 d3_element_prototype.setAttributeNS = function(space, local, value) { 29 d3_element_setAttributeNS.call(this, space, local, value + ""); 30 }; 31 d3_style_prototype.setProperty = function(name, value, priority) { 32 d3_style_setProperty.call(this, name, value + "", priority); 33 }; 34 } 35 d3.ascending = function(a, b) { 36 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; 37 }; 38 d3.descending = function(a, b) { 39 return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; 40 }; 41 d3.min = function(array, f) { 42 var i = -1, n = array.length, a, b; 43 if (arguments.length === 1) { 44 while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; 45 while (++i < n) if ((b = array[i]) != null && a > b) a = b; 46 } else { 47 while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; 48 while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; 49 } 50 return a; 51 }; 52 d3.max = function(array, f) { 53 var i = -1, n = array.length, a, b; 54 if (arguments.length === 1) { 55 while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; 56 while (++i < n) if ((b = array[i]) != null && b > a) a = b; 57 } else { 58 while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; 59 while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; 60 } 61 return a; 62 }; 63 d3.extent = function(array, f) { 64 var i = -1, n = array.length, a, b, c; 65 if (arguments.length === 1) { 66 while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined; 67 while (++i < n) if ((b = array[i]) != null) { 68 if (a > b) a = b; 69 if (c < b) c = b; 70 } 71 } else { 72 while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined; 73 while (++i < n) if ((b = f.call(array, array[i], i)) != null) { 74 if (a > b) a = b; 75 if (c < b) c = b; 76 } 77 } 78 return [ a, c ]; 79 }; 80 d3.sum = function(array, f) { 81 var s = 0, n = array.length, a, i = -1; 82 if (arguments.length === 1) { 83 while (++i < n) if (!isNaN(a = +array[i])) s += a; 84 } else { 85 while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; 86 } 87 return s; 88 }; 89 function d3_number(x) { 90 return x != null && !isNaN(x); 91 } 92 d3.mean = function(array, f) { 93 var n = array.length, a, m = 0, i = -1, j = 0; 94 if (arguments.length === 1) { 95 while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j; 96 } else { 97 while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j; 98 } 99 return j ? m : undefined; 100 }; 101 d3.quantile = function(values, p) { 102 var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; 103 return e ? v + e * (values[h] - v) : v; 104 }; 105 d3.median = function(array, f) { 106 if (arguments.length > 1) array = array.map(f); 107 array = array.filter(d3_number); 108 return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined; 109 }; 110 d3.bisector = function(f) { 111 return { 112 left: function(a, x, lo, hi) { 113 if (arguments.length < 3) lo = 0; 114 if (arguments.length < 4) hi = a.length; 115 while (lo < hi) { 116 var mid = lo + hi >>> 1; 117 if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid; 118 } 119 return lo; 120 }, 121 right: function(a, x, lo, hi) { 122 if (arguments.length < 3) lo = 0; 123 if (arguments.length < 4) hi = a.length; 124 while (lo < hi) { 125 var mid = lo + hi >>> 1; 126 if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1; 127 } 128 return lo; 129 } 130 }; 131 }; 132 var d3_bisector = d3.bisector(function(d) { 133 return d; 134 }); 135 d3.bisectLeft = d3_bisector.left; 136 d3.bisect = d3.bisectRight = d3_bisector.right; 137 d3.shuffle = function(array) { 138 var m = array.length, t, i; 139 while (m) { 140 i = Math.random() * m-- | 0; 141 t = array[m], array[m] = array[i], array[i] = t; 142 } 143 return array; 144 }; 145 d3.permute = function(array, indexes) { 146 var i = indexes.length, permutes = new Array(i); 147 while (i--) permutes[i] = array[indexes[i]]; 148 return permutes; 149 }; 150 d3.pairs = function(array) { 151 var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); 152 while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; 153 return pairs; 154 };
155 d3.zip = function() { 156 if (!(n = arguments.length)) return []; 157 for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) { 158 for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) { 159 zip[j] = arguments[j][i]; 160 } 161 } 162 return zips; 163 }; 164 function d3_zipLength(d) { 165 return d.length; 166 } 167 d3.transpose = function(matrix) { 168 return d3.zip.apply(d3, matrix); 169 }; 170 d3.keys = function(map) { 171 var keys = []; 172 for (var key in map) keys.push(key); 173 return keys; 174 }; 175 d3.values = function(map) { 176 var values = []; 177 for (var key in map) values.push(map[key]); 178 return values; 179 }; 180 d3.entries = function(map) { 181 var entries = []; 182 for (var key in map) entries.push({ 183 key: key, 184 value: map[key] 185 }); 186 return entries; 187 }; 188 d3.merge = function(arrays) { 189 var n = arrays.length, m, i = -1, j = 0, merged, array; 190 while (++i < n) j += arrays[i].length; 191 merged = new Array(j); 192 while (--n >= 0) { 193 array = arrays[n]; 194 m = array.length; 195 while (--m >= 0) { 196 merged[--j] = array[m]; 197 } 198 } 199 return merged; 200 }; 201 var abs = Math.abs; 202 d3.range = function(start, stop, step) { 203 if (arguments.length < 3) { 204 step = 1; 205 if (arguments.length < 2) { 206 stop = start; 207 start = 0; 208 } 209 } 210 if ((stop - start) / step === Infinity) throw new Error("infinite range"); 211 var range = [], k = d3_range_integerScale(abs(step)), i = -1, j; 212 start *= k, stop *= k, step *= k; 213 if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); 214 return range; 215 }; 216 function d3_range_integerScale(x) { 217 var k = 1; 218 while (x * k % 1) k *= 10; 219 return k; 220 } 221 function d3_class(ctor, properties) { 222 try { 223 for (var key in properties) { 224 Object.defineProperty(ctor.prototype, key, { 225 value: properties[key], 226 enumerable: false 227 }); 228 } 229 } catch (e) { 230 ctor.prototype = properties; 231 } 232 } 233 d3.map = function(object) { 234 var map = new d3_Map(); 235 if (object instanceof d3_Map) object.forEach(function(key, value) { 236 map.set(key, value); 237 }); else for (var key in object) map.set(key, object[key]); 238 return map; 239 }; 240 function d3_Map() {} 241 d3_class(d3_Map, { 242 has: d3_map_has, 243 get: function(key) { 244 return this[d3_map_prefix + key]; 245 }, 246 set: function(key, value) { 247 return this[d3_map_prefix + key] = value; 248 }, 249 remove: d3_map_remove, 250 keys: d3_map_keys, 251 values: function() { 252 var values = []; 253 this.forEach(function(key, value) { 254 values.push(value); 255 }); 256 return values; 257 }, 258 entries: function() { 259 var entries = []; 260 this.forEach(function(key, value) { 261 entries.push({ 262 key: key, 263 value: value 264 }); 265 }); 266 return entries; 267 }, 268 size: d3_map_size, 269 empty: d3_map_empty, 270 forEach: function(f) { 271 for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) f.call(this, key.substring(1), this[key]); 272 } 273 }); 274 var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); 275 function d3_map_has(key) { 276 return d3_map_prefix + key in this; 277 } 278 function d3_map_remove(key) { 279 key = d3_map_prefix + key; 280 return key in this && delete this[key]; 281 } 282 function d3_map_keys() { 283 var keys = []; 284 this.forEach(function(key) { 285 keys.push(key); 286 }); 287 return keys; 288 } 289 function d3_map_size() { 290 var size = 0; 291 for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) ++size; 292 return size; 293 } 294 function d3_map_empty() { 295 for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) return false; 296 return true; 297 } 298 d3.nest = function() { 299 var nest = {}, keys = [], sortKeys = [], sortValues, rollup; 300 function map(mapType, array, depth) { 301 if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; 302 var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; 303 while (++i < n) { 304 if (values = valuesByKey.get(keyValue = key(object = array[i]))) { 305 values.push(object); 306 } else {
vendor: 13,445 bytes, lines 307-704
307 valuesByKey.set(keyValue, [ object ]); 308 } 309 } 310 if (mapType) { 311 object = mapType(); 312 setter = function(keyValue, values) { 313 object.set(keyValue, map(mapType, values, depth)); 314 }; 315 } else { 316 object = {}; 317 setter = function(keyValue, values) { 318 object[keyValue] = map(mapType, values, depth); 319 }; 320 } 321 valuesByKey.forEach(setter); 322 return object; 323 } 324 function entries(map, depth) { 325 if (depth >= keys.length) return map; 326 var array = [], sortKey = sortKeys[depth++]; 327 map.forEach(function(key, keyMap) { 328 array.push({ 329 key: key, 330 values: entries(keyMap, depth) 331 }); 332 }); 333 return sortKey ? array.sort(function(a, b) { 334 return sortKey(a.key, b.key); 335 }) : array; 336 } 337 nest.map = function(array, mapType) { 338 return map(mapType, array, 0); 339 }; 340 nest.entries = function(array) { 341 return entries(map(d3.map, array, 0), 0); 342 }; 343 nest.key = function(d) { 344 keys.push(d); 345 return nest; 346 }; 347 nest.sortKeys = function(order) { 348 sortKeys[keys.length - 1] = order; 349 return nest; 350 }; 351 nest.sortValues = function(order) { 352 sortValues = order; 353 return nest; 354 }; 355 nest.rollup = function(f) { 356 rollup = f; 357 return nest; 358 }; 359 return nest; 360 }; 361 d3.set = function(array) { 362 var set = new d3_Set(); 363 if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); 364 return set; 365 }; 366 function d3_Set() {} 367 d3_class(d3_Set, { 368 has: d3_map_has, 369 add: function(value) { 370 this[d3_map_prefix + value] = true; 371 return value; 372 }, 373 remove: function(value) { 374 value = d3_map_prefix + value; 375 return value in this && delete this[value]; 376 }, 377 values: d3_map_keys, 378 size: d3_map_size, 379 empty: d3_map_empty, 380 forEach: function(f) { 381 for (var value in this) if (value.charCodeAt(0) === d3_map_prefixCode) f.call(this, value.substring(1)); 382 } 383 }); 384 d3.behavior = {}; 385 d3.rebind = function(target, source) { 386 var i = 1, n = arguments.length, method; 387 while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); 388 return target; 389 }; 390 function d3_rebind(target, source, method) { 391 return function() { 392 var value = method.apply(source, arguments); 393 return value === source ? target : value; 394 }; 395 } 396 function d3_vendorSymbol(object, name) { 397 if (name in object) return name; 398 name = name.charAt(0).toUpperCase() + name.substring(1); 399 for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { 400 var prefixName = d3_vendorPrefixes[i] + name; 401 if (prefixName in object) return prefixName; 402 } 403 } 404 var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; 405 function d3_noop() {} 406 d3.dispatch = function() { 407 var dispatch = new d3_dispatch(), i = -1, n = arguments.length; 408 while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); 409 return dispatch; 410 }; 411 function d3_dispatch() {} 412 d3_dispatch.prototype.on = function(type, listener) { 413 var i = type.indexOf("."), name = ""; 414 if (i >= 0) { 415 name = type.substring(i + 1); 416 type = type.substring(0, i); 417 } 418 if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); 419 if (arguments.length === 2) { 420 if (listener == null) for (type in this) { 421 if (this.hasOwnProperty(type)) this[type].on(name, null); 422 } 423 return this; 424 } 425 }; 426 function d3_dispatch_event(dispatch) { 427 var listeners = [], listenerByName = new d3_Map(); 428 function event() { 429 var z = listeners, i = -1, n = z.length, l; 430 while (++i < n) if (l = z[i].on) l.apply(this, arguments); 431 return dispatch; 432 } 433 event.on = function(name, listener) { 434 var l = listenerByName.get(name), i; 435 if (arguments.length < 2) return l && l.on; 436 if (l) { 437 l.on = null; 438 listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); 439 listenerByName.remove(name); 440 } 441 if (listener) listeners.push(listenerByName.set(name, { 442 on: listener 443 })); 444 return dispatch; 445 }; 446 return event; 447 } 448 d3.event = null; 449 function d3_eventPreventDefault() { 450 d3.event.preventDefault(); 451 } 452 function d3_eventSource() { 453 var e = d3.event, s; 454 while (s = e.sourceEvent) e = s; 455 return e; 456 } 457 function d3_eventDispatch(target) { 458 var dispatch = new d3_dispatch(), i = 0, n = arguments.length; 459 while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); 460 dispatch.of = function(thiz, argumentz) { 461 return function(e1) { 462 try { 463 var e0 = e1.sourceEvent = d3.event; 464 e1.target = target; 465 d3.event = e1; 466 dispatch[e1.type].apply(thiz, argumentz); 467 } finally { 468 d3.event = e0; 469 } 470 }; 471 }; 472 return dispatch; 473 } 474 d3.requote = function(s) { 475 return s.replace(d3_requote_re, "\\$&"); 476 }; 477 var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; 478 var d3_subclass = {}.__proto__ ? function(object, prototype) { 479 object.__proto__ = prototype; 480 } : function(object, prototype) { 481 for (var property in prototype) object[property] = prototype[property]; 482 }; 483 function d3_selection(groups) { 484 d3_subclass(groups, d3_selectionPrototype); 485 return groups; 486 } 487 var d3_select = function(s, n) { 488 return n.querySelector(s); 489 }, d3_selectAll = function(s, n) { 490 return n.querySelectorAll(s); 491 }, d3_selectMatcher = d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) { 492 return d3_selectMatcher.call(n, s); 493 }; 494 if (typeof Sizzle === "function") { 495 d3_select = function(s, n) { 496 return Sizzle(s, n)[0] || null; 497 }; 498 d3_selectAll = function(s, n) { 499 return Sizzle.uniqueSort(Sizzle(s, n)); 500 }; 501 d3_selectMatches = Sizzle.matchesSelector; 502 } 503 d3.selection = function() { 504 return d3_selectionRoot; 505 }; 506 var d3_selectionPrototype = d3.selection.prototype = []; 507 d3_selectionPrototype.select = function(selector) { 508 var subgroups = [], subgroup, subnode, group, node; 509 selector = d3_selection_selector(selector); 510 for (var j = -1, m = this.length; ++j < m; ) { 511 subgroups.push(subgroup = []); 512 subgroup.parentNode = (group = this[j]).parentNode; 513 for (var i = -1, n = group.length; ++i < n; ) { 514 if (node = group[i]) { 515 subgroup.push(subnode = selector.call(node, node.__data__, i, j)); 516 if (subnode && "__data__" in node) subnode.__data__ = node.__data__; 517 } else { 518 subgroup.push(null); 519 } 520 } 521 } 522 return d3_selection(subgroups); 523 }; 524 function d3_selection_selector(selector) { 525 return typeof selector === "function" ? selector : function() { 526 return d3_select(selector, this); 527 }; 528 } 529 d3_selectionPrototype.selectAll = function(selector) { 530 var subgroups = [], subgroup, node; 531 selector = d3_selection_selectorAll(selector); 532 for (var j = -1, m = this.length; ++j < m; ) { 533 for (var group = this[j], i = -1, n = group.length; ++i < n; ) { 534 if (node = group[i]) { 535 subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); 536 subgroup.parentNode = node; 537 } 538 } 539 } 540 return d3_selection(subgroups); 541 }; 542 function d3_selection_selectorAll(selector) { 543 return typeof selector === "function" ? selector : function() { 544 return d3_selectAll(selector, this); 545 }; 546 } 547 var d3_nsPrefix = { 548 svg: "http://www.w3.org/2000/svg", 549 xhtml: "http://www.w3.org/1999/xhtml", 550 xlink: "http://www.w3.org/1999/xlink", 551 xml: "http://www.w3.org/XML/1998/namespace", 552 xmlns: "http://www.w3.org/2000/xmlns/" 553 }; 554 d3.ns = { 555 prefix: d3_nsPrefix, 556 qualify: function(name) { 557 var i = name.indexOf(":"), prefix = name; 558 if (i >= 0) { 559 prefix = name.substring(0, i); 560 name = name.substring(i + 1); 561 } 562 return d3_nsPrefix.hasOwnProperty(prefix) ? { 563 space: d3_nsPrefix[prefix], 564 local: name 565 } : name; 566 } 567 }; 568 d3_selectionPrototype.attr = function(name, value) { 569 if (arguments.length < 2) { 570 if (typeof name === "string") { 571 var node = this.node(); 572 name = d3.ns.qualify(name); 573 return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); 574 } 575 for (value in name) this.each(d3_selection_attr(value, name[value])); 576 return this; 577 } 578 return this.each(d3_selection_attr(name, value)); 579 }; 580 function d3_selection_attr(name, value) { 581 name = d3.ns.qualify(name); 582 function attrNull() { 583 this.removeAttribute(name); 584 } 585 function attrNullNS() { 586 this.removeAttributeNS(name.space, name.local); 587 } 588 function attrConstant() { 589 this.setAttribute(name, value); 590 } 591 function attrConstantNS() { 592 this.setAttributeNS(name.space, name.local, value); 593 } 594 function attrFunction() { 595 var x = value.apply(this, arguments); 596 if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); 597 } 598 function attrFunctionNS() { 599 var x = value.apply(this, arguments); 600 if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); 601 } 602 return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; 603 } 604 function d3_collapse(s) { 605 return s.trim().replace(/\s+/g, " "); 606 } 607 d3_selectionPrototype.classed = function(name, value) { 608 if (arguments.length < 2) { 609 if (typeof name === "string") { 610 var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; 611 if (value = node.classList) { 612 while (++i < n) if (!value.contains(name[i])) return false; 613 } else { 614 value = node.getAttribute("class"); 615 while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; 616 } 617 return true; 618 } 619 for (value in name) this.each(d3_selection_classed(value, name[value])); 620 return this; 621 } 622 return this.each(d3_selection_classed(name, value)); 623 }; 624 function d3_selection_classedRe(name) { 625 return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); 626 } 627 function d3_selection_classes(name) { 628 return name.trim().split(/^|\s+/); 629 } 630 function d3_selection_classed(name, value) { 631 name = d3_selection_classes(name).map(d3_selection_classedName); 632 var n = name.length; 633 function classedConstant() { 634 var i = -1; 635 while (++i < n) name[i](this, value); 636 } 637 function classedFunction() { 638 var i = -1, x = value.apply(this, arguments); 639 while (++i < n) name[i](this, x); 640 } 641 return typeof value === "function" ? classedFunction : classedConstant; 642 } 643 function d3_selection_classedName(name) { 644 var re = d3_selection_classedRe(name); 645 return function(node, value) { 646 if (c = node.classList) return value ? c.add(name) : c.remove(name); 647 var c = node.getAttribute("class") || ""; 648 if (value) { 649 re.lastIndex = 0; 650 if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); 651 } else { 652 node.setAttribute("class", d3_collapse(c.replace(re, " "))); 653 } 654 }; 655 } 656 d3_selectionPrototype.style = function(name, value, priority) { 657 var n = arguments.length; 658 if (n < 3) { 659 if (typeof name !== "string") { 660 if (n < 2) value = ""; 661 for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); 662 return this; 663 } 664 if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name); 665 priority = ""; 666 } 667 return this.each(d3_selection_style(name, value, priority)); 668 }; 669 function d3_selection_style(name, value, priority) { 670 function styleNull() { 671 this.style.removeProperty(name); 672 } 673 function styleConstant() { 674 this.style.setProperty(name, value, priority); 675 } 676 function styleFunction() { 677 var x = value.apply(this, arguments); 678 if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); 679 } 680 return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; 681 } 682 d3_selectionPrototype.property = function(name, value) { 683 if (arguments.length < 2) { 684 if (typeof name === "string") return this.node()[name]; 685 for (value in name) this.each(d3_selection_property(value, name[value])); 686 return this; 687 } 688 return this.each(d3_selection_property(name, value)); 689 }; 690 function d3_selection_property(name, value) { 691 function propertyNull() { 692 delete this[name]; 693 } 694 function propertyConstant() { 695 this[name] = value; 696 } 697 function propertyFunction() { 698 var x = value.apply(this, arguments); 699 if (x == null) delete this[name]; else this[name] = x; 700 } 701 return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; 702 } 703 d3_selectionPrototype.text = function(value) { 704 return arguments.length ? this.each(typeof value === "function" ? function() {
vendor: 8,021 bytes, lines 705-934
705 var v = value.apply(this, arguments); 706 this.textContent = v == null ? "" : v; 707 } : value == null ? function() { 708 this.textContent = ""; 709 } : function() { 710 this.textContent = value; 711 }) : this.node().textContent; 712 }; 713 d3_selectionPrototype.html = function(value) { 714 return arguments.length ? this.each(typeof value === "function" ? function() { 715 var v = value.apply(this, arguments); 716 this.innerHTML = v == null ? "" : v; 717 } : value == null ? function() { 718 this.innerHTML = ""; 719 } : function() { 720 this.innerHTML = value; 721 }) : this.node().innerHTML; 722 }; 723 d3_selectionPrototype.append = function(name) { 724 name = d3_selection_creator(name); 725 return this.select(function() { 726 return this.appendChild(name.apply(this, arguments)); 727 }); 728 }; 729 function d3_selection_creator(name) { 730 return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? function() { 731 return this.ownerDocument.createElementNS(name.space, name.local); 732 } : function() { 733 return this.ownerDocument.createElementNS(this.namespaceURI, name); 734 }; 735 } 736 d3_selectionPrototype.insert = function(name, before) { 737 name = d3_selection_creator(name); 738 before = d3_selection_selector(before); 739 return this.select(function() { 740 return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); 741 }); 742 }; 743 d3_selectionPrototype.remove = function() { 744 return this.each(function() { 745 var parent = this.parentNode; 746 if (parent) parent.removeChild(this); 747 }); 748 }; 749 d3_selectionPrototype.data = function(value, key) { 750 var i = -1, n = this.length, group, node; 751 if (!arguments.length) { 752 value = new Array(n = (group = this[0]).length); 753 while (++i < n) { 754 if (node = group[i]) { 755 value[i] = node.__data__; 756 } 757 } 758 return value; 759 } 760 function bind(group, groupData) { 761 var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; 762 if (key) { 763 var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; 764 for (i = -1; ++i < n; ) { 765 keyValue = key.call(node = group[i], node.__data__, i); 766 if (nodeByKeyValue.has(keyValue)) { 767 exitNodes[i] = node; 768 } else { 769 nodeByKeyValue.set(keyValue, node); 770 } 771 keyValues.push(keyValue); 772 } 773 for (i = -1; ++i < m; ) { 774 keyValue = key.call(groupData, nodeData = groupData[i], i); 775 if (node = nodeByKeyValue.get(keyValue)) { 776 updateNodes[i] = node; 777 node.__data__ = nodeData; 778 } else if (!dataByKeyValue.has(keyValue)) { 779 enterNodes[i] = d3_selection_dataNode(nodeData); 780 } 781 dataByKeyValue.set(keyValue, nodeData); 782 nodeByKeyValue.remove(keyValue); 783 } 784 for (i = -1; ++i < n; ) { 785 if (nodeByKeyValue.has(keyValues[i])) { 786 exitNodes[i] = group[i]; 787 } 788 } 789 } else { 790 for (i = -1; ++i < n0; ) { 791 node = group[i]; 792 nodeData = groupData[i]; 793 if (node) { 794 node.__data__ = nodeData; 795 updateNodes[i] = node; 796 } else { 797 enterNodes[i] = d3_selection_dataNode(nodeData); 798 } 799 } 800 for (;i < m; ++i) { 801 enterNodes[i] = d3_selection_dataNode(groupData[i]); 802 } 803 for (;i < n; ++i) { 804 exitNodes[i] = group[i]; 805 } 806 } 807 enterNodes.update = updateNodes; 808 enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; 809 enter.push(enterNodes); 810 update.push(updateNodes); 811 exit.push(exitNodes); 812 } 813 var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); 814 if (typeof value === "function") { 815 while (++i < n) { 816 bind(group = this[i], value.call(group, group.parentNode.__data__, i)); 817 } 818 } else { 819 while (++i < n) { 820 bind(group = this[i], value); 821 } 822 } 823 update.enter = function() { 824 return enter; 825 }; 826 update.exit = function() { 827 return exit; 828 }; 829 return update; 830 }; 831 function d3_selection_dataNode(data) { 832 return { 833 __data__: data 834 }; 835 } 836 d3_selectionPrototype.datum = function(value) { 837 return arguments.length ? this.property("__data__", value) : this.property("__data__"); 838 }; 839 d3_selectionPrototype.filter = function(filter) { 840 var subgroups = [], subgroup, group, node; 841 if (typeof filter !== "function") filter = d3_selection_filter(filter); 842 for (var j = 0, m = this.length; j < m; j++) { 843 subgroups.push(subgroup = []); 844 subgroup.parentNode = (group = this[j]).parentNode; 845 for (var i = 0, n = group.length; i < n; i++) { 846 if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { 847 subgroup.push(node); 848 } 849 } 850 } 851 return d3_selection(subgroups); 852 }; 853 function d3_selection_filter(selector) { 854 return function() { 855 return d3_selectMatches(this, selector); 856 }; 857 } 858 d3_selectionPrototype.order = function() { 859 for (var j = -1, m = this.length; ++j < m; ) { 860 for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { 861 if (node = group[i]) { 862 if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); 863 next = node; 864 } 865 } 866 } 867 return this; 868 }; 869 d3_selectionPrototype.sort = function(comparator) { 870 comparator = d3_selection_sortComparator.apply(this, arguments); 871 for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); 872 return this.order(); 873 }; 874 function d3_selection_sortComparator(comparator) { 875 if (!arguments.length) comparator = d3.ascending; 876 return function(a, b) { 877 return a && b ? comparator(a.__data__, b.__data__) : !a - !b; 878 }; 879 } 880 d3_selectionPrototype.each = function(callback) { 881 return d3_selection_each(this, function(node, i, j) { 882 callback.call(node, node.__data__, i, j); 883 }); 884 }; 885 function d3_selection_each(groups, callback) { 886 for (var j = 0, m = groups.length; j < m; j++) { 887 for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { 888 if (node = group[i]) callback(node, i, j); 889 } 890 } 891 return groups; 892 } 893 d3_selectionPrototype.call = function(callback) { 894 var args = d3_array(arguments); 895 callback.apply(args[0] = this, args); 896 return this; 897 }; 898 d3_selectionPrototype.empty = function() { 899 return !this.node(); 900 }; 901 d3_selectionPrototype.node = function() { 902 for (var j = 0, m = this.length; j < m; j++) { 903 for (var group = this[j], i = 0, n = group.length; i < n; i++) { 904 var node = group[i]; 905 if (node) return node; 906 } 907 } 908 return null; 909 }; 910 d3_selectionPrototype.size = function() { 911 var n = 0; 912 this.each(function() { 913 ++n; 914 }); 915 return n; 916 }; 917 function d3_selection_enter(selection) { 918 d3_subclass(selection, d3_selection_enterPrototype); 919 return selection; 920 } 921 var d3_selection_enterPrototype = []; 922 d3.selection.enter = d3_selection_enter; 923 d3.selection.enter.prototype = d3_selection_enterPrototype; 924 d3_selection_enterPrototype.append = d3_selectionPrototype.append; 925 d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; 926 d3_selection_enterPrototype.node = d3_selectionPrototype.node; 927 d3_selection_enterPrototype.call = d3_selectionPrototype.call; 928 d3_selection_enterPrototype.size = d3_selectionPrototype.size; 929 d3_selection_enterPrototype.select = function(selector) { 930 var subgroups = [], subgroup, subnode, upgroup, group, node; 931 for (var j = -1, m = this.length; ++j < m; ) { 932 upgroup = (group = this[j]).update; 933 subgroups.push(subgroup = []); 934 subgroup.parentNode = group.parentNode;
vendor: 2,320 bytes, lines 935-998
935 for (var i = -1, n = group.length; ++i < n; ) { 936 if (node = group[i]) { 937 subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j)); 938 subnode.__data__ = node.__data__; 939 } else { 940 subgroup.push(null); 941 } 942 } 943 } 944 return d3_selection(subgroups); 945 }; 946 d3_selection_enterPrototype.insert = function(name, before) { 947 if (arguments.length < 2) before = d3_selection_enterInsertBefore(this); 948 return d3_selectionPrototype.insert.call(this, name, before); 949 }; 950 function d3_selection_enterInsertBefore(enter) { 951 var i0, j0; 952 return function(d, i, j) { 953 var group = enter[j].update, n = group.length, node; 954 if (j != j0) j0 = j, i0 = 0; 955 if (i >= i0) i0 = i + 1; 956 while (!(node = group[i0]) && ++i0 < n) ; 957 return node; 958 }; 959 } 960 d3_selectionPrototype.transition = function() { 961 var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || { 962 time: Date.now(), 963 ease: d3_ease_cubicInOut, 964 delay: 0, 965 duration: 250 966 }; 967 for (var j = -1, m = this.length; ++j < m; ) { 968 subgroups.push(subgroup = []); 969 for (var group = this[j], i = -1, n = group.length; ++i < n; ) { 970 if (node = group[i]) d3_transitionNode(node, i, id, transition); 971 subgroup.push(node); 972 } 973 } 974 return d3_transition(subgroups, id); 975 }; 976 d3_selectionPrototype.interrupt = function() { 977 return this.each(d3_selection_interrupt); 978 }; 979 function d3_selection_interrupt() { 980 var lock = this.__transition__; 981 if (lock) ++lock.active; 982 } 983 d3.select = function(node) { 984 var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ]; 985 group.parentNode = d3_documentElement; 986 return d3_selection([ group ]); 987 }; 988 d3.selectAll = function(nodes) { 989 var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes); 990 group.parentNode = d3_documentElement; 991 return d3_selection([ group ]); 992 }; 993 var d3_selectionRoot = d3.select(d3_documentElement); 994 d3_selectionPrototype.on = function(type, listener, capture) { 995 var n = arguments.length; 996 if (n < 3) { 997 if (typeof type !== "string") { 998 if (n < 2) listener = false;
vendor: 2,330 bytes, lines 999-1066
999 for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); 1000 return this; 1001 } 1002 if (n < 2) return (n = this.node()["__on" + type]) && n._; 1003 capture = false; 1004 } 1005 return this.each(d3_selection_on(type, listener, capture)); 1006 }; 1007 function d3_selection_on(type, listener, capture) { 1008 var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; 1009 if (i > 0) type = type.substring(0, i); 1010 var filter = d3_selection_onFilters.get(type); 1011 if (filter) type = filter, wrap = d3_selection_onFilter; 1012 function onRemove() { 1013 var l = this[name]; 1014 if (l) { 1015 this.removeEventListener(type, l, l.$); 1016 delete this[name]; 1017 } 1018 } 1019 function onAdd() { 1020 var l = wrap(listener, d3_array(arguments)); 1021 onRemove.call(this); 1022 this.addEventListener(type, this[name] = l, l.$ = capture); 1023 l._ = listener; 1024 } 1025 function removeAll() { 1026 var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; 1027 for (var name in this) { 1028 if (match = name.match(re)) { 1029 var l = this[name]; 1030 this.removeEventListener(match[1], l, l.$); 1031 delete this[name]; 1032 } 1033 } 1034 } 1035 return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; 1036 } 1037 var d3_selection_onFilters = d3.map({ 1038 mouseenter: "mouseover", 1039 mouseleave: "mouseout" 1040 }); 1041 d3_selection_onFilters.forEach(function(k) { 1042 if ("on" + k in d3_document) d3_selection_onFilters.remove(k); 1043 }); 1044 function d3_selection_onListener(listener, argumentz) { 1045 return function(e) { 1046 var o = d3.event; 1047 d3.event = e; 1048 argumentz[0] = this.__data__; 1049 try { 1050 listener.apply(this, argumentz); 1051 } finally { 1052 d3.event = o; 1053 } 1054 }; 1055 } 1056 function d3_selection_onFilter(listener, argumentz) { 1057 var l = d3_selection_onListener(listener, argumentz); 1058 return function(e) { 1059 var target = this, related = e.relatedTarget; 1060 if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { 1061 l.call(target, e); 1062 } 1063 }; 1064 } 1065 var d3_event_dragSelect = "onselectstart" in d3_document ? null : d3_vendorSymbol(d3_documentElement.style, "userSelect"), d3_event_dragId = 0; 1066 function d3_event_dragSuppress() {
vendor: 11,360 bytes, lines 1067-1379
1067 var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault); 1068 if (d3_event_dragSelect) { 1069 var style = d3_documentElement.style, select = style[d3_event_dragSelect]; 1070 style[d3_event_dragSelect] = "none"; 1071 } 1072 return function(suppressClick) { 1073 w.on(name, null); 1074 if (d3_event_dragSelect) style[d3_event_dragSelect] = select; 1075 if (suppressClick) { 1076 function off() { 1077 w.on(click, null); 1078 } 1079 w.on(click, function() { 1080 d3_eventPreventDefault(); 1081 off(); 1082 }, true); 1083 setTimeout(off, 0); 1084 } 1085 }; 1086 } 1087 d3.mouse = function(container) { 1088 return d3_mousePoint(container, d3_eventSource()); 1089 }; 1090 var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0; 1091 function d3_mousePoint(container, e) { 1092 if (e.changedTouches) e = e.changedTouches[0]; 1093 var svg = container.ownerSVGElement || container; 1094 if (svg.createSVGPoint) { 1095 var point = svg.createSVGPoint(); 1096 if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) { 1097 svg = d3.select("body").append("svg").style({ 1098 position: "absolute", 1099 top: 0, 1100 left: 0, 1101 margin: 0, 1102 padding: 0, 1103 border: "none" 1104 }, "important"); 1105 var ctm = svg[0][0].getScreenCTM(); 1106 d3_mouse_bug44083 = !(ctm.f || ctm.e); 1107 svg.remove(); 1108 } 1109 if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, 1110 point.y = e.clientY; 1111 point = point.matrixTransform(container.getScreenCTM().inverse()); 1112 return [ point.x, point.y ]; 1113 } 1114 var rect = container.getBoundingClientRect(); 1115 return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; 1116 } 1117 d3.touches = function(container, touches) { 1118 if (arguments.length < 2) touches = d3_eventSource().touches; 1119 return touches ? d3_array(touches).map(function(touch) { 1120 var point = d3_mousePoint(container, touch); 1121 point.identifier = touch.identifier; 1122 return point; 1123 }) : []; 1124 }; 1125 d3.behavior.drag = function() { 1126 var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, "mousemove", "mouseup"), touchstart = dragstart(touchid, touchposition, "touchmove", "touchend"); 1127 function drag() { 1128 this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); 1129 } 1130 function touchid() { 1131 return d3.event.changedTouches[0].identifier; 1132 } 1133 function touchposition(parent, id) { 1134 return d3.touches(parent).filter(function(p) { 1135 return p.identifier === id; 1136 })[0]; 1137 } 1138 function dragstart(id, position, move, end) { 1139 return function() { 1140 var target = this, parent = target.parentNode, event_ = event.of(target, arguments), eventTarget = d3.event.target, eventId = id(), drag = eventId == null ? "drag" : "drag-" + eventId, origin_ = position(parent, eventId), dragged = 0, offset, w = d3.select(d3_window).on(move + "." + drag, moved).on(end + "." + drag, ended), dragRestore = d3_event_dragSuppress(); 1141 if (origin) { 1142 offset = origin.apply(target, arguments); 1143 offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; 1144 } else { 1145 offset = [ 0, 0 ]; 1146 } 1147 event_({ 1148 type: "dragstart" 1149 }); 1150 function moved() { 1151 var p = position(parent, eventId), dx = p[0] - origin_[0], dy = p[1] - origin_[1]; 1152 dragged |= dx | dy; 1153 origin_ = p; 1154 event_({ 1155 type: "drag", 1156 x: p[0] + offset[0], 1157 y: p[1] + offset[1], 1158 dx: dx, 1159 dy: dy 1160 }); 1161 } 1162 function ended() { 1163 w.on(move + "." + drag, null).on(end + "." + drag, null); 1164 dragRestore(dragged && d3.event.target === eventTarget); 1165 event_({ 1166 type: "dragend" 1167 }); 1168 } 1169 }; 1170 } 1171 drag.origin = function(x) { 1172 if (!arguments.length) return origin; 1173 origin = x; 1174 return drag; 1175 }; 1176 return d3.rebind(drag, event, "on"); 1177 }; 1178 var Ï = Math.PI, Ï = 2 * Ï, halfÏ = Ï / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = Ï / 180, d3_degrees = 180 / Ï; 1179 function d3_sgn(x) { 1180 return x > 0 ? 1 : x < 0 ? -1 : 0; 1181 } 1182 function d3_cross2d(a, b, c) { 1183 return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); 1184 } 1185 function d3_acos(x) { 1186 return x > 1 ? 0 : x < -1 ? Ï : Math.acos(x); 1187 } 1188 function d3_asin(x) { 1189 return x > 1 ? halfÏ : x < -1 ? -halfÏ : Math.asin(x); 1190 } 1191 function d3_sinh(x) { 1192 return ((x = Math.exp(x)) - 1 / x) / 2; 1193 } 1194 function d3_cosh(x) { 1195 return ((x = Math.exp(x)) + 1 / x) / 2; 1196 } 1197 function d3_tanh(x) { 1198 return ((x = Math.exp(2 * x)) - 1) / (x + 1); 1199 } 1200 function d3_haversin(x) { 1201 return (x = Math.sin(x / 2)) * x; 1202 } 1203 var Ï = Math.SQRT2, Ï2 = 2, Ï4 = 4; 1204 d3.interpolateZoom = function(p0, p1) { 1205 var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2]; 1206 var dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + Ï4 * d2) / (2 * w0 * Ï2 * d1), b1 = (w1 * w1 - w0 * w0 - Ï4 * d2) / (2 * w1 * Ï2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1), dr = r1 - r0, S = (dr || Math.log(w1 / w0)) / Ï; 1207 function interpolate(t) { 1208 var s = t * S; 1209 if (dr) { 1210 var coshr0 = d3_cosh(r0), u = w0 / (Ï2 * d1) * (coshr0 * d3_tanh(Ï * s + r0) - d3_sinh(r0)); 1211 return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(Ï * s + r0) ]; 1212 } 1213 return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(Ï * s) ]; 1214 } 1215 interpolate.duration = S * 1e3; 1216 return interpolate; 1217 }; 1218 d3.behavior.zoom = function() { 1219 var view = { 1220 x: 0, 1221 y: 0, 1222 k: 1 1223 }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; 1224 function zoom(g) { 1225 g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); 1226 } 1227 zoom.event = function(g) { 1228 g.each(function() { 1229 var event_ = event.of(this, arguments), view1 = view; 1230 if (d3_transitionInheritId) { 1231 d3.select(this).transition().each("start.zoom", function() { 1232 view = this.__chart__ || { 1233 x: 0, 1234 y: 0, 1235 k: 1 1236 }; 1237 zoomstarted(event_); 1238 }).tween("zoom:zoom", function() { 1239 var dx = size[0], dy = size[1], cx = dx / 2, cy = dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); 1240 return function(t) { 1241 var l = i(t), k = dx / l[2]; 1242 this.__chart__ = view = { 1243 x: cx - l[0] * k, 1244 y: cy - l[1] * k, 1245 k: k 1246 }; 1247 zoomed(event_); 1248 }; 1249 }).each("end.zoom", function() { 1250 zoomended(event_); 1251 }); 1252 } else { 1253 this.__chart__ = view; 1254 zoomstarted(event_); 1255 zoomed(event_); 1256 zoomended(event_); 1257 } 1258 }); 1259 }; 1260 zoom.translate = function(_) { 1261 if (!arguments.length) return [ view.x, view.y ]; 1262 view = { 1263 x: +_[0], 1264 y: +_[1], 1265 k: view.k 1266 }; 1267 rescale(); 1268 return zoom; 1269 }; 1270 zoom.scale = function(_) { 1271 if (!arguments.length) return view.k; 1272 view = { 1273 x: view.x, 1274 y: view.y, 1275 k: +_ 1276 }; 1277 rescale(); 1278 return zoom; 1279 }; 1280 zoom.scaleExtent = function(_) { 1281 if (!arguments.length) return scaleExtent; 1282 scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ]; 1283 return zoom; 1284 }; 1285 zoom.center = function(_) { 1286 if (!arguments.length) return center; 1287 center = _ && [ +_[0], +_[1] ]; 1288 return zoom; 1289 }; 1290 zoom.size = function(_) { 1291 if (!arguments.length) return size; 1292 size = _ && [ +_[0], +_[1] ]; 1293 return zoom; 1294 }; 1295 zoom.x = function(z) { 1296 if (!arguments.length) return x1; 1297 x1 = z; 1298 x0 = z.copy(); 1299 view = { 1300 x: 0, 1301 y: 0, 1302 k: 1 1303 }; 1304 return zoom; 1305 }; 1306 zoom.y = function(z) { 1307 if (!arguments.length) return y1; 1308 y1 = z; 1309 y0 = z.copy(); 1310 view = { 1311 x: 0, 1312 y: 0, 1313 k: 1 1314 }; 1315 return zoom; 1316 }; 1317 function location(p) { 1318 return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ]; 1319 } 1320 function point(l) { 1321 return [ l[0] * view.k + view.x, l[1] * view.k + view.y ]; 1322 } 1323 function scaleTo(s) { 1324 view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); 1325 } 1326 function translateTo(p, l) { 1327 l = point(l); 1328 view.x += p[0] - l[0]; 1329 view.y += p[1] - l[1]; 1330 } 1331 function rescale() { 1332 if (x1) x1.domain(x0.range().map(function(x) { 1333 return (x - view.x) / view.k; 1334 }).map(x0.invert)); 1335 if (y1) y1.domain(y0.range().map(function(y) { 1336 return (y - view.y) / view.k; 1337 }).map(y0.invert)); 1338 } 1339 function zoomstarted(event) { 1340 event({ 1341 type: "zoomstart" 1342 }); 1343 } 1344 function zoomed(event) { 1345 rescale(); 1346 event({ 1347 type: "zoom", 1348 scale: view.k, 1349 translate: [ view.x, view.y ] 1350 }); 1351 } 1352 function zoomended(event) { 1353 event({ 1354 type: "zoomend" 1355 }); 1356 } 1357 function mousedowned() { 1358 var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, dragged = 0, w = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), l = location(d3.mouse(target)), dragRestore = d3_event_dragSuppress(); 1359 d3_selection_interrupt.call(target); 1360 zoomstarted(event_); 1361 function moved() { 1362 dragged = 1; 1363 translateTo(d3.mouse(target), l); 1364 zoomed(event_); 1365 } 1366 function ended() { 1367 w.on(mousemove, d3_window === target ? mousewheelreset : null).on(mouseup, null); 1368 dragRestore(dragged && d3.event.target === eventTarget); 1369 zoomended(event_); 1370 } 1371 } 1372 function touchstarted() { 1373 var target = this, event_ = event.of(target, arguments), locations0 = {}, distance0 = 0, scale0, eventId = d3.event.changedTouches[0].identifier, touchmove = "touchmove.zoom-" + eventId, touchend = "touchend.zoom-" + eventId, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress(); 1374 d3_selection_interrupt.call(target); 1375 started(); 1376 zoomstarted(event_); 1377 function relocate() { 1378 var touches = d3.touches(target); 1379 scale0 = view.k;
vendor: 11,264 bytes, lines 1380-1686
1380 touches.forEach(function(t) { 1381 if (t.identifier in locations0) locations0[t.identifier] = location(t); 1382 }); 1383 return touches; 1384 } 1385 function started() { 1386 var changed = d3.event.changedTouches; 1387 for (var i = 0, n = changed.length; i < n; ++i) { 1388 locations0[changed[i].identifier] = null; 1389 } 1390 var touches = relocate(), now = Date.now(); 1391 if (touches.length === 1) { 1392 if (now - touchtime < 500) { 1393 var p = touches[0], l = locations0[p.identifier]; 1394 scaleTo(view.k * 2); 1395 translateTo(p, l); 1396 d3_eventPreventDefault(); 1397 zoomed(event_); 1398 } 1399 touchtime = now; 1400 } else if (touches.length > 1) { 1401 var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; 1402 distance0 = dx * dx + dy * dy; 1403 } 1404 } 1405 function moved() { 1406 var touches = d3.touches(target), p0, l0, p1, l1; 1407 for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { 1408 p1 = touches[i]; 1409 if (l1 = locations0[p1.identifier]) { 1410 if (l0) break; 1411 p0 = p1, l0 = l1; 1412 } 1413 } 1414 if (l1) { 1415 var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0); 1416 p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; 1417 l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; 1418 scaleTo(scale1 * scale0); 1419 } 1420 touchtime = null; 1421 translateTo(p0, l0); 1422 zoomed(event_); 1423 } 1424 function ended() { 1425 if (d3.event.touches.length) { 1426 var changed = d3.event.changedTouches; 1427 for (var i = 0, n = changed.length; i < n; ++i) { 1428 delete locations0[changed[i].identifier]; 1429 } 1430 for (var identifier in locations0) { 1431 return void relocate(); 1432 } 1433 } 1434 w.on(touchmove, null).on(touchend, null); 1435 t.on(mousedown, mousedowned).on(touchstart, touchstarted); 1436 dragRestore(); 1437 zoomended(event_); 1438 } 1439 } 1440 function mousewheeled() { 1441 var event_ = event.of(this, arguments); 1442 if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), 1443 zoomstarted(event_); 1444 mousewheelTimer = setTimeout(function() { 1445 mousewheelTimer = null; 1446 zoomended(event_); 1447 }, 50); 1448 d3_eventPreventDefault(); 1449 var point = center || d3.mouse(this); 1450 if (!translate0) translate0 = location(point); 1451 scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); 1452 translateTo(point, translate0); 1453 zoomed(event_); 1454 } 1455 function mousewheelreset() { 1456 translate0 = null; 1457 } 1458 function dblclicked() { 1459 var event_ = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2; 1460 zoomstarted(event_); 1461 scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1)); 1462 translateTo(p, l); 1463 zoomed(event_); 1464 zoomended(event_); 1465 } 1466 return d3.rebind(zoom, event, "on"); 1467 }; 1468 var d3_behavior_zoomInfinity = [ 0, Infinity ]; 1469 var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { 1470 return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); 1471 }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { 1472 return d3.event.wheelDelta; 1473 }, "mousewheel") : (d3_behavior_zoomDelta = function() { 1474 return -d3.event.detail; 1475 }, "MozMousePixelScroll"); 1476 function d3_Color() {} 1477 d3_Color.prototype.toString = function() { 1478 return this.rgb() + ""; 1479 }; 1480 d3.hsl = function(h, s, l) { 1481 return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l); 1482 }; 1483 function d3_hsl(h, s, l) { 1484 return new d3_Hsl(h, s, l); 1485 } 1486 function d3_Hsl(h, s, l) { 1487 this.h = h; 1488 this.s = s; 1489 this.l = l; 1490 } 1491 var d3_hslPrototype = d3_Hsl.prototype = new d3_Color(); 1492 d3_hslPrototype.brighter = function(k) { 1493 k = Math.pow(.7, arguments.length ? k : 1); 1494 return d3_hsl(this.h, this.s, this.l / k); 1495 }; 1496 d3_hslPrototype.darker = function(k) { 1497 k = Math.pow(.7, arguments.length ? k : 1); 1498 return d3_hsl(this.h, this.s, k * this.l); 1499 }; 1500 d3_hslPrototype.rgb = function() { 1501 return d3_hsl_rgb(this.h, this.s, this.l); 1502 }; 1503 function d3_hsl_rgb(h, s, l) { 1504 var m1, m2; 1505 h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; 1506 s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; 1507 l = l < 0 ? 0 : l > 1 ? 1 : l; 1508 m2 = l <= .5 ? l * (1 + s) : l + s - l * s; 1509 m1 = 2 * l - m2; 1510 function v(h) { 1511 if (h > 360) h -= 360; else if (h < 0) h += 360; 1512 if (h < 60) return m1 + (m2 - m1) * h / 60; 1513 if (h < 180) return m2; 1514 if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; 1515 return m1; 1516 } 1517 function vv(h) { 1518 return Math.round(v(h) * 255); 1519 } 1520 return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); 1521 } 1522 d3.hcl = function(h, c, l) { 1523 return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); 1524 }; 1525 function d3_hcl(h, c, l) { 1526 return new d3_Hcl(h, c, l); 1527 } 1528 function d3_Hcl(h, c, l) { 1529 this.h = h; 1530 this.c = c; 1531 this.l = l; 1532 } 1533 var d3_hclPrototype = d3_Hcl.prototype = new d3_Color(); 1534 d3_hclPrototype.brighter = function(k) { 1535 return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); 1536 }; 1537 d3_hclPrototype.darker = function(k) { 1538 return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); 1539 }; 1540 d3_hclPrototype.rgb = function() { 1541 return d3_hcl_lab(this.h, this.c, this.l).rgb(); 1542 }; 1543 function d3_hcl_lab(h, c, l) { 1544 if (isNaN(h)) h = 0; 1545 if (isNaN(c)) c = 0; 1546 return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); 1547 } 1548 d3.lab = function(l, a, b) { 1549 return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); 1550 }; 1551 function d3_lab(l, a, b) { 1552 return new d3_Lab(l, a, b); 1553 } 1554 function d3_Lab(l, a, b) { 1555 this.l = l; 1556 this.a = a; 1557 this.b = b; 1558 } 1559 var d3_lab_K = 18; 1560 var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; 1561 var d3_labPrototype = d3_Lab.prototype = new d3_Color(); 1562 d3_labPrototype.brighter = function(k) { 1563 return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); 1564 }; 1565 d3_labPrototype.darker = function(k) { 1566 return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); 1567 }; 1568 d3_labPrototype.rgb = function() { 1569 return d3_lab_rgb(this.l, this.a, this.b); 1570 }; 1571 function d3_lab_rgb(l, a, b) { 1572 var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; 1573 x = d3_lab_xyz(x) * d3_lab_X; 1574 y = d3_lab_xyz(y) * d3_lab_Y; 1575 z = d3_lab_xyz(z) * d3_lab_Z; 1576 return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); 1577 } 1578 function d3_lab_hcl(l, a, b) { 1579 return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l); 1580 } 1581 function d3_lab_xyz(x) { 1582 return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; 1583 } 1584 function d3_xyz_lab(x) { 1585 return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; 1586 } 1587 function d3_xyz_rgb(r) { 1588 return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); 1589 } 1590 d3.rgb = function(r, g, b) { 1591 return arguments.length === 1 ? r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : d3_rgb(~~r, ~~g, ~~b); 1592 }; 1593 function d3_rgbNumber(value) { 1594 return d3_rgb(value >> 16, value >> 8 & 255, value & 255); 1595 } 1596 function d3_rgbString(value) { 1597 return d3_rgbNumber(value) + ""; 1598 } 1599 function d3_rgb(r, g, b) { 1600 return new d3_Rgb(r, g, b); 1601 } 1602 function d3_Rgb(r, g, b) { 1603 this.r = r; 1604 this.g = g; 1605 this.b = b; 1606 } 1607 var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color(); 1608 d3_rgbPrototype.brighter = function(k) { 1609 k = Math.pow(.7, arguments.length ? k : 1); 1610 var r = this.r, g = this.g, b = this.b, i = 30; 1611 if (!r && !g && !b) return d3_rgb(i, i, i); 1612 if (r && r < i) r = i; 1613 if (g && g < i) g = i; 1614 if (b && b < i) b = i; 1615 return d3_rgb(Math.min(255, ~~(r / k)), Math.min(255, ~~(g / k)), Math.min(255, ~~(b / k))); 1616 }; 1617 d3_rgbPrototype.darker = function(k) { 1618 k = Math.pow(.7, arguments.length ? k : 1); 1619 return d3_rgb(~~(k * this.r), ~~(k * this.g), ~~(k * this.b)); 1620 }; 1621 d3_rgbPrototype.hsl = function() { 1622 return d3_rgb_hsl(this.r, this.g, this.b); 1623 }; 1624 d3_rgbPrototype.toString = function() { 1625 return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); 1626 }; 1627 function d3_rgb_hex(v) { 1628 return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); 1629 } 1630 function d3_rgb_parse(format, rgb, hsl) { 1631 var r = 0, g = 0, b = 0, m1, m2, name; 1632 m1 = /([a-z]+)\((.*)\)/i.exec(format); 1633 if (m1) { 1634 m2 = m1[2].split(","); 1635 switch (m1[1]) { 1636 case "hsl": 1637 { 1638 return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); 1639 } 1640 1641 case "rgb": 1642 { 1643 return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); 1644 } 1645 } 1646 } 1647 if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); 1648 if (format != null && format.charAt(0) === "#") { 1649 if (format.length === 4) { 1650 r = format.charAt(1); 1651 r += r; 1652 g = format.charAt(2); 1653 g += g; 1654 b = format.charAt(3); 1655 b += b; 1656 } else if (format.length === 7) { 1657 r = format.substring(1, 3); 1658 g = format.substring(3, 5); 1659 b = format.substring(5, 7); 1660 } 1661 r = parseInt(r, 16); 1662 g = parseInt(g, 16); 1663 b = parseInt(b, 16); 1664 } 1665 return rgb(r, g, b); 1666 } 1667 function d3_rgb_hsl(r, g, b) { 1668 var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; 1669 if (d) { 1670 s = l < .5 ? d / (max + min) : d / (2 - max - min); 1671 if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; 1672 h *= 60; 1673 } else { 1674 h = NaN; 1675 s = l > 0 && l < 1 ? 0 : h; 1676 } 1677 return d3_hsl(h, s, l); 1678 } 1679 function d3_rgb_lab(r, g, b) { 1680 r = d3_rgb_xyz(r); 1681 g = d3_rgb_xyz(g); 1682 b = d3_rgb_xyz(b); 1683 var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); 1684 return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); 1685 } 1686 function d3_rgb_xyz(r) {
vendor: 5,412 bytes, lines 1687-1884
1687 return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); 1688 } 1689 function d3_rgb_parseNumber(c) { 1690 var f = parseFloat(c); 1691 return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; 1692 } 1693 var d3_rgb_names = d3.map({ 1694 aliceblue: 15792383, 1695 antiquewhite: 16444375, 1696 aqua: 65535, 1697 aquamarine: 8388564, 1698 azure: 15794175, 1699 beige: 16119260, 1700 bisque: 16770244, 1701 black: 0, 1702 blanchedalmond: 16772045, 1703 blue: 255, 1704 blueviolet: 9055202, 1705 brown: 10824234, 1706 burlywood: 14596231, 1707 cadetblue: 6266528, 1708 chartreuse: 8388352, 1709 chocolate: 13789470, 1710 coral: 16744272, 1711 cornflowerblue: 6591981, 1712 cornsilk: 16775388, 1713 crimson: 14423100, 1714 cyan: 65535, 1715 darkblue: 139, 1716 darkcyan: 35723, 1717 darkgoldenrod: 12092939, 1718 darkgray: 11119017, 1719 darkgreen: 25600, 1720 darkgrey: 11119017, 1721 darkkhaki: 12433259, 1722 darkmagenta: 9109643, 1723 darkolivegreen: 5597999, 1724 darkorange: 16747520, 1725 darkorchid: 10040012, 1726 darkred: 9109504, 1727 darksalmon: 15308410, 1728 darkseagreen: 9419919, 1729 darkslateblue: 4734347, 1730 darkslategray: 3100495, 1731 darkslategrey: 3100495, 1732 darkturquoise: 52945, 1733 darkviolet: 9699539, 1734 deeppink: 16716947, 1735 deepskyblue: 49151, 1736 dimgray: 6908265, 1737 dimgrey: 6908265, 1738 dodgerblue: 2003199, 1739 firebrick: 11674146, 1740 floralwhite: 16775920, 1741 forestgreen: 2263842, 1742 fuchsia: 16711935, 1743 gainsboro: 14474460, 1744 ghostwhite: 16316671, 1745 gold: 16766720, 1746 goldenrod: 14329120, 1747 gray: 8421504, 1748 green: 32768, 1749 greenyellow: 11403055, 1750 grey: 8421504, 1751 honeydew: 15794160, 1752 hotpink: 16738740, 1753 indianred: 13458524, 1754 indigo: 4915330, 1755 ivory: 16777200, 1756 khaki: 15787660, 1757 lavender: 15132410, 1758 lavenderblush: 16773365, 1759 lawngreen: 8190976, 1760 lemonchiffon: 16775885, 1761 lightblue: 11393254, 1762 lightcoral: 15761536, 1763 lightcyan: 14745599, 1764 lightgoldenrodyellow: 16448210, 1765 lightgray: 13882323, 1766 lightgreen: 9498256, 1767 lightgrey: 13882323, 1768 lightpink: 16758465, 1769 lightsalmon: 16752762, 1770 lightseagreen: 2142890, 1771 lightskyblue: 8900346, 1772 lightslategray: 7833753, 1773 lightslategrey: 7833753, 1774 lightsteelblue: 11584734, 1775 lightyellow: 16777184, 1776 lime: 65280, 1777 limegreen: 3329330, 1778 linen: 16445670, 1779 magenta: 16711935, 1780 maroon: 8388608, 1781 mediumaquamarine: 6737322, 1782 mediumblue: 205, 1783 mediumorchid: 12211667, 1784 mediumpurple: 9662683, 1785 mediumseagreen: 3978097, 1786 mediumslateblue: 8087790, 1787 mediumspringgreen: 64154, 1788 mediumturquoise: 4772300, 1789 mediumvioletred: 13047173, 1790 midnightblue: 1644912, 1791 mintcream: 16121850, 1792 mistyrose: 16770273, 1793 moccasin: 16770229, 1794 navajowhite: 16768685, 1795 navy: 128, 1796 oldlace: 16643558, 1797 olive: 8421376, 1798 olivedrab: 7048739, 1799 orange: 16753920, 1800 orangered: 16729344, 1801 orchid: 14315734, 1802 palegoldenrod: 15657130, 1803 palegreen: 10025880, 1804 paleturquoise: 11529966, 1805 palevioletred: 14381203, 1806 papayawhip: 16773077, 1807 peachpuff: 16767673, 1808 peru: 13468991, 1809 pink: 16761035, 1810 plum: 14524637, 1811 powderblue: 11591910, 1812 purple: 8388736, 1813 red: 16711680, 1814 rosybrown: 12357519, 1815 royalblue: 4286945, 1816 saddlebrown: 9127187, 1817 salmon: 16416882, 1818 sandybrown: 16032864, 1819 seagreen: 3050327, 1820 seashell: 16774638, 1821 sienna: 10506797, 1822 silver: 12632256, 1823 skyblue: 8900331, 1824 slateblue: 6970061, 1825 slategray: 7372944, 1826 slategrey: 7372944, 1827 snow: 16775930, 1828 springgreen: 65407, 1829 steelblue: 4620980, 1830 tan: 13808780, 1831 teal: 32896, 1832 thistle: 14204888, 1833 tomato: 16737095, 1834 turquoise: 4251856, 1835 violet: 15631086, 1836 wheat: 16113331, 1837 white: 16777215, 1838 whitesmoke: 16119285, 1839 yellow: 16776960, 1840 yellowgreen: 10145074 1841 }); 1842 d3_rgb_names.forEach(function(key, value) { 1843 d3_rgb_names.set(key, d3_rgbNumber(value)); 1844 }); 1845 function d3_functor(v) { 1846 return typeof v === "function" ? v : function() { 1847 return v; 1848 }; 1849 } 1850 d3.functor = d3_functor; 1851 function d3_identity(d) { 1852 return d; 1853 } 1854 d3.xhr = d3_xhrType(d3_identity); 1855 function d3_xhrType(response) { 1856 return function(url, mimeType, callback) { 1857 if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, 1858 mimeType = null; 1859 return d3_xhr(url, mimeType, response, callback); 1860 }; 1861 } 1862 function d3_xhr(url, mimeType, response, callback) { 1863 var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; 1864 if (d3_window.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); 1865 "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { 1866 request.readyState > 3 && respond(); 1867 }; 1868 function respond() { 1869 var status = request.status, result; 1870 if (!status && request.responseText || status >= 200 && status < 300 || status === 304) { 1871 try { 1872 result = response.call(xhr, request); 1873 } catch (e) { 1874 dispatch.error.call(xhr, e); 1875 return; 1876 } 1877 dispatch.load.call(xhr, result); 1878 } else { 1879 dispatch.error.call(xhr, request); 1880 } 1881 } 1882 request.onprogress = function(event) { 1883 var o = d3.event; 1884 d3.event = event;
vendor: 6,348 bytes, lines 1885-2067
1885 try { 1886 dispatch.progress.call(xhr, request); 1887 } finally { 1888 d3.event = o; 1889 } 1890 }; 1891 xhr.header = function(name, value) { 1892 name = (name + "").toLowerCase(); 1893 if (arguments.length < 2) return headers[name]; 1894 if (value == null) delete headers[name]; else headers[name] = value + ""; 1895 return xhr; 1896 }; 1897 xhr.mimeType = function(value) { 1898 if (!arguments.length) return mimeType; 1899 mimeType = value == null ? null : value + ""; 1900 return xhr; 1901 }; 1902 xhr.responseType = function(value) { 1903 if (!arguments.length) return responseType; 1904 responseType = value; 1905 return xhr; 1906 }; 1907 xhr.response = function(value) { 1908 response = value; 1909 return xhr; 1910 }; 1911 [ "get", "post" ].forEach(function(method) { 1912 xhr[method] = function() { 1913 return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); 1914 }; 1915 }); 1916 xhr.send = function(method, data, callback) { 1917 if (arguments.length === 2 && typeof data === "function") callback = data, data = null; 1918 request.open(method, url, true); 1919 if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; 1920 if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); 1921 if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); 1922 if (responseType != null) request.responseType = responseType; 1923 if (callback != null) xhr.on("error", callback).on("load", function(request) { 1924 callback(null, request); 1925 }); 1926 dispatch.beforesend.call(xhr, request); 1927 request.send(data == null ? null : data); 1928 return xhr; 1929 }; 1930 xhr.abort = function() { 1931 request.abort(); 1932 return xhr; 1933 }; 1934 d3.rebind(xhr, dispatch, "on"); 1935 return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); 1936 } 1937 function d3_xhr_fixCallback(callback) { 1938 return callback.length === 1 ? function(error, request) { 1939 callback(error == null ? request : null); 1940 } : callback; 1941 } 1942 d3.dsv = function(delimiter, mimeType) { 1943 var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); 1944 function dsv(url, row, callback) { 1945 if (arguments.length < 3) callback = row, row = null; 1946 var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); 1947 xhr.row = function(_) { 1948 return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; 1949 }; 1950 return xhr; 1951 } 1952 function response(request) { 1953 return dsv.parse(request.responseText); 1954 } 1955 function typedResponse(f) { 1956 return function(request) { 1957 return dsv.parse(request.responseText, f); 1958 }; 1959 } 1960 dsv.parse = function(text, f) { 1961 var o; 1962 return dsv.parseRows(text, function(row, i) { 1963 if (o) return o(row, i - 1); 1964 var a = new Function("d", "return {" + row.map(function(name, i) { 1965 return JSON.stringify(name) + ": d[" + i + "]"; 1966 }).join(",") + "}"); 1967 o = f ? function(row, i) { 1968 return f(a(row), i); 1969 } : a; 1970 }); 1971 }; 1972 dsv.parseRows = function(text, f) { 1973 var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; 1974 function token() { 1975 if (I >= N) return EOF; 1976 if (eol) return eol = false, EOL; 1977 var j = I; 1978 if (text.charCodeAt(j) === 34) { 1979 var i = j; 1980 while (i++ < N) { 1981 if (text.charCodeAt(i) === 34) { 1982 if (text.charCodeAt(i + 1) !== 34) break; 1983 ++i; 1984 } 1985 } 1986 I = i + 2; 1987 var c = text.charCodeAt(i + 1); 1988 if (c === 13) { 1989 eol = true; 1990 if (text.charCodeAt(i + 2) === 10) ++I; 1991 } else if (c === 10) { 1992 eol = true; 1993 } 1994 return text.substring(j + 1, i).replace(/""/g, '"'); 1995 } 1996 while (I < N) { 1997 var c = text.charCodeAt(I++), k = 1; 1998 if (c === 10) eol = true; else if (c === 13) { 1999 eol = true; 2000 if (text.charCodeAt(I) === 10) ++I, ++k; 2001 } else if (c !== delimiterCode) continue; 2002 return text.substring(j, I - k); 2003 } 2004 return text.substring(j); 2005 } 2006 while ((t = token()) !== EOF) { 2007 var a = []; 2008 while (t !== EOL && t !== EOF) { 2009 a.push(t); 2010 t = token(); 2011 } 2012 if (f && !(a = f(a, n++))) continue; 2013 rows.push(a); 2014 } 2015 return rows; 2016 }; 2017 dsv.format = function(rows) { 2018 if (Array.isArray(rows[0])) return dsv.formatRows(rows); 2019 var fieldSet = new d3_Set(), fields = []; 2020 rows.forEach(function(row) { 2021 for (var field in row) { 2022 if (!fieldSet.has(field)) { 2023 fields.push(fieldSet.add(field)); 2024 } 2025 } 2026 }); 2027 return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { 2028 return fields.map(function(field) { 2029 return formatValue(row[field]); 2030 }).join(delimiter); 2031 })).join("\n"); 2032 }; 2033 dsv.formatRows = function(rows) { 2034 return rows.map(formatRow).join("\n"); 2035 }; 2036 function formatRow(row) { 2037 return row.map(formatValue).join(delimiter); 2038 } 2039 function formatValue(text) { 2040 return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; 2041 } 2042 return dsv; 2043 }; 2044 d3.csv = d3.dsv(",", "text/csv"); 2045 d3.tsv = d3.dsv(" ", "text/tab-separated-values"); 2046 var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) { 2047 setTimeout(callback, 17); 2048 }; 2049 d3.timer = function(callback, delay, then) { 2050 var n = arguments.length; 2051 if (n < 2) delay = 0; 2052 if (n < 3) then = Date.now(); 2053 var time = then + delay, timer = { 2054 c: callback, 2055 t: time, 2056 f: false, 2057 n: null 2058 }; 2059 if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; 2060 d3_timer_queueTail = timer; 2061 if (!d3_timer_interval) { 2062 d3_timer_timeout = clearTimeout(d3_timer_timeout); 2063 d3_timer_interval = 1; 2064 d3_timer_frame(d3_timer_step); 2065 } 2066 }; 2067 function d3_timer_step() {
2068 var now = d3_timer_mark(), delay = d3_timer_sweep() - now; 2069 if (delay > 24) { 2070 if (isFinite(delay)) { 2071 clearTimeout(d3_timer_timeout); 2072 d3_timer_timeout = setTimeout(d3_timer_step, delay); 2073 } 2074 d3_timer_interval = 0; 2075 } else { 2076 d3_timer_interval = 1; 2077 d3_timer_frame(d3_timer_step); 2078 } 2079 } 2080 d3.timer.flush = function() { 2081 d3_timer_mark(); 2082 d3_timer_sweep(); 2083 }; 2084 function d3_timer_mark() { 2085 var now = Date.now(); 2086 d3_timer_active = d3_timer_queueHead; 2087 while (d3_timer_active) { 2088 if (now >= d3_timer_active.t) d3_timer_active.f = d3_timer_active.c(now - d3_timer_active.t); 2089 d3_timer_active = d3_timer_active.n; 2090 } 2091 return now; 2092 } 2093 function d3_timer_sweep() { 2094 var t0, t1 = d3_timer_queueHead, time = Infinity; 2095 while (t1) { 2096 if (t1.f) { 2097 t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; 2098 } else { 2099 if (t1.t < time) time = t1.t; 2100 t1 = (t0 = t1).n; 2101 } 2102 } 2103 d3_timer_queueTail = t0; 2104 return time; 2105 } 2106 function d3_format_precision(x, p) { 2107 return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); 2108 } 2109 d3.round = function(x, n) { 2110 return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); 2111 }; 2112 var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); 2113 d3.formatPrefix = function(value, precision) { 2114 var i = 0; 2115 if (value) { 2116 if (value < 0) value *= -1; 2117 if (precision) value = d3.round(value, d3_format_precision(value, precision)); 2118 i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); 2119 i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3)); 2120 } 2121 return d3_formatPrefixes[8 + i / 3]; 2122 }; 2123 function d3_formatPrefix(d, i) { 2124 var k = Math.pow(10, abs(8 - i) * 3); 2125 return { 2126 scale: i > 8 ? function(d) { 2127 return d / k; 2128 } : function(d) { 2129 return d * k; 2130 }, 2131 symbol: d 2132 }; 2133 } 2134 function d3_locale_numberFormat(locale) { 2135 var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping ? function(value) { 2136 var i = value.length, t = [], j = 0, g = locale_grouping[0]; 2137 while (i > 0 && g > 0) { 2138 t.push(value.substring(i -= g, i + g)); 2139 g = locale_grouping[j = (j + 1) % locale_grouping.length]; 2140 } 2141 return t.reverse().join(locale_thousands); 2142 } : d3_identity; 2143 return function(specifier) { 2144 var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false; 2145 if (precision) precision = +precision.substring(1); 2146 if (zfill || fill === "0" && align === "=") { 2147 zfill = fill = "0"; 2148 align = "="; 2149 if (comma) width -= Math.floor((width - 1) / 4); 2150 } 2151 switch (type) { 2152 case "n": 2153 comma = true; 2154 type = "g"; 2155 break; 2156 2157 case "%": 2158 scale = 100; 2159 suffix = "%"; 2160 type = "f"; 2161 break; 2162 2163 case "p": 2164 scale = 100; 2165 suffix = "%"; 2166 type = "r"; 2167 break; 2168 2169 case "b": 2170 case "o": 2171 case "x": 2172 case "X": 2173 if (symbol === "#") prefix = "0" + type.toLowerCase(); 2174 2175 case "c": 2176 case "d": 2177 integer = true; 2178 precision = 0; 2179 break; 2180 2181 case "s": 2182 scale = -1; 2183 type = "r"; 2184 break; 2185 } 2186 if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1]; 2187 if (type == "r" && !precision) type = "g"; 2188 if (precision != null) { 2189 if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); 2190 } 2191 type = d3_format_types.get(type) || d3_format_typeDefault; 2192 var zcomma = zfill && comma; 2193 return function(value) { 2194 if (integer && value % 1) return ""; 2195 var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; 2196 if (scale < 0) { 2197 var unit = d3.formatPrefix(value, precision); 2198 value = unit.scale(value); 2199 suffix = unit.symbol; 2200 } else { 2201 value *= scale; 2202 } 2203 value = type(value, precision); 2204 var i = value.lastIndexOf("."), before = i < 0 ? value : value.substring(0, i), after = i < 0 ? "" : locale_decimal + value.substring(i + 1); 2205 if (!zfill && comma) before = formatGroup(before); 2206 var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; 2207 if (zcomma) before = formatGroup(padding + before); 2208 negative += prefix; 2209 value = before + after; 2210 return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix; 2211 }; 2212 }; 2213 } 2214 var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; 2215 var d3_format_types = d3.map({ 2216 b: function(x) { 2217 return x.toString(2); 2218 }, 2219 c: function(x) { 2220 return String.fromCharCode(x); 2221 }, 2222 o: function(x) { 2223 return x.toString(8); 2224 }, 2225 x: function(x) { 2226 return x.toString(16); 2227 }, 2228 X: function(x) { 2229 return x.toString(16).toUpperCase(); 2230 }, 2231 g: function(x, p) { 2232 return x.toPrecision(p); 2233 }, 2234 e: function(x, p) { 2235 return x.toExponential(p); 2236 }, 2237 f: function(x, p) { 2238 return x.toFixed(p); 2239 }, 2240 r: function(x, p) { 2241 return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); 2242 } 2243 }); 2244 function d3_format_typeDefault(x) { 2245 return x + ""; 2246 } 2247 var d3_time = d3.time = {}, d3_date = Date; 2248 function d3_date_utc() { 2249 this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); 2250 } 2251 d3_date_utc.prototype = { 2252 getDate: function() { 2253 return this._.getUTCDate(); 2254 }, 2255 getDay: function() { 2256 return this._.getUTCDay(); 2257 }, 2258 getFullYear: function() { 2259 return this._.getUTCFullYear(); 2260 }, 2261 getHours: function() { 2262 return this._.getUTCHours(); 2263 }, 2264 getMilliseconds: function() { 2265 return this._.getUTCMilliseconds(); 2266 }, 2267 getMinutes: function() { 2268 return this._.getUTCMinutes(); 2269 }, 2270 getMonth: function() { 2271 return this._.getUTCMonth(); 2272 }, 2273 getSeconds: function() { 2274 return this._.getUTCSeconds(); 2275 }, 2276 getTime: function() { 2277 return this._.getTime(); 2278 }, 2279 getTimezoneOffset: function() { 2280 return 0; 2281 },
2282 valueOf: function() { 2283 return this._.valueOf(); 2284 }, 2285 setDate: function() { 2286 d3_time_prototype.setUTCDate.apply(this._, arguments); 2287 }, 2288 setDay: function() { 2289 d3_time_prototype.setUTCDay.apply(this._, arguments); 2290 }, 2291 setFullYear: function() { 2292 d3_time_prototype.setUTCFullYear.apply(this._, arguments); 2293 }, 2294 setHours: function() { 2295 d3_time_prototype.setUTCHours.apply(this._, arguments); 2296 }, 2297 setMilliseconds: function() { 2298 d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); 2299 }, 2300 setMinutes: function() { 2301 d3_time_prototype.setUTCMinutes.apply(this._, arguments); 2302 }, 2303 setMonth: function() { 2304 d3_time_prototype.setUTCMonth.apply(this._, arguments); 2305 }, 2306 setSeconds: function() { 2307 d3_time_prototype.setUTCSeconds.apply(this._, arguments); 2308 }, 2309 setTime: function() { 2310 d3_time_prototype.setTime.apply(this._, arguments); 2311 } 2312 }; 2313 var d3_time_prototype = Date.prototype; 2314 function d3_time_interval(local, step, number) { 2315 function round(date) { 2316 var d0 = local(date), d1 = offset(d0, 1); 2317 return date - d0 < d1 - date ? d0 : d1; 2318 } 2319 function ceil(date) { 2320 step(date = local(new d3_date(date - 1)), 1); 2321 return date; 2322 } 2323 function offset(date, k) { 2324 step(date = new d3_date(+date), k); 2325 return date; 2326 } 2327 function range(t0, t1, dt) { 2328 var time = ceil(t0), times = []; 2329 if (dt > 1) { 2330 while (time < t1) { 2331 if (!(number(time) % dt)) times.push(new Date(+time)); 2332 step(time, 1); 2333 } 2334 } else { 2335 while (time < t1) times.push(new Date(+time)), step(time, 1); 2336 } 2337 return times; 2338 } 2339 function range_utc(t0, t1, dt) { 2340 try { 2341 d3_date = d3_date_utc; 2342 var utc = new d3_date_utc(); 2343 utc._ = t0; 2344 return range(utc, t1, dt); 2345 } finally { 2346 d3_date = Date; 2347 } 2348 } 2349 local.floor = local; 2350 local.round = round; 2351 local.ceil = ceil; 2352 local.offset = offset; 2353 local.range = range; 2354 var utc = local.utc = d3_time_interval_utc(local); 2355 utc.floor = utc; 2356 utc.round = d3_time_interval_utc(round); 2357 utc.ceil = d3_time_interval_utc(ceil); 2358 utc.offset = d3_time_interval_utc(offset); 2359 utc.range = range_utc; 2360 return local; 2361 } 2362 function d3_time_interval_utc(method) { 2363 return function(date, k) { 2364 try { 2365 d3_date = d3_date_utc; 2366 var utc = new d3_date_utc(); 2367 utc._ = date; 2368 return method(utc, k)._; 2369 } finally { 2370 d3_date = Date; 2371 } 2372 }; 2373 } 2374 d3_time.year = d3_time_interval(function(date) { 2375 date = d3_time.day(date); 2376 date.setMonth(0, 1); 2377 return date; 2378 }, function(date, offset) { 2379 date.setFullYear(date.getFullYear() + offset); 2380 }, function(date) { 2381 return date.getFullYear(); 2382 }); 2383 d3_time.years = d3_time.year.range; 2384 d3_time.years.utc = d3_time.year.utc.range; 2385 d3_time.day = d3_time_interval(function(date) { 2386 var day = new d3_date(2e3, 0); 2387 day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); 2388 return day; 2389 }, function(date, offset) { 2390 date.setDate(date.getDate() + offset); 2391 }, function(date) { 2392 return date.getDate() - 1; 2393 }); 2394 d3_time.days = d3_time.day.range; 2395 d3_time.days.utc = d3_time.day.utc.range; 2396 d3_time.dayOfYear = function(date) { 2397 var year = d3_time.year(date); 2398 return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); 2399 }; 2400 [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) { 2401 i = 7 - i; 2402 var interval = d3_time[day] = d3_time_interval(function(date) { 2403 (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); 2404 return date; 2405 }, function(date, offset) { 2406 date.setDate(date.getDate() + Math.floor(offset) * 7); 2407 }, function(date) { 2408 var day = d3_time.year(date).getDay(); 2409 return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); 2410 }); 2411 d3_time[day + "s"] = interval.range; 2412 d3_time[day + "s"].utc = interval.utc.range; 2413 d3_time[day + "OfYear"] = function(date) { 2414 var day = d3_time.year(date).getDay(); 2415 return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7); 2416 }; 2417 }); 2418 d3_time.week = d3_time.sunday; 2419 d3_time.weeks = d3_time.sunday.range; 2420 d3_time.weeks.utc = d3_time.sunday.utc.range; 2421 d3_time.weekOfYear = d3_time.sundayOfYear; 2422 function d3_locale_timeFormat(locale) { 2423 var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths; 2424 function d3_time_format(template) { 2425 var n = template.length; 2426 function format(date) { 2427 var string = [], i = -1, j = 0, c, p, f; 2428 while (++i < n) { 2429 if (template.charCodeAt(i) === 37) {
2430 string.push(template.substring(j, i)); 2431 if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); 2432 if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); 2433 string.push(c); 2434 j = i + 1; 2435 } 2436 } 2437 string.push(template.substring(j, i)); 2438 return string.join(""); 2439 } 2440 format.parse = function(string) { 2441 var d = { 2442 y: 1900, 2443 m: 0, 2444 d: 1, 2445 H: 0, 2446 M: 0, 2447 S: 0, 2448 L: 0, 2449 Z: null 2450 }, i = d3_time_parse(d, template, string, 0); 2451 if (i != string.length) return null; 2452 if ("p" in d) d.H = d.H % 12 + d.p * 12; 2453 var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); 2454 if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) { 2455 date.setFullYear(d.y, 0, 1); 2456 date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); 2457 } else date.setFullYear(d.y, d.m, d.d); 2458 date.setHours(d.H + Math.floor(d.Z / 100), d.M + d.Z % 100, d.S, d.L); 2459 return localZ ? date._ : date; 2460 }; 2461 format.toString = function() { 2462 return template; 2463 }; 2464 return format; 2465 } 2466 function d3_time_parse(date, template, string, j) { 2467 var c, p, t, i = 0, n = template.length, m = string.length; 2468 while (i < n) { 2469 if (j >= m) return -1; 2470 c = template.charCodeAt(i++); 2471 if (c === 37) { 2472 t = template.charAt(i++); 2473 p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; 2474 if (!p || (j = p(date, string, j)) < 0) return -1; 2475 } else if (c != string.charCodeAt(j++)) { 2476 return -1; 2477 } 2478 } 2479 return j; 2480 } 2481 d3_time_format.utc = function(template) { 2482 var local = d3_time_format(template); 2483 function format(date) { 2484 try { 2485 d3_date = d3_date_utc; 2486 var utc = new d3_date(); 2487 utc._ = date; 2488 return local(utc); 2489 } finally { 2490 d3_date = Date; 2491 } 2492 } 2493 format.parse = function(string) { 2494 try { 2495 d3_date = d3_date_utc; 2496 var date = local.parse(string); 2497 return date && date._; 2498 } finally { 2499 d3_date = Date; 2500 } 2501 }; 2502 format.toString = local.toString; 2503 return format; 2504 }; 2505 d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti; 2506 var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths); 2507 locale_periods.forEach(function(p, i) { 2508 d3_time_periodLookup.set(p.toLowerCase(), i); 2509 }); 2510 var d3_time_formats = { 2511 a: function(d) { 2512 return locale_shortDays[d.getDay()]; 2513 }, 2514 A: function(d) { 2515 return locale_days[d.getDay()]; 2516 }, 2517 b: function(d) { 2518 return locale_shortMonths[d.getMonth()]; 2519 }, 2520 B: function(d) { 2521 return locale_months[d.getMonth()]; 2522 }, 2523 c: d3_time_format(locale_dateTime), 2524 d: function(d, p) { 2525 return d3_time_formatPad(d.getDate(), p, 2); 2526 }, 2527 e: function(d, p) { 2528 return d3_time_formatPad(d.getDate(), p, 2); 2529 }, 2530 H: function(d, p) { 2531 return d3_time_formatPad(d.getHours(), p, 2); 2532 }, 2533 I: function(d, p) { 2534 return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); 2535 }, 2536 j: function(d, p) { 2537 return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); 2538 }, 2539 L: function(d, p) { 2540 return d3_time_formatPad(d.getMilliseconds(), p, 3); 2541 }, 2542 m: function(d, p) { 2543 return d3_time_formatPad(d.getMonth() + 1, p, 2); 2544 }, 2545 M: function(d, p) { 2546 return d3_time_formatPad(d.getMinutes(), p, 2); 2547 }, 2548 p: function(d) { 2549 return locale_periods[+(d.getHours() >= 12)]; 2550 }, 2551 S: function(d, p) { 2552 return d3_time_formatPad(d.getSeconds(), p, 2); 2553 }, 2554 U: function(d, p) { 2555 return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); 2556 }, 2557 w: function(d) { 2558 return d.getDay(); 2559 }, 2560 W: function(d, p) { 2561 return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); 2562 }, 2563 x: d3_time_format(locale_date), 2564 X: d3_time_format(locale_time), 2565 y: function(d, p) { 2566 return d3_time_formatPad(d.getFullYear() % 100, p, 2); 2567 }, 2568 Y: function(d, p) { 2569 return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); 2570 }, 2571 Z: d3_time_zone, 2572 "%": function() { 2573 return "%"; 2574 } 2575 }; 2576 var d3_time_parsers = { 2577 a: d3_time_parseWeekdayAbbrev, 2578 A: d3_time_parseWeekday, 2579 b: d3_time_parseMonthAbbrev, 2580 B: d3_time_parseMonth, 2581 c: d3_time_parseLocaleFull, 2582 d: d3_time_parseDay, 2583 e: d3_time_parseDay, 2584 H: d3_time_parseHour24, 2585 I: d3_time_parseHour24, 2586 j: d3_time_parseDayOfYear, 2587 L: d3_time_parseMilliseconds, 2588 m: d3_time_parseMonthNumber, 2589 M: d3_time_parseMinutes, 2590 p: d3_time_parseAmPm, 2591 S: d3_time_parseSeconds, 2592 U: d3_time_parseWeekNumberSunday, 2593 w: d3_time_parseWeekdayNumber, 2594 W: d3_time_parseWeekNumberMonday, 2595 x: d3_time_parseLocaleDate, 2596 X: d3_time_parseLocaleTime, 2597 y: d3_time_parseYear, 2598 Y: d3_time_parseFullYear, 2599 Z: d3_time_parseZone, 2600 "%": d3_time_parseLiteralPercent 2601 }; 2602 function d3_time_parseWeekdayAbbrev(date, string, i) { 2603 d3_time_dayAbbrevRe.lastIndex = 0; 2604 var n = d3_time_dayAbbrevRe.exec(string.substring(i)); 2605 return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; 2606 } 2607 function d3_time_parseWeekday(date, string, i) { 2608 d3_time_dayRe.lastIndex = 0; 2609 var n = d3_time_dayRe.exec(string.substring(i)); 2610 return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; 2611 } 2612 function d3_time_parseMonthAbbrev(date, string, i) { 2613 d3_time_monthAbbrevRe.lastIndex = 0; 2614 var n = d3_time_monthAbbrevRe.exec(string.substring(i)); 2615 return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; 2616 } 2617 function d3_time_parseMonth(date, string, i) { 2618 d3_time_monthRe.lastIndex = 0; 2619 var n = d3_time_monthRe.exec(string.substring(i)); 2620 return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; 2621 } 2622 function d3_time_parseLocaleFull(date, string, i) { 2623 return d3_time_parse(date, d3_time_formats.c.toString(), string, i); 2624 } 2625 function d3_time_parseLocaleDate(date, string, i) { 2626 return d3_time_parse(date, d3_time_formats.x.toString(), string, i); 2627 } 2628 function d3_time_parseLocaleTime(date, string, i) { 2629 return d3_time_parse(date, d3_time_formats.X.toString(), string, i); 2630 } 2631 function d3_time_parseAmPm(date, string, i) { 2632 var n = d3_time_periodLookup.get(string.substring(i, i += 2).toLowerCase()); 2633 return n == null ? -1 : (date.p = n, i); 2634 } 2635 return d3_time_format; 2636 } 2637 var d3_time_formatPads = { 2638 "-": "", 2639 _: " ", 2640 "0": "0" 2641 }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/; 2642 function d3_time_formatPad(value, fill, width) { 2643 var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; 2644 return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); 2645 } 2646 function d3_time_formatRe(names) { 2647 return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); 2648 } 2649 function d3_time_formatLookup(names) { 2650 var map = new d3_Map(), i = -1, n = names.length; 2651 while (++i < n) map.set(names[i].toLowerCase(), i); 2652 return map; 2653 } 2654 function d3_time_parseWeekdayNumber(date, string, i) { 2655 d3_time_numberRe.lastIndex = 0; 2656 var n = d3_time_numberRe.exec(string.substring(i, i + 1)); 2657 return n ? (date.w = +n[0], i + n[0].length) : -1; 2658 } 2659 function d3_time_parseWeekNumberSunday(date, string, i) { 2660 d3_time_numberRe.lastIndex = 0; 2661 var n = d3_time_numberRe.exec(string.substring(i)); 2662 return n ? (date.U = +n[0], i + n[0].length) : -1; 2663 } 2664 function d3_time_parseWeekNumberMonday(date, string, i) { 2665 d3_time_numberRe.lastIndex = 0; 2666 var n = d3_time_numberRe.exec(string.substring(i)); 2667 return n ? (date.W = +n[0], i + n[0].length) : -1; 2668 } 2669 function d3_time_parseFullYear(date, string, i) { 2670 d3_time_numberRe.lastIndex = 0; 2671 var n = d3_time_numberRe.exec(string.substring(i, i + 4)); 2672 return n ? (date.y = +n[0], i + n[0].length) : -1; 2673 } 2674 function d3_time_parseYear(date, string, i) { 2675 d3_time_numberRe.lastIndex = 0; 2676 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2677 return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; 2678 } 2679 function d3_time_parseZone(date, string, i) { 2680 return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = +string, 2681 i + 5) : -1; 2682 } 2683 function d3_time_expandYear(d) { 2684 return d + (d > 68 ? 1900 : 2e3); 2685 } 2686 function d3_time_parseMonthNumber(date, string, i) { 2687 d3_time_numberRe.lastIndex = 0; 2688 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2689 return n ? (date.m = n[0] - 1, i + n[0].length) : -1; 2690 } 2691 function d3_time_parseDay(date, string, i) { 2692 d3_time_numberRe.lastIndex = 0; 2693 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2694 return n ? (date.d = +n[0], i + n[0].length) : -1; 2695 } 2696 function d3_time_parseDayOfYear(date, string, i) { 2697 d3_time_numberRe.lastIndex = 0; 2698 var n = d3_time_numberRe.exec(string.substring(i, i + 3)); 2699 return n ? (date.j = +n[0], i + n[0].length) : -1; 2700 } 2701 function d3_time_parseHour24(date, string, i) { 2702 d3_time_numberRe.lastIndex = 0; 2703 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2704 return n ? (date.H = +n[0], i + n[0].length) : -1; 2705 } 2706 function d3_time_parseMinutes(date, string, i) { 2707 d3_time_numberRe.lastIndex = 0; 2708 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2709 return n ? (date.M = +n[0], i + n[0].length) : -1; 2710 } 2711 function d3_time_parseSeconds(date, string, i) { 2712 d3_time_numberRe.lastIndex = 0; 2713 var n = d3_time_numberRe.exec(string.substring(i, i + 2)); 2714 return n ? (date.S = +n[0], i + n[0].length) : -1; 2715 } 2716 function d3_time_parseMilliseconds(date, string, i) { 2717 d3_time_numberRe.lastIndex = 0; 2718 var n = d3_time_numberRe.exec(string.substring(i, i + 3)); 2719 return n ? (date.L = +n[0], i + n[0].length) : -1; 2720 } 2721 function d3_time_zone(d) { 2722 var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(abs(z) / 60), zm = abs(z) % 60; 2723 return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); 2724 } 2725 function d3_time_parseLiteralPercent(date, string, i) { 2726 d3_time_percentRe.lastIndex = 0; 2727 var n = d3_time_percentRe.exec(string.substring(i, i + 1)); 2728 return n ? i + n[0].length : -1; 2729 } 2730 function d3_time_formatMulti(formats) { 2731 var n = formats.length, i = -1; 2732 while (++i < n) formats[i][0] = this(formats[i][0]); 2733 return function(date) { 2734 var i = 0, f = formats[i]; 2735 while (!f[1](date)) f = formats[++i]; 2736 return f[0](date); 2737 }; 2738 } 2739 d3.locale = function(locale) { 2740 return { 2741 numberFormat: d3_locale_numberFormat(locale), 2742 timeFormat: d3_locale_timeFormat(locale) 2743 }; 2744 };
2745 var d3_locale_enUS = d3.locale({ 2746 decimal: ".", 2747 thousands: ",", 2748 grouping: [ 3 ], 2749 currency: [ "$", "" ], 2750 dateTime: "%a %b %e %X %Y", 2751 date: "%m/%d/%Y", 2752 time: "%H:%M:%S", 2753 periods: [ "AM", "PM" ], 2754 days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], 2755 shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], 2756 months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 2757 shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 2758 }); 2759 d3.format = d3_locale_enUS.numberFormat; 2760 d3.geo = {}; 2761 function d3_adder() {} 2762 d3_adder.prototype = { 2763 s: 0, 2764 t: 0, 2765 add: function(y) { 2766 d3_adderSum(y, this.t, d3_adderTemp); 2767 d3_adderSum(d3_adderTemp.s, this.s, this); 2768 if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; 2769 }, 2770 reset: function() { 2771 this.s = this.t = 0; 2772 }, 2773 valueOf: function() { 2774 return this.s; 2775 } 2776 }; 2777 var d3_adderTemp = new d3_adder(); 2778 function d3_adderSum(a, b, o) { 2779 var x = o.s = a + b, bv = x - a, av = x - bv; 2780 o.t = a - av + (b - bv); 2781 } 2782 d3.geo.stream = function(object, listener) { 2783 if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { 2784 d3_geo_streamObjectType[object.type](object, listener); 2785 } else { 2786 d3_geo_streamGeometry(object, listener); 2787 } 2788 }; 2789 function d3_geo_streamGeometry(geometry, listener) { 2790 if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { 2791 d3_geo_streamGeometryType[geometry.type](geometry, listener); 2792 } 2793 } 2794 var d3_geo_streamObjectType = { 2795 Feature: function(feature, listener) { 2796 d3_geo_streamGeometry(feature.geometry, listener); 2797 }, 2798 FeatureCollection: function(object, listener) { 2799 var features = object.features, i = -1, n = features.length; 2800 while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); 2801 } 2802 }; 2803 var d3_geo_streamGeometryType = { 2804 Sphere: function(object, listener) { 2805 listener.sphere(); 2806 }, 2807 Point: function(object, listener) { 2808 object = object.coordinates; 2809 listener.point(object[0], object[1], object[2]); 2810 }, 2811 MultiPoint: function(object, listener) { 2812 var coordinates = object.coordinates, i = -1, n = coordinates.length; 2813 while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); 2814 }, 2815 LineString: function(object, listener) { 2816 d3_geo_streamLine(object.coordinates, listener, 0); 2817 }, 2818 MultiLineString: function(object, listener) { 2819 var coordinates = object.coordinates, i = -1, n = coordinates.length; 2820 while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); 2821 }, 2822 Polygon: function(object, listener) { 2823 d3_geo_streamPolygon(object.coordinates, listener); 2824 }, 2825 MultiPolygon: function(object, listener) { 2826 var coordinates = object.coordinates, i = -1, n = coordinates.length; 2827 while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); 2828 }, 2829 GeometryCollection: function(object, listener) { 2830 var geometries = object.geometries, i = -1, n = geometries.length; 2831 while (++i < n) d3_geo_streamGeometry(geometries[i], listener); 2832 } 2833 }; 2834 function d3_geo_streamLine(coordinates, listener, closed) { 2835 var i = -1, n = coordinates.length - closed, coordinate; 2836 listener.lineStart(); 2837 while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); 2838 listener.lineEnd(); 2839 } 2840 function d3_geo_streamPolygon(coordinates, listener) { 2841 var i = -1, n = coordinates.length; 2842 listener.polygonStart(); 2843 while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); 2844 listener.polygonEnd(); 2845 } 2846 d3.geo.area = function(object) { 2847 d3_geo_areaSum = 0; 2848 d3.geo.stream(object, d3_geo_area); 2849 return d3_geo_areaSum; 2850 }; 2851 var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); 2852 var d3_geo_area = { 2853 sphere: function() { 2854 d3_geo_areaSum += 4 * Ï; 2855 }, 2856 point: d3_noop, 2857 lineStart: d3_noop, 2858 lineEnd: d3_noop, 2859 polygonStart: function() { 2860 d3_geo_areaRingSum.reset(); 2861 d3_geo_area.lineStart = d3_geo_areaRingStart; 2862 }, 2863 polygonEnd: function() { 2864 var area = 2 * d3_geo_areaRingSum; 2865 d3_geo_areaSum += area < 0 ? 4 * Ï + area : area; 2866 d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; 2867 } 2868 }; 2869 function d3_geo_areaRingStart() { 2870 var λ00, Ï00, λ0, cosÏ0, sinÏ0; 2871 d3_geo_area.point = function(λ, Ï) { 2872 d3_geo_area.point = nextPoint; 2873 λ0 = (λ00 = λ) * d3_radians, cosÏ0 = Math.cos(Ï = (Ï00 = Ï) * d3_radians / 2 + Ï / 4),
vendor: 9,649 bytes, lines 2874-3124
2874 sinÏ0 = Math.sin(Ï); 2875 }; 2876 function nextPoint(λ, Ï) { 2877 λ *= d3_radians; 2878 Ï = Ï * d3_radians / 2 + Ï / 4; 2879 var dλ = λ - λ0, cosÏ = Math.cos(Ï), sinÏ = Math.sin(Ï), k = sinÏ0 * sinÏ, u = cosÏ0 * cosÏ + k * Math.cos(dλ), v = k * Math.sin(dλ); 2880 d3_geo_areaRingSum.add(Math.atan2(v, u)); 2881 λ0 = λ, cosÏ0 = cosÏ, sinÏ0 = sinÏ; 2882 } 2883 d3_geo_area.lineEnd = function() { 2884 nextPoint(λ00, Ï00); 2885 }; 2886 } 2887 function d3_geo_cartesian(spherical) { 2888 var λ = spherical[0], Ï = spherical[1], cosÏ = Math.cos(Ï); 2889 return [ cosÏ * Math.cos(λ), cosÏ * Math.sin(λ), Math.sin(Ï) ]; 2890 } 2891 function d3_geo_cartesianDot(a, b) { 2892 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; 2893 } 2894 function d3_geo_cartesianCross(a, b) { 2895 return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; 2896 } 2897 function d3_geo_cartesianAdd(a, b) { 2898 a[0] += b[0]; 2899 a[1] += b[1]; 2900 a[2] += b[2]; 2901 } 2902 function d3_geo_cartesianScale(vector, k) { 2903 return [ vector[0] * k, vector[1] * k, vector[2] * k ]; 2904 } 2905 function d3_geo_cartesianNormalize(d) { 2906 var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); 2907 d[0] /= l; 2908 d[1] /= l; 2909 d[2] /= l; 2910 } 2911 function d3_geo_spherical(cartesian) { 2912 return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; 2913 } 2914 function d3_geo_sphericalEqual(a, b) { 2915 return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; 2916 } 2917 d3.geo.bounds = function() { 2918 var λ0, Ï0, λ1, Ï1, λ_, λ__, Ï__, p0, dλSum, ranges, range; 2919 var bound = { 2920 point: point, 2921 lineStart: lineStart, 2922 lineEnd: lineEnd, 2923 polygonStart: function() { 2924 bound.point = ringPoint; 2925 bound.lineStart = ringStart; 2926 bound.lineEnd = ringEnd; 2927 dλSum = 0; 2928 d3_geo_area.polygonStart(); 2929 }, 2930 polygonEnd: function() { 2931 d3_geo_area.polygonEnd(); 2932 bound.point = point; 2933 bound.lineStart = lineStart; 2934 bound.lineEnd = lineEnd; 2935 if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), Ï0 = -(Ï1 = 90); else if (dλSum > ε) Ï1 = 90; else if (dλSum < -ε) Ï0 = -90; 2936 range[0] = λ0, range[1] = λ1; 2937 } 2938 }; 2939 function point(λ, Ï) { 2940 ranges.push(range = [ λ0 = λ, λ1 = λ ]); 2941 if (Ï < Ï0) Ï0 = Ï; 2942 if (Ï > Ï1) Ï1 = Ï; 2943 } 2944 function linePoint(λ, Ï) { 2945 var p = d3_geo_cartesian([ λ * d3_radians, Ï * d3_radians ]); 2946 if (p0) { 2947 var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); 2948 d3_geo_cartesianNormalize(inflection); 2949 inflection = d3_geo_spherical(inflection); 2950 var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180; 2951 if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { 2952 var Ïi = inflection[1] * d3_degrees; 2953 if (Ïi > Ï1) Ï1 = Ïi; 2954 } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { 2955 var Ïi = -inflection[1] * d3_degrees; 2956 if (Ïi < Ï0) Ï0 = Ïi; 2957 } else { 2958 if (Ï < Ï0) Ï0 = Ï; 2959 if (Ï > Ï1) Ï1 = Ï; 2960 } 2961 if (antimeridian) { 2962 if (λ < λ_) { 2963 if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; 2964 } else { 2965 if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; 2966 } 2967 } else { 2968 if (λ1 >= λ0) { 2969 if (λ < λ0) λ0 = λ; 2970 if (λ > λ1) λ1 = λ; 2971 } else { 2972 if (λ > λ_) { 2973 if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; 2974 } else { 2975 if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; 2976 } 2977 } 2978 } 2979 } else { 2980 point(λ, Ï); 2981 } 2982 p0 = p, λ_ = λ; 2983 } 2984 function lineStart() { 2985 bound.point = linePoint; 2986 } 2987 function lineEnd() { 2988 range[0] = λ0, range[1] = λ1; 2989 bound.point = point; 2990 p0 = null; 2991 } 2992 function ringPoint(λ, Ï) { 2993 if (p0) { 2994 var dλ = λ - λ_; 2995 dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; 2996 } else λ__ = λ, Ï__ = Ï; 2997 d3_geo_area.point(λ, Ï); 2998 linePoint(λ, Ï); 2999 } 3000 function ringStart() { 3001 d3_geo_area.lineStart(); 3002 } 3003 function ringEnd() { 3004 ringPoint(λ__, Ï__); 3005 d3_geo_area.lineEnd(); 3006 if (abs(dλSum) > ε) λ0 = -(λ1 = 180); 3007 range[0] = λ0, range[1] = λ1; 3008 p0 = null; 3009 } 3010 function angle(λ0, λ1) { 3011 return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; 3012 } 3013 function compareRanges(a, b) { 3014 return a[0] - b[0]; 3015 } 3016 function withinRange(x, range) { 3017 return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; 3018 } 3019 return function(feature) { 3020 Ï1 = λ1 = -(λ0 = Ï0 = Infinity); 3021 ranges = []; 3022 d3.geo.stream(feature, bound); 3023 var n = ranges.length; 3024 if (n) { 3025 ranges.sort(compareRanges); 3026 for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { 3027 b = ranges[i]; 3028 if (withinRange(b[0], a) || withinRange(b[1], a)) { 3029 if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; 3030 if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; 3031 } else { 3032 merged.push(a = b); 3033 } 3034 } 3035 var best = -Infinity, dλ; 3036 for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { 3037 b = merged[i]; 3038 if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; 3039 } 3040 } 3041 ranges = range = null; 3042 return λ0 === Infinity || Ï0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, Ï0 ], [ λ1, Ï1 ] ]; 3043 }; 3044 }(); 3045 d3.geo.centroid = function(object) { 3046 d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; 3047 d3.geo.stream(object, d3_geo_centroid); 3048 var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; 3049 if (m < ε2) { 3050 x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; 3051 if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; 3052 m = x * x + y * y + z * z; 3053 if (m < ε2) return [ NaN, NaN ]; 3054 } 3055 return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; 3056 }; 3057 var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; 3058 var d3_geo_centroid = { 3059 sphere: d3_noop, 3060 point: d3_geo_centroidPoint, 3061 lineStart: d3_geo_centroidLineStart, 3062 lineEnd: d3_geo_centroidLineEnd, 3063 polygonStart: function() { 3064 d3_geo_centroid.lineStart = d3_geo_centroidRingStart; 3065 }, 3066 polygonEnd: function() { 3067 d3_geo_centroid.lineStart = d3_geo_centroidLineStart; 3068 } 3069 }; 3070 function d3_geo_centroidPoint(λ, Ï) { 3071 λ *= d3_radians; 3072 var cosÏ = Math.cos(Ï *= d3_radians); 3073 d3_geo_centroidPointXYZ(cosÏ * Math.cos(λ), cosÏ * Math.sin(λ), Math.sin(Ï)); 3074 } 3075 function d3_geo_centroidPointXYZ(x, y, z) { 3076 ++d3_geo_centroidW0; 3077 d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; 3078 d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; 3079 d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; 3080 } 3081 function d3_geo_centroidLineStart() { 3082 var x0, y0, z0; 3083 d3_geo_centroid.point = function(λ, Ï) { 3084 λ *= d3_radians; 3085 var cosÏ = Math.cos(Ï *= d3_radians); 3086 x0 = cosÏ * Math.cos(λ); 3087 y0 = cosÏ * Math.sin(λ); 3088 z0 = Math.sin(Ï); 3089 d3_geo_centroid.point = nextPoint; 3090 d3_geo_centroidPointXYZ(x0, y0, z0); 3091 }; 3092 function nextPoint(λ, Ï) { 3093 λ *= d3_radians; 3094 var cosÏ = Math.cos(Ï *= d3_radians), x = cosÏ * Math.cos(λ), y = cosÏ * Math.sin(λ), z = Math.sin(Ï), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); 3095 d3_geo_centroidW1 += w; 3096 d3_geo_centroidX1 += w * (x0 + (x0 = x)); 3097 d3_geo_centroidY1 += w * (y0 + (y0 = y)); 3098 d3_geo_centroidZ1 += w * (z0 + (z0 = z)); 3099 d3_geo_centroidPointXYZ(x0, y0, z0); 3100 } 3101 } 3102 function d3_geo_centroidLineEnd() { 3103 d3_geo_centroid.point = d3_geo_centroidPoint; 3104 } 3105 function d3_geo_centroidRingStart() { 3106 var λ00, Ï00, x0, y0, z0; 3107 d3_geo_centroid.point = function(λ, Ï) { 3108 λ00 = λ, Ï00 = Ï; 3109 d3_geo_centroid.point = nextPoint; 3110 λ *= d3_radians; 3111 var cosÏ = Math.cos(Ï *= d3_radians); 3112 x0 = cosÏ * Math.cos(λ); 3113 y0 = cosÏ * Math.sin(λ); 3114 z0 = Math.sin(Ï); 3115 d3_geo_centroidPointXYZ(x0, y0, z0); 3116 }; 3117 d3_geo_centroid.lineEnd = function() { 3118 nextPoint(λ00, Ï00); 3119 d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; 3120 d3_geo_centroid.point = d3_geo_centroidPoint; 3121 }; 3122 function nextPoint(λ, Ï) { 3123 λ *= d3_radians; 3124 var cosÏ = Math.cos(Ï *= d3_radians), x = cosÏ * Math.cos(λ), y = cosÏ * Math.sin(λ), z = Math.sin(Ï), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u);
vendor: 7,189 bytes, lines 3125-3337
3125 d3_geo_centroidX2 += v * cx; 3126 d3_geo_centroidY2 += v * cy; 3127 d3_geo_centroidZ2 += v * cz; 3128 d3_geo_centroidW1 += w; 3129 d3_geo_centroidX1 += w * (x0 + (x0 = x)); 3130 d3_geo_centroidY1 += w * (y0 + (y0 = y)); 3131 d3_geo_centroidZ1 += w * (z0 + (z0 = z)); 3132 d3_geo_centroidPointXYZ(x0, y0, z0); 3133 } 3134 } 3135 function d3_true() { 3136 return true; 3137 } 3138 function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { 3139 var subject = [], clip = []; 3140 segments.forEach(function(segment) { 3141 if ((n = segment.length - 1) <= 0) return; 3142 var n, p0 = segment[0], p1 = segment[n]; 3143 if (d3_geo_sphericalEqual(p0, p1)) { 3144 listener.lineStart(); 3145 for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); 3146 listener.lineEnd(); 3147 return; 3148 } 3149 var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false); 3150 a.o = b; 3151 subject.push(a); 3152 clip.push(b); 3153 a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); 3154 b = new d3_geo_clipPolygonIntersection(p1, null, a, true); 3155 a.o = b; 3156 subject.push(a); 3157 clip.push(b); 3158 }); 3159 clip.sort(compare); 3160 d3_geo_clipPolygonLinkCircular(subject); 3161 d3_geo_clipPolygonLinkCircular(clip); 3162 if (!subject.length) return; 3163 for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { 3164 clip[i].e = entry = !entry; 3165 } 3166 var start = subject[0], points, point; 3167 while (1) { 3168 var current = start, isSubject = true; 3169 while (current.v) if ((current = current.n) === start) return; 3170 points = current.z; 3171 listener.lineStart(); 3172 do { 3173 current.v = current.o.v = true; 3174 if (current.e) { 3175 if (isSubject) { 3176 for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); 3177 } else { 3178 interpolate(current.x, current.n.x, 1, listener); 3179 } 3180 current = current.n; 3181 } else { 3182 if (isSubject) { 3183 points = current.p.z; 3184 for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); 3185 } else { 3186 interpolate(current.x, current.p.x, -1, listener); 3187 } 3188 current = current.p; 3189 } 3190 current = current.o; 3191 points = current.z; 3192 isSubject = !isSubject; 3193 } while (!current.v); 3194 listener.lineEnd(); 3195 } 3196 } 3197 function d3_geo_clipPolygonLinkCircular(array) { 3198 if (!(n = array.length)) return; 3199 var n, i = 0, a = array[0], b; 3200 while (++i < n) { 3201 a.n = b = array[i]; 3202 b.p = a; 3203 a = b; 3204 } 3205 a.n = b = array[0]; 3206 b.p = a; 3207 } 3208 function d3_geo_clipPolygonIntersection(point, points, other, entry) { 3209 this.x = point; 3210 this.z = points; 3211 this.o = other; 3212 this.e = entry; 3213 this.v = false; 3214 this.n = this.p = null; 3215 } 3216 function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { 3217 return function(rotate, listener) { 3218 var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); 3219 var clip = { 3220 point: point, 3221 lineStart: lineStart, 3222 lineEnd: lineEnd, 3223 polygonStart: function() { 3224 clip.point = pointRing; 3225 clip.lineStart = ringStart; 3226 clip.lineEnd = ringEnd; 3227 segments = []; 3228 polygon = []; 3229 listener.polygonStart(); 3230 }, 3231 polygonEnd: function() { 3232 clip.point = point; 3233 clip.lineStart = lineStart; 3234 clip.lineEnd = lineEnd; 3235 segments = d3.merge(segments); 3236 var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); 3237 if (segments.length) { 3238 d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); 3239 } else if (clipStartInside) { 3240 listener.lineStart(); 3241 interpolate(null, null, 1, listener); 3242 listener.lineEnd(); 3243 } 3244 listener.polygonEnd(); 3245 segments = polygon = null; 3246 }, 3247 sphere: function() { 3248 listener.polygonStart(); 3249 listener.lineStart(); 3250 interpolate(null, null, 1, listener); 3251 listener.lineEnd(); 3252 listener.polygonEnd(); 3253 } 3254 }; 3255 function point(λ, Ï) { 3256 var point = rotate(λ, Ï); 3257 if (pointVisible(λ = point[0], Ï = point[1])) listener.point(λ, Ï); 3258 } 3259 function pointLine(λ, Ï) { 3260 var point = rotate(λ, Ï); 3261 line.point(point[0], point[1]); 3262 } 3263 function lineStart() { 3264 clip.point = pointLine; 3265 line.lineStart(); 3266 } 3267 function lineEnd() { 3268 clip.point = point; 3269 line.lineEnd(); 3270 } 3271 var segments; 3272 var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygon, ring; 3273 function pointRing(λ, Ï) { 3274 ring.push([ λ, Ï ]); 3275 var point = rotate(λ, Ï); 3276 ringListener.point(point[0], point[1]); 3277 } 3278 function ringStart() { 3279 ringListener.lineStart(); 3280 ring = []; 3281 } 3282 function ringEnd() { 3283 pointRing(ring[0][0], ring[0][1]); 3284 ringListener.lineEnd(); 3285 var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; 3286 ring.pop(); 3287 polygon.push(ring); 3288 ring = null; 3289 if (!n) return; 3290 if (clean & 1) { 3291 segment = ringSegments[0]; 3292 var n = segment.length - 1, i = -1, point; 3293 listener.lineStart(); 3294 while (++i < n) listener.point((point = segment[i])[0], point[1]); 3295 listener.lineEnd(); 3296 return; 3297 } 3298 if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); 3299 segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); 3300 } 3301 return clip; 3302 }; 3303 } 3304 function d3_geo_clipSegmentLength1(segment) { 3305 return segment.length > 1; 3306 } 3307 function d3_geo_clipBufferListener() { 3308 var lines = [], line; 3309 return { 3310 lineStart: function() { 3311 lines.push(line = []); 3312 }, 3313 point: function(λ, Ï) { 3314 line.push([ λ, Ï ]); 3315 }, 3316 lineEnd: d3_noop, 3317 buffer: function() { 3318 var buffer = lines; 3319 lines = []; 3320 line = null; 3321 return buffer; 3322 }, 3323 rejoin: function() { 3324 if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); 3325 } 3326 }; 3327 } 3328 function d3_geo_clipSort(a, b) { 3329 return ((a = a.x)[0] < 0 ? a[1] - halfÏ - ε : halfÏ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfÏ - ε : halfÏ - b[1]); 3330 } 3331 function d3_geo_pointInPolygon(point, polygon) { 3332 var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; 3333 d3_geo_areaRingSum.reset(); 3334 for (var i = 0, n = polygon.length; i < n; ++i) { 3335 var ring = polygon[i], m = ring.length; 3336 if (!m) continue; 3337 var point0 = ring[0], λ0 = point0[0], Ï0 = point0[1] / 2 + Ï / 4, sinÏ0
3337= Math.sin(Ï0), cosÏ0 = Math.cos(Ï0), j = 1; 3338 while (true) { 3339 if (j === m) j = 0; 3340 point = ring[j]; 3341 var λ = point[0], Ï = point[1] / 2 + Ï / 4, sinÏ = Math.sin(Ï), cosÏ = Math.cos(Ï), dλ = λ - λ0, antimeridian = abs(dλ) > Ï, k = sinÏ0 * sinÏ; 3342 d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(dλ), cosÏ0 * cosÏ + k * Math.cos(dλ))); 3343 polarAngle += antimeridian ? dλ + (dλ >= 0 ? Ï : -Ï) : dλ; 3344 if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { 3345 var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); 3346 d3_geo_cartesianNormalize(arc); 3347 var intersection = d3_geo_cartesianCross(meridianNormal, arc); 3348 d3_geo_cartesianNormalize(intersection); 3349 var Ïarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); 3350 if (parallel > Ïarc || parallel === Ïarc && (arc[0] || arc[1])) { 3351 winding += antimeridian ^ dλ >= 0 ? 1 : -1; 3352 } 3353 } 3354 if (!j++) break; 3355 λ0 = λ, sinÏ0 = sinÏ, cosÏ0 = cosÏ, point0 = point; 3356 } 3357 } 3358 return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; 3359 } 3360 var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -Ï, -Ï / 2 ]); 3361 function d3_geo_clipAntimeridianLine(listener) { 3362 var λ0 = NaN, Ï0 = NaN, sλ0 = NaN, clean; 3363 return { 3364 lineStart: function() { 3365 listener.lineStart(); 3366 clean = 1; 3367 }, 3368 point: function(λ1, Ï1) { 3369 var sλ1 = λ1 > 0 ? Ï : -Ï, dλ = abs(λ1 - λ0); 3370 if (abs(dλ - Ï) < ε) { 3371 listener.point(λ0, Ï0 = (Ï0 + Ï1) / 2 > 0 ? halfÏ : -halfÏ); 3372 listener.point(sλ0, Ï0); 3373 listener.lineEnd(); 3374 listener.lineStart(); 3375 listener.point(sλ1, Ï0); 3376 listener.point(λ1, Ï0); 3377 clean = 0; 3378 } else if (sλ0 !== sλ1 && dλ >= Ï) { 3379 if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; 3380 if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; 3381 Ï0 = d3_geo_clipAntimeridianIntersect(λ0, Ï0, λ1, Ï1); 3382 listener.point(sλ0, Ï0); 3383 listener.lineEnd(); 3384 listener.lineStart(); 3385 listener.point(sλ1, Ï0); 3386 clean = 0; 3387 } 3388 listener.point(λ0 = λ1, Ï0 = Ï1); 3389 sλ0 = sλ1; 3390 }, 3391 lineEnd: function() { 3392 listener.lineEnd(); 3393 λ0 = Ï0 = NaN; 3394 }, 3395 clean: function() { 3396 return 2 - clean; 3397 } 3398 }; 3399 } 3400 function d3_geo_clipAntimeridianIntersect(λ0, Ï0, λ1, Ï1) { 3401 var cosÏ0, cosÏ1, sinλ0_λ1 = Math.sin(λ0 - λ1); 3402 return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(Ï0) * (cosÏ1 = Math.cos(Ï1)) * Math.sin(λ1) - Math.sin(Ï1) * (cosÏ0 = Math.cos(Ï0)) * Math.sin(λ0)) / (cosÏ0 * cosÏ1 * sinλ0_λ1)) : (Ï0 + Ï1) / 2; 3403 } 3404 function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { 3405 var Ï; 3406 if (from == null) { 3407 Ï = direction * halfÏ; 3408 listener.point(-Ï, Ï); 3409 listener.point(0, Ï); 3410 listener.point(Ï, Ï); 3411 listener.point(Ï, 0); 3412 listener.point(Ï, -Ï); 3413 listener.point(0, -Ï); 3414 listener.point(-Ï, -Ï); 3415 listener.point(-Ï, 0); 3416 listener.point(-Ï, Ï); 3417 } else if (abs(from[0] - to[0]) > ε) { 3418 var s = from[0] < to[0] ? Ï : -Ï; 3419 Ï = direction * s / 2; 3420 listener.point(-s, Ï); 3421 listener.point(0, Ï); 3422 listener.point(s, Ï); 3423 } else { 3424 listener.point(to[0], to[1]); 3425 } 3426 } 3427 function d3_geo_clipCircle(radius) { 3428 var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); 3429 return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -Ï, radius - Ï ]); 3430 function visible(λ, Ï) { 3431 return Math.cos(λ) * Math.cos(Ï) > cr; 3432 } 3433 function clipLine(listener) { 3434 var point0, c0, v0, v00, clean; 3435 return { 3436 lineStart: function() { 3437 v00 = v0 = false;
vendor: 5,172 bytes, lines 3438-3581
3438 clean = 1; 3439 }, 3440 point: function(λ, Ï) { 3441 var point1 = [ λ, Ï ], point2, v = visible(λ, Ï), c = smallRadius ? v ? 0 : code(λ, Ï) : v ? code(λ + (λ < 0 ? Ï : -Ï), Ï) : 0; 3442 if (!point0 && (v00 = v0 = v)) listener.lineStart(); 3443 if (v !== v0) { 3444 point2 = intersect(point0, point1); 3445 if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { 3446 point1[0] += ε; 3447 point1[1] += ε; 3448 v = visible(point1[0], point1[1]); 3449 } 3450 } 3451 if (v !== v0) { 3452 clean = 0; 3453 if (v) { 3454 listener.lineStart(); 3455 point2 = intersect(point1, point0); 3456 listener.point(point2[0], point2[1]); 3457 } else { 3458 point2 = intersect(point0, point1); 3459 listener.point(point2[0], point2[1]); 3460 listener.lineEnd(); 3461 } 3462 point0 = point2; 3463 } else if (notHemisphere && point0 && smallRadius ^ v) { 3464 var t; 3465 if (!(c & c0) && (t = intersect(point1, point0, true))) { 3466 clean = 0; 3467 if (smallRadius) { 3468 listener.lineStart(); 3469 listener.point(t[0][0], t[0][1]); 3470 listener.point(t[1][0], t[1][1]); 3471 listener.lineEnd(); 3472 } else { 3473 listener.point(t[1][0], t[1][1]); 3474 listener.lineEnd(); 3475 listener.lineStart(); 3476 listener.point(t[0][0], t[0][1]); 3477 } 3478 } 3479 } 3480 if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { 3481 listener.point(point1[0], point1[1]); 3482 } 3483 point0 = point1, v0 = v, c0 = c; 3484 }, 3485 lineEnd: function() { 3486 if (v0) listener.lineEnd(); 3487 point0 = null; 3488 }, 3489 clean: function() { 3490 return clean | (v00 && v0) << 1; 3491 } 3492 }; 3493 } 3494 function intersect(a, b, two) { 3495 var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); 3496 var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; 3497 if (!determinant) return !two && a; 3498 var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); 3499 d3_geo_cartesianAdd(A, B); 3500 var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); 3501 if (t2 < 0) return; 3502 var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); 3503 d3_geo_cartesianAdd(q, A); 3504 q = d3_geo_spherical(q); 3505 if (!two) return q; 3506 var λ0 = a[0], λ1 = b[0], Ï0 = a[1], Ï1 = b[1], z; 3507 if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; 3508 var δλ = λ1 - λ0, polar = abs(δλ - Ï) < ε, meridian = polar || δλ < ε; 3509 if (!polar && Ï1 < Ï0) z = Ï0, Ï0 = Ï1, Ï1 = z; 3510 if (meridian ? polar ? Ï0 + Ï1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? Ï0 : Ï1) : Ï0 <= q[1] && q[1] <= Ï1 : δλ > Ï ^ (λ0 <= q[0] && q[0] <= λ1)) { 3511 var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); 3512 d3_geo_cartesianAdd(q1, A); 3513 return [ q, d3_geo_spherical(q1) ]; 3514 } 3515 } 3516 function code(λ, Ï) { 3517 var r = smallRadius ? radius : Ï - radius, code = 0; 3518 if (λ < -r) code |= 1; else if (λ > r) code |= 2; 3519 if (Ï < -r) code |= 4; else if (Ï > r) code |= 8; 3520 return code; 3521 } 3522 } 3523 function d3_geom_clipLine(x0, y0, x1, y1) { 3524 return function(line) { 3525 var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r; 3526 r = x0 - ax; 3527 if (!dx && r > 0) return; 3528 r /= dx; 3529 if (dx < 0) { 3530 if (r < t0) return; 3531 if (r < t1) t1 = r; 3532 } else if (dx > 0) { 3533 if (r > t1) return; 3534 if (r > t0) t0 = r; 3535 } 3536 r = x1 - ax; 3537 if (!dx && r < 0) return; 3538 r /= dx; 3539 if (dx < 0) { 3540 if (r > t1) return; 3541 if (r > t0) t0 = r; 3542 } else if (dx > 0) { 3543 if (r < t0) return; 3544 if (r < t1) t1 = r; 3545 } 3546 r = y0 - ay; 3547 if (!dy && r > 0) return; 3548 r /= dy; 3549 if (dy < 0) { 3550 if (r < t0) return; 3551 if (r < t1) t1 = r; 3552 } else if (dy > 0) { 3553 if (r > t1) return; 3554 if (r > t0) t0 = r; 3555 } 3556 r = y1 - ay; 3557 if (!dy && r < 0) return; 3558 r /= dy; 3559 if (dy < 0) { 3560 if (r > t1) return; 3561 if (r > t0) t0 = r; 3562 } else if (dy > 0) { 3563 if (r < t0) return; 3564 if (r < t1) t1 = r; 3565 } 3566 if (t0 > 0) line.a = { 3567 x: ax + t0 * dx, 3568 y: ay + t0 * dy 3569 }; 3570 if (t1 < 1) line.b = { 3571 x: ax + t1 * dx, 3572 y: ay + t1 * dy 3573 }; 3574 return line; 3575 }; 3576 } 3577 var d3_geo_clipExtentMAX = 1e9; 3578 d3.geo.clipExtent = function() { 3579 var x0, y0, x1, y1, stream, clip, clipExtent = { 3580 stream: function(output) { 3581 if (stream) stream.valid = false;
3582 stream = clip(output); 3583 stream.valid = true; 3584 return stream; 3585 }, 3586 extent: function(_) { 3587 if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; 3588 clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); 3589 if (stream) stream.valid = false, stream = null; 3590 return clipExtent; 3591 } 3592 }; 3593 return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]); 3594 }; 3595 function d3_geo_clipExtent(x0, y0, x1, y1) { 3596 return function(listener) { 3597 var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring; 3598 var clip = { 3599 point: point, 3600 lineStart: lineStart, 3601 lineEnd: lineEnd, 3602 polygonStart: function() { 3603 listener = bufferListener; 3604 segments = []; 3605 polygon = []; 3606 clean = true; 3607 }, 3608 polygonEnd: function() { 3609 listener = listener_; 3610 segments = d3.merge(segments); 3611 var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length; 3612 if (inside || visible) { 3613 listener.polygonStart(); 3614 if (inside) { 3615 listener.lineStart(); 3616 interpolate(null, null, 1, listener); 3617 listener.lineEnd(); 3618 } 3619 if (visible) { 3620 d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); 3621 } 3622 listener.polygonEnd(); 3623 } 3624 segments = polygon = ring = null; 3625 } 3626 }; 3627 function insidePolygon(p) { 3628 var wn = 0, n = polygon.length, y = p[1]; 3629 for (var i = 0; i < n; ++i) { 3630 for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { 3631 b = v[j]; 3632 if (a[1] <= y) { 3633 if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; 3634 } else { 3635 if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; 3636 } 3637 a = b; 3638 } 3639 } 3640 return wn !== 0; 3641 } 3642 function interpolate(from, to, direction, listener) { 3643 var a = 0, a1 = 0; 3644 if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { 3645 do { 3646 listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); 3647 } while ((a = (a + direction + 4) % 4) !== a1); 3648 } else { 3649 listener.point(to[0], to[1]); 3650 } 3651 } 3652 function pointVisible(x, y) { 3653 return x0 <= x && x <= x1 && y0 <= y && y <= y1; 3654 } 3655 function point(x, y) { 3656 if (pointVisible(x, y)) listener.point(x, y); 3657 } 3658 var x__, y__, v__, x_, y_, v_, first, clean; 3659 function lineStart() { 3660 clip.point = linePoint; 3661 if (polygon) polygon.push(ring = []); 3662 first = true; 3663 v_ = false; 3664 x_ = y_ = NaN; 3665 } 3666 function lineEnd() { 3667 if (segments) { 3668 linePoint(x__, y__); 3669 if (v__ && v_) bufferListener.rejoin(); 3670 segments.push(bufferListener.buffer()); 3671 } 3672 clip.point = point; 3673 if (v_) listener.lineEnd(); 3674 } 3675 function linePoint(x, y) { 3676 x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); 3677 y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); 3678 var v = pointVisible(x, y); 3679 if (polygon) ring.push([ x, y ]); 3680 if (first) { 3681 x__ = x, y__ = y, v__ = v; 3682 first = false; 3683 if (v) { 3684 listener.lineStart(); 3685 listener.point(x, y); 3686 } 3687 } else { 3688 if (v && v_) listener.point(x, y); else { 3689 var l = { 3690 a: { 3691 x: x_, 3692 y: y_ 3693 }, 3694 b: { 3695 x: x, 3696 y: y 3697 } 3698 }; 3699 if (clipLine(l)) { 3700 if (!v_) { 3701 listener.lineStart(); 3702 listener.point(l.a.x, l.a.y); 3703 } 3704 listener.point(l.b.x, l.b.y); 3705 if (!v) listener.lineEnd(); 3706 clean = false;
3707 } else if (v) { 3708 listener.lineStart(); 3709 listener.point(x, y); 3710 clean = false; 3711 } 3712 } 3713 } 3714 x_ = x, y_ = y, v_ = v; 3715 } 3716 return clip; 3717 }; 3718 function corner(p, direction) { 3719 return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; 3720 } 3721 function compare(a, b) { 3722 return comparePoints(a.x, b.x); 3723 } 3724 function comparePoints(a, b) { 3725 var ca = corner(a, 1), cb = corner(b, 1); 3726 return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; 3727 } 3728 } 3729 function d3_geo_compose(a, b) { 3730 function compose(x, y) { 3731 return x = a(x, y), b(x[0], x[1]); 3732 } 3733 if (a.invert && b.invert) compose.invert = function(x, y) { 3734 return x = b.invert(x, y), x && a.invert(x[0], x[1]); 3735 }; 3736 return compose; 3737 } 3738 function d3_geo_conic(projectAt) { 3739 var Ï0 = 0, Ï1 = Ï / 3, m = d3_geo_projectionMutator(projectAt), p = m(Ï0, Ï1); 3740 p.parallels = function(_) { 3741 if (!arguments.length) return [ Ï0 / Ï * 180, Ï1 / Ï * 180 ]; 3742 return m(Ï0 = _[0] * Ï / 180, Ï1 = _[1] * Ï / 180); 3743 }; 3744 return p; 3745 } 3746 function d3_geo_conicEqualArea(Ï0, Ï1) { 3747 var sinÏ0 = Math.sin(Ï0), n = (sinÏ0 + Math.sin(Ï1)) / 2, C = 1 + sinÏ0 * (2 * n - sinÏ0), Ï0 = Math.sqrt(C) / n; 3748 function forward(λ, Ï) { 3749 var Ï = Math.sqrt(C - 2 * n * Math.sin(Ï)) / n; 3750 return [ Ï * Math.sin(λ *= n), Ï0 - Ï * Math.cos(λ) ]; 3751 } 3752 forward.invert = function(x, y) { 3753 var Ï0_y = Ï0 - y; 3754 return [ Math.atan2(x, Ï0_y) / n, d3_asin((C - (x * x + Ï0_y * Ï0_y) * n * n) / (2 * n)) ]; 3755 }; 3756 return forward; 3757 } 3758 (d3.geo.conicEqualArea = function() { 3759 return d3_geo_conic(d3_geo_conicEqualArea); 3760 }).raw = d3_geo_conicEqualArea; 3761 d3.geo.albers = function() { 3762 return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); 3763 }; 3764 d3.geo.albersUsa = function() { 3765 var lower48 = d3.geo.albers(); 3766 var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); 3767 var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); 3768 var point, pointStream = { 3769 point: function(x, y) { 3770 point = [ x, y ]; 3771 } 3772 }, lower48Point, alaskaPoint, hawaiiPoint; 3773 function albersUsa(coordinates) { 3774 var x = coordinates[0], y = coordinates[1]; 3775 point = null; 3776 (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); 3777 return point; 3778 } 3779 albersUsa.invert = function(coordinates) { 3780 var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; 3781 return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); 3782 }; 3783 albersUsa.stream = function(stream) { 3784 var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); 3785 return { 3786 point: function(x, y) { 3787 lower48Stream.point(x, y); 3788 alaskaStream.point(x, y); 3789 hawaiiStream.point(x, y); 3790 }, 3791 sphere: function() { 3792 lower48Stream.sphere(); 3793 alaskaStream.sphere(); 3794 hawaiiStream.sphere(); 3795 }, 3796 lineStart: function() { 3797 lower48Stream.lineStart(); 3798 alaskaStream.lineStart(); 3799 hawaiiStream.lineStart(); 3800 }, 3801 lineEnd: function() { 3802 lower48Stream.lineEnd(); 3803 alaskaStream.lineEnd(); 3804 hawaiiStream.lineEnd(); 3805 }, 3806 polygonStart: function() { 3807 lower48Stream.polygonStart(); 3808 alaskaStream.polygonStart(); 3809 hawaiiStream.polygonStart(); 3810 }, 3811 polygonEnd: function() { 3812 lower48Stream.polygonEnd(); 3813 alaskaStream.polygonEnd(); 3814 hawaiiStream.polygonEnd(); 3815 } 3816 }; 3817 }; 3818 albersUsa.precision = function(_) { 3819 if (!arguments.length) return lower48.precision(); 3820 lower48.precision(_); 3821 alaska.precision(_); 3822 hawaii.precision(_); 3823 return albersUsa; 3824 }; 3825 albersUsa.scale = function(_) { 3826 if (!arguments.length) return lower48.scale(); 3827 lower48.scale(_); 3828 alaska.scale(_ * .35); 3829 hawaii.scale(_); 3830 return albersUsa.translate(lower48.translate()); 3831 }; 3832 albersUsa.translate = function(_) { 3833 if (!arguments.length) return lower48.translate(); 3834 var k = lower48.scale(), x = +_[0], y = +_[1]; 3835 lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; 3836 alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; 3837 hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; 3838 return albersUsa; 3839 }; 3840 return albersUsa.scale(1070); 3841 }; 3842 var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { 3843 point: d3_noop, 3844 lineStart: d3_noop, 3845 lineEnd: d3_noop, 3846 polygonStart: function() { 3847 d3_geo_pathAreaPolygon = 0; 3848 d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; 3849 }, 3850 polygonEnd: function() { 3851 d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; 3852 d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); 3853 } 3854 }; 3855 function d3_geo_pathAreaRingStart() { 3856 var x00, y00, x0, y0; 3857 d3_geo_pathArea.point = function(x, y) { 3858 d3_geo_pathArea.point = nextPoint; 3859 x00 = x0 = x, y00 = y0 = y; 3860 }; 3861 function nextPoint(x, y) { 3862 d3_geo_pathAreaPolygon += y0 * x - x0 * y; 3863 x0 = x, y0 = y; 3864 } 3865 d3_geo_pathArea.lineEnd = function() { 3866 nextPoint(x00, y00); 3867 }; 3868 } 3869 var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; 3870 var d3_geo_pathBounds = { 3871 point: d3_geo_pathBoundsPoint, 3872 lineStart: d3_noop, 3873 lineEnd: d3_noop, 3874 polygonStart: d3_noop, 3875 polygonEnd: d3_noop 3876 }; 3877 function d3_geo_pathBoundsPoint(x, y) { 3878 if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; 3879 if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; 3880 if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; 3881 if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; 3882 } 3883 function d3_geo_pathBuffer() { 3884 var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; 3885 var stream = { 3886 point: point, 3887 lineStart: function() { 3888 stream.point = pointLineStart; 3889 }, 3890 lineEnd: lineEnd, 3891 polygonStart: function() { 3892 stream.lineEnd = lineEndPolygon; 3893 }, 3894 polygonEnd: function() { 3895 stream.lineEnd = lineEnd; 3896 stream.point = point; 3897 }, 3898 pointRadius: function(_) { 3899 pointCircle = d3_geo_pathBufferCircle(_); 3900 return stream; 3901 }, 3902 result: function() { 3903 if (buffer.length) { 3904 var result = buffer.join(""); 3905 buffer = []; 3906 return result; 3907 } 3908 } 3909 }; 3910 function point(x, y) { 3911 buffer.push("M", x, ",", y, pointCircle); 3912 } 3913 function pointLineStart(x, y) { 3914 buffer.push("M", x, ",", y); 3915 stream.point = pointLine; 3916 } 3917 function pointLine(x, y) { 3918 buffer.push("L", x, ",", y); 3919 } 3920 function lineEnd() { 3921 stream.point = point; 3922 } 3923 function lineEndPolygon() { 3924 buffer.push("Z"); 3925 } 3926 return stream; 3927 } 3928 function d3_geo_pathBufferCircle(radius) {
3929 return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; 3930 } 3931 var d3_geo_pathCentroid = { 3932 point: d3_geo_pathCentroidPoint, 3933 lineStart: d3_geo_pathCentroidLineStart, 3934 lineEnd: d3_geo_pathCentroidLineEnd, 3935 polygonStart: function() { 3936 d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; 3937 }, 3938 polygonEnd: function() { 3939 d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; 3940 d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; 3941 d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; 3942 } 3943 }; 3944 function d3_geo_pathCentroidPoint(x, y) { 3945 d3_geo_centroidX0 += x; 3946 d3_geo_centroidY0 += y; 3947 ++d3_geo_centroidZ0; 3948 } 3949 function d3_geo_pathCentroidLineStart() { 3950 var x0, y0; 3951 d3_geo_pathCentroid.point = function(x, y) { 3952 d3_geo_pathCentroid.point = nextPoint; 3953 d3_geo_pathCentroidPoint(x0 = x, y0 = y); 3954 }; 3955 function nextPoint(x, y) { 3956 var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); 3957 d3_geo_centroidX1 += z * (x0 + x) / 2; 3958 d3_geo_centroidY1 += z * (y0 + y) / 2; 3959 d3_geo_centroidZ1 += z; 3960 d3_geo_pathCentroidPoint(x0 = x, y0 = y); 3961 } 3962 } 3963 function d3_geo_pathCentroidLineEnd() { 3964 d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; 3965 } 3966 function d3_geo_pathCentroidRingStart() { 3967 var x00, y00, x0, y0; 3968 d3_geo_pathCentroid.point = function(x, y) { 3969 d3_geo_pathCentroid.point = nextPoint; 3970 d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); 3971 }; 3972 function nextPoint(x, y) { 3973 var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); 3974 d3_geo_centroidX1 += z * (x0 + x) / 2; 3975 d3_geo_centroidY1 += z * (y0 + y) / 2; 3976 d3_geo_centroidZ1 += z; 3977 z = y0 * x - x0 * y; 3978 d3_geo_centroidX2 += z * (x0 + x); 3979 d3_geo_centroidY2 += z * (y0 + y); 3980 d3_geo_centroidZ2 += z * 3; 3981 d3_geo_pathCentroidPoint(x0 = x, y0 = y); 3982 } 3983 d3_geo_pathCentroid.lineEnd = function() { 3984 nextPoint(x00, y00); 3985 }; 3986 } 3987 function d3_geo_pathContext(context) { 3988 var pointRadius = 4.5; 3989 var stream = { 3990 point: point, 3991 lineStart: function() { 3992 stream.point = pointLineStart; 3993 }, 3994 lineEnd: lineEnd, 3995 polygonStart: function() { 3996 stream.lineEnd = lineEndPolygon; 3997 }, 3998 polygonEnd: function() { 3999 stream.lineEnd = lineEnd; 4000 stream.point = point; 4001 }, 4002 pointRadius: function(_) { 4003 pointRadius = _; 4004 return stream; 4005 }, 4006 result: d3_noop 4007 }; 4008 function point(x, y) { 4009 context.moveTo(x, y); 4010 context.arc(x, y, pointRadius, 0, Ï); 4011 } 4012 function pointLineStart(x, y) { 4013 context.moveTo(x, y); 4014 stream.point = pointLine; 4015 } 4016 function pointLine(x, y) { 4017 context.lineTo(x, y); 4018 } 4019 function lineEnd() { 4020 stream.point = point; 4021 } 4022 function lineEndPolygon() { 4023 context.closePath(); 4024 } 4025 return stream; 4026 } 4027 function d3_geo_resample(project) { 4028 var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; 4029 function resample(stream) { 4030 return (maxDepth ? resampleRecursive : resampleNone)(stream); 4031 } 4032 function resampleNone(stream) { 4033 return d3_geo_transformPoint(stream, function(x, y) { 4034 x = project(x, y); 4035 stream.point(x[0], x[1]); 4036 }); 4037 } 4038 function resampleRecursive(stream) { 4039 var λ00, Ï00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; 4040 var resample = { 4041 point: point, 4042 lineStart: lineStart, 4043 lineEnd: lineEnd, 4044 polygonStart: function() { 4045 stream.polygonStart(); 4046 resample.lineStart = ringStart; 4047 }, 4048 polygonEnd: function() { 4049 stream.polygonEnd(); 4050 resample.lineStart = lineStart; 4051 } 4052 }; 4053 function point(x, y) { 4054 x = project(x, y); 4055 stream.point(x[0], x[1]); 4056 } 4057 function lineStart() { 4058 x0 = NaN; 4059 resample.point = linePoint; 4060 stream.lineStart(); 4061 } 4062 function linePoint(λ, Ï) { 4063 var c = d3_geo_cartesian([ λ, Ï ]), p = project(λ, Ï); 4064 resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); 4065 stream.point(x0, y0); 4066 } 4067 function lineEnd() { 4068 resample.point = point; 4069 stream.lineEnd(); 4070 } 4071 function ringStart() { 4072 lineStart(); 4073 resample.point = ringPoint; 4074 resample.lineEnd = ringEnd; 4075 } 4076 function ringPoint(λ, Ï) { 4077 linePoint(λ00 = λ, Ï00 = Ï), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; 4078 resample.point = linePoint; 4079 } 4080 function ringEnd() { 4081 resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); 4082 resample.lineEnd = lineEnd; 4083 lineEnd(); 4084 } 4085 return resample; 4086 } 4087 function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { 4088 var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; 4089 if (d2 > 4 * δ2 && depth--) { 4090 var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), Ï2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, Ï2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; 4091 if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { 4092 resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); 4093 stream.point(x2, y2); 4094 resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); 4095 } 4096 } 4097 } 4098 resample.precision = function(_) { 4099 if (!arguments.length) return Math.sqrt(δ2); 4100 maxDepth = (δ2 = _ * _) > 0 && 16; 4101 return resample; 4102 }; 4103 return resample; 4104 } 4105 d3.geo.path = function() { 4106 var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; 4107 function path(object) { 4108 if (object) { 4109 if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); 4110 if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); 4111 d3.geo.stream(object, cacheStream); 4112 } 4113 return contextStream.result(); 4114 } 4115 path.area = function(object) { 4116 d3_geo_pathAreaSum = 0; 4117 d3.geo.stream(object, projectStream(d3_geo_pathArea)); 4118 return d3_geo_pathAreaSum; 4119 };
4120 path.centroid = function(object) { 4121 d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; 4122 d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); 4123 return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; 4124 }; 4125 path.bounds = function(object) { 4126 d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); 4127 d3.geo.stream(object, projectStream(d3_geo_pathBounds)); 4128 return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; 4129 }; 4130 path.projection = function(_) { 4131 if (!arguments.length) return projection; 4132 projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; 4133 return reset(); 4134 }; 4135 path.context = function(_) { 4136 if (!arguments.length) return context; 4137 contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); 4138 if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); 4139 return reset(); 4140 }; 4141 path.pointRadius = function(_) { 4142 if (!arguments.length) return pointRadius; 4143 pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); 4144 return path; 4145 }; 4146 function reset() { 4147 cacheStream = null; 4148 return path; 4149 } 4150 return path.projection(d3.geo.albersUsa()).context(null); 4151 }; 4152 function d3_geo_pathProjectStream(project) { 4153 var resample = d3_geo_resample(function(x, y) { 4154 return project([ x * d3_degrees, y * d3_degrees ]); 4155 }); 4156 return function(stream) { 4157 return d3_geo_projectionRadians(resample(stream)); 4158 }; 4159 } 4160 d3.geo.transform = function(methods) { 4161 return { 4162 stream: function(stream) { 4163 var transform = new d3_geo_transform(stream); 4164 for (var k in methods) transform[k] = methods[k]; 4165 return transform; 4166 } 4167 }; 4168 }; 4169 function d3_geo_transform(stream) { 4170 this.stream = stream; 4171 } 4172 d3_geo_transform.prototype = { 4173 point: function(x, y) { 4174 this.stream.point(x, y); 4175 }, 4176 sphere: function() { 4177 this.stream.sphere(); 4178 }, 4179 lineStart: function() { 4180 this.stream.lineStart(); 4181 }, 4182 lineEnd: function() { 4183 this.stream.lineEnd(); 4184 }, 4185 polygonStart: function() { 4186 this.stream.polygonStart(); 4187 }, 4188 polygonEnd: function() { 4189 this.stream.polygonEnd(); 4190 } 4191 }; 4192 function d3_geo_transformPoint(stream, point) { 4193 return { 4194 point: point, 4195 sphere: function() { 4196 stream.sphere(); 4197 }, 4198 lineStart: function() { 4199 stream.lineStart(); 4200 }, 4201 lineEnd: function() { 4202 stream.lineEnd(); 4203 }, 4204 polygonStart: function() { 4205 stream.polygonStart(); 4206 }, 4207 polygonEnd: function() { 4208 stream.polygonEnd(); 4209 } 4210 }; 4211 } 4212 d3.geo.projection = d3_geo_projection; 4213 d3.geo.projectionMutator = d3_geo_projectionMutator; 4214 function d3_geo_projection(project) { 4215 return d3_geo_projectionMutator(function() { 4216 return project; 4217 })(); 4218 } 4219 function d3_geo_projectionMutator(projectAt) { 4220 var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { 4221 x = project(x, y); 4222 return [ x[0] * k + δx, δy - x[1] * k ]; 4223 }), k = 150, x = 480, y = 250, λ = 0, Ï = 0, δλ = 0, Î´Ï = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; 4224 function projection(point) { 4225 point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); 4226 return [ point[0] * k + δx, δy - point[1] * k ]; 4227 } 4228 function invert(point) { 4229 point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); 4230 return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; 4231 } 4232 projection.stream = function(output) { 4233 if (stream) stream.valid = false;
4234 stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); 4235 stream.valid = true; 4236 return stream; 4237 }; 4238 projection.clipAngle = function(_) { 4239 if (!arguments.length) return clipAngle; 4240 preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); 4241 return invalidate(); 4242 }; 4243 projection.clipExtent = function(_) { 4244 if (!arguments.length) return clipExtent; 4245 clipExtent = _; 4246 postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; 4247 return invalidate(); 4248 }; 4249 projection.scale = function(_) { 4250 if (!arguments.length) return k; 4251 k = +_; 4252 return reset(); 4253 }; 4254 projection.translate = function(_) { 4255 if (!arguments.length) return [ x, y ]; 4256 x = +_[0]; 4257 y = +_[1]; 4258 return reset(); 4259 }; 4260 projection.center = function(_) { 4261 if (!arguments.length) return [ λ * d3_degrees, Ï * d3_degrees ]; 4262 λ = _[0] % 360 * d3_radians; 4263 Ï = _[1] % 360 * d3_radians; 4264 return reset(); 4265 }; 4266 projection.rotate = function(_) { 4267 if (!arguments.length) return [ δλ * d3_degrees, Î´Ï * d3_degrees, δγ * d3_degrees ]; 4268 δλ = _[0] % 360 * d3_radians; 4269 Î´Ï = _[1] % 360 * d3_radians; 4270 δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; 4271 return reset(); 4272 }; 4273 d3.rebind(projection, projectResample, "precision"); 4274 function reset() { 4275 projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δÏ, δγ), project); 4276 var center = project(λ, Ï); 4277 δx = x - center[0] * k; 4278 δy = y + center[1] * k; 4279 return invalidate(); 4280 }
4281 function invalidate() { 4282 if (stream) stream.valid = false, stream = null; 4283 return projection; 4284 } 4285 return function() { 4286 project = projectAt.apply(this, arguments); 4287 projection.invert = project.invert && invert; 4288 return reset(); 4289 }; 4290 } 4291 function d3_geo_projectionRadians(stream) { 4292 return d3_geo_transformPoint(stream, function(x, y) { 4293 stream.point(x * d3_radians, y * d3_radians); 4294 }); 4295 } 4296 function d3_geo_equirectangular(λ, Ï) { 4297 return [ λ, Ï ]; 4298 } 4299 (d3.geo.equirectangular = function() { 4300 return d3_geo_projection(d3_geo_equirectangular); 4301 }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; 4302 d3.geo.rotation = function(rotate) { 4303 rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); 4304 function forward(coordinates) { 4305 coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); 4306 return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; 4307 } 4308 forward.invert = function(coordinates) { 4309 coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); 4310 return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; 4311 }; 4312 return forward; 4313 }; 4314 function d3_geo_identityRotation(λ, Ï) { 4315 return [ λ > Ï ? λ - Ï : λ < -Ï ? λ + Ï : λ, Ï ]; 4316 } 4317 d3_geo_identityRotation.invert = d3_geo_equirectangular; 4318 function d3_geo_rotation(δλ, δÏ, δγ) { 4319 return δλ ? Î´Ï || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ
4319), d3_geo_rotationÏγ(δÏ, δγ)) : d3_geo_rotationλ(δλ) : Î´Ï || δγ ? d3_geo_rotationÏγ(δÏ, δγ) : d3_geo_identityRotation; 4320 } 4321 function d3_geo_forwardRotationλ(δλ) { 4322 return function(λ, Ï) { 4323 return λ += δλ, [ λ > Ï ? λ - Ï : λ < -Ï ? λ + Ï : λ, Ï ]; 4324 }; 4325 } 4326 function d3_geo_rotationλ(δλ) { 4327 var rotation = d3_geo_forwardRotationλ(δλ); 4328 rotation.invert = d3_geo_forwardRotationλ(-δλ); 4329 return rotation; 4330 } 4331 function d3_geo_rotationÏγ(δÏ, δγ) { 4332 var cosÎ´Ï = Math.cos(δÏ), sinÎ´Ï = Math.sin(δÏ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); 4333 function rotation(λ, Ï) { 4334 var cosÏ = Math.cos(Ï), x = Math.cos(λ) * cosÏ, y = Math.sin(λ) * cosÏ, z = Math.sin(Ï), k = z * cosÎ´Ï + x * sinδÏ; 4335 return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosÎ´Ï - z * sinδÏ), d3_asin(k * cosδγ + y * sinδγ) ]; 4336 } 4337 rotation.invert = function(λ, Ï) { 4338 var cosÏ = Math.cos(Ï), x = Math.cos(λ) * cosÏ, y = Math.sin(λ) * cosÏ, z = Math.sin(Ï), k = z * cosδγ - y * sinδγ; 4339 return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosÎ´Ï + k * sinδÏ), d3_asin(k * cosÎ´Ï - x * sinδÏ) ]; 4340 }; 4341 return rotation; 4342 } 4343 d3.geo.circle = function() { 4344 var origin = [ 0, 0 ], angle, precision = 6, interpolate; 4345 function circle() { 4346 var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; 4347 interpolate(null, null, 1, { 4348 point: function(x, y) { 4349 ring.push(x = rotate(x, y)); 4350 x[0] *= d3_degrees, x[1] *= d3_degrees; 4351 } 4352 }); 4353 return { 4354 type: "Polygon", 4355 coordinates: [ ring ] 4356 }; 4357 } 4358 circle.origin = function(x) { 4359 if (!arguments.length) return origin; 4360 origin = x; 4361 return circle; 4362 }; 4363 circle.angle = function(x) { 4364 if (!arguments.length) return angle; 4365 interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); 4366 return circle; 4367 }; 4368 circle.precision = function(_) { 4369 if (!arguments.length) return precision; 4370 interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); 4371 return circle; 4372 }; 4373 return circle.angle(90); 4374 }; 4375 function d3_geo_circleInterpolate(radius, precision) { 4376 var cr = Math.cos(radius), sr = Math.sin(radius); 4377 return function(from, to, direction, listener) { 4378 var step = direction * precision; 4379 if (from != null) { 4380 from = d3_geo_circleAngle(cr, from); 4381 to = d3_geo_circleAngle(cr, to); 4382 if (direction > 0 ? from < to : from > to) from += direction * Ï; 4383 } else { 4384 from = radius + direction * Ï; 4385 to = radius - .5 * step; 4386 } 4387 for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { 4388 listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); 4389 } 4390 }; 4391 } 4392 function d3_geo_circleAngle(cr, point) { 4393 var a = d3_geo_cartesian(point); 4394 a[0] -= cr; 4395 d3_geo_cartesianNormalize(a); 4396 var angle = d3_acos(-a[1]); 4397 return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); 4398 } 4399 d3.geo.distance = function(a, b) { 4400 var Îλ = (b[0] - a[0]) * d3_radians, Ï0 = a[1] * d3_radians, Ï1 = b[1] * d3_radians, sinÎλ = Math.sin(Îλ), cosÎλ = Math.cos(Îλ), sinÏ0 = Math.sin(Ï0), cosÏ0 = Math.cos(Ï0), sinÏ1 = Math.sin(Ï1), cosÏ1 = Math.cos(Ï1), t; 4401 return Math.atan2(Math.sqrt((t = cosÏ1 * sinÎλ) * t + (t = cosÏ0 * sinÏ1 - sinÏ0 * cosÏ1 * cosÎλ) * t), sinÏ0 * sinÏ1 + cosÏ0 * cosÏ1 * cosÎλ); 4402 }; 4403 d3.geo.graticule = function() { 4404 var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; 4405 function graticule() { 4406 return { 4407 type: "MultiLineString", 4408 coordinates: lines() 4409 }; 4410 } 4411 function lines() { 4412 return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { 4413 return abs(x % DX) > ε; 4414 }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { 4415 return abs(y % DY) > ε; 4416 }).map(y)); 4417 } 4418 graticule.lines = function() { 4419 return lines().map(function(coordinates) { 4420 return { 4421 type: "LineString", 4422 coordinates: coordinates 4423 }; 4424 }); 4425 }; 4426 graticule.outline = function() { 4427 return { 4428 type: "Polygon", 4429 coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] 4430 }; 4431 }; 4432 graticule.extent = function(_) { 4433 if (!arguments.length) return graticule.minorExtent(); 4434 return graticule.majorExtent(_).minorExtent(_); 4435 }; 4436 graticule.majorExtent = function(_) { 4437 if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; 4438 X0 = +_[0][0], X1 = +_[1][0]; 4439 Y0 = +_[0][1], Y1 = +_[1][1]; 4440 if (X0 > X1) _ = X0, X0 = X1, X1 = _; 4441 if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; 4442 return graticule.precision(precision); 4443 }; 4444 graticule.minorExtent = function(_) { 4445 if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; 4446 x0 = +_[0][0], x1 = +_[1][0]; 4447 y0 = +_[0][1], y1 = +_[1][1]; 4448 if (x0 > x1) _ = x0, x0 = x1, x1 = _; 4449 if (y0 > y1) _ = y0, y0 = y1, y1 = _; 4450 return graticule.precision(precision); 4451 };
4452 graticule.step = function(_) { 4453 if (!arguments.length) return graticule.minorStep(); 4454 return graticule.majorStep(_).minorStep(_); 4455 }; 4456 graticule.majorStep = function(_) { 4457 if (!arguments.length) return [ DX, DY ]; 4458 DX = +_[0], DY = +_[1]; 4459 return graticule; 4460 }; 4461 graticule.minorStep = function(_) { 4462 if (!arguments.length) return [ dx, dy ]; 4463 dx = +_[0], dy = +_[1]; 4464 return graticule; 4465 }; 4466 graticule.precision = function(_) { 4467 if (!arguments.length) return precision; 4468 precision = +_; 4469 x = d3_geo_graticuleX(y0, y1, 90); 4470 y = d3_geo_graticuleY(x0, x1, precision); 4471 X = d3_geo_graticuleX(Y0, Y1, 90); 4472 Y = d3_geo_graticuleY(X0, X1, precision); 4473 return graticule; 4474 }; 4475 return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); 4476 }; 4477 function d3_geo_graticuleX(y0, y1, dy) { 4478 var y = d3.range(y0, y1 - ε, dy).concat(y1); 4479 return function(x) { 4480 return y.map(function(y) { 4481 return [ x, y ]; 4482 }); 4483 }; 4484 } 4485 function d3_geo_graticuleY(x0, x1, dx) { 4486 var x = d3.range(x0, x1 - ε, dx).concat(x1); 4487 return function(y) { 4488 return x.map(function(x) { 4489 return [ x, y ]; 4490 }); 4491 }; 4492 } 4493 function d3_source(d) { 4494 return d.source; 4495 } 4496 function d3_target(d) { 4497 return d.target; 4498 } 4499 d3.geo.greatArc = function() { 4500 var source = d3_source, source_, target = d3_target, target_; 4501 function greatArc() { 4502 return { 4503 type: "LineString", 4504 coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] 4505 }; 4506 } 4507 greatArc.distance = function() { 4508 return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); 4509 }; 4510 greatArc.source = function(_) { 4511 if (!arguments.length) return source; 4512 source = _, source_ = typeof _ === "function" ? null : _; 4513 return greatArc; 4514 }; 4515 greatArc.target = function(_) { 4516 if (!arguments.length) return target; 4517 target = _, target_ = typeof _ === "function" ? null : _; 4518 return greatArc; 4519 }; 4520 greatArc.precision = function() { 4521 return arguments.length ? greatArc : 0; 4522 }; 4523 return greatArc; 4524 }; 4525 d3.geo.interpolate = function(source, target) { 4526 return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); 4527 }; 4528 function d3_geo_interpolate(x0, y0, x1, y1) { 4529 var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); 4530 var interpolate = d ? function(t) { 4531 var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; 4532 return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; 4533 } : function() { 4534 return [ x0 * d3_degrees, y0 * d3_degrees ]; 4535 }; 4536 interpolate.distance = d; 4537 return interpolate; 4538 } 4539 d3.geo.length = function(object) { 4540 d3_geo_lengthSum = 0; 4541 d3.geo.stream(object, d3_geo_length); 4542 return d3_geo_lengthSum; 4543 }; 4544 var d3_geo_lengthSum; 4545 var d3_geo_length = { 4546 sphere: d3_noop, 4547 point: d3_noop, 4548 lineStart: d3_geo_lengthLineStart, 4549 lineEnd: d3_noop, 4550 polygonStart: d3_noop, 4551 polygonEnd: d3_noop 4552 }; 4553 function d3_geo_lengthLineStart() { 4554 var λ0, sinÏ0, cosÏ0; 4555 d3_geo_length.point = function(λ, Ï) { 4556 λ0 = λ * d3_radians, sinÏ0 = Math.sin(Ï *= d3_radians), cosÏ0 = Math.cos(Ï); 4557 d3_geo_length.point = nextPoint; 4558 }; 4559 d3_geo_length.lineEnd = function() { 4560 d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; 4561 }; 4562 function nextPoint(λ, Ï) { 4563 var sinÏ = Math.sin(Ï *= d3_radians), cosÏ = Math.cos(Ï), t = abs((λ *= d3_radians) - λ0), cosÎλ = Math.cos(t); 4564 d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosÏ * Math.sin(t)) * t + (t = cosÏ0 * sinÏ - sinÏ0 * cosÏ * cosÎλ) * t), sinÏ0 * sinÏ + cosÏ0 * cosÏ * cosÎλ);
4565 λ0 = λ, sinÏ0 = sinÏ, cosÏ0 = cosÏ; 4566 } 4567 } 4568 function d3_geo_azimuthal(scale, angle) { 4569 function azimuthal(λ, Ï) { 4570 var cosλ = Math.cos(λ), cosÏ = Math.cos(Ï), k = scale(cosλ * cosÏ); 4571 return [ k * cosÏ * Math.sin(λ), k * Math.sin(Ï) ]; 4572 } 4573 azimuthal.invert = function(x, y) { 4574 var Ï = Math.sqrt(x * x + y * y), c = angle(Ï), sinc = Math.sin(c), cosc = Math.cos(c); 4575 return [ Math.atan2(x * sinc, Ï * cosc), Math.asin(Ï && y * sinc / Ï) ]; 4576 }; 4577 return azimuthal; 4578 } 4579 var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosÏ) { 4580 return Math.sqrt(2 / (1 + cosλcosÏ)); 4581 }, function(Ï) { 4582 return 2 * Math.asin(Ï / 2); 4583 }); 4584 (d3.geo.azimuthalEqualArea = function() { 4585 return d3_geo_projection(d3_geo_azimuthalEqualArea); 4586 }).raw = d3_geo_azimuthalEqualArea; 4587 var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosÏ) { 4588 var c = Math.acos(cosλcosÏ); 4589 return c && c / Math.sin(c); 4590 }, d3_identity); 4591 (d3.geo.azimuthalEquidistant = function() { 4592 return d3_geo_projection(d3_geo_azimuthalEquidistant); 4593 }).raw = d3_geo_azimuthalEquidistant; 4594 function d3_geo_conicConformal(Ï0, Ï1) { 4595 var cosÏ0 = Math.cos(Ï0), t = function(Ï) { 4596 return Math.tan(Ï / 4 + Ï / 2); 4597 }, n = Ï0 === Ï1 ? Math.sin(Ï0) : Math.log(cosÏ0 / Math.cos(Ï1)) / Math.log(t(Ï1) / t(Ï0)), F = cosÏ0 * Math.pow(t(Ï0), n) / n; 4598 if (!n) return d3_geo_mercator; 4599 function forward(λ, Ï) { 4600 var Ï = abs(abs(Ï) - halfÏ) < ε ? 0 : F / Math.pow(t(Ï), n); 4601 return [ Ï * Math.sin(n * λ), F - Ï * Math.cos(n * λ) ]; 4602 } 4603 forward.invert = function(x, y) { 4604 var Ï0_y = F - y, Ï = d3_sgn(n) * Math.sqrt(x * x + Ï0_y * Ï0_y); 4605 return [ Math.atan2(x, Ï0_y) / n, 2 * Math.atan(Math.pow(F / Ï, 1 / n)) - halfÏ ]; 4606 }; 4607 return forward; 4608 } 4609 (d3.geo.conicConformal = function() { 4610 return d3_geo_conic(d3_geo_conicConformal); 4611 }).raw = d3_geo_conicConformal; 4612 function d3_geo_conicEquidistant(Ï0, Ï1) { 4613 var cosÏ0 = Math.cos(Ï0), n = Ï0 === Ï1 ? Math.sin(Ï0) : (cosÏ0 - Math.cos(Ï1)) / (Ï1 - Ï0), G = cosÏ0 / n + Ï0; 4614 if (abs(n) < ε) return d3_geo_equirectangular; 4615 function forward(λ, Ï) { 4616 var Ï = G - Ï; 4617 return [ Ï * Math.sin(n * λ), G - Ï * Math.cos(n * λ) ]; 4618 } 4619 forward.invert = function(x, y) { 4620 var Ï0_y = G - y; 4621 return [ Math.atan2(x, Ï0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + Ï0_y * Ï0_y) ]; 4622 }; 4623 return forward; 4624 } 4625 (d3.geo.conicEquidistant = function() { 4626 return d3_geo_conic(d3_geo_conicEquidistant); 4627 }).raw = d3_geo_conicEquidistant; 4628 var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosÏ) { 4629 return 1 / cosλcosÏ; 4630 }, Math.atan); 4631 (d3.geo.gnomonic = function() { 4632 return d3_geo_projection(d3_geo_gnomonic); 4633 }).raw = d3_geo_gnomonic; 4634 function d3_geo_mercator(λ, Ï) { 4635 return [ λ, Math.log(Math.tan(Ï / 4 + Ï / 2)) ]; 4636 } 4637 d3_geo_mercator.invert = function(x, y) { 4638 return [ x, 2 * Math.atan(Math.exp(y)) - halfÏ ]; 4639 }; 4640 function d3_geo_mercatorProjection(project) { 4641 var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; 4642 m.scale = function() { 4643 var v = scale.apply(m, arguments); 4644 return v === m ? clipAuto ? m.clipExtent(null) : m : v; 4645 }; 4646 m.translate = function() { 4647 var v = translate.apply(m, arguments); 4648 return v === m ? clipAuto ? m.clipExtent(null) : m : v; 4649 }; 4650 m.clipExtent = function(_) { 4651 var v = clipExtent.apply(m, arguments); 4652 if (v === m) { 4653 if (clipAuto = _ == null) { 4654 var k = Ï * scale(), t = translate(); 4655 clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); 4656 } 4657 } else if (clipAuto) { 4658 v = null; 4659 } 4660 return v; 4661 }; 4662 return m.clipExtent(null); 4663 } 4664 (d3.geo.mercator = function() { 4665 return d3_geo_mercatorProjection(d3_geo_mercator); 4666 }).raw = d3_geo_mercator; 4667 var d3_geo_orthographic = d3_geo_azimuthal(function() { 4668 return 1; 4669 }, Math.asin); 4670 (d3.geo.orthographic = function() { 4671 return d3_geo_projection(d3_geo_orthographic); 4672 }).raw = d3_geo_orthographic; 4673 var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosÏ) { 4674 return 1 / (1 + cosλcosÏ); 4675 }, function(Ï) { 4676 return 2 * Math.atan(Ï); 4677 }); 4678 (d3.geo.stereographic = function() { 4679 return d3_geo_projection(d3_geo_stereographic); 4680 }).raw = d3_geo_stereographic; 4681 function d3_geo_transverseMercator(λ, Ï) { 4682 return [ Math.log(Math.tan(Ï / 4 + Ï / 2)), -λ ]; 4683 } 4684 d3_geo_transverseMercator.invert = function(x, y) { 4685 return [ -y, 2 * Math.atan(Math.exp(x)) - halfÏ ]; 4686 }; 4687 (d3.geo.transverseMercator = function() { 4688 var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; 4689 projection.center = function(_) { 4690 return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ -_[1], _[0] ]); 4691 }; 4692 projection.rotate = function(_) { 4693 return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), 4694 [ _[0], _[1], _[2] - 90 ]); 4695 }; 4696 return projection.rotate([ 0, 0 ]); 4697 }).raw = d3_geo_transverseMercator; 4698 d3.geom = {}; 4699 function d3_geom_pointX(d) { 4700 return d[0]; 4701 } 4702 function d3_geom_pointY(d) { 4703 return d[1]; 4704 } 4705 d3.geom.hull = function(vertices) { 4706 var x = d3_geom_pointX, y = d3_geom_pointY; 4707 if (arguments.length) return hull(vertices); 4708 function hull(data) { 4709 if (data.length < 3) return []; 4710 var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = []; 4711 for (i = 0; i < n; i++) { 4712 points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]); 4713 } 4714 points.sort(d3_geom_hullOrder); 4715 for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]); 4716 var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints); 4717 var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], pol
vendor: 23,510 bytes, lines 4717-5412
4717ygon = []; 4718 for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); 4719 for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); 4720 return polygon; 4721 } 4722 hull.x = function(_) { 4723 return arguments.length ? (x = _, hull) : x; 4724 }; 4725 hull.y = function(_) { 4726 return arguments.length ? (y = _, hull) : y; 4727 }; 4728 return hull; 4729 }; 4730 function d3_geom_hullUpper(points) { 4731 var n = points.length, hull = [ 0, 1 ], hs = 2; 4732 for (var i = 2; i < n; i++) { 4733 while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs; 4734 hull[hs++] = i; 4735 } 4736 return hull.slice(0, hs); 4737 } 4738 function d3_geom_hullOrder(a, b) { 4739 return a[0] - b[0] || a[1] - b[1]; 4740 } 4741 d3.geom.polygon = function(coordinates) { 4742 d3_subclass(coordinates, d3_geom_polygonPrototype); 4743 return coordinates; 4744 }; 4745 var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; 4746 d3_geom_polygonPrototype.area = function() { 4747 var i = -1, n = this.length, a, b = this[n - 1], area = 0; 4748 while (++i < n) { 4749 a = b; 4750 b = this[i]; 4751 area += a[1] * b[0] - a[0] * b[1]; 4752 } 4753 return area * .5; 4754 }; 4755 d3_geom_polygonPrototype.centroid = function(k) { 4756 var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c; 4757 if (!arguments.length) k = -1 / (6 * this.area()); 4758 while (++i < n) { 4759 a = b; 4760 b = this[i]; 4761 c = a[0] * b[1] - b[0] * a[1]; 4762 x += (a[0] + b[0]) * c; 4763 y += (a[1] + b[1]) * c; 4764 } 4765 return [ x * k, y * k ]; 4766 }; 4767 d3_geom_polygonPrototype.clip = function(subject) { 4768 var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d; 4769 while (++i < n) { 4770 input = subject.slice(); 4771 subject.length = 0; 4772 b = this[i]; 4773 c = input[(m = input.length - closed) - 1]; 4774 j = -1; 4775 while (++j < m) { 4776 d = input[j]; 4777 if (d3_geom_polygonInside(d, a, b)) { 4778 if (!d3_geom_polygonInside(c, a, b)) { 4779 subject.push(d3_geom_polygonIntersect(c, d, a, b)); 4780 } 4781 subject.push(d); 4782 } else if (d3_geom_polygonInside(c, a, b)) { 4783 subject.push(d3_geom_polygonIntersect(c, d, a, b)); 4784 } 4785 c = d; 4786 } 4787 if (closed) subject.push(subject[0]); 4788 a = b; 4789 } 4790 return subject; 4791 }; 4792 function d3_geom_polygonInside(p, a, b) { 4793 return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); 4794 } 4795 function d3_geom_polygonIntersect(c, d, a, b) { 4796 var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); 4797 return [ x1 + ua * x21, y1 + ua * y21 ]; 4798 } 4799 function d3_geom_polygonClosed(coordinates) { 4800 var a = coordinates[0], b = coordinates[coordinates.length - 1]; 4801 return !(a[0] - b[0] || a[1] - b[1]); 4802 } 4803 var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = []; 4804 function d3_geom_voronoiBeach() { 4805 d3_geom_voronoiRedBlackNode(this); 4806 this.edge = this.site = this.circle = null; 4807 } 4808 function d3_geom_voronoiCreateBeach(site) { 4809 var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach(); 4810 beach.site = site; 4811 return beach; 4812 } 4813 function d3_geom_voronoiDetachBeach(beach) { 4814 d3_geom_voronoiDetachCircle(beach); 4815 d3_geom_voronoiBeaches.remove(beach); 4816 d3_geom_voronoiBeachPool.push(beach); 4817 d3_geom_voronoiRedBlackNode(beach); 4818 } 4819 function d3_geom_voronoiRemoveBeach(beach) { 4820 var circle = beach.circle, x = circle.x, y = circle.cy, vertex = { 4821 x: x, 4822 y: y 4823 }, previous = beach.P, next = beach.N, disappearing = [ beach ]; 4824 d3_geom_voronoiDetachBeach(beach); 4825 var lArc = previous; 4826 while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) { 4827 previous = lArc.P; 4828 disappearing.unshift(lArc); 4829 d3_geom_voronoiDetachBeach(lArc); 4830 lArc = previous; 4831 } 4832 disappearing.unshift(lArc); 4833 d3_geom_voronoiDetachCircle(lArc); 4834 var rArc = next; 4835 while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) { 4836 next = rArc.N; 4837 disappearing.push(rArc); 4838 d3_geom_voronoiDetachBeach(rArc); 4839 rArc = next; 4840 } 4841 disappearing.push(rArc); 4842 d3_geom_voronoiDetachCircle(rArc); 4843 var nArcs = disappearing.length, iArc; 4844 for (iArc = 1; iArc < nArcs; ++iArc) { 4845 rArc = disappearing[iArc]; 4846 lArc = disappearing[iArc - 1]; 4847 d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); 4848 } 4849 lArc = disappearing[0]; 4850 rArc = disappearing[nArcs - 1]; 4851 rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); 4852 d3_geom_voronoiAttachCircle(lArc); 4853 d3_geom_voronoiAttachCircle(rArc); 4854 } 4855 function d3_geom_voronoiAddBeach(site) { 4856 var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._; 4857 while (node) { 4858 dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; 4859 if (dxl > ε) node = node.L; else { 4860 dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); 4861 if (dxr > ε) { 4862 if (!node.R) { 4863 lArc = node; 4864 break; 4865 } 4866 node = node.R; 4867 } else { 4868 if (dxl > -ε) { 4869 lArc = node.P; 4870 rArc = node; 4871 } else if (dxr > -ε) { 4872 lArc = node; 4873 rArc = node.N; 4874 } else { 4875 lArc = rArc = node; 4876 } 4877 break; 4878 } 4879 } 4880 } 4881 var newArc = d3_geom_voronoiCreateBeach(site); 4882 d3_geom_voronoiBeaches.insert(lArc, newArc); 4883 if (!lArc && !rArc) return; 4884 if (lArc === rArc) { 4885 d3_geom_voronoiDetachCircle(lArc); 4886 rArc = d3_geom_voronoiCreateBeach(lArc.site); 4887 d3_geom_voronoiBeaches.insert(newArc, rArc); 4888 newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); 4889 d3_geom_voronoiAttachCircle(lArc); 4890 d3_geom_voronoiAttachCircle(rArc); 4891 return; 4892 } 4893 if (!rArc) { 4894 newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); 4895 return; 4896 } 4897 d3_geom_voronoiDetachCircle(lArc); 4898 d3_geom_voronoiDetachCircle(rArc); 4899 var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = { 4900 x: (cy * hb - by * hc) / d + ax, 4901 y: (bx * hc - cx * hb) / d + ay 4902 }; 4903 d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); 4904 newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); 4905 rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); 4906 d3_geom_voronoiAttachCircle(lArc); 4907 d3_geom_voronoiAttachCircle(rArc); 4908 } 4909 function d3_geom_voronoiLeftBreakPoint(arc, directrix) { 4910 var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix; 4911 if (!pby2) return rfocx; 4912 var lArc = arc.P; 4913 if (!lArc) return -Infinity; 4914 site = lArc.site; 4915 var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix; 4916 if (!plby2) return lfocx; 4917 var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2; 4918 if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; 4919 return (rfocx + lfocx) / 2; 4920 } 4921 function d3_geom_voronoiRightBreakPoint(arc, directrix) { 4922 var rArc = arc.N; 4923 if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); 4924 var site = arc.site; 4925 return site.y === directrix ? site.x : Infinity; 4926 } 4927 function d3_geom_voronoiCell(site) { 4928 this.site = site; 4929 this.edges = []; 4930 } 4931 d3_geom_voronoiCell.prototype.prepare = function() { 4932 var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge; 4933 while (iHalfEdge--) { 4934 edge = halfEdges[iHalfEdge].edge; 4935 if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); 4936 } 4937 halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); 4938 return halfEdges.length; 4939 }; 4940 function d3_geom_voronoiCloseCells(extent) { 4941 var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end; 4942 while (iCell--) { 4943 cell = cells[iCell]; 4944 if (!cell || !cell.prepare()) continue; 4945 halfEdges = cell.edges; 4946 nHalfEdges = halfEdges.length; 4947 iHalfEdge = 0; 4948 while (iHalfEdge < nHalfEdges) { 4949 end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; 4950 start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; 4951 if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { 4952 halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? { 4953 x: x0, 4954 y: abs(x2 - x0) < ε ? y2 : y1 4955 } : abs(y3 - y1) < ε && x1 - x3 > ε ? { 4956 x: abs(y2 - y1) < ε ? x2 : x1, 4957 y: y1 4958 } : abs(x3 - x1) < ε && y3 - y0 > ε ? { 4959 x: x1, 4960 y: abs(x2 - x1) < ε ? y2 : y0 4961 } : abs(y3 - y0) < ε && x3 - x0 > ε ? { 4962 x: abs(y2 - y0) < ε ? x2 : x0, 4963 y: y0 4964 } : null), cell.site, null)); 4965 ++nHalfEdges; 4966 } 4967 } 4968 } 4969 } 4970 function d3_geom_voronoiHalfEdgeOrder(a, b) { 4971 return b.angle - a.angle; 4972 } 4973 function d3_geom_voronoiCircle() { 4974 d3_geom_voronoiRedBlackNode(this); 4975 this.x = this.y = this.arc = this.site = this.cy = null; 4976 } 4977 function d3_geom_voronoiAttachCircle(arc) { 4978 var lArc = arc.P, rArc = arc.N; 4979 if (!lArc || !rArc) return; 4980 var lSite = lArc.site, cSite = arc.site, rSite = rArc.site; 4981 if (lSite === rSite) return; 4982 var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by; 4983 var d = 2 * (ax * cy - ay * cx); 4984 if (d >= -ε2) return; 4985 var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by; 4986 var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle(); 4987 circle.arc = arc; 4988 circle.site = cSite; 4989 circle.x = x + bx; 4990 circle.y = cy + Math.sqrt(x * x + y * y); 4991 circle.cy = cy; 4992 arc.circle = circle; 4993 var before = null, node = d3_geom_voronoiCircles._; 4994 while (node) { 4995 if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) { 4996 if (node.L) node = node.L; else { 4997 before = node.P; 4998 break; 4999 } 5000 } else { 5001 if (node.R) node = node.R; else { 5002 before = node; 5003 break; 5004 } 5005 } 5006 } 5007 d3_geom_voronoiCircles.insert(before, circle); 5008 if (!before) d3_geom_voronoiFirstCircle = circle; 5009 } 5010 function d3_geom_voronoiDetachCircle(arc) { 5011 var circle = arc.circle; 5012 if (circle) { 5013 if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; 5014 d3_geom_voronoiCircles.remove(circle); 5015 d3_geom_voronoiCirclePool.push(circle); 5016 d3_geom_voronoiRedBlackNode(circle); 5017 arc.circle = null; 5018 } 5019 } 5020 function d3_geom_voronoiClipEdges(extent) { 5021 var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; 5022 while (i--) { 5023 e = edges[i]; 5024 if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) { 5025 e.a = e.b = null; 5026 edges.splice(i, 1); 5027 } 5028 } 5029 } 5030 function d3_geom_voronoiConnectEdge(edge, extent) { 5031 var vb = edge.b; 5032 if (vb) return true; 5033 var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb; 5034 if (ry === ly) { 5035 if (fx < x0 || fx >= x1) return; 5036 if (lx > rx) { 5037 if (!va) va = { 5038 x: fx, 5039 y: y0 5040 }; else if (va.y >= y1) return; 5041 vb = { 5042 x: fx, 5043 y: y1 5044 }; 5045 } else { 5046 if (!va) va = { 5047 x: fx, 5048 y: y1 5049 }; else if (va.y < y0) return; 5050 vb = { 5051 x: fx, 5052 y: y0 5053 }; 5054 } 5055 } else { 5056 fm = (lx - rx) / (ry - ly); 5057 fb = fy - fm * fx; 5058 if (fm < -1 || fm > 1) { 5059 if (lx > rx) { 5060 if (!va) va = { 5061 x: (y0 - fb) / fm, 5062 y: y0 5063 }; else if (va.y >= y1) return; 5064 vb = { 5065 x: (y1 - fb) / fm, 5066 y: y1 5067 }; 5068 } else { 5069 if (!va) va = { 5070 x: (y1 - fb) / fm, 5071 y: y1 5072 }; else if (va.y < y0) return; 5073 vb = { 5074 x: (y0 - fb) / fm, 5075 y: y0 5076 }; 5077 } 5078 } else { 5079 if (ly < ry) { 5080 if (!va) va = { 5081 x: x0, 5082 y: fm * x0 + fb 5083 }; else if (va.x >= x1) return; 5084 vb = { 5085 x: x1, 5086 y: fm * x1 + fb 5087 }; 5088 } else { 5089 if (!va) va = { 5090 x: x1, 5091 y: fm * x1 + fb 5092 }; else if (va.x < x0) return; 5093 vb = { 5094 x: x0, 5095 y: fm * x0 + fb 5096 }; 5097 } 5098 } 5099 } 5100 edge.a = va; 5101 edge.b = vb; 5102 return true; 5103 } 5104 function d3_geom_voronoiEdge(lSite, rSite) { 5105 this.l = lSite; 5106 this.r = rSite; 5107 this.a = this.b = null; 5108 } 5109 function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { 5110 var edge = new d3_geom_voronoiEdge(lSite, rSite); 5111 d3_geom_voronoiEdges.push(edge); 5112 if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); 5113 if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); 5114 d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); 5115 d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); 5116 return edge; 5117 } 5118 function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { 5119 var edge = new d3_geom_voronoiEdge(lSite, null); 5120 edge.a = va; 5121 edge.b = vb; 5122 d3_geom_voronoiEdges.push(edge); 5123 return edge; 5124 } 5125 function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { 5126 if (!edge.a && !edge.b) { 5127 edge.a = vertex; 5128 edge.l = lSite; 5129 edge.r = rSite; 5130 } else if (edge.l === rSite) { 5131 edge.b = vertex; 5132 } else { 5133 edge.a = vertex; 5134 } 5135 } 5136 function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { 5137 var va = edge.a, vb = edge.b; 5138 this.edge = edge; 5139 this.site = lSite; 5140 this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y); 5141 } 5142 d3_geom_voronoiHalfEdge.prototype = { 5143 start: function() { 5144 return this.edge.l === this.site ? this.edge.a : this.edge.b; 5145 }, 5146 end: function() { 5147 return this.edge.l === this.site ? this.edge.b : this.edge.a; 5148 } 5149 }; 5150 function d3_geom_voronoiRedBlackTree() { 5151 this._ = null; 5152 } 5153 function d3_geom_voronoiRedBlackNode(node) { 5154 node.U = node.C = node.L = node.R = node.P = node.N = null; 5155 } 5156 d3_geom_voronoiRedBlackTree.prototype = { 5157 insert: function(after, node) { 5158 var parent, grandpa, uncle; 5159 if (after) { 5160 node.P = after; 5161 node.N = after.N; 5162 if (after.N) after.N.P = node; 5163 after.N = node; 5164 if (after.R) { 5165 after = after.R; 5166 while (after.L) after = after.L; 5167 after.L = node; 5168 } else { 5169 after.R = node; 5170 } 5171 parent = after; 5172 } else if (this._) { 5173 after = d3_geom_voronoiRedBlackFirst(this._); 5174 node.P = null; 5175 node.N = after; 5176 after.P = after.L = node; 5177 parent = after; 5178 } else { 5179 node.P = node.N = null; 5180 this._ = node; 5181 parent = null; 5182 } 5183 node.L = node.R = null; 5184 node.U = parent; 5185 node.C = true; 5186 after = node; 5187 while (parent && parent.C) { 5188 grandpa = parent.U; 5189 if (parent === grandpa.L) { 5190 uncle = grandpa.R; 5191 if (uncle && uncle.C) { 5192 parent.C = uncle.C = false; 5193 grandpa.C = true; 5194 after = grandpa; 5195 } else { 5196 if (after === parent.R) { 5197 d3_geom_voronoiRedBlackRotateLeft(this, parent); 5198 after = parent; 5199 parent = after.U; 5200 } 5201 parent.C = false; 5202 grandpa.C = true; 5203 d3_geom_voronoiRedBlackRotateRight(this, grandpa); 5204 } 5205 } else { 5206 uncle = grandpa.L; 5207 if (uncle && uncle.C) { 5208 parent.C = uncle.C = false; 5209 grandpa.C = true; 5210 after = grandpa; 5211 } else { 5212 if (after === parent.L) { 5213 d3_geom_voronoiRedBlackRotateRight(this, parent); 5214 after = parent; 5215 parent = after.U; 5216 } 5217 parent.C = false; 5218 grandpa.C = true; 5219 d3_geom_voronoiRedBlackRotateLeft(this, grandpa); 5220 } 5221 } 5222 parent = after.U; 5223 } 5224 this._.C = false; 5225 }, 5226 remove: function(node) { 5227 if (node.N) node.N.P = node.P; 5228 if (node.P) node.P.N = node.N; 5229 node.N = node.P = null; 5230 var parent = node.U, sibling, left = node.L, right = node.R, next, red; 5231 if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right); 5232 if (parent) { 5233 if (parent.L === node) parent.L = next; else parent.R = next; 5234 } else { 5235 this._ = next; 5236 } 5237 if (left && right) { 5238 red = next.C; 5239 next.C = node.C; 5240 next.L = left; 5241 left.U = next; 5242 if (next !== right) { 5243 parent = next.U; 5244 next.U = node.U; 5245 node = next.R; 5246 parent.L = node; 5247 next.R = right; 5248 right.U = next; 5249 } else { 5250 next.U = parent; 5251 parent = next; 5252 node = next.R; 5253 } 5254 } else { 5255 red = node.C; 5256 node = next; 5257 } 5258 if (node) node.U = parent; 5259 if (red) return; 5260 if (node && node.C) { 5261 node.C = false; 5262 return; 5263 } 5264 do { 5265 if (node === this._) break; 5266 if (node === parent.L) { 5267 sibling = parent.R; 5268 if (sibling.C) { 5269 sibling.C = false; 5270 parent.C = true; 5271 d3_geom_voronoiRedBlackRotateLeft(this, parent); 5272 sibling = parent.R; 5273 } 5274 if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { 5275 if (!sibling.R || !sibling.R.C) { 5276 sibling.L.C = false; 5277 sibling.C = true; 5278 d3_geom_voronoiRedBlackRotateRight(this, sibling); 5279 sibling = parent.R; 5280 } 5281 sibling.C = parent.C; 5282 parent.C = sibling.R.C = false; 5283 d3_geom_voronoiRedBlackRotateLeft(this, parent); 5284 node = this._; 5285 break; 5286 } 5287 } else { 5288 sibling = parent.L; 5289 if (sibling.C) { 5290 sibling.C = false; 5291 parent.C = true; 5292 d3_geom_voronoiRedBlackRotateRight(this, parent); 5293 sibling = parent.L; 5294 } 5295 if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { 5296 if (!sibling.L || !sibling.L.C) { 5297 sibling.R.C = false; 5298 sibling.C = true; 5299 d3_geom_voronoiRedBlackRotateLeft(this, sibling); 5300 sibling = parent.L; 5301 } 5302 sibling.C = parent.C; 5303 parent.C = sibling.L.C = false; 5304 d3_geom_voronoiRedBlackRotateRight(this, parent); 5305 node = this._; 5306 break; 5307 } 5308 } 5309 sibling.C = true; 5310 node = parent; 5311 parent = parent.U; 5312 } while (!node.C); 5313 if (node) node.C = false; 5314 } 5315 }; 5316 function d3_geom_voronoiRedBlackRotateLeft(tree, node) { 5317 var p = node, q = node.R, parent = p.U; 5318 if (parent) { 5319 if (parent.L === p) parent.L = q; else parent.R = q; 5320 } else { 5321 tree._ = q; 5322 } 5323 q.U = parent; 5324 p.U = q; 5325 p.R = q.L; 5326 if (p.R) p.R.U = p; 5327 q.L = p; 5328 } 5329 function d3_geom_voronoiRedBlackRotateRight(tree, node) { 5330 var p = node, q = node.L, parent = p.U; 5331 if (parent) { 5332 if (parent.L === p) parent.L = q; else parent.R = q; 5333 } else { 5334 tree._ = q; 5335 } 5336 q.U = parent; 5337 p.U = q; 5338 p.L = q.R; 5339 if (p.L) p.L.U = p; 5340 q.R = p; 5341 } 5342 function d3_geom_voronoiRedBlackFirst(node) { 5343 while (node.L) node = node.L; 5344 return node; 5345 } 5346 function d3_geom_voronoi(sites, bbox) { 5347 var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle; 5348 d3_geom_voronoiEdges = []; 5349 d3_geom_voronoiCells = new Array(sites.length); 5350 d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree(); 5351 d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree(); 5352 while (true) { 5353 circle = d3_geom_voronoiFirstCircle; 5354 if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) { 5355 if (site.x !== x0 || site.y !== y0) { 5356 d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); 5357 d3_geom_voronoiAddBeach(site); 5358 x0 = site.x, y0 = site.y; 5359 } 5360 site = sites.pop(); 5361 } else if (circle) { 5362 d3_geom_voronoiRemoveBeach(circle.arc); 5363 } else { 5364 break; 5365 } 5366 } 5367 if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); 5368 var diagram = { 5369 cells: d3_geom_voronoiCells, 5370 edges: d3_geom_voronoiEdges 5371 }; 5372 d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null; 5373 return diagram; 5374 } 5375 function d3_geom_voronoiVertexOrder(a, b) { 5376 return b.y - a.y || b.x - a.x; 5377 } 5378 d3.geom.voronoi = function(points) { 5379 var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent; 5380 if (points) return voronoi(points); 5381 function voronoi(data) { 5382 var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1]; 5383 d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { 5384 var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) { 5385 var s = e.start(); 5386 return [ s.x, s.y ]; 5387 }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : []; 5388 polygon.point = data[i]; 5389 }); 5390 return polygons; 5391 } 5392 function sites(data) { 5393 return data.map(function(d, i) { 5394 return { 5395 x: Math.round(fx(d, i) / ε) * ε, 5396 y: Math.round(fy(d, i) / ε) * ε, 5397 i: i 5398 }; 5399 }); 5400 } 5401 voronoi.links = function(data) { 5402 return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { 5403 return edge.l && edge.r; 5404 }).map(function(edge) { 5405 return { 5406 source: data[edge.l.i], 5407 target: data[edge.r.i] 5408 }; 5409 }); 5410 }; 5411 voronoi.triangles = function(data) { 5412 var triangles = [];
vendor: 5,984 bytes, lines 5413-5580
5413 d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { 5414 var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l; 5415 while (++j < m) { 5416 e0 = e1; 5417 s0 = s1; 5418 e1 = edges[j].edge; 5419 s1 = e1.l === site ? e1.r : e1.l; 5420 if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { 5421 triangles.push([ data[i], data[s0.i], data[s1.i] ]); 5422 } 5423 } 5424 }); 5425 return triangles; 5426 }; 5427 voronoi.x = function(_) { 5428 return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; 5429 }; 5430 voronoi.y = function(_) { 5431 return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; 5432 }; 5433 voronoi.clipExtent = function(_) { 5434 if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; 5435 clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; 5436 return voronoi; 5437 }; 5438 voronoi.size = function(_) { 5439 if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; 5440 return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); 5441 }; 5442 return voronoi; 5443 }; 5444 var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ]; 5445 function d3_geom_voronoiTriangleArea(a, b, c) { 5446 return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); 5447 } 5448 d3.geom.delaunay = function(vertices) { 5449 return d3.geom.voronoi().triangles(vertices); 5450 }; 5451 d3.geom.quadtree = function(points, x1, y1, x2, y2) { 5452 var x = d3_geom_pointX, y = d3_geom_pointY, compat; 5453 if (compat = arguments.length) { 5454 x = d3_geom_quadtreeCompatX; 5455 y = d3_geom_quadtreeCompatY; 5456 if (compat === 3) { 5457 y2 = y1; 5458 x2 = x1; 5459 y1 = x1 = 0; 5460 } 5461 return quadtree(points); 5462 } 5463 function quadtree(data) { 5464 var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; 5465 if (x1 != null) { 5466 x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; 5467 } else { 5468 x2_ = y2_ = -(x1_ = y1_ = Infinity); 5469 xs = [], ys = []; 5470 n = data.length; 5471 if (compat) for (i = 0; i < n; ++i) { 5472 d = data[i]; 5473 if (d.x < x1_) x1_ = d.x; 5474 if (d.y < y1_) y1_ = d.y; 5475 if (d.x > x2_) x2_ = d.x; 5476 if (d.y > y2_) y2_ = d.y; 5477 xs.push(d.x); 5478 ys.push(d.y); 5479 } else for (i = 0; i < n; ++i) { 5480 var x_ = +fx(d = data[i], i), y_ = +fy(d, i); 5481 if (x_ < x1_) x1_ = x_; 5482 if (y_ < y1_) y1_ = y_; 5483 if (x_ > x2_) x2_ = x_; 5484 if (y_ > y2_) y2_ = y_; 5485 xs.push(x_); 5486 ys.push(y_); 5487 } 5488 } 5489 var dx = x2_ - x1_, dy = y2_ - y1_; 5490 if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; 5491 function insert(n, d, x, y, x1, y1, x2, y2) { 5492 if (isNaN(x) || isNaN(y)) return; 5493 if (n.leaf) { 5494 var nx = n.x, ny = n.y; 5495 if (nx != null) { 5496 if (abs(nx - x) + abs(ny - y) < .01) { 5497 insertChild(n, d, x, y, x1, y1, x2, y2); 5498 } else { 5499 var nPoint = n.point; 5500 n.x = n.y = n.point = null; 5501 insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); 5502 insertChild(n, d, x, y, x1, y1, x2, y2); 5503 } 5504 } else { 5505 n.x = x, n.y = y, n.point = d; 5506 } 5507 } else { 5508 insertChild(n, d, x, y, x1, y1, x2, y2); 5509 } 5510 } 5511 function insertChild(n, d, x, y, x1, y1, x2, y2) { 5512 var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right; 5513 n.leaf = false; 5514 n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); 5515 if (right) x1 = sx; else x2 = sx; 5516 if (bottom) y1 = sy; else y2 = sy; 5517 insert(n, d, x, y, x1, y1, x2, y2); 5518 } 5519 var root = d3_geom_quadtreeNode(); 5520 root.add = function(d) { 5521 insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); 5522 }; 5523 root.visit = function(f) { 5524 d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); 5525 }; 5526 i = -1; 5527 if (x1 == null) { 5528 while (++i < n) { 5529 insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); 5530 } 5531 --i; 5532 } else data.forEach(root.add); 5533 xs = ys = data = d = null; 5534 return root; 5535 } 5536 quadtree.x = function(_) { 5537 return arguments.length ? (x = _, quadtree) : x; 5538 }; 5539 quadtree.y = function(_) { 5540 return arguments.length ? (y = _, quadtree) : y; 5541 }; 5542 quadtree.extent = function(_) { 5543 if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; 5544 if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], 5545 y2 = +_[1][1]; 5546 return quadtree; 5547 }; 5548 quadtree.size = function(_) { 5549 if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; 5550 if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; 5551 return quadtree; 5552 }; 5553 return quadtree; 5554 }; 5555 function d3_geom_quadtreeCompatX(d) { 5556 return d.x; 5557 } 5558 function d3_geom_quadtreeCompatY(d) { 5559 return d.y; 5560 } 5561 function d3_geom_quadtreeNode() { 5562 return { 5563 leaf: true, 5564 nodes: [], 5565 point: null, 5566 x: null, 5567 y: null 5568 }; 5569 } 5570 function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { 5571 if (!f(node, x1, y1, x2, y2)) { 5572 var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; 5573 if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); 5574 if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); 5575 if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); 5576 if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); 5577 } 5578 } 5579 d3.interpolateRgb = d3_interpolateRgb; 5580 function d3_interpolateRgb(a, b) {
vendor: 13,978 bytes, lines 5581-6047
5581 a = d3.rgb(a); 5582 b = d3.rgb(b); 5583 var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; 5584 return function(t) { 5585 return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); 5586 }; 5587 } 5588 d3.interpolateObject = d3_interpolateObject; 5589 function d3_interpolateObject(a, b) { 5590 var i = {}, c = {}, k; 5591 for (k in a) { 5592 if (k in b) { 5593 i[k] = d3_interpolate(a[k], b[k]); 5594 } else { 5595 c[k] = a[k]; 5596 } 5597 } 5598 for (k in b) { 5599 if (!(k in a)) { 5600 c[k] = b[k]; 5601 } 5602 } 5603 return function(t) { 5604 for (k in i) c[k] = i[k](t); 5605 return c; 5606 }; 5607 } 5608 d3.interpolateNumber = d3_interpolateNumber; 5609 function d3_interpolateNumber(a, b) { 5610 b -= a = +a; 5611 return function(t) { 5612 return a + b * t; 5613 }; 5614 } 5615 d3.interpolateString = d3_interpolateString; 5616 function d3_interpolateString(a, b) { 5617 var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; 5618 a = a + "", b = b + ""; 5619 d3_interpolate_number.lastIndex = 0; 5620 for (i = 0; m = d3_interpolate_number.exec(b); ++i) { 5621 if (m.index) s.push(b.substring(s0, s1 = m.index)); 5622 q.push({ 5623 i: s.length, 5624 x: m[0] 5625 }); 5626 s.push(null); 5627 s0 = d3_interpolate_number.lastIndex; 5628 } 5629 if (s0 < b.length) s.push(b.substring(s0)); 5630 for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { 5631 o = q[i]; 5632 if (o.x == m[0]) { 5633 if (o.i) { 5634 if (s[o.i + 1] == null) { 5635 s[o.i - 1] += o.x; 5636 s.splice(o.i, 1); 5637 for (j = i + 1; j < n; ++j) q[j].i--; 5638 } else { 5639 s[o.i - 1] += o.x + s[o.i + 1]; 5640 s.splice(o.i, 2); 5641 for (j = i + 1; j < n; ++j) q[j].i -= 2; 5642 } 5643 } else { 5644 if (s[o.i + 1] == null) { 5645 s[o.i] = o.x; 5646 } else { 5647 s[o.i] = o.x + s[o.i + 1]; 5648 s.splice(o.i + 1, 1); 5649 for (j = i + 1; j < n; ++j) q[j].i--; 5650 } 5651 } 5652 q.splice(i, 1); 5653 n--; 5654 i--; 5655 } else { 5656 o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); 5657 } 5658 } 5659 while (i < n) { 5660 o = q.pop(); 5661 if (s[o.i + 1] == null) { 5662 s[o.i] = o.x; 5663 } else { 5664 s[o.i] = o.x + s[o.i + 1]; 5665 s.splice(o.i + 1, 1); 5666 } 5667 n--; 5668 } 5669 if (s.length === 1) { 5670 return s[0] == null ? (o = q[0].x, function(t) { 5671 return o(t) + ""; 5672 }) : function() { 5673 return b; 5674 }; 5675 } 5676 return function(t) { 5677 for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); 5678 return s.join(""); 5679 }; 5680 } 5681 var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; 5682 d3.interpolate = d3_interpolate; 5683 function d3_interpolate(a, b) { 5684 var i = d3.interpolators.length, f; 5685 while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; 5686 return f; 5687 } 5688 d3.interpolators = [ function(a, b) { 5689 var t = typeof b; 5690 return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b); 5691 } ]; 5692 d3.interpolateArray = d3_interpolateArray; 5693 function d3_interpolateArray(a, b) { 5694 var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; 5695 for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); 5696 for (;i < na; ++i) c[i] = a[i]; 5697 for (;i < nb; ++i) c[i] = b[i]; 5698 return function(t) { 5699 for (i = 0; i < n0; ++i) c[i] = x[i](t); 5700 return c; 5701 }; 5702 } 5703 var d3_ease_default = function() { 5704 return d3_identity; 5705 }; 5706 var d3_ease = d3.map({ 5707 linear: d3_ease_default, 5708 poly: d3_ease_poly, 5709 quad: function() { 5710 return d3_ease_quad; 5711 }, 5712 cubic: function() { 5713 return d3_ease_cubic; 5714 }, 5715 sin: function() { 5716 return d3_ease_sin; 5717 }, 5718 exp: function() { 5719 return d3_ease_exp; 5720 }, 5721 circle: function() { 5722 return d3_ease_circle; 5723 }, 5724 elastic: d3_ease_elastic, 5725 back: d3_ease_back, 5726 bounce: function() { 5727 return d3_ease_bounce; 5728 } 5729 }); 5730 var d3_ease_mode = d3.map({ 5731 "in": d3_identity, 5732 out: d3_ease_reverse, 5733 "in-out": d3_ease_reflect, 5734 "out-in": function(f) { 5735 return d3_ease_reflect(d3_ease_reverse(f)); 5736 } 5737 }); 5738 d3.ease = function(name) { 5739 var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in"; 5740 t = d3_ease.get(t) || d3_ease_default; 5741 m = d3_ease_mode.get(m) || d3_identity; 5742 return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); 5743 }; 5744 function d3_ease_clamp(f) { 5745 return function(t) { 5746 return t <= 0 ? 0 : t >= 1 ? 1 : f(t); 5747 }; 5748 } 5749 function d3_ease_reverse(f) { 5750 return function(t) { 5751 return 1 - f(1 - t); 5752 }; 5753 } 5754 function d3_ease_reflect(f) { 5755 return function(t) { 5756 return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); 5757 }; 5758 } 5759 function d3_ease_quad(t) { 5760 return t * t; 5761 } 5762 function d3_ease_cubic(t) { 5763 return t * t * t; 5764 } 5765 function d3_ease_cubicInOut(t) { 5766 if (t <= 0) return 0; 5767 if (t >= 1) return 1; 5768 var t2 = t * t, t3 = t2 * t; 5769 return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); 5770 } 5771 function d3_ease_poly(e) { 5772 return function(t) { 5773 return Math.pow(t, e); 5774 }; 5775 } 5776 function d3_ease_sin(t) { 5777 return 1 - Math.cos(t * halfÏ); 5778 } 5779 function d3_ease_exp(t) { 5780 return Math.pow(2, 10 * (t - 1)); 5781 } 5782 function d3_ease_circle(t) { 5783 return 1 - Math.sqrt(1 - t * t); 5784 } 5785 function d3_ease_elastic(a, p) { 5786 var s; 5787 if (arguments.length < 2) p = .45; 5788 if (arguments.length) s = p / Ï * Math.asin(1 / a); else a = 1, s = p / 4; 5789 return function(t) { 5790 return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * Ï / p); 5791 }; 5792 } 5793 function d3_ease_back(s) { 5794 if (!s) s = 1.70158; 5795 return function(t) { 5796 return t * t * ((s + 1) * t - s); 5797 }; 5798 } 5799 function d3_ease_bounce(t) { 5800 return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; 5801 } 5802 d3.interpolateHcl = d3_interpolateHcl; 5803 function d3_interpolateHcl(a, b) { 5804 a = d3.hcl(a); 5805 b = d3.hcl(b); 5806 var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; 5807 if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; 5808 if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; 5809 return function(t) { 5810 return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; 5811 }; 5812 } 5813 d3.interpolateHsl = d3_interpolateHsl; 5814 function d3_interpolateHsl(a, b) { 5815 a = d3.hsl(a); 5816 b = d3.hsl(b); 5817 var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; 5818 if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; 5819 if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; 5820 return function(t) { 5821 return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; 5822 }; 5823 } 5824 d3.interpolateLab = d3_interpolateLab; 5825 function d3_interpolateLab(a, b) { 5826 a = d3.lab(a); 5827 b = d3.lab(b); 5828 var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; 5829 return function(t) { 5830 return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; 5831 }; 5832 } 5833 d3.interpolateRound = d3_interpolateRound; 5834 function d3_interpolateRound(a, b) { 5835 b -= a; 5836 return function(t) { 5837 return Math.round(a + b * t); 5838 }; 5839 } 5840 d3.transform = function(string) { 5841 var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); 5842 return (d3.transform = function(string) { 5843 if (string != null) { 5844 g.setAttribute("transform", string); 5845 var t = g.transform.baseVal.consolidate(); 5846 } 5847 return new d3_transform(t ? t.matrix : d3_transformIdentity); 5848 })(string); 5849 }; 5850 function d3_transform(m) { 5851 var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; 5852 if (r0[0] * r1[1] < r1[0] * r0[1]) { 5853 r0[0] *= -1; 5854 r0[1] *= -1; 5855 kx *= -1; 5856 kz *= -1; 5857 } 5858 this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; 5859 this.translate = [ m.e, m.f ]; 5860 this.scale = [ kx, ky ]; 5861 this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; 5862 } 5863 d3_transform.prototype.toString = function() { 5864 return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; 5865 }; 5866 function d3_transformDot(a, b) { 5867 return a[0] * b[0] + a[1] * b[1]; 5868 } 5869 function d3_transformNormalize(a) { 5870 var k = Math.sqrt(d3_transformDot(a, a)); 5871 if (k) { 5872 a[0] /= k; 5873 a[1] /= k; 5874 } 5875 return k; 5876 } 5877 function d3_transformCombine(a, b, k) { 5878 a[0] += k * b[0]; 5879 a[1] += k * b[1]; 5880 return a; 5881 } 5882 var d3_transformIdentity = { 5883 a: 1, 5884 b: 0, 5885 c: 0, 5886 d: 1, 5887 e: 0, 5888 f: 0 5889 }; 5890 d3.interpolateTransform = d3_interpolateTransform; 5891 function d3_interpolateTransform(a, b) { 5892 var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale; 5893 if (ta[0] != tb[0] || ta[1] != tb[1]) { 5894 s.push("translate(", null, ",", null, ")"); 5895 q.push({ 5896 i: 1, 5897 x: d3_interpolateNumber(ta[0], tb[0]) 5898 }, { 5899 i: 3, 5900 x: d3_interpolateNumber(ta[1], tb[1]) 5901 }); 5902 } else if (tb[0] || tb[1]) { 5903 s.push("translate(" + tb + ")"); 5904 } else { 5905 s.push(""); 5906 } 5907 if (ra != rb) { 5908 if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; 5909 q.push({ 5910 i: s.push(s.pop() + "rotate(", null, ")") - 2, 5911 x: d3_interpolateNumber(ra, rb) 5912 }); 5913 } else if (rb) { 5914 s.push(s.pop() + "rotate(" + rb + ")"); 5915 } 5916 if (wa != wb) { 5917 q.push({ 5918 i: s.push(s.pop() + "skewX(", null, ")") - 2, 5919 x: d3_interpolateNumber(wa, wb) 5920 }); 5921 } else if (wb) { 5922 s.push(s.pop() + "skewX(" + wb + ")"); 5923 } 5924 if (ka[0] != kb[0] || ka[1] != kb[1]) { 5925 n = s.push(s.pop() + "scale(", null, ",", null, ")"); 5926 q.push({ 5927 i: n - 4, 5928 x: d3_interpolateNumber(ka[0], kb[0]) 5929 }, { 5930 i: n - 2, 5931 x: d3_interpolateNumber(ka[1], kb[1]) 5932 }); 5933 } else if (kb[0] != 1 || kb[1] != 1) { 5934 s.push(s.pop() + "scale(" + kb + ")"); 5935 } 5936 n = q.length; 5937 return function(t) { 5938 var i = -1, o; 5939 while (++i < n) s[(o = q[i]).i] = o.x(t); 5940 return s.join(""); 5941 }; 5942 } 5943 function d3_uninterpolateNumber(a, b) { 5944 b = b - (a = +a) ? 1 / (b - a) : 0; 5945 return function(x) { 5946 return (x - a) * b; 5947 }; 5948 } 5949 function d3_uninterpolateClamp(a, b) { 5950 b = b - (a = +a) ? 1 / (b - a) : 0; 5951 return function(x) { 5952 return Math.max(0, Math.min(1, (x - a) * b)); 5953 }; 5954 } 5955 d3.layout = {}; 5956 d3.layout.bundle = function() { 5957 return function(links) { 5958 var paths = [], i = -1, n = links.length; 5959 while (++i < n) paths.push(d3_layout_bundlePath(links[i])); 5960 return paths; 5961 }; 5962 }; 5963 function d3_layout_bundlePath(link) { 5964 var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; 5965 while (start !== lca) { 5966 start = start.parent; 5967 points.push(start); 5968 } 5969 var k = points.length; 5970 while (end !== lca) { 5971 points.splice(k, 0, end); 5972 end = end.parent; 5973 } 5974 return points; 5975 } 5976 function d3_layout_bundleAncestors(node) { 5977 var ancestors = [], parent = node.parent; 5978 while (parent != null) { 5979 ancestors.push(node); 5980 node = parent; 5981 parent = parent.parent; 5982 } 5983 ancestors.push(node); 5984 return ancestors; 5985 } 5986 function d3_layout_bundleLeastCommonAncestor(a, b) { 5987 if (a === b) return a; 5988 var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; 5989 while (aNode === bNode) { 5990 sharedNode = aNode; 5991 aNode = aNodes.pop(); 5992 bNode = bNodes.pop(); 5993 } 5994 return sharedNode; 5995 } 5996 d3.layout.chord = function() { 5997 var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; 5998 function relayout() { 5999 var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; 6000 chords = []; 6001 groups = []; 6002 k = 0, i = -1; 6003 while (++i < n) { 6004 x = 0, j = -1; 6005 while (++j < n) { 6006 x += matrix[i][j]; 6007 } 6008 groupSums.push(x); 6009 subgroupIndex.push(d3.range(n)); 6010 k += x; 6011 } 6012 if (sortGroups) { 6013 groupIndex.sort(function(a, b) { 6014 return sortGroups(groupSums[a], groupSums[b]); 6015 }); 6016 } 6017 if (sortSubgroups) { 6018 subgroupIndex.forEach(function(d, i) { 6019 d.sort(function(a, b) { 6020 return sortSubgroups(matrix[i][a], matrix[i][b]); 6021 }); 6022 }); 6023 } 6024 k = (Ï - padding * n) / k; 6025 x = 0, i = -1; 6026 while (++i < n) { 6027 x0 = x, j = -1; 6028 while (++j < n) { 6029 var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; 6030 subgroups[di + "-" + dj] = { 6031 index: di, 6032 subindex: dj, 6033 startAngle: a0, 6034 endAngle: a1, 6035 value: v 6036 }; 6037 } 6038 groups[di] = { 6039 index: di, 6040 startAngle: x0, 6041 endAngle: x, 6042 value: (x - x0) / k 6043 }; 6044 x += padding; 6045 } 6046 i = -1; 6047 while (++i < n) {
vendor: 3,724 bytes, lines 6048-6168
6048 j = i - 1; 6049 while (++j < n) { 6050 var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; 6051 if (source.value || target.value) { 6052 chords.push(source.value < target.value ? { 6053 source: target, 6054 target: source 6055 } : { 6056 source: source, 6057 target: target 6058 }); 6059 } 6060 } 6061 } 6062 if (sortChords) resort(); 6063 } 6064 function resort() { 6065 chords.sort(function(a, b) { 6066 return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); 6067 }); 6068 } 6069 chord.matrix = function(x) { 6070 if (!arguments.length) return matrix; 6071 n = (matrix = x) && matrix.length; 6072 chords = groups = null; 6073 return chord; 6074 }; 6075 chord.padding = function(x) { 6076 if (!arguments.length) return padding; 6077 padding = x; 6078 chords = groups = null; 6079 return chord; 6080 }; 6081 chord.sortGroups = function(x) { 6082 if (!arguments.length) return sortGroups; 6083 sortGroups = x; 6084 chords = groups = null; 6085 return chord; 6086 }; 6087 chord.sortSubgroups = function(x) { 6088 if (!arguments.length) return sortSubgroups; 6089 sortSubgroups = x; 6090 chords = null; 6091 return chord; 6092 }; 6093 chord.sortChords = function(x) { 6094 if (!arguments.length) return sortChords; 6095 sortChords = x; 6096 if (chords) resort(); 6097 return chord; 6098 }; 6099 chord.chords = function() { 6100 if (!chords) relayout(); 6101 return chords; 6102 }; 6103 chord.groups = function() { 6104 if (!groups) relayout(); 6105 return groups; 6106 }; 6107 return chord; 6108 }; 6109 d3.layout.force = function() { 6110 var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; 6111 function repulse(node) { 6112 return function(quad, x1, _, x2) { 6113 if (quad.point !== node) { 6114 var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy; 6115 if (dw * dw / theta2 < dn) { 6116 if (dn < chargeDistance2) { 6117 var k = quad.charge / dn; 6118 node.px -= dx * k; 6119 node.py -= dy * k; 6120 } 6121 return true; 6122 } 6123 if (quad.point && dn && dn < chargeDistance2) { 6124 var k = quad.pointCharge / dn; 6125 node.px -= dx * k; 6126 node.py -= dy * k; 6127 } 6128 } 6129 return !quad.charge; 6130 }; 6131 } 6132 force.tick = function() { 6133 if ((alpha *= .99) < .005) { 6134 event.end({ 6135 type: "end", 6136 alpha: alpha = 0 6137 }); 6138 return true; 6139 } 6140 var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; 6141 for (i = 0; i < m; ++i) { 6142 o = links[i]; 6143 s = o.source; 6144 t = o.target; 6145 x = t.x - s.x; 6146 y = t.y - s.y; 6147 if (l = x * x + y * y) { 6148 l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; 6149 x *= l; 6150 y *= l; 6151 t.x -= x * (k = s.weight / (t.weight + s.weight)); 6152 t.y -= y * k; 6153 s.x += x * (k = 1 - k); 6154 s.y += y * k; 6155 } 6156 } 6157 if (k = alpha * gravity) { 6158 x = size[0] / 2; 6159 y = size[1] / 2; 6160 i = -1; 6161 if (k) while (++i < n) { 6162 o = nodes[i]; 6163 o.x += (x - o.x) * k; 6164 o.y += (y - o.y) * k; 6165 } 6166 } 6167 if (charge) { 6168 d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alph
vendor: 13,209 bytes, lines 6168-6596
6168a, charges); 6169 i = -1; 6170 while (++i < n) { 6171 if (!(o = nodes[i]).fixed) { 6172 q.visit(repulse(o)); 6173 } 6174 } 6175 } 6176 i = -1; 6177 while (++i < n) { 6178 o = nodes[i]; 6179 if (o.fixed) { 6180 o.x = o.px; 6181 o.y = o.py; 6182 } else { 6183 o.x -= (o.px - (o.px = o.x)) * friction; 6184 o.y -= (o.py - (o.py = o.y)) * friction; 6185 } 6186 } 6187 event.tick({ 6188 type: "tick", 6189 alpha: alpha 6190 }); 6191 }; 6192 force.nodes = function(x) { 6193 if (!arguments.length) return nodes; 6194 nodes = x; 6195 return force; 6196 }; 6197 force.links = function(x) { 6198 if (!arguments.length) return links; 6199 links = x; 6200 return force; 6201 }; 6202 force.size = function(x) { 6203 if (!arguments.length) return size; 6204 size = x; 6205 return force; 6206 }; 6207 force.linkDistance = function(x) { 6208 if (!arguments.length) return linkDistance; 6209 linkDistance = typeof x === "function" ? x : +x; 6210 return force; 6211 }; 6212 force.distance = force.linkDistance; 6213 force.linkStrength = function(x) { 6214 if (!arguments.length) return linkStrength; 6215 linkStrength = typeof x === "function" ? x : +x; 6216 return force; 6217 }; 6218 force.friction = function(x) { 6219 if (!arguments.length) return friction; 6220 friction = +x; 6221 return force; 6222 }; 6223 force.charge = function(x) { 6224 if (!arguments.length) return charge; 6225 charge = typeof x === "function" ? x : +x; 6226 return force; 6227 }; 6228 force.chargeDistance = function(x) { 6229 if (!arguments.length) return Math.sqrt(chargeDistance2); 6230 chargeDistance2 = x * x; 6231 return force; 6232 }; 6233 force.gravity = function(x) { 6234 if (!arguments.length) return gravity; 6235 gravity = +x; 6236 return force; 6237 }; 6238 force.theta = function(x) { 6239 if (!arguments.length) return Math.sqrt(theta2); 6240 theta2 = x * x; 6241 return force; 6242 }; 6243 force.alpha = function(x) { 6244 if (!arguments.length) return alpha; 6245 x = +x; 6246 if (alpha) { 6247 if (x > 0) alpha = x; else alpha = 0; 6248 } else if (x > 0) { 6249 event.start({ 6250 type: "start", 6251 alpha: alpha = x 6252 }); 6253 d3.timer(force.tick); 6254 } 6255 return force; 6256 }; 6257 force.start = function() { 6258 var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; 6259 for (i = 0; i < n; ++i) { 6260 (o = nodes[i]).index = i; 6261 o.weight = 0; 6262 } 6263 for (i = 0; i < m; ++i) { 6264 o = links[i]; 6265 if (typeof o.source == "number") o.source = nodes[o.source]; 6266 if (typeof o.target == "number") o.target = nodes[o.target]; 6267 ++o.source.weight; 6268 ++o.target.weight; 6269 } 6270 for (i = 0; i < n; ++i) { 6271 o = nodes[i]; 6272 if (isNaN(o.x)) o.x = position("x", w); 6273 if (isNaN(o.y)) o.y = position("y", h); 6274 if (isNaN(o.px)) o.px = o.x; 6275 if (isNaN(o.py)) o.py = o.y; 6276 } 6277 distances = []; 6278 if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; 6279 strengths = []; 6280 if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; 6281 charges = []; 6282 if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; 6283 function position(dimension, size) { 6284 if (!neighbors) { 6285 neighbors = new Array(n); 6286 for (j = 0; j < n; ++j) { 6287 neighbors[j] = []; 6288 } 6289 for (j = 0; j < m; ++j) { 6290 var o = links[j]; 6291 neighbors[o.source.index].push(o.target); 6292 neighbors[o.target.index].push(o.source); 6293 } 6294 } 6295 var candidates = neighbors[i], j = -1, m = candidates.length, x; 6296 while (++j < m) if (!isNaN(x = candidates[j][dimension])) return x; 6297 return Math.random() * size; 6298 } 6299 return force.resume(); 6300 }; 6301 force.resume = function() { 6302 return force.alpha(.1); 6303 }; 6304 force.stop = function() { 6305 return force.alpha(0); 6306 }; 6307 force.drag = function() { 6308 if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); 6309 if (!arguments.length) return drag; 6310 this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); 6311 }; 6312 function dragmove(d) { 6313 d.px = d3.event.x, d.py = d3.event.y; 6314 force.resume(); 6315 } 6316 return d3.rebind(force, event, "on"); 6317 }; 6318 function d3_layout_forceDragstart(d) { 6319 d.fixed |= 2; 6320 } 6321 function d3_layout_forceDragend(d) { 6322 d.fixed &= ~6; 6323 } 6324 function d3_layout_forceMouseover(d) { 6325 d.fixed |= 4; 6326 d.px = d.x, d.py = d.y; 6327 } 6328 function d3_layout_forceMouseout(d) { 6329 d.fixed &= ~4; 6330 } 6331 function d3_layout_forceAccumulate(quad, alpha, charges) { 6332 var cx = 0, cy = 0; 6333 quad.charge = 0; 6334 if (!quad.leaf) { 6335 var nodes = quad.nodes, n = nodes.length, i = -1, c; 6336 while (++i < n) { 6337 c = nodes[i]; 6338 if (c == null) continue; 6339 d3_layout_forceAccumulate(c, alpha, charges); 6340 quad.charge += c.charge; 6341 cx += c.charge * c.cx; 6342 cy += c.charge * c.cy; 6343 } 6344 } 6345 if (quad.point) { 6346 if (!quad.leaf) { 6347 quad.point.x += Math.random() - .5; 6348 quad.point.y += Math.random() - .5; 6349 } 6350 var k = alpha * charges[quad.point.index]; 6351 quad.charge += quad.pointCharge = k; 6352 cx += k * quad.point.x; 6353 cy += k * quad.point.y; 6354 } 6355 quad.cx = cx / quad.charge; 6356 quad.cy = cy / quad.charge; 6357 } 6358 var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity; 6359 d3.layout.hierarchy = function() { 6360 var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; 6361 function recurse(node, depth, nodes) { 6362 var childs = children.call(hierarchy, node, depth); 6363 node.depth = depth; 6364 nodes.push(node); 6365 if (childs && (n = childs.length)) { 6366 var i = -1, n, c = node.children = new Array(n), v = 0, j = depth + 1, d; 6367 while (++i < n) { 6368 d = c[i] = recurse(childs[i], j, nodes); 6369 d.parent = node; 6370 v += d.value; 6371 } 6372 if (sort) c.sort(sort); 6373 if (value) node.value = v; 6374 } else { 6375 delete node.children; 6376 if (value) { 6377 node.value = +value.call(hierarchy, node, depth) || 0; 6378 } 6379 } 6380 return node; 6381 } 6382 function revalue(node, depth) { 6383 var children = node.children, v = 0; 6384 if (children && (n = children.length)) { 6385 var i = -1, n, j = depth + 1; 6386 while (++i < n) v += revalue(children[i], j); 6387 } else if (value) { 6388 v = +value.call(hierarchy, node, depth) || 0; 6389 } 6390 if (value) node.value = v; 6391 return v; 6392 } 6393 function hierarchy(d) { 6394 var nodes = []; 6395 recurse(d, 0, nodes); 6396 return nodes; 6397 } 6398 hierarchy.sort = function(x) { 6399 if (!arguments.length) return sort; 6400 sort = x; 6401 return hierarchy; 6402 }; 6403 hierarchy.children = function(x) { 6404 if (!arguments.length) return children; 6405 children = x; 6406 return hierarchy; 6407 }; 6408 hierarchy.value = function(x) { 6409 if (!arguments.length) return value; 6410 value = x; 6411 return hierarchy; 6412 }; 6413 hierarchy.revalue = function(root) { 6414 revalue(root, 0); 6415 return root; 6416 }; 6417 return hierarchy; 6418 }; 6419 function d3_layout_hierarchyRebind(object, hierarchy) { 6420 d3.rebind(object, hierarchy, "sort", "children", "value"); 6421 object.nodes = object; 6422 object.links = d3_layout_hierarchyLinks; 6423 return object; 6424 } 6425 function d3_layout_hierarchyChildren(d) { 6426 return d.children; 6427 } 6428 function d3_layout_hierarchyValue(d) { 6429 return d.value; 6430 } 6431 function d3_layout_hierarchySort(a, b) { 6432 return b.value - a.value; 6433 } 6434 function d3_layout_hierarchyLinks(nodes) { 6435 return d3.merge(nodes.map(function(parent) { 6436 return (parent.children || []).map(function(child) { 6437 return { 6438 source: parent, 6439 target: child 6440 }; 6441 }); 6442 })); 6443 } 6444 d3.layout.partition = function() { 6445 var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; 6446 function position(node, x, dx, dy) { 6447 var children = node.children; 6448 node.x = x; 6449 node.y = node.depth * dy; 6450 node.dx = dx; 6451 node.dy = dy; 6452 if (children && (n = children.length)) { 6453 var i = -1, n, c, d; 6454 dx = node.value ? dx / node.value : 0; 6455 while (++i < n) { 6456 position(c = children[i], x, d = c.value * dx, dy); 6457 x += d; 6458 } 6459 } 6460 } 6461 function depth(node) { 6462 var children = node.children, d = 0; 6463 if (children && (n = children.length)) { 6464 var i = -1, n; 6465 while (++i < n) d = Math.max(d, depth(children[i])); 6466 } 6467 return 1 + d; 6468 } 6469 function partition(d, i) { 6470 var nodes = hierarchy.call(this, d, i); 6471 position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); 6472 return nodes; 6473 } 6474 partition.size = function(x) { 6475 if (!arguments.length) return size; 6476 size = x; 6477 return partition; 6478 }; 6479 return d3_layout_hierarchyRebind(partition, hierarchy); 6480 }; 6481 d3.layout.pie = function() { 6482 var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = Ï; 6483 function pie(data) { 6484 var values = data.map(function(d, i) { 6485 return +value.call(pie, d, i); 6486 }); 6487 var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); 6488 var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values); 6489 var index = d3.range(data.length); 6490 if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { 6491 return values[j] - values[i]; 6492 } : function(i, j) { 6493 return sort(data[i], data[j]); 6494 }); 6495 var arcs = []; 6496 index.forEach(function(i) { 6497 var d; 6498 arcs[i] = { 6499 data: data[i], 6500 value: d = values[i], 6501 startAngle: a, 6502 endAngle: a += d * k 6503 }; 6504 }); 6505 return arcs; 6506 } 6507 pie.value = function(x) { 6508 if (!arguments.length) return value; 6509 value = x; 6510 return pie; 6511 }; 6512 pie.sort = function(x) { 6513 if (!arguments.length) return sort; 6514 sort = x; 6515 return pie; 6516 }; 6517 pie.startAngle = function(x) { 6518 if (!arguments.length) return startAngle; 6519 startAngle = x; 6520 return pie; 6521 }; 6522 pie.endAngle = function(x) { 6523 if (!arguments.length) return endAngle; 6524 endAngle = x; 6525 return pie; 6526 }; 6527 return pie; 6528 }; 6529 var d3_layout_pieSortByValue = {}; 6530 d3.layout.stack = function() { 6531 var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; 6532 function stack(data, index) { 6533 var series = data.map(function(d, i) { 6534 return values.call(stack, d, i); 6535 }); 6536 var points = series.map(function(d) { 6537 return d.map(function(v, i) { 6538 return [ x.call(stack, v, i), y.call(stack, v, i) ]; 6539 }); 6540 }); 6541 var orders = order.call(stack, points, index); 6542 series = d3.permute(series, orders); 6543 points = d3.permute(points, orders); 6544 var offsets = offset.call(stack, points, index); 6545 var n = series.length, m = series[0].length, i, j, o; 6546 for (j = 0; j < m; ++j) { 6547 out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); 6548 for (i = 1; i < n; ++i) { 6549 out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); 6550 } 6551 } 6552 return data; 6553 } 6554 stack.values = function(x) { 6555 if (!arguments.length) return values; 6556 values = x; 6557 return stack; 6558 }; 6559 stack.order = function(x) { 6560 if (!arguments.length) return order; 6561 order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; 6562 return stack; 6563 }; 6564 stack.offset = function(x) { 6565 if (!arguments.length) return offset; 6566 offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; 6567 return stack; 6568 }; 6569 stack.x = function(z) { 6570 if (!arguments.length) return x; 6571 x = z; 6572 return stack; 6573 }; 6574 stack.y = function(z) { 6575 if (!arguments.length) return y; 6576 y = z; 6577 return stack; 6578 }; 6579 stack.out = function(z) { 6580 if (!arguments.length) return out; 6581 out = z; 6582 return stack; 6583 }; 6584 return stack; 6585 }; 6586 function d3_layout_stackX(d) { 6587 return d.x; 6588 } 6589 function d3_layout_stackY(d) { 6590 return d.y; 6591 } 6592 function d3_layout_stackOut(d, y0, y) { 6593 d.y0 = y0; 6594 d.y = y; 6595 } 6596 var d3_layout_stackOrders = d3.map({
vendor: 4,935 bytes, lines 6597-6741
6597 "inside-out": function(data) { 6598 var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { 6599 return max[a] - max[b]; 6600 }), top = 0, bottom = 0, tops = [], bottoms = []; 6601 for (i = 0; i < n; ++i) { 6602 j = index[i]; 6603 if (top < bottom) { 6604 top += sums[j]; 6605 tops.push(j); 6606 } else { 6607 bottom += sums[j]; 6608 bottoms.push(j); 6609 } 6610 } 6611 return bottoms.reverse().concat(tops); 6612 }, 6613 reverse: function(data) { 6614 return d3.range(data.length).reverse(); 6615 }, 6616 "default": d3_layout_stackOrderDefault 6617 }); 6618 var d3_layout_stackOffsets = d3.map({ 6619 silhouette: function(data) { 6620 var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; 6621 for (j = 0; j < m; ++j) { 6622 for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; 6623 if (o > max) max = o; 6624 sums.push(o); 6625 } 6626 for (j = 0; j < m; ++j) { 6627 y0[j] = (max - sums[j]) / 2; 6628 } 6629 return y0; 6630 }, 6631 wiggle: function(data) { 6632 var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; 6633 y0[0] = o = o0 = 0; 6634 for (j = 1; j < m; ++j) { 6635 for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; 6636 for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { 6637 for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { 6638 s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; 6639 } 6640 s2 += s3 * data[i][j][1]; 6641 } 6642 y0[j] = o -= s1 ? s2 / s1 * dx : 0; 6643 if (o < o0) o0 = o; 6644 } 6645 for (j = 0; j < m; ++j) y0[j] -= o0; 6646 return y0; 6647 }, 6648 expand: function(data) { 6649 var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; 6650 for (j = 0; j < m; ++j) { 6651 for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; 6652 if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; 6653 } 6654 for (j = 0; j < m; ++j) y0[j] = 0; 6655 return y0; 6656 }, 6657 zero: d3_layout_stackOffsetZero 6658 }); 6659 function d3_layout_stackOrderDefault(data) { 6660 return d3.range(data.length); 6661 } 6662 function d3_layout_stackOffsetZero(data) { 6663 var j = -1, m = data[0].length, y0 = []; 6664 while (++j < m) y0[j] = 0; 6665 return y0; 6666 } 6667 function d3_layout_stackMaxIndex(array) { 6668 var i = 1, j = 0, v = array[0][1], k, n = array.length; 6669 for (;i < n; ++i) { 6670 if ((k = array[i][1]) > v) { 6671 j = i; 6672 v = k; 6673 } 6674 } 6675 return j; 6676 } 6677 function d3_layout_stackReduceSum(d) { 6678 return d.reduce(d3_layout_stackSum, 0); 6679 } 6680 function d3_layout_stackSum(p, d) { 6681 return p + d[1]; 6682 } 6683 d3.layout.histogram = function() { 6684 var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; 6685 function histogram(data, i) { 6686 var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; 6687 while (++i < m) { 6688 bin = bins[i] = []; 6689 bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); 6690 bin.y = 0; 6691 } 6692 if (m > 0) { 6693 i = -1; 6694 while (++i < n) { 6695 x = values[i]; 6696 if (x >= range[0] && x <= range[1]) { 6697 bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; 6698 bin.y += k; 6699 bin.push(data[i]); 6700 } 6701 } 6702 } 6703 return bins; 6704 } 6705 histogram.value = function(x) { 6706 if (!arguments.length) return valuer; 6707 valuer = x; 6708 return histogram; 6709 }; 6710 histogram.range = function(x) { 6711 if (!arguments.length) return ranger; 6712 ranger = d3_functor(x); 6713 return histogram; 6714 }; 6715 histogram.bins = function(x) { 6716 if (!arguments.length) return binner; 6717 binner = typeof x === "number" ? function(range) { 6718 return d3_layout_histogramBinFixed(range, x); 6719 } : d3_functor(x); 6720 return histogram; 6721 }; 6722 histogram.frequency = function(x) { 6723 if (!arguments.length) return frequency; 6724 frequency = !!x; 6725 return histogram; 6726 }; 6727 return histogram; 6728 }; 6729 function d3_layout_histogramBinSturges(range, values) { 6730 return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); 6731 } 6732 function d3_layout_histogramBinFixed(range, n) { 6733 var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; 6734 while (++x <= n) f[x] = m * x + b; 6735 return f; 6736 } 6737 function d3_layout_histogramRange(values) { 6738 return [ d3.min(values), d3.max(values) ]; 6739 } 6740 d3.layout.tree = function() { 6741 var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
6742 function tree(d, i) { 6743 var nodes = hierarchy.call(this, d, i), root = nodes[0]; 6744 function firstWalk(node, previousSibling) { 6745 var children = node.children, layout = node._tree; 6746 if (children && (n = children.length)) { 6747 var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1; 6748 while (++i < n) { 6749 child = children[i]; 6750 firstWalk(child, previousChild); 6751 ancestor = apportion(child, previousChild, ancestor); 6752 previousChild = child; 6753 } 6754 d3_layout_treeShift(node); 6755 var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim); 6756 if (previousSibling) { 6757 layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); 6758 layout.mod = layout.prelim - midpoint; 6759 } else { 6760 layout.prelim = midpoint; 6761 } 6762 } else { 6763 if (previousSibling) { 6764 layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); 6765 } 6766 } 6767 } 6768 function secondWalk(node, x) { 6769 node.x = node._tree.prelim + x; 6770 var children = node.children; 6771 if (children && (n = children.length)) { 6772 var i = -1, n; 6773 x += node._tree.mod; 6774 while (++i < n) { 6775 secondWalk(children[i], x); 6776 } 6777 } 6778 } 6779 function apportion(node, previousSibling, ancestor) { 6780 if (previousSibling) { 6781 var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift; 6782 while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { 6783 vom = d3_layout_treeLeft(vom); 6784 vop = d3_layout_treeRight(vop); 6785 vop._tree.ancestor = node; 6786 shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip); 6787 if (shift > 0) { 6788 d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift); 6789 sip += shift; 6790 sop += shift; 6791 } 6792 sim += vim._tree.mod; 6793 sip += vip._tree.mod; 6794 som += vom._tree.mod; 6795 sop += vop._tree.mod; 6796 } 6797 if (vim && !d3_layout_treeRight(vop)) { 6798 vop._tree.thread = vim; 6799 vop._tree.mod += sim - sop; 6800 } 6801 if (vip && !d3_layout_treeLeft(vom)) { 6802 vom._tree.thread = vip; 6803 vom._tree.mod += sip - som; 6804 ancestor = node; 6805 } 6806 } 6807 return ancestor; 6808 } 6809 d3_layout_treeVisitAfter(root, function(node, previousSibling) { 6810 node._tree = { 6811 ancestor: node, 6812 prelim: 0, 6813 mod: 0, 6814 change: 0, 6815 shift: 0, 6816 number: previousSibling ? previousSibling._tree.number + 1 : 0 6817 }; 6818 }); 6819 firstWalk(root); 6820 secondWalk(root, -root._tree.prelim); 6821 var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1; 6822 d3_layout_treeVisitAfter(root, nodeSize ? function(node) { 6823 node.x *= size[0]; 6824 node.y = node.depth * size[1]; 6825 delete node._tree; 6826 } : function(node) { 6827 node.x = (node.x - x0) / (x1 - x0) * size[0]; 6828 node.y = node.depth / y1 * size[1]; 6829 delete node._tree; 6830 }); 6831 return nodes; 6832 } 6833 tree.separation = function(x) { 6834 if (!arguments.length) return separation; 6835 separation = x; 6836 return tree; 6837 }; 6838 tree.size = function(x) { 6839 if (!arguments.length) return nodeSize ? null : size; 6840 nodeSize = (size = x) == null; 6841 return tree; 6842 }; 6843 tree.nodeSize = function(x) { 6844 if (!arguments.length) return nodeSize ? size : null; 6845 nodeSize = (size = x) != null; 6846 return tree; 6847 }; 6848 return d3_layout_hierarchyRebind(tree, hierarchy); 6849 }; 6850 function d3_layout_treeSeparation(a, b) { 6851 return a.parent == b.parent ? 1 : 2; 6852 } 6853 function d3_layout_treeLeft(node) { 6854 var children = node.children; 6855 return children && children.length ? children[0] : node._tree.thread; 6856 } 6857 function d3_layout_treeRight(node) { 6858 var children = node.children, n; 6859 return children && (n = children.length) ? children[n - 1] : node._tree.thread; 6860 } 6861 function d3_layout_treeSearch(node, compare) { 6862 var children = node.children; 6863 if (children && (n = children.length)) { 6864 var child, n, i = -1; 6865 while (++i < n) { 6866 if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) { 6867 node = child; 6868 } 6869 } 6870 } 6871 return node; 6872 } 6873 function d3_layout_treeRightmost(a, b) { 6874 return a.x - b.x; 6875 } 6876 function d3_layout_treeLeftmost(a, b) { 6877 return b.x - a.x; 6878 } 6879 function d3_layout_treeDeepest(a, b) { 6880 return a.depth - b.depth; 6881 } 6882 function d3_layout_treeVisitAfter(node, callback) { 6883 function visit(node, previousSibling) { 6884 var children = node.children; 6885 if (children && (n = children.length)) { 6886 var child, previousChild = null, i = -1, n; 6887 while (++i < n) { 6888 child = children[i]; 6889 visit(child, previousChild); 6890 previousChild = child; 6891 } 6892 } 6893 callback(node, previousSibling); 6894 } 6895 visit(node, null); 6896 } 6897 function d3_layout_treeShift(node) { 6898 var shift = 0, change = 0, children = node.children, i = children.length, child; 6899 while (--i >= 0) { 6900 child = children[i]._tree; 6901 child.prelim += shift; 6902 child.mod += shift; 6903 shift += child.shift + (change += child.change); 6904 } 6905 } 6906 function d3_layout_treeMove(ancestor, node, shift) { 6907 ancestor = ancestor._tree; 6908 node = node._tree; 6909 var change = shift / (node.number - ancestor.number); 6910 ancestor.change += change; 6911 node.change -= change; 6912 node.shift += shift; 6913 node.prelim += shift; 6914 node.mod += shift; 6915 } 6916 function d3_layout_treeAncestor(vim, node, ancestor) { 6917 return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor; 6918 } 6919 d3.layout.pack = function() { 6920 var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; 6921 function pack(d, i) { 6922 var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() {
vendor: 8,994 bytes, lines 6923-7182
6923 return radius; 6924 }; 6925 root.x = root.y = 0; 6926 d3_layout_treeVisitAfter(root, function(d) { 6927 d.r = +r(d.value); 6928 }); 6929 d3_layout_treeVisitAfter(root, d3_layout_packSiblings); 6930 if (padding) { 6931 var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; 6932 d3_layout_treeVisitAfter(root, function(d) { 6933 d.r += dr; 6934 }); 6935 d3_layout_treeVisitAfter(root, d3_layout_packSiblings); 6936 d3_layout_treeVisitAfter(root, function(d) { 6937 d.r -= dr; 6938 }); 6939 } 6940 d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); 6941 return nodes; 6942 } 6943 pack.size = function(_) { 6944 if (!arguments.length) return size; 6945 size = _; 6946 return pack; 6947 }; 6948 pack.radius = function(_) { 6949 if (!arguments.length) return radius; 6950 radius = _ == null || typeof _ === "function" ? _ : +_; 6951 return pack; 6952 }; 6953 pack.padding = function(_) { 6954 if (!arguments.length) return padding; 6955 padding = +_; 6956 return pack; 6957 }; 6958 return d3_layout_hierarchyRebind(pack, hierarchy); 6959 }; 6960 function d3_layout_packSort(a, b) { 6961 return a.value - b.value; 6962 } 6963 function d3_layout_packInsert(a, b) { 6964 var c = a._pack_next; 6965 a._pack_next = b; 6966 b._pack_prev = a; 6967 b._pack_next = c; 6968 c._pack_prev = b; 6969 } 6970 function d3_layout_packSplice(a, b) { 6971 a._pack_next = b; 6972 b._pack_prev = a; 6973 } 6974 function d3_layout_packIntersects(a, b) { 6975 var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; 6976 return .999 * dr * dr > dx * dx + dy * dy; 6977 } 6978 function d3_layout_packSiblings(node) { 6979 if (!(nodes = node.children) || !(n = nodes.length)) return; 6980 var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; 6981 function bound(node) { 6982 xMin = Math.min(node.x - node.r, xMin); 6983 xMax = Math.max(node.x + node.r, xMax); 6984 yMin = Math.min(node.y - node.r, yMin); 6985 yMax = Math.max(node.y + node.r, yMax); 6986 } 6987 nodes.forEach(d3_layout_packLink); 6988 a = nodes[0]; 6989 a.x = -a.r; 6990 a.y = 0; 6991 bound(a); 6992 if (n > 1) { 6993 b = nodes[1]; 6994 b.x = b.r; 6995 b.y = 0; 6996 bound(b); 6997 if (n > 2) { 6998 c = nodes[2]; 6999 d3_layout_packPlace(a, b, c); 7000 bound(c); 7001 d3_layout_packInsert(a, c); 7002 a._pack_prev = c; 7003 d3_layout_packInsert(c, b); 7004 b = a._pack_next; 7005 for (i = 3; i < n; i++) { 7006 d3_layout_packPlace(a, b, c = nodes[i]); 7007 var isect = 0, s1 = 1, s2 = 1; 7008 for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { 7009 if (d3_layout_packIntersects(j, c)) { 7010 isect = 1; 7011 break; 7012 } 7013 } 7014 if (isect == 1) { 7015 for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { 7016 if (d3_layout_packIntersects(k, c)) { 7017 break; 7018 } 7019 } 7020 } 7021 if (isect) { 7022 if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); 7023 i--; 7024 } else { 7025 d3_layout_packInsert(a, c); 7026 b = c; 7027 bound(c); 7028 } 7029 } 7030 } 7031 } 7032 var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; 7033 for (i = 0; i < n; i++) { 7034 c = nodes[i]; 7035 c.x -= cx; 7036 c.y -= cy; 7037 cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); 7038 } 7039 node.r = cr; 7040 nodes.forEach(d3_layout_packUnlink); 7041 } 7042 function d3_layout_packLink(node) { 7043 node._pack_next = node._pack_prev = node; 7044 } 7045 function d3_layout_packUnlink(node) { 7046 delete node._pack_next; 7047 delete node._pack_prev; 7048 } 7049 function d3_layout_packTransform(node, x, y, k) { 7050 var children = node.children; 7051 node.x = x += k * node.x; 7052 node.y = y += k * node.y; 7053 node.r *= k; 7054 if (children) { 7055 var i = -1, n = children.length; 7056 while (++i < n) d3_layout_packTransform(children[i], x, y, k); 7057 } 7058 } 7059 function d3_layout_packPlace(a, b, c) { 7060 var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; 7061 if (db && (dx || dy)) { 7062 var da = b.r + c.r, dc = dx * dx + dy * dy; 7063 da *= da; 7064 db *= db; 7065 var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); 7066 c.x = a.x + x * dx + y * dy; 7067 c.y = a.y + x * dy - y * dx; 7068 } else { 7069 c.x = a.x + db; 7070 c.y = a.y; 7071 } 7072 } 7073 d3.layout.cluster = function() { 7074 var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; 7075 function cluster(d, i) { 7076 var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; 7077 d3_layout_treeVisitAfter(root, function(node) { 7078 var children = node.children; 7079 if (children && children.length) { 7080 node.x = d3_layout_clusterX(children); 7081 node.y = d3_layout_clusterY(children); 7082 } else { 7083 node.x = previousNode ? x += separation(node, previousNode) : 0; 7084 node.y = 0; 7085 previousNode = node; 7086 } 7087 }); 7088 var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; 7089 d3_layout_treeVisitAfter(root, nodeSize ? function(node) { 7090 node.x = (node.x - root.x) * size[0]; 7091 node.y = (root.y - node.y) * size[1]; 7092 } : function(node) { 7093 node.x = (node.x - x0) / (x1 - x0) * size[0]; 7094 node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; 7095 }); 7096 return nodes; 7097 } 7098 cluster.separation = function(x) { 7099 if (!arguments.length) return separation; 7100 separation = x; 7101 return cluster; 7102 }; 7103 cluster.size = function(x) { 7104 if (!arguments.length) return nodeSize ? null : size; 7105 nodeSize = (size = x) == null; 7106 return cluster; 7107 }; 7108 cluster.nodeSize = function(x) { 7109 if (!arguments.length) return nodeSize ? size : null; 7110 nodeSize = (size = x) != null; 7111 return cluster; 7112 }; 7113 return d3_layout_hierarchyRebind(cluster, hierarchy); 7114 }; 7115 function d3_layout_clusterY(children) { 7116 return 1 + d3.max(children, function(child) { 7117 return child.y; 7118 }); 7119 } 7120 function d3_layout_clusterX(children) { 7121 return children.reduce(function(x, child) { 7122 return x + child.x; 7123 }, 0) / children.length; 7124 } 7125 function d3_layout_clusterLeft(node) { 7126 var children = node.children; 7127 return children && children.length ? d3_layout_clusterLeft(children[0]) : node; 7128 } 7129 function d3_layout_clusterRight(node) { 7130 var children = node.children, n; 7131 return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; 7132 } 7133 d3.layout.treemap = function() { 7134 var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); 7135 function scale(children, k) { 7136 var i = -1, n = children.length, child, area; 7137 while (++i < n) { 7138 area = (child = children[i]).value * (k < 0 ? 0 : k); 7139 child.area = isNaN(area) || area <= 0 ? 0 : area; 7140 } 7141 } 7142 function squarify(node) { 7143 var children = node.children; 7144 if (children && children.length) { 7145 var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; 7146 scale(remaining, rect.dx * rect.dy / node.value); 7147 row.area = 0; 7148 while ((n = remaining.length) > 0) { 7149 row.push(child = remaining[n - 1]); 7150 row.area += child.area; 7151 if (mode !== "squarify" || (score = worst(row, u)) <= best) { 7152 remaining.pop(); 7153 best = score; 7154 } else { 7155 row.area -= row.pop().area; 7156 position(row, u, rect, false); 7157 u = Math.min(rect.dx, rect.dy); 7158 row.length = row.area = 0; 7159 best = Infinity; 7160 } 7161 } 7162 if (row.length) { 7163 position(row, u, rect, true); 7164 row.length = row.area = 0; 7165 } 7166 children.forEach(squarify); 7167 } 7168 } 7169 function stickify(node) { 7170 var children = node.children; 7171 if (children && children.length) { 7172 var rect = pad(node), remaining = children.slice(), child, row = []; 7173 scale(remaining, rect.dx * rect.dy / node.value); 7174 row.area = 0; 7175 while (child = remaining.pop()) { 7176 row.push(child); 7177 row.area += child.area; 7178 if (child.z != null) { 7179 position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); 7180 row.length = row.area = 0; 7181 } 7182 }
vendor: 6,641 bytes, lines 7183-7403
7183 children.forEach(stickify); 7184 } 7185 } 7186 function worst(row, u) { 7187 var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; 7188 while (++i < n) { 7189 if (!(r = row[i].area)) continue; 7190 if (r < rmin) rmin = r; 7191 if (r > rmax) rmax = r; 7192 } 7193 s *= s; 7194 u *= u; 7195 return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; 7196 } 7197 function position(row, u, rect, flush) { 7198 var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; 7199 if (u == rect.dx) { 7200 if (flush || v > rect.dy) v = rect.dy; 7201 while (++i < n) { 7202 o = row[i]; 7203 o.x = x; 7204 o.y = y; 7205 o.dy = v; 7206 x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); 7207 } 7208 o.z = true; 7209 o.dx += rect.x + rect.dx - x; 7210 rect.y += v; 7211 rect.dy -= v; 7212 } else { 7213 if (flush || v > rect.dx) v = rect.dx; 7214 while (++i < n) { 7215 o = row[i]; 7216 o.x = x; 7217 o.y = y; 7218 o.dx = v; 7219 y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); 7220 } 7221 o.z = false; 7222 o.dy += rect.y + rect.dy - y; 7223 rect.x += v; 7224 rect.dx -= v; 7225 } 7226 } 7227 function treemap(d) { 7228 var nodes = stickies || hierarchy(d), root = nodes[0]; 7229 root.x = 0; 7230 root.y = 0; 7231 root.dx = size[0]; 7232 root.dy = size[1]; 7233 if (stickies) hierarchy.revalue(root); 7234 scale([ root ], root.dx * root.dy / root.value); 7235 (stickies ? stickify : squarify)(root); 7236 if (sticky) stickies = nodes; 7237 return nodes; 7238 } 7239 treemap.size = function(x) { 7240 if (!arguments.length) return size; 7241 size = x; 7242 return treemap; 7243 }; 7244 treemap.padding = function(x) { 7245 if (!arguments.length) return padding; 7246 function padFunction(node) { 7247 var p = x.call(treemap, node, node.depth); 7248 return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); 7249 } 7250 function padConstant(node) { 7251 return d3_layout_treemapPad(node, x); 7252 } 7253 var type; 7254 pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], 7255 padConstant) : padConstant; 7256 return treemap; 7257 }; 7258 treemap.round = function(x) { 7259 if (!arguments.length) return round != Number; 7260 round = x ? Math.round : Number; 7261 return treemap; 7262 }; 7263 treemap.sticky = function(x) { 7264 if (!arguments.length) return sticky; 7265 sticky = x; 7266 stickies = null; 7267 return treemap; 7268 }; 7269 treemap.ratio = function(x) { 7270 if (!arguments.length) return ratio; 7271 ratio = x; 7272 return treemap; 7273 }; 7274 treemap.mode = function(x) { 7275 if (!arguments.length) return mode; 7276 mode = x + ""; 7277 return treemap; 7278 }; 7279 return d3_layout_hierarchyRebind(treemap, hierarchy); 7280 }; 7281 function d3_layout_treemapPadNull(node) { 7282 return { 7283 x: node.x, 7284 y: node.y, 7285 dx: node.dx, 7286 dy: node.dy 7287 }; 7288 } 7289 function d3_layout_treemapPad(node, padding) { 7290 var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; 7291 if (dx < 0) { 7292 x += dx / 2; 7293 dx = 0; 7294 } 7295 if (dy < 0) { 7296 y += dy / 2; 7297 dy = 0; 7298 } 7299 return { 7300 x: x, 7301 y: y, 7302 dx: dx, 7303 dy: dy 7304 }; 7305 } 7306 d3.random = { 7307 normal: function(µ, Ï) { 7308 var n = arguments.length; 7309 if (n < 2) Ï = 1; 7310 if (n < 1) µ = 0; 7311 return function() { 7312 var x, y, r; 7313 do { 7314 x = Math.random() * 2 - 1; 7315 y = Math.random() * 2 - 1; 7316 r = x * x + y * y; 7317 } while (!r || r > 1); 7318 return µ + Ï * x * Math.sqrt(-2 * Math.log(r) / r); 7319 }; 7320 }, 7321 logNormal: function() { 7322 var random = d3.random.normal.apply(d3, arguments); 7323 return function() { 7324 return Math.exp(random()); 7325 }; 7326 }, 7327 bates: function(m) { 7328 var random = d3.random.irwinHall(m); 7329 return function() { 7330 return random() / m; 7331 }; 7332 }, 7333 irwinHall: function(m) { 7334 return function() { 7335 for (var s = 0, j = 0; j < m; j++) s += Math.random(); 7336 return s; 7337 }; 7338 } 7339 }; 7340 d3.scale = {}; 7341 function d3_scaleExtent(domain) { 7342 var start = domain[0], stop = domain[domain.length - 1]; 7343 return start < stop ? [ start, stop ] : [ stop, start ]; 7344 } 7345 function d3_scaleRange(scale) { 7346 return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); 7347 } 7348 function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { 7349 var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); 7350 return function(x) { 7351 return i(u(x)); 7352 }; 7353 } 7354 function d3_scale_nice(domain, nice) { 7355 var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; 7356 if (x1 < x0) { 7357 dx = i0, i0 = i1, i1 = dx; 7358 dx = x0, x0 = x1, x1 = dx; 7359 } 7360 domain[i0] = nice.floor(x0); 7361 domain[i1] = nice.ceil(x1); 7362 return domain; 7363 } 7364 function d3_scale_niceStep(step) { 7365 return step ? { 7366 floor: function(x) { 7367 return Math.floor(x / step) * step; 7368 }, 7369 ceil: function(x) { 7370 return Math.ceil(x / step) * step; 7371 } 7372 } : d3_scale_niceIdentity; 7373 } 7374 var d3_scale_niceIdentity = { 7375 floor: d3_identity, 7376 ceil: d3_identity 7377 }; 7378 function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { 7379 var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; 7380 if (domain[k] < domain[0]) { 7381 domain = domain.slice().reverse(); 7382 range = range.slice().reverse(); 7383 } 7384 while (++j <= k) { 7385 u.push(uninterpolate(domain[j - 1], domain[j])); 7386 i.push(interpolate(range[j - 1], range[j])); 7387 } 7388 return function(x) { 7389 var j = d3.bisect(domain, x, 1, k) - 1; 7390 return i[j](u[j](x)); 7391 }; 7392 } 7393 d3.scale.linear = function() { 7394 return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); 7395 }; 7396 function d3_scale_linear(domain, range, interpolate, clamp) { 7397 var output, input; 7398 function rescale() { 7399 var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; 7400 output = linear(domain, range, uninterpolate, interpolate); 7401 input = linear(range, domain, uninterpolate, d3_interpolate); 7402 return scale; 7403 }
vendor: 5,722 bytes, lines 7404-7562
7404 function scale(x) { 7405 return output(x); 7406 } 7407 scale.invert = function(y) { 7408 return input(y); 7409 }; 7410 scale.domain = function(x) { 7411 if (!arguments.length) return domain; 7412 domain = x.map(Number); 7413 return rescale(); 7414 }; 7415 scale.range = function(x) { 7416 if (!arguments.length) return range; 7417 range = x; 7418 return rescale(); 7419 }; 7420 scale.rangeRound = function(x) { 7421 return scale.range(x).interpolate(d3_interpolateRound); 7422 }; 7423 scale.clamp = function(x) { 7424 if (!arguments.length) return clamp; 7425 clamp = x; 7426 return rescale(); 7427 }; 7428 scale.interpolate = function(x) { 7429 if (!arguments.length) return interpolate; 7430 interpolate = x; 7431 return rescale(); 7432 }; 7433 scale.ticks = function(m) { 7434 return d3_scale_linearTicks(domain, m); 7435 }; 7436 scale.tickFormat = function(m, format) { 7437 return d3_scale_linearTickFormat(domain, m, format); 7438 }; 7439 scale.nice = function(m) { 7440 d3_scale_linearNice(domain, m); 7441 return rescale(); 7442 }; 7443 scale.copy = function() { 7444 return d3_scale_linear(domain, range, interpolate, clamp); 7445 }; 7446 return rescale(); 7447 } 7448 function d3_scale_linearRebind(scale, linear) { 7449 return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); 7450 } 7451 function d3_scale_linearNice(domain, m) { 7452 return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); 7453 } 7454 function d3_scale_linearTickRange(domain, m) { 7455 if (m == null) m = 10; 7456 var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; 7457 if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; 7458 extent[0] = Math.ceil(extent[0] / step) * step; 7459 extent[1] = Math.floor(extent[1] / step) * step + step * .5; 7460 extent[2] = step; 7461 return extent; 7462 } 7463 function d3_scale_linearTicks(domain, m) { 7464 return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); 7465 } 7466 function d3_scale_linearTickFormat(domain, m, format) { 7467 var range = d3_scale_linearTickRange(domain, m); 7468 return d3.format(format ? format.replace(d3_format_re, function(a, b, c, d, e, f, g, h, i, j) { 7469 return [ b, c, d, e, f, g, h, i || "." + d3_scale_linearFormatPrecision(j, range), j ].join(""); 7470 }) : ",." + d3_scale_linearPrecision(range[2]) + "f"); 7471 } 7472 var d3_scale_linearFormatSignificant = { 7473 s: 1, 7474 g: 1, 7475 p: 1, 7476 r: 1, 7477 e: 1 7478 }; 7479 function d3_scale_linearPrecision(value) { 7480 return -Math.floor(Math.log(value) / Math.LN10 + .01); 7481 } 7482 function d3_scale_linearFormatPrecision(type, range) { 7483 var p = d3_scale_linearPrecision(range[2]); 7484 return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(Math.abs(range[0]), Math.abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; 7485 } 7486 d3.scale.log = function() { 7487 return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); 7488 }; 7489 function d3_scale_log(linear, base, positive, domain) { 7490 function log(x) { 7491 return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base); 7492 } 7493 function pow(x) { 7494 return positive ? Math.pow(base, x) : -Math.pow(base, -x); 7495 } 7496 function scale(x) { 7497 return linear(log(x)); 7498 } 7499 scale.invert = function(x) { 7500 return pow(linear.invert(x)); 7501 }; 7502 scale.domain = function(x) { 7503 if (!arguments.length) return domain; 7504 positive = x[0] >= 0; 7505 linear.domain((domain = x.map(Number)).map(log)); 7506 return scale; 7507 }; 7508 scale.base = function(_) { 7509 if (!arguments.length) return base; 7510 base = +_; 7511 linear.domain(domain.map(log)); 7512 return scale; 7513 }; 7514 scale.nice = function() { 7515 var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative); 7516 linear.domain(niced); 7517 domain = niced.map(pow); 7518 return scale; 7519 }; 7520 scale.ticks = function() { 7521 var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base; 7522 if (isFinite(j - i)) { 7523 if (positive) { 7524 for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k); 7525 ticks.push(pow(i)); 7526 } else { 7527 ticks.push(pow(i)); 7528 for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k); 7529 } 7530 for (i = 0; ticks[i] < u; i++) {} 7531 for (j = ticks.length; ticks[j - 1] > v; j--) {} 7532 ticks = ticks.slice(i, j); 7533 } 7534 return ticks; 7535 }; 7536 scale.tickFormat = function(n, format) { 7537 if (!arguments.length) return d3_scale_logFormat; 7538 if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); 7539 var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12, 7540 Math.floor), e; 7541 return function(d) { 7542 return d / pow(f(log(d) + e)) <= k ? format(d) : ""; 7543 }; 7544 }; 7545 scale.copy = function() { 7546 return d3_scale_log(linear.copy(), base, positive, domain); 7547 }; 7548 return d3_scale_linearRebind(scale, linear); 7549 } 7550 var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = { 7551 floor: function(x) { 7552 return -Math.ceil(-x); 7553 }, 7554 ceil: function(x) { 7555 return -Math.floor(-x); 7556 } 7557 }; 7558 d3.scale.pow = function() { 7559 return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); 7560 }; 7561 function d3_scale_pow(linear, exponent, domain) { 7562 var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
vendor: 4,635 bytes, lines 7563-7698
7563 function scale(x) { 7564 return linear(powp(x)); 7565 } 7566 scale.invert = function(x) { 7567 return powb(linear.invert(x)); 7568 }; 7569 scale.domain = function(x) { 7570 if (!arguments.length) return domain; 7571 linear.domain((domain = x.map(Number)).map(powp)); 7572 return scale; 7573 }; 7574 scale.ticks = function(m) { 7575 return d3_scale_linearTicks(domain, m); 7576 }; 7577 scale.tickFormat = function(m, format) { 7578 return d3_scale_linearTickFormat(domain, m, format); 7579 }; 7580 scale.nice = function(m) { 7581 return scale.domain(d3_scale_linearNice(domain, m)); 7582 }; 7583 scale.exponent = function(x) { 7584 if (!arguments.length) return exponent; 7585 powp = d3_scale_powPow(exponent = x); 7586 powb = d3_scale_powPow(1 / exponent); 7587 linear.domain(domain.map(powp)); 7588 return scale; 7589 }; 7590 scale.copy = function() { 7591 return d3_scale_pow(linear.copy(), exponent, domain); 7592 }; 7593 return d3_scale_linearRebind(scale, linear); 7594 } 7595 function d3_scale_powPow(e) { 7596 return function(x) { 7597 return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); 7598 }; 7599 } 7600 d3.scale.sqrt = function() { 7601 return d3.scale.pow().exponent(.5); 7602 }; 7603 d3.scale.ordinal = function() { 7604 return d3_scale_ordinal([], { 7605 t: "range", 7606 a: [ [] ] 7607 }); 7608 }; 7609 function d3_scale_ordinal(domain, ranger) { 7610 var index, range, rangeBand; 7611 function scale(x) { 7612 return range[((index.get(x) || ranger.t === "range" && index.set(x, domain.push(x))) - 1) % range.length]; 7613 } 7614 function steps(start, step) { 7615 return d3.range(domain.length).map(function(i) { 7616 return start + step * i; 7617 }); 7618 } 7619 scale.domain = function(x) { 7620 if (!arguments.length) return domain; 7621 domain = []; 7622 index = new d3_Map(); 7623 var i = -1, n = x.length, xi; 7624 while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); 7625 return scale[ranger.t].apply(scale, ranger.a); 7626 }; 7627 scale.range = function(x) { 7628 if (!arguments.length) return range; 7629 range = x; 7630 rangeBand = 0; 7631 ranger = { 7632 t: "range", 7633 a: arguments 7634 }; 7635 return scale; 7636 }; 7637 scale.rangePoints = function(x, padding) { 7638 if (arguments.length < 2) padding = 0; 7639 var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); 7640 range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); 7641 rangeBand = 0; 7642 ranger = { 7643 t: "rangePoints", 7644 a: arguments 7645 }; 7646 return scale; 7647 }; 7648 scale.rangeBands = function(x, padding, outerPadding) { 7649 if (arguments.length < 2) padding = 0; 7650 if (arguments.length < 3) outerPadding = padding; 7651 var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); 7652 range = steps(start + step * outerPadding, step); 7653 if (reverse) range.reverse(); 7654 rangeBand = step * (1 - padding); 7655 ranger = { 7656 t: "rangeBands", 7657 a: arguments 7658 }; 7659 return scale; 7660 }; 7661 scale.rangeRoundBands = function(x, padding, outerPadding) { 7662 if (arguments.length < 2) padding = 0; 7663 if (arguments.length < 3) outerPadding = padding; 7664 var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step; 7665 range = steps(start + Math.round(error / 2), step); 7666 if (reverse) range.reverse(); 7667 rangeBand = Math.round(step * (1 - padding)); 7668 ranger = { 7669 t: "rangeRoundBands", 7670 a: arguments 7671 }; 7672 return scale; 7673 }; 7674 scale.rangeBand = function() { 7675 return rangeBand; 7676 }; 7677 scale.rangeExtent = function() { 7678 return d3_scaleExtent(ranger.a[0]); 7679 }; 7680 scale.copy = function() { 7681 return d3_scale_ordinal(domain, ranger); 7682 }; 7683 return scale.domain(domain); 7684 } 7685 d3.scale.category10 = function() { 7686 return d3.scale.ordinal().range(d3_category10); 7687 }; 7688 d3.scale.category20 = function() { 7689 return d3.scale.ordinal().range(d3_category20); 7690 }; 7691 d3.scale.category20b = function() { 7692 return d3.scale.ordinal().range(d3_category20b); 7693 }; 7694 d3.scale.category20c = function() { 7695 return d3.scale.ordinal().range(d3_category20c); 7696 }; 7697 var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString); 7698 var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16
vendor: 3,794 bytes, lines 7698-7814
7698750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString); 7699 var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString); 7700 var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString); 7701 d3.scale.quantile = function() { 7702 return d3_scale_quantile([], []); 7703 }; 7704 function d3_scale_quantile(domain, range) { 7705 var thresholds; 7706 function rescale() { 7707 var k = 0, q = range.length; 7708 thresholds = []; 7709 while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); 7710 return scale; 7711 } 7712 function scale(x) { 7713 if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; 7714 } 7715 scale.domain = function(x) { 7716 if (!arguments.length) return domain; 7717 domain = x.filter(function(d) { 7718 return !isNaN(d); 7719 }).sort(d3.ascending); 7720 return rescale(); 7721 }; 7722 scale.range = function(x) { 7723 if (!arguments.length) return range; 7724 range = x; 7725 return rescale(); 7726 }; 7727 scale.quantiles = function() { 7728 return thresholds; 7729 }; 7730 scale.invertExtent = function(y) { 7731 y = range.indexOf(y); 7732 return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ]; 7733 }; 7734 scale.copy = function() { 7735 return d3_scale_quantile(domain, range); 7736 }; 7737 return rescale(); 7738 } 7739 d3.scale.quantize = function() { 7740 return d3_scale_quantize(0, 1, [ 0, 1 ]); 7741 }; 7742 function d3_scale_quantize(x0, x1, range) { 7743 var kx, i; 7744 function scale(x) { 7745 return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; 7746 } 7747 function rescale() { 7748 kx = range.length / (x1 - x0); 7749 i = range.length - 1; 7750 return scale; 7751 } 7752 scale.domain = function(x) { 7753 if (!arguments.length) return [ x0, x1 ]; 7754 x0 = +x[0]; 7755 x1 = +x[x.length - 1]; 7756 return rescale(); 7757 }; 7758 scale.range = function(x) { 7759 if (!arguments.length) return range; 7760 range = x; 7761 return rescale(); 7762 }; 7763 scale.invertExtent = function(y) { 7764 y = range.indexOf(y); 7765 y = y < 0 ? NaN : y / kx + x0; 7766 return [ y, y + 1 / kx ]; 7767 }; 7768 scale.copy = function() { 7769 return d3_scale_quantize(x0, x1, range); 7770 }; 7771 return rescale(); 7772 } 7773 d3.scale.threshold = function() { 7774 return d3_scale_threshold([ .5 ], [ 0, 1 ]); 7775 }; 7776 function d3_scale_threshold(domain, range) { 7777 function scale(x) { 7778 if (x <= x) return range[d3.bisect(domain, x)]; 7779 } 7780 scale.domain = function(_) { 7781 if (!arguments.length) return domain; 7782 domain = _; 7783 return scale; 7784 }; 7785 scale.range = function(_) { 7786 if (!arguments.length) return range; 7787 range = _; 7788 return scale; 7789 }; 7790 scale.invertExtent = function(y) { 7791 y = range.indexOf(y); 7792 return [ domain[y - 1], domain[y] ]; 7793 }; 7794 scale.copy = function() { 7795 return d3_scale_threshold(domain, range); 7796 }; 7797 return scale; 7798 } 7799 d3.scale.identity = function() { 7800 return d3_scale_identity([ 0, 1 ]); 7801 }; 7802 function d3_scale_identity(domain) { 7803 function identity(x) { 7804 return +x; 7805 } 7806 identity.invert = identity; 7807 identity.domain = identity.range = function(x) { 7808 if (!arguments.length) return domain; 7809 domain = x.map(identity); 7810 return identity; 7811 }; 7812 identity.ticks = function(m) { 7813 return d3_scale_linearTicks(domain, m); 7814 };
7815 identity.tickFormat = function(m, format) { 7816 return d3_scale_linearTickFormat(domain, m, format); 7817 }; 7818 identity.copy = function() { 7819 return d3_scale_identity(domain); 7820 }; 7821 return identity; 7822 } 7823 d3.svg = {}; 7824 d3.svg.arc = function() { 7825 var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; 7826 function arc() { 7827 var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0, 7828 a0 = a1, a1 = da), a1 - a0), df = da < Ï ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1); 7829 return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z"; 7830 } 7831 arc.innerRadius = function(v) { 7832 if (!arguments.length) return innerRadius; 7833 innerRadius = d3_functor(v); 7834 return arc; 7835 }; 7836 arc.outerRadius = function(v) { 7837 if (!arguments.length) return outerRadius; 7838 outerRadius = d3_functor(v); 7839 return arc; 7840 }; 7841 arc.startAngle = function(v) { 7842 if (!arguments.length) return startAngle; 7843 startAngle = d3_functor(v); 7844 return arc; 7845 }; 7846 arc.endAngle = function(v) { 7847 if (!arguments.length) return endAngle; 7848 endAngle = d3_functor(v); 7849 return arc; 7850 }; 7851 arc.centroid = function() { 7852 var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset; 7853 return [ Math.cos(a) * r, Math.sin(a) * r ]; 7854 }; 7855 return arc; 7856 }; 7857 var d3_svg_arcOffset = -halfÏ, d3_svg_arcMax = Ï - ε; 7858 function d3_svg_arcInnerRadius(d) { 7859 return d.innerRadius; 7860 } 7861 function d3_svg_arcOuterRadius(d) { 7862 return d.outerRadius; 7863 } 7864 function d3_svg_arcStartAngle(d) { 7865 return d.startAngle; 7866 } 7867 function d3_svg_arcEndAngle(d) { 7868 return d.endAngle; 7869 } 7870 function d3_svg_line(projection) { 7871 var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; 7872 function line(data) { 7873 var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); 7874 function segment() { 7875 segments.push("M", interpolate(projection(points), tension)); 7876 } 7877 while (++i < n) { 7878 if (defined.call(this, d = data[i], i)) { 7879 points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); 7880 } else if (points.length) { 7881 segment(); 7882 points = []; 7883 } 7884 } 7885 if (points.length) segment(); 7886 return segments.length ? segments.join("") : null; 7887 } 7888 line.x = function(_) { 7889 if (!arguments.length) return x; 7890 x = _; 7891 return line; 7892 }; 7893 line.y = function(_) { 7894 if (!arguments.length) return y; 7895 y = _; 7896 return line; 7897 }; 7898 line.defined = function(_) { 7899 if (!arguments.length) return defined; 7900 defined = _; 7901 return line; 7902 }; 7903 line.interpolate = function(_) { 7904 if (!arguments.length) return interpolateKey; 7905 if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; 7906 return line; 7907 }; 7908 line.tension = function(_) { 7909 if (!arguments.length) return tension; 7910 tension = _; 7911 return line; 7912 }; 7913 return line; 7914 } 7915 d3.svg.line = function() { 7916 return d3_svg_line(d3_identity); 7917 }; 7918 var d3_svg_lineInterpolators = d3.map({ 7919 linear: d3_svg_lineLinear, 7920 "linear-closed": d3_svg_lineLinearClosed, 7921 step: d3_svg_lineStep, 7922 "step-before": d3_svg_lineStepBefore, 7923 "step-after": d3_svg_lineStepAfter, 7924 basis: d3_svg_lineBasis, 7925 "basis-open": d3_svg_lineBasisOpen, 7926 "basis-closed": d3_svg_lineBasisClosed, 7927 bundle: d3_svg_lineBundle, 7928 cardinal: d3_svg_lineCardinal, 7929 "cardinal-open": d3_svg_lineCardinalOpen, 7930 "cardinal-closed": d3_svg_lineCardinalClosed, 7931 monotone: d3_svg_lineMonotone 7932 });
vendor: 12,000 bytes, lines 7933-8249
7933 d3_svg_lineInterpolators.forEach(function(key, value) { 7934 value.key = key; 7935 value.closed = /-closed$/.test(key); 7936 }); 7937 function d3_svg_lineLinear(points) { 7938 return points.join("L"); 7939 } 7940 function d3_svg_lineLinearClosed(points) { 7941 return d3_svg_lineLinear(points) + "Z"; 7942 } 7943 function d3_svg_lineStep(points) { 7944 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; 7945 while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); 7946 if (n > 1) path.push("H", p[0]); 7947 return path.join(""); 7948 } 7949 function d3_svg_lineStepBefore(points) { 7950 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; 7951 while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); 7952 return path.join(""); 7953 } 7954 function d3_svg_lineStepAfter(points) { 7955 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; 7956 while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); 7957 return path.join(""); 7958 } 7959 function d3_svg_lineCardinalOpen(points, tension) { 7960 return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension)); 7961 } 7962 function d3_svg_lineCardinalClosed(points, tension) { 7963 return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), 7964 points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); 7965 } 7966 function d3_svg_lineCardinal(points, tension) { 7967 return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); 7968 } 7969 function d3_svg_lineHermite(points, tangents) { 7970 if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { 7971 return d3_svg_lineLinear(points); 7972 } 7973 var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; 7974 if (quad) { 7975 path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; 7976 p0 = points[1]; 7977 pi = 2; 7978 } 7979 if (tangents.length > 1) { 7980 t = tangents[1]; 7981 p = points[pi]; 7982 pi++; 7983 path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; 7984 for (var i = 2; i < tangents.length; i++, pi++) { 7985 p = points[pi]; 7986 t = tangents[i]; 7987 path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; 7988 } 7989 } 7990 if (quad) { 7991 var lp = points[pi]; 7992 path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; 7993 } 7994 return path; 7995 } 7996 function d3_svg_lineCardinalTangents(points, tension) { 7997 var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; 7998 while (++i < n) { 7999 p0 = p1; 8000 p1 = p2; 8001 p2 = points[i]; 8002 tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); 8003 } 8004 return tangents; 8005 } 8006 function d3_svg_lineBasis(points) { 8007 if (points.length < 3) return d3_svg_lineLinear(points); 8008 var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; 8009 points.push(points[n - 1]); 8010 while (++i <= n) { 8011 pi = points[i]; 8012 px.shift(); 8013 px.push(pi[0]); 8014 py.shift(); 8015 py.push(pi[1]); 8016 d3_svg_lineBasisBezier(path, px, py); 8017 } 8018 points.pop(); 8019 path.push("L", pi); 8020 return path.join(""); 8021 } 8022 function d3_svg_lineBasisOpen(points) { 8023 if (points.length < 4) return d3_svg_lineLinear(points); 8024 var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; 8025 while (++i < 3) { 8026 pi = points[i]; 8027 px.push(pi[0]); 8028 py.push(pi[1]); 8029 } 8030 path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); 8031 --i; 8032 while (++i < n) { 8033 pi = points[i]; 8034 px.shift(); 8035 px.push(pi[0]); 8036 py.shift(); 8037 py.push(pi[1]); 8038 d3_svg_lineBasisBezier(path, px, py); 8039 } 8040 return path.join(""); 8041 } 8042 function d3_svg_lineBasisClosed(points) { 8043 var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; 8044 while (++i < 4) { 8045 pi = points[i % n]; 8046 px.push(pi[0]); 8047 py.push(pi[1]); 8048 } 8049 path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; 8050 --i; 8051 while (++i < m) { 8052 pi = points[i % n]; 8053 px.shift(); 8054 px.push(pi[0]); 8055 py.shift(); 8056 py.push(pi[1]); 8057 d3_svg_lineBasisBezier(path, px, py); 8058 } 8059 return path.join(""); 8060 } 8061 function d3_svg_lineBundle(points, tension) { 8062 var n = points.length - 1; 8063 if (n) { 8064 var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; 8065 while (++i <= n) { 8066 p = points[i]; 8067 t = i / n; 8068 p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); 8069 p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); 8070 } 8071 } 8072 return d3_svg_lineBasis(points); 8073 } 8074 function d3_svg_lineDot4(a, b) { 8075 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; 8076 } 8077 var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; 8078 function d3_svg_lineBasisBezier(path, x, y) { 8079 path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); 8080 } 8081 function d3_svg_lineSlope(p0, p1) { 8082 return (p1[1] - p0[1]) / (p1[0] - p0[0]); 8083 } 8084 function d3_svg_lineFiniteDifferences(points) { 8085 var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); 8086 while (++i < j) { 8087 m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; 8088 } 8089 m[i] = d; 8090 return m; 8091 } 8092 function d3_svg_lineMonotoneTangents(points) { 8093 var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; 8094 while (++i < j) { 8095 d = d3_svg_lineSlope(points[i], points[i + 1]); 8096 if (abs(d) < ε) { 8097 m[i] = m[i + 1] = 0; 8098 } else { 8099 a = m[i] / d; 8100 b = m[i + 1] / d; 8101 s = a * a + b * b; 8102 if (s > 9) { 8103 s = d * 3 / Math.sqrt(s); 8104 m[i] = s * a; 8105 m[i + 1] = s * b; 8106 } 8107 } 8108 } 8109 i = -1; 8110 while (++i <= j) { 8111 s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); 8112 tangents.push([ s || 0, m[i] * s || 0 ]); 8113 } 8114 return tangents; 8115 } 8116 function d3_svg_lineMonotone(points) { 8117 return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); 8118 } 8119 d3.svg.line.radial = function() { 8120 var line = d3_svg_line(d3_svg_lineRadial); 8121 line.radius = line.x, delete line.x; 8122 line.angle = line.y, delete line.y; 8123 return line; 8124 }; 8125 function d3_svg_lineRadial(points) { 8126 var point, i = -1, n = points.length, r, a; 8127 while (++i < n) { 8128 point = points[i]; 8129 r = point[0]; 8130 a = point[1] + d3_svg_arcOffset; 8131 point[0] = r * Math.cos(a); 8132 point[1] = r * Math.sin(a); 8133 } 8134 return points; 8135 } 8136 function d3_svg_area(projection) { 8137 var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; 8138 function area(data) { 8139 var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { 8140 return x; 8141 } : d3_functor(x1), fy1 = y0 === y1 ? function() { 8142 return y; 8143 } : d3_functor(y1), x, y; 8144 function segment() { 8145 segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); 8146 } 8147 while (++i < n) { 8148 if (defined.call(this, d = data[i], i)) { 8149 points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); 8150 points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); 8151 } else if (points0.length) { 8152 segment(); 8153 points0 = []; 8154 points1 = []; 8155 } 8156 } 8157 if (points0.length) segment(); 8158 return segments.length ? segments.join("") : null; 8159 } 8160 area.x = function(_) { 8161 if (!arguments.length) return x1; 8162 x0 = x1 = _; 8163 return area; 8164 }; 8165 area.x0 = function(_) { 8166 if (!arguments.length) return x0; 8167 x0 = _; 8168 return area; 8169 }; 8170 area.x1 = function(_) { 8171 if (!arguments.length) return x1; 8172 x1 = _; 8173 return area; 8174 }; 8175 area.y = function(_) { 8176 if (!arguments.length) return y1; 8177 y0 = y1 = _; 8178 return area; 8179 }; 8180 area.y0 = function(_) { 8181 if (!arguments.length) return y0; 8182 y0 = _; 8183 return area; 8184 }; 8185 area.y1 = function(_) { 8186 if (!arguments.length) return y1; 8187 y1 = _; 8188 return area; 8189 }; 8190 area.defined = function(_) { 8191 if (!arguments.length) return defined; 8192 defined = _; 8193 return area; 8194 }; 8195 area.interpolate = function(_) { 8196 if (!arguments.length) return interpolateKey; 8197 if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; 8198 interpolateReverse = interpolate.reverse || interpolate; 8199 L = interpolate.closed ? "M" : "L"; 8200 return area; 8201 }; 8202 area.tension = function(_) { 8203 if (!arguments.length) return tension; 8204 tension = _; 8205 return area; 8206 }; 8207 return area; 8208 } 8209 d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; 8210 d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; 8211 d3.svg.area = function() { 8212 return d3_svg_area(d3_identity); 8213 }; 8214 d3.svg.area.radial = function() { 8215 var area = d3_svg_area(d3_svg_lineRadial); 8216 area.radius = area.x, delete area.x; 8217 area.innerRadius = area.x0, delete area.x0; 8218 area.outerRadius = area.x1, delete area.x1; 8219 area.angle = area.y, delete area.y; 8220 area.startAngle = area.y0, delete area.y0; 8221 area.endAngle = area.y1, delete area.y1; 8222 return area; 8223 }; 8224 d3.svg.chord = function() { 8225 var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; 8226 function chord(d, i) { 8227 var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); 8228 return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; 8229 } 8230 function subgroup(self, f, d, i) { 8231 var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset; 8232 return { 8233 r: r, 8234 a0: a0, 8235 a1: a1, 8236 p0: [ r * Math.cos(a0), r * Math.sin(a0) ], 8237 p1: [ r * Math.cos(a1), r * Math.sin(a1) ] 8238 }; 8239 } 8240 function equals(a, b) { 8241 return a.a0 == b.a0 && a.a1 == b.a1; 8242 } 8243 function arc(r, p, a) { 8244 return "A" + r + "," + r + " 0 " + +(a > Ï) + ",1 " + p; 8245 } 8246 function curve(r0, p0, r1, p1) { 8247 return "Q 0,0 " + p1; 8248 } 8249 chord.radius = function(v) {
vendor: 5,564 bytes, lines 8250-8399
8250 if (!arguments.length) return radius; 8251 radius = d3_functor(v); 8252 return chord; 8253 }; 8254 chord.source = function(v) { 8255 if (!arguments.length) return source; 8256 source = d3_functor(v); 8257 return chord; 8258 }; 8259 chord.target = function(v) { 8260 if (!arguments.length) return target; 8261 target = d3_functor(v); 8262 return chord; 8263 }; 8264 chord.startAngle = function(v) { 8265 if (!arguments.length) return startAngle; 8266 startAngle = d3_functor(v); 8267 return chord; 8268 }; 8269 chord.endAngle = function(v) { 8270 if (!arguments.length) return endAngle; 8271 endAngle = d3_functor(v); 8272 return chord; 8273 }; 8274 return chord; 8275 }; 8276 function d3_svg_chordRadius(d) { 8277 return d.radius; 8278 } 8279 d3.svg.diagonal = function() { 8280 var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; 8281 function diagonal(d, i) { 8282 var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { 8283 x: p0.x, 8284 y: m 8285 }, { 8286 x: p3.x, 8287 y: m 8288 }, p3 ]; 8289 p = p.map(projection); 8290 return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; 8291 } 8292 diagonal.source = function(x) { 8293 if (!arguments.length) return source; 8294 source = d3_functor(x); 8295 return diagonal; 8296 }; 8297 diagonal.target = function(x) { 8298 if (!arguments.length) return target; 8299 target = d3_functor(x); 8300 return diagonal; 8301 }; 8302 diagonal.projection = function(x) { 8303 if (!arguments.length) return projection; 8304 projection = x; 8305 return diagonal; 8306 }; 8307 return diagonal; 8308 }; 8309 function d3_svg_diagonalProjection(d) { 8310 return [ d.x, d.y ]; 8311 } 8312 d3.svg.diagonal.radial = function() { 8313 var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; 8314 diagonal.projection = function(x) { 8315 return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; 8316 }; 8317 return diagonal; 8318 }; 8319 function d3_svg_diagonalRadialProjection(projection) { 8320 return function() { 8321 var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset; 8322 return [ r * Math.cos(a), r * Math.sin(a) ]; 8323 }; 8324 } 8325 d3.svg.symbol = function() { 8326 var type = d3_svg_symbolType, size = d3_svg_symbolSize; 8327 function symbol(d, i) { 8328 return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); 8329 } 8330 symbol.type = function(x) { 8331 if (!arguments.length) return type; 8332 type = d3_functor(x); 8333 return symbol; 8334 }; 8335 symbol.size = function(x) { 8336 if (!arguments.length) return size; 8337 size = d3_functor(x); 8338 return symbol; 8339 }; 8340 return symbol; 8341 }; 8342 function d3_svg_symbolSize() { 8343 return 64; 8344 } 8345 function d3_svg_symbolType() { 8346 return "circle"; 8347 } 8348 function d3_svg_symbolCircle(size) { 8349 var r = Math.sqrt(size / Ï); 8350 return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; 8351 } 8352 var d3_svg_symbols = d3.map({ 8353 circle: d3_svg_symbolCircle, 8354 cross: function(size) { 8355 var r = Math.sqrt(size / 5) / 2; 8356 return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; 8357 }, 8358 diamond: function(size) { 8359 var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; 8360 return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; 8361 }, 8362 square: function(size) { 8363 var r = Math.sqrt(size) / 2; 8364 return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; 8365 }, 8366 "triangle-down": function(size) { 8367 var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; 8368 return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; 8369 }, 8370 "triangle-up": function(size) { 8371 var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; 8372 return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; 8373 } 8374 }); 8375 d3.svg.symbolTypes = d3_svg_symbols.keys(); 8376 var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); 8377 function d3_transition(groups, id) { 8378 d3_subclass(groups, d3_transitionPrototype); 8379 groups.id = id; 8380 return groups; 8381 } 8382 var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit; 8383 d3_transitionPrototype.call = d3_selectionPrototype.call; 8384 d3_transitionPrototype.empty = d3_selectionPrototype.empty; 8385 d3_transitionPrototype.node = d3_selectionPrototype.node; 8386 d3_transitionPrototype.size = d3_selectionPrototype.size; 8387 d3.transition = function(selection) { 8388 return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); 8389 }; 8390 d3.transition.prototype = d3_transitionPrototype; 8391 d3_transitionPrototype.select = function(selector) { 8392 var id = this.id, subgroups = [], subgroup, subnode, node; 8393 selector = d3_selection_selector(selector); 8394 for (var j = -1, m = this.length; ++j < m; ) { 8395 subgroups.push(subgroup = []); 8396 for (var group = this[j], i = -1, n = group.length; ++i < n; ) { 8397 if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) { 8398 if ("__data__" in node) subnode.__data__ = node.__data__; 8399 d3_transitionNode(subnode, i, id, node.__transition__[id]);
vendor: 4,289 bytes, lines 8400-8514
8400 subgroup.push(subnode); 8401 } else { 8402 subgroup.push(null); 8403 } 8404 } 8405 } 8406 return d3_transition(subgroups, id); 8407 }; 8408 d3_transitionPrototype.selectAll = function(selector) { 8409 var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition; 8410 selector = d3_selection_selectorAll(selector); 8411 for (var j = -1, m = this.length; ++j < m; ) { 8412 for (var group = this[j], i = -1, n = group.length; ++i < n; ) { 8413 if (node = group[i]) { 8414 transition = node.__transition__[id]; 8415 subnodes = selector.call(node, node.__data__, i, j); 8416 subgroups.push(subgroup = []); 8417 for (var k = -1, o = subnodes.length; ++k < o; ) { 8418 if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition); 8419 subgroup.push(subnode); 8420 } 8421 } 8422 } 8423 } 8424 return d3_transition(subgroups, id); 8425 }; 8426 d3_transitionPrototype.filter = function(filter) { 8427 var subgroups = [], subgroup, group, node; 8428 if (typeof filter !== "function") filter = d3_selection_filter(filter); 8429 for (var j = 0, m = this.length; j < m; j++) { 8430 subgroups.push(subgroup = []); 8431 for (var group = this[j], i = 0, n = group.length; i < n; i++) { 8432 if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { 8433 subgroup.push(node); 8434 } 8435 } 8436 } 8437 return d3_transition(subgroups, this.id); 8438 }; 8439 d3_transitionPrototype.tween = function(name, tween) { 8440 var id = this.id; 8441 if (arguments.length < 2) return this.node().__transition__[id].tween.get(name); 8442 return d3_selection_each(this, tween == null ? function(node) { 8443 node.__transition__[id].tween.remove(name); 8444 } : function(node) { 8445 node.__transition__[id].tween.set(name, tween); 8446 }); 8447 }; 8448 function d3_transition_tween(groups, name, value, tween) { 8449 var id = groups.id; 8450 return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { 8451 node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j))); 8452 } : (value = tween(value), function(node) { 8453 node.__transition__[id].tween.set(name, value); 8454 })); 8455 } 8456 d3_transitionPrototype.attr = function(nameNS, value) { 8457 if (arguments.length < 2) { 8458 for (value in nameNS) this.attr(value, nameNS[value]); 8459 return this; 8460 } 8461 var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS); 8462 function attrNull() { 8463 this.removeAttribute(name); 8464 } 8465 function attrNullNS() { 8466 this.removeAttributeNS(name.space, name.local); 8467 } 8468 function attrTween(b) { 8469 return b == null ? attrNull : (b += "", function() { 8470 var a = this.getAttribute(name), i; 8471 return a !== b && (i = interpolate(a, b), function(t) { 8472 this.setAttribute(name, i(t)); 8473 }); 8474 }); 8475 } 8476 function attrTweenNS(b) { 8477 return b == null ? attrNullNS : (b += "", function() { 8478 var a = this.getAttributeNS(name.space, name.local), i; 8479 return a !== b && (i = interpolate(a, b), function(t) { 8480 this.setAttributeNS(name.space, name.local, i(t)); 8481 }); 8482 }); 8483 } 8484 return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); 8485 }; 8486 d3_transitionPrototype.attrTween = function(nameNS, tween) { 8487 var name = d3.ns.qualify(nameNS); 8488 function attrTween(d, i) { 8489 var f = tween.call(this, d, i, this.getAttribute(name)); 8490 return f && function(t) { 8491 this.setAttribute(name, f(t)); 8492 }; 8493 } 8494 function attrTweenNS(d, i) { 8495 var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); 8496 return f && function(t) { 8497 this.setAttributeNS(name.space, name.local, f(t)); 8498 }; 8499 } 8500 return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); 8501 }; 8502 d3_transitionPrototype.style = function(name, value, priority) { 8503 var n = arguments.length; 8504 if (n < 3) { 8505 if (typeof name !== "string") { 8506 if (n < 2) value = ""; 8507 for (priority in name) this.style(priority, name[priority], value); 8508 return this; 8509 } 8510 priority = ""; 8511 } 8512 function styleNull() { 8513 this.style.removeProperty(name); 8514 }
8515 function styleString(b) { 8516 return b == null ? styleNull : (b += "", function() { 8517 var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i; 8518 return a !== b && (i = d3_interpolate(a, b), function(t) { 8519 this.style.setProperty(name, i(t), priority); 8520 }); 8521 }); 8522 } 8523 return d3_transition_tween(this, "style." + name, value, styleString); 8524 }; 8525 d3_transitionPrototype.styleTween = function(name, tween, priority) { 8526 if (arguments.length < 3) priority = ""; 8527 function styleTween(d, i) { 8528 var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name)); 8529 return f && function(t) { 8530 this.style.setProperty(name, f(t), priority); 8531 }; 8532 } 8533 return this.tween("style." + name, styleTween); 8534 }; 8535 d3_transitionPrototype.text = function(value) { 8536 return d3_transition_tween(this, "text", value, d3_transition_text); 8537 }; 8538 function d3_transition_text(b) { 8539 if (b == null) b = ""; 8540 return function() { 8541 this.textContent = b; 8542 }; 8543 } 8544 d3_transitionPrototype.remove = function() { 8545 return this.each("end.transition", function() { 8546 var p; 8547 if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this); 8548 }); 8549 }; 8550 d3_transitionPrototype.ease = function(value) { 8551 var id = this.id; 8552 if (arguments.length < 1) return this.node().__transition__[id].ease; 8553 if (typeof value !== "function") value = d3.ease.apply(d3, arguments); 8554 return d3_selection_each(this, function(node) { 8555 node.__transition__[id].ease = value; 8556 }); 8557 }; 8558 d3_transitionPrototype.delay = function(value) { 8559 var id = this.id; 8560 return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { 8561 node.__transition__[id].delay = +value.call(node, node.__data__, i, j); 8562 } : (value = +value, function(node) { 8563 node.__transition__[id].delay = value; 8564 })); 8565 }; 8566 d3_transitionPrototype.duration = function(value) { 8567 var id = this.id; 8568 return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { 8569 node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j)); 8570 } : (value = Math.max(1, value), function(node) { 8571 node.__transition__[id].duration = value; 8572 })); 8573 }; 8574 d3_transitionPrototype.each = function(type, listener) { 8575 var id = this.id; 8576 if (arguments.length < 2) { 8577 var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; 8578 d3_transitionInheritId = id; 8579 d3_selection_each(this, function(node, i, j) { 8580 d3_transitionInherit = node.__transition__[id]; 8581 type.call(node, node.__data__, i, j); 8582 }); 8583 d3_transitionInherit = inherit; 8584 d3_transitionInheritId = inheritId; 8585 } else { 8586 d3_selection_each(this, function(node) { 8587 var transition = node.__transition__[id]; 8588 (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener); 8589 }); 8590 } 8591 return this; 8592 }; 8593 d3_transitionPrototype.transition = function() { 8594 var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition; 8595 for (var j = 0, m = this.length; j < m; j++) { 8596 subgroups.push(subgroup = []); 8597 for (var group = this[j], i = 0, n = group.length; i < n; i++) { 8598 if (node = group[i]) { 8599 transition = Object.create(node.__transition__[id0]); 8600 transition.delay += transition.duration; 8601 d3_transitionNode(node, i, id1, transition); 8602 } 8603 subgroup.push(node); 8604 } 8605 } 8606 return d3_transition(subgroups, id1); 8607 }; 8608 function d3_transitionNode(node, i, id, inherit) { 8609 var lock = node.__transition__ || (node.__transition__ = { 8610 active: 0, 8611 count: 0 8612 }), transition = lock[id]; 8613 if (!transition) { 8614 var time = inherit.time; 8615 transition = lock[id] = { 8616 tween: new d3_Map(), 8617 time: time, 8618 ease: inherit.ease, 8619 delay: inherit.delay, 8620 duration: inherit.duration 8621 }; 8622 ++lock.count; 8623 d3.timer(function(elapsed) { 8624 var d = node.__data__, ease = transition.ease, delay = transition.delay, duration = transition.duration, timer = d3_timer_active, tweened = []; 8625 timer.t = delay + time; 8626 if (delay <= elapsed) return start(elapsed - delay); 8627 timer.c = start; 8628 function start(elapsed) { 8629 if (lock.active > id) return stop(); 8630 lock.active = id; 8631 transition.event && transition.event.start.call(node, d, i);
8632 transition.tween.forEach(function(key, value) { 8633 if (value = value.call(node, d, i)) { 8634 tweened.push(value); 8635 } 8636 }); 8637 d3.timer(function() { 8638 timer.c = tick(elapsed || 1) ? d3_true : tick; 8639 return 1; 8640 }, 0, time); 8641 } 8642 function tick(elapsed) { 8643 if (lock.active !== id) return stop(); 8644 var t = elapsed / duration, e = ease(t), n = tweened.length; 8645 while (n > 0) { 8646 tweened[--n].call(node, e); 8647 } 8648 if (t >= 1) { 8649 transition.event && transition.event.end.call(node, d, i); 8650 return stop(); 8651 } 8652 } 8653 function stop() { 8654 if (--lock.count) delete lock[id]; else delete node.__transition__; 8655 return 1; 8656 } 8657 }, 0, time); 8658 } 8659 } 8660 d3.svg.axis = function() { 8661 var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_; 8662 function axis(g) { 8663 g.each(function() { 8664 var g = d3.select(this); 8665 var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); 8666 var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; 8667 var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), 8668 d3.transition(path)); 8669 tickEnter.append("line"); 8670 tickEnter.append("text"); 8671 var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); 8672 switch (orient) { 8673 case "bottom": 8674 { 8675 tickTransform = d3_svg_axisX; 8676 lineEnter.attr("y2", innerTickSize); 8677 textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding); 8678 lineUpdate.attr("x2", 0).attr("y2", innerTickSize); 8679 textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding); 8680 text.attr("dy", ".71em").style("text-anchor", "middle"); 8681 pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); 8682 break; 8683 } 8684 8685 case "top": 8686 { 8687 tickTransform = d3_svg_axisX; 8688 lineEnter.attr("y2", -innerTickSize); 8689 textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); 8690 lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); 8691 textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); 8692 text.attr("dy", "0em").style("text-anchor", "middle"); 8693 pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); 8694 break; 8695 } 8696 8697 case "left": 8698 { 8699 tickTransform = d3_svg_axisY; 8700 lineEnter.attr("x2", -innerTickSize); 8701 textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)); 8702 lineUpdate.attr("x2", -innerTickSize).attr("y2", 0); 8703 textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0); 8704 text.attr("dy", ".32em").style("text-anchor", "end"); 8705 pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); 8706 break; 8707 } 8708 8709 case "right": 8710 { 8711 tickTransform = d3_svg_axisY; 8712 lineEnter.attr("x2", innerTickSize); 8713 textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding); 8714 lineUpdate.attr("x2", innerTickSize).attr("y2", 0); 8715 textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0); 8716 text.attr("dy", ".32em").style("text-anchor", "start"); 8717 pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize); 8718 break; 8719 } 8720 } 8721 if (scale1.rangeBand) { 8722 var x = scale1, dx = x.rangeBand() / 2; 8723 scale0 = scale1 = function(d) { 8724 return x(d) + dx; 8725 }; 8726 } else if (scale0.rangeBand) { 8727 scale0 = scale1; 8728 } else { 8729 tickExit.call(tickTransform, scale1); 8730 } 8731 tickEnter.call(tickTransform, scale0); 8732 tickUpdate.call(tickTransform, scale1); 8733 }); 8734 } 8735 axis.scale = function(x) { 8736 if (!arguments.length) return scale; 8737 scale = x; 8738 return axis; 8739 }; 8740 axis.orient = function(x) { 8741 if (!arguments.length) return orient; 8742 orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; 8743 return axis; 8744 }; 8745 axis.ticks = function() { 8746 if (!arguments.length) return tickArguments_; 8747 tickArguments_ = arguments; 8748 return axis; 8749 }; 8750 axis.tickValues = function(x) { 8751 if (!arguments.length) return tickValues; 8752 tickValues = x; 8753 return axis; 8754 }; 8755 axis.tickFormat = function(x) { 8756 if (!arguments.length) return tickFormat_; 8757 tickFormat_ = x; 8758 return axis; 8759 }; 8760 axis.tickSize = function(x) { 8761 var n = arguments.length; 8762 if (!n) return innerTickSize;
vendor: 7,035 bytes, lines 8763-8948
8763 innerTickSize = +x; 8764 outerTickSize = +arguments[n - 1]; 8765 return axis; 8766 }; 8767 axis.innerTickSize = function(x) { 8768 if (!arguments.length) return innerTickSize; 8769 innerTickSize = +x; 8770 return axis; 8771 }; 8772 axis.outerTickSize = function(x) { 8773 if (!arguments.length) return outerTickSize; 8774 outerTickSize = +x; 8775 return axis; 8776 }; 8777 axis.tickPadding = function(x) { 8778 if (!arguments.length) return tickPadding; 8779 tickPadding = +x; 8780 return axis; 8781 }; 8782 axis.tickSubdivide = function() { 8783 return arguments.length && axis; 8784 }; 8785 return axis; 8786 }; 8787 var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { 8788 top: 1, 8789 right: 1, 8790 bottom: 1, 8791 left: 1 8792 }; 8793 function d3_svg_axisX(selection, x) { 8794 selection.attr("transform", function(d) { 8795 return "translate(" + x(d) + ",0)"; 8796 }); 8797 } 8798 function d3_svg_axisY(selection, y) { 8799 selection.attr("transform", function(d) { 8800 return "translate(0," + y(d) + ")"; 8801 }); 8802 } 8803 d3.svg.brush = function() { 8804 var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0]; 8805 function brush(g) { 8806 g.each(function() { 8807 var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); 8808 var background = g.selectAll(".background").data([ 0 ]); 8809 background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); 8810 g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move"); 8811 var resize = g.selectAll(".resize").data(resizes, d3_identity); 8812 resize.exit().remove(); 8813 resize.enter().append("g").attr("class", function(d) { 8814 return "resize " + d; 8815 }).style("cursor", function(d) { 8816 return d3_svg_brushCursor[d]; 8817 }).append("rect").attr("x", function(d) { 8818 return /[ew]$/.test(d) ? -3 : null; 8819 }).attr("y", function(d) { 8820 return /^[ns]/.test(d) ? -3 : null; 8821 }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); 8822 resize.style("display", brush.empty() ? "none" : null); 8823 var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range; 8824 if (x) { 8825 range = d3_scaleRange(x); 8826 backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]); 8827 redrawX(gUpdate); 8828 } 8829 if (y) { 8830 range = d3_scaleRange(y); 8831 backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]); 8832 redrawY(gUpdate); 8833 } 8834 redraw(gUpdate); 8835 }); 8836 } 8837 brush.event = function(g) { 8838 g.each(function() { 8839 var event_ = event.of(this, arguments), extent1 = { 8840 x: xExtent, 8841 y: yExtent, 8842 i: xExtentDomain, 8843 j: yExtentDomain 8844 }, extent0 = this.__chart__ || extent1; 8845 this.__chart__ = extent1; 8846 if (d3_transitionInheritId) { 8847 d3.select(this).transition().each("start.brush", function() { 8848 xExtentDomain = extent0.i; 8849 yExtentDomain = extent0.j; 8850 xExtent = extent0.x; 8851 yExtent = extent0.y; 8852 event_({ 8853 type: "brushstart" 8854 }); 8855 }).tween("brush:brush", function() { 8856 var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y); 8857 xExtentDomain = yExtentDomain = null; 8858 return function(t) { 8859 xExtent = extent1.x = xi(t); 8860 yExtent = extent1.y = yi(t); 8861 event_({ 8862 type: "brush", 8863 mode: "resize" 8864 }); 8865 }; 8866 }).each("end.brush", function() { 8867 xExtentDomain = extent1.i; 8868 yExtentDomain = extent1.j; 8869 event_({ 8870 type: "brush", 8871 mode: "resize" 8872 }); 8873 event_({ 8874 type: "brushend" 8875 }); 8876 }); 8877 } else { 8878 event_({ 8879 type: "brushstart" 8880 }); 8881 event_({ 8882 type: "brush", 8883 mode: "resize" 8884 }); 8885 event_({ 8886 type: "brushend" 8887 }); 8888 } 8889 }); 8890 }; 8891 function redraw(g) { 8892 g.selectAll(".resize").attr("transform", function(d) { 8893 return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")"; 8894 }); 8895 } 8896 function redrawX(g) { 8897 g.select(".extent").attr("x", xExtent[0]); 8898 g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]); 8899 } 8900 function redrawY(g) { 8901 g.select(".extent").attr("y", yExtent[0]); 8902 g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]); 8903 } 8904 function brushstart() { 8905 var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(), center, origin = d3.mouse(target), offset; 8906 var w = d3.select(d3_window).on("keydown.brush", keydown).on("keyup.brush", keyup); 8907 if (d3.event.changedTouches) { 8908 w.on("touchmove.brush", brushmove).on("touchend.brush", brushend); 8909 } else { 8910 w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend); 8911 } 8912 g.interrupt().selectAll("*").interrupt(); 8913 if (dragging) { 8914 origin[0] = xExtent[0] - origin[0]; 8915 origin[1] = yExtent[0] - origin[1]; 8916 } else if (resizing) { 8917 var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); 8918 offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ]; 8919 origin[0] = xExtent[ex]; 8920 origin[1] = yExtent[ey]; 8921 } else if (d3.event.altKey) center = origin.slice(); 8922 g.style("pointer-events", "none").selectAll(".resize").style("display", null); 8923 d3.select("body").style("cursor", eventTarget.style("cursor")); 8924 event_({ 8925 type: "brushstart" 8926 }); 8927 brushmove(); 8928 function keydown() { 8929 if (d3.event.keyCode == 32) { 8930 if (!dragging) { 8931 center = null; 8932 origin[0] -= xExtent[1]; 8933 origin[1] -= yExtent[1]; 8934 dragging = 2; 8935 } 8936 d3_eventPreventDefault(); 8937 } 8938 } 8939 function keyup() { 8940 if (d3.event.keyCode == 32 && dragging == 2) { 8941 origin[0] += xExtent[1]; 8942 origin[1] += yExtent[1]; 8943 dragging = 0; 8944 d3_eventPreventDefault(); 8945 } 8946 } 8947 function brushmove() { 8948 var point = d3.mouse(target), moved = false;
vendor: 6,929 bytes, lines 8949-9144
8949 if (offset) { 8950 point[0] += offset[0]; 8951 point[1] += offset[1]; 8952 } 8953 if (!dragging) { 8954 if (d3.event.altKey) { 8955 if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ]; 8956 origin[0] = xExtent[+(point[0] < center[0])]; 8957 origin[1] = yExtent[+(point[1] < center[1])]; 8958 } else center = null; 8959 } 8960 if (resizingX && move1(point, x, 0)) { 8961 redrawX(g); 8962 moved = true; 8963 } 8964 if (resizingY && move1(point, y, 1)) { 8965 redrawY(g); 8966 moved = true; 8967 } 8968 if (moved) { 8969 redraw(g); 8970 event_({ 8971 type: "brush", 8972 mode: dragging ? "move" : "resize" 8973 }); 8974 } 8975 } 8976 function move1(point, scale, i) { 8977 var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max; 8978 if (dragging) { 8979 r0 -= position; 8980 r1 -= size + position; 8981 } 8982 min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i]; 8983 if (dragging) { 8984 max = (min += position) + size; 8985 } else { 8986 if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); 8987 if (position < min) { 8988 max = min; 8989 min = position; 8990 } else { 8991 max = position; 8992 } 8993 } 8994 if (extent[0] != min || extent[1] != max) { 8995 if (i) yExtentDomain = null; else xExtentDomain = null; 8996 extent[0] = min; 8997 extent[1] = max; 8998 return true; 8999 } 9000 } 9001 function brushend() { 9002 brushmove(); 9003 g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); 9004 d3.select("body").style("cursor", null); 9005 w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); 9006 dragRestore(); 9007 event_({ 9008 type: "brushend" 9009 }); 9010 } 9011 } 9012 brush.x = function(z) { 9013 if (!arguments.length) return x; 9014 x = z; 9015 resizes = d3_svg_brushResizes[!x << 1 | !y]; 9016 return brush; 9017 }; 9018 brush.y = function(z) { 9019 if (!arguments.length) return y; 9020 y = z; 9021 resizes = d3_svg_brushResizes[!x << 1 | !y]; 9022 return brush; 9023 }; 9024 brush.clamp = function(z) { 9025 if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null; 9026 if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z; 9027 return brush; 9028 }; 9029 brush.extent = function(z) { 9030 var x0, x1, y0, y1, t; 9031 if (!arguments.length) { 9032 if (x) { 9033 if (xExtentDomain) { 9034 x0 = xExtentDomain[0], x1 = xExtentDomain[1]; 9035 } else { 9036 x0 = xExtent[0], x1 = xExtent[1]; 9037 if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); 9038 if (x1 < x0) t = x0, x0 = x1, x1 = t; 9039 } 9040 } 9041 if (y) { 9042 if (yExtentDomain) { 9043 y0 = yExtentDomain[0], y1 = yExtentDomain[1]; 9044 } else { 9045 y0 = yExtent[0], y1 = yExtent[1]; 9046 if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); 9047 if (y1 < y0) t = y0, y0 = y1, y1 = t; 9048 } 9049 } 9050 return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; 9051 } 9052 if (x) { 9053 x0 = z[0], x1 = z[1]; 9054 if (y) x0 = x0[0], x1 = x1[0]; 9055 xExtentDomain = [ x0, x1 ]; 9056 if (x.invert) x0 = x(x0), x1 = x(x1); 9057 if (x1 < x0) t = x0, x0 = x1, x1 = t; 9058 if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ]; 9059 } 9060 if (y) { 9061 y0 = z[0], y1 = z[1]; 9062 if (x) y0 = y0[1], y1 = y1[1]; 9063 yExtentDomain = [ y0, y1 ]; 9064 if (y.invert) y0 = y(y0), y1 = y(y1); 9065 if (y1 < y0) t = y0, y0 = y1, y1 = t; 9066 if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ]; 9067 } 9068 return brush; 9069 }; 9070 brush.clear = function() { 9071 if (!brush.empty()) { 9072 xExtent = [ 0, 0 ], yExtent = [ 0, 0 ]; 9073 xExtentDomain = yExtentDomain = null; 9074 } 9075 return brush; 9076 }; 9077 brush.empty = function() { 9078 return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1]; 9079 }; 9080 return d3.rebind(brush, event, "on"); 9081 }; 9082 var d3_svg_brushCursor = { 9083 n: "ns-resize", 9084 e: "ew-resize", 9085 s: "ns-resize", 9086 w: "ew-resize", 9087 nw: "nwse-resize", 9088 ne: "nesw-resize", 9089 se: "nwse-resize", 9090 sw: "nesw-resize" 9091 }; 9092 var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; 9093 var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat; 9094 var d3_time_formatUtc = d3_time_format.utc; 9095 var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ"); 9096 d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; 9097 function d3_time_formatIsoNative(date) { 9098 return date.toISOString(); 9099 } 9100 d3_time_formatIsoNative.parse = function(string) { 9101 var date = new Date(string); 9102 return isNaN(date) ? null : date; 9103 }; 9104 d3_time_formatIsoNative.toString = d3_time_formatIso.toString; 9105 d3_time.second = d3_time_interval(function(date) { 9106 return new d3_date(Math.floor(date / 1e3) * 1e3); 9107 }, function(date, offset) { 9108 date.setTime(date.getTime() + Math.floor(offset) * 1e3); 9109 }, function(date) { 9110 return date.getSeconds(); 9111 }); 9112 d3_time.seconds = d3_time.second.range; 9113 d3_time.seconds.utc = d3_time.second.utc.range; 9114 d3_time.minute = d3_time_interval(function(date) { 9115 return new d3_date(Math.floor(date / 6e4) * 6e4); 9116 }, function(date, offset) { 9117 date.setTime(date.getTime() + Math.floor(offset) * 6e4); 9118 }, function(date) { 9119 return date.getMinutes(); 9120 }); 9121 d3_time.minutes = d3_time.minute.range; 9122 d3_time.minutes.utc = d3_time.minute.utc.range; 9123 d3_time.hour = d3_time_interval(function(date) { 9124 var timezone = date.getTimezoneOffset() / 60; 9125 return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5); 9126 }, function(date, offset) { 9127 date.setTime(date.getTime() + Math.floor(offset) * 36e5); 9128 }, function(date) { 9129 return date.getHours(); 9130 }); 9131 d3_time.hours = d3_time.hour.range; 9132 d3_time.hours.utc = d3_time.hour.utc.range; 9133 d3_time.month = d3_time_interval(function(date) { 9134 date = d3_time.day(date); 9135 date.setDate(1); 9136 return date; 9137 }, function(date, offset) { 9138 date.setMonth(date.getMonth() + offset); 9139 }, function(date) { 9140 return date.getMonth(); 9141 }); 9142 d3_time.months = d3_time.month.range; 9143 d3_time.months.utc = d3_time.month.utc.range; 9144 function d3_time_scale(linear, methods, format) {
9145 function scale(x) { 9146 return linear(x); 9147 } 9148 scale.invert = function(x) { 9149 return d3_time_scaleDate(linear.invert(x)); 9150 }; 9151 scale.domain = function(x) { 9152 if (!arguments.length) return linear.domain().map(d3_time_scaleDate); 9153 linear.domain(x); 9154 return scale; 9155 }; 9156 function tickMethod(extent, count) { 9157 var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target); 9158 return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) { 9159 return d / 31536e6; 9160 }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i]; 9161 } 9162 scale.nice = function(interval, skip) { 9163 var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval); 9164 if (method) interval = method[0], skip = method[1]; 9165 function skipped(date) { 9166 return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length; 9167 } 9168 return scale.domain(d3_scale_nice(domain, skip > 1 ? { 9169 floor: function(date) { 9170 while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1); 9171 return date; 9172 }, 9173 ceil: function(date) { 9174 while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1); 9175 return date; 9176 } 9177 } : interval)); 9178 }; 9179 scale.ticks = function(interval, skip) { 9180 var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ { 9181 range: interval 9182 }, skip ]; 9183 if (method) interval = method[0], skip = method[1]; 9184 return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); 9185 }; 9186 scale.tickFormat = function() { 9187 return format; 9188 }; 9189 scale.copy = function() { 9190 return d3_time_scale(linear.copy(), methods, format); 9191 }; 9192 return d3_scale_linearRebind(scale, linear); 9193 } 9194 function d3_time_scaleDate(t) { 9195 return new Date(t); 9196 } 9197 var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; 9198 var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ]; 9199 var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) { 9200 return d.getMilliseconds(); 9201 } ], [ ":%S", function(d) { 9202 return d.getSeconds(); 9203 } ], [ "%I:%M", function(d) { 9204 return d.getMinutes(); 9205 } ], [ "%I %p", function(d) { 9206 return d.getHours(); 9207 } ], [ "%a %d", function(d) { 9208 return d.getDay() && d.getDate() != 1; 9209 } ], [ "%b %d", function(d) { 9210 return d.getDate() != 1; 9211 } ], [ "%B", function(d) { 9212 return d.getMonth(); 9213 } ], [ "%Y", d3_true ] ]); 9214 var d3_time_scaleMilliseconds = { 9215 range: function(start, stop, step) { 9216 return d3.range(+start, +stop, step).map(d3_time_scaleDate); 9217 }, 9218 floor: d3_identity, 9219 ceil: d3_identity 9220 }; 9221 d3_time_scaleLocalMethods.year = d3_time.year; 9222 d3_time.scale = function() { 9223 return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); 9224 }; 9225 var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) { 9226 return [ m[0].utc, m[1] ]; 9227 }); 9228 var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) { 9229 return d.getUTCMilliseconds(); 9230 } ], [ ":%S", function(d) { 9231 return d.getUTCSeconds(); 9232 } ], [ "%I:%M", function(d) { 9233 return d.getUTCMinutes(); 9234 } ], [ "%I %p", function(d) { 9235 return d.getUTCHours(); 9236 } ], [ "%a %d", function(d) { 9237 return d.getUTCDay() && d.getUTCDate() != 1; 9238 } ], [ "%b %d", function(d) { 9239 return d.getUTCDate() != 1; 9240 } ], [ "%B", function(d) { 9241 return d.getUTCMonth(); 9242 } ], [ "%Y", d3_true ] ]); 9243 d3_time_scaleUtcMethods.year = d3_time.year.utc; 9244 d3_time.scale.utc = function() { 9245 return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat); 9246 }; 9247 d3.text = d3_xhrType(function(request) { 9248 return request.responseText; 9249 }); 9250 d3.json = function(url, callback) { 9251 return d3_xhr(url, "application/json", d3_json, callback); 9252 }; 9253 function d3_json(request) { 9254 return JSON.parse(request.responseText); 9255 } 9256 d3.html = function(url, callback) { 9257 return d3_xhr(url, "text/html", d3_html, callback); 9258 }; 9259 function d3_html(request) { 9260 var range = d3_document.createRange(); 9261 range.selectNode(d3_document.body); 9262 return range.createContextualFragment(request.responseText); 9263 } 9264 d3.xml = d3_xhrType(function(request) { 9265 return request.responseXML; 9266 }); 9267 if (typeof define === "function" && define.amd) { 9268 define(d3); 9269 } else if (typeof module === "object" && module.exports) { 9270 module.exports = d3; 9271 } else { 9272 this.d3 = d3; 9273 } 9274}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.