Hello, I have made a visual in R, and it is working perfectly but with one problem. The slider that controls the frames is not in the order I want it to be in. Not sure if the issue is because I am using dates, or if there is another issue i am not aware of.
Have recreated it below (I am using an azure database for my data, so I have made up a sample dataframe), but have replaced the date slider with just numbers. The initial question still holds though, the slider is being ordered automatically, and is not in the order I specified. Can I even replace the labels on the slider?
Any help on how to solve this would be appreciated. Thanks!
mySample <- data.frame(pg = c("v1", "v2", "v3"),spi = c(0.3, 0.5, 0.7),cpi = c(0.4, 0.5, 0.8),bac = c(100, 1000, 250))
myDates<-data.frame(m=c(1,1,1,3,3,3,2,2,2))
df<-cbind(mySample ,myDates)
names(df)<-c("pg","spi","cpi","bac","m")
p <- df %>%
plot_ly(x = ~spi,
y = ~cpi,
color = ~pg,
frame = ~m)%>%
add_trace(mode = "markers",
hoverinfo = "text",
hovertext=~t,
type = 'scatter',
size = ~bac,
sizes = c(10, 40),
marker = list(
line = list(
color = ~pg,
width = 1
)))%>%
add_trace(mode = "text",
type = 'scatter',
hoverinfo = "none",
text = ~pg,
#textposition = "top right",
textfont = list(color = '#000000',size=14)
)%>%
layout( yaxis = list(showgrid = FALSE),
xaxis = list(showgrid = FALSE),
showlegend = FALSE,
plot_bgcolor='#ff0000',
shapes = list(
list(type = "rect",
fillcolor = "#ffc000", line = list(color = "#ffc000"),
x0 = 0.85, x1 = 1.15, xref = "x",
y0 = 0.85, y1 = 1.15, yref = "y",layer="below"),
list(type = "rect",
fillcolor = "008000", line = list(color = "008000"),
x0 = 0.95, x1 = 1.05, xref = "x",
y0 = 0.95, y1 = 1.05, yref = "y",layer="below"),
list(type = "line",
line = list(color = "black", dash = 'dash'),
x0 = 1, x1 = 1, xref = "x",
y0 = 0, y1 = 2, yref = "y"),
list(type = "line",
line = list(color = "black", dash = 'dash'),
x0 = 0, x1 = 2, xref = "x",
y0 = 1, y1 = 1, yref = "y")
))%>%
animation_slider(currentvalue = list(prefix = "Reporting Month: ")) %>%
animation_opts(750)
p