Skip to content

Commit

Permalink
Merge pull request #1 from hrbrmstr/master
Browse files Browse the repository at this point in the history
Update package.json
  • Loading branch information
jlewis91 committed Aug 12, 2015
2 parents 37585d2 + 81b6b07 commit fb9073e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
person("Kent", "Russell", email = "[email protected]", role = c("aut", "ctb")),
Expand Down
2 changes: 1 addition & 1 deletion R/fonts.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' tau_set_font("'Montserrat', sans-serif", "http://fonts.googleapis.com/css?family=Montserrat:400,700")
tau_set_font <- function(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") {

if (!is.null(import_url)) tau$x$forFonts <- c(tau$x$forFonts, import_url)

Expand Down
17 changes: 15 additions & 2 deletions R/rules.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion R/taucharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ tauchart <- function(data, width = NULL, height = NULL) {
padding=NULL,
guide=list(x=NULL, y=NULL, padding=NULL, color=NULL),
forCSS=NULL,
forFonts="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600&subset=latin,cyrillic-ext"
forFonts="https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600&subset=latin,cyrillic-ext"
)

# create widget
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,7 +78,7 @@ library(taucharts)

# current verison
packageVersion("taucharts")
#> [1] '0.3.3'
#> [1] '0.3.4.9000'
```

### Test Results
Expand All @@ -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 ========================================================================================================
Expand Down
7 changes: 5 additions & 2 deletions man/tau_add_css_rule.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/tau_set_font.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down

0 comments on commit fb9073e

Please sign in to comment.