From 20de45ae4fd50108b48b7024bad0fde98516177b Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 31 Dec 2017 00:42:18 +0100 Subject: [PATCH] Fix tooltip position by using mouse position --- js/diagrams.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/diagrams.js b/js/diagrams.js index e1d3f2a..0ae0d15 100644 --- a/js/diagrams.js +++ b/js/diagrams.js @@ -388,16 +388,16 @@ function createLineGraph(containerId, raceData){ .attr("style", "fill:rgb(225,225,225);stroke:black;stroke-width:2;") .attr("width", "150") .attr("height", (textArr.length + 1) + "em") - .attr("x", function() { return x(d.lap) + 10; }) - .attr("y", function() { return y(d.position) + 10; }); + .attr("x", function() { return d3.mouse(this)[0] + 10; }) + .attr("y", function() { return d3.mouse(this)[1] + 10; }); //Necessary to add Text for each Line textArr.forEach((text, textIndex) =>{ // Specify where to put label of text tooltipGroup.append("text") .attr("dy", (textIndex + 1) + "em") - .attr("x", function() { return x(d.lap) + 15; }) - .attr("y", function() { return y(d.position) + 15; }) + .attr("x", function() { return d3.mouse(this)[0] + 15; }) + .attr("y", function() { return d3.mouse(this)[1] + 15; }) .text(function() { return text; // Value of the text });