Skip to contents

First column of the df tibble must be a datetime or date variable. The rest of columns must be numeric of the same units. This functions makes use of dygraphs package to generate an HTML Dygraphs plot.

Usage

plot_ts(
  df,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  legend_show = "auto",
  legend_width = 250,
  group = NULL,
  width = NULL,
  height = NULL,
  ...
)

Arguments

df

data.frame or tibble, first column of name datetime being of class datetime and rest of columns being numeric

title

character, title of the plot (accepts HTML code)

xlab

character, X axis label (accepts HTML code)

ylab

character, Y axis label (accepts HTML code)

legend_show

character, when to display the legend. Specify "always" to always show the legend. Specify "onmouseover" to only display it when a user mouses over the chart. Specify "follow" to have the legend show as overlay to the chart which follows the mouse. The default behavior is "auto", which results in "always" when more than one series is plotted and "onmouseover" when only a single series is plotted.

legend_width

integer, width (in pixels) of the div which shows the legend.

group

character, dygraphs group to associate this plot with. The x-axis zoom level of dygraphs plots within a group is automatically synchronized.

width

Width in pixels (optional, defaults to automatic sizing)

height

Height in pixels (optional, defaults to automatic sizing)

...

extra arguments to pass to dygraphs::dyOptions function.

Value

dygraph

Examples

suppressMessages(library(lubridate))
suppressMessages(library(dplyr))

# Get demand with the complete datetime sequence from the sessions
sessions <- head(evsim::california_ev_sessions, 100)
demand <- get_demand(
  sessions,
  by = "Session",
  resolution = 60
)
#> Warning: charging sessions are aligned to 60-minute resolution.
demand %>% plot_ts()