diff --git a/src/charts/BarStacked.js b/src/charts/BarStacked.js index 2afb7eb75..2b55a4946 100644 --- a/src/charts/BarStacked.js +++ b/src/charts/BarStacked.js @@ -518,14 +518,12 @@ class BarStacked extends Bar { elSeries, }) - x = x + xDivision - return { pathTo: paths.pathTo, pathFrom: paths.pathFrom, goalY: this.barHelpers.getGoalValues('y', null, zeroH, i, j), barXPosition, - x: w.globals.isXNumeric ? x - xDivision : x, + x: w.globals.isXNumeric ? x : x + xDivision, y, } } diff --git a/src/charts/common/bar/DataLabels.js b/src/charts/common/bar/DataLabels.js index d07b32972..03f2b6ced 100644 --- a/src/charts/common/bar/DataLabels.js +++ b/src/charts/common/bar/DataLabels.js @@ -328,16 +328,14 @@ export default class BarDataLabels { ADDITIONAL_OFFY } + // width divided into equal parts + let xDivision = w.globals.gridWidth / w.globals.dataPoints + totalDataLabelsX = - totalDataLabelsBcx + - (w.globals.isXNumeric - ? barWidth * (w.globals.barGroups.length - 1) - barWidth / 2 - : -( - barWidth * w.globals.barGroups.length - - barWidth / 2 - - strokeWidth * 2 - )) + - barTotalDataLabelsConfig.offsetX + totalDataLabelsBcx + + barWidth * (w.globals.barGroups.length - 0.5) + - (w.globals.isXNumeric ? barWidth : xDivision) + + barTotalDataLabelsConfig.offsetX } if (!w.config.chart.stacked) {