| add_dygraph | R Documentation | 
Add a dygraph to a chronicle report
add_dygraph(
  report = "",
  dt,
  value,
  date,
  groups = NULL,
  y_axis_label = NULL,
  plot_palette = NULL,
  plot_palette_generator = NULL,
  dygraph_title = NULL,
  title_level = 2,
  echo = FALSE,
  message = FALSE,
  warning = FALSE,
  fig_width = NULL,
  fig_height = NULL
)
| report | Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. | 
| dt | Data to plot | 
| value | Name of the column of the data frame containing the numerical variables of the time series. | 
| date | Name of the column containing the date variable. It must be already a date or time object. | 
| groups | Name of the columns containing the different groups. | 
| y_axis_label | Label for the y axis. x axis is the date (or time) so it is not needed | 
| plot_palette | Character vector of hex codes specifying the colors to use on the plot. | 
| plot_palette_generator | Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required. | 
| dygraph_title | Title for the Rmarkdown section containing the dygraph | 
| title_level | Level of the section title of this plot (ie, number of # on Rmarkdown syntax.) | 
| echo | Whether to display the source code in the output document. Default is FALSE. | 
| message | Whether to preserve messages on rendering. Default is FALSE. | 
| warning | Whether to preserve warnings on rendering. Default is FALSE. | 
| fig_width | Width of the plot (in inches). | 
| fig_height | Height of the plot (in inches). | 
An R Markdown file as a character string, now containing a chunk for the specified dygraph.
dat <- data.frame(x = c(rnorm(100, 2, 4),
                        rnorm(100, 6, 1),
                        rnorm(100, 8, 2)),
                 group = c(rep('A', 100),
                           rep('B', 100),
                           rep('C', 100)),
                 date = rep(seq(as.Date("2020-01-01"),
                                as.Date("2020-04-09"),
                                'days'),
                            3))
html_report <- add_dygraph(report = '',
                          dt = dat,
                          value = 'x',
                          date = 'date')
cat(html_report)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.