From ab3df0eda657caf1ea9371a5dafeb9ac12c2b0dd Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Sat, 30 May 2026 19:59:31 +0200 Subject: [PATCH] new renders --- DESCRIPTION | 3 ++- NAMESPACE | 2 ++ NEWS.md | 4 ++++ R/hosted_version.R | 2 +- R/plot_hbar.R | 2 +- inst/translations/translation_da.csv | 7 ------- inst/translations/translation_sw.csv | 7 ------- man/align_axes.Rd | 2 +- man/all_but.Rd | 2 +- man/available_plots.Rd | 27 +++++++++++++++++++++++++++ man/clean_common_axis.Rd | 2 +- man/data-plots.Rd | 19 ++++++++++--------- man/get_input_params.Rd | 27 +++++++++++++++++++++++++++ man/get_label.Rd | 2 +- man/get_plot_options.Rd | 2 +- man/line_break.Rd | 2 +- man/plot_euler_single.Rd | 2 +- man/possible_plots.Rd | 4 ++-- man/selectPlotVariables.Rd | 11 +++++++++++ man/subset_types.Rd | 2 +- man/supported_plots.Rd | 2 +- man/wrap_plot_list.Rd | 2 +- 22 files changed, 97 insertions(+), 38 deletions(-) create mode 100644 man/available_plots.Rd create mode 100644 man/get_input_params.Rd create mode 100644 man/selectPlotVariables.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 69564bc2..881625b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: FreesearchR Title: Easy data analysis for clinicians -Version: 26.4.2 +Version: 26.5.1 Authors@R: c( person("Andreas Gammelgaard", "Damsbo",email="agdamsbo@clin.au.dk", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7559-1154")), @@ -118,6 +118,7 @@ Collate: 'launch_FreesearchR.R' 'missings-module.R' 'plot-download-module.R' + 'plot-helpers.R' 'plot_bar.R' 'plot_box.R' 'plot_euler.R' diff --git a/NAMESPACE b/NAMESPACE index 9e036c3f..947b97e8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ export(append_column) export(append_list) export(apply_labels) export(argsstring2list) +export(available_plots) export(baseline_table) export(class_icons) export(clean_common_axis) @@ -64,6 +65,7 @@ export(format_writer) export(generate_colors) export(get_data_packages) export(get_fun_options) +export(get_input_params) export(get_label) export(get_list_elements) export(get_plot_options) diff --git a/NEWS.md b/NEWS.md index 785ee46a..62106e48 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# FreesearchR 26.5.1 + +*NEW* The visuals module has been restructured to allow for more advanced inputs, which will be added in the future. Basically a more future proof design allowing for more adjustments, while striving to keep the simplicity. Have fun! + # FreesearchR 26.4.2 Bug fixes and revised color choices. diff --git a/R/hosted_version.R b/R/hosted_version.R index 5a0a6546..b2178643 100644 --- a/R/hosted_version.R +++ b/R/hosted_version.R @@ -1 +1 @@ -hosted_version <- function()'v26.4.2-260528' +hosted_version <- function()'v26.4.2-260530' diff --git a/R/plot_hbar.R b/R/plot_hbar.R index 1405678f..fc33b20d 100644 --- a/R/plot_hbar.R +++ b/R/plot_hbar.R @@ -76,7 +76,7 @@ vertical_stacked_bars <- function(data, colors <- generate_colors(n = nrow(df.table), palette = color.palette) ## Colors are reversed by default as that usually gives the best result - if (isTRUE(reverse)) { + if (isTRUE(reverse) | reverse=="TRUE") { colors <- rev(colors) } diff --git a/inst/translations/translation_da.csv b/inst/translations/translation_da.csv index 927131ba..50a8e93b 100644 --- a/inst/translations/translation_da.csv +++ b/inst/translations/translation_da.csv @@ -89,7 +89,6 @@ "and","og" "from each pair","fra hvert par" "Plot","Tegn" -"Adjust settings, then press ""Plot"".","Juster indstillingerne og tryk så ""Tegn""." "Plot height (mm)","Højde af grafik (mm)" "Plot width (mm)","Bredde af grafik (mm)" "File format","File format" @@ -97,12 +96,7 @@ "Select variable","Vælg variabel" "Response variable","Svarvariable" "Plot type","Type af grafik" -"Please select","Vælg" -"Additional variables","Yderligere variabler" -"Secondary variable","Sekundær variabel" "No variable","Ingen variabel" -"Grouping variable","Variabel til gruppering" -"No stratification","Ingen stratificering" "Drawing the plot. Hold tight for a moment..","Tegner grafikken. Spænd selen.." "#Plotting\n","#Tegner\n" "Stacked horizontal bars","Stablede horisontale søjler" @@ -310,7 +304,6 @@ "Sample data","Sample data" "Settings","Settings" "Create new factor","Create new factor" -"Choose color palette","Choose color palette" "Optional filter logic (e.g., ⁠[gender] = 'female')","Optional filter logic (e.g., ⁠[gender] = 'female')" "Drop empty","Drop empty" "Choose variable:","Choose variable:" diff --git a/inst/translations/translation_sw.csv b/inst/translations/translation_sw.csv index 134ec155..cff599bb 100644 --- a/inst/translations/translation_sw.csv +++ b/inst/translations/translation_sw.csv @@ -89,7 +89,6 @@ "and","na" "from each pair","kutoka kwa kila jozi" "Plot","Kipande cha habari" -"Adjust settings, then press ""Plot"".","Rekebisha mipangilio, kisha bonyeza ""Plot""." "Plot height (mm)","Urefu wa kiwanja (mm)" "Plot width (mm)","Upana wa kiwanja (mm)" "File format","Umbizo la faili" @@ -97,12 +96,7 @@ "Select variable","Chagua kigezo" "Response variable","Kigezo cha majibu" "Plot type","Aina ya kiwanja" -"Please select","Tafadhali chagua" -"Additional variables","Vigezo vya ziada" -"Secondary variable","Kigezo cha pili" "No variable","Hakuna kigezo" -"Grouping variable","Kigezo cha kuweka katika makundi" -"No stratification","Hakuna matabaka" "Drawing the plot. Hold tight for a moment..","Kuchora njama. Shikilia kwa muda.." "#Plotting\n","#Upangaji\n" "Stacked horizontal bars","Pau za mlalo zilizopangwa kwa mpangilio" @@ -310,7 +304,6 @@ "Sample data","Sample data" "Settings","Settings" "Create new factor","Create new factor" -"Choose color palette","Choose color palette" "Optional filter logic (e.g., ⁠[gender] = 'female')","Optional filter logic (e.g., ⁠[gender] = 'female')" "Drop empty","Drop empty" "Choose variable:","Choose variable:" diff --git a/man/align_axes.Rd b/man/align_axes.Rd index 6d3e79e2..f403e1a7 100644 --- a/man/align_axes.Rd +++ b/man/align_axes.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{align_axes} \alias{align_axes} \title{Aligns axes between plots} diff --git a/man/all_but.Rd b/man/all_but.Rd index e2453d15..8dc3f46e 100644 --- a/man/all_but.Rd +++ b/man/all_but.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{all_but} \alias{all_but} \title{Select all from vector but} diff --git a/man/available_plots.Rd b/man/available_plots.Rd new file mode 100644 index 00000000..0ee1d5ac --- /dev/null +++ b/man/available_plots.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot-helpers.R +\name{available_plots} +\alias{available_plots} +\title{Implemented functions} +\usage{ +available_plots() +} +\value{ +list +} +\description{ +Library of supported functions. The list name and "descr" element should be +unique for each element on list. +\itemize{ +\item fun: the plotting function +\item fun.args: default parameters for the plotting function +\item descr: Plot description +\item note: Short note/description of the function for displaying in ui and docs +\item primary.type: Primary variable data type (see \link{data_type}) +\item base: holds a list of parameters for plot input fields generation +Secondary and tertiary variable input fields are mandatory. +} +} +\examples{ +available_plots() |> str() +} diff --git a/man/clean_common_axis.Rd b/man/clean_common_axis.Rd index 175053c9..67197d46 100644 --- a/man/clean_common_axis.Rd +++ b/man/clean_common_axis.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{clean_common_axis} \alias{clean_common_axis} \title{Extract and clean axis ranges} diff --git a/man/data-plots.Rd b/man/data-plots.Rd index 4222466f..e6d84e08 100644 --- a/man/data-plots.Rd +++ b/man/data-plots.Rd @@ -1,7 +1,7 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R, R/plot_bar.R, R/plot_box.R, -% R/plot_hbar.R, R/plot_likert.R, R/plot_ridge.R, R/plot_sankey.R, -% R/plot_scatter.R, R/plot_violin.R +% Please edit documentation in R/data_plots.R, R/plot-helpers.R, R/plot_bar.R, +% R/plot_box.R, R/plot_hbar.R, R/plot_likert.R, R/plot_ridge.R, +% R/plot_sankey.R, R/plot_scatter.R, R/plot_violin.R \name{data-plots} \alias{data-plots} \alias{data_visuals_ui} @@ -22,7 +22,7 @@ \usage{ data_visuals_ui(id, tab_title = "Plots", ...) -data_visuals_server(id, data, palettes, ...) +data_visuals_server(id, data, palettes = color_choices(), ...) create_plot(data, type, pri, sec, ter = NULL, color.palette = "viridis", ...) @@ -50,9 +50,9 @@ plot_box(data, pri, sec, ter = NULL, color.palette = "viridis", ...) plot_box_single(data, pri, sec = NULL, seed = 2103, color.palette = "viridis") -plot_hbars(data, pri, sec, ter = NULL, color.palette = "viridis") +plot_hbars(data, pri, sec, ter = NULL, color.palette = "viridis", ...) -plot_likert(data, pri, sec = NULL, ter = NULL, color.palette = "viridis") +plot_likert(data, pri, sec = NULL, ter = NULL, color.palette = "viridis", ...) plot_ridge(data, x, y, z = NULL, color.palette = "viridis", ...) @@ -69,12 +69,13 @@ plot_sankey( default.color = "#2986cc", box.color = "#1E4B66", na.color = "grey80", - missing.level = "Missing" + missing.level = "Missing", + ... ) -plot_scatter(data, pri, sec, ter = NULL, color.palette = "viridis") +plot_scatter(data, pri, sec, ter = NULL, color.palette = "viridis", ...) -plot_violin(data, pri, sec, ter = NULL, color.palette = "viridis") +plot_violin(data, pri, sec, ter = NULL, color.palette = "viridis", ...) } \arguments{ \item{id}{Module id. (Use 'ns("id")')} diff --git a/man/get_input_params.Rd b/man/get_input_params.Rd new file mode 100644 index 00000000..6766d73e --- /dev/null +++ b/man/get_input_params.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot-helpers.R +\name{get_input_params} +\alias{get_input_params} +\title{Get the function parameters based on the selected function description} +\usage{ +get_input_params(data) +} +\arguments{ +\item{data}{vector} +} +\value{ +list +} +\description{ +Get the function parameters based on the selected function description +} +\examples{ +ls <- mtcars |> + default_parsing() |> + dplyr::pull(mpg) |> + possible_plots() |> + (\(.x){ + .x[[1]] + })() |> + get_input_params() +} diff --git a/man/get_label.Rd b/man/get_label.Rd index 108fd372..c808209e 100644 --- a/man/get_label.Rd +++ b/man/get_label.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{get_label} \alias{get_label} \title{Print label, and if missing print variable name for plots} diff --git a/man/get_plot_options.Rd b/man/get_plot_options.Rd index 08c04496..83001d38 100644 --- a/man/get_plot_options.Rd +++ b/man/get_plot_options.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{get_plot_options} \alias{get_plot_options} \title{Get the function options based on the selected function description} diff --git a/man/line_break.Rd b/man/line_break.Rd index 65c987c7..d926556e 100644 --- a/man/line_break.Rd +++ b/man/line_break.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{line_break} \alias{line_break} \title{Line breaking at given number of characters for nicely plotting labels} diff --git a/man/plot_euler_single.Rd b/man/plot_euler_single.Rd index f481d5af..22d425c2 100644 --- a/man/plot_euler_single.Rd +++ b/man/plot_euler_single.Rd @@ -4,7 +4,7 @@ \alias{plot_euler_single} \title{Easily plot single euler diagrams} \usage{ -plot_euler_single(data, color.palette = "viridis") +plot_euler_single(data, color.palette = "viridis", ...) } \value{ ggplot2 object diff --git a/man/possible_plots.Rd b/man/possible_plots.Rd index 28c0b623..d1519e38 100644 --- a/man/possible_plots.Rd +++ b/man/possible_plots.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{possible_plots} \alias{possible_plots} \title{Get possible regression models} \usage{ -possible_plots(data) +possible_plots(data, source_list = supported_plots()) } \arguments{ \item{data}{data} diff --git a/man/selectPlotVariables.Rd b/man/selectPlotVariables.Rd new file mode 100644 index 00000000..f9e63e5d --- /dev/null +++ b/man/selectPlotVariables.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot-helpers.R +\name{selectPlotVariables} +\alias{selectPlotVariables} +\title{Wrapper for columnSelectInput} +\usage{ +selectPlotVariables(data, exclude = NULL, allow_none = TRUE, var_types, ...) +} +\description{ +Wrapper for columnSelectInput +} diff --git a/man/subset_types.Rd b/man/subset_types.Rd index 61fced5e..a33e1561 100644 --- a/man/subset_types.Rd +++ b/man/subset_types.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{subset_types} \alias{subset_types} \title{Easily subset by data type function} diff --git a/man/supported_plots.Rd b/man/supported_plots.Rd index c91ad753..caa250e3 100644 --- a/man/supported_plots.Rd +++ b/man/supported_plots.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{supported_plots} \alias{supported_plots} \title{Implemented functions} diff --git a/man/wrap_plot_list.Rd b/man/wrap_plot_list.Rd index 40cf0ba1..dcf1ae64 100644 --- a/man/wrap_plot_list.Rd +++ b/man/wrap_plot_list.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data_plots.R +% Please edit documentation in R/plot-helpers.R \name{wrap_plot_list} \alias{wrap_plot_list} \title{Wrapping}