File: css.R

package info (click to toggle)
r-cran-dygraphs 1.1.1.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,228 kB
  • sloc: sh: 19; makefile: 15
file content (30 lines) | stat: -rw-r--r-- 1,084 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#' CSS for dygraph labels and legend
#' 
#' Apply custom CSS to the text drawn within a dygraph. See the 
#' \href{http://dygraphs.com/css.html}{CSS documentation} on the dygraphs 
#' website for additional details on which styles are available.
#' 
#' @param dygraph Dygraph to add CSS styles to
#' @param css Path to css file to be used for styling textual elements of the 
#'   graph.
#'   
#' @return dygraph with additional CSS styles
#'   
#' @note See the 
#'   \href{https://rstudio.github.io/dygraphs/gallery-css-styling.html}{CSS 
#'   Styling} article on the dygraphs for R website for additional details.
#'   
#'   Note that CSS styles are global so will affect all dygraphs on a given web
#'   page. This also implies that for a page with multiple plots you only need
#'   to specify styles for the first one (alternatively you can just add them
#'   directly to the page by other means).
#'   
#' @export
dyCSS <- function(dygraph, css) {
  
  # read css
  dygraph$x$css <- paste(readLines(css, warn = FALSE), collapse = "\n")
  
  # return modified dygraph
  dygraph
}