Commit f538aeea authored by unknown's avatar unknown
Browse files

v0.1.1.5 dyplot functionhas new xlab, ylab and main default values

parent 30f0005b
Package: airGRteaching
Type: Package
Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (including a Shiny Application)
Version: 0.1.1.3
Version: 0.1.1.5
Date: 2017-02-16
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")))
Depends: airGR (>= 1.0.5.4)
......
dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
xlab = "Time", ylab = c("precip. [mm]", "flow [mm]"), main = NULL,
xlab = NULL, ylab = NULL, main = NULL,
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\"")
}
if (any(class(x) %in% "ObsGR")) {
if (is.null(xlab)) {
xlab <- "Time"
}
if (is.null(ylab)) {
yunit <- .TypeModelGR(x)$TimeUnit
ylab <- paste0(c("flow [mm/", "precip. [mm/"), yunit, "]")
} else {
if (length(ylab) < 2) {
ylab <- c(ylab, "")
}
}
if (any(class(x) %in% "ObsGR")) {
data <- data.frame(DatesR = x$InputsModel$DatesR,
Precip = x$InputsModel$Precip,
Qobs = x$Qobs)
......@@ -22,9 +34,9 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
data.xts <- xts(data[, -1L], order.by = data$DatesR)
graphOut <- dygraph(data.xts, main = main)
graphOut <- dyAxis(dygraph = graphOut, name = "y", label = ylab[2L],
graphOut <- dyAxis(dygraph = graphOut, name = "y", label = ylab[1L],
valueRange = range(data.xts[, grep("^Q", colnames(data.xts))], na.rm = TRUE) * c(0.01, 1.59))
graphOut <- dyAxis(dygraph = graphOut, name = "y2", label = ylab[1L], independentTicks = FALSE,
graphOut <- dyAxis(dygraph = graphOut, name = "y2", label = ylab[2L], independentTicks = FALSE,
valueRange = rev(range(data.xts[, "Precip"], na.rm = TRUE) * c(0.01, 2.99)))
graphOut <- dySeries(dygraph = graphOut, tail(grep("^Q", colnames(data.xts), value = TRUE), 1), axis = 'y' , color = col.Q[seq_along(grep("^Q", colnames(data.xts)))])
graphOut <- dySeries(dygraph = graphOut, "Precip", axis = 'y2', stepPlot = TRUE, fillGraph = TRUE, color = col.Precip)
......
......@@ -10,7 +10,7 @@
\usage{
\method{dyplot}{default}(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
xlab = "Time", ylab = c("precip. [mm]", "flow [mm]"), main = NULL,
xlab = NULL, ylab = NULL, main = NULL,
RangeSelector = TRUE, Roller = FALSE, LegendShow = c("follow", "auto", "always",
"onmouseover", "never"), ...)
}
......@@ -23,11 +23,11 @@
\item{col.Q}{[character] vector of 2 colors codes or names for observed and simulated flows (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}{[character] a title for the x axis}
\item{xlab}{(optional) [character] a label for the x axis}
\item{ylab}{[character] a title for the y axis}
\item{ylab}{(optional) [character] a label for the y axis (flow and rainfall)}
\item{main}{(optional) [character] an overall title for the plot}
\item{main}{(optional) [character] a main title for the plot}
\item{RangeSelector}{[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}}}
......
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