Hello,

wonder if you could provide input on the following: please see toy example 
below, wanted to see if there is a way to have restrictions on how the points 
are dragged on the plot. More specifically I would like the points draggable 
horizontally ONLY and have their y axis value remain fixed, ie the movement 
vertically would be restricted and no change allowed to that direction for each 
point? much appreciate any input you may have,

library(plotly)
library(purrr)

# creates a list of 32 circle shapes (one for each row/car)
circles <- map2(
  mtcars$mpg, 
  mtcars$wt, 
  ~list(
    type = "circle",
    # anchor circles at (mpg, wt)
    xanchor = .x,
    yanchor = .y,
    # give each circle a 2 pixel diameter
    x0 = -5, x1 = 5,
    y0 = -5, y1 = 5,
    xsizemode = "pixel", 
    ysizemode = "pixel",
    # other visual properties
    fillcolor = "blue",
    line = list(color = "transparent")
  )
)


plot_ly() %>%
  layout(shapes = circles) %>%
  config(edits = list(shapePosition = TRUE))


appreciate the help,


thanks,

Andras 

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to