diff --git a/DESCRIPTION b/DESCRIPTION index 92715dd..7d809e4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: taucharts Title: Create Interactive Charts with the JavaScript 'TauCharts' Library -Version: 0.3.3.9001 +Version: 0.3.4.9000 Authors@R: c( person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")), person("Kent", "Russell", email = "kent.russell@timelyportfolio.com", role = c("aut", "ctb")), diff --git a/R/rules.r b/R/rules.r index 2b2a268..e3a9e0d 100644 --- a/R/rules.r +++ b/R/rules.r @@ -12,9 +12,11 @@ #' #' @param tau taucharts object #' @param rule character vector of CSS rule(s) to add to the widget DOM +#' @param warn show warnings for global CSS rules? (default: \code{TRUE}) #' @return taucharts htmlwidget object #' @note This is for expert use only. You need to know quite a bit about the visualization -#' and target DOM to effectively use this function. +#' and target DOM to effectively use this function. CSS rules without the \code{\{\{ID\}\}} +#' are applied to the entire DOM. #' @export #' @examples #' # change the default white tooltip to black @@ -33,7 +35,18 @@ #' tau_color_manual(c("blue", "maroon", "black")) %>% #' tau_tooltip() %>% #' make_black_tooltip() -tau_add_css_rule <- function(tau, rule) { +tau_add_css_rule <- function(tau, rule, warn=TRUE) { + + # if any of the CSS statements in 'rule' do not have {{ID}} targets, warn the user + if (warn) { + if (!any(grepl("\\{\\{ID\\}\\}", rule))) { + # special case for the tooltip since that resides outsie the widget div + # it has to be targeted globally unless the TauCharts folks change the behavior + if (!all(grepl("graphical-report__tooltip", rule[which(!grepl("\\{\\{ID\\}\\}", rule))]))) { + message("NOTE: CSS rules without {{ID}} are applied to the entire DOM.") + } + } + } tau$x$forCSS <- c(tau$x$forCSS, rule) tau } diff --git a/README.Rmd b/README.Rmd index 7879ed8..039fade 100644 --- a/README.Rmd +++ b/README.Rmd @@ -65,6 +65,7 @@ The following datasets are included: ### News +- Version 0.3.4.9000 released : added warning for global targeted CSS rules and font ref fix thx to @jlewis91 - Version 0.3.3.9001 released : fix for custom colors and `tau_line` - Version 0.3.3 released : custom font for chart (`?tau_set_font`) - Version 0.3.2 released : custom colors working in legend & trendlines diff --git a/README.md b/README.md index aa4c476..7f4dce4 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ The following datasets are included: ### News +- Version 0.3.4.9000 released : added warning for global targeted CSS rules and font ref fix thx to @jlewis91 - Version 0.3.3.9001 released : fix for custom colors and `tau_line` - Version 0.3.3 released : custom font for chart (`?tau_set_font`) - Version 0.3.2 released : custom colors working in legend & trendlines @@ -77,7 +78,7 @@ library(taucharts) # current verison packageVersion("taucharts") -#> [1] '0.3.3' +#> [1] '0.3.4.9000' ``` ### Test Results @@ -87,7 +88,7 @@ library(taucharts) library(testthat) date() -#> [1] "Mon Aug 10 20:17:36 2015" +#> [1] "Wed Aug 12 16:37:18 2015" test_dir("tests/") #> testthat results ======================================================================================================== diff --git a/man/tau_add_css_rule.Rd b/man/tau_add_css_rule.Rd index 708d1f6..0209268 100644 --- a/man/tau_add_css_rule.Rd +++ b/man/tau_add_css_rule.Rd @@ -4,12 +4,14 @@ \alias{tau_add_css_rule} \title{Add a CSS rule to the rendered htmlwidget} \usage{ -tau_add_css_rule(tau, rule) +tau_add_css_rule(tau, rule, warn = TRUE) } \arguments{ \item{tau}{taucharts object} \item{rule}{character vector of CSS rule(s) to add to the widget DOM} + +\item{warn}{show warnings for global CSS rules? (default: \code{TRUE})} } \value{ taucharts htmlwidget object @@ -28,7 +30,8 @@ Vectorized over \code{rule} } \note{ This is for expert use only. You need to know quite a bit about the visualization - and target DOM to effectively use this function. + and target DOM to effectively use this function. CSS rules without the \code{\{\{ID\}\}} + are applied to the entire DOM. } \examples{ # change the default white tooltip to black diff --git a/man/tau_set_font.Rd b/man/tau_set_font.Rd index 7f8a804..f94d7c0 100644 --- a/man/tau_set_font.Rd +++ b/man/tau_set_font.Rd @@ -6,7 +6,7 @@ \usage{ tau_set_font(tau, family = "OpenSans, 'Helvetica Neue', Helvetica, Arial, sans-serif", - import_url = "http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,700,600italic,700italic,800,300,300italic,800italic") + import_url = "https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,700,600italic,700italic,800,300,300italic,800italic") } \arguments{ \item{family}{CSS \code{font-family} spec (just the comma-separated font names)}