Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add option to zoom in sliderInput #133

Closed
Tracked by #6
gogonzo opened this issue Nov 24, 2022 · 11 comments
Closed
Tracked by #6

[Feature Request] Add option to zoom in sliderInput #133

gogonzo opened this issue Nov 24, 2022 · 11 comments

Comments

@gogonzo
Copy link
Contributor

gogonzo commented Nov 24, 2022

Our sliderInput needs improvement for distributions where values are concentrated in a narrow range. It's hard to figure out where to set slider range. I propose option to zoom in the histogram by the user.

image

  1. scenario where data are concentrated in some narrow range
  2. User can select some range which will pop up the small window where additional range slider will be shown. Range of additional range input will be the same as selected range.
  3. Selected range in the "small" slider are then reflected in the "main" slider.
@gogonzo gogonzo added this to the Module specific filter-panel milestone Nov 24, 2022
@gogonzo gogonzo added the core label Nov 24, 2022
@gogonzo gogonzo changed the title Add option to zoom in sliderInput [Feature Request] Add option to zoom in sliderInput Nov 24, 2022
@lcd2yyz
Copy link

lcd2yyz commented Nov 30, 2022

It would also be very convenient for users to be able to enter the desired value range as text input.
Something like the numerical filter slider in RStudio SDE could be pretty nice.
It allows user to drag and drop to select on a range, or enter the value directly in the text box below.
image

@nikolas-burkoff
Copy link
Contributor

Yes - I was thinking that being able to add the range might be all we actually need @lcd2yyz (i.e. behave like the slider in teal.goshawk - if you want to see the zoomed in distribution you can always use the variable browser to see what you are filtering) - it would then be much simpler both to use and to implement.

image
image

and if this was a widget in teal.widgets it could be reused in teal.goshawk...

One thing we need to be careful with is at the moment it's not possible to create invalid filters in the ui of the filter panel, but by adding input boxes it will be possible - so we should add shinyvalidate (?) and handle the case where the filter panel filtering would produce an error carefully (e.g. not apply filter until it's valid, have a save filter button which is disabled until it's valid)

@gogonzo
Copy link
Contributor Author

gogonzo commented Jan 3, 2023

@nikolas-burkoff Looks like we agree on this insightsengineering/teal.goshawk#205

@nikolas-burkoff
Copy link
Contributor

See #144

gogonzo pushed a commit that referenced this issue Jan 4, 2023
This is a branch going into @gogonzo 's work in progress branch - but
would close #133

Assuming this is the approach we want to take - it still needs 
a) some tweaking of UI - i.e. reset and apply on same line
b) the reset button to work properly
c) make the text boxes remember the range selected by the slider when
you switch to manual mode
d) handle the case where you have selected a small range (i.e. 7.5 to
7.5001) manually and saved the range and then click back on the filter -
we should probably make the textboxes remember the range (which it may
do)


![image](https://user-images.githubusercontent.com/15201933/210398106-477c6c50-97dc-44de-8ac0-e8275ffef534.png)

![image](https://user-images.githubusercontent.com/15201933/210398158-5d68768a-e988-4b93-8373-0164ffc819ae.png)

![image](https://user-images.githubusercontent.com/15201933/210398218-13d59133-d2ab-4968-bf32-400a1a147bff.png)

![image](https://user-images.githubusercontent.com/15201933/210398245-c2fa578c-4546-4b10-87ac-18ce73992828.png)
@nikolas-burkoff
Copy link
Contributor

Note
image

@nikolas-burkoff
Copy link
Contributor

shinyvalidate plays nicely with the various inputs:

Image

Though note for FilterStateDateTime we use 2 indpendent datepickers rather than a single range like in this example, which would can also be handled but you need the value of the "other" one included in the validation function

library(shiny)
library(shinyvalidate)
library(shinyWidgets)

ui <- fluidPage(
  numericRangeInput("range", "Select a range", value = c(10, 20)),
  dateRangeInput("date", "Select a date range", start = "2023-01-10", end = "2023-01-20"),
  airDatepickerInput("date2", "Select another date range", range = TRUE, value = c("2023-01-10", "2023-01-20")),
  airDatepickerInput("date_time", "Select a date range", range = TRUE, timepicker = TRUE, value = c("2023-01-10", "2023-01-20"))
)

server <- function(input, output, session) {
  iv <- shinyvalidate::InputValidator$new()

  iv$add_rule("range", sv_required("Invalid numeric range"))
  iv$add_rule("date", sv_required("Invalid date range"))
  iv$add_rule("date2", sv_required("Invalid date range"))
  iv$add_rule("datetime", sv_required("Invalid date time range"))
  iv$add_rule("range", ~ if ((.)[[1]] > (.)[[2]]) "Invalid numeric range")
  iv$add_rule("date", ~ if ((.)[[1]] > (.)[[2]]) "Invalid date range")
  iv$add_rule("date2", ~ if (length(.) < 2) "Invalid date range")
  iv$add_rule("date_time", ~ if (length(.) < 2) "Invalid datetime range")


  iv$enable()
}

shinyApp(ui, server)

@gogonzo gogonzo removed their assignment Jan 27, 2023
@gogonzo
Copy link
Contributor Author

gogonzo commented Jan 27, 2023

Blocked to avoid conflicts with #129

@gogonzo gogonzo removed the Blocked label Feb 17, 2023
@asbates
Copy link
Contributor

asbates commented Mar 6, 2023

@gogonzo I think this can be un-blocked now?

Also I'm not exactly sure what is needed here.

  • I think we don't want a zoom but rather 2 input boxes?
  • How much of Allow manually choosing range #144 do we need? For example,
    • What is the reset button supposed to do?
    • Do we need to add the validation? This feels like another issue to me because then we should do validation for all inputs.

@nikolas-burkoff
Copy link
Contributor

So I think the only inputs which need validation are this new one and the date/date time range pickers ( #158) and those have been done

@gogonzo
Copy link
Contributor Author

gogonzo commented Mar 7, 2023

@asbates

  • I think we don't want a zoom but rather 2 input boxes?

True, we prefer two input boxes

  • How much of Allow manually choosing range #144 do we need? For example,
    • What is the reset button supposed to do?
    • Do we need to add the validation? This feels like another issue to me because then we should do validation for all inputs.
  • Reset is something for later - it will reset selected to choices.
  • Regarding validation - If I was doing this issue I'd probably do this if I felt it's missing. Some inputs already have validation (date and datetime).

@donyunardi
Copy link
Contributor

asbates added a commit that referenced this issue May 9, 2023
Adds a numeric range input to range filter state cards so range can be
set manually. This is a redo of #226


Fixes #133
@asbates asbates closed this as completed May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants