mckinsey / vizro

Vizro is a toolkit for creating modular data visualization applications.
https://vizro.readthedocs.io/en/stable/
Apache License 2.0
2.49k stars 112 forks source link

[Feat] Enable temporal selector `DatePicker` #309

Closed nadijagraca closed 4 months ago

nadijagraca commented 5 months ago

Description

Added temporal selector DatePicker for Filter and Parameter.

DatePicker is a single model, but based on value of argument range will either return dmc.DatePicker or dmc.DateRangePicker. Default value of range is True and the model will return dmc.DateRangePicker if range is not provided, or if the selector is not defined.

Options where DateRangePicker is returned:

  1. User does not define the Filter.selector but filter column is datetime dtype.
  2. User defines vm.DatePicker as Filter.selector without specifying range argument or by setting range=True

Option where DatePicker is returned:

  1. User defines vm.DatePicker as Filter.selector and sets vm.DatePicker range argument as False.

vm.DatePicker.value supported format are all inputs that could be translated to datetime.date. See more here

Done is separate pr:

Screenshot

image
image

Notice

antonymilne commented 5 months ago

This looks great! Just some answers to your open questions and then I will do a full review next week 🙂

  • How to hand value argument in both date picker and date range picker? I followed the approach of slider and range_slider in this pr, meaning if value is not provided I take min_date allowed for date picker, and [min_date, max_date] for date range picker.

This sounds right to me 👍

  • Do we keep min_date/max_date or do we replace it with min and max as in sliders?

Let's go for min and max to match the sliders.

Definitely keep it minimal and just expose only the essential arguments like we do for slider/rangeslider. What we should do though is set values for these fields if we think the dmc defaults aren't suitable for us. But those wouldn't be configurable as model fields, just hardcoded into the component returned in the build method.

AnnMarieW commented 5 months ago

Be sure to set the dropdownPosition prop. It seems to be a workaround for this issue: https://github.com/snehilvj/dash-mantine-components/issues/219

huong-li-nguyen commented 5 months ago

@nadijagraca - let us know how it goes! I found several issues regarding the datepickerrange from the mantine library that are still open, all concerning persistence.. So if this is not easy to solve, then let's brainstorm next week what alternatives we have. As Petar said, I also hope that we find a way to fix this other than replacing it with the dcc version 😅 I think even if we would replace it with the dcc version, it should be straight-forward except for the styling 😓 But let's see!

If you haven't seen it yet: