Skip to content

Commit

Permalink
gender pay gap charts
Browse files Browse the repository at this point in the history
  • Loading branch information
kygoffe committed Nov 1, 2023
1 parent 4d25858 commit 7a9e690
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
22 changes: 12 additions & 10 deletions R/mod_paygap.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod_paygap_ui <- function(id) {
),
nhs_selectInput(
inputId = ns("stats"),
label = "Pay gap shown by",
label = "Gender pay gap by",
choices = c("Mean" = "mean_paygap",
"Median" = "median_paygap"),
full_width = TRUE,
Expand Down Expand Up @@ -83,7 +83,7 @@ mod_paygap_server <- function(id) {
x = df_paygap,
xvar = "period",
yvar = "mean_paygap",
yaxis_title = "Mean pay gap (%)"
yaxis_title = "Mean gender pay gap (%)"
)
})

Expand All @@ -92,7 +92,7 @@ mod_paygap_server <- function(id) {
x = df_paygap,
xvar = "period",
yvar = "median_paygap",
yaxis_title = "Median pay gap (%)"
yaxis_title = "Median gender pay gap (%)"
)
})

Expand All @@ -103,26 +103,28 @@ mod_paygap_server <- function(id) {

if(input$factor == "afc_band"){
nhsbsaGPG::gpg_class$df_hrrate_afc |>
dplyr::mutate(mean_paygap = round(mean_paygap, 1),
median_paygap = round(median_paygap, 1)) |>
dplyr::filter(period == input$period) |>
dplyr::select(period, afc_band, input$stats)
dplyr::select(period, afc_band, input$stats)

}else{
nhsbsaGPG::gpg_class$df_hrrate_dir |>
dplyr::mutate(mean_paygap = round(mean_paygap, 1),
median_paygap = round(median_paygap, 1)) |>
dplyr::filter(period == input$period) |>
dplyr::select(period, directorate, input$stats)
}
})

observe(print(df_paygap_afc_directorate()))


output$paygap_afc_directorate <- highcharter::renderHighchart({
gpg_bar(
x = df_paygap_afc_directorate(),
xvar = input$factor,
yvar = input$stats,
yaxis_title = switch(input$stats,
"mean_paygap" = "Mean pay gap (%)",
"median_paygap" = "Median pay gap (%)")
"mean_paygap" = "Mean gender pay gap (%)",
"median_paygap" = "Median gender pay gap (%)")
)
})

Expand Down
14 changes: 8 additions & 6 deletions R/utils-charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ gpg_bar <- function(x, xvar, yvar, yaxis_title) {
) |>
nhsbsaR::theme_nhsbsa_highchart() |>
highcharter::hc_yAxis(
title = list(text = yaxis_title)
title = list(text = yaxis_title),
max = 50
) |>
highcharter::hc_xAxis(
type = "category",
Expand All @@ -301,12 +302,12 @@ gpg_bar <- function(x, xvar, yvar, yaxis_title) {
enabled = TRUE,
format = "{y} %",
inside = FALSE,
align = "right",
align = "top",
color = "#425563",
style = list(fontSize = "14px")
style = list(fontSize = "13px")
)),
pointPadding = 0.1,
groupPadding = 0
pointPadding = 1,
groupPadding = 1
) |>
highcharter::hc_tooltip(
headerFormat = '<span style="font-size: 10px">{point.key}</span><br/>',
Expand Down Expand Up @@ -360,7 +361,8 @@ gpg_column <- function(x, xvar = "period", yvar, yaxis_title) {
) |>
nhsbsaR::theme_nhsbsa_highchart() |>
highcharter::hc_yAxis(
title = list(text = yaxis_title)
title = list(text = yaxis_title),
max = 20
) |>
highcharter::hc_xAxis(
type = "category",
Expand Down

0 comments on commit 7a9e690

Please sign in to comment.