Skip to content

Commit

Permalink
fix stacked bars condition when setting stacked min max
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Nov 26, 2023
1 parent 939125f commit 03d799f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/charts/common/line/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Helpers {

let pointsPos = {
x: ptX,
y: ptY
y: ptY,
}

return pointsPos
Expand Down Expand Up @@ -98,13 +98,15 @@ export default class Helpers {

return {
pathFromLine,
pathFromArea
pathFromArea,
}
}

determineFirstPrevY({ i, series, prevY, lineYPosition }) {
let w = this.w
let stackSeries = w.config.chart.stacked && (!w.config.chart.stackOnlyBar || (series[i] && series[i].type && series[i].type === 'bar'));
let stackSeries =
w.config.chart.stacked &&
(!w.config.chart.stackOnlyBar || series?.[i]?.type === 'bar')

if (typeof series[i]?.[0] !== 'undefined') {
if (stackSeries) {
Expand All @@ -127,11 +129,7 @@ export default class Helpers {
2
} else {
// the first value in the current series is null
if (
stackSeries &&
i > 0 &&
typeof series[i][0] === 'undefined'
) {
if (stackSeries && i > 0 && typeof series[i][0] === 'undefined') {
// check for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses)
for (let s = i - 1; s >= 0; s--) {
// for loop to get to 1st previous value until we get it
Expand All @@ -145,7 +143,7 @@ export default class Helpers {
}
return {
prevY,
lineYPosition
lineYPosition,
}
}
}
4 changes: 3 additions & 1 deletion src/modules/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ class Range {
stackedNegs[group][j] = 0
}
let stackSeries =
!this.w.config.chart.stackOnlyBar || gl.series?.[i]?.type === 'bar'
!this.w.config.chart.stackOnlyBar ||
gl.series?.[i]?.type === 'bar' ||
this.w.config.chart.type === 'bar'

if (stackSeries) {
if (gl.series[i][j] !== null && Utils.isNumber(gl.series[i][j])) {
Expand Down

0 comments on commit 03d799f

Please sign in to comment.