Skip to content

Commit

Permalink
fixed bug with n_geoms different between ui and server
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Jul 5, 2024
1 parent 236dcbf commit 82d2e84
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ URL: https://dreamrs.github.io/esquisse/, https://github.com/dreamRs/esquisse
BugReports: https://github.com/dreamRs/esquisse/issues
License: GPL-3 | file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Imports:
bslib,
Expand Down
2 changes: 0 additions & 2 deletions R/esquisse-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,9 @@ esquisse_server <- function(id,
geoms <- potential_geoms(data_chart$data, mapping)
req(geom %in% geoms)


if (isTruthy(setdiff(geoms_others_r(), "blank"))) {
geom <- c(geom, geoms_others_r())
mappings <- c(list(mapping), aes_others_r())
# browser()
geom_args <- lapply(
X = seq_len(n_geoms), # n_geoms
FUN = function(i) {
Expand Down
8 changes: 5 additions & 3 deletions R/esquisse-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ esquisse_ui <- function(id,
id = ns("controls"),
insert_code = insert_code,
controls = controls,
downloads = downloads
downloads = downloads,
n_geoms = n_geoms
)
)
} else {
Expand All @@ -140,7 +141,8 @@ esquisse_ui <- function(id,
insert_code = insert_code,
controls = controls,
layout = "accordion",
downloads = downloads
downloads = downloads,
n_geoms = n_geoms
)
),

Expand Down Expand Up @@ -181,7 +183,7 @@ esquisse_ui <- function(id,
}

#' @param width,height The width and height of the container, e.g. `"400px"`,
#' or `"100%"`; see \code{\link[htmltools]{validateCssUnit}}.
#' or `"100%"`; see [htmltools::validateCssUnit()].
#' @param fixed Use a fixed container, e.g. to use use esquisse full page.
#' If `TRUE`, width and height are ignored. Default to `FALSE`.
#' It's possible to use a vector of CSS unit of length 4 to specify the margins
Expand Down
4 changes: 2 additions & 2 deletions R/module-controls-geoms.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ controls_geoms_server <- function(id,
aesthetics <- names(aesthetics_r())

dropNulls(list(
stat = if (geom == "bar" & "yvar" %in% aesthetics) "summary",
fun = if (geom == "bar" & "yvar" %in% aesthetics) input$stat_fun,
stat = if (identical(geom, "bar") & isTRUE("yvar" %in% aesthetics)) "summary",
fun = if (identical(geom, "bar") & isTRUE("yvar" %in% aesthetics)) input$stat_fun,
adjust = input$adjust,
position = if (
!identical(input$position, "stack") &
Expand Down
19 changes: 12 additions & 7 deletions R/module-controls.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ controls_ui <- function(id,
controls = c("options", "labs", "axes", "geoms", "theme", "filters", "code"),
insert_code = FALSE,
layout = c("dropdown", "accordion"),
downloads = downloads_labels()) {
downloads = downloads_labels(),
n_geoms = 1) {
ns <- NS(id)
layout <- match.arg(layout)
if (!is.null(controls)) {
Expand Down Expand Up @@ -148,7 +149,7 @@ controls_ui <- function(id,
padding = "5px 7px"
)
},
n_geoms = 5
n_geoms = n_geoms
),
inputId = ns("controls-geoms"),
class = "esquisse-controls-geoms",
Expand Down Expand Up @@ -242,11 +243,15 @@ controls_ui <- function(id,
#' Dropup buttons to hide chart's controls
#'
#' @param id Module's ID.
#' @param type \code{reactiveValues} indicating the type of chart.
#' @param data_r \code{reactive} function returning data used in plot.
#' @param data_name \code{reactive} function returning data name.
#' @param ggplot_rv \code{reactiveValues} with ggplot object (for export).
#' @param aesthetics \code{reactive} function returning aesthetic names used.
#' @param data_r `reactive` function returning data used in plot.
#' @param data_name `reactive` function returning data name.
#' @param ggplot_rv `reactiveValues` with ggplot object (for export).
#' @param aesthetics_r `reactive` function returning aesthetic names used.
#' @param geoms_r `reactive` function returning geoms selected.
#' @param active_geom_r `reactive` function returning the current geom.
#' @param n_geoms Number of geoms possible.
#' @param width,height Width and height of the chart.
#' @param drop_ids Drop or not IDs in filter module.
#'
#' @return A reactiveValues with all input's values
#' @noRd
Expand Down
2 changes: 1 addition & 1 deletion man/esquisse-module.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82d2e84

Please sign in to comment.