giocomai / ganttrify

Create beautiful Gantt charts with ggplot2
https://ganttrify.europeandatajournalism.eu/
GNU General Public License v3.0
654 stars 61 forks source link

Wrong labels and colours when activities in different wp have the same name #10

Closed dvanic closed 7 months ago

dvanic commented 4 years ago

Hi! I'm having a very weird issue which I don't understand - ganttrify seems to be choosing weird lines to bold for my projects!

For example,

mydata <- data.frame(
  stringsAsFactors = FALSE,
  wp = c("Bayesian","Bayesian",
         "Bayesian","Machine","Machine",
         "Machine","BSDSSS","BSDSSS","BSDSSS","BSDSSS","BSDSSS",
         "BSDSSS","FMH","FMH","FMH","FMH",
         "FMH","Short"),
  activity = c("Summarise survey results",
               "Course development","Pilot",
               "Revise","Deliver R","Deliver python",
               "Review2","Begin",
               "Call out",
               "Support","Actual",
               "Review","Begin",
               "Call out 2","Support2",
               "Actual3","Review2",
               "Ongoing"),
  start_date = c("2020-08","2020-09","2020-12",
                 "2020-09","2020-11","2020-11","2020-10","2020-11",
                 "2020-12","2021-01","2021-02","2021-03","2020-09",
                 "2020-12","2020-12","2021-02","2021-03","2020-09"),
  end_date = c("2020-08","2020-11","2020-12",
               "2020-11","2020-11","2020-11","2020-10","2020-11",
               "2021-01","2021-02","2021-02","2021-03","2020-12",
               "2021-01","2021-01","2021-02","2021-03","2020-12"))

ganttrify(mydata,
          project_start_date = "2020-08",
          size_text_relative = 1.2, 
          by_date = TRUE,
          mark_quarters = TRUE,
          font_family = "Roboto Condensed")

Results in this

image

Whereas I was expecting the wp project labels to be bold?

What's going on and how do I fix this?

giocomai commented 4 years ago

I confirm this bug, which happens when activity names have the same name. I will fix it in a future version.

In the meantime, as a workaround, you may want to simply add a space before the name of the activities with the same name in one of the wp, or e.g. give a number to activities, so each of them will have a different name.

Again, this is obviously a bug, thanks for reporting, it will be fixed.

Here example with the workaround:

library("ganttrify")
mydata <- data.frame(
  stringsAsFactors = FALSE,
  wp = c("Bayesian","Bayesian",
         "Bayesian","Machine","Machine",
         "Machine","BSDSSS","BSDSSS","BSDSSS","BSDSSS","BSDSSS",
         "BSDSSS","FMH","FMH","FMH","FMH",
         "FMH","Short"),
  activity = c("Summarise survey results",
               "Course development","Pilot",
               "Revise","Deliver R","Deliver python",
               " Review2"," Begin",
               "Call out",
               "Support","Actual",
               "Review","Begin",
               "Call out 2","Support2",
               "Actual3","Review2",
               "Ongoing"),
  start_date = c("2020-08","2020-09","2020-12",
                 "2020-09","2020-11","2020-11","2020-10","2020-11",
                 "2020-12","2021-01","2021-02","2021-03","2020-09",
                 "2020-12","2020-12","2021-02","2021-03","2020-09"),
  end_date = c("2020-08","2020-11","2020-12",
               "2020-11","2020-11","2020-11","2020-10","2020-11",
               "2021-01","2021-02","2021-02","2021-03","2020-12",
               "2021-01","2021-01","2021-02","2021-03","2020-12"))

ganttrify(mydata,
          project_start_date = "2020-08",
          size_text_relative = 1.2, 
          by_date = TRUE,
          mark_quarters = TRUE,
          font_family = "Roboto Condensed")

Created on 2020-07-22 by the reprex package (v0.3.0)