You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/11/15 12:28:03 UTC

[GitHub] [superset] villebro commented on a change in pull request #16591: feat: Range filter extras [WIP]

villebro commented on a change in pull request #16591:
URL: https://github.com/apache/superset/pull/16591#discussion_r749272486



##########
File path: superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
##########
@@ -118,47 +103,86 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
   const [row] = data;
   // @ts-ignore
   const { min, max }: { min: number; max: number } = row;
-  const { groupby, defaultValue, inputRef } = formData;
+  const { groupby, defaultValue, inputRef, stepSize, logScale } = formData;
   const [col = ''] = groupby || [];
   const [value, setValue] = useState<[number, number]>(
     defaultValue ?? [min, max],
   );
   const [marks, setMarks] = useState<{ [key: number]: string }>({});
 
+  // these could be replaced with a property instead, to allow custom transforms
+  const transformScale = useCallback(
+    (val: number | null) =>
+      logScale && val ? (val > 0 ? Math.log10(val) : 0) : val,
+    [logScale],
+  );
+
+  const inverseScale = useCallback(
+    (val: number | null) => (logScale && val ? Math.pow(10, val) : val),
+    [logScale],
+  );

Review comment:
       Could be a good idea to break these out into a util and add unit tests for these, just in case (I can see the need later for introducing other than base 10)

##########
File path: superset-frontend/src/filters/components/Range/types.ts
##########
@@ -28,6 +28,8 @@ import { PluginFilterHooks, PluginFilterStylesProps } from '../types';
 interface PluginFilterSelectCustomizeProps {
   max?: number;
   min?: number;
+  stepSize: number;
+  logScale: boolean;

Review comment:
       bycatch: This interface should be renamed to `PluginFilterRangeCustomizeProps`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org