diff --git a/DESCRIPTION b/DESCRIPTION index f80fee72474dbbeeeefa529aa676dfdb35e302e1..8e78050f3d139d99073a5609bfadbe280237a8a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,4 +44,4 @@ Remotes: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index c6813839b41165df385a93259b2a8c1493317d51..a1b45a6aaf6b03e9a43728911625e3a9b5a52f8c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -45,6 +45,7 @@ importFrom(ggplot2,aes) importFrom(ggplot2,coord_flip) importFrom(ggplot2,coord_sf) importFrom(ggplot2,element_blank) +importFrom(ggplot2,element_line) importFrom(ggplot2,element_rect) importFrom(ggplot2,element_text) importFrom(ggplot2,facet_wrap) diff --git a/R/creer_chiffres_clefs.R b/R/creer_chiffres_clefs.R index e81d5458f6bf22f9a75c3df5cfd57a2aa8168537..6d471508571f78fdedb0307dff87a2e9ea0f0d60 100644 --- a/R/creer_chiffres_clefs.R +++ b/R/creer_chiffres_clefs.R @@ -13,7 +13,26 @@ en_trimestre <- function(date) { lubridate::month(date) <= 12 ~ "4\u00e8me" ) return( - paste(trim, "trimestre", lubridate::year(date)) + paste(trim, "trimestre de", lubridate::year(date)) + ) +} + +#' Converti une date en trimestre annee moins un +#' +#' @param date une date +#' +#' @return une chaine de caractère +#' @importFrom dplyr case_when +#' @importFrom lubridate month year +en_trimestre_moins_un <- function(date) { + trim <- dplyr::case_when( + lubridate::month(date) <= 3 ~ "1er", + lubridate::month(date) <= 6 ~ "2\u00e8me", + lubridate::month(date) <= 9 ~ "3\u00e8me", + lubridate::month(date) <= 12 ~ "4\u00e8me" + ) + return( + paste(trim, "trimestre de", lubridate::year(date)-1) ) } @@ -98,10 +117,11 @@ creer_chiffres_clefs_ecln <- function(data = indic_ecln, ) val <- list( periode = en_trimestre(df$Periode), + periode_moins_un = en_trimestre_moins_un(df$Periode), valeur = format_fr_nb(df$Valeur, dec = 0), evolution = format_fr_pct(df$TauxEvolution12Mois, dec = 1) ) - res <- glue::glue("{drealdown::my_icon('la-building', size=2)} <b>{val$valeur}</b> {texte_log} au {val$periode}<br> - {drealdown::my_icon('la-line-chart', size=2)} <b>{val$evolution}</b> sur un an") + res <- glue::glue("{drealdown::my_icon('la-building', size=2)} <b>{val$valeur}</b> {texte_log} au cours du {val$periode}<br> + {drealdown::my_icon('la-line-chart', size=2)} <b>{val$evolution}</b> par rapport au {val$periode_moins_un}") return(res) } diff --git a/R/creer_graphique_evolution_trim.R b/R/creer_graphique_evolution_trim.R index 7eb722a0bccdeeb932c75faaa7f90cdd16d0d891..3b5f0b4773d56338c855bc50ee9f723275f2c3f6 100644 --- a/R/creer_graphique_evolution_trim.R +++ b/R/creer_graphique_evolution_trim.R @@ -10,7 +10,7 @@ #' @importFrom dplyr select distinct pull filter mutate #' @importFrom forcats fct_recode #' @importFrom ggforce geom_mark_circle -#' @importFrom ggplot2 ggplot aes geom_line geom_point margin theme labs guides scale_y_continuous scale_x_date element_text +#' @importFrom ggplot2 ggplot aes geom_line geom_point margin theme labs guides scale_y_continuous scale_x_date element_text element_line #' @importFrom glue glue #' @importFrom gouvdown gouv_colors scale_color_gouv_discrete scale_fill_gouv_discrete #' @importFrom grid unit @@ -84,7 +84,7 @@ creer_graphique_evolution_trim <- function(data = indic_ecln, ) %>% ggplot2::ggplot() + ggplot2::aes(x = .data$Periode, y = .data$Valeur, group = .data$TypeIndicateur, linetype = .data$TypeIndicateur, color = .data$TypeIndicateur) + - ggplot2::geom_line() + + ggplot2::geom_line(size = 1.2) + ggplot2::geom_point(data = label, ggplot2::aes(x = .data$Periode, y = .data$Valeur, group = .data$TypeIndicateur, color = .data$TypeIndicateur)) + ggforce::geom_mark_circle( data = label, ggplot2::aes( @@ -93,17 +93,19 @@ creer_graphique_evolution_trim <- function(data = indic_ecln, description = .data$description ), label.buffer = grid::unit(5, "mm"), #longueur du trait - expand = grid::unit(2, "mm"), + expand = grid::unit(0, "mm"), #diametre du cercle sur le dernier point. 0 on le supprime label.margin = ggplot2::margin(2, 5, 2, 5, "mm"), #marges autour du texte (haut, gauche, bas, droite) - # label.colour = "white", #couleur du texte + # label.colour = c("red", "blue"), #couleur du texte label.fontsize = 9, label.colour = gouvdown::gouv_colors("bleu_france"), - alpha = 0.5, #transparence du cercle + # alpha = 0.5, #transparence du cercle label.fill = NA # label.fill = gouvdown::gouv_colors("bleu_france") #couleur de la boite d'annotation ) + ggplot2::theme(legend.position = "bottom", - legend.title = element_blank()) + + legend.title = element_blank(), + axis.line = element_line(colour = "black", + size = 0.5, linetype = "solid")) + gouvdown::scale_color_gouv_discrete(palette = "pal_gouv_qual2") + gouvdown::scale_fill_gouv_discrete(palette = "pal_gouv_qual2") + ggplot2::labs( @@ -111,7 +113,7 @@ creer_graphique_evolution_trim <- function(data = indic_ecln, y = "Nombre de ventes", title = titre, subtitle = sous_titre, - caption = "Source : ECLN - SDES\nMoyenne annuelle : Valeur observ\u00e9e en moyenne sur les 4 derniers trimestres" + caption = "Source : ECLN - SDES\nMoyenne annuelle : valeur observ\u00e9e en moyenne sur les 4 derniers trimestres" ) + ggplot2::theme(plot.caption = element_text(size = 10))+ ggplot2::guides(fill = F) + diff --git a/R/creer_graphique_series_temporelles_prix.R b/R/creer_graphique_series_temporelles_prix.R index f259de931b16edd0178a14c828ab7d804096149d..d3b3f3726e871c9fb6d3df9186b756c7a09d0531 100644 --- a/R/creer_graphique_series_temporelles_prix.R +++ b/R/creer_graphique_series_temporelles_prix.R @@ -13,7 +13,7 @@ #' @export #' @importFrom dplyr filter mutate #' @importFrom forcats fct_drop -#' @importFrom ggplot2 ggplot aes geom_line geom_point theme scale_x_date scale_y_continuous labs facet_wrap +#' @importFrom ggplot2 ggplot aes geom_line geom_point theme scale_x_date scale_y_continuous labs facet_wrap element_line #' @importFrom scales dollar_format #' @importFrom stringr str_split_fixed #' @importFrom gouvdown scale_color_gouv_discrete @@ -63,7 +63,9 @@ creer_graphique_series_temporelles_prix <- function(data = indic_ecln, .data$TypeZone %in% type_zone, .data$Periode == max(.data$Periode) )) + - ggplot2::theme(legend.position = "none") + + ggplot2::theme(legend.position = "none", + axis.line = element_line(colour = "black", + size = 0.5, linetype = "solid")) + ggplot2::scale_x_date(date_labels = "%y", date_breaks = "1 year") + ggplot2::scale_y_continuous(labels = scales::dollar_format(big.mark = " ", decimal_mark = ",", prefix = "", suffix = " \u20ac")) + gouvdown::scale_color_gouv_discrete(palette = "pal_gouv_qual2") + diff --git a/dev/config_attachment.yaml b/dev/config_attachment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46e24ecc2173ddbd6d930225a01bb92e508508d5 --- /dev/null +++ b/dev/config_attachment.yaml @@ -0,0 +1,12 @@ +path.n: NAMESPACE +path.d: DESCRIPTION +dir.r: R +dir.v: vignettes +dir.t: tests +extra.suggests: ~ +pkg_ignore: ~ +document: yes +normalize: yes +inside_rmd: no +must.exist: yes +check_if_suggests_is_installed: yes diff --git a/inst/rmarkdown/templates/ecln_conjoncture/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/ecln_conjoncture/skeleton/skeleton.Rmd index 2f966306e362db57365dbafeb19206f531977c53..dd36a64c1a2b3205f4233c0d29dfb44f607d24dc 100644 --- a/inst/rmarkdown/templates/ecln_conjoncture/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/ecln_conjoncture/skeleton/skeleton.Rmd @@ -6,8 +6,8 @@ params: abc: FALSE title: "La commercialisation des logements neufs en `r mapfactory::get_nom_reg(params$region)`" subtitle: <h1>`r params$trimestre``r ifelse(params$trimestre == "1","<sup>er</sup>","<sup>e</sup>")` trimestre de `r params$annee`</h1> -author: "Denis Douillard - Dreal Pays de la Loire" -date: "`r Sys.Date()`" +author: "[**Denis DOUILLARD - DREAL des Pays de la Loire**](mailto:statistiques.dreal-pdl@developpement-durable.gouv.fr)" +date: "Dernière mise à jour : `r format(Sys.Date(),'%d %B %Y')`" output: gouvdown::html_gouv: toc: TRUE @@ -27,6 +27,11 @@ knitr::opts_chunk$set( width = 100 ) library(propre.ecln) +library(extrafont) +font_import(pattern = "Marianne", prompt = TRUE) +loadfonts(device = "win") +myFont <- "Marianne" +windowsFonts(sans = myFont) nom_region <- COGiter::regions %>% dplyr::filter (.data$REG == params$region) %>% @@ -72,7 +77,7 @@ indic_ecln <- data_prep( ## 1 - Les logements (maisons et appartements) -### 1.1 - Les ventes de logements neufs +### 1.1 - Les ventes <div class = "row"> @@ -181,7 +186,7 @@ creer_carte_evolution(data=indic_ecln, ## 2 - Les appartements -### 2.1 - Les ventes d'appartements +### 2.1 - Les ventes <div class = "row"> @@ -301,7 +306,7 @@ creer_carte_evolution(data=indic_ecln, ## 3 - Les maisons -### 3.1 - Les ventes de maisons +### 3.1 - Les ventes <div class = "row"> diff --git a/man/en_trimestre_moins_un.Rd b/man/en_trimestre_moins_un.Rd new file mode 100644 index 0000000000000000000000000000000000000000..4ba89d6fc464490a6ffc642b0184590a0db63655 --- /dev/null +++ b/man/en_trimestre_moins_un.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/creer_chiffres_clefs.R +\name{en_trimestre_moins_un} +\alias{en_trimestre_moins_un} +\title{Converti une date en trimestre annee moins un} +\usage{ +en_trimestre_moins_un(date) +} +\arguments{ +\item{date}{une date} +} +\value{ +une chaine de caractère +} +\description{ +Converti une date en trimestre annee moins un +} diff --git a/man/indic_ecln.Rd b/man/indic_ecln.Rd index 3a095584ef7de95373e076c393f8858aeececd19..1b1b57b85bc51e268db1bfc916a3b7f758d0e6f4 100644 --- a/man/indic_ecln.Rd +++ b/man/indic_ecln.Rd @@ -6,7 +6,7 @@ \alias{indic_ecln} \title{Table contenant les différents indicateurs de la source ecln utiles pour la publication.} \format{ -Table de 96720 lignes et 10 colonnes: +Table de 2450674 lignes et 9 colonnes: \describe{ \item{TypeZone}{Type de territoire} \item{CodeZone}{Code du territoire}