[Pkg-javascript-commits] [d3-tip.js] 08/277: tweak positioning. still not 100% right
bhuvan krishna
bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:11 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 2e90295a93777f76bc8de8362d09c51591c3e575
Author: Justin Palmer <justin at labratrevenge.com>
Date: Sat Jan 7 14:15:10 2012 -0800
tweak positioning. still not 100% right
---
examples/bars.html | 1 +
src/d3.tip.js | 19 +++++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/examples/bars.html b/examples/bars.html
index fc4bf2b..3a08a21 100644
--- a/examples/bars.html
+++ b/examples/bars.html
@@ -30,6 +30,7 @@
tip = d3.svg.tip()
.orient('top')
.padding(10)
+ .offset(function() { return [0, -10]})
.text(function(d, i, t) {
return "value: " + d;
})
diff --git a/src/d3.tip.js b/src/d3.tip.js
index 110697d..8c9f011 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -18,13 +18,13 @@ d3.svg.tip = function() {
bounds = doc.node().getBoundingClientRect(),
symbol = d3.svg.symbol().type('triangle-down').size(stemSize);
- el.on('mouseout', function() { group.remove() })
+ //el.on('mouseout', function() { group.remove() })
group.classed(klass, true).text(' ');
var rect = group.append('rect').attr('transform', 'translate(0,0)').attr('rx', 3).attr('ry', 3),
stem = group.append('path').attr('d', symbol),
- ebbox = el.node().getBBox(),
+ ebbox = el.node().getBoundingClientRect(),
stemBounds = stem.node().getBBox();
if(typeof cnt === 'string' || typeof cnt === 'number') {
@@ -32,20 +32,27 @@ d3.svg.tip = function() {
.text(cnt)
.attr('text-anchor', 'middle')
.attr('alignment-baseline', 'middle'),
- sbbox = str.node().getBBox(),
+ sbbox = str.node().getBoundingClientRect(),
rectw = sbbox.width + padding(d, i) * 2,
recth = sbbox.height + padding(d, i) * 2;
rect.attr('width', rectw).attr('height', recth)
-
var rbbox = rect.node().getBBox(),
- x = (ebbox.x - sbbox.width / 2) + oset[0],
- y = (ebbox.y - rbbox.height) - stemBounds.height + oset[1];
+ x = (ebbox.right - (ebbox.width / 2) - (rbbox.width / 2) - (stemBounds.width / 2)) + oset[0],
+ y = (ebbox.top - rbbox.height) - stemBounds.height + oset[1];
if(x <= 0) { x = 0 }
if(x + rbbox.width > bounds.width) { x = bounds.width - rbbox.width }
if(y <= 0) { y = 0 }
+ console.log(ebbox);
+ doc.append('circle')
+ .attr('class', 'debug')
+ .attr('r', 2)
+ .attr('cy', ebbox.top)
+ .attr('cx', (ebbox.right - (ebbox.width / 2)))
+ .style('fill', 'hotpink')
+
str.attr('dx', rbbox.width / 2).attr('dy', rbbox.height / 2)
group.attr('transform', "translate(" + x + "," + y + ")")
stem.attr('transform','translate(' + rbbox.width / 2 + ',' + (rbbox.height + stemBounds.height / 2) + ')')
--
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