Skip to content

Commit e8f0a8e

Browse files
author
Benoit Thieurmel
committed
some update on TP
1 parent 5d63aaf commit e8f0a8e

File tree

17 files changed

+99
-114
lines changed

17 files changed

+99
-114
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
library(shiny)
2-
library(rAmCharts)
2+
library(rAmCharts)
3+
library(colourpicker)
4+
5+
# chargement des fonctions
6+
7+
# chargement des donnees globales

TP/applications/app_graphiques_interactifs_correction/server.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
#
2-
# This is the server logic of a Shiny web application. You can run the
3-
# application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
9-
10-
111
# Define server logic required to draw a histogram
122
shinyServer(function(input, output) {
133

TP/applications/app_graphiques_interactifs_correction/ui.R

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
#
2-
# This is the user-interface definition of a Shiny web application. You can
3-
# run the application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
91

102

113
# Define UI for application that draws a histogram
124
shinyUI(
135
# navbarPage
14-
navbarPage("Old Faithful Geyser Data",
6+
navbarPage("Premiers pas avec shiny",
157

168
# premier onglet Data
179
tabPanel("Data",
@@ -37,8 +29,7 @@ shinyUI(
3729
value = 30),
3830

3931
# input pour la couleur
40-
selectInput(inputId = "color", label = "Couleur :",
41-
choices = c("Rouge" = "red", "Vert" = "green", "Bleu" = "blue")),
32+
colourInput(inputId = "color", label = "Couleur :", value = "purple"),
4233

4334
# titre du graphique
4435
textInput(inputId = "titre", label = "Titre :", value = "Histogramme"),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX

TP/applications/app_input_output_correction/server.R

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
#
2-
# This is the server logic of a Shiny web application. You can run the
3-
# application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
9-
101
library(shiny)
112

123
# Define server logic required to draw a histogram
@@ -38,4 +29,18 @@ shinyServer(function(input, output) {
3829
paste("Nombre de classes : ", input$bins)
3930
})
4031

32+
# telechargement du graphique
33+
output$download_plot <- downloadHandler(
34+
filename = function() {
35+
paste('plot-', Sys.Date(), '.jpeg', sep='')
36+
},
37+
content = function(con) {
38+
jpeg(file = con)
39+
x <- faithful[, input$var]
40+
bins <- seq(min(x), max(x), length.out = input$bins + 1)
41+
# draw the histogram with the specified number of bins
42+
hist(x, breaks = bins, col = input$color, border = 'white', main = input$titre)
43+
dev.off()
44+
}
45+
)
4146
})

TP/applications/app_input_output_correction/ui.R

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
#
2-
# This is the user-interface definition of a Shiny web application. You can
3-
# run the application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
9-
101
library(shiny)
2+
library(colourpicker)
113

124
# Define UI for application that draws a histogram
135
shinyUI(fluidPage(
146

157
# Application title
16-
titlePanel("Old Faithful Geyser Data"),
8+
titlePanel("Premiers pas avec shiny"),
179

1810
# Sidebar with a slider input for number of bins
1911
sidebarLayout(
@@ -25,14 +17,17 @@ shinyUI(fluidPage(
2517
value = 30),
2618

2719
# input pour la couleur
28-
selectInput(inputId = "color", label = "Couleur :",
29-
choices = c("Rouge" = "red", "Vert" = "green", "Bleu" = "blue")),
20+
colourInput(inputId = "color", label = "Couleur :", value = "purple"),
3021

3122
# titre du graphique
3223
textInput(inputId = "titre", label = "Titre :", value = "Histogramme"),
3324

3425
# selection de la colonne
35-
radioButtons(inputId = "var", label = "Variable : ", choices = colnames(faithful))
26+
radioButtons(inputId = "var", label = "Variable : ", choices = colnames(faithful)),
27+
28+
# bouton de telechargement du graphique
29+
downloadLink('download_plot', 'Télécharger le graphique')
30+
3631
),
3732

3833
# Show a plot of the generated distribution
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
library(shiny)
2-
library(rAmCharts)
2+
library(rAmCharts)
3+
library(colourpicker)
4+
5+
# chargement des fonctions
6+
7+
# chargement des donnees globales

TP/applications/app_plus_loin/server.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
#
2-
# This is the server logic of a Shiny web application. You can run the
3-
# application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
9-
10-
111
# Define server logic required to draw a histogram
122
shinyServer(function(input, output, session) {
133

TP/applications/app_plus_loin/ui.R

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
#
2-
# This is the user-interface definition of a Shiny web application. You can
3-
# run the application by clicking 'Run App' above.
4-
#
5-
# Find out more about building applications with Shiny here:
6-
#
7-
# http://shiny.rstudio.com/
8-
#
9-
10-
library(shiny)
111

122
# Define UI for application that draws a histogram
133
shinyUI(
144
# navbarPage
15-
navbarPage("Old Faithful Geyser Data",
5+
navbarPage("Premiers pas avec shiny",
6+
7+
# theme css
8+
theme = "css/bootstrap.min.css",
169

1710
# premier onglet Data
1811
tabPanel("Data",
@@ -42,8 +35,7 @@ shinyUI(
4235
value = 30),
4336

4437
# input pour la couleur
45-
selectInput(inputId = "color", label = "Couleur :",
46-
choices = c("Rouge" = "red", "Vert" = "green", "Bleu" = "blue")),
38+
colourInput(inputId = "color", label = "Couleur :", value = "purple"),
4739

4840
# titre du graphique
4941
textInput(inputId = "titre", label = "Titre :", value = "Histogramme"),

TP/applications/app_plus_loin/www/css/bootstrap.min.css

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)