Ubuntu commited on
Commit
acf17b0
1 Parent(s): 724b797

feat: added waiter and turned ggplot into plotly

Browse files
app/main.R CHANGED
@@ -1,8 +1,9 @@
1
  box::use(
2
- shiny[tagList, div, reactive, moduleServer, observeEvent, NS, renderUI, tags, uiOutput, numericInput],
3
  bslib[page_sidebar, nav_panel, navset_tab],
4
  data.table[fread],
5
  shinyWidgets[pickerInput, materialSwitch],
 
6
  shinyjs[hidden, disable, enable, useShinyjs]
7
  )
8
 
@@ -17,6 +18,7 @@ box::use(
17
  ui <- function(id) {
18
  ns <- NS(id)
19
  page_sidebar(
 
20
  useShinyjs(),
21
  title = "New York bridges analysis",
22
  sidebar = my_sidebar(ns),
@@ -41,6 +43,9 @@ server <- function(id) {
41
  data <- reactive({fread("data/bike_data_filtered_long.csv")})
42
 
43
  recompute_trigger <- reactive({
 
 
 
44
  list(input$data_group_input, input$prior_a_input, input$prior_b_input, input$jeffreys_prior)
45
  })
46
 
 
1
  box::use(
2
+ shiny[tagList, div, req, reactive, moduleServer, observeEvent, NS, renderUI, tags, uiOutput, numericInput],
3
  bslib[page_sidebar, nav_panel, navset_tab],
4
  data.table[fread],
5
  shinyWidgets[pickerInput, materialSwitch],
6
+ waiter[useWaiter],
7
  shinyjs[hidden, disable, enable, useShinyjs]
8
  )
9
 
 
18
  ui <- function(id) {
19
  ns <- NS(id)
20
  page_sidebar(
21
+ useWaiter(),
22
  useShinyjs(),
23
  title = "New York bridges analysis",
24
  sidebar = my_sidebar(ns),
 
43
  data <- reactive({fread("data/bike_data_filtered_long.csv")})
44
 
45
  recompute_trigger <- reactive({
46
+ req(input$data_group_input)
47
+ req(input$prior_a_input)
48
+ req(input$prior_b_input)
49
  list(input$data_group_input, input$prior_a_input, input$prior_b_input, input$jeffreys_prior)
50
  })
51
 
app/view/mod_poisson_model.R CHANGED
@@ -1,9 +1,12 @@
1
  box::use(
2
- shiny[observeEvent, tagList, numericInput, reactiveVal, moduleServer, actionButton, reactive, req, NS, plotOutput, renderPlot],
3
  bslib[layout_column_wrap, layout_sidebar, sidebar, card, card_header],
4
  dplyr[bind_rows, filter],
5
  data.table[setnames],
6
  reactable[reactableOutput, reactable, renderReactable, colDef, colFormat, reactableTheme],
 
 
 
7
  )
8
 
9
 
@@ -19,6 +22,7 @@ box::use(
19
  ]
20
  )
21
 
 
22
  #' @export
23
  ui <- function(id) {
24
  ns <- NS(id)
@@ -116,6 +120,9 @@ server <- function(id, data, prior_a, prior_b, is_jeffreys) {
116
 
117
  observeEvent(recompute_prior_trigger(), {
118
  req(data())
 
 
 
119
  prior_tab_dry <- get_poisson_prior_tab(input$theta_start, input$theta_end, prior_a, prior_b, 0.1, "Dry prior", is_jeffreys)
120
  prior_tab_rainy <- get_poisson_prior_tab(input$theta_start, input$theta_end, prior_a, prior_b, 0.1, "Rainy prior", is_jeffreys)
121
 
@@ -144,9 +151,11 @@ server <- function(id, data, prior_a, prior_b, is_jeffreys) {
144
  full_tab <- bind_rows(prior, posterior, likelihood)
145
 
146
  full_dist_tab(full_tab)
147
- distribution_plot(get_distribution_plot(full_dist_tab(), input$linewidth_dist))
148
  characteristics_reactable(compute_characteristics(prior_a, prior_b, n_dry, y_dry, posterior_tab_dry, n_wet, y_wet, posterior_tab_rainy))
149
  #sensitivity_plot(get_poisson_sensitivity_plot(prior_a, prior_b, n, y))
 
 
150
  })
151
 
152
  observeEvent(input$btn_redraw_sensitivity, {
@@ -171,7 +180,7 @@ server <- function(id, data, prior_a, prior_b, is_jeffreys) {
171
  })
172
 
173
 
174
- output$distribution_plot <- renderPlot({
175
  req(distribution_plot())
176
  distribution_plot()
177
  })
@@ -242,7 +251,7 @@ plot_card <- function(header, plot_id, settings = NULL, btn_id = NULL, btn_label
242
  settings,
243
  actionButton(btn_id, btn_label),
244
  ),
245
- plotOutput(plot_id)
246
  )
247
  )
248
  }
 
1
  box::use(
2
+ shiny[observeEvent, tagList, div, h3, numericInput, reactiveVal, moduleServer, actionButton, reactive, req, NS, plotOutput, renderPlot],
3
  bslib[layout_column_wrap, layout_sidebar, sidebar, card, card_header],
4
  dplyr[bind_rows, filter],
5
  data.table[setnames],
6
  reactable[reactableOutput, reactable, renderReactable, colDef, colFormat, reactableTheme],
7
+ plotly[ggplotly, plotlyOutput, renderPlotly],
8
+ waiter[Waiter, spin_fading_circles]
9
+
10
  )
11
 
12
 
 
22
  ]
23
  )
24
 
25
+
26
  #' @export
27
  ui <- function(id) {
28
  ns <- NS(id)
 
120
 
121
  observeEvent(recompute_prior_trigger(), {
122
  req(data())
123
+ waiter <- Waiter$new(html = tagList(div(class = "main-waiter", h3("Computing..."), spin_fading_circles())))
124
+ waiter$show()
125
+
126
  prior_tab_dry <- get_poisson_prior_tab(input$theta_start, input$theta_end, prior_a, prior_b, 0.1, "Dry prior", is_jeffreys)
127
  prior_tab_rainy <- get_poisson_prior_tab(input$theta_start, input$theta_end, prior_a, prior_b, 0.1, "Rainy prior", is_jeffreys)
128
 
 
151
  full_tab <- bind_rows(prior, posterior, likelihood)
152
 
153
  full_dist_tab(full_tab)
154
+ distribution_plot(ggplotly(get_distribution_plot(full_dist_tab(), input$linewidth_dist)))
155
  characteristics_reactable(compute_characteristics(prior_a, prior_b, n_dry, y_dry, posterior_tab_dry, n_wet, y_wet, posterior_tab_rainy))
156
  #sensitivity_plot(get_poisson_sensitivity_plot(prior_a, prior_b, n, y))
157
+ waiter$hide()
158
+
159
  })
160
 
161
  observeEvent(input$btn_redraw_sensitivity, {
 
180
  })
181
 
182
 
183
+ output$distribution_plot <- renderPlotly({
184
  req(distribution_plot())
185
  distribution_plot()
186
  })
 
251
  settings,
252
  actionButton(btn_id, btn_label),
253
  ),
254
+ plotlyOutput(plot_id)
255
  )
256
  )
257
  }
app/view/mod_value_boxes.R CHANGED
@@ -23,7 +23,7 @@ server <- function(id, data) {
23
  output$value_boxes_uioutput <- renderUI({
24
  layout_column_wrap(
25
  value_box(
26
- title = "Number of measured weeks",
27
  value = nrow(data()),
28
  showcase = bs_icon("calendar-date"),
29
  theme = "blue"
 
23
  output$value_boxes_uioutput <- renderUI({
24
  layout_column_wrap(
25
  value_box(
26
+ title = "Number of measured days",
27
  value = nrow(data()),
28
  showcase = bs_icon("calendar-date"),
29
  theme = "blue"
dependencies.R CHANGED
@@ -14,3 +14,4 @@ library(shinyjs)
14
  library(shinyWidgets)
15
  library(tidyr)
16
  library(VGAM)
 
 
14
  library(shinyWidgets)
15
  library(tidyr)
16
  library(VGAM)
17
+ library(waiter)
renv.lock CHANGED
@@ -1666,6 +1666,18 @@
1666
  ],
1667
  "Hash": "390f9315bc0025be03012054103d227c"
1668
  },
 
 
 
 
 
 
 
 
 
 
 
 
1669
  "waldo": {
1670
  "Package": "waldo",
1671
  "Version": "0.5.2",
 
1666
  ],
1667
  "Hash": "390f9315bc0025be03012054103d227c"
1668
  },
1669
+ "waiter": {
1670
+ "Package": "waiter",
1671
+ "Version": "0.2.5",
1672
+ "Source": "Repository",
1673
+ "Repository": "CRAN",
1674
+ "Requirements": [
1675
+ "R6",
1676
+ "htmltools",
1677
+ "shiny"
1678
+ ],
1679
+ "Hash": "93e6b6c8ae3f81d4be77a0dc74e5cf5e"
1680
+ },
1681
  "waldo": {
1682
  "Package": "waldo",
1683
  "Version": "0.5.2",