[Pkg-javascript-commits] [d3-tip.js] 64/277: use new coordinate system to position tip
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 2269bdca46682a09ef9f7b6433a3719eb31ad5b6
Author: Justin Palmer <justin at github.com>
Date: Fri Apr 5 17:06:56 2013 -0700
use new coordinate system to position tip
---
examples/bars.html | 2 ++
src/d3.tip.js | 18 ++++++++----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/examples/bars.html b/examples/bars.html
index 357e422..4c7f6cf 100644
--- a/examples/bars.html
+++ b/examples/bars.html
@@ -74,6 +74,8 @@
vis = d3.select('#graph')
.append('svg')
+ .attr('width', w)
+ .attr('height', h)
.append('g')
.attr('transform', 'translate(' + padl + ',' + padt + ')')
diff --git a/src/d3.tip.js b/src/d3.tip.js
index abbc2e5..ef66b13 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -27,14 +27,12 @@ d3.svg.tip = function() {
tip.show = function(v) {
var bbox = get_screen_bbox(),
- content = text.apply(this, arguments),
- center = (bbox.ne.x - bbox.nw.x) / 2
+ content = text.apply(this, arguments)
- debug(bbox)
- node.innerText = content
+ node.innerHTML = content
node.style.display = 'block'
- node.style.left = (bbox.ne.x - center - (node.offsetWidth / 2)) + 'px'
- node.style.top = (bbox.ne.y - node.offsetHeight) + 'px'
+ node.style.left = (bbox.n.x - node.offsetWidth / 2) + 'px'
+ node.style.top = (bbox.n.y - node.offsetHeight) + 'px'
}
tip.hide = function(v) {
@@ -117,13 +115,13 @@ d3.svg.tip = function() {
function get_screen_bbox() {
var target = d3.event.target,
- bbox = {}, x, y,
+ bbox = {}, x, y, width, height,
matrix = target.getScreenCTM()
- width = target.width ? target.width.animVal.value : target.r.animVal.value * 2
+ width = target.width ? target.width.animVal.value : target.r.animVal.value * 2
height = target.height ? target.height.animVal.value : target.r.animVal.value * 2
- x = target.x ? target.x.animVal.value : target.cx.animVal.value - (width / 2)
- y = target.y ? target.y.animVal.value : target.cy.animVal.value - (height / 2)
+ x = target.x ? target.x.animVal.value : target.cx.animVal.value - (width / 2)
+ y = target.y ? target.y.animVal.value : target.cy.animVal.value - (height / 2)
point.x = x + document.body.scrollLeft
point.y = y + document.body.scrollTop
--
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