Skip to content

Commit d214fe8

Browse files
committed
fix #4876; stacked columns when uneven data is provided
1 parent 6213f39 commit d214fe8

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

src/modules/Range.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -565,31 +565,34 @@ class Range {
565565
if (gl.isXNumeric) {
566566
// get the least x diff if numeric x axis is present
567567
gl.seriesX.forEach((sX, i) => {
568-
if (sX.length === 1) {
569-
// a small hack to prevent overlapping multiple bars when there is just 1 datapoint in bar series.
570-
// fix #811
571-
sX.push(
572-
gl.seriesX[gl.maxValsInArrayIndex][
573-
gl.seriesX[gl.maxValsInArrayIndex].length - 1
574-
]
575-
)
576-
}
568+
if (sX.length) {
569+
if (sX.length === 1) {
570+
// a small hack to prevent overlapping multiple bars when there is just 1 datapoint in bar series.
571+
// fix #811
572+
sX.push(
573+
gl.seriesX[gl.maxValsInArrayIndex][
574+
gl.seriesX[gl.maxValsInArrayIndex].length - 1
575+
]
576+
)
577+
}
577578

578-
// fix #983 (clone the array to avoid side effects)
579-
const seriesX = sX.slice()
580-
seriesX.sort((a, b) => a - b)
579+
// fix #983 (clone the array to avoid side effects)
580+
const seriesX = sX.slice()
581+
seriesX.sort((a, b) => a - b)
581582

582-
seriesX.forEach((s, j) => {
583-
if (j > 0) {
584-
let xDiff = s - seriesX[j - 1]
585-
if (xDiff > 0) {
586-
gl.minXDiff = Math.min(xDiff, gl.minXDiff)
583+
seriesX.forEach((s, j) => {
584+
if (j > 0) {
585+
let xDiff = s - seriesX[j - 1]
586+
if (xDiff > 0) {
587+
gl.minXDiff = Math.min(xDiff, gl.minXDiff)
588+
}
587589
}
590+
})
591+
592+
if (gl.dataPoints === 1 || gl.minXDiff === Number.MAX_VALUE) {
593+
// fixes apexcharts.js #1221
594+
gl.minXDiff = 0.5
588595
}
589-
})
590-
if (gl.dataPoints === 1 || gl.minXDiff === Number.MAX_VALUE) {
591-
// fixes apexcharts.js #1221
592-
gl.minXDiff = 0.5
593596
}
594597
})
595598
}

0 commit comments

Comments
 (0)