From 95ac6fb65402db0f9ea883e39b6582e50a6dc207 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 29 Jun 2013 10:25:31 -0700 Subject: [PATCH 1/2] support bulk assignment for attr and style. Fixes #14 --- src/d3.tip.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/d3.tip.js b/src/d3.tip.js index d8de8d7..82ebc87 100644 --- a/src/d3.tip.js +++ b/src/d3.tip.js @@ -58,10 +58,11 @@ d3.tip = function() { // // Returns tip or attribute value tip.attr = function(n, v) { - if (arguments.length < 2) { + if (arguments.length < 2 && typeof n === 'string') { return d3.select(node).attr(n) } else { - d3.select(node).attr(n, v) + var args = Array.prototype.slice.call(arguments) + d3.selection.prototype.attr.apply(d3.select(node), args) } return tip; @@ -74,10 +75,11 @@ d3.tip = function() { // // Returns tip or style property value tip.style = function(n, v) { - if (arguments.length < 2) { + if (arguments.length < 2 && typeof n === 'string') { return d3.select(node).style(n) } else { - d3.select(node).style(n, v) + var args = Array.prototype.slice.call(arguments) + d3.selection.prototype.style.apply(d3.select(node), args) } return tip; From 656ef7ef2cb9481d5fdf019e59b4099e17085122 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 29 Jun 2013 10:25:41 -0700 Subject: [PATCH 2/2] bulk assignment test --- examples/bulk-attr-style.html | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 examples/bulk-attr-style.html diff --git a/examples/bulk-attr-style.html b/examples/bulk-attr-style.html new file mode 100644 index 0000000..cfee720 --- /dev/null +++ b/examples/bulk-attr-style.html @@ -0,0 +1,135 @@ + + + + d3.tip.js - Tooltips for D3 + + Bar Chart + + + + + + +
+ +
+ + + \ No newline at end of file