d3_rails 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.DS_Store CHANGED
Binary file
data/README.md CHANGED
@@ -14,8 +14,8 @@ or you can use it to build dynamic pages (like jQuery).
14
14
 
15
15
  # D3 Version
16
16
 
17
- The current release of this gem is using **D3 v=3.0.5**
18
- **Last Updated 2-3-2013**
17
+ The current release of this gem is using **D3 v=3.0.6**
18
+ **Last Updated 2-10-2013**
19
19
 
20
20
  # Included Javascripts
21
21
 
data/lib/.DS_Store CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module D3Rails
2
- VERSION = "3.0.5"
2
+ VERSION = "3.0.6"
3
3
  end
data/vendor/.DS_Store CHANGED
Binary file
Binary file
@@ -1,26 +1,25 @@
1
- (function() {
1
+ d3 = function() {
2
+ var π = Math.PI, ε = 1e-6, d3 = {
3
+ version: "3.0.6"
4
+ }, d3_radians = π / 180, d3_degrees = 180 / π, d3_document = document, d3_window = window;
5
+ function d3_target(d) {
6
+ return d.target;
7
+ }
8
+ function d3_source(d) {
9
+ return d.source;
10
+ }
2
11
  var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ];
3
12
  if (!Date.now) Date.now = function() {
4
13
  return +new Date();
5
14
  };
6
15
  try {
7
- document.createElement("div").style.setProperty("opacity", 0, "");
16
+ d3_document.createElement("div").style.setProperty("opacity", 0, "");
8
17
  } catch (error) {
9
- var d3_style_prototype = CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
18
+ var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
10
19
  d3_style_prototype.setProperty = function(name, value, priority) {
11
20
  d3_style_setProperty.call(this, name, value + "", priority);
12
21
  };
13
22
  }
14
- d3 = {
15
- version: "3.0.5"
16
- };
17
- var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
18
- function d3_target(d) {
19
- return d.target;
20
- }
21
- function d3_source(d) {
22
- return d.source;
23
- }
24
23
  function d3_class(ctor, properties) {
25
24
  try {
26
25
  for (var key in properties) {
@@ -43,7 +42,7 @@
43
42
  return Array.prototype.slice.call(pseudoarray);
44
43
  }
45
44
  try {
46
- d3_array(document.documentElement.childNodes)[0].nodeType;
45
+ d3_array(d3_document.documentElement.childNodes)[0].nodeType;
47
46
  } catch (e) {
48
47
  d3_array = d3_arrayCopy;
49
48
  }
@@ -202,13 +201,10 @@
202
201
  return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
203
202
  };
204
203
  },
205
- logNormal: function(µ, σ) {
206
- var n = arguments.length;
207
- if (n < 2) σ = 1;
208
- if (n < 1) µ = 0;
209
- var random = d3.random.normal();
204
+ logNormal: function() {
205
+ var random = d3.random.normal.apply(d3, arguments);
210
206
  return function() {
211
- return Math.exp(µ + σ * random());
207
+ return Math.exp(random());
212
208
  };
213
209
  },
214
210
  irwinHall: function(m) {
@@ -395,7 +391,7 @@
395
391
  return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
396
392
  };
397
393
  d3.xhr = function(url, mimeType, callback) {
398
- var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
394
+ var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
399
395
  "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
400
396
  request.readyState > 3 && respond();
401
397
  };
@@ -474,8 +470,8 @@
474
470
  return d3.xhr(url, "text/html", callback).response(d3_html);
475
471
  };
476
472
  function d3_html(request) {
477
- var range = document.createRange();
478
- range.selectNode(document.body);
473
+ var range = d3_document.createRange();
474
+ range.selectNode(d3_document.body);
479
475
  return range.createContextualFragment(request.responseText);
480
476
  }
481
477
  d3.xml = function() {
@@ -634,11 +630,11 @@
634
630
  return x.toFixed(p);
635
631
  },
636
632
  r: function(x, p) {
637
- return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p)));
633
+ 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))));
638
634
  }
639
635
  });
640
636
  function d3_format_precision(x, p) {
641
- return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
637
+ return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);
642
638
  }
643
639
  function d3_format_typeDefault(x) {
644
640
  return x + "";
@@ -656,7 +652,7 @@
656
652
  return t.reverse().join(d3_format_thousandsSeparator || "") + f;
657
653
  };
658
654
  }
659
- var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "μ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
655
+ var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
660
656
  d3.formatPrefix = function(value, precision) {
661
657
  var i = 0;
662
658
  if (value) {
@@ -805,7 +801,7 @@
805
801
  return dispatch;
806
802
  }
807
803
  d3.transform = function(string) {
808
- var g = document.createElementNS(d3.ns.prefix.svg, "g");
804
+ var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
809
805
  return (d3.transform = function(string) {
810
806
  g.setAttribute("transform", string);
811
807
  var t = g.transform.baseVal.consolidate();
@@ -1440,7 +1436,7 @@
1440
1436
  return n.querySelector(s);
1441
1437
  }, d3_selectAll = function(s, n) {
1442
1438
  return n.querySelectorAll(s);
1443
- }, d3_selectRoot = document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
1439
+ }, d3_selectRoot = d3_document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
1444
1440
  return d3_selectMatcher.call(n, s);
1445
1441
  };
1446
1442
  if (typeof Sizzle === "function") {
@@ -1592,7 +1588,7 @@
1592
1588
  for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
1593
1589
  return this;
1594
1590
  }
1595
- if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name);
1591
+ if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);
1596
1592
  priority = "";
1597
1593
  }
1598
1594
  return this.each(d3_selection_style(name, value, priority));
@@ -1654,20 +1650,20 @@
1654
1650
  d3_selectionPrototype.append = function(name) {
1655
1651
  name = d3.ns.qualify(name);
1656
1652
  function append() {
1657
- return this.appendChild(document.createElementNS(this.namespaceURI, name));
1653
+ return this.appendChild(d3_document.createElementNS(this.namespaceURI, name));
1658
1654
  }
1659
1655
  function appendNS() {
1660
- return this.appendChild(document.createElementNS(name.space, name.local));
1656
+ return this.appendChild(d3_document.createElementNS(name.space, name.local));
1661
1657
  }
1662
1658
  return this.select(name.local ? appendNS : append);
1663
1659
  };
1664
1660
  d3_selectionPrototype.insert = function(name, before) {
1665
1661
  name = d3.ns.qualify(name);
1666
1662
  function insert() {
1667
- return this.insertBefore(document.createElementNS(this.namespaceURI, name), d3_select(before, this));
1663
+ return this.insertBefore(d3_document.createElementNS(this.namespaceURI, name), d3_select(before, this));
1668
1664
  }
1669
1665
  function insertNS() {
1670
- return this.insertBefore(document.createElementNS(name.space, name.local), d3_select(before, this));
1666
+ return this.insertBefore(d3_document.createElementNS(name.space, name.local), d3_select(before, this));
1671
1667
  }
1672
1668
  return this.select(name.local ? insertNS : insert);
1673
1669
  };
@@ -1805,7 +1801,7 @@
1805
1801
  function d3_selection_sortComparator(comparator) {
1806
1802
  if (!arguments.length) comparator = d3.ascending;
1807
1803
  return function(a, b) {
1808
- return comparator(a && a.__data__, b && b.__data__);
1804
+ return !a - !b || comparator(a.__data__, b.__data__);
1809
1805
  };
1810
1806
  }
1811
1807
  d3_selectionPrototype.on = function(type, listener, capture) {
@@ -1891,7 +1887,7 @@
1891
1887
  }
1892
1888
  return d3_transition(subgroups, id);
1893
1889
  };
1894
- var d3_selectionRoot = d3_selection([ [ document ] ]);
1890
+ var d3_selectionRoot = d3_selection([ [ d3_document ] ]);
1895
1891
  d3_selectionRoot[0].parentNode = d3_selectRoot;
1896
1892
  d3.select = function(selector) {
1897
1893
  return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]);
@@ -2103,7 +2099,7 @@
2103
2099
  }
2104
2100
  return d3_transition_tween(this, "style." + name, value, function(b) {
2105
2101
  function styleString() {
2106
- var a = getComputedStyle(this, null).getPropertyValue(name), i;
2102
+ var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
2107
2103
  return a !== b && (i = interpolate(a, b), function(t) {
2108
2104
  this.style.setProperty(name, i(t), priority);
2109
2105
  });
@@ -2114,7 +2110,7 @@
2114
2110
  d3_transitionPrototype.styleTween = function(name, tween, priority) {
2115
2111
  if (arguments.length < 3) priority = "";
2116
2112
  return this.tween("style." + name, function(d, i) {
2117
- var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name));
2113
+ var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
2118
2114
  return f && function(t) {
2119
2115
  this.style.setProperty(name, f(t), priority);
2120
2116
  };
@@ -2272,19 +2268,19 @@
2272
2268
  }
2273
2269
  return then;
2274
2270
  }
2275
- var d3_timer_frame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
2271
+ var d3_timer_frame = d3_window.requestAnimationFrame || d3_window.webkitRequestAnimationFrame || d3_window.mozRequestAnimationFrame || d3_window.oRequestAnimationFrame || d3_window.msRequestAnimationFrame || function(callback) {
2276
2272
  setTimeout(callback, 17);
2277
2273
  };
2278
2274
  d3.mouse = function(container) {
2279
2275
  return d3_mousePoint(container, d3_eventSource());
2280
2276
  };
2281
- var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
2277
+ var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
2282
2278
  function d3_mousePoint(container, e) {
2283
2279
  var svg = container.ownerSVGElement || container;
2284
2280
  if (svg.createSVGPoint) {
2285
2281
  var point = svg.createSVGPoint();
2286
- if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
2287
- svg = d3.select(document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
2282
+ if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
2283
+ svg = d3.select(d3_document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
2288
2284
  var ctm = svg[0][0].getScreenCTM();
2289
2285
  d3_mouse_bug44083 = !(ctm.f || ctm.e);
2290
2286
  svg.remove();
@@ -3317,18 +3313,18 @@
3317
3313
  d3.svg.symbolTypes = d3_svg_symbols.keys();
3318
3314
  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
3319
3315
  d3.svg.axis = function() {
3320
- var scale = d3.scale.linear(), orient = "bottom", tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0;
3316
+ var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0;
3321
3317
  function axis(g) {
3322
3318
  g.each(function() {
3323
3319
  var g = d3.select(this);
3324
3320
  var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String : tickFormat_;
3325
- var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", "g").attr("class", "tick minor").style("opacity", 1e-6), subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(), subtickUpdate = d3.transition(subtick).style("opacity", 1);
3326
- var tick = g.selectAll("g").data(ticks, String), tickEnter = tick.enter().insert("g", "path").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
3327
- var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = d3.transition(path);
3321
+ var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".tick.minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", ".tick").attr("class", "tick minor").style("opacity", 1e-6), subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(), subtickUpdate = d3.transition(subtick).style("opacity", 1);
3322
+ var tick = g.selectAll(".tick.major").data(ticks, String), tickEnter = tick.enter().insert("g", "path").attr("class", "tick major").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
3323
+ var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
3324
+ d3.transition(path));
3328
3325
  var scale1 = scale.copy(), scale0 = this.__chart__ || scale1;
3329
3326
  this.__chart__ = scale1;
3330
- path.enter().append("path").attr("class", "domain");
3331
- tickEnter.append("line").attr("class", "tick");
3327
+ tickEnter.append("line");
3332
3328
  tickEnter.append("text");
3333
3329
  var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text");
3334
3330
  switch (orient) {
@@ -3411,7 +3407,7 @@
3411
3407
  };
3412
3408
  axis.orient = function(x) {
3413
3409
  if (!arguments.length) return orient;
3414
- orient = x;
3410
+ orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient;
3415
3411
  return axis;
3416
3412
  };
3417
3413
  axis.ticks = function() {
@@ -3449,6 +3445,12 @@
3449
3445
  };
3450
3446
  return axis;
3451
3447
  };
3448
+ var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = {
3449
+ top: 1,
3450
+ right: 1,
3451
+ bottom: 1,
3452
+ left: 1
3453
+ };
3452
3454
  function d3_svg_axisX(selection, x) {
3453
3455
  selection.attr("transform", function(d) {
3454
3456
  return "translate(" + x(d) + ",0)";
@@ -3523,7 +3525,7 @@
3523
3525
  }
3524
3526
  function brushstart() {
3525
3527
  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"), center, origin = mouse(), offset;
3526
- var w = d3.select(window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup);
3528
+ var w = d3.select(d3_window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup);
3527
3529
  if (dragging) {
3528
3530
  origin[0] = extent[0][0] - origin[0];
3529
3531
  origin[1] = extent[0][1] - origin[1];
@@ -3710,7 +3712,7 @@
3710
3712
  }
3711
3713
  function mousedown() {
3712
3714
  var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null, offset, origin_ = point(), moved = 0;
3713
- var w = d3.select(window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
3715
+ var w = d3.select(d3_window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
3714
3716
  if (origin) {
3715
3717
  offset = origin.apply(target, arguments);
3716
3718
  offset = [ offset.x - origin_[0], offset.y - origin_[1] ];
@@ -3766,7 +3768,7 @@
3766
3768
  d3.behavior.zoom = function() {
3767
3769
  var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
3768
3770
  function zoom() {
3769
- this.on("mousedown.zoom", mousedown).on("mousewheel.zoom", mousewheel).on("mousemove.zoom", mousemove).on("DOMMouseScroll.zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart);
3771
+ this.on("mousedown.zoom", mousedown).on("mousemove.zoom", mousemove).on(d3_behavior_zoomWheel + ".zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart);
3770
3772
  }
3771
3773
  zoom.translate = function(x) {
3772
3774
  if (!arguments.length) return translate;
@@ -3833,8 +3835,8 @@
3833
3835
  });
3834
3836
  }
3835
3837
  function mousedown() {
3836
- var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
3837
- window.focus();
3838
+ var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
3839
+ d3_window.focus();
3838
3840
  d3_eventCancel();
3839
3841
  function mousemove() {
3840
3842
  moved = 1;
@@ -3898,21 +3900,14 @@
3898
3900
  }
3899
3901
  return d3.rebind(zoom, event, "on");
3900
3902
  };
3901
- var d3_behavior_zoomDiv, d3_behavior_zoomInfinity = [ 0, Infinity ];
3902
- function d3_behavior_zoomDelta() {
3903
- if (!d3_behavior_zoomDiv) {
3904
- d3_behavior_zoomDiv = d3.select("body").append("div").style("visibility", "hidden").style("top", 0).style("height", 0).style("width", 0).style("overflow-y", "scroll").append("div").style("height", "2000px").node().parentNode;
3905
- }
3906
- var e = d3.event, delta;
3907
- try {
3908
- d3_behavior_zoomDiv.scrollTop = 1e3;
3909
- d3_behavior_zoomDiv.dispatchEvent(e);
3910
- delta = 1e3 - d3_behavior_zoomDiv.scrollTop;
3911
- } catch (error) {
3912
- delta = e.wheelDelta || -e.detail * 5;
3913
- }
3914
- return delta;
3915
- }
3903
+ var d3_behavior_zoomInfinity = [ 0, Infinity ];
3904
+ var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in document ? (d3_behavior_zoomDelta = function() {
3905
+ return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);
3906
+ }, "wheel") : "onmousewheel" in document ? (d3_behavior_zoomDelta = function() {
3907
+ return d3.event.wheelDelta;
3908
+ }, "mousewheel") : (d3_behavior_zoomDelta = function() {
3909
+ return -d3.event.detail;
3910
+ }, "MozMousePixelScroll");
3916
3911
  d3.layout = {};
3917
3912
  d3.layout.bundle = function() {
3918
3913
  return function(links) {
@@ -4165,18 +4160,18 @@
4165
4160
  };
4166
4161
  force.linkDistance = function(x) {
4167
4162
  if (!arguments.length) return linkDistance;
4168
- linkDistance = d3_functor(x);
4163
+ linkDistance = typeof x === "function" ? x : +x;
4169
4164
  return force;
4170
4165
  };
4171
4166
  force.distance = force.linkDistance;
4172
4167
  force.linkStrength = function(x) {
4173
4168
  if (!arguments.length) return linkStrength;
4174
- linkStrength = d3_functor(x);
4169
+ linkStrength = typeof x === "function" ? x : +x;
4175
4170
  return force;
4176
4171
  };
4177
4172
  force.friction = function(x) {
4178
4173
  if (!arguments.length) return friction;
4179
- friction = x;
4174
+ friction = +x;
4180
4175
  return force;
4181
4176
  };
4182
4177
  force.charge = function(x) {
@@ -4186,16 +4181,17 @@
4186
4181
  };
4187
4182
  force.gravity = function(x) {
4188
4183
  if (!arguments.length) return gravity;
4189
- gravity = x;
4184
+ gravity = +x;
4190
4185
  return force;
4191
4186
  };
4192
4187
  force.theta = function(x) {
4193
4188
  if (!arguments.length) return theta;
4194
- theta = x;
4189
+ theta = +x;
4195
4190
  return force;
4196
4191
  };
4197
4192
  force.alpha = function(x) {
4198
4193
  if (!arguments.length) return alpha;
4194
+ x = +x;
4199
4195
  if (alpha) {
4200
4196
  if (x > 0) alpha = x; else alpha = 0;
4201
4197
  } else if (x > 0) {
@@ -4213,14 +4209,10 @@
4213
4209
  (o = nodes[i]).index = i;
4214
4210
  o.weight = 0;
4215
4211
  }
4216
- distances = [];
4217
- strengths = [];
4218
4212
  for (i = 0; i < m; ++i) {
4219
4213
  o = links[i];
4220
4214
  if (typeof o.source == "number") o.source = nodes[o.source];
4221
4215
  if (typeof o.target == "number") o.target = nodes[o.target];
4222
- distances[i] = linkDistance.call(this, o, i);
4223
- strengths[i] = linkStrength.call(this, o, i);
4224
4216
  ++o.source.weight;
4225
4217
  ++o.target.weight;
4226
4218
  }
@@ -4231,16 +4223,12 @@
4231
4223
  if (isNaN(o.px)) o.px = o.x;
4232
4224
  if (isNaN(o.py)) o.py = o.y;
4233
4225
  }
4226
+ distances = [];
4227
+ 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;
4228
+ strengths = [];
4229
+ 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;
4234
4230
  charges = [];
4235
- if (typeof charge === "function") {
4236
- for (i = 0; i < n; ++i) {
4237
- charges[i] = +charge.call(this, nodes[i], i);
4238
- }
4239
- } else {
4240
- for (i = 0; i < n; ++i) {
4241
- charges[i] = charge;
4242
- }
4243
- }
4231
+ 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;
4244
4232
  function position(dimension, size) {
4245
4233
  var neighbors = neighbor(i), j = -1, m = neighbors.length, x;
4246
4234
  while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x;
@@ -4269,7 +4257,8 @@
4269
4257
  return force.alpha(0);
4270
4258
  };
4271
4259
  force.drag = function() {
4272
- if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart", d3_layout_forceDragstart).on("drag", dragmove).on("dragend", d3_layout_forceDragend);
4260
+ 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);
4261
+ if (!arguments.length) return drag;
4273
4262
  this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag);
4274
4263
  };
4275
4264
  function dragmove(d) {
@@ -4282,14 +4271,14 @@
4282
4271
  d.fixed |= 2;
4283
4272
  }
4284
4273
  function d3_layout_forceDragend(d) {
4285
- d.fixed &= 1;
4274
+ d.fixed &= ~6;
4286
4275
  }
4287
4276
  function d3_layout_forceMouseover(d) {
4288
4277
  d.fixed |= 4;
4289
4278
  d.px = d.x, d.py = d.y;
4290
4279
  }
4291
4280
  function d3_layout_forceMouseout(d) {
4292
- d.fixed &= 3;
4281
+ d.fixed &= ~4;
4293
4282
  }
4294
4283
  function d3_layout_forceAccumulate(quad, alpha, charges) {
4295
4284
  var cx = 0, cy = 0;
@@ -4318,12 +4307,7 @@
4318
4307
  quad.cx = cx / quad.charge;
4319
4308
  quad.cy = cy / quad.charge;
4320
4309
  }
4321
- function d3_layout_forceLinkDistance() {
4322
- return 20;
4323
- }
4324
- function d3_layout_forceLinkStrength() {
4325
- return 1;
4326
- }
4310
+ var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1;
4327
4311
  d3.layout.partition = function() {
4328
4312
  var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];
4329
4313
  function position(node, x, dx, dy) {
@@ -6453,7 +6437,7 @@
6453
6437
  d3.geo.stream(object, d3_geo_area);
6454
6438
  return d3_geo_areaSum;
6455
6439
  };
6456
- var d3_geo_areaSum, d3_geo_areaRing;
6440
+ var d3_geo_areaSum, d3_geo_areaRingU, d3_geo_areaRingV;
6457
6441
  var d3_geo_area = {
6458
6442
  sphere: function() {
6459
6443
  d3_geo_areaSum += 4 * π;
@@ -6462,30 +6446,29 @@
6462
6446
  lineStart: d3_noop,
6463
6447
  lineEnd: d3_noop,
6464
6448
  polygonStart: function() {
6465
- d3_geo_areaRing = 0;
6449
+ d3_geo_areaRingU = 1, d3_geo_areaRingV = 0;
6466
6450
  d3_geo_area.lineStart = d3_geo_areaRingStart;
6467
6451
  },
6468
6452
  polygonEnd: function() {
6469
- d3_geo_areaSum += d3_geo_areaRing < 0 ? 4 * π + d3_geo_areaRing : d3_geo_areaRing;
6453
+ var area = 2 * Math.atan2(d3_geo_areaRingV, d3_geo_areaRingU);
6454
+ d3_geo_areaSum += area < 0 ? 4 * π + area : area;
6470
6455
  d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;
6471
6456
  }
6472
6457
  };
6473
6458
  function d3_geo_areaRingStart() {
6474
- var λ00, φ00, λ1, λ0, φ0, cosφ0, sinφ0;
6459
+ var λ00, φ00, λ0, cosφ0, sinφ0;
6475
6460
  d3_geo_area.point = function(λ, φ) {
6476
6461
  d3_geo_area.point = nextPoint;
6477
- λ1 = λ0 = (λ00 = λ) * d3_radians, φ0 = (φ00 = φ) * d3_radians, cosφ0 = Math.cos(φ0),
6478
- sinφ0 = Math.sin(φ0);
6462
+ λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos = (φ00 = φ) * d3_radians / 2 + π / 4),
6463
+ sinφ0 = Math.sin(φ);
6479
6464
  };
6480
6465
  function nextPoint(λ, φ) {
6481
- λ *= d3_radians, φ *= d3_radians;
6482
- if (Math.abs(Math.abs(φ0) - π / 2) < ε && Math.abs(Math.abs(φ) - π / 2) < ε) return;
6483
- var cosφ = Math.cos(φ), sinφ = Math.sin(φ);
6484
- if (Math.abs(φ0 - π / 2) < ε) d3_geo_areaRing += (λ - λ1) * 2; else {
6485
- var = λ - λ0, cosdλ = Math.cos(dλ), d = Math.atan2(Math.sqrt((d = cosφ * Math.sin(dλ)) * d + (d = cosφ0 * sinφ - sinφ0 * cosφ * cosdλ) * d), sinφ0 * sinφ + cosφ0 * cosφ * cosdλ), s = (d + π + φ0 + φ) / 4;
6486
- d3_geo_areaRing += (dλ < 0 && > -π || dλ > π ? -4 : 4) * Math.atan(Math.sqrt(Math.abs(Math.tan(s) * Math.tan(s - d / 2) * Math.tan(s - π / 4 - φ0 / 2) * Math.tan(s - π / 4 - φ / 2))));
6487
- }
6488
- λ1 = λ0, λ0 = λ, φ0 = φ, cosφ0 = cosφ, sinφ0 = sinφ;
6466
+ λ *= d3_radians;
6467
+ φ = φ * d3_radians / 2 + π / 4;
6468
+ var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u0 = d3_geo_areaRingU, v0 = d3_geo_areaRingV, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ);
6469
+ d3_geo_areaRingU = u0 * u - v0 * v;
6470
+ d3_geo_areaRingV = v0 * u + u0 * v;
6471
+ λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;
6489
6472
  }
6490
6473
  d3_geo_area.lineEnd = function() {
6491
6474
  nextPoint(λ00, φ00);
@@ -6789,10 +6772,10 @@
6789
6772
  polygons = polygons.map(function(polygon, i) {
6790
6773
  var cx = vertices[i][0], cy = vertices[i][1], angle = polygon.map(function(v) {
6791
6774
  return Math.atan2(v[0] - cx, v[1] - cy);
6792
- });
6793
- return d3.range(polygon.length).sort(function(a, b) {
6775
+ }), order = d3.range(polygon.length).sort(function(a, b) {
6794
6776
  return angle[a] - angle[b];
6795
- }).filter(function(d, i, order) {
6777
+ });
6778
+ return order.filter(function(d, i) {
6796
6779
  return !i || angle[d] - angle[order[i - 1]] > ε;
6797
6780
  }).map(function(d) {
6798
6781
  return polygon[d];
@@ -7803,4 +7786,5 @@
7803
7786
  d3.time.scale.utc = function() {
7804
7787
  return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
7805
7788
  };
7806
- })();
7789
+ return d3;
7790
+ }();