-
-
Notifications
You must be signed in to change notification settings - Fork 144
Updating dcc.Location pathname #44
Comments
Thanks for opening @tahouse ! Yes, this would be great and you're correct that this isn't supported right now. Dash doesn't support "synced" components (there is a better name for this but I can't recall what it is, maybe "two way bindings" would be a better way to describe it.) In the case for URLs, we need the following flows: If you think about this in reactive terms like as in an Excel spreadsheet, this would cause an infinite loop - changing the URL updates the component which then updates the URL which then updates the component, etc. What Dash should do is update the components and then stop when it detects a loop like this. Or, allow the user to configure the number of loops that it should execute before stopping (like a discrete dynamical system that eventually converges). Then, you could write these relationships that depend on each other. This actually comes up a lot. If we want to enable users to write and share complex models with "what if" scenarios where every parameter is configurable, then we'll need to support this. For example, pulling from Bret Victor's Explorable Explanations (http://worrydream.com/ExplorableExplanations/):
In that case, every word that is in the Long story short, I'd like to support this use case. In the meantime, I'm not aware of any other workarounds. |
I would love this feature as well. I've tried playing with the internals dcc.Location component, but always ended up with various infinite loops or dead-ends. Recently just saw the addition of the |
So, I think that ideally we would allow circular relationships like this:
With support for previous state (plotly/dash-renderer#25), we would be able to eventually do something like:
Which might make the code a little bit cleaner (easier to add more items that depend on the current path). However, we still run into the issue of having circular dependencies. |
Just adding another vote for this feature. I believe this is generally referred to as "deep linking" (at least that's what Adobe Flex called it) and when applied to a web application is specifically referring to RESTful invocation of an application's state via its URL with the updating of the URL as the application is used, so as to continue to allow the back button in browsers to work (core usability) and states of the web application to be shared via URL as mentioned above. We are hoping to build a general purpose Plotly app for our Earth science data visualization applications that can be launched from our other web applications via RESTful URLS (I believe this already works). However, we want to make our Plotly app powerful and configurable and not being able to preserve the Plotly app's state after many operations, via an updated URL is an issue. |
I think that this is actually a separate issue than circular states, in that it's more of a built-in "save state in url" plotly/dash#188 |
Any updates on this issue? In the latest release, I tried to update a location pathname as the output of callback and ended up stuck in an infinite loop. EDIT: |
Hi @syamajala thanks for posting. Better Location handling is on the short-term roadmap but I can't guarantee any particular dates right now. We'll update this thread once we have more info |
Upvoting this. My particular use case is selecting the URL from a dropdown, because we have more pages than fits in a menu bar. I was able to create the infinite loop pretty easily by having the dropdown update the url, and the url update the page (which re-loaded the header with the dropdown)... |
Upvoting this as I would like to have a multi-user app where the URL is the user information I need to feed into the callbacks to display the correct things. |
Upvoting here as well |
Upvoting too! Thanks @chriddyp for the thorough explanation. |
Upvoting too. I have tried to redirect to a specific page after successful login. I encountered problems with both the ways that I tried:
|
Any updates on this? Would also love to have! |
Looking for a solution for this as well! |
I came across this issue, when I was searching for the same feature in Dash API.
Here are the links to:
Note, I didn't save all the output callback values in the data cache store in Redis, only the final output states of the data that was important and not output figures or tables. This can be easily done for figures' state by also saving the dict for fig.data and fig.layout in a dcc.Store component. Please let me know if any feedback on the above approach for suggestions. |
Hi, Is there still no way to do this? I have tried updating the location with:
And it returns correctly but doesn't actually change the in-browser URL. |
Hey @ldorigo, this repo is no longer used; it's been migrated into https://github.com/plotly/dash |
I've followed the updated urls example at https://plot.ly/dash/urls and have found it very helpful in setting up some rudimentary routing. I'd like to take it a bit further and allow changes made within a page to update the pathname.
From the example:
where the page-content is changed when the url pathname is updated. This works well, allowing me to set default UI states based on the pathname.
What I'd like to do is reverse the situation -- UI changes update the pathname -- on input from one of several internal divs, update the url pathname to reflect the current settings being used. The Link component updates the pathname, but only on click. I'd like the update to be based on graph update callbacks.
For instance (some made up pathname):
This doesn't seem to work however. I don't get any errors or exceptions; but nothing happens.
With this, someone could update the the UI widgets, adjust the output graphs, all the changes could reflect in the current path name like:
http://plot_server:8050/plot/dataset=1/startDate=2017-06-07/endDate=2017-06-09/
Passing this off to another user (email) would mean quick sharing of the same graph setup parameters, without having to go through tedious setup procedures (click this, wait for component to update, click next component, select multiple items from dropdown box, adjust date range 1, adjust date range 2). This seems to be inline with making dash apps more stateful, except in this case, for the user. To quote from @chriddyp on an unrelated issue:
A downside would be the need to prevent some feedback loop: user inputs a pathname, callback takes pathname and updates page content, page content update triggers pathname change, and so on.
Other than that, I'm not knowledgeable enough with the underlying react js components to try changing them. The dcc.Location component appears simpler than other components that have update methods, but maybe I'm looking in the wrong spot:
As of right now, the only option I can see for easy setup/testing urls is to generate a text string as described, but output it to some P tag on screen so that a user can copy it and paste it.
Any ideas, or am I thinking about this all wrong? Thanks for any help and for the great package.
The text was updated successfully, but these errors were encountered: