Updatemenu buttons is not working properly, graph disappearing
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am trying to add buttons in plotly R by using updatemenus option to change xaxis range. I am using category array. I have 10 variable in x-axis as given below. When I use "7A" instead of "1234500" as variable at x-axis, updatemenus is working properly and it is changing graph with selected range. If I use "1234500" instead of "7A", graph is disappearing after changing range at menu. I could not find the reason.
I hope someone can help what is really wrong
Here is as an example code:
x<-c("1A","2A","3A","4A","5A","6A","1234500","1234501","1234502","1234503")
random_y <- sample(1:10, 10, replace=T)
random_z <- sample(1:10, 10, replace=T)
random_w <- sample(1:10, 10, replace=T)
data <- data.frame(x, random_y, random_z, random_w)
y<-ceiling(length(data$x)/3)
buttons<-vector(mode = "list", length = y)
for(i in 1:y){
lower<-(i-1)*3
upper<-i*3-1
a<- list(
label = as.character(i*3),
method = "update",
args = list(list(visible = c(T,T,T)),
list(xaxis = list(range = c(lower, upper))))
)
buttons[[i]]<-a
}
updatemenus <- list(
list(
active = -1,
type = 'dropdown',
direction = "down",
buttons = buttons
)
)
fig <- plot_ly(data, x = ~x, y = ~random_y, type = 'bar') %>%
add_trace(y = ~random_z)%>%
add_trace(y = ~random_w)%>%
layout(barmode = 'stack', xaxis = list(categoryorder = "array", categoryarray = ~x, range = c(0,10)),updatemenus = updatemenus
)
fig
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied R example using plot_ly, add_trace, layout, and the updatemenus configuration, comparing the "7A" and "1234500" category values. Trace how the xaxis range update is applied to the categorical axis; done means the dropdown changes the selected range without making the graph disappear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100