From dd739f5757ae1e9f9ab9b19bb1139f96c0245f01 Mon Sep 17 00:00:00 2001 From: Florian Damhaut Date: Wed, 17 Apr 2024 16:26:11 +0200 Subject: [PATCH] [FIX] web: cumulated graph single fix Single value graph were not shown in cumulated graph. This is due to unshift happening before the accumulator, leading to `undefined + X = NaN` for the value. closes odoo/odoo#162385 X-original-commit: 121aa7e02235c5117bf6be6ccc6c8d6cefe6a744 Signed-off-by: Mathieu Duckerts-Antoine (dam) Signed-off-by: Florian Damhaut (flda) --- .../web/static/src/views/graph/graph_renderer.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/views/graph/graph_renderer.js b/addons/web/static/src/views/graph/graph_renderer.js index 46f216ebe63..fdf8f2ed163 100644 --- a/addons/web/static/src/views/graph/graph_renderer.js +++ b/addons/web/static/src/views/graph/graph_renderer.js @@ -373,6 +373,13 @@ export class GraphRenderer extends Component { } else { dataset.borderColor = getColor(index, cookie.get("color_scheme")); } + if (cumulated) { + let accumulator = dataset.cumulatedStart; + dataset.data = dataset.data.map((value) => { + accumulator += value; + return accumulator; + }); + } if (data.labels.length === 1) { // shift of the real value to right. This is done to // center the points in the chart. See data.labels below in @@ -386,13 +393,6 @@ export class GraphRenderer extends Component { if (stacked) { dataset.backgroundColor = hexToRGBA(dataset.borderColor, LINE_FILL_TRANSPARENCY); } - if (cumulated) { - let accumulator = dataset.cumulatedStart; - dataset.data = dataset.data.map((value) => { - accumulator += value; - return accumulator; - }); - } } if (data.datasets.length === 1 && data.datasets[0].originIndex === 0) { const dataset = data.datasets[0];