Commit fd8ea522 authored by unknown's avatar unknown
Browse files

v0.0.3 dyplot.default gains a roller period argument

parent e696752d
dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "red"),
xlab = "Time", ylab = c("Precipitation [mm]", "Flow [mm]"), main = NULL,
RangeSelector = TRUE, dyLegendShow = c("follow", "auto", "always", "onmouseover", "never"), ...) {
dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
xlab = "Time", ylab = c("precip. [mm]", "flow [mm]"), 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\"")
stop("Non convenient data for x argument. Must be of class \"ObsGR\", \"CalGR\" or \"SimGR\"")
}
if (any(class(x) %in% "ObsGR")) {
......@@ -22,21 +22,27 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "red"
data.xts <- xts(data[, -1L], order.by = data$DatesR)
graphOut <- dygraph(data.xts, main = main)
graphOut <- dyAxis(dygraph = graphOut, name = "y", label = "Flow",
graphOut <- dyAxis(dygraph = graphOut, name = "y", label = ylab[2L],
valueRange = range(data.xts[, grep("^Q", colnames(data.xts))], na.rm = TRUE) * c(0.01, 1.59))
graphOut <- dyAxis(dygraph = graphOut, name = "y2", label = "Precip.", independentTicks = FALSE,
graphOut <- dyAxis(dygraph = graphOut, name = "y2", label = ylab[1L], independentTicks = FALSE,
valueRange = rev(range(data.xts[, "Precip"], na.rm = TRUE) * c(0.01, 2.99)))
graphOut <- dySeries(dygraph = graphOut, "Qobs" , axis = 'y' , color = col.Q[seq_along(grep("^Q", colnames(data.xts)))])
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)
# if (ModelPeriod) {
# graphOut <- dyShading(dygraph = graphOut, from = x$PeriodModel$WarmUp[1L], to = x$PeriodModel$WarmUp[2L], color = "red")
# graphOut <- dyShading(dygraph = graphOut, from = x$PeriodModel$WarmUp[1L], to = x$PeriodModel$WarmUp[2L], color = "orangered")
# graphOut <- dyShading(dygraph = graphOut, from = x$PeriodModel$Run[1L] , to = x$PeriodModel$Run[2L] , color = "blue")
# }
if (RangeSelector) {
graphOut <- dyRangeSelector(dygraph = graphOut, height = 15)
}
if (any(dyLegendShow %in% c("follow", "auto", "always", "onmouseover", "never"))) {
graphOut <- dyLegend(dygraph = graphOut, show = dyLegendShow[1L])
if (Roller) {
graphOut <- dyRoller(dygraph = graphOut, rollPeriod = 5)
}
if (is.numeric(Roller)) {
graphOut <- dyRoller(dygraph = graphOut, rollPeriod = Roller)
}
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,9 +9,9 @@
\usage{
\method{dyplot}{default}(x, col.Precip = "royalblue", col.Q = c("black", "red"),
\method{dyplot}{default}(x, col.Precip = "royalblue", col.Q = c("black", "orangered"),
xlab = "Time", ylab = c("Precipitation [mm]", "Flow [mm]"), main = NULL,
RangeSelector = TRUE, dyLegendShow = c("follow", "auto", "always",
RangeSelector = TRUE, Roller = FALSE, LegendShow = c("follow", "auto", "always",
"onmouseover", "never"), ...)
}
......@@ -30,8 +30,10 @@
\item{main}{(optional) [character] an overall 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}}}
\item{Roller}{[boolean or numeric] number of time scale units, see \code{\link{dyRoller}}}
\item{dyLegendShow}{[character] when to display the legend. Specify \code{"always"} to always show the legend. Specify \code{"onmouseover"} to only display it when a user mouses over the chart. Specify \code{"follow"} (default) to have the legend show as overlay to the chart which follows the mouse. See \code{\link{dyLegend}}}
\item{LegendShow}{[character] when to display the legend. Specify \code{"always"} to always show the legend. Specify \code{"onmouseover"} to only display it when a user mouses over the chart. Specify \code{"follow"} (default) to have the legend show as overlay to the chart which follows the mouse. See \code{\link{dyLegend}}}
\item{...}{Further graphical parameters may also be supplied as arguments. See 'Details'}
}
......
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