From 0fd4a8395e2207d0cda685c1a3d69a14f121b6bf Mon Sep 17 00:00:00 2001 From: Colin McLeod Date: Tue, 16 Jun 2015 15:26:47 -0700 Subject: [PATCH] Tweak area chart tooltip --- app/js/directives/directive-area-chart.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/js/directives/directive-area-chart.js b/app/js/directives/directive-area-chart.js index c34fc9ba..0ade7b93 100755 --- a/app/js/directives/directive-area-chart.js +++ b/app/js/directives/directive-area-chart.js @@ -62,7 +62,7 @@ angular.module('app').directive('areaChart', ['$window', function($window) { // Create and Add tooltip var tip = vis.append('g').style('display', 'none'); - tip.append('rect').attr('width', '5em').attr('height', '2em').attr('x', '0.5em').attr('y', '-1em').attr('class', 'tip'); + tip.append('rect').attr('width', '4.5em').attr('height', '2em').attr('x', '0.5em').attr('y', '-1em').attr('class', 'tip'); tip.append('circle') .attr('class', 'marker') .attr('r', 4); @@ -146,9 +146,9 @@ angular.module('app').directive('areaChart', ['$window', function($window) { } function moveTip() { - var xPos = d3.mouse(this)[0], x0 = x.invert(xPos), y0 = func(x0), flip = (x0 / x.domain()[1] > 0.75); + var xPos = d3.mouse(this)[0], x0 = x.invert(xPos), y0 = func(x0), flip = (x0 / x.domain()[1] > 0.65); tip.attr('transform', 'translate(' + x(x0) + ',' + y(y0) + ')'); - tip.selectAll('rect').attr('x', flip ? '-6.25em' : '0.5em').style('text-anchor', flip ? 'end' : 'start'); + tip.selectAll('rect').attr('x', flip ? '-5.75em' : '0.5em').style('text-anchor', flip ? 'end' : 'start'); tip.selectAll('text.label').attr('x', flip ? '-2em' : '1em').style('text-anchor', flip ? 'end' : 'start'); tip.select('text.label.x').text(fmtLong(x0) + ' ' + labels.xAxis.unit); tip.select('text.label.y').text(fmtLong(y0) + ' ' + labels.yAxis.unit);