Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
}
}, [enableSingleExactValue]);

const MIN_NUM_STEPS = 20;
const stepHeuristic = (min: number, max: number) => {
const maxStepSize = (max - min) / MIN_NUM_STEPS;
// normalizedStepSize: .06 -> .01, .003 -> .001
const normalizedStepSize = `1E${Math.floor(Math.log10(maxStepSize))}`;
return Math.min(1, parseFloat(normalizedStepSize));
};

const step = max - min <= 1 ? stepHeuristic(min, max) : 1;

return (
<FilterPluginStyle height={height} width={width}>
{Number.isNaN(Number(min)) || Number.isNaN(Number(max)) ? (
Expand All @@ -323,6 +333,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
<AntdSlider
min={min}
max={max}
step={step}
value={minMax[maxIndex]}
tipFormatter={tipFormatter}
marks={marks}
Expand All @@ -335,6 +346,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
validateStatus={filterState.validateStatus}
min={min}
max={max}
step={step}
value={minMax[minIndex]}
tipFormatter={tipFormatter}
marks={marks}
Expand All @@ -346,6 +358,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
<AntdSlider
min={min}
max={max}
step={step}
included={false}
value={minMax[minIndex]}
tipFormatter={tipFormatter}
Expand All @@ -359,6 +372,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
range
min={min}
max={max}
step={step}
value={minMax}
onAfterChange={handleAfterChange}
onChange={handleChange}
Expand Down