@@ -21,7 +21,7 @@ import { assert, isArray, eqNaN, isFunction } from 'zrender/src/core/util';
2121import Scale from '../scale/Scale' ;
2222import { AxisBaseModel } from './AxisBaseModel' ;
2323import { parsePercent } from 'zrender/src/contain/text' ;
24- import { AxisBaseOption , CategoryAxisBaseOption } from './axisCommonTypes' ;
24+ import { AxisBaseOption , CategoryAxisBaseOption , NumericAxisBaseOptionCommon } from './axisCommonTypes' ;
2525import { ScaleDataValue } from '../util/types' ;
2626
2727
@@ -69,6 +69,9 @@ export class ScaleRawExtentInfo {
6969 // Make that the `rawExtentInfo` can not be modified any more.
7070 readonly frozen : boolean ;
7171
72+ // custom dataMin/dataMax
73+ private _dataMinNum : number ;
74+ private _dataMaxNum : number ;
7275
7376 constructor (
7477 scale : Scale ,
@@ -98,6 +101,19 @@ export class ScaleRawExtentInfo {
98101 const isOrdinal = this . _isOrdinal = scale . type === 'ordinal' ;
99102 this . _needCrossZero = scale . type === 'interval' && model . getNeedCrossZero && model . getNeedCrossZero ( ) ;
100103
104+ if ( scale . type === 'interval' || scale . type === 'log' || scale . type === 'time' ) {
105+ // Process custom dataMin/dataMax
106+ const dataMinRaw = ( model as AxisBaseModel < NumericAxisBaseOptionCommon > ) . get ( 'dataMin' , true ) ;
107+ if ( dataMinRaw != null ) {
108+ this . _dataMinNum = parseAxisModelMinMax ( scale , dataMinRaw ) ;
109+ }
110+
111+ const dataMaxRaw = ( model as AxisBaseModel < NumericAxisBaseOptionCommon > ) . get ( 'dataMax' , true ) ;
112+ if ( dataMaxRaw != null ) {
113+ this . _dataMaxNum = parseAxisModelMinMax ( scale , dataMaxRaw ) ;
114+ }
115+ }
116+
101117 let axisMinValue = model . get ( 'min' , true ) ;
102118 if ( axisMinValue == null ) {
103119 axisMinValue = model . get ( 'startValue' , true ) ;
@@ -173,8 +189,20 @@ export class ScaleRawExtentInfo {
173189 // (3) If no data, it should be ensured that `scale.setBlank` is set.
174190
175191 const isOrdinal = this . _isOrdinal ;
176- const dataMin = this . _dataMin ;
177- const dataMax = this . _dataMax ;
192+ let dataMin = this . _dataMin ;
193+ let dataMax = this . _dataMax ;
194+
195+ // Include custom dataMin/dataMax in calculation
196+ // If dataMin is set and less than current data minimum, update the minimum value
197+ if ( this . _dataMinNum != null && isFinite ( dataMin ) && this . _dataMinNum < dataMin ) {
198+ dataMin = this . _dataMinNum ;
199+ }
200+
201+ // If dataMax is set and greater than current data maximum, update the maximum value
202+ if ( this . _dataMaxNum != null && isFinite ( dataMax ) && this . _dataMaxNum > dataMax ) {
203+ dataMax = this . _dataMaxNum ;
204+ }
205+
178206 const axisDataLen = this . _axisDataLen ;
179207 const boundaryGapInner = this . _boundaryGapInner ;
180208
0 commit comments