vistime
vistime copied to clipboard
Add days after a date in the x-axis
Hi! I need to create a timeline that shows the number of days after the start and not specific days in the x-axis. Is there a way of doing it? Thanks in advance Best regards
I can't imagine what the result would look like, could you draw a picture or sketch?
It would look like any gantt chart, when you do not know yet when something will happen in time, just the order of events and number of days of each task:
https://images.app.goo.gl/SKx5D6EMuJedi4dP7
The screenshot behind your link does show projects in the y-axis, not days, so kindly specify what you have tried and what is failing, thanks :)
The image says on the x-axis: “days of the month”. I wish to add numbers of days and not specific dates. Your package right now gives back an error and requested that the start and the end to be in a date format.
I want to add to the timeline: this project should start on day 6 and go until day 10 after the start of the project (that I don’t know when it will be). But without a month or year.
The image is of what I want to do and not an output of your package... Sorry, I thought that was clear
So you are talking about the x-axis, not the y axis and already have tried something in code - please post this code as a starting point. The solution will be to convert your integer days into dates by using as.Date(2000-01-01) + your_days_vector
.
I do not want it to show up like dates, so I don’t want to transform it do date. I just would like that the package does not require the input to be in a date format. This way the package could be applied in different contexts. But I will look for another solution in another package.
The code I am using is the example you give in the documentation.
Thanks for the attention
So you are talking about the x-axis, not the y axis and already have tried something in code - please post this code as a starting point. The solution will be to convert your integer days into dates by using
as.Date(2000-01-01) + your_days_vector
.
Thanks... indeed I am using it in x-axis, and I corrected it on the question. But it could actually be a nice idea to be able to flip the visualization.
I used my suggestions and formatted the x-axis accordingly:
data <- read.csv(text="event,start,end
Phase 1,1,10
Phase 2,8,15", stringsAsFactors=FALSE)
data$start <- as.Date("2000-01-01") + data$start - 1
data$end <- as.Date("2000-01-01") + data$end - 1
gg_vistime(data) +
scale_x_datetime(breaks = seq(min(as.POSIXct(data$start)),
max(as.POSIXct(data$end)),
"days"),
date_labels = "%d") +
xlab("Day")