@@ -630,15 +630,50 @@ function lessOrEqual(v0, v1) { return v0 <= v1; }
630
630
function greaterOrEqual ( v0 , v1 ) { return v0 >= v1 ; }
631
631
632
632
function applyAutorangeMinOptions ( v , ax ) {
633
- if ( ax . autorangemin !== undefined ) return ax . autorangemin ;
634
- if ( ax . autorangeclipmin === undefined ) return v ;
635
- return Math . max ( v , ax . d2l ( ax . autorangeclipmin ) ) ;
633
+ if (
634
+ ax . autorangemin !== undefined &&
635
+ hasValidMinAndMax ( ax , ax . autorangemin , ax . autorangemax )
636
+ ) {
637
+ return ax . autorangemin ;
638
+ }
639
+
640
+ if (
641
+ ax . autorangeclipmin !== undefined &&
642
+ hasValidMinAndMax ( ax , ax . autorangeclipmin , ax . autorangeclipmax )
643
+ ) {
644
+ return Math . max ( v , ax . d2l ( ax . autorangeclipmin ) ) ;
645
+ }
646
+ return v ;
636
647
}
637
648
638
649
function applyAutorangeMaxOptions ( v , ax ) {
639
- if ( ax . autorangemax !== undefined ) return ax . autorangemax ;
640
- if ( ax . autorangeclipmax === undefined ) return v ;
641
- return Math . min ( v , ax . d2l ( ax . autorangeclipmax ) ) ;
650
+ if (
651
+ ax . autorangemax !== undefined &&
652
+ hasValidMinAndMax ( ax , ax . autorangemin , ax . autorangemax )
653
+ ) {
654
+ return ax . autorangemax ;
655
+ }
656
+
657
+ if (
658
+ ax . autorangeclipmax !== undefined &&
659
+ hasValidMinAndMax ( ax , ax . autorangeclipmin , ax . autorangeclipmax )
660
+ ) {
661
+ return Math . min ( v , ax . d2l ( ax . autorangeclipmax ) ) ;
662
+ }
663
+ return v ;
664
+ }
665
+
666
+ function hasValidMinAndMax ( ax , min , max ) {
667
+ // in case both min and max are defined, ensure min < max
668
+ if (
669
+ min !== undefined &&
670
+ max !== undefined
671
+ ) {
672
+ min = ax . d2l ( ax . autorangeclipmin ) ;
673
+ max = ax . d2l ( ax . autorangeclipmax ) ;
674
+ return min < max ;
675
+ }
676
+ return true ;
642
677
}
643
678
644
679
// this function should be (and is) called before reversing the range
0 commit comments