reichlab / forecast-repository

Codebase for Zoltar forecast repository
https://zoltardata.com/
GNU General Public License v3.0
6 stars 3 forks source link

allow for direct links to specific viz pages #372

Closed nickreich closed 8 months ago

nickreich commented 11 months ago

If I'd like to share a link to a specific plot, e.g. a specific set of drop-down and check-box selections, could those be encapsulated within a custom url? Say I want to send someone to the page with a specific set of models and a specific date chosen, I can't do that right now. There are a lot of knobs here (e.g. the axis limits?), so it might get too messy, but a way to specify an outcome, unit, interval, models, and date would be really nice so that the link could then be passed along to others to see and explore what you are looking at.

image
matthewcornell commented 11 months ago

Maybe something like the "quick query" feature (my term) that we added for forecasts: https://zoltardata.com/forecast/106743?unit=4725&target=3625#search . It's a kind of permalink, I suppose.

nickreich commented 11 months ago

Yeah, exactly.

matthewcornell commented 8 months ago

Question: Would you want to update the browser history with every click so that users can go forward and back? ( https://reichlab.io/flusight-eval/ does this). The possible problem with doing so is that the history could get pretty long - not a memory problem, but more of unnecessary work that would show up in the browser's back/forward dropdown menu. If we did not support history then the URL would still be updated with each click, but forward/back would not be possible.

elray1 commented 8 months ago

I think we don't need to update browser history -- the main use case is probably sharing links to specific views, not necessary navigating with a back/forward button in the browser

matthewcornell commented 8 months ago

Regarding url parameter names and encoding, I suggest the following:


http://127.0.0.1:8080/dist/?as_of=2022-01-29&model=COVIDhub-baseline&model=COVIDhub-ensemble&interval=95%25&target_var=week_ahead_incident_deaths&scenario_id=1&location=48

-> Firefox parses these seven params as:

image

nickreich commented 8 months ago

Adding comments about possibly fixing the y-axis as part of this...

Draft statement of desired behavior:

nickreich commented 8 months ago

The updated functionality looks good to me. I'll note that I tried to manually change one of the dates and it ended up at a place with no data, and a very empty looking window. direct link

Maybe this is a separate issue, but we are maybe introducing the possibility of directly navigating to a place with no data to show, with editable urls?

image
matthewcornell commented 8 months ago

Good catch, Nick. Looking at the browser console I see the problem:

Uncaught (in promise) initial_as_of not in available_as_ofs: 2022-01-30

What's going on is that the program reads parameters (if present) from the URL and then validates them, same as is done with the initial options that are passed to predtimechart by clients like zoltar or Covid-19-Hub-Vizualization . I'm not sure how the offending as_of got into the URL parameters without manual editing (there may be a bug - Nick, maybe you can clarify how you got that as_of=2022-01-30?), but using the calendar and arrows, the closest valid as_ofs are 2022-01-29 and 2022-02-05.

As a solution, maybe we can have a bailout where, if the offending parameter was loaded from the URL, then all of the URL parameters are dropped. This would put the program into an initial "good" state, assuming the above options values were configured properly by the client.

matthewcornell commented 8 months ago

Following up, we decided to go ahead with the bailout, but it needs to inform the user of its actions and why.