I have a simple timeline I've built using Vistime/Plotly:
library(vistime)
library(plotly)
data <- read.csv(text="event,group,start,end,color
Bought Apples,Shopping,2020-06-15,2020-10-15,#fed8b1
Shoes,Shopping,2020-07-01,2020-07-01,#fed8b1
Shoes,Shopping,2020-07-01,2020-07-01,#fed8b1
Shoes,Shopping,2020-07-02,2020-07-02,#fed8b1
Shirts,Shopping,2020-07-01,2020-07-01,#fed8b1
Invoice,Charity,2020-08-30,2020-08-30,#fed8b1
Report 1,Work,2020-06-10,2020-06-10,#ffcccb
Meeting 5,Meetings,2020-08-15,2020-08-15,#b19cd9 ")
p <- vistime(data)
pb <- plotly_build(p)
#change label size
for (i in 1:length(pb$x$data)) {
if (pb$x$data[[i]]$mode == "text") pb$x$data[[i]]$textfont$size <- 10
}
#change x axis font size:
#pb$x$layout$xaxis$tickfont <- list(size = 28)
# change marker size
for (i in 1:length(pb$x$data)) {
if (pb$x$data[[i]]$mode == "markers") pb$x$data[[i]]$marker$size <- 20
}
pb
Which gives me:
As you can see, if there are multiple points clustered close together, the labels collide. Is there any fairly easy way to avoid this problem? An out-of-the box solution that isn't too complex? I'm wondering if there's any built in methods in Vistime or Plotly to deal with this.