@@ -167,8 +167,8 @@ class RangeAgg extends Component {
167
167
return (
168
168
formatLabel ?. ( value , type ) ||
169
169
formatNumber (
170
- unit && displayUnit
171
- ? Math . round ( convert ( value ) . from ( unit ) . to ( displayUnit ) * 100 ) / 100
170
+ unit && displayUnit && unit !== displayUnit
171
+ ? convert ( value ) . from ( unit ) . to ( displayUnit )
172
172
: value ,
173
173
)
174
174
) ;
@@ -180,9 +180,8 @@ class RangeAgg extends Component {
180
180
disabled,
181
181
displayName = 'Unnamed Field' ,
182
182
fieldName,
183
- rangeStep,
183
+ rangeStep : rangeStepFromProps ,
184
184
stats : { max, min } = emptyObj ,
185
- step,
186
185
theme : {
187
186
colors,
188
187
components : {
@@ -229,10 +228,19 @@ class RangeAgg extends Component {
229
228
...( type && { 'data-type' : type } ) ,
230
229
} ;
231
230
231
+ const maxFractionRemainder = rangeStepFromProps === 0 && max % 1 ;
232
+ const decimalPointsToPad =
233
+ maxFractionRemainder && `${ maxFractionRemainder } ` . replace ( '0.' , '' ) . length - 1 ;
234
+ const calculatedStep = maxFractionRemainder
235
+ ? parseFloat ( `0.${ String ( 1 ) . padStart ( decimalPointsToPad , '0' ) } ` )
236
+ : 1 ;
237
+
238
+ const rangeStep = rangeStepFromProps || calculatedStep ;
239
+
232
240
const minIsMax = min === max ;
233
241
const unusable = disabled || min + rangeStep === max || minIsMax ;
234
242
235
- // TODO: implement unit selection disability per fieldname.
243
+ // TODO: implement unit selection disabling per fieldname.
236
244
// const enableUnitSelection = !themeDisableUnitSelection;
237
245
238
246
return (
@@ -370,7 +378,7 @@ class RangeAgg extends Component {
370
378
maxValue = { max }
371
379
onChange = { this . setNewValue }
372
380
onChangeComplete = { this . onChangeComplete }
373
- step = { step }
381
+ step = { rangeStep }
374
382
value = { currentValues }
375
383
/>
376
384
0 commit comments