R/limitSizeGraph.R

Defines functions controlWidgetSize limitSizeGraph

Documented in limitSizeGraph

#' Use to change limit size of graph (in Mb)
#' 
#' @param size \code{numeric} widget size autorized in modules (default 200)
#' @examples 
#' \dontrun{
#' limitSizeGraph(500)
#' }
#' 
#' @export
limitSizeGraph <- function(size){
  options(antaresVizSizeGraph = size)
}


controlWidgetSize <- function(widget, language = "en"){
  if(is.null(getOption("antaresVizSizeGraph"))){
    options(antaresVizSizeGraph = 200)
  }
  
  # round(as.numeric(pryr::object_size(widget)) / 1048000, 1)
  if(round(as.numeric(object.size(widget)) / 1048000, 1) > getOption("antaresVizSizeGraph")){
    return(
      combineWidgets(
        switch(language, 
               "fr" = antaresVizSizeGraphError_fr,
               antaresVizSizeGraphError)
      )
    )
  } else {
    widget
  }
}

Try the antaresViz package in your browser

Any scripts or data that you put into this service are public.

antaresViz documentation built on Sept. 25, 2023, 5:06 p.m.