Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/click #24

Merged
merged 3 commits into from Sep 19, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

add click to dispatcher and add_shiny

  • Loading branch information
timelyportfolio committed Aug 30, 2016
commit d3239b42f7dc29dcbe9456523bccd601e25f0a20
@@ -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) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.