[Pkg-javascript-commits] [d3-tip.js] 24/277: move orientation types into reusable methods
bhuvan krishna
bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:13 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 0c8dc55ee3f4595976763550d2c4962b76469e46
Author: Justin Palmer <justin at labratrevenge.com>
Date: Mon Jan 9 09:23:07 2012 -0800
move orientation types into reusable methods
---
src/d3.tip.js | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/d3.tip.js b/src/d3.tip.js
index e4f3cc1..44e1b21 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -14,7 +14,7 @@ d3.svg.tip = function() {
tipText = text.apply(this, arguments),
container = d3.select(node),
tag = this.tagName.toLowerCase(),
- x, y, stem, backingRect, containerRect, stemRect;
+ loc, stem, backingRect, containerRect, stemRect, d3_orient_types;
// Elements and Bounds
var doc = d3.select(this.ownerSVGElement),
@@ -49,22 +49,27 @@ d3.svg.tip = function() {
stem = container.append('path').attr('d', d3_svg_stem())
stemRect = stem.node().getBBox()
- switch(orient) {
- case 'top':
+ d3_orient_types = {
+ top: function() {
stem.attr('transform', 'translate(' + (backingRect.width / 2) + ',' + backingRect.height + ')');
-
containerRect = container.node().getBBox()
x = targetRect.x + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
y = targetRect.y - containerRect.height + tipOffset[1];
- break;
- case 'bottom':
+
+ return {x: x, y: y}
+ },
+
+ bottom: function() {
stem.attr('transform', 'translate(' + (backingRect.width / 2) + ',' + -(stemRect.height / 2) + ')');
containerRect = container.node().getBBox()
x = targetRect.x + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
- y = targetRect.y + targetRect.height + stemRect.height - tipOffset[1];
- break;
- case 'left':
+ y = targetRect.y + targetRect.height + stemRect.height - tipOffset[1]
+
+ return {x: x, y: y}
+ },
+
+ left: function() {
stem.attr('transform', 'translate(' + backingRect.width + ',' + (backingRect.height / 2) + ') rotate(-90)');
containerRect = container.node().getBBox()
@@ -78,9 +83,11 @@ d3.svg.tip = function() {
x -= containerRect.width - (stemRect.height / 2)
y -= containerRect.height / 2
}
+
+ return {x: x, y: y}
+ },
- break;
- case 'right':
+ right: function() {
stem.attr('transform', 'translate(' + -(stemRect.height / 2) + ',' + (backingRect.height / 2) + ') rotate(90)');
containerRect = container.node().getBBox()
@@ -94,10 +101,13 @@ d3.svg.tip = function() {
x += targetRect.width
y -= containerRect.height / 2
}
- break;
+
+ return {x: x, y: y}
+ }
}
- container.attr('transform', 'translate(' + x + ',' + y + ')')
+ loc = d3_orient_types[orient]()
+ container.attr('transform', 'translate(' + loc.x + ',' + loc.y + ')')
}
function d3_svg_offset() {
--
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