[Pkg-javascript-commits] [d3-tip.js] 15/277: implement bottom orientation
bhuvan krishna
bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
bhuvan-guest pushed a commit to branch master
in repository d3-tip.js.
commit 0082a827eb0e9042b514645c0d16246430418866
Author: Justin Palmer <justin at labratrevenge.com>
Date: Sun Jan 8 15:35:03 2012 -0800
implement bottom orientation
---
examples/circles.html | 4 ++--
examples/line.html | 6 +++---
src/d3.tip.js | 6 +++++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/examples/circles.html b/examples/circles.html
index 8d2af8e..908fd5f 100644
--- a/examples/circles.html
+++ b/examples/circles.html
@@ -36,7 +36,7 @@
x = d3.scale.linear().domain([0, data.length - 1]).range([r, w - r]),
y = d3.scale.linear().domain([0, d3.max(data)]).range([h, r]),
tip = d3.svg.tip()
- .orient('top')
+ .orient('bottom')
.padding(10)
.text(function(d) { return d; })
.attr('class', 'd3-tip')
@@ -56,7 +56,7 @@
.on('click', function() {
var bbox = this.getBBox(),
x = bbox.x + (bbox.width / 2),
- y = bbox.y;
+ y = bbox.y + bbox.height;
linex.transition()
.attr('x1', x)
diff --git a/examples/line.html b/examples/line.html
index 704fa56..257d231 100644
--- a/examples/line.html
+++ b/examples/line.html
@@ -45,9 +45,9 @@
max = d3.max(data, function(d) { return d3.max(d) }),
linex, liney,
tip = d3.svg.tip()
- .orient('top')
+ .orient('bottom')
.padding(5)
- .offset([20, 20])
+ .offset([20, -20])
.text(function(d) { return d; })
.attr('class', 'd3-tip');
@@ -99,7 +99,7 @@
var rect = this.getBoundingClientRect(),
bbox = this.getBBox(),
x = bbox.x + (bbox.width / 2),
- y = bbox.y;
+ y = bbox.y + bbox.height;
linex.transition()
.attr('x1', x)
diff --git a/src/d3.tip.js b/src/d3.tip.js
index 2230ab2..5e58e52 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -37,12 +37,16 @@ d3.svg.tip = function() {
backing.attr('width', valRect.width).attr('height', valRect.height).attr('rx', cornerRadius).attr('ry', cornerRadius)
val.attr('dx', valRect.width / 2).attr('dy', valRect.height / 2)
- var backingRect = backing.node().getBBox();
+ var backingRect = backing.node().getBBox(),
+ containerRect = container.node().getBBox();
switch(orient) {
case 'top':
x = targetRect.x + (targetRect.width / 2) - (backingRect.width / 2) + tipOffset[0];
y = targetRect.y - backingRect.height + tipOffset[1];
+ case 'bottom':
+ x = targetRect.x + (targetRect.width / 2) - (backingRect.width / 2) + tipOffset[0];
+ y = targetRect.y + targetRect.height - tipOffset[1];
break;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/d3-tip.js.git
More information about the Pkg-javascript-commits
mailing list