Skip to content

Commit

Permalink
Add right click "back" action
Browse files Browse the repository at this point in the history
Need to add some sort of “history”. There may be a better way.
  • Loading branch information
danfowler committed Oct 13, 2015
1 parent 287c862 commit e144a0a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/visualisations/jquery.treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
aggregated_csv_url: config.data.aggregated_csv_url,
drilldowns: config.data.drilldowns,
cuts: config.data.cuts,
year: config.data.year
year: config.data.year,
last: []
};

// Draw the treemap from the given data
Expand Down Expand Up @@ -113,6 +114,15 @@
// We have to enable event handling
enable: true,
// User clicks a node (we call it tile to avoid confusion)
onRightClick: function(tile) {
var current_tile = state.last.pop();
if (state.last.length > 0) {
makeRoot(state.last.pop());
} else {
state.last.push(current_tile);
alert("Not able to go any further");
}
},
onClick: function(tile) {
if(tile) {
// Perform a click from the config
Expand Down Expand Up @@ -183,6 +193,7 @@

// Set a node as the root node
var makeRoot = function(node) {
state.last.push(node);
// Create the representation (we need information about the node's
// children which we'll draw
var data = {children: _.map(node.children, function(item, index) {
Expand Down

0 comments on commit e144a0a

Please sign in to comment.