Skip to content

[BUG] Resampling not updating on all traces using go.Scatter #242

@avdcc

Description

@avdcc

Hi,

I am trying to plot using multiple y-axis.
To do this, I need to pass go.Scatter() to the ".add_trace" methods.
By doing so, the resampling when zooming in only displays in the first trace, but not any of the following traces.

You can see this happening by slightly modifying the code in "03_minimal_cache_dynamic.py", replacing the construct_display_graph with this:

@app.callback(
    ServersideOutput({"type": "store", "index": MATCH}, "data"),
    Output({"type": "dynamic-graph", "index": MATCH}, "figure"),
    State("add-chart", "n_clicks"),
    Trigger({"type": "interval", "index": MATCH}, "n_intervals"),
    prevent_initial_call=True,
)
def construct_display_graph(n_clicks) -> FigureResampler:
    fig = FigureResampler(go.Figure(), default_n_shown_samples=2_000)
    
    # Figure construction logic based on a state variable, in our case n_clicks
    sigma = n_clicks * 1e-6
    
    fig.add_trace(
        go.Scatter(
            x=x,
            y=noisy_sin * (1 + sigma) ** x - 100000,
            name="exp - 100000",
            yaxis="y",
            mode="lines"
        )
    )
    
    fig.add_trace(
        go.Scatter(
            x=x,
            y=noisy_sin * (1 + sigma) ** x + 100000,
            name="exp + 100000",
            yaxis="y2",
            mode="lines"
        )
    )
    
    
    fig.update_layout(title=f"<b>graph - {n_clicks}</b>", title_x=0.5)
    
    fig.update_layout(
        yaxis={
            "title": "exp - 100000",
        },
        yaxis2={
            "title": "exp + 100000",
            "anchor": "free",
            "overlaying": "y",
            "autoshift": True,
        }
    )

    return fig, fig

image

Environment information: (please complete the following information)

  • OS: Ubuntu Server 22.04.2
  • Python environment:
    • Python version: 3.10
    • plotly-resampler environment: Dash (2.11.1), Firefox (114.0.2)
  • plotly-resampler version: 0.8.3.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions