Skip to content

Commit

Permalink
Merge pull request #4482 from rosco54/Issue_4474
Browse files Browse the repository at this point in the history
Stacked column totals dataLabel position fix (category X-axis).
  • Loading branch information
junedchhipa authored May 24, 2024
2 parents c677e1a + f403059 commit 8b34013
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/charts/BarStacked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/charts/common/bar/DataLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8b34013

Please sign in to comment.