Commit e1ea3265 authored by unknown's avatar unknown
Browse files

v0.1.3.8 NA values can be drawn by dyplot* functions

parent e11b6074
Package: airGRteaching
Type: Package
Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (Including a Shiny Application)
Version: 0.1.3.7
Version: 0.1.3.8
Date: 2017-06-22
Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut")), person("Guillaume", "Thirel", role = c("ctb")))
Depends: airGR (>= 1.0.8.0)
......
dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "orangered"), col.na = "lightgrey",
xlab = NULL, ylab = NULL, main = NULL,
RangeSelector = TRUE, Roller = FALSE, LegendShow = c("follow", "auto", "always", "onmouseover", "never"), ...) {
plot.na = TRUE, RangeSelector = TRUE, Roller = FALSE,
LegendShow = c("follow", "auto", "always", "onmouseover", "never"), ...) {
if (! any(class(x) %in% c("ObsGR", "CalGR", "SimGR"))) {
stop("Non convenient data for x argument. Must be of class \"ObsGR\", \"CalGR\" or \"SimGR\"")
......@@ -31,6 +32,8 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
col.Q <- rep(col.Q, 2)
}
}
data.xts <- xts(data[, -1L], order.by = data$DatesR)
graphOut <- dygraph(data.xts, main = main)
......@@ -47,6 +50,18 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
if (RangeSelector) {
graphOut <- dyRangeSelector(dygraph = graphOut, height = 15)
}
if (plot.na) {
naQ_rle <- rle(is.na(data$Qobs))
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, end = naQ_ide)
for (i in seq_len(nrow(IDna))) {
graphOut <- dyShading(dygraph = graphOut,
from = as.character(data$DatesR)[IDna[i, "start"]],
to = as.character(data$DatesR)[IDna[i, "end" ]],
color = col.na)
}
}
if (Roller) {
graphOut <- dyRoller(dygraph = graphOut, rollPeriod = 5)
}
......@@ -55,7 +70,8 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
}
if (any(LegendShow %in% c("follow", "auto", "always", "onmouseover", "never"))) {
graphOut <- dyLegend(dygraph = graphOut, show = LegendShow[1L])
}
}
graphOut <- dyOptions(dygraph = graphOut, useDataTimezone = TRUE)
return(graphOut)
......
......@@ -9,10 +9,10 @@
\usage{
\method{dyplot}{default}(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
\method{dyplot}{default}(x, col.Precip = "royalblue", col.Q = c("black", "orangered"), col.na = "lightgrey",
xlab = NULL, ylab = NULL, main = NULL,
RangeSelector = TRUE, Roller = FALSE, LegendShow = c("follow", "auto", "always",
"onmouseover", "never"), ...)
plot.na = TRUE, RangeSelector = TRUE, Roller = FALSE,
LegendShow = c("follow", "auto", "always", "onmouseover", "never"), ...)
}
......@@ -23,12 +23,16 @@
\item{col.Q}{(optional) [character] vector of 2 colors codes or names for observed and simulated flows, respectively (these can be of the form \code{"#AABBCC"} or \code{"rgb(255, 100, 200)"} or \code{"yellow"}), see \code{\link{par}} and \code{\link{rgb}}}
\item{col.na}{(optional) [character] color code or name for missing values(these can be of the form \code{"#AABBCC"} or \code{"rgb(255, 100, 200)"} or \code{"yellow"}), see \code{\link{par}} and \code{\link{rgb}}}
\item{xlab}{(optional) [character] a label for the x-axis}
\item{ylab}{(optional) [character] a label for the y-axis (flow and precipitation)}
\item{main}{(optional) [character] a main title for the plot}
\item{plot.na}{[boolean] boolean indicating if the missing values are plotted on the x-axis}
\item{RangeSelector}{(optional) [boolean] add a range selector to the bottom of the chart that allows users to pan and zoom to various date ranges (see \code{\link{dyRangeSelector}})}
\item{Roller}{(optional) [boolean or numeric] number of time scale units (see \code{\link{dyRoller}})}
......
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