Commit c3a89e1e authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v0.2.8.32 NEW: add to function (.startStop and .dyShadingMulti) in order to...

v0.2.8.32 NEW: add to function (.startStop and .dyShadingMulti) in order to draw draw several shadows on dygraphs
parent 598cd530
Package: airGRteaching
Type: Package
Title: Teaching Hydrological Modelling with the GR Rainfall-Runoff Models ('Shiny' Interface Included)
Version: 0.2.8.31
Date: 2020-02-13
Version: 0.2.8.32
Date: 2020-02-14
Authors@R: c(
person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
person("Laurent", "Coron", role = c("aut"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -34,6 +34,8 @@ export(ShinyGR)
export(as.data.frame.airGRt)
exportPattern(".DiagramGR")
exportPattern(".TypeModelGR")
exportPattern(".startStop")
exportPattern(".dyShadingMulti")
......
......@@ -4,7 +4,7 @@
### 0.2.8.31 Release Notes (2020-02-13)
### 0.2.8.32 Release Notes (2020-02-14)
#### New features
......
......@@ -8,6 +8,9 @@
}
}
## =================================================================================
## commands to avoid warnings during package checking when global variables are used
## =================================================================================
......@@ -22,6 +25,38 @@ if (getRversion() >= "2.15.1") {
## =================================================================================
## function to compute the start and stop id of equal values in a vector
## =================================================================================
.startStop <- function(x, FUN) {
naQ_rle <- rle(FUN(x))
naQ_ide <- cumsum(naQ_rle$lengths)[naQ_rle$values] + 1
naQ_ids <- naQ_ide - naQ_rle$lengths[naQ_rle$values] - 1
idNA <- data.frame(start = naQ_ids, stop = naQ_ide)
idNA$start <- ifelse(idNA$start < 1 , 1 , idNA$start)
idNA$stop <- ifelse(idNA$stop > length(x), length(x), idNA$stop )
idNA
}
## =================================================================================
## function for drawing several shadows of dygraphic regions simultaneously
## =================================================================================
.dyShadingMulti <- function(dygraph, ts, idStart, IdStop, ...) {
for (i in seq_along(idStart)) {
dygraph <- dygraphs::dyShading(dygraph = dygraph,
from = as.character(ts)[idStart[i]],
to = as.character(ts)[IdStop[i]],
...)
}
dygraph
}
## =================================================================================
## function to manage the model units
## =================================================================================
......@@ -134,7 +169,6 @@ if (getRversion() >= "2.15.1") {
i_pdt <- which(format(OutputsModel$DatesR, "%Y%m%d") == format(EventDate, "%Y%m%d"))
# --------------------------------------------------------------------------------
# UH 1 & 2
# --------------------------------------------------------------------------------
......@@ -255,6 +289,7 @@ if (getRversion() >= "2.15.1") {
# Parametres
tmp_decal <- 20
# --------------------------------------------------------------------------------
# NEUTRALISATION DE P
# --------------------------------------------------------------------------------
......@@ -413,6 +448,7 @@ if (getRversion() >= "2.15.1") {
cex = cex_tri(OutputsModel$PR[i_pdt], fact = fact_triangle, max = cex_max_poly))
}
# --------------------------------------------------------------------------------
# HYDROGRAMME UNITAIRE 1
# --------------------------------------------------------------------------------
......@@ -432,6 +468,7 @@ if (getRversion() >= "2.15.1") {
ncol = PR_mat_UH1_lg+1)[, -1L]
PR_mat_UH1[lower.tri(PR_mat_UH1)] <- 0
# --------------------------------------------------------------------------------
# HYDROGRAMME UNITAIRE 2
# --------------------------------------------------------------------------------
......@@ -618,7 +655,6 @@ if (getRversion() >= "2.15.1") {
}
}
# --------------------------------------------------------------------------------
# RESERVOIR EXPONENTIEL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment