[Pkg-javascript-commits] [d3-tip.js] 62/277: basic top center rect positioning
bhuvan krishna
bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:17 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 ab5e52fcaba8487ace39d38efdad5350d511478f
Author: Justin Palmer <justin at github.com>
Date: Fri Apr 5 15:14:11 2013 -0700
basic top center rect positioning
---
examples/bars.html | 8 +++++++-
examples/circles.html | 8 +++++++-
src/d3.tip.js | 7 ++++---
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/examples/bars.html b/examples/bars.html
index defd513..357e422 100644
--- a/examples/bars.html
+++ b/examples/bars.html
@@ -14,8 +14,14 @@
}
.d3-tip {
- fill: #c00;
font-weight: bold;
+ padding: 12px;
+ border: 1px solid rgba(0, 0, 0, 0.8);
+ background: rgba(0, 0, 0, 0.5);
+ color: #fff;
+ text-align: center;
+ border-radius: 2px;
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.d3-tip text {
diff --git a/examples/circles.html b/examples/circles.html
index 598b9a7..c6376b2 100644
--- a/examples/circles.html
+++ b/examples/circles.html
@@ -12,8 +12,14 @@
}
.d3-tip {
- fill: #c00;
font-weight: bold;
+ padding: 12px;
+ border: 1px solid rgba(0, 0, 0, 0.8);
+ background: rgba(0, 0, 0, 0.5);
+ color: #fff;
+ text-align: center;
+ border-radius: 2px;
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.d3-tip text {
diff --git a/src/d3.tip.js b/src/d3.tip.js
index a7a89c3..62dff8b 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -25,12 +25,13 @@ d3.svg.tip = function() {
tip.show = function(v) {
var bbox = get_screen_bbox(),
- content = text.apply(this, arguments)
+ content = text.apply(this, arguments),
+ center = (bbox.ne.x - bbox.nw.x) / 2
node.innerText = content
node.style.display = 'block'
- node.style.left = bbox.ne.x + 'px'
- node.style.top = bbox.ne.y + 'px'
+ node.style.left = (bbox.ne.x - center - (node.offsetWidth / 2)) + 'px'
+ node.style.top = (bbox.ne.y - node.offsetHeight) + 'px'
}
tip.hide = function(v) {
--
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