Skip to content
Permalink
Browse files

add click to dispatcher and add_shiny

  • Loading branch information
timelyportfolio committed Aug 30, 2016
1 parent e69b554 commit d3239b42f7dc29dcbe9456523bccd601e25f0a20
Showing with 14 additions and 2 deletions.
  1. +3 −0 R/shiny.R
  2. +11 −2 inst/htmlwidgets/sunburst.js
@@ -21,6 +21,9 @@ function(){
chart.on("mouseleave.shiny", function(d){
Shiny.onInputChange(el.id + "_mouseleave",d)
});
chart.on("click.shiny", function(d){
Shiny.onInputChange(el.id + "_click",d)
});
}
}
'
@@ -10,7 +10,7 @@ HTMLWidgets.widget({

instance.chart = {};

var dispatch = d3.dispatch("mouseover","mouseleave");
var dispatch = d3.dispatch("mouseover","mouseleave","click");

d3.rebind(instance.chart, dispatch, 'on');

@@ -156,7 +156,8 @@ HTMLWidgets.widget({
.attr("fill-rule", "evenodd")
.style("fill", function(d) { return colors(d.name); })
.style("opacity", 1)
.on("mouseover", mouseover);
.on("mouseover", mouseover)
.on("click", click);

// Add the mouseleave handler to the bounding circle.
d3.select(el).select("#"+ el.id + "-container").on("mouseleave", mouseleave);
@@ -252,6 +253,14 @@ HTMLWidgets.widget({
.style("visibility", "hidden");
}

function click(d,i) {
var sequenceArray = getAncestors(d);

dispatch.click(sequenceArray.map(
function(d){return d.name}
));
}

// Given a node in a partition layout, return an array of all of its ancestor
// nodes, highest first, but excluding the root.
function getAncestors(node) {

0 comments on commit d3239b4

Please sign in to comment.
You can’t perform that action at this time.