diff --git a/R/report_mig_mult.R b/R/report_mig_mult.R index 671a02e129185c891ef18b7bb71915a3001c7a8e..23a731a89a315e50f991a4bc7cfbe7a4c6cfee86 100644 --- a/R/report_mig_mult.R +++ b/R/report_mig_mult.R @@ -566,7 +566,69 @@ setMethod("plot", signature(x = "report_mig_mult", y = "missing"), definition = funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retrieve the object")) } - # ==========================end / type=3============================= + # ==========================type=4============================= + if (plot.type == "time") { + grdata <- fun_date_extraction(data=report_mig_mult@data, # tableau de donnees e importer + nom_coldt = "ope_date_debut", # nom de la colonne + annee=TRUE, + mois=TRUE, + quinzaine=FALSE, + semaine=TRUE, + semaine_std=FALSE, + jour_an=FALSE, + jour_mois=TRUE, + heure=TRUE + ) + hhh <- grdata %>% group_by(heure, lot_tax_code, lot_std_code, ope_dic_identifiant) %>% summarize(N=sum(value)) + + if (length(unique(grdata$lot_tax_code)) == 1 & length(unique(grdata$lot_std_code)) == 1) { + p <- ggplot(hhh, aes(x = heure)) + + geom_histogram(aes(y=N), width = 0.6, colour = NA,stat="identity") + + coord_polar(start=3*pi/4) + + theme_minimal() + + ylab("Nombre")+ + facet_grid(ope_dic_identifiant ~ + ., scales = "free_y") + + } else if (length(unique(grdata$lot_tax_code)) == 1) { + p <- ggplot(hhh, aes(x = heure, fill=lot_std_code)) + + geom_histogram(aes(y=N), width = 0.6, colour = NA,stat="identity") + + coord_polar(start=3*pi/4) + + theme_minimal() + + ylab("Nombre")+ + facet_grid(ope_dic_identifiant ~ + ., scales = "free_y") + scale_fill_brewer(palette = "Set2") + + } else if (length(unique(grdata$lot_std_code)) == 1) { + p <- ggplot(hhh, aes(x = heure, fill=lot_tax_code)) + + geom_histogram(aes(y=N), width = 0.6, colour = NA,stat="identity") + + coord_polar(start=3*pi/4) + + theme_minimal() + + ylab("Nombre")+ + facet_grid(ope_dic_identifiant ~ + ., scales = "free_y") + scale_fill_brewer(palette = "Set2") + + } else { + p <- ggplot(hhh, aes(x = heure, fill=lot_std_code)) + + geom_histogram(aes(y=N), width = 0.6, colour = NA,stat="identity") + + coord_polar(start=3*pi/4) + + theme_minimal() + + ylab("Nombre")+ + facet_grid(cols=vars(hhh$ope_dic_identifiant) , rows=vars(hhh$lot_tax_code), scales = "free_y") + scale_fill_brewer(palette = "Set2") + # facet_grid(ope_dic_identifiant + lot_tax_code ~ + # ., scales = "free_y") + scale_fill_brewer(palette = "Set2") + } + + print(p) + assign("p_time", p, envir = envir_stacomi) + if (!silent) + funout(gettext("The plot has been assigned to p_multiple in envir_stacomi,write p<-get('pmultiple',envir_stacomi) to retrieve the object")) + assign("grdata", grdata, envir_stacomi) + if (!silent) + funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retrieve the object")) + + } + # ==========================end / type=4============================= return(invisible(NULL)) }) diff --git a/tests/testthat/test-01-report_mig_mult.R b/tests/testthat/test-01-report_mig_mult.R index e9706fefad8adc6d8508b7fb3645992139c24faf..a977d67433b2a4601db7b68d86b359dcf4821f6c 100644 --- a/tests/testthat/test-01-report_mig_mult.R +++ b/tests/testthat/test-01-report_mig_mult.R @@ -269,6 +269,7 @@ test_that("Test plot", expect_error(plot(report_mig_mult,plot.type="standard",silent=TRUE), NA) expect_error(plot(report_mig_mult,plot.type="step",silent=TRUE), NA) expect_error(plot(report_mig_mult,plot.type="multiple",silent=TRUE), NA) + expect_error(plot(report_mig_mult,plot.type="time",silent=TRUE), NA) rm(list = ls(envir = envir_stacomi), envir = envir_stacomi) })