feat: log scale and step size control for range filters [WIP]#18009
feat: log scale and step size control for range filters [WIP]#18009stevetracvc wants to merge 28 commits intoapache:masterfrom
Conversation
geido
left a comment
There was a problem hiding this comment.
Hey @stevetracvc I appreciate a lot the contributions that you are making! I am reviewing this PR which is still a WIP for some quick nits. Let me know when you are ready for a more in-depth review. Thank you!
...shboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
Outdated
Show resolved
Hide resolved
...shboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
Outdated
Show resolved
Hide resolved
|
Fixes #17043 |
|
@stevetracvc I see that some tests are requiring some love. Let me know how I can help to move this forward! Thank you |
Codecov Report
@@ Coverage Diff @@
## master #18009 +/- ##
==========================================
+ Coverage 66.57% 66.68% +0.10%
==========================================
Files 1667 1682 +15
Lines 64421 64367 -54
Branches 6503 6593 +90
==========================================
+ Hits 42886 42920 +34
+ Misses 19850 19736 -114
- Partials 1685 1711 +26
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
--ran into an issue when pulling and pushing some of this older code, now it should work when resetting the filter --it's easy to add in extra transforms, so I added cube and quad root
fixed default scaling in controlPanel, and added default in RangeFilterPlugin to handle importing old range filters to the new scaling system
|
/testenv up |
|
@geido Ephemeral environment spinning up at http://54.203.236.191:8080. Credentials are |
|
Thanks for the improvement @stevetracvc! Screen.Recording.2022-03-31.at.11.29.09.mov |
@kgabryje I agree with you – I would also expect the possible selections to be 0, 25, and 41 in that scenario. |
| inverseScale(upper), | ||
| ), | ||
| filterState: { | ||
| value: lower !== null || upper !== null ? value : null, |
There was a problem hiding this comment.
@michael-s-molina What does the filterState.value do? The variable "value" is transformed, meaning it could be the log of the actual desired value. So I'd expect that this would need to actually be
value.map(inverseScale)
like how it is below for the lower and upper vars. But the queries appear to run properly, and the text labels are correct.... 🤔 I don't see any difference when I inverse this value or leave it transformed.
We had a conversation with @michael-s-molina who has suggested the following:
You are right this wasn't straightforward forward but we aim to improve the codebase of native filters in the upcoming phase 2. Some other observations that came out from our conversation:
Let me know if you have any questions. Thanks for the hard work! |
|
Awesome! Questions inline:
If we did that, then that moves more of the config out of the specific native filter component's controlPanel file and into the main one. I had tried to make this more general so that other filter types could also include select boxes for controls if needed. If you do want the FiltersConfigForm modified instead, it seems like it should go under the "single value" checkbox, as part of the configuration rather than the settings. What do you think?
Since that's the plan, which route would be better? It seems like we'd want everything in the specific component's controlPanel rather than spread across the two files. And maybe revisit this when phase 2 is complete?
Is it really that specific? Am I one of the few people using range filters for a large range of values? If you want it hidden like that, then the wording on that needs improvement, since step size and scaling can each be used independent of the other one. Eg, you can't currently use a range filter for floats since the step size is inherently 1 (especially on a range 0 to 1). I feel like each one is its own thing, and step size could be incorporated without bothering with the scaling.
I finally found where it does its magic, so I made them half width now (I haven't pushed yet). I'm starting to understand how everything works here, but a lot of what I originally did was just get it to work because these were features I needed...so I copied and pasted code. The issue is that FiltersControlModal calls getControlItemsMap, which calls getControlItems, which flattens the controlPanel config array. I think ideally, step size and scaling function would be in the same row, don't you think? But that would take a decent rework of the FiltersConfigModal code to make that work.
Not sure I follow on this one, though it also might be related to the issue of values not being in exact increments of the step size. When I have the step size at 0.001, linear scale, for something with values 0 to 1, each increment is actually 0.005, which I think is a limitation on the antd slider control.
|
there was an issue with the displayed values not having enough significant digits to match the stepSize (SMART_NUMBER formatting)
|
Actually I think I get what @geido you meant about the decimals being displayed. SMART_NUMBER formatting was used, which didn't seem to give enough digits of precision. I just changed that to switch to ".nf" where n is the precision of the stepSize. Also I added validators to the stepSize in the controlPanel, which also required some conversion between the controlPanel validators and the StyledFormItem rules. It seems kind of odd that there are two drastically different validation methods being used. Will visualizations move to the FormItem rules? This is more obvious in the RangeFilter case because it can be both a native filter component AND a dashboard visualization. |
There were issues with odd combinations of stepSize, min, and max values. This now pushes the maximum value for the slider up to the next integer increment of stepSize. Unfortunately, the antd slider won't allow steps such as (0, 25, 50, 60) so it has to get bumped to (0, 25, 50, 75)
Unfortunately it looks like this is a restriction on the antd slider. You can't have 0, 25, 41. They say (max - min) / stepSize must be a whole number (evenly divisible). Recent push tackles this by bumping the max up to the next possible increment of stepSize. Not ideal, I know, but 0, 25, 50 is better than just 0, 25, and an unselectable 41 |
@stevetracvc Ah I see. @yousoph @lauderbaugh if you guys are fine with this then I am too 🙂 |
|
/testenv up |
|
@kgabryje Ephemeral environment spinning up at http://34.219.118.108:8080. Credentials are |
|
@kgabryje weird. It works for step sizes LESS than 1, but not greater than. Eg on the video game sales, global sales is 0 to 82. Step size of 0.001 on log scale takes it up to 82.560. But if step size is 1, it stops at 81. I'll investigate |
|
@stevetracvc it looks like this was on the road to success, but things halted. Do you still have interest/bandwidth to get this through? |
|
@rusackas I got stuck on something. It works well enough for my usage but not for release. I would probably have time in Feb to look at it again |
|
Heya @stevetracvc I'll go ahead and close this since it's been a couple years since it saw action. Please re-open it (or let me know do to so) and we'll be excited to rekindle this when the day comes! |

SUMMARY
This is my PR for issue Extra features for Range Filters #16582 (sorry, I screwed up my original PR #16591)
Range filters are fantastic, but there is no simple way to adjust the step size or the scale of the range. Scale is useful for large ranges, eg a log scale, so that you can easily select small and large values
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Config Screen Usage

Log Scale with 0.01 step size

Linear Scale with 100k step size

Config Screen Defaults

TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
Known Issues