From fa00ff97be5429f2d3fb43a28a8d4eb38e25f4c5 Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Tue, 21 Apr 2020 12:27:53 +0000 Subject: [IMP] web: graph: add bar/line chart sorting PURPOSE Currently, reporting views such as the bar and line charts have their x-axis sorted either alphabetically or according to a sequence. When reporting, the user would be interested in sorting the x-axis values by their measure. SPECIFICATIONS Add 'ascending' and 'descending' options in graph view for bar and line charts Task 2070103 closes odoo/odoo#49970 Signed-off-by: Aaron Bohy (aab) Co-authored-by: Mohammed Shekha --- addons/web/static/src/js/views/graph/graph_controller.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'addons/web/static/src/js/views/graph/graph_controller.js') diff --git a/addons/web/static/src/js/views/graph/graph_controller.js b/addons/web/static/src/js/views/graph/graph_controller.js index eb5fd107081..f33db981667 100644 --- a/addons/web/static/src/js/views/graph/graph_controller.js +++ b/addons/web/static/src/js/views/graph/graph_controller.js @@ -184,6 +184,11 @@ var GraphController = AbstractController.extend({ .data('stacked', state.stacked) .toggleClass('active', state.stacked) .toggleClass('o_hidden', state.mode !== 'bar'); + this.$buttons + .find('.o_graph_button[data-order]') + .toggleClass('o_hidden', state.mode === 'pie' || !!Object.keys(state.timeRanges).length) + .filter('.o_graph_button[data-order="' + state.orderBy + '"]') + .toggleClass('active', !!state.orderBy); }, //-------------------------------------------------------------------------- @@ -258,6 +263,10 @@ var GraphController = AbstractController.extend({ this.update({ mode: $target.data('mode') }); } else if ($target.data('mode') === 'stack') { this.update({ stacked: !$target.data('stacked') }); + } else if (['asc', 'desc'].includes($target.data('order'))) { + const order = $target.data('order'); + const state = this.model.get(); + this.update({ orderBy: state.orderBy === order ? false : order }); } } }, -- cgit v1.2.3