Skip to content

Commit

Permalink
Fix tool tips in add_lodcurve and dotchart
Browse files Browse the repository at this point in the history
 - need to attach tool tip to body rather than parent chart,
   as div can't be inside an SVG.
  • Loading branch information
kbroman committed Jun 8, 2020
1 parent 472d328 commit 6ebaf53
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## d3panels 1.6.2 (2020-06-08)
## d3panels 1.6.3 (2020-06-08)

- Implemented custom tool tips in order to drop the
[d3-tip]http://labratrevenge.com/d3-tip) library, which is no longer
Expand Down
12 changes: 5 additions & 7 deletions d3panels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!function() { // encapsulate d3panels functions
var d3panels = {
version: "1.6.2"
version: "1.6.3"
};
"use strict";

Expand Down Expand Up @@ -3640,7 +3640,7 @@ d3panels.dotchart = function (chartOpts) {
}).attr("cy", function (d) {
return d.y;
});
indtip = d3panels.tooltip_create(selection, points, {
indtip = d3panels.tooltip_create(d3.select("body"), points, {
tipclass: tipclass
}, function (d, i) {
return indID[i];
Expand Down Expand Up @@ -4312,7 +4312,7 @@ d3panels.add_lodcurve = function (chartOpts) {

chart = function chart(prevchart, data) {
// prevchart = chart function used to create lodchart to which we're adding
var bigpointsize, chr, curves, hiddenpoints, i, j, len, lodcurve, markerpoints, parent, ref8, svg, xscale, yscale;
var bigpointsize, chr, curves, hiddenpoints, i, j, len, lodcurve, markerpoints, ref8, svg, xscale, yscale;

if (data.chr == null) {
// data = {chr, pos, lod, marker} each an ordered vector
Expand Down Expand Up @@ -4450,10 +4450,8 @@ d3panels.add_lodcurve = function (chartOpts) {
return d3.select(this).attr("opacity", 1);
}).on("mouseout", function () {
return d3.select(this).attr("opacity", 0);
}); // parent = d3.select(svg.node().parentNode)

parent = d3.select("body");
return markertip = d3panels.tooltip_create(parent, markerSelect, {
});
return markertip = d3panels.tooltip_create(d3.select("body"), markerSelect, {
tipclass: tipclass
}, function (d, i) {
return [d.name, " LOD = " + d3.format('.2f')(d.lod)];
Expand Down
2 changes: 1 addition & 1 deletion d3panels.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3panels",
"version": "1.6.2",
"version": "1.6.3",
"description": "D3-based graphics panels",
"author": "Karl Broman <[email protected]> (https://kbroman.org)",
"repository": "github:kbroman/d3panels",
Expand Down
4 changes: 1 addition & 3 deletions src/add_lodcurve.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ d3panels.add_lodcurve = (chartOpts) ->
.on "mouseout", ->
d3.select(this).attr("opacity", 0)

# parent = d3.select(svg.node().parentNode)
parent = d3.select("body")
markertip = d3panels.tooltip_create(parent, markerSelect,
markertip = d3panels.tooltip_create(d3.select("body"), markerSelect,
{tipclass:tipclass},
(d,i) -> [d.name, " LOD = #{d3.format('.2f')(d.lod)}"])

Expand Down
2 changes: 1 addition & 1 deletion src/d3panels_top.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!function() { // encapsulate d3panels functions
var d3panels = {
version: "1.6.2"
version: "1.6.3"
};
2 changes: 1 addition & 1 deletion src/dotchart.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ d3panels.dotchart = (chartOpts) ->
.attr("cx", (d) -> d.x)
.attr("cy", (d) -> d.y)

indtip = d3panels.tooltip_create(selection, points,
indtip = d3panels.tooltip_create(d3.select("body"), points,
{tipclass:tipclass},
(d,i) -> indID[i])

Expand Down

0 comments on commit 6ebaf53

Please sign in to comment.