[Pkg-javascript-commits] [d3-tip.js] 22/277: right tips for circles

bhuvan krishna bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:57:12 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 c842b3b373b60eeaba1c53578bd9fb576f53937c
Author: Justin Palmer <justin at labratrevenge.com>
Date:   Mon Jan 9 08:46:53 2012 -0800

    right tips for circles
---
 examples/bars.html    |  2 +-
 examples/circles.html |  2 +-
 src/d3.tip.js         | 16 ++++++++++++----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/examples/bars.html b/examples/bars.html
index 92425c5..135d5e1 100644
--- a/examples/bars.html
+++ b/examples/bars.html
@@ -35,7 +35,7 @@
         x  = d3.scale.ordinal().domain(d3.range(data.length)).rangeRoundBands([0, w], 0.1),
         y  = d3.scale.linear().domain([0, d3.max(data)]).range([h, 0]),
         tip = d3.svg.tip()
-          .orient('left')
+          .orient('right')
           .padding(5)
           .text(function(d) { return d; })
           .attr('class', 'd3-tip')
diff --git a/examples/circles.html b/examples/circles.html
index 91637b4..c348660 100644
--- a/examples/circles.html
+++ b/examples/circles.html
@@ -36,7 +36,7 @@
         x = d3.scale.linear().domain([0, data.length - 1]).range([r, w - r]),
         y = d3.scale.linear().domain([0, d3.max(data)]).range([h,  r]),
         tip = d3.svg.tip()
-          .orient('left')
+          .orient('right')
           .padding(10)
           .text(function(d) { return d; })
           .attr('class', 'd3-tip')
diff --git a/src/d3.tip.js b/src/d3.tip.js
index 2d5243c..a17cd1c 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -2,7 +2,7 @@ d3.svg.tip = function() {
   var orient = 'top',
       padding = 5,
       cornerRadius = 2,
-      stemSize = 60,
+      stemSize = 50,
       offset = d3_svg_offset,
       text = d3_svg_text,
       node = make('g');
@@ -81,11 +81,19 @@ d3.svg.tip = function() {
 
       break;
       case 'right':
-        stem.attr('transform', 'translate(' + backingRect.width + ',' + (backingRect.height / 2) + ') rotate(-90)');
+        stem.attr('transform', 'translate(' + -(stemRect.height / 2) + ',' + (backingRect.height / 2) + ') rotate(90)');
         
         containerRect = container.node().getBBox()
-        x = targetRect.x - targetRect.width - (containerRect.width / 2) - (stemRect.height / 2) + tipOffset[0];
-        y = targetRect.y - (targetRect.height / 2) + tipOffset[1];
+        x = targetRect.x + (targetRect.width / 2) + stemRect.height + containerRect.width + tipOffset[0];
+        y = targetRect.y + tipOffset[1];
+
+        if(tag == 'circle') {
+          x -= targetRect.width + (containerRect.width / 2);
+          y -= targetRect.height / 2
+        } else if(tag == 'rect') {
+          x -= containerRect.width - (stemRect.height / 2)
+          y -= containerRect.height / 2
+        }
       break;    
     }
 

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