generated from The-Strategy-Unit/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_plot_rates_funnel.R
More file actions
43 lines (41 loc) · 1.18 KB
/
mod_plot_rates_funnel.R
File metadata and controls
43 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' Plot Rates Funnel UI
#' @param id,input,output,session Internal parameters for `shiny`.
#' @noRd
mod_plot_rates_funnel_ui <- function(id) {
ns <- shiny::NS(id)
bslib::card(
bslib::card_header("Rates Funnel"),
bslib::card_body(shiny::plotOutput(ns("rates_funnel_plot"))),
full_screen = TRUE
)
}
#' Plot Rates Funnel Server
#' @param id Internal parameter for `shiny`.
#' @param rates A data.frame. Annual rate values for combinations of provider
#' and strategy
#' @param y_axis_limits Numeric vector. Min and max values for the y axis.
#' @param x_axis_title Character. Title for the x-axis.
#' @noRd
mod_plot_rates_funnel_server <- function(
id,
rates,
y_axis_limits,
x_axis_title
) {
shiny::moduleServer(id, function(input, output, session) {
output$rates_funnel_plot <- shiny::renderPlot({
rates <- rates()
shiny::validate(shiny::need(
nrow(rates) > 0,
"No data available for these selections."
))
shiny::req(y_axis_limits())
shiny::req(x_axis_title())
plot_rates_funnel(
rates,
y_axis_limits(),
x_axis_title = x_axis_title()
)
})
})
}