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

Ability to add more layers to the ggplot output #5

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

hugomflavio
Copy link

Hi!

I have played with the code a bit more, and I thought perhaps you would appreciate having a look at the changes I made. I was mainly looking for a way to be able to add points, but adding a geom_point call to the output of ganttrify was returning errors. I re-based my fork with the latest commits, so it should be up to date.

Summary of the changes:

  • commit a8f4e8c was fixed by yourself in the master repo, so I rolled it back with fa3e552
  • added a 'line_end' argument so users can decide how the edges of the activities look like.
  • Moved code lines 73-81 to a previously empty if (exact_date) call in lines 62-70. I did this because it seems to me that exact_date = TRUE only makes sense if use_date = TRUE, but I may be wrong.
  • Moved the code in lines 111-115 to a separate function (gantt_levels), so the user can easily obtain a copy of the y axis order (if needed for adding layers on top of the ganttrify output).
  • created a size column in df_yearmon_fct (which is filled with the values listed in arguments size_wp and size_activity, to avoid having to call geom_segment twice in lines 157-166.
  • moved the 'xend', 'yend' and 'colour' aes definitions from main ggplot call to the geom_segment call. This allows the user to add layers without needing to replicate these columns. This also means that some columns in the remaining data frames were no longer needed (see deleted lines 203-205 and 219-221).
  • created a new gantt_points function (needs a data frame with columns activity and date) that can be used on top of ganttrify to add points to the plot (see example in the function documentation).

Note: I am only using ganttrify with by_date = TRUE and exact_date = TRUE and didn't test all options thoroughly. But I did try running gantt_points() on the default example code and it also worked, so it should be fine.

Hope you find at least some of these relevant.

@giocomai
Copy link
Owner

Thanks for this thoughtful pull request! I'll set up some tests and check if everything works smoothly with different parameters. However, I'll probably get back to this only at some point later in July. Just out of curiosity, when you refer to additional layers, do you have in mind something specific? If it's a reasonably common use case, I may consider facilitating this directly from the package

@hugomflavio
Copy link
Author

I was mainly looking for a way to add points at specific places, which is why I created that gantt_points() function (6f7b6ed). This could be useful to highlight different kinds of repetitive point-tasks are not really worth a label. In my very specific case, I wanted to be able to see when data had been retrieved for receivers that were deployed over a certain period (these deployments being the "activities"). e.g:

In a more general sense, because I transferred the 'xend', 'yend' and 'colour' aes definitions from the main ggplot call to the geom_segment call (see 0e20208), it should now be easy to add any other layer on top of the ganttrify output (such as text, rectangles, etc) using the native ggplot2 functions and simply specifying an 'x' and 'y' aes.

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

Successfully merging this pull request may close these issues.

2 participants