Skip to content

Commit

Permalink
Provide the html element instead of returning html content
Browse files Browse the repository at this point in the history
This reworks allows to trigger js event in the tooltip within the tooltipBuilder
  • Loading branch information
bryan-brancotte committed May 5, 2021
1 parent 0551467 commit afd2ed8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions js/tree-reusable-d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ function interactive_tree() {
return d.data.text;
},
elementEquality=function (e,f){return identifierAccessor(e)==identifierAccessor(f);},
tooltipBuilder=function(d) {
return "<div class=\"panel panel-default card\"><div class=\"panel-heading\">"+
tooltipBuilder=function(d, tooltipContainer) {
var c = "<div class=\"panel panel-default card\"><div class=\"panel-heading\">"+
textAccessor(d)+
"</div>"+
"<div class=\"panel-body\">"+
"Identifier: "+identifierAccessor(d)+
"</div></div>";
tooltipContainer.html(c);
},
preTreatmentOfLoadedTree=function(tree){return tree;},
tooltipEnabled=false,
Expand Down Expand Up @@ -177,12 +178,12 @@ function interactive_tree() {
})
.on("mouseover", function(d) {
if (!tooltipEnabled) return;
tooltipBuilder(d, tooltip);
tooltip
.transition()
.duration(200)
.style("opacity", 1);
tooltip
.html(tooltipBuilder(d))
.style("left", (d3.event.pageX+20) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
Expand Down

0 comments on commit afd2ed8

Please sign in to comment.