From d2760ff0d78e7ec03c5b88e0e1a63081fa1eafd0 Mon Sep 17 00:00:00 2001
From: Dichi13 <diciganteng01@icloud.com>
Date: Thu, 25 Apr 2019 20:59:57 +0700
Subject: [PATCH] changed tooltip behaviour

---
 src/components/partials/Visualization.vue | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/components/partials/Visualization.vue b/src/components/partials/Visualization.vue
index 6d394a0..4d663a9 100644
--- a/src/components/partials/Visualization.vue
+++ b/src/components/partials/Visualization.vue
@@ -162,7 +162,6 @@ export default {
           .style("box-shadow", "0 5px 10px rgba(0, 0, 0, 0.25)")
           .text("")
         
-
         // ticked handler function
         self.ticked = function(e) {
           node.attr("cx", function(d) {
@@ -224,7 +223,12 @@ export default {
             }
           })
           .on("mousemove", function(d) {
-            return self.tooltip.style("top", (d3.event.pageY-window.scrollY+2) + "px").style("left", (d3.event.pageX+2) + "px")
+            let yPos = d3.event.pageY - window.scrollY + 2
+            let xPos = (d3.event.pageX)
+            if (xPos < window.innerWidth/2)
+              return self.tooltip.style("top", yPos + "px").style("left", (xPos+2) + "px").style("right", null)
+            else
+              return self.tooltip.style("top", yPos + "px").style("left", null).style("right", (window.innerWidth-xPos-20) + "px")
           })
           .on("mouseout", function() {
             return self.tooltip.style("visibility", "hidden")
-- 
GitLab