Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dataviz_gitlabr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DREAL Pays de la Loire
Centre de Services de la Donnée
dataviz_gitlabr
Commits
c910aaa2
Commit
c910aaa2
authored
9 months ago
by
LE DURAND Matteo
Browse files
Options
Downloads
Patches
Plain Diff
changement de reactiv() a reactiveValue() + observeEvent()
parent
48821ad6
Branches
Branches containing commit
No related tags found
2 merge requests
!25
changement de reactiv() a reactiveValue() + observeEvent()
,
!18
MAJ de main de la branche dev
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.R
+44
-38
44 additions, 38 deletions
server.R
with
44 additions
and
38 deletions
server.R
+
44
−
38
View file @
c910aaa2
server
<-
function
(
input
,
output
)
{
filteredData
<-
reactive
({
req
(
input
$
daterange
)
all_data
%>%
filter
(
updated_at
>=
as.Date
(
input
$
daterange
[[
1
]])
&
updated_at
<=
as.Date
(
input
$
daterange
[[
2
]]))
})
observeEvent
(
input
$
daterange
,{
updateSelectizeInput
(
inputId
=
"idprojet"
,
label
=
"Projet : "
,
choices
=
unique
(
filteredData
()
$
project_name
))
r
<-
reactiveValues
(
filteredData
=
NULL
,
filteredData2
=
NULL
)
# Daterange ----
observeEvent
(
input
$
daterange
,
{
req
(
input
$
daterange
)
r
$
filteredData
<-
all_data
%>%
filter
(
updated_at
>=
as.Date
(
input
$
daterange
[[
1
]])
&
updated_at
<=
as.Date
(
input
$
daterange
[[
2
]]))
updateSelectizeInput
(
inputId
=
"idprojet"
,
label
=
"Projet : "
,
choices
=
unique
(
r
$
filteredData
$
project_name
)
)
})
#----↑Observe Daterange
observeEvent
(
input
$
idprojet
,{
output
$
lien
<-
renderUI
({
# Générer une liste d'URLs basée sur input$idprojet
urls
<-
paste0
(
"https://gitlab-forge.din.developpement-durable.gouv.fr/dreal-pdl/csd/"
,
input
$
idprojet
)
# Créer une liste de balises <a> pour chaque lien
urls
<-
paste0
(
"https://gitlab-forge.din.developpement-durable.gouv.fr/dreal-pdl/csd/"
,
input
$
idprojet
)
# Générer une liste d'URLs basée sur input$idprojet
links
<-
lapply
(
seq_along
(
input
$
idprojet
),
function
(
i
)
{
a
(
href
=
urls
[
i
],
target
=
"_blank"
,
input
$
idprojet
[
i
])
})
}
)
# Créer une liste de balises <a> pour chaque lien
do.call
(
tagList
,
c
(
links
,
list
(
br
())))
# Retourner les liens avec un saut de ligne après chacun
})
r
$
filteredData2
<-
r
$
filteredData
%>%
dplyr
::
filter
(
project_name
%in%
input
$
idprojet
)
#2eme graph
output
$
filteredPlot2
<-
plotly
::
renderPlotly
({
req
(
input
$
idprojet
,
cancelOutput
=
TRUE
)
p
<-
ggplot2
::
ggplot
(
r
$
filteredData2
,
ggplot2
::
aes
(
x
=
updated_at
,
y
=
as.factor
(
project_name
)))
+
ggplot2
::
geom_jitter
(
ggplot2
::
aes
(
color
=
type
,
text
=
paste
(
updated_at
,
message
,
sep
=
"\n"
)),
size
=
3
,
alpha
=
0.5
,
height
=
0
,
width
=
0.75
)
+
ggplot2
::
labs
(
shape
=
"Type"
,
color
=
"Type"
,
x
=
""
)
+
ggplot2
::
scale_x_datetime
(
date_labels
=
"%d/%m"
,
timezone
=
"Europe/Paris"
)
+
gouvdown
::
theme_gouv
()
+
ggplot2
::
theme
(
axis.text.x
=
ggplot2
::
element_text
(
angle
=
0
,
hjust
=
1
),
axis.title.y
=
ggplot2
::
element_blank
()
)
+
gouvdown
::
scale_color_gouv_discrete
(
palette
=
"pal_gouv_qual2"
)
# Retourner les liens avec un saut de ligne après chacun
do.call
(
tagList
,
c
(
links
,
list
(
br
())))
plotly
::
ggplotly
(
p
,
tooltip
=
"text"
)
})
})
filteredData2
<-
reactive
({
req
(
input
$
idprojet
)
filteredData
()
%>%
dplyr
::
filter
(
project_name
%in%
input
$
idprojet
)
})
})
#----↑Observe idprojet----↑↑↑↑↑↑
output
$
filteredPlot
<-
plotly
::
renderPlotly
({
p
<-
ggplot2
::
ggplot
(
filteredData
(),
ggplot2
::
aes
(
x
=
updated_at
,
y
=
as.factor
(
project_name
)))
+
req
(
input
$
daterange
)
p
<-
ggplot2
::
ggplot
(
r
$
filteredData
,
ggplot2
::
aes
(
x
=
updated_at
,
y
=
as.factor
(
project_name
)))
+
ggplot2
::
geom_jitter
(
ggplot2
::
aes
(
color
=
type
,
text
=
paste
(
updated_at
,
message
,
sep
=
"\n"
)),
size
=
3
,
alpha
=
0.5
,
height
=
0
,
width
=
0.75
...
...
@@ -47,23 +70,6 @@
plotly
::
ggplotly
(
p
,
tooltip
=
"text"
)
})
#2eme graph
output
$
filteredPlot2
<-
plotly
::
renderPlotly
({
p
<-
ggplot2
::
ggplot
(
filteredData2
(),
ggplot2
::
aes
(
x
=
updated_at
,
y
=
as.factor
(
project_name
)))
+
ggplot2
::
geom_jitter
(
ggplot2
::
aes
(
color
=
type
,
text
=
paste
(
updated_at
,
message
,
sep
=
"\n"
)),
size
=
3
,
alpha
=
0.5
,
height
=
0
,
width
=
0.75
)
+
ggplot2
::
labs
(
shape
=
"Type"
,
color
=
"Type"
,
x
=
""
)
+
ggplot2
::
scale_x_datetime
(
date_labels
=
"%d/%m"
,
timezone
=
"Europe/Paris"
)
+
gouvdown
::
theme_gouv
()
+
ggplot2
::
theme
(
axis.text.x
=
ggplot2
::
element_text
(
angle
=
0
,
hjust
=
1
),
axis.title.y
=
ggplot2
::
element_blank
()
)
+
gouvdown
::
scale_color_gouv_discrete
(
palette
=
"pal_gouv_qual2"
)
plotly
::
ggplotly
(
p
,
tooltip
=
"text"
)
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment