From fc60c1b86ac83156ea817060306a1f3ff60c2552 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Tue, 10 Jun 2014 09:16:12 +0300 Subject: [PATCH] Additional chart controls: toggle all, show total --- rd_ui/app/scripts/ng_highchart.js | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/rd_ui/app/scripts/ng_highchart.js b/rd_ui/app/scripts/ng_highchart.js index bdcd742d..a9e39cba 100644 --- a/rd_ui/app/scripts/ng_highchart.js +++ b/rd_ui/app/scripts/ng_highchart.js @@ -81,6 +81,45 @@ series.update({stacking: newStacking}, true); }); } + }, + { + text: 'Select All', + onclick: function () { + _.each(this.series, function (s) { + s.setVisible(true, false); + }); + this.redraw(); + } + }, + { + text: 'Unselect All', + onclick: function () { + _.each(this.series, function (s) { + s.setVisible(false, false); + }); + this.redraw(); + } + }, + { + text: 'Show Total', + onclick: function () { + var data = {}; + _.each(this.series, function (s) { + s.setVisible(false, false); + _.each(s.data, function (p) { + data[p.x] = data[p.x] || {'x': p.x, 'y': 0}; + data[p.x].y = data[p.x].y + p.y; + }); + }); + + this.addSeries({ + data: _.values(data), + type: 'line', + name: 'Total' + }, false) + + this.redraw(); + } } ] }