From 65487a0a31d5f1d3eaa57533531e0e1c35b3a890 Mon Sep 17 00:00:00 2001 From: Justin Francos Date: Mon, 8 May 2023 20:29:12 -0400 Subject: [PATCH 1/3] Set AntdSlider step size --- .../filters/components/Range/RangeFilterPlugin.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx index 5c8533dd1e5ad..1b88c406391c7 100644 --- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx @@ -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 = stepHeuristic(min, max); + return ( {Number.isNaN(Number(min)) || Number.isNaN(Number(max)) ? ( @@ -323,6 +333,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) { Date: Mon, 8 May 2023 20:40:50 -0400 Subject: [PATCH 2/3] Appease eslint --- .../src/filters/components/Range/RangeFilterPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx index 1b88c406391c7..afe20c429c2d9 100644 --- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx @@ -304,7 +304,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) { 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)); + const normalizedStepSize = `1E${Math.floor(Math.log10(maxStepSize))}`; return Math.min(1, parseFloat(normalizedStepSize)); }; From de79685611f68273b99fe68195b78f6d75680126 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Tue, 27 Feb 2024 08:32:35 -0500 Subject: [PATCH 3/3] Apply suggestion --- .../src/filters/components/Range/RangeFilterPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx index afe20c429c2d9..9b30cd4824768 100644 --- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx @@ -308,7 +308,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) { return Math.min(1, parseFloat(normalizedStepSize)); }; - const step = stepHeuristic(min, max); + const step = max - min <= 1 ? stepHeuristic(min, max) : 1; return (