You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug ποΈ
(when using a FigureResampler, with hover mode x-unified) the vertical spikes are removed when clicking reset-axis.
Reproducing the bug π
Please provide steps & minimal viable code to reproduce the behavior.
importnumpyasnpimportplotly.graph_objectsasgofromdashimportDash, Input, Output, callback_context, dcc, html, no_updatefromplotly_resamplerimportFigureResampler# Data that will be used for the plotly-resampler figuresx=np.arange(2_000_000)
noisy_sin= (3+np.sin(x/200) +np.random.randn(len(x)) /10) *x/1_000# --------------------------------------Globals ---------------------------------------app=Dash(__name__)
fig: FigureResampler=FigureResampler()
# NOTE: in this example, this reference to a FigureResampler is essential to preserve# throughout the whole dash app! If your dash app wants to create a new go.Figure(),# you should not construct a new FigureResampler object, but replace the figure of this# FigureResampler object by using the FigureResampler.replace() method.app.layout=html.Div(
[
html.H1("plotly-resampler global variable", style={"textAlign": "center"}),
html.Button("plot chart", id="plot-button", n_clicks=0),
html.Hr(),
# The graph object - which we will empower with plotly-resamplerdcc.Graph(id="graph-id"),
]
)
# ------------------------------------ DASH logic -------------------------------------# The callback used to construct and store the graph's data on the serverside@app.callback(Output("graph-id", "figure"),Input("plot-button", "n_clicks"),prevent_initial_call=True,)defplot_graph(n_clicks):
ctx=callback_contextiflen(ctx.triggered) and"plot-button"inctx.triggered[0]["prop_id"]:
# Note how the replace method is used here on the global figure objectglobalfigiflen(fig.data):
# Replace the figure with an empty one to clear the graphfig.replace(go.Figure())
fig.add_trace(go.Scattergl(name="log"), hf_x=x, hf_y=noisy_sin*0.9999995**x)
fig.add_trace(go.Scattergl(name="exp"), hf_x=x, hf_y=noisy_sin*1.000002**x)
fig.update_layout(hovermode="x unified")
fig.update_xaxes(showspikes=True)
returnfigelse:
returnno_update# The plotly-resampler callback to update the graph after a relayout event (= zoom/pan)fig.register_update_graph_callback(app=app, graph_id="graph-id")
# --------------------------------- Running the app ---------------------------------if__name__=="__main__":
app.run_server(debug=True, port=9022)
Giving this information makes it tremendously easier to work on your issue!
Expected behavior π§
The spikes should remain visible visible.
The text was updated successfully, but these errors were encountered:
Describe the bug ποΈ
(when using a FigureResampler, with hover mode
x-unified
) the vertical spikes are removed when clicking reset-axis.Reproducing the bug π
Expected behavior π§
The spikes should remain visible visible.
The text was updated successfully, but these errors were encountered: