0

I'm trying to make a gantt like chart in R with the code the below code, however when I use plotly the bars won't seem to show (if i hover with my mouse over it I do see the tooltip). I'm trying to use plotly as it gives the option of zooming in and out and shows the tooltips.

    ############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly");
libraryRequireInstall("scales")
libraryRequireInstall("htmlwidgets")
####################################################

################### Actual code ####################
dataset <- Values  

dataset$`Start Time` <- as.POSIXct(dataset$`Time_Move`,format="%Y-%m-%dT%H:%M:%OS", tz ="GMT")

dataset$`End Time`<- as.POSIXct(dataset$`end_move`,format="%Y-%m-%dT%H:%M:%OS", tz="GMT")

g =ggplot(Values ,aes(x=dataset$`Start Time`, y=dataset$`CHEID`, color= dataset$`HNDTYP`)) +
  geom_segment(aes(x=dataset$`Start Time`,xend=dataset$`End Time` ,yend=dataset$`CHEID`),size=15) +
  scale_colour_discrete(guide=guide_legend(override.aes=list(size=10))) +
  scale_x_datetime(breaks = date_breaks("2 hour"), labels=date_format("%m-%d %Hh"))+ 
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 1))   + 
  
  
  ggtitle("Time_Move and end_move") + xlab("Time") + ylab("Crane") + theme_bw();
####################################################

############# Create and save widget ###############

p = ggplotly(g);
internalSaveWidget(p, 'out.html');
####################################################

################ Reduce paddings ###################

ReadFullFileReplaceString('out.html', 'out.html', ',"padding":[0-9]*,', ',"padding":1,')
####################################################

result

what I want is this to show like this but then with the ability to zoom, does anyone has any ideas how I to solve this?

Kind regards,

Mars

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
mars00
  • 1
  • Please see [this](https://plotly.com/ggplot2/gantt/) or [this](https://plotly.com/r/gantt/). – ismirsehregal Jan 04 '22 at 10:53
  • It looks like you're fairly new to SO; welcome to the community! If you want great answers quickly, it's best to make your question reproducible. This includes sample code you've attempted, listing non-base R packages, any errors/warnings received, sample data (e.g., `data.frame(x=...,y=...)`, like the output from `dput(head(dataObject)))`, and what type of output you are expecting. Check out these resources for great questions: [making R questions reproducible](https://stackoverflow.com/q/5963269) and [tagging questions](https://stackoverflow.com/tags/r/info). – Kat Jan 20 '22 at 19:37

0 Answers0