Skip to content

Enhancement: Use python installed plotly.min.js instead of renderer. #8373

Closed
@janosh

Description

@janosh

Adding fig.update_layout(legend_groupclick="toggleitem") (as documented) to the grouped legend items example does not affect legend click behavior in VS Code. It does when opening the figure in a browser. This appears to be because VS Code Jupyter ships with an outdated version of plotly.js.

Posted earlier: plotly/plotly.py#3488
Related: #2648

import plotly.graph_objects as go


fig = go.Figure()

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[2, 1, 3],
        legendgroup="group",  # this can be any string, not just "group"
        legendgrouptitle_text="First Group Title",
        name="first legend group",
        mode="markers",
        marker=dict(color="Crimson", size=10),
    )
)

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[2, 2, 2],
        legendgroup="group",
        name="first legend group - average",
        mode="lines",
        line=dict(color="Crimson"),
    )
)

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[4, 9, 2],
        legendgroup="group2",
        legendgrouptitle_text="Second Group Title",
        name="second legend group",
        mode="markers",
        marker=dict(color="MediumPurple", size=10),
    )
)

fig.add_trace(
    go.Scatter(
        x=[1, 2, 3],
        y=[5, 5, 5],
        legendgroup="group2",
        name="second legend group - average",
        mode="lines",
        line=dict(color="MediumPurple"),
    )
)

# No effect from this line
fig.update_layout(legend_groupclick="toggleitem")

Metadata

Metadata

Assignees

Labels

*out-of-scopePosted issue is not in scope of VS Codefeature-requestRequest for new features or functionalityipywidgetsRendering, loading, saving, anything to do with IPyWidgetsplot-viewer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions