Plotly legend and button moves when changing Step

I have an app that uses Steps. On Step 2 i have a WebView with a Plotly Table or Graph.
When i first press update it looks as it should:

However if I go back to Step1, such that the visual disappears and then back to Step 2, the plot shows again (nothing has changed, so no update needed, but the legend and buttons on the plot has shifted:

I dont know if this is a Viktor thing or a Plotly thing, but can you give any insight?

Hi Natalie,

I will check with our FE devs and let you know.

Have a nice weekend,

Raoul

A follow-up question; if you expand and shrink the view does it sort itself out?

No, makes no difference at all

Thank you for the reply,

Could you send a minimal reproducible example so that we can have a closer look?

Regards,

Raoul

this should work

import copy

from munch import Munch
import plotly.graph_objects as go

cpts = ["model 1", "model 2", "model 3"]
results_list = [
Munch({'z': [-15.0, -15.5, -16.0, -16.5, -17.0, -17.5, -18.0, -18.5, -19.0, -19.5, -20.0], 'normal': [790.74, 1131.5, 1363.5, 1622.9, 1846.6, 2104.54, 2593.58, 2734.68, 2732.2, 3158.56, 3200.1], 'reduced': [394.0, 564.39, 683.01
, 816.22, 935.06, 1069.48, 1357.29, 1478.49, 1511.82, 1742.66, 1825.46], 'combined': [403.52, 649.68, 778.05, 935.51, 1060.37, 1215.63, 1568.57, 1685.59, 1640.24, 1940.06, 1964.09]})
Munch({'z': [-14.0, -14.5, -15.0, -15.5], 'normal': [614.32, 705.53, 1075.8, 1225.69], 'reduced': [307.15, 352.76, 537.9, 612.84], 'combined': [314.4, 385.14, 622.29, 711.17]})
Munch({'z': [-8.5, -9.0, -9.5, -10.0, -10.5, -11.0], 'normal': [133.78, 559.27, 585.97, 722.04, 1330.92, 1499.82], 'reduced': [66.88, 279.62, 281.19, 332.07, 666.29, 775.68], 'combined': [73.24, 364.27, 360.09, 381.49, 813.2, 90
7.54]})
]


fig = go.Figure()
buttons = []
visibilities = []

num = 0
for i, results in enumerate(results_list):
        num += 1
        _visible = True if num == 1 else False
        visibilities.extend([False] * 3)
        fig.add_trace(
            go.Scatter(
                name=f"{cpts[i]} - normal",
                x=results["normal"],
                y=results["z"],
                showlegend=True,
                visible=_visible,
                mode="lines+markers",
                line=dict(width=1,
                          color="red")
            )
        )
        fig.add_trace(
            go.Scatter(
                name=f"{cpts[i]} - reduced",
                x=results["reduced"],
                y=results["z"],
                showlegend=True,
                visible=_visible,
                mode="lines+markers",
                line=dict(width=1,
                          color="blue")
            )
        )
        fig.add_trace(
            go.Scatter(
                name=f"{cpts[i]} - combined",
                x=results["combined"],
                y=results["z"],
                showlegend=True,
                visible=_visible,
                mode="lines+markers",
                line=dict(width=1,
                          color="green")
            )
        )
        fig.update_xaxes(title="Rc,Net,d [kN]")
        fig.update_yaxes(title="PPN [m]")
        fig.update_layout(legend=dict(
            yanchor="top",
            xanchor="right",
            x=0.99,
            y=0.99
        ))
for i, cpt in enumerate(cpts):
    j = i * 3
    k = j + 1
    l = j + 2
    _temp_visibilities = copy.deepcopy(visibilities)
    _temp_visibilities[j] = True
    _temp_visibilities[k] = True
    _temp_visibilities[l] = True
    buttons.append(
        dict(
            label=cpts[i],
            method="update",
            args=[{"visible": _temp_visibilities}, {"title": f"{cpts[i]} - Rc,Net,D"}]
        )
    )
updatemenus = list(
    [dict(direction="down", x=1.0, y=1.1, buttons=buttons, showactive=False, xanchor="right", yanchor="top",
          active=0)]
)
fig.update_layout(updatemenus=updatemenus, title_text=f"{cpts[0]} - Rc,Net,D")

Thanks for the example. I haven’t been able to reproduce the issue yet. What browser, sdk and plotly version are you using?

Browser: Microsoft Edge
SDK: v14.13.0
Plotly: 5.23.0

Thank you! Unfortunately I am still not able reproduce. Could you share the Microsoft Edge version as well?

Regards,

Raoul

Versie 129.0.2792.52 (Officiële build) (64-bits)

i see that there is an update, but this is the version that i currently have