stevetracvc commented on a change in pull request #16591:
URL: https://github.com/apache/superset/pull/16591#discussion_r749377016
##########
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:
I think it would be interesting to allow generic transform and inverse
functions...somehow... eg, you need quadratic, but I need log. I thought about
adding an extra dropdown in the config, to allow the designer to choose between
the two, but I left it out because I wasn't sure I'd need it myself.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]