How to lock editing on some shapes in plotly

Hi,

When I am using the following config in Dcc.Graph, it is making ALL the shapes editable. E.g. if I am adding my own X-axis and Y-axis using fig.add_shapes, it is. making the axes positions editable as well.

Is there any way to make certain shapes editable and other not ?

       config={
            'editable': True,
            'edits': {
                'shapePosition': True
            }

Hi @SANTY.DAS.8128,

Welcome to the community!

If you used Config Options, it will apply to all shapes.
The possible approach is, you can set editable attribute directly in add_shape method.

# Add first editable shape
fig.add_shape(type="rect",
    x0=1, y0=1, x1=2, y1=3, editable=True,
    line=dict(color="RoyalBlue"),
)

# Add first non-editable shape
fig.add_shape(type="rect",
    x0=3, y0=1, x1=6, y1=2, editable=False,
    line=dict(
        color="RoyalBlue",
        width=2,
    ),
    fillcolor="LightSkyBlue",
)

It will make first shape editable, and the second one is not.

Hope this help.

2 Likes