Skip to content

Commit

Permalink
Minor fixes (#41)
Browse files Browse the repository at this point in the history
* Fix: Double inclusion of the Stat N statistics table, casuing extra infinte spinner

* Chore: Updated the Rank tooltip to not use perfomer

* Fix: Changing Plain Years to Mixed Year Types in Create Own charts

* Fix: Adding topic to num_exclude in Create Own staging table (turning KS1 to NA)

* Fix: Reversing order of levels in LA level line chart so selected LA appears top

* Fix: Attempt to fix metadata strange spacing

* Fix: Changing bookmarks from include all to exclude all, adding only LA, Topic and tabs for now

* Tests: LA line screenshot updated for bringing the selected LA to front
  • Loading branch information
JT-39 authored Nov 21, 2024
1 parent 55000cf commit 1f73799
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 181 deletions.
7 changes: 5 additions & 2 deletions 02_dev/la_level_page/la_dev_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ server_dev <- function(input, output, session) {

# Build plot
la_line_chart <- la_long() |>
# Set geog orders so selected LA is on top of plot
reorder_la_regions(reverse = TRUE) |>
ggplot2::ggplot() +
ggiraph::geom_line_interactive(
ggplot2::aes(
Expand Down Expand Up @@ -460,8 +462,9 @@ server_dev <- function(input, output, session) {
format_axes(la_long()) +
set_plot_colours(la_long(), focus_group = input$la_input) +
set_plot_labs(filtered_bds$data) +
custom_theme()

custom_theme() +
# Revert order of the legend so goes from right to left
ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE))

# Creating vertical geoms to make vertical hover tooltip
vertical_hover <- lapply(
Expand Down
6 changes: 4 additions & 2 deletions 02_dev/la_level_page/la_page_features_workshop.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ dfe_reactable(
`Latest National Rank` = reactable::colDef(
header = add_tooltip_to_reactcol(
"Latest National Rank",
"Rank 1 is always the best performer"
"Rank 1 is always best/top"
)
),
Polarity = reactable::colDef(show = FALSE)
Expand All @@ -281,6 +281,8 @@ covid_plot_line <- calculate_covid_plot(la_long, covid_affected, "line")

# Plot
la_line_chart <- la_long |>
# Set geog orders so selected LA is on top of plot
reorder_la_regions(reverse = TRUE) |>
ggplot2::ggplot() +
# Only show point data where line won't appear (NAs)
ggplot2::geom_point(
Expand Down Expand Up @@ -309,7 +311,7 @@ la_line_chart <- la_long |>
# Add COVID plot if indicator affected
add_covid_elements(covid_plot_line) +
format_axes(la_long) +
set_plot_colours(la_long, focus_group = selected_la) +
set_plot_colours(la_long, "colour", focus_group = selected_la) +
set_plot_labs(filtered_bds) +
custom_theme()

Expand Down
2 changes: 1 addition & 1 deletion 02_dev/stat_n_level_page/stat_neigh_dev_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ server_dev <- function(input, output, session) {
`Latest National Rank` = reactable::colDef(
header = add_tooltip_to_reactcol(
"Latest National Rank",
"Rank 1 is always the best performer"
"Rank 1 is always best/top"
)
),
Polarity = reactable::colDef(show = FALSE)
Expand Down
11 changes: 6 additions & 5 deletions R/fn_plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ get_yaxis_title <- function(data_full) {
#' This function retrieves the title for the X-axis based on the `Year_Type`
#' column of the provided dataset. If there is only one unique value for
#' `Year_Type`, the title will be formatted with line breaks. If there are
#' multiple unique values, a generic "Plain Years" label is used.
#' multiple unique values, a generic "Mixed Year Types" label is used.
#'
#' @param data_full A data frame containing the `Year_Type` column, which will
#' be used to determine the X-axis title.
#'
#' @return A character string representing the X-axis title. This can either
#' be the value of `Year_Type` formatted with line breaks or the string
#' "Plain Years" if there are multiple unique values.
#' "Mixed Year Types" if there are multiple unique values.
#'
#' @details The function uses `pull_uniques` to extract unique values from
#' the `Year_Type` column. If a single unique value is found, it formats
Expand All @@ -79,7 +79,7 @@ get_xaxis_title <- function(data_full) {
if (length(x_axis_title) == 1) {
add_line_breaks(x_axis_title)
} else {
"Plain Years"
"Mixed Year Types"
}
}

Expand Down Expand Up @@ -934,10 +934,11 @@ generic_ggiraph_options <- function(...) {
#' reordered_data <- reorder_la_regions(chart_data, factor_order)
#' print(reordered_data)
#'
reorder_la_regions <- function(chart_data, factor_order, ...) {
reorder_la_regions <- function(chart_data, factor_order = NULL, reverse = FALSE, ...) {
chart_data |>
dplyr::mutate(
`LA and Regions` = forcats::fct_relevel(`LA and Regions`, factor_order, ...)
`LA and Regions` = forcats::fct_relevel(`LA and Regions`, factor_order, ...),
`LA and Regions` = if (reverse) forcats::fct_rev(`LA and Regions`) else `LA and Regions`
) |>
dplyr::arrange(`LA and Regions`)
}
Expand Down
2 changes: 1 addition & 1 deletion R/lait_modules/mod_create_own_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ StagingTableServer <- function(id,
format_num_reactable_cols(
staging_data(),
get_indicator_dps(staging_bds()),
num_exclude = c("LA Number", "Measure")
num_exclude = c("LA Number", "Topic", "Measure")
),
list(
set_custom_default_col_widths(
Expand Down
6 changes: 5 additions & 1 deletion R/lait_modules/mod_la_lvl_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ LA_LineChartServer <- function(id,

# Build plot
la_long() |>
# Set geog orders so selected LA is on top of plot
reorder_la_regions(reverse = TRUE) |>
ggplot2::ggplot() +
ggiraph::geom_line_interactive(
ggplot2::aes(
Expand Down Expand Up @@ -130,7 +132,9 @@ LA_LineChartServer <- function(id,
format_axes(la_long()) +
set_plot_colours(la_long(), "colour", app_inputs$la()) +
set_plot_labs(filtered_bds()) +
custom_theme()
custom_theme() +
# Revert order of the legend so goes from right to left
ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE))
})

# Build interactive line chart
Expand Down
Loading

0 comments on commit 1f73799

Please sign in to comment.