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

Meta-issue on date filters/widgets across Lumen, Panel and Param #293

Open
maximlt opened this issue Aug 2, 2022 · 0 comments
Open

Meta-issue on date filters/widgets across Lumen, Panel and Param #293

maximlt opened this issue Aug 2, 2022 · 0 comments

Comments

@maximlt
Copy link
Member

maximlt commented Aug 2, 2022

This is a meta-issue on the handling of datetime widgets across Lumen, Panel and Param. I'm posting it here as the goal of this analysis was to see what were the missing parts to update the date/datetime filters offered by Lumen. But of course this entails improving Panel, and in some cases improving Param (as was done recently with improving the serialization support, to allow syncing a date filter value with the URL).

For now, this skips mentioning time zones, which is another analysis of its own.

Python

First useful observation, datetime.datetime is a subclass of datetime.date.

Param 1.12.2

Date Parameters and the types they accept

Given the type alias dt_types as datetime.date | datetime.datetime | np.datetime64.

Observations/Suggestions

CalendarDateRange actually accepts a tuple that contain one or more datetime.datetime values. Not sure how disruptive it would be to change that.

Panel 0.13.1

Date Widgets

Panel Widget value Param Display as
DatePicker CalendarDate calendar date
DatetimePicker Date datetime
DatetimeRangePicker DateRange datetime
DateSlider Date calendar date
DateRangeSlider DateRange calendar date
DatetimeRangeSlider DateRange datetime
DatetimeInput Date datetime
DatetimeRangeInput Tuple datetime

Observations/Suggestions

  • DatetimeRangeSlider is new and inherits all from DateRangeSlider except that it is based on another Bokeh widget that renders the values as datetimes. DateRangeSlider's value Parameter should be CalendarDate
  • DateSlider has a as_datetime Boolean Parameter that when True leas to value being casted to datetime.date or datetime.datetime.
  • Missing DatetimeSlider whose display is a datetime:
  • Missing DateRangePicker whose value Parameter is a CalendarDateRange. There's actually an open PR by a contributor: Daterangepicker panel#2804
  • Missing a DateInput widget whose value Parameter is a CalendarDate and displays as a calendar date
  • DatetimeRangeInput won't serialize as the Parameter that holds the datetime values isn't a date-like Parameter but a bare tuple.

Lumen

Current Date Filters

Lumen currently has one date filter -DateFilter - whose behavior can be changed by setting the mode parameter:

  • slider: DateRangeSlider
  • picker: DatePicker

Observations/Suggestions

  • More date filters should be made available to Lumen users!
    • Add datetime filters as there's currently none.
  • WidgetFilterand BinFilter both have a multi parameter, multi=True meaning that a multi-select widget is used instead of a single-select widget. As far as possible this distinction should be reused to keep the

Suggested changes to DateFilter:

Mostly by adding a multi parameter that is True by default asmulti is True by default for WidgetFilter and BinFilter. mode being currently 'slider' by default this also preserves the current default widget users get by declaring a DateFilter. However, when mode is set to 'picker' the proposed logic would lead to a DateRangePicker, that doesn't yet exist. There are three options:

  1. add the DateRangePicker to Panel before its next release and the next release of Lumen
  2. temporarily return a DatetimeRangePicker, and make sure that the date types are correctly handled
  3. temporarily return anyway a DatePicker, to totally preserve backwards compatibility, raising a warning that this should change in a future version in favor of a DateRangePicker. We may have to bend the code in a weird way for this to work, as a DatePicker isn't a multi type of widget

I'd go for 1, or 2, but not 3 as I've got access to a code base with many Lumen apps where I saw no usage at all of the 'picker' mode.

multi mode Panel widget
True slider DateRangeSlider
True picker 1, 2 or 3?
False slider DateSlider
False picker DatePicker

Suggesting adding a new DatetimeFilter:

multi mode Panel widget
True slider DatetimeRangeSlider
True picker DatetimeRangePicker
False slider fallback to DatetimePicker
False picker DatetimePicker

As there's no DatetimeSlider I would just document that this isn't yet a supported case, emit a warning and fall back to a DatetimePicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant