Add datetime filter dropdown

I would like to add a dropdown menu, where the user can view data only from a specific year (provided in the dataset there are 3 years) - or using any other column.

The goal is to allow the data shown represent all years, but to be flexible and allow the user to deep dive onto one specific year.

Hi @guy,

Iโ€™d recommend taking a look at how some of the slider examples work (like https://plot.ly/python/sliders/#simple-slider-control). The basic approach in this example is to create a separate trace for each year (or whatever grouping youโ€™d like to use), and then the slider steps change which trace is visible.

You should be able to adapt this approach to control the visibility using a dropdown control rather than a slider by moving the method and args properties from layout.sliders.setps to layout.updatemenus.buttons.

Feel free to post a small example if youโ€™d like to work through more of the details.

Hope that helps!
-Jon

Thanks for your response.
I took a look, and while it might be helpful when trying to slide between years, this doesnโ€™t give the option to accumulate years: if Iโ€™m interested in 2016 AND 2017 AND 2019 but NOT 2018, I cannot achieve that with a slider.

I was wondering if something like a Tableau filter exists - where you have a checkbox based on values from one of the columns (see in this link)

Hi @guy,

I donโ€™t think youโ€™ll be able to accomplish this kind of filtering use case with the built-in Plotly.js widgets. For more advanced use cases you can move to using a FigureWidget in the Jupyter Notebook (See https://plot.ly/python/figurewidget-app/ for example) or using Dash for a standalone web app (See https://dash.plot.ly/).

-Jon

Thanks - Iโ€™ll look into these options