@@ -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,11 @@ 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 _dataMinRaw : ScaleDataValue ;
74+ private _dataMaxRaw : ScaleDataValue ;
75+ private _dataMinNum : number ;
76+ private _dataMaxNum : number ;
7277
7378 constructor (
7479 scale : Scale ,
@@ -98,6 +103,19 @@ export class ScaleRawExtentInfo {
98103 const isOrdinal = this . _isOrdinal = scale . type === 'ordinal' ;
99104 this . _needCrossZero = scale . type === 'interval' && model . getNeedCrossZero && model . getNeedCrossZero ( ) ;
100105
106+ if ( scale . type === 'interval' || scale . type === 'log' ) {
107+ // Process custom dataMin/dataMax
108+ this . _dataMinRaw = ( model as AxisBaseModel < NumericAxisBaseOptionCommon > ) . get ( 'dataMin' , true ) ;
109+ if ( this . _dataMinRaw != null ) {
110+ this . _dataMinNum = parseAxisModelMinMax ( scale , this . _dataMinRaw ) ;
111+ }
112+
113+ this . _dataMaxRaw = ( model as AxisBaseModel < NumericAxisBaseOptionCommon > ) . get ( 'dataMax' , true ) ;
114+ if ( this . _dataMaxRaw != null ) {
115+ this . _dataMaxNum = parseAxisModelMinMax ( scale , this . _dataMaxRaw ) ;
116+ }
117+ }
118+
101119 let axisMinValue = model . get ( 'min' , true ) ;
102120 if ( axisMinValue == null ) {
103121 axisMinValue = model . get ( 'startValue' , true ) ;
@@ -173,8 +191,20 @@ export class ScaleRawExtentInfo {
173191 // (3) If no data, it should be ensured that `scale.setBlank` is set.
174192
175193 const isOrdinal = this . _isOrdinal ;
176- const dataMin = this . _dataMin ;
177- const dataMax = this . _dataMax ;
194+ let dataMin = this . _dataMin ;
195+ let dataMax = this . _dataMax ;
196+
197+ // Include custom dataMin/dataMax in calculation
198+ // If dataMin is set and less than current data minimum, update the minimum value
199+ if ( this . _dataMinNum != null && isFinite ( dataMin ) && this . _dataMinNum < dataMin ) {
200+ dataMin = this . _dataMinNum ;
201+ }
202+
203+ // If dataMax is set and greater than current data maximum, update the maximum value
204+ if ( this . _dataMaxNum != null && isFinite ( dataMax ) && this . _dataMaxNum > dataMax ) {
205+ dataMax = this . _dataMaxNum ;
206+ }
207+
178208 const axisDataLen = this . _axisDataLen ;
179209 const boundaryGapInner = this . _boundaryGapInner ;
180210
0 commit comments