[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) <dam@odoo.com> Signed-off-by: Florian Damhaut (flda) <flda@odoo.com>
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user