[Pkg-javascript-commits] [d3-tip.js] 42/277: top position working for circles

bhuvan krishna bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:15 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 de494366b4800d283a8dbc6ee5800a97eda05aa9
Author: Caged <justin at labratrevenge.com>
Date:   Tue Feb 7 16:57:45 2012 -0800

    top position working for circles
---
 examples/nested-groups.html | 10 +++++++---
 src/d3.tip.js               | 20 +++++++++++++++-----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/examples/nested-groups.html b/examples/nested-groups.html
index 60eff0d..5d5c98b 100644
--- a/examples/nested-groups.html
+++ b/examples/nested-groups.html
@@ -80,7 +80,12 @@
         .padding(4)
         .text(function(d) { return d; })
         .attr('class', 'd3-tip');
-
+      tip2 = d3.svg.tip()
+        .orient('top')
+        .offset([-11, -32])
+        .padding(4)
+        .text(function(d) { return d; })
+        .attr('class', 'd3-tip');
 
   // CIRCLES HERE
   (function() {
@@ -124,7 +129,7 @@
       dots.append('circle')
         .attr('r', 4)
         .on('mouseover', function(d, i) {
-          tip.apply(this, arguments)
+          tip2.apply(this, arguments)
           var rect = this.getBoundingClientRect(),
               bbox = this.getBBox(),
               // trans = this.getTransformToElement(),
@@ -193,7 +198,6 @@
         .attr('height', function(d) { return h - y(d) })
         .attr('y', function(d) { return y(d) })
         .on('mouseover', function(d) {
-          d3.select(this).style('fill', 'red')
           tip.apply(this, arguments)
           var rect = this.getBoundingClientRect(),
               bbox = this.getBBox(),
diff --git a/src/d3.tip.js b/src/d3.tip.js
index 1b2c45f..3584d88 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -28,7 +28,7 @@ d3.svg.tip = function() {
         targetCTM  = this.getCTM();
 
     // TODO: Allow ability to specify this in someway
-    target.on('mouseout', function() { container.remove() })
+    // target.on('mouseout', function() { container.remove() })
 
     // FIXME: d3 has problems using `append` with nodes that were created
     // but not immediately added to the SVG dom.
@@ -63,8 +63,13 @@ d3.svg.tip = function() {
         containerRect = container.node().getBBox()
         stemRect = stem.node().getBBox()
 
-        x = targetCTM.e + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
-        y = targetRect.y - stemRect.height + tipOffset[1];
+        if(tag == 'circle') {
+          x = targetCTM.e + tipOffset[0];
+          y = targetCTM.f  + tipOffset[1];
+        } else {
+          x = targetCTM.e + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
+          y = targetRect.y - stemRect.height + tipOffset[1];
+        }
 
         return {x: x, y: y}
       },
@@ -80,8 +85,13 @@ d3.svg.tip = 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]
+        if(tag == 'circle') {
+          x = targetCTM.e;
+          y = targetCTM.f;
+        } else {
+          x = targetRect.x + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
+          y = targetRect.y + targetRect.height + stemRect.height - tipOffset[1];
+        }
 
         return {x: x, y: y}
       },

-- 
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