version 2024
This commit is contained in:
commit
34af57a4f3
4
README
Normal file
4
README
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Graphes de fréquentation des Ateliers
|
||||||
|
|
||||||
|
Les infos de paramétrage sont sur le wiki :
|
||||||
|
https://git.minesderayons.fr/oca/graphes-ateliers/wiki
|
15
Requete-date.sql
Normal file
15
Requete-date.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
SELECT act.date,
|
||||||
|
COALESCE(SUM(CASE WHEN 1 THEN 1 ELSE 0 END), 0) AS present,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.id_category = 4 THEN 0 ELSE 1 END), 0) AS benevole,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.membre_du_conseil_d_administration LIKE '%Salarié%' ESCAPE "\" THEN 1 ELSE 0 END), 0) AS salarie,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.genre = 'Femme' THEN 1 ELSE 0 END), 0) AS femme,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.genre = 'Homme' THEN 1 ELSE 0 END), 0) AS homme,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.qpv IS NOT NULL AND adh.qpv IS NOT 'Non' THEN 1 ELSE 0 END), 0) AS qpv,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.annee_naissance > (act.date - 18) THEN 1 ELSE 0 END), 0) AS dixhuit,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.annee_naissance < (act.date - 60) THEN 1 ELSE 0 END), 0) AS soixante
|
||||||
|
FROM users adh
|
||||||
|
JOIN services_users act
|
||||||
|
ON adh.id = act.id_user
|
||||||
|
WHERE act.id_service = 6
|
||||||
|
AND 2024 < act.date AND act.date < 2025
|
||||||
|
GROUP BY act.date;
|
15
Requete-id.sql
Normal file
15
Requete-id.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
SELECT adh.id,
|
||||||
|
COALESCE(SUM(CASE WHEN 1 THEN 1 ELSE 0 END), 0) AS present,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.id_category = 4 THEN 0 ELSE 1 END), 0) AS benevole,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.membre_du_conseil_d_administration LIKE '%Salarié%' ESCAPE "\" THEN 1 ELSE 0 END), 0) AS salarie,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.genre = 'Femme' THEN 1 ELSE 0 END), 0) AS femme,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.genre = 'Homme' THEN 1 ELSE 0 END), 0) AS homme,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.qpv IS NOT NULL AND adh.qpv IS NOT 'Non' THEN 1 ELSE 0 END), 0) AS qpv,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.annee_naissance > (act.date - 18) THEN 1 ELSE 0 END), 0) AS dixhuit,
|
||||||
|
COALESCE(SUM(CASE WHEN adh.annee_naissance < (act.date - 60) THEN 1 ELSE 0 END), 0) AS soixante
|
||||||
|
FROM users adh
|
||||||
|
JOIN services_users act
|
||||||
|
ON adh.id = act.id_user
|
||||||
|
WHERE act.id_service = 6
|
||||||
|
AND 2024 < act.date AND act.date < 2025
|
||||||
|
GROUP BY adh.id;
|
260
graphes.tex
Normal file
260
graphes.tex
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
\documentclass[convert={density=900,outext=.png}]{standalone}
|
||||||
|
\usepackage[defaultfam,tabular,lining]{montserrat} %% Option 'defaultfam'
|
||||||
|
\usepackage{mathastext}
|
||||||
|
\usepackage{pgfplots}
|
||||||
|
\usepackage{pgfplotstable}
|
||||||
|
\usepgfplotslibrary{dateplot}
|
||||||
|
\usepgfplotslibrary{fillbetween}
|
||||||
|
\usetikzlibrary{backgrounds}
|
||||||
|
\usetikzlibrary{matrix}
|
||||||
|
\usetikzlibrary{calc}
|
||||||
|
|
||||||
|
\standaloneenv{page}
|
||||||
|
|
||||||
|
|
||||||
|
\def\colorDefault{white}
|
||||||
|
|
||||||
|
\def\colorMineur{yellow}
|
||||||
|
\def\colorAdulte{brown}
|
||||||
|
\def\colorSenior{lightgray}
|
||||||
|
|
||||||
|
\def\colorHomme{blue}
|
||||||
|
\def\colorFemme{red}
|
||||||
|
\def\colorQ{white}
|
||||||
|
|
||||||
|
\def\colorQPV{orange}
|
||||||
|
|
||||||
|
\def\colorBenevole{teal}
|
||||||
|
|
||||||
|
|
||||||
|
\pgfplotstableread[row sep=newline, col sep=comma, ignore chars={"}]{export-date.csv}\bydate
|
||||||
|
|
||||||
|
\pgfplotstableread[row sep=newline, col sep=comma, ignore chars={"}]{export-id.csv}\byid
|
||||||
|
\pgfplotsforeachungrouped \colname in {present,homme,femme,soixante, dixhuit, qpv, benevole, salarie}{
|
||||||
|
\pgfplotstablecreatecol[
|
||||||
|
expr accum={
|
||||||
|
round(\pgfmathaccuma) + \thisrow{\colname}
|
||||||
|
}{0}
|
||||||
|
]{\colname-sum}{\byid}
|
||||||
|
\pgfplotstablecreatecol[
|
||||||
|
expr accum={
|
||||||
|
round(\pgfmathaccuma) + (\thisrow{\colname} ? 1 : 0)
|
||||||
|
}{0}
|
||||||
|
]{\colname-one}{\byid}
|
||||||
|
}
|
||||||
|
\pgfplotstablegetrowsof{\byid}
|
||||||
|
\pgfmathsetmacro{\LastRow}{\pgfplotsretval-1}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\begin{page}%
|
||||||
|
\begin{tikzpicture}[
|
||||||
|
every axis/.style={
|
||||||
|
clip=false,
|
||||||
|
scale only axis,
|
||||||
|
axis on top,
|
||||||
|
height = 27.7cm,
|
||||||
|
width = 3cm,
|
||||||
|
axis on top,
|
||||||
|
date coordinates in=y,
|
||||||
|
date ZERO=2024-01-01,
|
||||||
|
yticklabel=\empty,
|
||||||
|
ytick distance=7,
|
||||||
|
y dir=reverse,
|
||||||
|
xmin = 0,
|
||||||
|
xmax = 29,
|
||||||
|
y tick style = {draw=none},
|
||||||
|
ymin=2024-01-01,
|
||||||
|
ymax=2024-12-31,
|
||||||
|
xbar stacked,
|
||||||
|
bar width=5,
|
||||||
|
grid=major,
|
||||||
|
set layers,
|
||||||
|
axis line style={on layer=axis foreground},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
\begin{axis}[name=plot1]
|
||||||
|
\addplot [fill=\colorMineur, on layer= axis tick labels] table [y = date, x = dixhuit] {\bydate}; \label{plot:dixhuit}
|
||||||
|
\addplot [fill=\colorAdulte, on layer= axis tick labels] table [y = date, x expr = {\thisrow{present} - \thisrow{dixhuit} - \thisrow{soixante}}] {\bydate}; \label{plot:adulte}
|
||||||
|
\addplot [fill=\colorSenior, on layer= axis tick labels] table [y = date, x = soixante] {\bydate}; \label{plot:soixante}
|
||||||
|
|
||||||
|
\fill[blue!10, on layer= axis background] (axis cs: 0 , 2024-01-01) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-03-21) ;
|
||||||
|
\fill[green!30, on layer= axis background] (axis cs: 0 , 2024-03-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-06-21) ;
|
||||||
|
\fill[yellow!30, on layer= axis background] (axis cs: 0 , 2024-06-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-09-21) ;
|
||||||
|
\fill[orange!30, on layer= axis background] (axis cs: 0 , 2024-09-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-21) ;
|
||||||
|
\fill[blue!10, on layer= axis background] (axis cs: 0 , 2024-12-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-31) ;
|
||||||
|
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-01-01) -- node[below, midway, sloped] {janvier} (axis cs: 0 , 2024-02-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-02-01) -- node[below, midway, sloped] {février} (axis cs: 0 , 2024-03-01) ;
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-03-01) -- node[below, midway, sloped] {mars} (axis cs: 0 , 2024-04-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-04-01) -- node[below, midway, sloped] {avril} (axis cs: 0 , 2024-05-01) ;
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-05-01) -- node[below, midway, sloped] {mai} (axis cs: 0 , 2024-06-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-06-01) -- node[below, midway, sloped] {juin} (axis cs: 0 , 2024-07-01) ;
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-07-01) -- node[below, midway, sloped] {juillet} (axis cs: 0 , 2024-08-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-08-01) -- node[below, midway, sloped] {août} (axis cs: 0 , 2024-09-01) ;
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-09-01) -- node[below, midway, sloped] {septembre} (axis cs: 0 , 2024-10-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-10-01) -- node[below, midway, sloped] {octobre} (axis cs: 0 , 2024-11-01) ;
|
||||||
|
\draw[xshift=-1pt,line width=2pt] (axis cs: 0 , 2024-11-01) -- node[below, midway, sloped] {novembre} (axis cs: 0 , 2024-12-01) ;
|
||||||
|
\draw[draw=none] (axis cs: 0 , 2024-12-01) -- node[below, midway, sloped] {décembre} (axis cs: 0 , 2024-12-31) ;
|
||||||
|
\end{axis}%
|
||||||
|
\begin{axis}[
|
||||||
|
name=plot2,
|
||||||
|
at={($(plot1.east)$)},
|
||||||
|
anchor=west,
|
||||||
|
xlabel=Nombre de participants aux ateliers,
|
||||||
|
xlabel style = {yshift=1ex},
|
||||||
|
]
|
||||||
|
\addplot [fill=\colorHomme, on layer= axis tick labels] table [y = date, x = homme] {\bydate}; \label{plot:homme}
|
||||||
|
\addplot [fill=\colorQ, on layer= axis tick labels] table [y = date, x expr = {\thisrow{present} - \thisrow{femme} - \thisrow{homme}}] {\bydate}; \label{plot:q}
|
||||||
|
\addplot [fill=\colorFemme, on layer= axis tick labels] table [y = date, x = femme] {\bydate}; \label{plot:femme}
|
||||||
|
|
||||||
|
\fill[blue!05, on layer= axis background] (axis cs: 0 , 2024-01-01) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-03-21) ;
|
||||||
|
\fill[green!15, on layer= axis background] (axis cs: 0 , 2024-03-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-06-21) ;
|
||||||
|
\fill[yellow!15, on layer= axis background] (axis cs: 0 , 2024-06-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-09-21) ;
|
||||||
|
\fill[orange!15, on layer= axis background] (axis cs: 0 , 2024-09-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-21) ;
|
||||||
|
\fill[blue!05, on layer= axis background] (axis cs: 0 , 2024-12-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-31) ;
|
||||||
|
\end{axis}%
|
||||||
|
\begin{axis}[
|
||||||
|
name=plot3,
|
||||||
|
at={($(plot2.east)$)},
|
||||||
|
anchor=west,
|
||||||
|
]
|
||||||
|
\addplot [fill=\colorBenevole, on layer= axis tick labels] table [y = date, x expr = {\thisrow{benevole} + \thisrow{salarie}}] {\bydate}; \label{plot:benevole}
|
||||||
|
\addplot [fill=\colorDefault, on layer= axis tick labels] table [y = date, x expr = {\thisrow{present} - \thisrow{benevole} - \thisrow{salarie}}] {\bydate};
|
||||||
|
\addplot [fill=\colorQPV, on layer= axis descriptions, stack dir=minus,] table [y = date, x = qpv] {\bydate}; \label{plot:qpv}
|
||||||
|
|
||||||
|
|
||||||
|
\fill[blue!10, on layer= axis background] (axis cs: 0 , 2024-01-01) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-03-21) ;
|
||||||
|
\fill[green!30, on layer= axis background] (axis cs: 0 , 2024-03-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-06-21) ;
|
||||||
|
\fill[yellow!30, on layer= axis background] (axis cs: 0 , 2024-06-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-09-21) ;
|
||||||
|
\fill[orange!30, on layer= axis background] (axis cs: 0 , 2024-09-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-21) ;
|
||||||
|
\fill[blue!10, on layer= axis background] (axis cs: 0 , 2024-12-21) rectangle (axis cs: \pgfkeysvalueof{/pgfplots/xmax} , 2024-12-31) ;
|
||||||
|
\end{axis}%
|
||||||
|
\end{tikzpicture}%
|
||||||
|
\end{page}
|
||||||
|
\begin{page}%
|
||||||
|
\begin{tikzpicture}%
|
||||||
|
\matrix [
|
||||||
|
draw,
|
||||||
|
matrix of nodes,
|
||||||
|
node font=\small,
|
||||||
|
] at (0,0) {
|
||||||
|
\textbf{Âge} & & \hspace{1cm} & \textbf{Genre} & & \hspace{1cm} & \textbf{Participants} & \\
|
||||||
|
-18 ans & \ref{plot:dixhuit} & \hspace{1cm} & Homme & \ref{plot:homme} & \hspace{1cm} & Encadrants & \ref{plot:benevole} \\
|
||||||
|
18-59 ans & \ref{plot:adulte} & \hspace{1cm} & Femme & \ref{plot:femme} & \hspace{1cm} & Habitant & \\
|
||||||
|
+60 ans & \ref{plot:soixante} & \hspace{1cm} & & & \hspace{1cm} & d'un QPV & \ref{plot:qpv} \\
|
||||||
|
};%
|
||||||
|
\end{tikzpicture}%
|
||||||
|
\end{page}
|
||||||
|
\pgfplotsset{
|
||||||
|
compat=1.14,% <- current version is 1.14
|
||||||
|
}
|
||||||
|
\begin{page}%
|
||||||
|
\begin{tikzpicture}%
|
||||||
|
\pgfplotstablegetelem{\LastRow}{present-sum}\of{\byid}%
|
||||||
|
\pgfmathsetmacro{\sumpresent}{\pgfplotsretval}%
|
||||||
|
\begin{axis}[
|
||||||
|
width=10cm,
|
||||||
|
height=3cm,
|
||||||
|
scale only axis,
|
||||||
|
xbar stacked, nodes near coords,
|
||||||
|
nodes near coords style={/pgf/number format/.cd,fixed},
|
||||||
|
hide x axis,
|
||||||
|
hide y axis,
|
||||||
|
xmin=0,
|
||||||
|
xmax=\sumpresent,
|
||||||
|
ymin=0.5,
|
||||||
|
ymax=3.5,
|
||||||
|
y dir=reverse,
|
||||||
|
bar width=0.8cm,
|
||||||
|
title = {\pgfmathprintnumber{\sumpresent} participations au total},
|
||||||
|
]
|
||||||
|
\pgfplotstablegetelem{\LastRow}{dixhuit-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumdixhuit}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{soixante-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumsoixante}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorMineur] coordinates {(\sumdixhuit, 1)};
|
||||||
|
\addplot[fill=\colorAdulte] coordinates {(\sumpresent - \sumdixhuit - \sumsoixante, 1)};
|
||||||
|
\addplot[fill=\colorSenior] coordinates {(\sumsoixante, 1)};
|
||||||
|
|
||||||
|
\addplot[draw=none, point meta=explicit symbolic, stack dir=minus] coordinates {(\sumpresent, 1)};
|
||||||
|
|
||||||
|
\pgfplotstablegetelem{\LastRow}{homme-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumhomme}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{femme-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumfemme}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorHomme] coordinates {(\sumhomme, 2)};
|
||||||
|
\addplot[fill=\colorQ, point meta=explicit symbolic] coordinates {(\sumpresent - \sumfemme - \sumhomme, 2)};
|
||||||
|
\addplot[fill=\colorFemme] coordinates {(\sumfemme, 2)};
|
||||||
|
|
||||||
|
\addplot[draw=none, point meta=explicit symbolic, stack dir=minus] coordinates {(\sumpresent, 2)};
|
||||||
|
|
||||||
|
\pgfplotstablegetelem{\LastRow}{benevole-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumbenevole}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{qpv-sum}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\sumqpv}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorBenevole] coordinates {(\sumbenevole, 3)};
|
||||||
|
\addplot[fill=\colorDefault, point meta=explicit symbolic] coordinates {(\sumpresent - \sumbenevole - \sumqpv, 3)};
|
||||||
|
\addplot[fill=\colorQPV] coordinates {(\sumqpv, 3)};
|
||||||
|
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}%
|
||||||
|
\end{page}
|
||||||
|
\begin{page}%
|
||||||
|
\begin{tikzpicture}%
|
||||||
|
\pgfplotstablegetelem{\LastRow}{present-one}\of{\byid}%
|
||||||
|
\pgfmathsetmacro{\onepresent}{\pgfplotsretval}%
|
||||||
|
\begin{axis}[
|
||||||
|
width=10cm,
|
||||||
|
height=3cm,
|
||||||
|
scale only axis,
|
||||||
|
xbar stacked, nodes near coords,
|
||||||
|
nodes near coords style={/pgf/number format/.cd,fixed},
|
||||||
|
hide x axis,
|
||||||
|
hide y axis,
|
||||||
|
xmin=0,
|
||||||
|
xmax=\onepresent,
|
||||||
|
ymin=0.5,
|
||||||
|
ymax=3.5,
|
||||||
|
y dir=reverse,
|
||||||
|
bar width=0.8cm,
|
||||||
|
title = {\pgfmathprintnumber{\onepresent} participants uniques},
|
||||||
|
]
|
||||||
|
\pgfplotstablegetelem{\LastRow}{dixhuit-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\onedixhuit}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{soixante-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\onesoixante}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorMineur] coordinates {(\onedixhuit, 1)};
|
||||||
|
\addplot[fill=\colorAdulte] coordinates {(\onepresent - \onedixhuit - \onesoixante, 1)};
|
||||||
|
\addplot[fill=\colorSenior] coordinates {(\onesoixante, 1)};
|
||||||
|
|
||||||
|
\addplot[draw=none, point meta=explicit symbolic, stack dir=minus] coordinates {(\onepresent, 1)};
|
||||||
|
|
||||||
|
\pgfplotstablegetelem{\LastRow}{homme-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\onehomme}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{femme-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\onefemme}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorHomme] coordinates {(\onehomme, 2)};
|
||||||
|
\addplot[fill=\colorQ, point meta=explicit symbolic] coordinates {(\onepresent - \onefemme - \onehomme, 2)};
|
||||||
|
\addplot[fill=\colorFemme] coordinates {(\onefemme, 2)};
|
||||||
|
|
||||||
|
\addplot[draw=none, point meta=explicit symbolic, stack dir=minus] coordinates {(\onepresent, 2)};
|
||||||
|
|
||||||
|
\pgfplotstablegetelem{\LastRow}{benevole-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\onebenevole}{\pgfplotsretval}
|
||||||
|
\pgfplotstablegetelem{\LastRow}{qpv-one}\of{\byid}
|
||||||
|
\pgfmathsetmacro{\oneqpv}{\pgfplotsretval}
|
||||||
|
|
||||||
|
\addplot[fill=\colorBenevole] coordinates {(\onebenevole, 3)};
|
||||||
|
\addplot[fill=\colorDefault, point meta=explicit symbolic] coordinates {(\onepresent - \onebenevole - \oneqpv, 3)};
|
||||||
|
\addplot[fill=\colorQPV] coordinates {(\oneqpv, 3)};
|
||||||
|
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}%
|
||||||
|
\end{page}
|
||||||
|
\end{document}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user