Skip to content

Commit

Permalink
init new features
Browse files Browse the repository at this point in the history
  • Loading branch information
bthieurmel committed Mar 27, 2018
1 parent 4cacbb6 commit 245947d
Show file tree
Hide file tree
Showing 27 changed files with 1,887 additions and 477 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: antaresViz
Type: Package
Title: Antares Visualizations
Version: 0.12.0
Date: 2017-12-14
Version: 0.13.0
Date: 2018-03-28
Authors@R: c(
person("Jalal-Edine", "ZAWAM", , "[email protected]", role = c("aut", "cre")),
person("Francois", "Guillem", , "[email protected]", role = "aut"),
Expand Down
12 changes: 10 additions & 2 deletions R/limitSizeGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ limitSizeGraph <- function(size){
options(antaresVizSizeGraph = size)
}

controlWidgetSize <- function(widget){
# @importFrom pryr object_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(antaresVizSizeGraphError))
return(
combineWidgets(
switch(language,
"fr" = antaresVizSizeGraphError_fr,
antaresVizSizeGraphError)
)
)
} else {
widget
}
Expand Down
507 changes: 359 additions & 148 deletions R/map.R

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions R/map_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
.getColAndSize <- function(data, coords, mergeBy, mcy, t, colVar, sizeVar,
popupVars, colorScaleOpts, labelVar = NULL) {



if (mcy != "average") data <- data[J(as.numeric(mcy))]

neededVars <- setdiff(unique(c(colVar, sizeVar, popupVars, labelVar)), "none")
Expand Down Expand Up @@ -78,13 +76,15 @@
# Special case of FLOW LIN
if (colVar == "FLOW LIN.") rangevar <- c(0, max(abs(rangevar)))

if (rangevar[1] >= 0) {
domain <- rangevar
} else {
domain <- c(-min(rangevar), max(rangevar))
}
# if (rangevar[1] >= 0) {
# domain <- rangevar
# } else {
# domain <- c(-min(rangevar), max(rangevar))
# }

if (colVar == "FLOW LIN.") colorScaleOpts$x <- abs(data[[colVar]])
domain <- rangevar

if (colVar %in% c("FLOW LIN.", .getColumnsLanguage("FLOW LIN.", language = "fr"))) colorScaleOpts$x <- abs(data[[colVar]])
else colorScaleOpts$x <- data[[colVar]]

colorScaleOpts$domain <- domain
Expand Down Expand Up @@ -119,7 +119,11 @@
res$dir <- sign(data$`FLOW LIN.`)
#coords[, `FLOW LIN.` := abs(`FLOW LIN.`)]
} else {
res$dir <- 0
if(.getColumnsLanguage("FLOW LIN.", language = "fr") %in% names(data)){
res$dir <- sign(data[[.getColumnsLanguage("FLOW LIN.", language = "fr")]])
} else {
res$dir <- 0
}
}

# Pop-up
Expand All @@ -142,7 +146,7 @@

# Initialize a map with all elements invisible: links, circles and bar or polar
# charts
.initMap <- function(x, ml, options) {
.initMap <- function(x, ml, options, language = "en") {

map <- plot(ml, areas = !is.null(x$areas), links = !is.null(x$links),
colAreas = options$areaDefaultCol,
Expand All @@ -151,7 +155,7 @@
labelMaxSize = options$labelMaxSize,
tilesURL = options$tilesURL,
preprocess = options$preprocess) %>%
addAntaresLegend(display = options$legend)
addAntaresLegend(display = options$legend, language = language)

addShadows(map)
}
Expand Down
8 changes: 6 additions & 2 deletions R/map_plugins.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ addShadows <- function(map) {
#' @noRd
addAntaresLegend <- function(map, htmlAreaColor = NULL, htmlAreaSize = NULL,
htmlLinkColor = NULL, htmlLinkSize = NULL,
onComplete = "", display = "choose") {
onComplete = "", display = "choose", language = "en") {
options <- list(
htmlAreaColor = htmlAreaColor,
htmlAreaSize = htmlAreaSize,
htmlLinkColor = htmlLinkColor,
htmlLinkSize = htmlLinkSize,
onComplete = onComplete,
display = display
display = display,
areas_name = .getLabelLanguage("Areas", language),
links_names = .getLabelLanguage("Links", language),
show_legend = .getLabelLanguage("Show legend", language),
hide_legend = .getLabelLanguage("Hide legend", language)
)

map %>% requireDep("antaresLegend") %>%
Expand Down
Loading

0 comments on commit 245947d

Please sign in to comment.