@@ -57,6 +57,9 @@ export class LinearAxisMixin {
57
57
}
58
58
59
59
setLinearScaleNice ( ) {
60
+ if ( ! this . _nice ) {
61
+ return false ;
62
+ }
60
63
let tickCount : number = DEFAULT_TICK_COUNT ;
61
64
const tick = this . _spec . tick || { } ;
62
65
@@ -89,31 +92,38 @@ export class LinearAxisMixin {
89
92
}
90
93
const { min, max } = this . _domain ?? { } ;
91
94
if ( isNil ( min ) && isNil ( max ) ) {
92
- this . _nice && this . _scale . nice ( tickCount ) ;
95
+ return this . _scale . nice ( tickCount ) ;
93
96
} else if ( isValid ( min ) && isNil ( max ) ) {
94
- this . _nice && this . _scale . niceMax ( tickCount ) ;
97
+ return this . _scale . niceMax ( tickCount ) ;
95
98
} else if ( isNil ( min ) && isValid ( max ) ) {
96
- this . _nice && this . _scale . niceMin ( tickCount ) ;
99
+ return this . _scale . niceMin ( tickCount ) ;
97
100
}
101
+
102
+ return false ;
98
103
}
99
104
100
105
setLogScaleNice ( ) {
106
+ if ( ! this . _nice ) {
107
+ return false ;
108
+ }
109
+
101
110
const { min, max } = this . _domain ?? { } ;
102
111
if ( isNil ( min ) && isNil ( max ) ) {
103
- this . _nice && this . _scale . nice ( ) ;
112
+ return this . _scale . nice ( ) ;
104
113
} else if ( isValid ( min ) && isNil ( max ) ) {
105
- this . _nice && this . _scale . niceMax ( ) ;
114
+ return this . _scale . niceMax ( ) ;
106
115
} else if ( isNil ( min ) && isValid ( max ) ) {
107
- this . _nice && this . _scale . niceMin ( ) ;
116
+ return this . _scale . niceMin ( ) ;
108
117
}
118
+
119
+ return false ;
109
120
}
110
121
111
122
setScaleNice ( ) {
112
123
if ( this . _spec . type === 'log' ) {
113
- this . setLogScaleNice ( ) ;
114
- } else {
115
- this . setLinearScaleNice ( ) ;
124
+ return this . setLogScaleNice ( ) ;
116
125
}
126
+ return this . setLinearScaleNice ( ) ;
117
127
}
118
128
119
129
dataToPosition ( values : any [ ] , cfg ?: IAxisLocationCfg ) : number {
@@ -222,7 +232,12 @@ export class LinearAxisMixin {
222
232
this . setDomainMinMax ( domain ) ;
223
233
this . niceDomain ( domain ) ;
224
234
this . _scale . domain ( domain , this . _nice ) ;
225
- this . setScaleNice ( ) ;
235
+
236
+ if ( this . _nice ) {
237
+ const niced = this . setScaleNice ( ) ;
238
+
239
+ ! niced && this . _scale . rescale ( ) ;
240
+ }
226
241
227
242
this . event . emit ( ChartEvent . scaleUpdate , { model : this as any , value : 'domain' } ) ;
228
243
}
@@ -287,7 +302,11 @@ export class LinearAxisMixin {
287
302
this . niceDomain ( domain ) ;
288
303
this . _scale . domain ( domain , this . _nice ) ;
289
304
// 设置scale的nice-min-max
290
- this . setScaleNice ( ) ;
305
+ if ( this . _nice ) {
306
+ const niced = this . setScaleNice ( ) ;
307
+
308
+ ! niced && this . _scale . rescale ( ) ;
309
+ }
291
310
this . _updateNiceLabelFormatter ( domain ) ;
292
311
293
312
this . _domainAfterSpec = this . _scale . domain ( ) ;
0 commit comments