[Pkg-javascript-commits] [d3-tip.js] 05/277: first pass at stem

bhuvan krishna bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:10 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 efdc656e9b0fb86050b8698a89dc69ed29a8828c
Author: Justin Palmer <justin at labratrevenge.com>
Date:   Sat Jan 7 12:20:18 2012 -0800

    first pass at stem
---
 src/d3.tip.js | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/d3.tip.js b/src/d3.tip.js
index 6e58199..98a373c 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -2,42 +2,48 @@ d3.svg.tip = function() {
   var orient = 'top',
       id = 'd3-tip',
       className = 'd3-tip',
-      pad = 5;
+      pad = 5,
+      stemSize = 60;
 
   function tip(d, i) {
     var el = d3.select(this),
         doc = d3.select(this.ownerSVGElement),
         group = doc.select('#' + id).empty() ? doc.append('g').attr('id', id) : doc.select('#' + id),
-        bounds = doc.node().getBoundingClientRect();
+        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(className, 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),
         cnt = content(d, i, group),
-        ebbox = el.node().getBBox();
-    
+        ebbox = el.node().getBBox(),
+        stemBounds = stem.node().getBBox();
+
     if(typeof cnt === 'string' || typeof cnt === 'number') {
       var str = group.append('text')
           .text(cnt)
           .attr('text-anchor', 'middle')
           .attr('alignment-baseline', 'middle'),
           sbbox = str.node().getBBox();
+      
 
-      rect.attr('width', sbbox.width + pad * 2).attr('height', sbbox.height + pad * 2)
-      var rbbox = rect.node().getBBox();
-
-      str.attr('dx', rbbox.width / 2).attr('dy', rbbox.height / 2)
+      rect.attr('width', sbbox.width + pad * 2)
+        .attr('height', sbbox.height + pad * 2)
 
-      var x = (ebbox.x - sbbox.width / 2),
-          y = (ebbox.y - rbbox.height);
+      var rbbox = rect.node().getBBox(),
+          x = (ebbox.x - sbbox.width / 2),
+          y = (ebbox.y - rbbox.height) - stemBounds.height;
       
       if(x <= 0) { x = 0 }
       if(x + rbbox.width > bounds.width) { x = bounds.width - rbbox.width }
       if(y <= 0) { y = 0 }
 
+      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) + ')')
     }    
   }
 

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