enable linking to dashboard including state
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Is your feature request related to a problem? Please describe.
Outputs from Dashboards are often shared via screenshots, but the lineage is lost this way. This is because there is currently no easy way to share a dashboard including the state. When using Google Maps you can share your current URL and the other person will get the same view from the URL that you had. This is because Google Maps encodes it state in the url. I want the same thing for Plotly Dash.
Describe the solution you'd like
This app provides a manual proof of concept. When typing in my-input the URL automatically updates and when you copy and paste the URL in another tab, my-input text is already filled.
from html import escape, unescape
from dash import Dash, Input, Output, callback, dcc, html
app = Dash(__name__)
app.layout = html.Div(
[
html.H6("Change the value in the text box to see callbacks in action!"),
html.Div(
["Input: ", dcc.Input(id="my-input", value="initial value", type="text")]
),
html.Br(),
html.Div(id="my-output"),
# This prohibits the circular depedency warning
# I don't know if there are unwanted side effects
# https://github.com/plotly/dash/issues/889
dcc.Location(id="url-get", refresh=False),
dcc.Location(id="url-set", refresh=False),
dcc.Clipboard(
target_id="my-output",
title="copy",
style={
"display": "inline-block",
"fontSize": 20,
"verticalAlign": "top",
},
),
]
)
@callback(
Output(component_id="my-input", component_property="value"),
Input(component_id="url-get", component_property="search"),
)
def from_url(search):
search = dict(pair.split("=", 2) for pair in search[1:].split("&"))
my_input = search["my_input"]
return my_input
@callback(
[
Output(component_id="my-output", component_property="children"),
Output(component_id="url-set", component_property="search"),
],
Input(component_id="my-input", component_property="value"),
)
def update_output_div(my_input):
search = f"?my_input={my_input}"
return escape(f"http://localhost:8050/{search}"), search
if __name__ == "__main__":
app.run(debug=True)
What I've done manually in the app shall be automated for all input parameters (as everything else is calculated from that). I would like this to be an option added to Dash(). This should be doable as callback only accept HTML parseable inputs (and outputs). I havent thought about technical or performance limitations of this approach if scaled to larger Dash apps.
Describe alternatives you've considered
I havent considered any alternative.
Additional context
URL and state are in sync.
Currently we are not interested in sponsoring such a feature.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Dash() configuration, callback handling, and the dcc.Location URL pattern shown in the issue. Define how an opt-in setting should serialize all callback inputs into the URL and restore them on load, then verify that a copied dashboard URL reproduces the same state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100