Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce week-based projects #44

Open
giocomai opened this issue Jul 29, 2023 · 1 comment
Open

Introduce week-based projects #44

giocomai opened this issue Jul 29, 2023 · 1 comment

Comments

@giocomai
Copy link
Owner

There is currently not an easy way to show projects based on weeks, rather than months.

A consistent implementation requires some choices that may not be obvious, e.g. should the gray stripes in the background be then based on weeks rather than months? Probably.

Which dates should be shown on the x-axis? Probably the date in which each 7-day period starts.

Until a more consistent implementation will be introduced, here's a hacky workaround.

It requires providing as dates the start and end points of activities (a more consistent way would allow to pass week numbers).

library("ganttrify")
project <- ganttrify::test_project_date_day

# This is just to shorten a bit the example project
project$end_date[project$activity=="Active promo"] <- "2020-11-17"

base_gg <- ganttrify(project = project,
                     by_date = TRUE,
                     # colour_stripe = "lightgray",
                     colour_stripe = NA,
                     exact_date = TRUE) 

# break by weeks 
week_breaks <- seq.Date(from = min(lubridate::as_date(project$start_date)),
                        to = max(lubridate::as_date(project$end_date)),
                        by = 7)

base_gg +
  ggplot2::scale_x_date(name = "",
                        breaks = week_breaks,
                        date_labels = "%e %b\n%Y",
                        minor_breaks = NULL,
                        limits = c(min(lubridate::as_date(project$start_date)),
                                   max(lubridate::as_date(project$end_date))+3),
                        sec.axis = ggplot2::dup_axis(breaks = week_breaks+3.5,
                                                     labels = paste0("W", seq_along(week_breaks))))
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Warning: Removed 1 rows containing missing values (`geom_rect()`).

Created on 2023-07-29 with reprex v2.0.2

@kridsadakorn
Copy link

@giocomai Thank you so much this is very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants