From 22133a01becd01e6d8e85ab17ed192baf640f811 Mon Sep 17 00:00:00 2001 From: "Dardenne Florent (dafl)" Date: Wed, 3 Aug 2022 12:12:08 +0000 Subject: [PATCH] [IMP] web: add cumulative line chart The cumulative option on line chart is useful for displaying cumulative information graphically. closes odoo/odoo#97394 Task-id: 2146487 Signed-off-by: FrancoisGe --- .../src/views/graph/graph_arch_parser.js | 3 ++ .../src/views/graph/graph_controller.js | 5 ++ .../src/views/graph/graph_controller.xml | 4 ++ .../web/static/src/views/graph/graph_model.js | 2 +- .../static/src/views/graph/graph_renderer.js | 9 +++- .../web/static/src/views/graph/graph_view.js | 1 + .../static/tests/views/graph_view_tests.js | 50 +++++++++++++++++++ 7 files changed, 72 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/graph/graph_arch_parser.js b/addons/web/static/src/views/graph/graph_arch_parser.js index caa1e021090..d01f91d4d82 100644 --- a/addons/web/static/src/views/graph/graph_arch_parser.js +++ b/addons/web/static/src/views/graph/graph_arch_parser.js @@ -22,6 +22,9 @@ export class GraphArchParser extends XMLParser { if (node.hasAttribute("stacked")) { archInfo.stacked = archParseBoolean(node.getAttribute("stacked")); } + if (node.hasAttribute("cumulated")) { + archInfo.cumulated = archParseBoolean(node.getAttribute("cumulated")); + } const mode = node.getAttribute("type"); if (mode && MODES.includes(mode)) { archInfo.mode = mode; diff --git a/addons/web/static/src/views/graph/graph_controller.js b/addons/web/static/src/views/graph/graph_controller.js index 0e1ddd3dd4c..c77923e058d 100644 --- a/addons/web/static/src/views/graph/graph_controller.js +++ b/addons/web/static/src/views/graph/graph_controller.js @@ -112,6 +112,11 @@ export class GraphController extends Component { const { stacked } = this.model.metaData; this.model.updateMetaData({ stacked: !stacked }); } + + toggleCumulated() { + const { cumulated } = this.model.metaData; + this.model.updateMetaData({ cumulated: !cumulated }); + } } GraphController.template = "web.GraphView"; diff --git a/addons/web/static/src/views/graph/graph_controller.xml b/addons/web/static/src/views/graph/graph_controller.xml index ec97f5b03c6..75049f4574b 100644 --- a/addons/web/static/src/views/graph/graph_controller.xml +++ b/addons/web/static/src/views/graph/graph_controller.xml @@ -38,6 +38,10 @@ t-on-click="toggleStacked" t-att-class="{ active: model.metaData.stacked }" /> +