Skip missing dates in time series graph

`I simply want to plot a timeseries bar graph. There are no inputs on weenends and plotly recognises that the data is a time series and plots blank spaces for days with no data.
Is it possible to disable this feature and plot only the days with corresponding data?!

You’ll need to specify type = "category" inside layout like so:

library(plotly)
library(zoo)

dts <- as.Date(c("2016-05-02", "2016-05-03", "2016-05-04", "2016-05-05", "2016-05-10", "2016-05-11"))
df <- data.frame(dts, y = sample(1:10, size = length(dts), replace = T))

plot_ly(df, x = dts, y = y, type = "bar") %>% 
  layout(xaxis = list(type = "category"))

2 Likes

Hello royr2, Thank you so much,
That works perfectly!
I had a found a big workaround by querying from mysql data by altering the format of datetime but this seems much more simpler.
Thanks again!