[Pkg-javascript-commits] [d3-tip.js] 20/277: left orientation

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 4e1f6e9e6077109fc4ccaf2fad380a2d6a570604
Author: Justin Palmer <justin at labratrevenge.com>
Date:   Mon Jan 9 07:59:54 2012 -0800

    left orientation
---
 README.md             |  2 +-
 examples/circles.html |  2 +-
 src/d3.tip.js         | 13 +++++++++++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index acf60ed..760ea85 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ vis.selectAll('rect')
 ```
 
 ## TODO
-* Left orientation
+* ~~Left orientation~~
 * Right orientation
 * Auto orientation
 * Reorient when tip exceeds document bounds
diff --git a/examples/circles.html b/examples/circles.html
index 908fd5f..91637b4 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('bottom')
+          .orient('left')
           .padding(10)
           .text(function(d) { return d; })
           .attr('class', 'd3-tip')
diff --git a/src/d3.tip.js b/src/d3.tip.js
index 5b3c4ef..07be67e 100644
--- a/src/d3.tip.js
+++ b/src/d3.tip.js
@@ -38,7 +38,7 @@ d3.svg.tip = function() {
       .attr('height', valRect.height)
       .attr('rx', cornerRadius)
       .attr('ry', cornerRadius)
-      
+
     val.attr('dx', valRect.width / 2).attr('dy', valRect.height / 2)
 
     backingRect = backing.node().getBBox()
@@ -56,6 +56,7 @@ d3.svg.tip = function() {
         x = targetRect.x + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
         y = targetRect.y - containerRect.height + tipOffset[1];
         break;
+      
       case 'bottom':
         stem.attr('transform', 'translate(' + (backingRect.width / 2) + ',' + -(stemRect.height / 2) + ')');
         
@@ -63,6 +64,14 @@ d3.svg.tip = function() {
         x = targetRect.x + (targetRect.width / 2) - (containerRect.width / 2) + tipOffset[0];
         y = targetRect.y + targetRect.height + stemRect.height - tipOffset[1];
         break;
+      
+      case 'left':
+        stem.attr('transform', 'translate(' + backingRect.width + ',' + (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];
+        break;
     }
 
     container.attr('transform', 'translate(' + x + ',' + y + ')')
@@ -77,7 +86,7 @@ d3.svg.tip = function() {
   }
 
   function d3_svg_stem() {
-    return d3.svg.symbol().type(orient == 'top' ? 'triangle-down' : 'triangle-up').size(stemSize);
+    return d3.svg.symbol().type(orient == 'bottom' ? 'triangle-up' : 'triangle-down').size(stemSize);
   }
 
   tip.attr = function(n, v) {

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