Skip to content

Commit

Permalink
get the click events right all the way down to the leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Aug 23, 2015
1 parent ad0d8b0 commit 3f30077
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions inst/htmlwidgets/d3tree2.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ HTMLWidgets.widget({
.datum( d )
.on("click", function(d){
transition( (d.parent) ? d.parent: d );
communicateClick( d.parent ? d.parent: d );
} )
.select("text")
.text(name(d))
Expand Down Expand Up @@ -226,6 +227,9 @@ HTMLWidgets.widget({
g.append("rect")
.attr("class", "parent")
.call(rect)
.on("click", function(d){
communicateClick(d);
})
.append("title")
.text(function(d) { return formatNumber(d[valueField]); });

Expand Down Expand Up @@ -268,6 +272,11 @@ HTMLWidgets.widget({
});
}

return g;
}

function communicateClick(d){

// add a hook to Shiny
if( HTMLWidgets.shinyMode ){
Shiny.onInputChange(el.id + '_click', {name:d[celltext]})
Expand All @@ -278,8 +287,7 @@ HTMLWidgets.widget({
x.options.clickAction(d);
}

return g;
}
};

function text(text) {
text.attr("x", function(d) { return xscale(d.x) + 6; })
Expand Down

0 comments on commit 3f30077

Please sign in to comment.