Skip to contents

Applies user-drawn shape styling to a Plotly figure using inputs from uniform_plotly_inputs_ui(). Updates the newshape layout property to style shapes drawn with Plotly's drawing tools (rectangles, circles, lines, etc.) in the modebar.

Usage

apply_plotly_newshape(fig, input, isolate_fn = isolate)

Arguments

fig

A plotly figure object.

input

Shiny input object containing shape styling fields: shape.fill, shape.line.color, shape.line.width, shape.linetype, shape.opacity.

isolate_fn

Function to isolate reactive values. Defaults to shiny::isolate.

Value

The modified plotly figure with updated newshape layout settings.

Author

Jared Andrews

Examples

fig <- plotly::plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", mode = "markers")
shape_input <- list(
    shape.fill = "#ff000030", shape.line.color = "#ff0000",
    shape.line.width = 2, shape.linetype = "solid", shape.opacity = 0.5
)
apply_plotly_newshape(fig, shape_input, isolate_fn = identity)