@@ -565,31 +565,34 @@ class Range {
565
565
if ( gl . isXNumeric ) {
566
566
// get the least x diff if numeric x axis is present
567
567
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
+ }
577
578
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 )
581
582
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
+ }
587
589
}
590
+ } )
591
+
592
+ if ( gl . dataPoints === 1 || gl . minXDiff === Number . MAX_VALUE ) {
593
+ // fixes apexcharts.js #1221
594
+ gl . minXDiff = 0.5
588
595
}
589
- } )
590
- if ( gl . dataPoints === 1 || gl . minXDiff === Number . MAX_VALUE ) {
591
- // fixes apexcharts.js #1221
592
- gl . minXDiff = 0.5
593
596
}
594
597
} )
595
598
}
0 commit comments