From ba03b7ff048b4ac7257d677a17757897a4f937d1 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 2 Dec 2013 17:52:20 -0500 Subject: [PATCH] Make it so clicking on a bar in the chart filters down to events of that type --- static/js/graphing.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/static/js/graphing.js b/static/js/graphing.js index 52a7a5958..b276fa211 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -1410,7 +1410,28 @@ LogUsageChart.prototype.getColor = function(kind) { }; +/** + * Handler for when an element in the chart has been clicked. + */ +LogUsageChart.prototype.handleElementClicked_ = function(e) { + var key = e.series.key; + var kind = e.series.kind; + var disabled = []; + + for (var i = 0; i < this.data_.length; ++i) { + disabled.push(this.data_[i].key != key); + } + + this.chart_.dispatch.changeState({ 'disabled': disabled }); +}; + + +/** + * Handler for when the state of the chart has changed. + */ LogUsageChart.prototype.handleStateChange_ = function(e) { + window.console.log(e); + var allowed = {}; var disabled = e.disabled; for (var i = 0; i < this.data_.length; ++i) { @@ -1481,9 +1502,8 @@ LogUsageChart.prototype.draw = function(container, logData) { nv.utils.windowResize(chart.update); - chart.multibar.dispatch.on('elementClick', function(e) { window.console.log(e); }); + chart.multibar.dispatch.on('elementClick', function(e) { that.handleElementClicked_(e); }); chart.dispatch.on('stateChange', function(e) { that.handleStateChange_(e); }); - - return chart; + return that.chart_ = chart; }); }; \ No newline at end of file