Skip to content

Commit d935978

Browse files
remove rounding of RangeAdd values to better handle fractions
1 parent 7f882d1 commit d935978

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

modules/components/src/Aggs/RangeAgg.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const SUPPORTED_CONVERSIONS = {
2121
const supportedConversionFromUnit = (unit) =>
2222
unit ? SUPPORTED_CONVERSIONS[convert().describe(unit).measure] : [];
2323

24-
const round = (x) => Math.round(x * 100) / 100;
25-
2624
const RangeLabel = ({
2725
background = 'none',
2826
children,
@@ -119,7 +117,6 @@ class RangeAgg extends Component {
119117
stats: { max, min },
120118
} = this.props;
121119
let { currentValues, displayUnit } = this.state;
122-
const [currentMax, currentMin] = [currentValues.max, currentValues.min].map((x) => round(x));
123120

124121
return handleChange?.({
125122
field: {
@@ -133,18 +130,18 @@ class RangeAgg extends Component {
133130
{
134131
op: 'and',
135132
content: [
136-
...(currentMin > min
137-
? [{ op: '>=', content: { fieldName, value: currentMin } }]
133+
...(currentValues.min > min
134+
? [{ op: '>=', content: { fieldName, value: currentValues.min } }]
138135
: []),
139-
...(currentMax < max
140-
? [{ op: '<=', content: { fieldName, value: currentMax } }]
136+
...(currentValues.max < max
137+
? [{ op: '<=', content: { fieldName, value: currentValues.max } }]
141138
: []),
142139
],
143140
},
144141
sqon,
145142
),
146-
max: currentMax,
147-
min: currentMin,
143+
max: currentValues.max,
144+
min: currentValues.min,
148145
value: currentValues,
149146
});
150147
};
@@ -156,8 +153,8 @@ class RangeAgg extends Component {
156153
stats: { max, min },
157154
} = this.props;
158155

159-
if (round(newMax) <= round(max) && round(newMin) >= round(min)) {
160-
this.setState({ currentValues: { max: round(newMax), min: round(newMin) } });
156+
if (newMax <= max && newMin >= min) {
157+
this.setState({ currentValues: { max: newMax, min: newMin } });
161158
} else {
162159
console.error('the selected value is out of range');
163160
}

0 commit comments

Comments
 (0)