├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── CONDUCT.md ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── as_tauchart.r ├── colors.r ├── datasets.r ├── fonts.r ├── geoms.r ├── guides.r ├── plugins.R ├── rules.r ├── shiny.r ├── tasks.r ├── taucharts-package.r ├── taucharts.R ├── title.r └── utils.r ├── README.Rmd ├── README.md ├── data └── cars_data.rda ├── inst ├── htmlwidgets │ ├── lib │ │ ├── d3 │ │ │ ├── .gitattributes │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── d3.min.js │ │ └── taucharts │ │ │ ├── LICENSE │ │ │ ├── tauCharts.min.css │ │ │ └── tauCharts.min.js │ ├── taucharts.js │ └── taucharts.yaml └── shinyapps │ └── tau01 │ ├── server.R │ └── ui.R ├── man ├── as_tauchart.Rd ├── cars_data.Rd ├── run_tau_app.Rd ├── tau_add_css_rule.Rd ├── tau_annotations.Rd ├── tau_area.Rd ├── tau_bar.Rd ├── tau_boxplot.Rd ├── tau_color_538.Rd ├── tau_color_brewer.Rd ├── tau_color_economist.Rd ├── tau_color_few.Rd ├── tau_color_highcharts.Rd ├── tau_color_manual.Rd ├── tau_color_tableau.Rd ├── tau_color_wsj.Rd ├── tau_export_plugin.Rd ├── tau_guide_gridlines.Rd ├── tau_guide_padding.Rd ├── tau_guide_x.Rd ├── tau_guide_y.Rd ├── tau_legend.Rd ├── tau_line.Rd ├── tau_point.Rd ├── tau_quick_filter.Rd ├── tau_set_font.Rd ├── tau_stacked_bar.Rd ├── tau_tasks.Rd ├── tau_title.Rd ├── tau_tooltip.Rd ├── tau_trendline.Rd ├── tauchart.Rd ├── taucharts-exports.Rd ├── taucharts-shiny.Rd └── taucharts.Rd ├── taucharts.Rproj ├── tauchartsrpub.Rmd ├── tauchartsrpub.html └── tests ├── test.Rmd ├── test.html ├── testthat.R └── testthat ├── test-taucharts.R └── tests.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^README\.Rmd$ 4 | ^README-.*\.png$ 5 | ^\.travis\.yml$ 6 | ^CONDUCT\.md$ 7 | ^README\.md$ 8 | ^tauchartsrpub\.html$ 9 | ^tauchartsrpub\.Rmd$ 10 | \.bower\.json 11 | ^rsconnect$ 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | rsconnect/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Sample .travis.yml for R projects 2 | 3 | language: r 4 | warnings_are_errors: true 5 | sudo: required 6 | 7 | env: 8 | global: 9 | - CRAN: http://cran.rstudio.com 10 | 11 | notifications: 12 | email: 13 | on_success: change 14 | on_failure: change 15 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (http:contributor-covenant.org), version 1.0.0, available at 25 | http://contributor-covenant.org/version/1/0/0/ 26 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: taucharts 2 | Title: Create Interactive Charts with the JavaScript 'TauCharts' Library 3 | Version: 0.4.5 4 | Authors@R: c( 5 | person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")), 6 | person("Adeel", "Khan", email = "AdeelK@gwu.edu", role = c("aut", "ctb")), 7 | person("Kent", "Russell", email = "kent.russell@timelyportfolio.com", role = c("aut", "ctb")), 8 | person("Tho", "Nguyen", role = "ctb"), 9 | person("Pierre", "Formont", email = "pierre.formont@gmail.com", role = "ctb"), 10 | person("Mike", "Bostock", role = c("aut", "cph"), comment = "d3.js library in htmlwidgets/lib, http://d3js.org"), 11 | person("Jeremy", "Ashkenas", role = c("aut", "cph"), comment = "underscore.js library in htmlwidgets/lib, http://underscorejs.org"), 12 | person("Vladimir", "Petriko", role = c("aut", "cph"), comment = "taucharts.js library in htmlwidgets/lib, http://taucharts.com/") 13 | ) 14 | Maintainer: Bob Rudis 15 | Description: The TauCharts JavaScript (D3) library makes 16 | it possible to create compelling interactive charts. The taucharts package 17 | provides an htmlwidgets interface to the TauCharts JavaScript library and 18 | includes functions to translate simple ggplot2 objects into TauCharts 19 | visualizations. 20 | Depends: 21 | R (>= 3.0.0) 22 | License: MIT + file LICENSE 23 | LazyData: true 24 | Suggests: 25 | testthat, 26 | ggplot2, 27 | dplyr, 28 | tidyr, 29 | shiny 30 | Imports: 31 | htmlwidgets, 32 | htmltools, 33 | magrittr, 34 | RColorBrewer, 35 | ggthemes, 36 | zoo 37 | RoxygenNote: 6.0.1 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2015 2 | COPYRIGHT HOLDER: Bob Rudis 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("%>%") 4 | export(JS) 5 | export(as_tauchart) 6 | export(renderTaucharts) 7 | export(run_tau_app) 8 | export(tau_add_css_rule) 9 | export(tau_annotations) 10 | export(tau_area) 11 | export(tau_bar) 12 | export(tau_boxplot) 13 | export(tau_color_538) 14 | export(tau_color_brewer) 15 | export(tau_color_economist) 16 | export(tau_color_few) 17 | export(tau_color_highcharts) 18 | export(tau_color_manual) 19 | export(tau_color_tableau) 20 | export(tau_color_wsj) 21 | export(tau_export_plugin) 22 | export(tau_guide_gridlines) 23 | export(tau_guide_padding) 24 | export(tau_guide_x) 25 | export(tau_guide_y) 26 | export(tau_legend) 27 | export(tau_line) 28 | export(tau_point) 29 | export(tau_quick_filter) 30 | export(tau_set_font) 31 | export(tau_stacked_bar) 32 | export(tau_tasks) 33 | export(tau_title) 34 | export(tau_tooltip) 35 | export(tau_trendline) 36 | export(tauchart) 37 | export(tauchartsOutput) 38 | import(RColorBrewer) 39 | import(htmltools) 40 | importFrom(htmlwidgets,JS) 41 | importFrom(magrittr,"%>%") 42 | importFrom(zoo,index) 43 | -------------------------------------------------------------------------------- /R/as_tauchart.r: -------------------------------------------------------------------------------- 1 | #' Turn a simple (single-geom) ggplot plot into an tauchart object 2 | #' 3 | #' Takes a ggplot object that has a single geom (it can be geom_line, 4 | #' geom_point or geom_histogram) and converts it to it's tauchart counterpart. 5 | #' It will do it's best to identify plot labels, mapped size & color aesthetics, 6 | #' and x/y limits. 7 | #' 8 | #' If there are aesthetic mappings, \code{as_tauchart} will automaticlly add 9 | #' a legend. 10 | #' 11 | #' Currently supports: 12 | #' 13 | #' \itemize{ 14 | #' \item \code{geom_point} 15 | #' \item \code{geom_line} 16 | #' \item \code{geom_bar} 17 | #' \item \code{geom_histogram} 18 | #' } 19 | #' 20 | #' @note More aesthetic mappings are planned 21 | #' @param gg ggplot object 22 | #' @return tauchart object 23 | #' @export 24 | #' @examples 25 | #' if (interactive()) { 26 | #' library(ggplot2) 27 | #' dat <- data.frame(year=seq(1790, 1970, 10), 28 | #' uspop=as.numeric(uspop)) 29 | #' set.seed(5689) 30 | #' data(movies, package="ggplot2") 31 | #' movies <- movies[sample(nrow(movies), 1000), ] 32 | #' 33 | #' gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_line() 34 | #' as_tauchart(gg) 35 | #' 36 | #' gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_point() 37 | #' as_tauchart(gg) 38 | #' 39 | #' gg <- ggplot(dplyr::count(movies, rating), aes(rating, n)) + geom_bar(stat="identity") 40 | #' as_tauchart(gg) 41 | #' 42 | #' gg <- ggplot(mtcars) + geom_point(aes(x=mpg, y=wt, color=cyl)) 43 | #' as_tauchart(gg) 44 | #' 45 | #' gg <- ggplot(mtcars, aes(x=mpg, y=wt, color=am, size=wt)) + geom_point() 46 | #' as_tauchart(gg) 47 | #' 48 | #' data(economics, package="ggplot2") 49 | #' gg <- ggplot(economics) + geom_line(aes(x=date, y=unemploy)) 50 | #' as_tauchart(gg) %>% tau_guide_x(tick_format="%Y") 51 | #' 52 | #' gg <- ggplot(mtcars, aes(as.factor(cyl))) + geom_histogram() 53 | #' as_tauchart(gg) 54 | #' } 55 | as_tauchart <- function(gg) { 56 | 57 | if (!inherits(gg, c("gg", "ggplot"))) { 58 | stop("as_tauchart only works with ggplot objects", call.=FALSE) 59 | } 60 | 61 | gb <- ggplot2::ggplot_build(gg) 62 | 63 | if (length(gb$plot$layers) > 1) { 64 | stop("as_tauchart only works with single-layer-geoms", call.=FALSE) 65 | } 66 | 67 | plot_type <- gb$plot$layers[[1]]$geom$objname 68 | 69 | x <- as.character(gb$plot$mapping$x %||% gb$plot$layers[[1]]$mapping$x %||% NULL) 70 | y <- as.character(gb$plot$mapping$y %||% gb$plot$layers[[1]]$mapping$y %||% NULL) 71 | color <- gb$plot$mapping$colour %||% gb$plot$layers[[1]]$mapping$colour %||% NULL 72 | size <- gb$plot$mapping$size %||% gb$plot$layers[[1]]$mapping$size %||% NULL 73 | 74 | x <- grep("factor", as.character(x), value=TRUE, invert=TRUE) 75 | y <- grep("factor", as.character(y), value=TRUE, invert=TRUE) %||% NULL 76 | 77 | color <- grep("factor", as.character(color), value=TRUE, invert=TRUE) %||% NULL 78 | size <- grep("factor", as.character(size), value=TRUE, invert=TRUE) %||% NULL 79 | 80 | r_x <- gb$panel$ranges[[1]]$x.range 81 | r_y <- gb$panel$ranges[[1]]$y.range 82 | 83 | data <- gb$plot$data 84 | 85 | tc <- NULL 86 | 87 | if (plot_type=="line") { 88 | 89 | tau_guide_y( 90 | tau_guide_x( 91 | tau_line(tauchart(data), x=x, y=y, color=color, size=size), 92 | auto_scale=FALSE, label=gb$plot$labels$x, min=r_x[1], max=r_x[2]), 93 | auto_scale=FALSE, label=gb$plot$labels$y, min=r_y[1], max=r_y[2]) -> tc 94 | 95 | } else if (plot_type=="point") { 96 | 97 | tau_guide_y( 98 | tau_guide_x( 99 | tau_point(tauchart(data), x=x, y=y, color=color, size=size), 100 | auto_scale=FALSE, label=gb$plot$labels$x, min=r_x[1], max=r_x[2]), 101 | auto_scale=FALSE, label=gb$plot$labels$y, min=r_y[1], max=r_y[2]) -> tc 102 | 103 | } else if (plot_type=="bar") { 104 | 105 | tau_guide_y( 106 | tau_guide_x( 107 | tau_bar(tauchart(data), x=x, y=y, color=color, size=size), 108 | auto_scale=FALSE, label=gb$plot$labels$x, min=r_x[1], max=r_x[2]), 109 | auto_scale=FALSE, label=gb$plot$labels$y, min=r_y[1], max=r_y[2]) -> tc 110 | 111 | } else if (plot_type=="histogram") { 112 | 113 | data <- gb$data[[1]] 114 | x <- "x" 115 | y <- "y" 116 | 117 | tau_guide_y( 118 | tau_guide_x( 119 | tau_bar(tauchart(data), x=x, y=y, color=color, size=size), 120 | auto_scale=FALSE, label=gb$plot$labels$x, min=r_x[1], max=r_x[2]), 121 | auto_scale=FALSE, label=gb$plot$labels$y, min=r_y[1], max=r_y[2]) -> tc 122 | 123 | tc$x$dimensions$x$type <- "category" 124 | 125 | } else { 126 | stop("as_tauchart only works with geom_line, geom_point, geom_bar and geom_histogram", call.=FALSE) 127 | } 128 | 129 | if (!is.null(color) | !is.null(size)) tc <- tau_legend(tc) 130 | 131 | tc 132 | 133 | } 134 | 135 | -------------------------------------------------------------------------------- /R/colors.r: -------------------------------------------------------------------------------- 1 | #' Specify the colors used in the charts 2 | #' 3 | #' Vector can be optionally named in order to give explicit color/value mapping. 4 | #' 5 | #' @param tau taucharts object 6 | #' @param values vector of colors, ideally names (e.g. "\code{black}") or 7 | #' hex-format (e.g. "\code{#ffeeaa}") 8 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 9 | #' @export 10 | #' @examples 11 | #' tauchart(mtcars) %>% 12 | #' tau_point("wt", "mpg", color="cyl") %>% 13 | #' tau_color_manual(c("blue", "maroon", "black")) 14 | #' 15 | #' tauchart(mtcars) %>% 16 | #' tau_point("wt", "mpg", color="cyl") %>% 17 | #' tau_color_manual(c(`4`="blue",`6`= "maroon",`8`= "black")) 18 | tau_color_manual <- function(tau, values=NULL) { 19 | tau$x$dimensions[tau$x$color] <- "category" 20 | if (is.null(values)) return(tau) 21 | if(!is.null(names(values))) { 22 | tau$x$guide$color$brewer <- lapply(values,function(x) { 23 | rgb <- grDevices::col2rgb(x) 24 | sprintf("rgb(%d,%d,%d)",rgb[1],rgb[2],rgb[3]) 25 | }) 26 | return(tau) 27 | } 28 | eids <- lapply(1:length(values), function(i) { 29 | sprintf("tau-fill-%d-%s", i, 30 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 31 | tau$x$guide$color$brewer <- eids ; 32 | tau_add_css_rule(tau, c( 33 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 34 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 35 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 36 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 37 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 38 | )) 39 | } 40 | 41 | #' Use the ColorBrewer palette in the charts 42 | #' 43 | #' @param tau taucharts object 44 | #' @param n number of colors to generate (no checking is done to ensure the palette 45 | #' has \code{n} colors). 46 | #' @param palette ColorBrewer palette name. One of \code{"Set2"}, \code{"BrBG"}, 47 | #' \code{"PiYG"}, \code{"PRGn"}, \code{"PuOr"}, \code{"RdBu"}, \code{"RdGy"}, \code{"RdYlBu"}, 48 | #' \code{"RdYlGn"}, \code{"Spectral"}, \code{"Accent"}, \code{"Dark2"}, \code{"Paired"}, 49 | #' \code{"Pastel1"}, \code{"Pastel2"}, \code{"Set1"}, \code{"Set3"}, \code{"Blues"}, 50 | #' \code{"BuGn"}, \code{"BuPu"}, \code{"GnBu"}, \code{"Greens"}, \code{"Greys"}, \code{"Oranges"}, 51 | #' \code{"OrRd"}, \code{"PuBu"}, \code{"PuBuGn"}, \code{"PuRd"}, \code{"Purples"}, 52 | #' \code{"RdPu"}, \code{"Reds"}, \code{"YlGn"}, \code{"YlGnBu"}, \code{"YlOrBr"}, \code{"YlOrRd"}. 53 | #' @import RColorBrewer 54 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 55 | #' @export 56 | #' @note It is highly suggested that callers use the ColorBrewer qualitative palettes: 57 | #' ["Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set1", "Set2", "Set3"], 58 | #' especially if you are plotting categorical values (which you most liklely are 59 | #' since you're using this package). 60 | #' @examples 61 | #' tauchart(mtcars) %>% 62 | #' tau_point("wt", "mpg", color="cyl") %>% 63 | #' tau_color_brewer(3, "Set3") 64 | tau_color_brewer <- function(tau, n=NULL, palette="Set2") { 65 | tau$x$dimensions[tau$x$color] <- "category" 66 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 67 | values <- RColorBrewer::brewer.pal(n, palette) 68 | eids <- sapply(1:length(values), function(i) { 69 | sprintf("tau-fill-%d-%s", i, 70 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 71 | tau$x$guide$color$brewer <- eids ; 72 | tau_add_css_rule(tau, c( 73 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 74 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 75 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 76 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 77 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 78 | )) 79 | } 80 | 81 | 82 | #' Use the Tableau palette in the charts 83 | #' 84 | #' @param tau taucharts object 85 | #' @param palette Tableau palette name. One of \code{"tableau20"}, 86 | #' \code{"tableau10medium"}, \code{"gray5"}, \code{"colorblind10"}, 87 | #' \code{"purplegray12"}, \code{"bluered12"}, \code{"greenorange12"}, \code{"cyclic"}. 88 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 89 | #' @export 90 | #' @examples 91 | #' tauchart(mtcars) %>% 92 | #' tau_point("wt", "mpg", color="cyl") %>% 93 | #' tau_color_tableau() 94 | tau_color_tableau <- function(tau, palette="tableau20") { 95 | tau$x$dimensions[tau$x$color] <- "category" 96 | values <- tableau_colors(palette) 97 | eids <- sapply(1:length(values), function(i) { 98 | sprintf("tau-fill-%d-%s", i, 99 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 100 | tau$x$guide$color$brewer <- eids ; 101 | tau_add_css_rule(tau, c( 102 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 103 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 104 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 105 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 106 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 107 | )) 108 | } 109 | 110 | #' Use the "Economist" palette used in the charts 111 | #' 112 | #' The hues in the palette are blues, grays, and greens. Red is not included in 113 | #' these palettes and should be used to indicate important data. 114 | #' 115 | #' @param tau taucharts object 116 | #' @param n number of desired colors 117 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 118 | #' @export 119 | #' @seealso \code{\link[ggthemes]{economist_pal}} 120 | #' @examples 121 | #' tauchart(mtcars) %>% 122 | #' tau_point("wt", "mpg", color="cyl") %>% 123 | #' tau_color_economist() 124 | tau_color_economist <- function(tau, n=NULL) { 125 | tau$x$dimensions[tau$x$color] <- "category" 126 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 127 | values <- ggthemes::economist_pal()(n) 128 | eids <- sapply(1:length(values), function(i) { 129 | sprintf("tau-fill-%d-%s", i, 130 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 131 | tau$x$guide$color$brewer <- eids ; 132 | tau_add_css_rule(tau, c( 133 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 134 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 135 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 136 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 137 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 138 | )) 139 | } 140 | 141 | #' Use the "Few" palette used in the charts 142 | #' 143 | #' Qualitative color palettes from Stephen Few, "Practical Rules for Using Color in Charts". 144 | #' 145 | #' @param tau taucharts object 146 | #' @param n number of desired colors 147 | #' @param palette name of Few palette. One of \code{"medium"}, \code{"dark"} or \code{"light"} 148 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 149 | #' @export 150 | #' @seealso \code{\link[ggthemes]{few_pal}} 151 | #' @examples 152 | #' tauchart(mtcars) %>% 153 | #' tau_point("wt", "mpg", color="cyl") %>% 154 | #' tau_color_few() 155 | tau_color_few <- function(tau, n=NULL, palette="medium") { 156 | tau$x$dimensions[tau$x$color] <- "category" 157 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 158 | values <- ggthemes::few_pal(palette)(n) 159 | eids <- sapply(1:length(values), function(i) { 160 | sprintf("tau-fill-%d-%s", i, 161 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 162 | tau$x$guide$color$brewer <- eids ; 163 | tau_add_css_rule(tau, c( 164 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 165 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 166 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 167 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 168 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 169 | )) 170 | } 171 | 172 | 173 | #' Use the "fivethirtyeight.com" palette used in the charts 174 | #' 175 | #' The standard fivethirtyeight.com palette for line plots is blue, red, green. 176 | #' 177 | #' @param tau taucharts object 178 | #' @param n number of desired colors 179 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 180 | #' @export 181 | #' @seealso \code{\link[ggthemes]{fivethirtyeight_pal}} 182 | #' @examples 183 | #' tauchart(mtcars) %>% 184 | #' tau_point("wt", "mpg", color="cyl") %>% 185 | #' tau_color_538() 186 | tau_color_538 <- function(tau, n=NULL) { 187 | tau$x$dimensions[tau$x$color] <- "category" 188 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 189 | values <- ggthemes::fivethirtyeight_pal()(n) 190 | eids <- sapply(1:length(values), function(i) { 191 | sprintf("tau-fill-%d-%s", i, 192 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 193 | tau$x$guide$color$brewer <- eids ; 194 | tau_add_css_rule(tau, c( 195 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 196 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 197 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 198 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 199 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 200 | )) 201 | } 202 | 203 | #' Use the HighchartsJS palette used in the charts 204 | #' 205 | #' Qualitative color palettes from Stephen Few, "Practical Rules for Using Color in Charts". 206 | #' 207 | #' @param tau taucharts object 208 | #' @param n number of desired colors 209 | #' @param palette name of Few palette. One of \code{"default"} or \code{"darkunica"} 210 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 211 | #' @export 212 | #' @seealso \code{\link[ggthemes]{hc_pal}} 213 | #' @examples 214 | #' tauchart(mtcars) %>% 215 | #' tau_point("wt", "mpg", color="cyl") %>% 216 | #' tau_color_highcharts() 217 | tau_color_highcharts <- function(tau, n=NULL, palette="default") { 218 | tau$x$dimensions[tau$x$color] <- "category" 219 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 220 | values <- ggthemes::hc_pal(palette)(n) 221 | eids <- sapply(1:length(values), function(i) { 222 | sprintf("tau-fill-%d-%s", i, 223 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 224 | tau$x$guide$color$brewer <- eids ; 225 | tau_add_css_rule(tau, c( 226 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 227 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 228 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 229 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 230 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 231 | )) 232 | } 233 | 234 | 235 | #' Use the "Wall Street Journal" palette used in the charts 236 | #' 237 | #' A subset of the plethora of palettes used by the WSJ. 238 | #' 239 | #' @param tau taucharts object 240 | #' @param n number of desired colors 241 | #' @param palette name of Few palette. One of \code{"rgby"}, \code{"green_red"}, 242 | #' \code{"green_black"}, \code{"dem_rep"} or \code{"colors6"} 243 | #' @references \url{http://api.taucharts.com/advanced/encoding.html} 244 | #' @export 245 | #' @seealso \code{\link[ggthemes]{wsj_pal}} 246 | #' @examples 247 | #' tauchart(mtcars) %>% 248 | #' tau_point("wt", "mpg", color="cyl") %>% 249 | #' tau_color_wsj() 250 | tau_color_wsj <- function(tau, n=NULL, palette="rgby") { 251 | tau$x$dimensions[tau$x$color] <- "category" 252 | if (is.null(n)) n <- length(unique(tau$x$datasource[[tau$x$color]])) 253 | values <- ggthemes::wsj_pal(palette)(n) 254 | eids <- sapply(1:length(values), function(i) { 255 | sprintf("tau-fill-%d-%s", i, 256 | paste(sample(c(letters[1:6], 0:9), 6, replace=TRUE), collapse="")) }) 257 | tau$x$guide$color$brewer <- eids ; 258 | tau_add_css_rule(tau, c( 259 | sprintf("{{ID}} .%s { fill: %s; }", eids, values), 260 | sprintf("{{ID}} div .tau-chart__legend__guide.%s { background: %s; border: 1px solid %s; }", eids, values, values), 261 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__trendline.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 262 | sprintf("{{ID}} div .tau-chart__svg .tau-chart__line.%s { background: %s; border: 1px solid %s; stroke: %s; }", eids, values, values, values), 263 | sprintf("{{ID}} div .tau-chart__legend__item.disabled .tau-chart__legend__guide.%s { background: 0 0; background-color: transparent; }", eids, values, values) 264 | )) 265 | } 266 | -------------------------------------------------------------------------------- /R/datasets.r: -------------------------------------------------------------------------------- 1 | #' @title Automobile statistics from 1997-2013 2 | #' @description This dataset contains statistics on cars released from 1997 through 2013. 3 | #' It consists of a data.frame containing the columns: 4 | #' 5 | #' \itemize{ 6 | #' \item \code{vehicle}: Vehicle model. 7 | #' \item \code{year}: Year vehicle released. 8 | #' \item \code{date}: Price (new) of vehicle at release year (USD). 9 | #' \item \code{accelrate}: Vehicle acceleration rate. 10 | #' \item \code{milespergallon}: Vehicle MPG 11 | #' \item \code{class}: Vehicle class (according to U.S. driver's license code) 12 | #' } 13 | #' 14 | #' @docType data 15 | #' @keywords datasets 16 | #' @name cars_data 17 | #' @usage data(cars_data) 18 | #' @note Last updated 2015-08-04. 19 | #' @format A data frame with 135 rows and 7 variables 20 | #' @examples 21 | #' if (interactive()) { 22 | #' data(cars_data) 23 | #' tauchart(cars_data) %>% 24 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 25 | #' tau_legend() %>% 26 | #' tau_trendline() %>% 27 | #' tau_tooltip(c("vehicle", "year", "class", "price", "milespergallon")) 28 | #' } 29 | NULL 30 | -------------------------------------------------------------------------------- /R/fonts.r: -------------------------------------------------------------------------------- 1 | #' Set the font family for the TauCharts chart 2 | #' 3 | #' Set the font family (standard CSS \code{font-family} specification, comma-separated 4 | #' font names only) and an optional font CSS URL to load the font from. 5 | #' 6 | #' @param tau taucharts object 7 | #' @param family CSS \code{font-family} spec (just the comma-separated font names) 8 | #' @param import_url the \code{} href if the fonts come from an external source 9 | #' @return taucharts object 10 | #' @export 11 | #' @examples 12 | #' tauchart(mtcars) %>% 13 | #' tau_point("mpg", "wt", "cyl") %>% 14 | #' tau_legend() %>% 15 | #' tau_color_brewer() %>% 16 | #' tau_tooltip() %>% 17 | #' tau_set_font("Montserrat, sans-serif", 18 | #' "http://fonts.googleapis.com/css?family=Montserrat:400,700") 19 | tau_set_font <- function(tau, 20 | family="OpenSans, 'Helvetica Neue', Helvetica, Arial, sans-serif", 21 | import_url=paste0(c("https://fonts.googleapis.com/css?family=Open+Sans:400,", 22 | "400italic,600,700,600italic,700italic,800,300,300italic,800italic"), 23 | collapse="")) { 24 | 25 | if (!is.null(import_url)) tau$x$forFonts <- c(tau$x$forFonts, import_url) 26 | 27 | tau_add_css_rule(tau, sprintf("{{ID}} { font-family: %s }", family)) 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /R/geoms.r: -------------------------------------------------------------------------------- 1 | #' Create a TauCharts scatterplot 2 | #' 3 | #' @param tau taucharts object 4 | #' @param x quoted name of \code{data} column to use for x-axis values 5 | #' @param y quoted name of \code{data} column to use for y-axis values 6 | #' @param color quoted name of \code{data} column to map color aesthetic to 7 | #' @param size quoted name of \code{data} column to make size aesthetic to 8 | #' @references \url{http://api.taucharts.com/basic/scatterplot.html} 9 | #' @export 10 | #' @examples 11 | #' tauchart(mtcars) %>% tau_point("mpg", "wt") 12 | #' mtcars$cyl <- factor(mtcars$cyl) 13 | #' tauchart(mtcars) %>% tau_point("mpg", "wt", "cyl", "hp") 14 | tau_point <- function(tau, x, y, color=NULL, size=NULL) { 15 | tau$x$x <- x 16 | tau$x$y <- y 17 | tau$x$color <- color 18 | tau$x$size <- size 19 | tau$x$type <- "scatterplot" 20 | tau 21 | } 22 | 23 | #' Create a TauCharts box plot (horizontal or vertical) 24 | #' 25 | #' There is no option for color mappings as the tauCharts plugin does not support this yet. 26 | #' 27 | #' @param tau taucharts object 28 | #' @param x quoted name of \code{data} column to use for x-axis values 29 | #' @param y quoted name of \code{data} column to use for y-axis values 30 | #' @param horizontal should the bar chart be horizontal? (default: \code{FALSE} (no)) 31 | #' @param mode when to show scatter points? e.g. "hide-scatter", "show-scatter", "outliers-only" 32 | #' @export 33 | #' @examples 34 | #' tauchart(mtcars) %>% 35 | #' tau_boxplot("gear", "mpg", mode="hide-scatter") %>% 36 | #' tau_guide_y(nice=FALSE) 37 | tau_boxplot <- function(tau, x, y, horizontal=FALSE, mode="outliers-only") { 38 | tau$x$x <- x 39 | tau$x$y <- y 40 | tau$x$type <- "scatterplot" 41 | 42 | if (is.null(tau$x$plugins)){ 43 | tau$x$plugins = list() 44 | } 45 | 46 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 47 | type = "box-whiskers" 48 | ,settings = list( 49 | flip = horizontal, 50 | mode = `mode` 51 | ) 52 | ) 53 | 54 | tau 55 | } 56 | 57 | #' Create a TauCharts bar chart (horizontal or vertical) 58 | #' 59 | #' @param tau taucharts object 60 | #' @param x quoted name of \code{data} column to use for x-axis values 61 | #' @param y quoted name of \code{data} column to use for y-axis values 62 | #' @param color quoted name of \code{data} column to map color aesthetic to 63 | #' @param size quoted name of \code{data} column to make size aesthetic to 64 | #' @param horizontal should the bar chart be horizontal? (default: \code{FALSE} (no)) 65 | #' @references \url{http://api.taucharts.com/basic/line.html} 66 | #' @export 67 | #' @examples 68 | #' data(mpg, package="ggplot2") 69 | #' tauchart(dplyr::count(mpg, class)) %>% 70 | #' tau_bar("class", "n") 71 | #' 72 | #' # facets 73 | #' tauchart(dplyr::count(mpg, manufacturer, class)) %>% 74 | #' tau_bar("class", c("manufacturer", "n")) 75 | #' #facets 76 | #' mfclass <- dplyr::count(mpg, manufacturer, model, class) 77 | #' tauchart(mfclass) %>% 78 | #' tau_bar(c("manufacturer", "model"), "n") 79 | #' 80 | #' # ordered factors on x-axis 81 | #' mfclass$class <- factor(mfclass$class, 82 | #' levels=c("2seater", "subcompact", "compact", 83 | #' "midsize", "minivan", "suv", "pickup"), 84 | #' ordered=TRUE) 85 | #' tauchart(mfclass) %>% 86 | #' tau_bar(c("class", "manufacturer"), "n") 87 | tau_bar <- function(tau, x, y, color=NULL, size=NULL, horizontal=FALSE) { 88 | tau$x$x <- x 89 | tau$x$y <- y 90 | tau$x$color <- color 91 | tau$x$size <- size 92 | tau$x$type <- switch(as.character(horizontal), 93 | `TRUE`="horizontalBar", 94 | `FALSE`="bar") 95 | tau 96 | } 97 | 98 | #' Create a TauCharts stacked bar chart (experimental) 99 | #' 100 | #' The API supports it but it's not documented at all 101 | #' 102 | #' @param tau taucharts object 103 | #' @param x quoted name of \code{data} column to use for x-axis values 104 | #' @param y quoted name of \code{data} column to use for y-axis values 105 | #' @param color quoted name of \code{data} column to map color aesthetic to. 106 | #' NOTE that the parameter to this is what really defines the stacking. 107 | #' @param size quoted name of \code{data} column to make size aesthetic to 108 | #' @param horizontal should the bar chart be horizontal? (default: \code{FALSE} (no)) 109 | #' @references \url{http://api.taucharts.com/basic/line.html} 110 | #' @export 111 | #' @examples 112 | #' data(mpg, package="ggplot2") 113 | #' tauchart(dplyr::count(mpg, class, drv)) %>% 114 | #' tau_stacked_bar("class", "n", "drv") %>% 115 | #' tau_guide_gridlines(FALSE, FALSE) %>% 116 | #' tau_tooltip() 117 | tau_stacked_bar <- function(tau, x, y, color=NULL, size=NULL, horizontal=FALSE) { 118 | tau$x$x <- x 119 | tau$x$y <- y 120 | tau$x$color <- color 121 | tau$x$size <- size 122 | tau$x$type <- switch(as.character(horizontal), 123 | `TRUE`="horizontal-stacked-bar", 124 | `FALSE`="stacked-bar") 125 | tau 126 | } 127 | 128 | #' Create a TauCharts line chart 129 | #' 130 | #' @param tau taucharts object 131 | #' @param x quoted name of \code{data} column to use for x-axis values 132 | #' @param y quoted name of \code{data} column to use for y-axis values 133 | #' @param color quoted name of \code{data} column to map color aesthetic to 134 | #' @param size quoted name of \code{data} column to make size aesthetic to 135 | #' @references \url{http://api.taucharts.com/basic/bar.html}, 136 | #' \url{http://api.taucharts.com/basic/horizontal-bar.html} 137 | #' @export 138 | #' @examples 139 | #' data(economics, package="ggplot2") 140 | #' tauchart(economics) %>% 141 | #' tau_line("date", "unemploy") %>% 142 | #' tau_guide_x(tick_format="%Y") 143 | #' 144 | #' # facets 145 | #' library(dplyr) 146 | #' library(tidyr) 147 | #' 148 | #' crimes <- gather(add_rownames(USArrests, "State"), Crime, Amount, -State) 149 | #' tauchart(crimes) %>% 150 | #' tau_line("State", c("Crime", "Amount"), "Crime") %>% 151 | #' tau_guide_y(auto_scale = FALSE) 152 | tau_line <- function(tau, x, y, color=NULL, size=NULL) { 153 | tau$x$x <- x 154 | tau$x$y <- y 155 | tau$x$color <- color 156 | tau$x$size <- size 157 | tau$x$type <- "line" 158 | tau 159 | } 160 | 161 | #' Create a TauCharts area chart 162 | #' 163 | #' @param tau taucharts object 164 | #' @param x quoted name of \code{data} column to use for x-axis values 165 | #' @param y quoted name of \code{data} column to use for y-axis values 166 | #' @param color quoted name of \code{data} column to map color aesthetic to 167 | #' @references \url{http://api.taucharts.com/basic/bar.html}, 168 | #' \url{http://api.taucharts.com/basic/horizontal-bar.html} 169 | #' @export 170 | #' @examples 171 | #' data(economics, package="ggplot2") 172 | #' tauchart(economics) %>% 173 | #' tau_area("date", "unemploy") %>% 174 | #' tau_guide_x(tick_format="%Y") 175 | #' 176 | #' # facets 177 | #' library(dplyr) 178 | #' library(tidyr) 179 | #' 180 | #' crimes <- gather(add_rownames(USArrests, "State"), Crime, Amount, -State) 181 | #' tauchart(crimes) %>% 182 | #' tau_area("State", c("Crime", "Amount"), "Crime") %>% 183 | #' tau_guide_y(auto_scale = FALSE) 184 | tau_area <- function(tau, x, y, color=NULL) { 185 | tau$x$x <- x 186 | tau$x$y <- y 187 | tau$x$color <- color 188 | tau$x$type <- "area" 189 | tau 190 | } 191 | -------------------------------------------------------------------------------- /R/guides.r: -------------------------------------------------------------------------------- 1 | 2 | #' Set overall chart padding 3 | #' 4 | #' @param tau taucharts object 5 | #' @param bottom,top,left,right amount of padding 6 | #' @references \url{http://api.taucharts.com/basic/guide.html} 7 | #' @export 8 | #' @examples 9 | #' if (interactive()) { 10 | #' tauchart(mtcars) %>% 11 | #' tau_point("mpg", "wt") %>% 12 | #' tau_guide_padding(40, 40, 40, 40) 13 | #' } 14 | tau_guide_padding <- function(tau, bottom=0, left=0, top=0, right=0) { 15 | tau$x$guide$padding <- list(b=bottom, l=left, t=top, r=right) 16 | tau 17 | } 18 | 19 | #' Control showing of axis gridlines 20 | #' 21 | #' @param tau taucharts object 22 | #' @param show_x,show_y if \code{TRUE}, show the gridline 23 | #' @references \url{http://api.taucharts.com/basic/guide.html} 24 | #' @export 25 | #' @examples 26 | #' if (interactive()) { 27 | #' tauchart(mtcars) %>% 28 | #' tau_point("mpg", "wt") %>% 29 | #' tau_guide_gridlines(FALSE, FALSE) 30 | #' } 31 | tau_guide_gridlines <- function(tau, show_x=TRUE, show_y=TRUE) { 32 | tau$x$guide$showGridLines <- paste0(switch(as.character(show_x), 33 | `TRUE`="x", `FALSE`=""), 34 | switch(as.character(show_y), 35 | `TRUE`="y", `FALSE`="")) 36 | tau 37 | } 38 | 39 | #' Control x-axis padding, label, scale & tick format 40 | #' 41 | #' @param tau taucharts object 42 | #' @param padding space between axis ticks and chart panel 43 | #' @param label text of label for axis (overrides default use of variable name) 44 | #' @param label_padding space between axis ticks and axis label (can be negative) 45 | #' @param nice Taucharts engine tries to make axis scale "nice" by trying to start measure-based scale from 0 and adds some margins to complete scale with "nice" numbers. For example, if original scale domain contains values [8, 20, ... 40], then axis will have ticks from 0 to 45. 46 | #' (default: \code{TRUE}, if min and max values are set: \code{FALSE}). 47 | #' @param auto_scale (Deprecated) auto-pick "best" scale for axis? (default: \code{TRUE} (yes)) 48 | #' @param tick_period if axis is auto-determined to be a "period scale", 49 | #' this allows specification of the period size. See \code{References} for more 50 | #' information. 51 | #' @param tick_format can be any 52 | #' \href{https://github.com/mbostock/d3/wiki/Formatting#d3_format}{D3 format specifier} 53 | #' @param min,max manual minimum and maximum for the axis 54 | #' @references \url{http://api.taucharts.com/basic/guide.html}, 55 | #' \url{https://github.com/mbostock/d3/wiki/Formatting#d3_format} 56 | #' @export 57 | #' @examples 58 | #' if (interactive()) { 59 | #' tauchart(mtcars) %>% 60 | #' tau_point("mpg", "wt") %>% 61 | #' tau_guide_x(label="Miles/gallon", nice=FALSE) %>% 62 | #' tau_guide_y(label="Weight", nice=FALSE) 63 | #' } 64 | tau_guide_x <- function(tau, padding=NULL, 65 | label=NULL, label_padding=NULL, nice=NULL, 66 | auto_scale=NULL, tick_period=NULL, tick_format=NULL, 67 | min=NULL, max=NULL) { 68 | 69 | tau$x$guide$x$autoScale <- auto_scale %^^% tau[["x"]][["guide"]][["x"]][["autoScale"]] %^^% TRUE 70 | 71 | if (!is.null(label_padding)) tau$x$guide$x$label <- list(padding=label_padding) 72 | if (!is.null(label)) tau$x$guide$x$label$text <- label 73 | if (!is.null(tick_format)) tau$x$guide$x$tickFormat <- tick_format 74 | if (!is.null(tick_period)) tau$x$guide$x$tickPeriod <- tick_period 75 | if (!is.null(padding)) tau$x$guide$x$padding <- padding 76 | if (!is.null(min)) tau$x$guide$x$min <- min 77 | if (!is.null(max)) tau$x$guide$x$max <- max 78 | if (!is.null(nice)) tau$x$guide$x$nice <- nice 79 | else { 80 | if (!is.null(min) && !is.null(max)) tau$x$guide$x$nice <- FALSE 81 | else tau$x$guide$x$nice <- TRUE 82 | } 83 | 84 | tau 85 | } 86 | 87 | #' Control y-axis padding, label, scale & tick format 88 | #' 89 | #' @param tau taucharts object 90 | #' @param padding space between axis ticks and chart panel 91 | #' @param label text of label for axis (overrides default use of variable name) 92 | #' @param label_padding space between axis ticks and axis label (can be negative) 93 | #' @param nice Taucharts engine tries to make axis scale "nice" by trying to start measure-based scale from 0 and adds some margins to complete scale with "nice" numbers. For example, if original scale domain contains values [8, 20, ... 40], then axis will have ticks from 0 to 45. 94 | #' (default: \code{TRUE}, if min and max values are set: \code{FALSE}). 95 | #' @param auto_scale (Deprecated) auto-pick "best" scale for axis? (default: \code{TRUE} (yes)) 96 | #' @param tick_period if axis is auto-determined to be a "period scale", 97 | #' this allows specification of the period size. See \code{References} for more 98 | #' information. 99 | #' @param tick_format can be any 100 | #' \href{https://github.com/mbostock/d3/wiki/Formatting#d3_format}{D3 format specifier} 101 | #' @param min,max manual minimum and maximum for the axis 102 | #' @references \url{http://api.taucharts.com/basic/guide.html}, 103 | #' \url{https://github.com/mbostock/d3/wiki/Formatting#d3_format} 104 | #' @export 105 | #' @examples 106 | #' if (interactive()) { 107 | #' tauchart(mtcars) %>% 108 | #' tau_point("mpg", "wt") %>% 109 | #' tau_guide_x(label="Miles/gallon", nice=FALSE) %>% 110 | #' tau_guide_y(label="Weight", nice=FALSE) 111 | #' } 112 | tau_guide_y <- function(tau, padding=NULL, 113 | label=NULL, label_padding=NULL, nice=NULL, 114 | auto_scale=NULL, tick_period=NULL, tick_format=NULL, 115 | min=NULL, max=NULL) { 116 | 117 | tau$x$guide$x$autoScale <- auto_scale %^^% tau[["x"]][["guide"]][["y"]][["autoScale"]] %^^% TRUE 118 | 119 | if (!is.null(label_padding)) tau$x$guide$y$label <- list(padding=label_padding) 120 | if (!is.null(label)) tau$x$guide$y$label$text <- label 121 | if (!is.null(tick_format)) tau$x$guide$y$tickFormat <- tick_format 122 | if (!is.null(tick_period)) tau$x$guide$y$tickPeriod <- tick_period 123 | if (!is.null(padding)) tau$x$guide$y$padding <- padding 124 | if (!is.null(min)) tau$x$guide$y$min <- min 125 | if (!is.null(max)) tau$x$guide$y$max <- max 126 | if (!is.null(nice)) tau$x$guide$y$nice <- nice 127 | else { 128 | if (!is.null(min) && !is.null(max)) tau$x$guide$y$nice <- FALSE 129 | else tau$x$guide$y$nice <- TRUE 130 | } 131 | 132 | tau 133 | } 134 | -------------------------------------------------------------------------------- /R/plugins.R: -------------------------------------------------------------------------------- 1 | #' Add a TauCharts tooltip 2 | #' 3 | #' @param tau taucharts object 4 | #' @param fields character vector of fields to display in the tooltip 5 | #' (default is to use all columns in \code{data}) 6 | #' @param formatters a named list of options to format the tooltip values 7 | #' (see \url{https://api.taucharts.com/plugins/tooltip.html}) 8 | #' @seealso \code{\link{cars_data}} dataset 9 | #' @export 10 | #' @examples 11 | #' data(cars_data) 12 | #' tauchart(cars_data) %>% 13 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 14 | #' tau_tooltip(c("vehicle", "year", "class", "price", "milespergallon")) 15 | #' 16 | #' tauchart(cars_data) %>% 17 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 18 | #' tau_tooltip( 19 | #' fields = c("vehicle", "year", "class", "price", "milespergallon"), 20 | #' formatters = list( 21 | #' milespergallon = list(label = "Miles per Gallon"), 22 | #' price = list(format = "3f"), 23 | #' vehicle = list(format = htmlwidgets::JS( 24 | #' "function(str) { 25 | #' return str.toUpperCase(); 26 | #' }") 27 | #' ) 28 | #' ) 29 | #' ) 30 | tau_tooltip <- function(tau, fields = NULL, formatters = NULL) { 31 | 32 | if (is.null(fields)){ 33 | fields <- colnames(tau$x$datasource) 34 | } 35 | 36 | if (is.null(tau$x$plugins)){ 37 | tau$x$plugins = list() 38 | } 39 | 40 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 41 | type = "tooltip" 42 | ,fields = fields 43 | ,formatters = formatters 44 | ) 45 | 46 | tau 47 | } 48 | 49 | #' Add a TauCharts legend 50 | #' 51 | #' @param tau taucharts object 52 | #' @export 53 | #' @seealso \code{\link{cars_data}} dataset 54 | #' @examples 55 | #' data(cars_data) 56 | #' tauchart(cars_data) %>% 57 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 58 | #' tau_legend() 59 | tau_legend <- function(tau) { 60 | 61 | if (is.null(tau$x$color) & is.null(tau$x$size)) { 62 | message("Neither color nor size aesthetics have been mapped. Legend plugin will be active but not displayed.") 63 | } 64 | 65 | if(is.null(tau$x$plugins)){ 66 | tau$x$plugins = list() 67 | } 68 | 69 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 70 | type = "legend" 71 | ) 72 | 73 | tau 74 | } 75 | 76 | #' Add a TauCharts trendline 77 | #' 78 | #' @param tau taucharts object 79 | #' @param type \code{character} Model representing default trend line to show. Must be 80 | #' one of models specified in models parameter. 81 | #' If unspecified, will use the first model specified in models. 82 | #' 83 | #' @param hideError \code{logical} to show errors. 84 | #' @param showPanel \code{logical} to show the panel next to the chart to allow a user 85 | #' to manipulate the trendlines. When \code{FALSE}, the trendlines will 86 | #' still appear though. 87 | #' @param showTrend \code{logical} to show the trendlines on initial display. If 88 | #' \code{showPanel = TRUE}, then the user will have the opportunity 89 | #' to add/delete the trendlines. 90 | #' @param models \code{character} or \code{vector} of \code{characters} for the models 91 | #' to show in the trendline panel if \code{showPanel = TRUE}. If you 92 | #' would like to change the order of the options, then you can do 93 | #' \code{models = c("logarithmic","exponential")}, and the first provided 94 | #' will be the initial model type used. 95 | #' @seealso \code{\link{cars_data}} dataset 96 | #' @export 97 | #' @examples 98 | #' data(cars_data) 99 | #' tauchart(cars_data) %>% 100 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 101 | #' tau_trendline() 102 | tau_trendline <- function( 103 | tau, 104 | type = NULL, 105 | hideError = FALSE, 106 | showPanel = TRUE, 107 | showTrend = TRUE, 108 | models = c('linear', 'exponential', 'logarithmic', "loess", 109 | "lastvalue", "polynomial", "power") 110 | ) { 111 | if(is.null(type)) type <- models[1] 112 | if(!type %in% models) {message("Trendline `type` not included in `models`.")} 113 | if(is.null(tau$x$plugins)){ 114 | tau$x$plugins = list() 115 | } 116 | 117 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 118 | type = "trendline" 119 | ,settings = list( 120 | type = type, 121 | hideError = hideError, 122 | showPanel = showPanel, 123 | showTrend = showTrend, 124 | models = models 125 | ) 126 | ) 127 | 128 | tau 129 | } 130 | 131 | #' Add a TauCharts quick filter plugin 132 | #' 133 | #' @param tau taucharts object 134 | #' @param fields fields which should be shown in quick filter 135 | #' @seealso \code{\link{cars_data}} dataset 136 | #' @export 137 | #' @examples 138 | #' data(cars_data) 139 | #' tauchart(cars_data) %>% 140 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 141 | #' tau_quick_filter(fields = c("price")) 142 | tau_quick_filter <- function( 143 | tau, fields = NULL 144 | ) { 145 | 146 | if(is.null(tau$x$plugins)){ 147 | tau$x$plugins = list() 148 | } 149 | 150 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 151 | type = "quick-filter", 152 | fields = fields 153 | ) 154 | 155 | tau 156 | } 157 | 158 | #' Add a TauCharts export plugin 159 | #' 160 | #' @param tau taucharts object 161 | #' @seealso \code{\link{cars_data}} dataset 162 | #' @export 163 | #' @examples 164 | #' data(cars_data) 165 | #' tauchart(cars_data) %>% 166 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 167 | #' tau_export_plugin() 168 | tau_export_plugin <- function( 169 | tau 170 | ) { 171 | 172 | if(is.null(tau$x$plugins)){ 173 | tau$x$plugins = list() 174 | } 175 | 176 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 177 | type = "exportTo", 178 | cssPaths = list("lib/tauCharts-0.6.3/tauCharts.min.css") 179 | ) 180 | 181 | tau 182 | } 183 | 184 | #' Add a TauCharts annotations plugin 185 | #' 186 | #' @param tau taucharts object 187 | #' @param annotation_df a data frame with the following columns: 188 | #' dim: the data dimension to annotate (i.e. name of data column) 189 | #' val: the value (axis intercept) of the annotation 190 | #' text: the text to be displayed at the annotation 191 | #' front: if the annotation should be at in "front" of or "behind" the other data points 192 | #' color: hex color for annotation 193 | #' @seealso \code{\link{cars_data}} dataset 194 | #' @export 195 | #' @examples 196 | #' data(cars_data) 197 | #' tauchart(cars_data) %>% 198 | #' tau_point("milespergallon", c("class", "price"), color="class") %>% 199 | #' tau_annotations(data.frame(dim = "price", val = 50000, 200 | #' text = "Whoa there!", position = "front", 201 | #' color = '#4300FF')) 202 | 203 | tau_annotations <- function( 204 | tau, annotation_df 205 | ) { 206 | if(!all(colnames(annotation_df) %in% c("dim", "val", "text", "position", "color"))){ 207 | warning('Columns must be in c("dim", "val", "text", "position", "color")') 208 | } 209 | 210 | if(is.null(tau$x$plugins)){ 211 | tau$x$plugins = list() 212 | } 213 | 214 | # Date conversion 215 | annotation_df$val <- asISO8601Time(annotation_df$val, dateClasses) 216 | 217 | annotation_df$text <- as.character(annotation_df$text) 218 | if(!all(grepl("^#[[:alnum:]]{1,6}$", annotation_df$color))){ 219 | warning("All colors must be hex") 220 | } 221 | 222 | if(!all(annotation_df$dim %in% c("x", "y"))){ 223 | # warning("All dim must be either 'x' or 'y'") 224 | } 225 | 226 | tau$x$plugins[[length(tau$x$plugins) + 1]] = list( 227 | type = "annotations", 228 | items = annotation_df 229 | ) 230 | 231 | tau 232 | } 233 | -------------------------------------------------------------------------------- /R/rules.r: -------------------------------------------------------------------------------- 1 | #' Add a CSS rule to the rendered htmlwidget 2 | #' 3 | #' This function will add a CSS rule to a widget-created 4 | #' DOM stylesheet. \code{rule} should be a valid CSS rule as you 5 | #' would enter in a \code{} block. No checking is done 6 | #' to ensure validity. 7 | #' 8 | #' Use \code{\{\{ID\}\}} (followed by a space) to target the CSS rule 9 | #' just to the widget vs the whole DOM. 10 | #' 11 | #' Vectorized over \code{rule} 12 | #' 13 | #' @param tau taucharts object 14 | #' @param rule character vector of CSS rule(s) to add to the widget DOM 15 | #' @param warn show warnings for global CSS rules? (default: \code{TRUE}) 16 | #' @return taucharts htmlwidget object 17 | #' @note This is for expert use only. You need to know quite a bit about the visualization 18 | #' and target DOM to effectively use this function. CSS rules without the \code{\{\{ID\}\}} 19 | #' are applied to the entire DOM. 20 | #' @export 21 | #' @examples 22 | #' # change the default white tooltip to black 23 | #' 24 | #' if (interactive()) { 25 | #' make_black_tooltip <- function(tau) { 26 | #' tau %>% 27 | #' tau_add_css_rule( 28 | #' ".tau-chart__tooltip__gray-text { color: white; font-weight: bold; }") %>% 29 | #' tau_add_css_rule( 30 | #' ".tau-chart__tooltip__list__elem:first-child {color:white;font-weight:bold;}") %>% 31 | #' tau_add_css_rule( 32 | #' ".tau-chart__tooltip__exclude { color: white; }") %>% 33 | #' tau_add_css_rule( 34 | #' paste0(c(".tau-chart__tooltip__exclude:hover { color: #65717f; ", 35 | #' "background: linear-gradient(to right, rgba(255, 255, 255, 0) 100%, ", 36 | #' "rgba(235, 238, 241, 0.9) 0%); }"), collapse="\n")) %>% 37 | #' tau_add_css_rule(".tau-chart__tooltip { background: black; color: white; }") 38 | #' } 39 | #' 40 | #' tauchart(mtcars) %>% 41 | #' tau_point("wt", "mpg", color="cyl") %>% 42 | #' tau_color_manual(c("blue", "maroon", "black")) %>% 43 | #' tau_tooltip() %>% 44 | #' make_black_tooltip() 45 | #' } 46 | tau_add_css_rule <- function(tau, rule, warn=TRUE) { 47 | 48 | # if any of the CSS statements in 'rule' do not have {{ID}} targets, warn the user 49 | if (warn) { 50 | if (!any(grepl("\\{\\{ID\\}\\}", rule))) { 51 | # special case for the tooltip since that resides outsie the widget div 52 | # it has to be targeted globally unless the TauCharts folks change the behavior 53 | if (!all(grepl("tau-chart__tooltip", rule[which(!grepl("\\{\\{ID\\}\\}", rule))]))) { 54 | message("NOTE: CSS rules without {{ID}} are applied to the entire DOM.") 55 | } 56 | } 57 | } 58 | tau$x$forCSS <- c(tau$x$forCSS, rule) 59 | tau 60 | } 61 | -------------------------------------------------------------------------------- /R/shiny.r: -------------------------------------------------------------------------------- 1 | #' Run a built-in example Shiny app 2 | #' 3 | #' When run without specifying \code{app_name}, this function will return 4 | #' a list of built-in TauCharts Shiny example applications. To run one of the 5 | #' built-in example applications, specify only the name in the \code{app_name} 6 | #' parameter and the function will display the full path to the app (making it 7 | #' easier to find and view the source) and then execute the app. 8 | #' 9 | #' @param app_name name of built-in Shiny app to run (if \code{NULL} displays a list 10 | #' of built-in apps) 11 | #' @export 12 | #' @examples \dontrun{ 13 | #' # list the built-in apps 14 | #' 15 | #' run_tau_app() 16 | #' ## Available shiny example apps: 17 | #' ## ----------------------------- 18 | #' ## tau01 - TauCharts Shiny Example 01 19 | #' 20 | #' # run an app 21 | #' 22 | #' # run_tau_app("tau01") 23 | #' ## Running shiny app [tau01] from: 24 | # ## /Library/Frameworks/R.framework/Versions/3.2/Resources/library/taucharts/shinyapps/tau01 25 | # ## Listening on http://127.0.0.1:6077 26 | #' } 27 | run_tau_app <- function(app_name=NULL) { 28 | 29 | pkg_dir <- system.file(package="taucharts") 30 | 31 | if (is.null(app_name)) { 32 | 33 | cat("Available shiny example apps:\n") 34 | cat("-----------------------------\n") 35 | 36 | app_files <- list.files(pkg_dir, "ui.R", recursive=TRUE) 37 | invisible(sapply(app_files, function(x) { 38 | 39 | cat(gsub("^# META: ", "", 40 | grep("^# META:", readLines(paste0(pkg_dir, "/", x)), value=TRUE))) 41 | cat("\n") 42 | 43 | })) 44 | 45 | } else { 46 | 47 | app_dir <- sprintf("%s/shinyapps/%s", pkg_dir, app_name) 48 | if (file.exists(app_dir)) { 49 | message(paste0("Running shiny app [", app_name, "] from:\n ", app_dir)) 50 | shiny::runApp(app_dir) 51 | } else { 52 | message("Shiny example app not found.\nExecute run_tau_app() without parameters to see available shiny apps.") 53 | } 54 | } 55 | 56 | } 57 | 58 | #' Shiny bindings for taucharts 59 | #' 60 | #' Output and render functions for using taucharts within Shiny 61 | #' applications and interactive Rmd documents. 62 | #' 63 | #' @param outputId output variable to read from 64 | #' @param width,height Must be a valid CSS unit (like \code{'100\%'}, 65 | #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 66 | #' string and have \code{'px'} appended. 67 | #' @param expr An expression that generates a taucharts 68 | #' @param env The environment in which to evaluate \code{expr}. 69 | #' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This 70 | #' is useful if you want to save an expression in a variable. 71 | #' 72 | #' @name taucharts-shiny 73 | #' 74 | #' @export 75 | tauchartsOutput <- function(outputId, width = '100%', height = '400px'){ 76 | htmlwidgets::shinyWidgetOutput(outputId, 'taucharts', width, height, package = 'taucharts') 77 | } 78 | 79 | #' @rdname taucharts-shiny 80 | #' @export 81 | renderTaucharts <- function(expr, env = parent.frame(), quoted = FALSE) { 82 | if (!quoted) { expr <- substitute(expr) } # force quoted 83 | htmlwidgets::shinyRenderWidget(expr, tauchartsOutput, env, quoted = TRUE) 84 | } 85 | -------------------------------------------------------------------------------- /R/tasks.r: -------------------------------------------------------------------------------- 1 | #' Add post-render JavaScript tasks to taucharts 2 | #' 3 | #' @param tau taucharts object 4 | #' @param task either a \code{character} or \code{\link[htmlwidgets]{JS}} 5 | #' representing a JavaScript function to run after a tauchart has 6 | #' been rendered. This provides the ability for advanced customization. 7 | #' The JavaScript function will be \code{call}ed so \code{this.el} will be 8 | #' the containing \code{div} element and \code{this.chart} will be the 9 | #' \code{taucharts} object. 10 | #' 11 | #' @importFrom htmlwidgets JS 12 | #' @export 13 | #' @examples 14 | #' if (interactive()) { 15 | #' tauchart(mtcars) %>% 16 | #' tau_point("mpg", "wt") %>% 17 | #' tau_tasks("function(){alert('I drew a chart')}") %>% 18 | #' tau_tasks(htmlwidgets::JS( 19 | #' "function(){alert('Yep, I really did.')}" 20 | #' )) %>% 21 | #' tau_tasks( 22 | #' " 23 | #' function(){ 24 | #' d3.select(this.el).selectAll('.tau-chart__dot') 25 | #' .transition().style('opacity',0.1) 26 | #' .transition().style('opacity',0.9) 27 | #' .transition().style('opacity',0.1) 28 | #' .transition().style('opacity',0.9); 29 | #' } 30 | #' " 31 | #' ) 32 | #' } 33 | tau_tasks <- function ( tau, task = NULL ){ 34 | if(is.null(task)) stop("please provide a non-NULL task.", call. = FALSE) 35 | 36 | if(is.null(tau$x$tasks)){ 37 | tau$x$tasks <- list() 38 | } 39 | 40 | if(!inherits(task,"JS_EVAL")){ 41 | # convert to htmlwidgets::JS if just a character 42 | task <- htmlwidgets::JS( task ) 43 | } 44 | 45 | tau$x$tasks[[length(tau$x$tasks) + 1]] <- task 46 | 47 | tau 48 | } 49 | -------------------------------------------------------------------------------- /R/taucharts-package.r: -------------------------------------------------------------------------------- 1 | #' An \code{htmlwidget} interface to the 2 | #' \href{http://www.taucharts.com/}{TauCharts} D3 chart library 3 | #' @name taucharts 4 | #' @docType package 5 | #' @author Bob Rudis (@@hrbrmstr), Kent Russell (@@timelyportfolio) 6 | #' @import htmltools 7 | #' @importFrom zoo index 8 | NULL 9 | 10 | #' taucharts exported operators 11 | #' 12 | #' The following functions are imported and then re-exported 13 | #' from the taucharts package to enable use of the magrittr 14 | #' pipe operator with no additional library calls 15 | #' 16 | #' @name taucharts-exports 17 | NULL 18 | 19 | #' @importFrom magrittr %>% 20 | #' @name %>% 21 | #' @export 22 | #' @rdname taucharts-exports 23 | NULL 24 | 25 | #' @importFrom htmlwidgets JS 26 | #' @name JS 27 | #' @export 28 | #' @rdname taucharts-exports 29 | NULL 30 | -------------------------------------------------------------------------------- /R/taucharts.R: -------------------------------------------------------------------------------- 1 | #' Create a new TauChart 2 | #' 3 | #' Performs basic widget setup and returns an object suitable for 4 | #' use with the other \code{tau_} functions. 5 | #' 6 | #' @param data \code{data.frame}-like or \code{xts} object 7 | #' @param width,height Must be a valid CSS unit (like \code{'100\%'}, 8 | #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 9 | #' string and have \code{'px'} appended. 10 | #' @param inputId the input slot used to access the clicked point (for Shiny). 11 | #' @references \url{http://api.taucharts.com/} 12 | #' @export 13 | #' @examples 14 | #' tauchart(mtcars) %>% tau_point("mpg", "wt") 15 | tauchart <- function(data, width = NULL, height = NULL, inputId = NULL) { 16 | 17 | # try to accomodate xts objects 18 | # but this will require a dependency on xts 19 | if( inherits( data, "xts" ) ){ 20 | data <- data.frame( 21 | "Date" = zoo::index(data) 22 | ,as.data.frame(data) 23 | ,stringsAsFactors = FALSE 24 | ) 25 | } 26 | 27 | # this takes care of silly tbl_df/tbl_dt/data.table issues 28 | data <- data.frame(data) 29 | 30 | # try to determine the associated tau-type based on 31 | # column type/class. 32 | # 33 | # TODO: this is far from robust. amongst other things 34 | # it should figure out the date/time better if a character 35 | # and it should add the ordering of ordered factors 36 | 37 | dimensions <- lapply(data, function(v) { 38 | # if factor handle separately 39 | if(inherits(v, "factor")) { 40 | if(inherits(v, "ordered")){ 41 | list(type = "order", order = levels(v) ) 42 | } else { 43 | list(type = "category") 44 | } 45 | } else if(inherits(v, dateClasses)) { 46 | # some crude handling of dates 47 | list( type = "order", scale = "time" ) 48 | } else { 49 | list(`type` = 50 | switch(typeof(v), 51 | double= "measure", 52 | integer="measure", 53 | logical="category", 54 | character="category", 55 | "measure") 56 | ) 57 | 58 | } 59 | 60 | }) 61 | 62 | # try to handle dates smoothly between JS and R 63 | # this is very much a work in progress 64 | for (i in 1:ncol(data)) { 65 | data[, i] <- asISO8601Time(data[, i], dateClasses) 66 | } 67 | 68 | # forward options using x 69 | x <- list( 70 | datasource=data, 71 | dimensions=dimensions, 72 | x=NULL, 73 | y=NULL, 74 | padding=NULL, 75 | guide=list(x=NULL, y=NULL, padding=NULL, color=NULL), 76 | input=inputId, 77 | forCSS=NULL, 78 | forFonts="https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600&subset=latin,cyrillic-ext" 79 | ) 80 | 81 | 82 | eid <- sprintf("tau-%s", 83 | paste(sample(c(letters[1:6], 0:9), 30, replace=TRUE), collapse="")) 84 | 85 | 86 | # create widget 87 | htmlwidgets::createWidget( 88 | name = 'taucharts', 89 | x=x, 90 | width = width, 91 | height = height, 92 | sizingPolicy = htmlwidgets::sizingPolicy(), 93 | package = 'taucharts', 94 | elementId = eid 95 | ) 96 | } 97 | -------------------------------------------------------------------------------- /R/title.r: -------------------------------------------------------------------------------- 1 | #' Add a title to the tauchart plot 2 | #' 3 | #' This provides a hack-ish way to add a title to a tauchart. Heed the 4 | #' warning in \code{return} well. This is the last function you should use 5 | #' when building a \code{tauchart}.\cr 6 | #' \cr 7 | #' In interactive sessions this function uses \code{htmltools::html_print} to 8 | #' display the chart with title, otherwise it just returns the \code{shiny.tag}- 9 | #' classed object since that works well in R Markdown documents.\cr 10 | #' \cr 11 | #' This is most certainly a temporary hack. 12 | #' 13 | #' @param tau taucharts object 14 | #' @param title title for the chart 15 | #' @param div_css style to apply to the surrounding \code{div}. You should probably set 16 | #' the width here. 17 | #' @param span_css CSS style to apply to the title \code{span}. The default is to center-align 18 | #' the text and using a bold font. Go. Crazy. 19 | #' Not tested in a Shiny context yet 20 | #' @return THIS DOES NOT RETURN AN \code{htmlwidget}!! It returns a \code{shiny.tag} 21 | #' class HTML (the widget is wrapped in a \code{
}). It should be the LAST 22 | #' call in a magrittr pipe chain or called to wrap a streamgraph object for 23 | #' output 24 | #' @export 25 | #' @examples 26 | #' tauchart(mtcars) %>% 27 | #' tau_point("mpg", "wt") %>% 28 | #' tau_guide_y(auto_scale=FALSE) %>% 29 | #' tau_title("Some Really Good Plot Title", 30 | #' "font-weight:bold;margin:auto;text-align:center;font-size:24px; 31 | #' color:#7f7f7f;font-family:sans-serif") 32 | #' 33 | #' tauchart(mtcars) %>% 34 | #' tau_point("mpg", "wt") %>% 35 | #' tau_guide_y(auto_scale=FALSE) %>% 36 | #' tau_title("Some Really Good Plot Title", 37 | #' "font-weight:bold;margin:auto;text-align:right;font-size:24px; 38 | #' color:#7f7f7f;font-family:sans-serif") 39 | #' 40 | #' tauchart(mtcars, width="500px") %>% 41 | #' tau_point("mpg", "wt") %>% 42 | #' tau_guide_y(auto_scale=FALSE) %>% 43 | #' tau_title("Some Really Good Plot Title", 44 | #' "width:500px;font-weight:bold;margin:auto;text-align:left; 45 | #' font-size:24px;color:#7f7f7f;font-family:sans-serif") 46 | tau_title <- function(tau, title="", 47 | div_css="width:100%", 48 | span_css="font-weight:bold;margin:auto;text-align:center") { 49 | plot_with_title <- div(style=div_css, span(style=span_css, title), br(), tau) 50 | if (interactive()) return(html_print(plot_with_title)) 51 | return(plot_with_title) 52 | } 53 | -------------------------------------------------------------------------------- /R/utils.r: -------------------------------------------------------------------------------- 1 | noathenb <- function(a, b) { 2 | if (length(a) > 0) a else b 3 | } 4 | 5 | "%||%" <- noathenb 6 | 7 | naathenb <- function(a, b) { 8 | if (length(a) > 0) { 9 | if (!is.na(a)) a else b 10 | } else { 11 | b 12 | } 13 | } 14 | 15 | "%^^%" <- naathenb 16 | 17 | brewers <- c("BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", 18 | "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", 19 | "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", 20 | "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", 21 | "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd") 22 | 23 | # Currently supported date classes: 24 | dateClasses <- c("Date", "POSIXct", "date", "yearmon", "yearqtr") 25 | 26 | # from rstudio/dygraphs https://github.com/rstudio/dygraphs 27 | asISO8601Time <- function(x, dateClasses) { 28 | if (inherits(x, dateClasses)) { 29 | x <- try({ as.POSIXct(x, tz = "GMT") }) 30 | # if posix conversion worked 31 | if (inherits(x, "POSIXct")) { 32 | format(x, format="%04Y-%m-%dT%H:%M:%SZ", tz='GMT') 33 | } else { 34 | warning("Date conversion to ISO8601 failed. Classes ", 35 | paste(dateClasses, ", "), " are supported.") 36 | } 37 | } else { return(x) } 38 | } 39 | 40 | 41 | tableau_colors <- function(palette="tableau20") { 42 | 43 | x <- list( 44 | tableau20 = 45 | c("#1F77B4", "#AEC7E8", "#FF7F0E", "#FFBB78", "#2CA02C", "#98DF8A", 46 | "#D62728", "#FF9896", "#9467BD", "#C5B0D5", "#8C564B", "#C49C94", 47 | "#E377C2", "#F7B6D2", "#7F7F7F", "#C7C7C7", "#BCBD22", "#DBDB8D", 48 | "#17BECF", "#9EDAE5"), 49 | ## Tablau10 are odd, Tableau10-light are even 50 | tableau10medium = 51 | c("#729ECE", "#FF9E4A", "#67BF5C", "#ED665D", "#AD8BC9", "#A8786E", 52 | "#ED97CA", "#A2A2A2", "#CDCC5D", "#6DCCDA"), 53 | gray5 = 54 | c("#60636A", "#A5ACAF", "#414451", "#8F8782", "#CFCFCF"), 55 | colorblind10 = 56 | c("#006BA4", "#FF800E", "#ABABAB", "#595959", "#5F9ED1", "#C85200", 57 | "#898989", "#A2C8EC", "#FFBC79", "#CFCFCF"), 58 | trafficlight = 59 | c("#B10318", "#DBA13A", "#309343", "#D82526", "#FFC156", "#69B764", 60 | "#F26C64", "#FFDD71", "#9FCD99"), 61 | purplegray12 = 62 | c("#7B66D2", "#A699E8", "#DC5FBD", "#FFC0DA", "#5F5A41", "#B4B19B", 63 | "#995688", "#D898BA", "#AB6AD5", "#D098EE", "#8B7C6E", "#DBD4C5"), 64 | ## purplegray6 is oddd 65 | bluered12 = 66 | c("#2C69B0", "#B5C8E2", "#F02720", "#FFB6B0", "#AC613C", "#E9C39B", 67 | "#6BA3D6", "#B5DFFD", "#AC8763", "#DDC9B4", "#BD0A36", "#F4737A"), 68 | ## bluered6 is odd 69 | greenorange12 = 70 | c("#32A251", "#ACD98D", "#FF7F0F", "#FFB977", "#3CB7CC", "#98D9E4", 71 | "#B85A0D", "#FFD94A", "#39737C", "#86B4A9", "#82853B", "#CCC94D"), 72 | ## greenorange6 is odd 73 | cyclic = 74 | c("#1F83B4", "#1696AC", "#18A188", "#29A03C", "#54A338", "#82A93F", 75 | "#ADB828", "#D8BD35", "#FFBD4C", "#FFB022", "#FF9C0E", "#FF810E", 76 | "#E75727", "#D23E4E", "#C94D8C", "#C04AA7", "#B446B3", "#9658B1", 77 | "#8061B4", "#6F63BB") 78 | ) 79 | 80 | x[[palette]] 81 | } 82 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | md_document: 4 | variant: gfm 5 | --- 6 | 7 | 8 | 9 | ```{r, echo = FALSE} 10 | knitr::opts_chunk$set( 11 | collapse = TRUE, 12 | comment = "#>", 13 | fig.path = "README-" 14 | ) 15 | ``` 16 | 17 | taucharts is an R htmlwidget interface to the TauCharts javascript library 18 | 19 | Take a look at the [TODO list](https://github.com/hrbrmstr/taucharts/issues/1) and chip in! 20 | 21 | Right now, you can make & customize (including manual color scales & ordered factors + legends + tooltips + trendlines): 22 | 23 | - scatterplots 24 | - scatterplot matrices 25 | - line charts 26 | - bar charts (veritical, horizontal & stacked) 27 | 28 | Composite plots are on the road map for support but not in the R package yet. 29 | 30 | Have a look [on RPubs](http://rpubs.com/hrbrmstr/taucharts) to see what `taucharts` can do! 31 | 32 | The following functions are implemented: 33 | 34 | - `tauchart`: Create a new TauChart 35 | - `tau_line`: Create a TauCharts line chart 36 | - `tau_point`: Create a TauCharts scatterplot 37 | - `tau_bar`: Create a TauCharts bar chart (horizontal or vertical) 38 | - `tau_stacked_bar`: Create a TauCharts stacked bar chart (veritcal only) 39 | - `tau_guide_gridlines`: Control showing of axis gridlines 40 | - `tau_guide_padding`: Set overall chart padding 41 | - `tau_guide_x`: Control x-axis padding, label, scale & tick format 42 | - `tau_guide_y`: Control y-axis padding, label, scale & tick format 43 | - `tau_legend`: Add a TauCharts legend 44 | - `tau_tooltip`: Add a TauCharts tooltip 45 | - `tau_trendline`: Add a TauCharts trendline 46 | - `run_tau_app`: Run a built-in example Shiny app 47 | - `tau_tasks`: Add post-render JavaScript tasks to taucharts 48 | - `tau_add_css_rule`: Add a CSS rule to the rendered htmlwidget 49 | - `tau_set_font`: Set `font-family` for the chart 50 | - `as_tauchart`: Turn a simple (single-geom) ggplot plot into an tauchart object 51 | - `tau_title`: Add a title to the tauchart plot 52 | 53 | with many color palette options: 54 | 55 | - `tau_color_manual`: Specify the colors used in the charts 56 | - `tau_color_brewer`: Use the ColorBrewer palette in the charts 57 | - `tau_color_economist`: Use the "Economist" palette used in the charts 58 | - `tau_color_few`: Use the "Few" palette used in the charts 59 | - `tau_color_highcharts`: Use the HighchartsJS palette used in the charts 60 | - `tau_color_manual`: Specify the colors used in the charts 61 | - `tau_color_tableau`: Use the Tableau palette in the charts 62 | - `tau_color_wsj`: Use the "Wall Street Journal" palette used in the charts 63 | 64 | The following datasets are included: 65 | 66 | - `cars_data`: statistics on cars released from 1997 through 2013 (a data frame with 135 rows and 7 variables) 67 | 68 | ### News 69 | 70 | - Version 0.4.5 released : Shiny click events, color themes for faceted charts, updated TauCharts JS lib 71 | - Version 0.4.4.9000 released : `tau_title` 72 | - Version 0.4.3.9000 released : minor issue with guides 73 | - Version 0.4.2.9000 released : pre-CRAN flight check 74 | - Version 0.4.0.9000 released : added `as_tauchart` & updated TauCharts JS lib 75 | - Version 0.3.4.9000 released : added warning for global targeted CSS rules and font ref fix thx to @jlewis91 76 | - Version 0.3.3.9001 released : fix for custom colors and `tau_line` 77 | - Version 0.3.3 released : custom font for chart (`?tau_set_font`) 78 | - Version 0.3.2 released : custom colors working in legend & trendlines 79 | - Version 0.3.1 released : removed R 3.2.0 dependency (removed the dependent code) 80 | - Version 0.3.0 released : color palettes galore! 81 | - Version 0.3.0.9000 released : `?tau_add_css_rule` (add CSS rules to a chart) 82 | - Version 0.2.6.9000 released : `?tau_tasks` (add JavaScript to a chart) 83 | - Version 0.2.5.9000 released : list & run example Shiny apps - see `?run_tau_app` for more info 84 | - Version 0.2.5.9000 released : stacked bar charts 85 | - Version 0.1.0 released : trendline, tooltips & dev fork (prod is pretty much stable & functional) 86 | - Version 0.0.1.9003 released : facet-based ordering + legends 87 | - Version 0.0.1.9000 released : auto-detects column classes, can add manual colors & faceted plots are now working (see the Rpub for an example) 88 | - Version 0.0.0.9000 released 89 | 90 | ### Installation 91 | 92 | ```{r eval=FALSE} 93 | devtools::install_github("hrbrmstr/taucharts") 94 | ``` 95 | 96 | ### Usage 97 | 98 | ```{r} 99 | library(taucharts) 100 | 101 | # current verison 102 | packageVersion("taucharts") 103 | 104 | ``` 105 | 106 | ### Test Results 107 | 108 | ```{r} 109 | library(testthat) 110 | date() 111 | 112 | test_dir("tests/testthat", reporter = SummaryReporter) 113 | ``` 114 | 115 | ### Code of Conduct 116 | 117 | Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). 118 | By participating in this project you agree to abide by its terms. 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | taucharts is an R htmlwidget interface to the TauCharts javascript 4 | library 5 | 6 | Take a look at the [TODO 7 | list](https://github.com/hrbrmstr/taucharts/issues/1) and chip in\! 8 | 9 | Right now, you can make & customize (including manual color scales & 10 | ordered factors + legends + tooltips + trendlines): 11 | 12 | - scatterplots 13 | - scatterplot matrices 14 | - line charts 15 | - bar charts (veritical, horizontal & stacked) 16 | 17 | Composite plots are on the road map for support but not in the R package 18 | yet. 19 | 20 | Have a look [on RPubs](http://rpubs.com/hrbrmstr/taucharts) to see what 21 | `taucharts` can do\! 22 | 23 | The following functions are implemented: 24 | 25 | - `tauchart`: Create a new TauChart 26 | - `tau_line`: Create a TauCharts line chart 27 | - `tau_point`: Create a TauCharts scatterplot 28 | - `tau_bar`: Create a TauCharts bar chart (horizontal or vertical) 29 | - `tau_stacked_bar`: Create a TauCharts stacked bar chart (veritcal 30 | only) 31 | - `tau_guide_gridlines`: Control showing of axis gridlines 32 | - `tau_guide_padding`: Set overall chart padding 33 | - `tau_guide_x`: Control x-axis padding, label, scale & tick format 34 | - `tau_guide_y`: Control y-axis padding, label, scale & tick format 35 | - `tau_legend`: Add a TauCharts legend 36 | - `tau_tooltip`: Add a TauCharts tooltip 37 | - `tau_trendline`: Add a TauCharts trendline 38 | - `run_tau_app`: Run a built-in example Shiny app 39 | - `tau_tasks`: Add post-render JavaScript tasks to taucharts 40 | - `tau_add_css_rule`: Add a CSS rule to the rendered htmlwidget 41 | - `tau_set_font`: Set `font-family` for the chart 42 | - `as_tauchart`: Turn a simple (single-geom) ggplot plot into an 43 | tauchart object 44 | - `tau_title`: Add a title to the tauchart plot 45 | 46 | with many color palette options: 47 | 48 | - `tau_color_manual`: Specify the colors used in the charts 49 | - `tau_color_brewer`: Use the ColorBrewer palette in the charts 50 | - `tau_color_economist`: Use the “Economist” palette used in the 51 | charts 52 | - `tau_color_few`: Use the “Few” palette used in the charts 53 | - `tau_color_highcharts`: Use the HighchartsJS palette used in the 54 | charts 55 | - `tau_color_manual`: Specify the colors used in the charts 56 | - `tau_color_tableau`: Use the Tableau palette in the charts 57 | - `tau_color_wsj`: Use the “Wall Street Journal” palette used in the 58 | charts 59 | 60 | The following datasets are included: 61 | 62 | - `cars_data`: statistics on cars released from 1997 through 2013 (a 63 | data frame with 135 rows and 7 variables) 64 | 65 | ### News 66 | 67 | - Version 0.4.5 released : Shiny click events, color themes for 68 | faceted charts, updated TauCharts JS lib 69 | - Version 0.4.4.9000 released : `tau_title` 70 | - Version 0.4.3.9000 released : minor issue with guides 71 | - Version 0.4.2.9000 released : pre-CRAN flight check 72 | - Version 0.4.0.9000 released : added `as_tauchart` & updated 73 | TauCharts JS lib 74 | - Version 0.3.4.9000 released : added warning for global targeted CSS 75 | rules and font ref fix thx to @jlewis91 76 | - Version 0.3.3.9001 released : fix for custom colors and `tau_line` 77 | - Version 0.3.3 released : custom font for chart (`?tau_set_font`) 78 | - Version 0.3.2 released : custom colors working in legend & 79 | trendlines 80 | - Version 0.3.1 released : removed R 3.2.0 dependency (removed the 81 | dependent code) 82 | - Version 0.3.0 released : color palettes galore\! 83 | - Version 0.3.0.9000 released : `?tau_add_css_rule` (add CSS rules to 84 | a chart) 85 | - Version 0.2.6.9000 released : `?tau_tasks` (add JavaScript to a 86 | chart) 87 | - Version 0.2.5.9000 released : list & run example Shiny apps - see 88 | `?run_tau_app` for more info 89 | - Version 0.2.5.9000 released : stacked bar charts 90 | - Version 0.1.0 released : trendline, tooltips & dev fork (prod is 91 | pretty much stable & functional) 92 | - Version 0.0.1.9003 released : facet-based ordering + legends 93 | - Version 0.0.1.9000 released : auto-detects column classes, can add 94 | manual colors & faceted plots are now working (see the Rpub for an 95 | example) 96 | - Version 0.0.0.9000 released 97 | 98 | ### Installation 99 | 100 | ``` r 101 | devtools::install_github("hrbrmstr/taucharts") 102 | ``` 103 | 104 | ### Usage 105 | 106 | ``` r 107 | library(taucharts) 108 | 109 | # current verison 110 | packageVersion("taucharts") 111 | #> [1] '0.4.5' 112 | ``` 113 | 114 | ### Test Results 115 | 116 | ``` r 117 | library(testthat) 118 | date() 119 | #> [1] "Fri May 11 00:02:12 2018" 120 | 121 | test_dir("tests/testthat", reporter = SummaryReporter) 122 | #> basic functionality: S 123 | #> 124 | #> ══ Skipped ════════════════════════════════════════════════════════════════════════════ 125 | #> 1. we can do something (@test-taucharts.R#2) - Empty test 126 | #> 127 | #> ══ DONE ═══════════════════════════════════════════════════════════════════════════════ 128 | ``` 129 | 130 | ### Code of Conduct 131 | 132 | Please note that this project is released with a [Contributor Code of 133 | Conduct](CONDUCT.md). By participating in this project you agree to 134 | abide by its terms. 135 | -------------------------------------------------------------------------------- /data/cars_data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrbrmstr/taucharts/93dbdce5fc6b856b0cee60a9349f4fdfcf42d164/data/cars_data.rda -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3/.gitattributes: -------------------------------------------------------------------------------- 1 | bower.json -diff merge=ours 2 | component.json -diff merge=ours 3 | d3.js -diff merge=ours 4 | d3.min.js -diff merge=ours 5 | package.js -diff merge=ours 6 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010-2017 Mike Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of contributors may be used to 15 | endorse or promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3/README.md: -------------------------------------------------------------------------------- 1 | # D3: Data-Driven Documents 2 | 3 | 4 | 5 | **D3** (or **D3.js**) is a JavaScript library for visualizing data using web standards. D3 helps you bring data to life using SVG, Canvas and HTML. D3 combines powerful visualization and interaction techniques with a data-driven approach to DOM manipulation, giving you the full capabilities of modern browsers and the freedom to design the right visual interface for your data. 6 | 7 | ## Resources 8 | 9 | * [API Reference](https://github.com/d3/d3/blob/master/API.md) 10 | * [Release Notes](https://github.com/d3/d3/releases) 11 | * [Gallery](https://github.com/d3/d3/wiki/Gallery) 12 | * [Examples](https://bl.ocks.org/mbostock) 13 | * [Wiki](https://github.com/d3/d3/wiki) 14 | 15 | ## Installing 16 | 17 | If you use npm, `npm install d3`. Otherwise, download the [latest release](https://github.com/d3/d3/releases/latest). The released bundle supports anonymous AMD, CommonJS, and vanilla environments. You can load directly from [d3js.org](https://d3js.org), [CDNJS](https://cdnjs.com/libraries/d3), or [unpkg](https://unpkg.com/d3/). For example: 18 | 19 | ```html 20 | 21 | ``` 22 | 23 | For the minified version: 24 | 25 | ```html 26 | 27 | ``` 28 | 29 | You can also use the standalone D3 microlibraries. For example, [d3-selection](https://github.com/d3/d3-selection): 30 | 31 | ```html 32 | 33 | ``` 34 | 35 | D3 is written using [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html). Create a [custom bundle using Rollup](https://bl.ocks.org/mbostock/bb09af4c39c79cffcde4), Webpack, or your preferred bundler. To import D3 into an ES2015 application, either import specific symbols from specific D3 modules: 36 | 37 | ```js 38 | import {scaleLinear} from "d3-scale"; 39 | ``` 40 | 41 | Or import everything into a namespace (here, `d3`): 42 | 43 | ```js 44 | import * as d3 from "d3"; 45 | ``` 46 | 47 | In Node: 48 | 49 | ```js 50 | var d3 = require("d3"); 51 | ``` 52 | 53 | You can also require individual modules and combine them into a `d3` object using [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign): 54 | 55 | ```js 56 | var d3 = Object.assign({}, require("d3-format"), require("d3-geo"), require("d3-geo-projection")); 57 | ``` 58 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/taucharts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Targetprocess, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/taucharts/tauCharts.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * /* 3 | * taucharts@2.2.1 (2018-05-04) 4 | * Copyright 2018 Targetprocess, Inc. 5 | * Licensed under Apache License 2.0 6 | * * / 7 | * 8 | */ 9 | .tau-chart__layout { 10 | line-height: 1; 11 | font-family: Helvetica Neue, Segoe UI, Open Sans, Ubuntu, sans-serif; 12 | } 13 | .tau-chart__layout text { 14 | font: normal 13px Helvetica Neue, Segoe UI, Open Sans, Ubuntu, sans-serif; 15 | } 16 | .tau-chart__chart { 17 | font-family: Helvetica Neue, Segoe UI, Open Sans, Ubuntu, sans-serif; 18 | position: absolute; 19 | height: 100%; 20 | width: 100%; 21 | overflow: auto; 22 | } 23 | .tau-chart__layout { 24 | display: -webkit-box; 25 | display: -webkit-flexbox; 26 | display: -ms-flexbox; 27 | display: flex; 28 | -ms-flex-align: stretch; 29 | -webkit-align-items: stretch; 30 | align-items: stretch; 31 | -ms-flex-direction: column; 32 | -webkit-box-orient: vertical; 33 | flex-direction: column; 34 | height: 100%; 35 | width: 100%; 36 | overflow: auto; 37 | background: transparent; 38 | color: #333; 39 | } 40 | .tau-chart__layout__header { 41 | -ms-flex: 0 0.1 auto; 42 | -webkit-box-flex: 0 0.1 auto; 43 | flex: 0 0.1 auto; 44 | position: relative; 45 | } 46 | .tau-chart__layout__container { 47 | display: -webkit-box; 48 | display: -webkit-flexbox; 49 | display: -ms-flexbox; 50 | display: flex; 51 | -ms-flex: 1 1 auto; 52 | -webkit-box-flex: 1 1 auto; 53 | flex: 1 1 auto; 54 | height: 100%; 55 | } 56 | .tau-chart__layout__footer { 57 | -ms-flex: 0 1 auto; 58 | -webkit-box-flex: 0 1 auto; 59 | flex: 0 1 auto; 60 | } 61 | .tau-chart__layout__sidebar { 62 | -ms-flex: 0 1 auto; 63 | -webkit-box-flex: 0 1 auto; 64 | flex: 0 1 auto; 65 | } 66 | .tau-chart__layout__content { 67 | -ms-flex: 1 1 auto; 68 | -webkit-box-flex: 1 1 auto; 69 | flex: 1 1 auto; 70 | overflow: hidden; 71 | } 72 | .tau-chart__layout__sidebar-right { 73 | position: relative; 74 | overflow: hidden; 75 | -ms-flex: 0 0 auto; 76 | -webkit-box-flex: 0 0 auto; 77 | flex: 0 0 auto; 78 | } 79 | .tau-chart__layout__sidebar-right__wrap { 80 | max-height: 100%; 81 | box-sizing: border-box; 82 | } 83 | .tau-chart__layout text { 84 | fill: #333; 85 | } 86 | .tau-chart__layout.tau-chart__layout_rendering-error { 87 | opacity: 0.75; 88 | } 89 | .tau-chart__rendering-timeout-warning { 90 | align-items: center; 91 | background: rgba(255, 255, 255, 0.5); 92 | display: flex; 93 | flex-direction: column; 94 | height: 100%; 95 | position: absolute; 96 | top: 0; 97 | width: 100%; 98 | } 99 | .tau-chart__rendering-timeout-warning svg { 100 | height: 100%; 101 | max-width: 32em; 102 | width: 100%; 103 | } 104 | .tau-chart__rendering-timeout-warning text { 105 | font-weight: 300; 106 | } 107 | .tau-chart__progress { 108 | box-sizing: border-box; 109 | height: 0.25em; 110 | opacity: 0; 111 | overflow: hidden; 112 | pointer-events: none; 113 | position: absolute; 114 | top: 0; 115 | transition: opacity 1s 0.75s; 116 | width: 100%; 117 | } 118 | .tau-chart__progress_active { 119 | opacity: 1; 120 | } 121 | .tau-chart__progress__value { 122 | background: rgba(51, 51, 51, 0.25); 123 | height: 100%; 124 | transition: width 0.75s; 125 | } 126 | .tau-chart { 127 | /* region Select --------------------------------------------------*/ 128 | } 129 | .tau-chart__checkbox { 130 | position: relative; 131 | display: block; 132 | } 133 | .tau-chart__checkbox__input { 134 | position: absolute; 135 | z-index: -1; 136 | opacity: 0; 137 | } 138 | .tau-chart__checkbox__icon { 139 | position: relative; 140 | width: 14px; 141 | height: 14px; 142 | top: 3px; 143 | display: inline-block; 144 | border: 1px solid #c3c3c3; 145 | border-radius: 2px; 146 | background: linear-gradient(to bottom, #fff 0%, #dbdbde 100%); 147 | } 148 | .tau-chart__checkbox__icon:before { 149 | display: none; 150 | content: ''; 151 | background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAFoTx1HAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIFdpbmRvd3MiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MEQ4M0RDOTE4NDQ2MTFFNEE5RTdBRERDQzRBQzNEMTQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MEQ4M0RDOTI4NDQ2MTFFNEE5RTdBRERDQzRBQzNEMTQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowRDgzREM4Rjg0NDYxMUU0QTlFN0FERENDNEFDM0QxNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowRDgzREM5MDg0NDYxMUU0QTlFN0FERENDNEFDM0QxNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pn2UjdoAAAEGSURBVHjaYvz//z8DGIAYSUlJdwECiBEukpiY/BDEAQggBrgIVBkLjAEDAAHEiMyBywBNOwDmJCYm/cdQBhBAqHrQAUgSojV5P8QtSY+A+D7cPTDdMAUwTQABhNdYJgZ8AF1nRkaGAgjDvQzi/AOCP3+YWX7+/HmXiYlRAcXY37//AEPs511OTg65uXPnPkQxNi0tTTklJUWGaNcCBBj+EMIDmBjIBCwo1jMyYigAul/x79//B4CulwOqODBv3hxHDKcmJycfAHLtgfrvMTExJf/7938xUF4GaOB9FhZmh1mzZj2CqUdNEkAdSUmZSsAgBNrAIAsUAQYlu+O0adMeo0cS/QMHAGJZps83N5ZDAAAAAElFTkSuQmCC'); 152 | width: 100%; 153 | height: 100%; 154 | position: absolute; 155 | top: 0; 156 | left: 0; 157 | } 158 | .tau-chart__checkbox__text { 159 | margin-left: 5px; 160 | } 161 | .tau-chart__checkbox__input ~ .tau-chart__checkbox__text { 162 | cursor: pointer; 163 | } 164 | .tau-chart__checkbox__input:disabled ~ .tau-chart__checkbox__text { 165 | cursor: default; 166 | opacity: 0.3; 167 | } 168 | .tau-chart__checkbox__input:not(:disabled):focus + .tau-chart__checkbox__icon { 169 | box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 7px 0 #52a8ec; 170 | outline: none; 171 | } 172 | .tau-chart__checkbox:hover .tau-chart__checkbox__input:not(:disabled) ~ .tau-chart__checkbox__icon { 173 | border-color: #999; 174 | } 175 | .tau-chart__checkbox__input:checked + .tau-chart__checkbox__icon { 176 | background: linear-gradient(to bottom, #fff 0%, #dbdbde 100%); 177 | } 178 | .tau-chart__checkbox__input:checked + .tau-chart__checkbox__icon:before { 179 | display: block; 180 | } 181 | .tau-chart__select { 182 | font-size: 13px; 183 | font-family: inherit; 184 | display: inline-block; 185 | height: 24px; 186 | line-height: 24px; 187 | vertical-align: middle; 188 | padding: 2px; 189 | background-color: #fff; 190 | border: 1px solid #c3c3c3; 191 | border-radius: 2px; 192 | color: #333; 193 | } 194 | .tau-chart__select:focus { 195 | box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 7px 0 #52a8ec; 196 | outline: none; 197 | } 198 | .tau-chart__select[disabled] { 199 | opacity: 0.3; 200 | cursor: default; 201 | } 202 | .tau-chart__select[multiple] { 203 | height: auto; 204 | } 205 | .tau-chart__select option[disabled] { 206 | opacity: 0.6; 207 | } 208 | .tau-chart__button { 209 | background-color: rgba(255, 255, 255, 0.9); 210 | border: 1px solid currentColor; 211 | border-radius: 4px; 212 | box-shadow: 0 0 1px rgba(0, 0, 0, 0.1); 213 | box-sizing: border-box; 214 | color: #b3b3b3; 215 | cursor: pointer; 216 | font-size: 13px; 217 | padding: 0 6px; 218 | line-height: 1.5em; 219 | height: calc(1.5em + 2px); 220 | } 221 | .tau-chart__button:hover { 222 | border-color: #999999; 223 | color: #333; 224 | } 225 | /* region Generate .color@{n}-@{i} function */ 226 | .tau-chart__svg .color20-1 { 227 | stroke: #6FA1D9; 228 | fill: #6FA1D9; 229 | } 230 | .tau-chart__svg .color20-2 { 231 | stroke: #DF2B59; 232 | fill: #DF2B59; 233 | } 234 | .tau-chart__svg .color20-3 { 235 | stroke: #66DA26; 236 | fill: #66DA26; 237 | } 238 | .tau-chart__svg .color20-4 { 239 | stroke: #4C3862; 240 | fill: #4C3862; 241 | } 242 | .tau-chart__svg .color20-5 { 243 | stroke: #E5B011; 244 | fill: #E5B011; 245 | } 246 | .tau-chart__svg .color20-6 { 247 | stroke: #3A3226; 248 | fill: #3A3226; 249 | } 250 | .tau-chart__svg .color20-7 { 251 | stroke: #CB461A; 252 | fill: #CB461A; 253 | } 254 | .tau-chart__svg .color20-8 { 255 | stroke: #C7CE23; 256 | fill: #C7CE23; 257 | } 258 | .tau-chart__svg .color20-9 { 259 | stroke: #7FCDC2; 260 | fill: #7FCDC2; 261 | } 262 | .tau-chart__svg .color20-10 { 263 | stroke: #CCA1C8; 264 | fill: #CCA1C8; 265 | } 266 | .tau-chart__svg .color20-11 { 267 | stroke: #C84CCE; 268 | fill: #C84CCE; 269 | } 270 | .tau-chart__svg .color20-12 { 271 | stroke: #54762E; 272 | fill: #54762E; 273 | } 274 | .tau-chart__svg .color20-13 { 275 | stroke: #746BC9; 276 | fill: #746BC9; 277 | } 278 | .tau-chart__svg .color20-14 { 279 | stroke: #953441; 280 | fill: #953441; 281 | } 282 | .tau-chart__svg .color20-15 { 283 | stroke: #5C7A76; 284 | fill: #5C7A76; 285 | } 286 | .tau-chart__svg .color20-16 { 287 | stroke: #C8BF87; 288 | fill: #C8BF87; 289 | } 290 | .tau-chart__svg .color20-17 { 291 | stroke: #BFC1C3; 292 | fill: #BFC1C3; 293 | } 294 | .tau-chart__svg .color20-18 { 295 | stroke: #8E5C31; 296 | fill: #8E5C31; 297 | } 298 | .tau-chart__svg .color20-19 { 299 | stroke: #71CE7B; 300 | fill: #71CE7B; 301 | } 302 | .tau-chart__svg .color20-20 { 303 | stroke: #BE478B; 304 | fill: #BE478B; 305 | } 306 | .tau-chart__svg .color-default { 307 | stroke: #6FA1D9; 308 | fill: #6FA1D9; 309 | } 310 | /* endregion */ 311 | /* region Generate .line-params-@{n} function */ 312 | /* Generate .line-size-@{n} */ 313 | .tau-chart__line-width-1 { 314 | stroke-width: 1px; 315 | } 316 | .tau-chart__line-width-2 { 317 | stroke-width: 1.5px; 318 | } 319 | .tau-chart__line-width-3 { 320 | stroke-width: 2px; 321 | } 322 | .tau-chart__line-width-4 { 323 | stroke-width: 2.5px; 324 | } 325 | .tau-chart__line-width-5 { 326 | stroke-width: 3px; 327 | } 328 | /* Generate .line-opacity-@{n} */ 329 | .tau-chart__line-opacity-1 { 330 | stroke-opacity: 1; 331 | } 332 | .tau-chart__line-opacity-2 { 333 | stroke-opacity: 0.95; 334 | } 335 | .tau-chart__line-opacity-3 { 336 | stroke-opacity: 0.9; 337 | } 338 | .tau-chart__line-opacity-4 { 339 | stroke-opacity: 0.85; 340 | } 341 | .tau-chart__line-opacity-5 { 342 | stroke-opacity: 0.8; 343 | } 344 | /* endregion */ 345 | /* endregion */ 346 | .tau-chart { 347 | /* Links */ 348 | /* Axises and Grid */ 349 | /* Scatterplot */ 350 | /* Linechart */ 351 | /* Bar */ 352 | /* TODO: fix to avoid conflict on "stroke" with color brewer */ 353 | /* TODO: remove this when CSS for color brewer is fixed */ 354 | /* PLUGINS */ 355 | /* Highlighter */ 356 | } 357 | .tau-chart a { 358 | color: #3962FF; 359 | border-bottom: 1px solid rgba(57, 98, 255, 0.3); 360 | text-decoration: none; 361 | } 362 | .tau-chart a:hover { 363 | color: #E17152; 364 | border-bottom: 1px solid rgba(225, 113, 82, 0.3); 365 | } 366 | .tau-chart__time-axis-overflow .tick:nth-child(even) { 367 | display: none; 368 | } 369 | .tau-chart__svg { 370 | display: block; 371 | overflow: hidden; 372 | } 373 | .tau-chart__svg .place { 374 | fill: #fff; 375 | stroke: #000; 376 | stroke-opacity: 0.7; 377 | stroke-width: 0.5; 378 | } 379 | .tau-chart__svg .place-label { 380 | opacity: 0.7; 381 | font-size: 11px; 382 | color: #000000; 383 | line-height: 13px; 384 | text-anchor: start; 385 | } 386 | .tau-chart__svg .place-label-countries, 387 | .tau-chart__svg .place-label-subunits, 388 | .tau-chart__svg .place-label-states { 389 | text-anchor: middle; 390 | font-size: 10px; 391 | fill: rgba(51, 51, 51, 0.5); 392 | line-height: 10px; 393 | text-transform: capitalize; 394 | } 395 | .tau-chart__svg .map-contour-level path { 396 | stroke-opacity: 0.5; 397 | stroke-linejoin: 'round'; 398 | } 399 | .tau-chart__svg .map-contour-level-0 path { 400 | stroke: #fff; 401 | } 402 | .tau-chart__svg .map-contour-level-1 path { 403 | stroke: #fff; 404 | } 405 | .tau-chart__svg .map-contour-level-2 path { 406 | stroke: #fff; 407 | } 408 | .tau-chart__svg .map-contour-level-3 path { 409 | stroke: #fff; 410 | } 411 | .tau-chart__svg .map-contour-level-4 path { 412 | stroke: #fff; 413 | } 414 | .tau-chart__svg .map-contour-highlighted, 415 | .tau-chart__svg .map-contour:hover { 416 | fill: #FFBF00; 417 | } 418 | .tau-chart__svg .map-contour-highlighted path, 419 | .tau-chart__svg .map-contour:hover path { 420 | stroke: #fff; 421 | } 422 | .tau-chart__svg .map-contour-highlighted text, 423 | .tau-chart__svg .map-contour:hover text { 424 | fill: #000; 425 | } 426 | .tau-chart__svg .axis line, 427 | .tau-chart__svg .axis path { 428 | stroke-width: 1; 429 | fill: none; 430 | stroke: rgba(189, 195, 205, 0.4); 431 | shape-rendering: crispEdges; 432 | } 433 | .tau-chart__svg .axis.facet-axis .tick line { 434 | opacity: 0; 435 | } 436 | .tau-chart__svg .axis.facet-axis .tick line.label-ref { 437 | opacity: 1; 438 | } 439 | .tau-chart__svg .axis.facet-axis .tick text { 440 | font-size: 12px; 441 | font-weight: 600; 442 | } 443 | .tau-chart__svg .axis.facet-axis path.domain { 444 | opacity: 0; 445 | } 446 | .tau-chart__svg .axis.facet-axis.compact .tick text { 447 | font-weight: normal; 448 | } 449 | .tau-chart__svg .axis.facet-axis.compact .label { 450 | font-weight: normal; 451 | } 452 | .tau-chart__svg .axis.facet-axis.compact .label .label-token { 453 | font-weight: normal; 454 | } 455 | .tau-chart__svg .tick text { 456 | font-size: 11px; 457 | } 458 | .tau-chart__svg .grid .grid-lines path { 459 | shape-rendering: crispEdges; 460 | } 461 | .tau-chart__svg .grid .line path, 462 | .tau-chart__svg .grid path.line, 463 | .tau-chart__svg .grid path.domain { 464 | fill: none; 465 | } 466 | .tau-chart__svg .grid .tick > line, 467 | .tau-chart__svg .grid .extra-tick-line { 468 | fill: none; 469 | stroke: rgba(189, 195, 205, 0.4); 470 | stroke-width: 1px; 471 | shape-rendering: crispEdges; 472 | } 473 | .tau-chart__svg .grid .tick.zero-tick > line { 474 | stroke: rgba(126, 129, 134, 0.505); 475 | } 476 | .tau-chart__svg .grid .line path { 477 | shape-rendering: auto; 478 | } 479 | .tau-chart__svg .grid .cursor-line { 480 | shape-rendering: crispEdges; 481 | stroke: #adadad; 482 | stroke-width: 1px; 483 | } 484 | .tau-chart__svg .label { 485 | font-size: 12px; 486 | font-weight: 600; 487 | } 488 | .tau-chart__svg .label .label-token { 489 | font-size: 12px; 490 | font-weight: 600; 491 | text-transform: capitalize; 492 | } 493 | .tau-chart__svg .label .label-token-1, 494 | .tau-chart__svg .label .label-token-2 { 495 | font-weight: normal; 496 | } 497 | .tau-chart__svg .label .label-token-2 { 498 | fill: gray; 499 | } 500 | .tau-chart__svg .label .label-token-delimiter { 501 | font-weight: normal; 502 | fill: gray; 503 | } 504 | .tau-chart__svg .label.inline .label-token { 505 | font-weight: normal; 506 | fill: gray; 507 | text-transform: none; 508 | } 509 | .tau-chart__svg .brush .selection { 510 | fill-opacity: .3; 511 | stroke: #fff; 512 | shape-rendering: crispEdges; 513 | } 514 | .tau-chart__svg .background { 515 | stroke: #f2f2f2; 516 | } 517 | .tau-chart__dot { 518 | opacity: 0.7; 519 | stroke-width: 0; 520 | transition: stroke-width 0.1s ease, opacity 0.2s ease; 521 | } 522 | .tau-chart__line { 523 | fill: none; 524 | transition: stroke-opacity 0.2s ease, stroke-width 0.2s ease; 525 | } 526 | .tau-chart__dot-line { 527 | opacity: 1; 528 | transition: stroke-opacity 0.2s ease; 529 | } 530 | .tau-chart__bar { 531 | opacity: 0.7; 532 | shape-rendering: geometricPrecision; 533 | stroke-opacity: 0.5; 534 | stroke-width: 1; 535 | stroke: #fff; 536 | transition: opacity 0.2s ease; 537 | } 538 | .tau-chart__area { 539 | transition: opacity 0.2s ease; 540 | } 541 | .tau-chart__area path:not(.i-data-anchor), 542 | .tau-chart__area polygon { 543 | opacity: 0.6; 544 | transition: stroke-opacity 0.2s ease, stroke-width 0.2s ease; 545 | } 546 | .tau-chart__svg .tau-chart__bar { 547 | stroke: #fff; 548 | } 549 | .tau-chart__dot.tau-chart__highlighted { 550 | stroke-width: 1; 551 | opacity: 1; 552 | } 553 | .tau-chart__dot.tau-chart__dimmed { 554 | opacity: 0.2; 555 | } 556 | .tau-chart__line.tau-chart__highlighted { 557 | stroke-opacity: 1; 558 | stroke-width: 3; 559 | } 560 | .tau-chart__line.tau-chart__dimmed { 561 | stroke-opacity: 0.2; 562 | } 563 | .i-role-label.tau-chart__highlighted, 564 | .tau-chart__area.tau-chart__highlighted, 565 | .tau-chart__bar.tau-chart__highlighted { 566 | stroke-opacity: 1; 567 | opacity: 1; 568 | } 569 | .i-role-label.tau-chart__dimmed, 570 | .tau-chart__area.tau-chart__dimmed, 571 | .tau-chart__bar.tau-chart__dimmed { 572 | opacity: 0.2; 573 | } 574 | .tau-chart__annotation-line { 575 | stroke-width: 2px; 576 | stroke-dasharray: 1,1; 577 | shape-rendering: crispEdges; 578 | } 579 | .tau-chart__annotation-area.tau-chart__area polygon { 580 | opacity: 0.1; 581 | } 582 | .tau-chart__category-filter { 583 | box-sizing: border-box; 584 | margin-right: 30px; 585 | padding: 20px 0 10px 10px; 586 | width: 160px; 587 | } 588 | .tau-chart__category-filter__category__label { 589 | font-weight: 600; 590 | font-size: 13px; 591 | margin: 0 0 10px 10px; 592 | text-transform: capitalize; 593 | } 594 | .tau-chart__category-filter__category__values { 595 | margin-bottom: 10px; 596 | } 597 | .tau-chart__category-filter__value { 598 | align-items: center; 599 | color: #ccc; 600 | cursor: pointer; 601 | display: flex; 602 | flex-direction: row; 603 | font-size: 13px; 604 | width: 100%; 605 | } 606 | .tau-chart__category-filter__value:hover { 607 | background-color: rgba(189, 195, 205, 0.2); 608 | } 609 | .tau-chart__category-filter__value_checked { 610 | color: #333; 611 | } 612 | .tau-chart__category-filter__value__toggle { 613 | flex: none; 614 | padding: 10px 10px 8px 10px; 615 | } 616 | .tau-chart__category-filter__value__toggle__icon { 617 | background-color: transparent; 618 | border: 1px solid #8694a3; 619 | box-sizing: border-box; 620 | border-radius: 50%; 621 | display: inline-block; 622 | height: 16px; 623 | pointer-events: none; 624 | position: relative; 625 | width: 16px; 626 | } 627 | .tau-chart__category-filter__value__toggle__icon::before, 628 | .tau-chart__category-filter__value__toggle__icon::after { 629 | background-color: #333; 630 | content: ""; 631 | display: block; 632 | opacity: 0; 633 | position: absolute; 634 | } 635 | .tau-chart__category-filter__value__toggle__icon::before { 636 | height: 2px; 637 | left: 3px; 638 | top: 6px; 639 | width: 8px; 640 | } 641 | .tau-chart__category-filter__value__toggle__icon::after { 642 | height: 8px; 643 | left: 6px; 644 | top: 3px; 645 | width: 2px; 646 | } 647 | .tau-chart__category-filter__value__toggle:hover .tau-chart__category-filter__value__toggle__icon::before, 648 | .tau-chart__category-filter__value__toggle:hover .tau-chart__category-filter__value__toggle__icon::after { 649 | opacity: 1; 650 | } 651 | .tau-chart__category-filter__value_checked .tau-chart__category-filter__value__toggle__icon { 652 | background-color: #8694a3; 653 | border-color: transparent; 654 | } 655 | .tau-chart__category-filter__value_checked .tau-chart__category-filter__value__toggle__icon::before, 656 | .tau-chart__category-filter__value_checked .tau-chart__category-filter__value__toggle__icon::after { 657 | background-color: #fff; 658 | transform: rotate(45deg); 659 | } 660 | .tau-chart__category-filter__value__label { 661 | padding-left: 4px; 662 | } 663 | .tau-chart__layout .tau-crosshair__line { 664 | shape-rendering: crispEdges; 665 | stroke-dasharray: 1px 1px; 666 | stroke-width: 1px; 667 | } 668 | .tau-chart__layout .tau-crosshair__label__text { 669 | fill: #fff; 670 | stroke: none; 671 | } 672 | .tau-chart__layout .tau-crosshair__label__text, 673 | .tau-chart__layout .tau-crosshair__label__text-shadow { 674 | font-size: 12px; 675 | font-weight: normal; 676 | } 677 | .tau-chart__layout .tau-crosshair__line-shadow { 678 | shape-rendering: crispEdges; 679 | stroke: #cccccc; 680 | stroke-width: 1px; 681 | } 682 | .tau-chart__layout .tau-crosshair__group.y .tau-crosshair__line-shadow { 683 | transform: translateX(-0.5px); 684 | } 685 | .tau-chart__layout .tau-crosshair__group.x .tau-crosshair__line-shadow { 686 | transform: translateY(0.5px); 687 | } 688 | .tau-chart__layout .tau-crosshair__label__text-shadow { 689 | stroke-linejoin: round; 690 | stroke-width: 3px; 691 | visibility: hidden; 692 | } 693 | .tau-chart__layout .tau-crosshair__label__box { 694 | fill-opacity: 0.85; 695 | rx: 3px; 696 | ry: 3px; 697 | stroke: none; 698 | } 699 | .tau-chart__layout .tau-crosshair__line.color20-1 { 700 | stroke: #6FA1D9; 701 | } 702 | .tau-chart__layout .tau-crosshair__label.color20-1 .tau-crosshair__label__text-shadow { 703 | stroke: #6FA1D9; 704 | } 705 | .tau-chart__layout .tau-crosshair__label.color20-1 .tau-crosshair__label__box { 706 | fill: #6FA1D9; 707 | } 708 | .tau-chart__layout .tau-crosshair__line.color20-2 { 709 | stroke: #DF2B59; 710 | } 711 | .tau-chart__layout .tau-crosshair__label.color20-2 .tau-crosshair__label__text-shadow { 712 | stroke: #DF2B59; 713 | } 714 | .tau-chart__layout .tau-crosshair__label.color20-2 .tau-crosshair__label__box { 715 | fill: #DF2B59; 716 | } 717 | .tau-chart__layout .tau-crosshair__line.color20-3 { 718 | stroke: #66DA26; 719 | } 720 | .tau-chart__layout .tau-crosshair__label.color20-3 .tau-crosshair__label__text-shadow { 721 | stroke: #66DA26; 722 | } 723 | .tau-chart__layout .tau-crosshair__label.color20-3 .tau-crosshair__label__box { 724 | fill: #66DA26; 725 | } 726 | .tau-chart__layout .tau-crosshair__line.color20-4 { 727 | stroke: #4C3862; 728 | } 729 | .tau-chart__layout .tau-crosshair__label.color20-4 .tau-crosshair__label__text-shadow { 730 | stroke: #4C3862; 731 | } 732 | .tau-chart__layout .tau-crosshair__label.color20-4 .tau-crosshair__label__box { 733 | fill: #4C3862; 734 | } 735 | .tau-chart__layout .tau-crosshair__line.color20-5 { 736 | stroke: #E5B011; 737 | } 738 | .tau-chart__layout .tau-crosshair__label.color20-5 .tau-crosshair__label__text-shadow { 739 | stroke: #E5B011; 740 | } 741 | .tau-chart__layout .tau-crosshair__label.color20-5 .tau-crosshair__label__box { 742 | fill: #E5B011; 743 | } 744 | .tau-chart__layout .tau-crosshair__line.color20-6 { 745 | stroke: #3A3226; 746 | } 747 | .tau-chart__layout .tau-crosshair__label.color20-6 .tau-crosshair__label__text-shadow { 748 | stroke: #3A3226; 749 | } 750 | .tau-chart__layout .tau-crosshair__label.color20-6 .tau-crosshair__label__box { 751 | fill: #3A3226; 752 | } 753 | .tau-chart__layout .tau-crosshair__line.color20-7 { 754 | stroke: #CB461A; 755 | } 756 | .tau-chart__layout .tau-crosshair__label.color20-7 .tau-crosshair__label__text-shadow { 757 | stroke: #CB461A; 758 | } 759 | .tau-chart__layout .tau-crosshair__label.color20-7 .tau-crosshair__label__box { 760 | fill: #CB461A; 761 | } 762 | .tau-chart__layout .tau-crosshair__line.color20-8 { 763 | stroke: #C7CE23; 764 | } 765 | .tau-chart__layout .tau-crosshair__label.color20-8 .tau-crosshair__label__text-shadow { 766 | stroke: #C7CE23; 767 | } 768 | .tau-chart__layout .tau-crosshair__label.color20-8 .tau-crosshair__label__box { 769 | fill: #C7CE23; 770 | } 771 | .tau-chart__layout .tau-crosshair__line.color20-9 { 772 | stroke: #7FCDC2; 773 | } 774 | .tau-chart__layout .tau-crosshair__label.color20-9 .tau-crosshair__label__text-shadow { 775 | stroke: #7FCDC2; 776 | } 777 | .tau-chart__layout .tau-crosshair__label.color20-9 .tau-crosshair__label__box { 778 | fill: #7FCDC2; 779 | } 780 | .tau-chart__layout .tau-crosshair__line.color20-10 { 781 | stroke: #CCA1C8; 782 | } 783 | .tau-chart__layout .tau-crosshair__label.color20-10 .tau-crosshair__label__text-shadow { 784 | stroke: #CCA1C8; 785 | } 786 | .tau-chart__layout .tau-crosshair__label.color20-10 .tau-crosshair__label__box { 787 | fill: #CCA1C8; 788 | } 789 | .tau-chart__layout .tau-crosshair__line.color20-11 { 790 | stroke: #C84CCE; 791 | } 792 | .tau-chart__layout .tau-crosshair__label.color20-11 .tau-crosshair__label__text-shadow { 793 | stroke: #C84CCE; 794 | } 795 | .tau-chart__layout .tau-crosshair__label.color20-11 .tau-crosshair__label__box { 796 | fill: #C84CCE; 797 | } 798 | .tau-chart__layout .tau-crosshair__line.color20-12 { 799 | stroke: #54762E; 800 | } 801 | .tau-chart__layout .tau-crosshair__label.color20-12 .tau-crosshair__label__text-shadow { 802 | stroke: #54762E; 803 | } 804 | .tau-chart__layout .tau-crosshair__label.color20-12 .tau-crosshair__label__box { 805 | fill: #54762E; 806 | } 807 | .tau-chart__layout .tau-crosshair__line.color20-13 { 808 | stroke: #746BC9; 809 | } 810 | .tau-chart__layout .tau-crosshair__label.color20-13 .tau-crosshair__label__text-shadow { 811 | stroke: #746BC9; 812 | } 813 | .tau-chart__layout .tau-crosshair__label.color20-13 .tau-crosshair__label__box { 814 | fill: #746BC9; 815 | } 816 | .tau-chart__layout .tau-crosshair__line.color20-14 { 817 | stroke: #953441; 818 | } 819 | .tau-chart__layout .tau-crosshair__label.color20-14 .tau-crosshair__label__text-shadow { 820 | stroke: #953441; 821 | } 822 | .tau-chart__layout .tau-crosshair__label.color20-14 .tau-crosshair__label__box { 823 | fill: #953441; 824 | } 825 | .tau-chart__layout .tau-crosshair__line.color20-15 { 826 | stroke: #5C7A76; 827 | } 828 | .tau-chart__layout .tau-crosshair__label.color20-15 .tau-crosshair__label__text-shadow { 829 | stroke: #5C7A76; 830 | } 831 | .tau-chart__layout .tau-crosshair__label.color20-15 .tau-crosshair__label__box { 832 | fill: #5C7A76; 833 | } 834 | .tau-chart__layout .tau-crosshair__line.color20-16 { 835 | stroke: #C8BF87; 836 | } 837 | .tau-chart__layout .tau-crosshair__label.color20-16 .tau-crosshair__label__text-shadow { 838 | stroke: #C8BF87; 839 | } 840 | .tau-chart__layout .tau-crosshair__label.color20-16 .tau-crosshair__label__box { 841 | fill: #C8BF87; 842 | } 843 | .tau-chart__layout .tau-crosshair__line.color20-17 { 844 | stroke: #BFC1C3; 845 | } 846 | .tau-chart__layout .tau-crosshair__label.color20-17 .tau-crosshair__label__text-shadow { 847 | stroke: #BFC1C3; 848 | } 849 | .tau-chart__layout .tau-crosshair__label.color20-17 .tau-crosshair__label__box { 850 | fill: #BFC1C3; 851 | } 852 | .tau-chart__layout .tau-crosshair__line.color20-18 { 853 | stroke: #8E5C31; 854 | } 855 | .tau-chart__layout .tau-crosshair__label.color20-18 .tau-crosshair__label__text-shadow { 856 | stroke: #8E5C31; 857 | } 858 | .tau-chart__layout .tau-crosshair__label.color20-18 .tau-crosshair__label__box { 859 | fill: #8E5C31; 860 | } 861 | .tau-chart__layout .tau-crosshair__line.color20-19 { 862 | stroke: #71CE7B; 863 | } 864 | .tau-chart__layout .tau-crosshair__label.color20-19 .tau-crosshair__label__text-shadow { 865 | stroke: #71CE7B; 866 | } 867 | .tau-chart__layout .tau-crosshair__label.color20-19 .tau-crosshair__label__box { 868 | fill: #71CE7B; 869 | } 870 | .tau-chart__layout .tau-crosshair__line.color20-20 { 871 | stroke: #BE478B; 872 | } 873 | .tau-chart__layout .tau-crosshair__label.color20-20 .tau-crosshair__label__text-shadow { 874 | stroke: #BE478B; 875 | } 876 | .tau-chart__layout .tau-crosshair__label.color20-20 .tau-crosshair__label__box { 877 | fill: #BE478B; 878 | } 879 | .diff-tooltip__table { 880 | border-top: 1px solid rgba(51, 51, 51, 0.2); 881 | margin-top: 5px; 882 | padding-top: 5px; 883 | width: calc(100% + 15px); 884 | } 885 | .diff-tooltip__header { 886 | align-items: stretch; 887 | display: flex; 888 | font-weight: 600; 889 | justify-content: space-between; 890 | padding: 2px 0px; 891 | position: relative; 892 | } 893 | .diff-tooltip__header__text { 894 | align-items: center; 895 | display: inline-flex; 896 | flex: 1 1 auto; 897 | justify-content: flex-start; 898 | max-width: 120px; 899 | } 900 | .diff-tooltip__header__value { 901 | align-items: center; 902 | display: inline-flex; 903 | flex: 1 1 auto; 904 | justify-content: flex-end; 905 | margin-right: 15px; 906 | max-width: 120px; 907 | padding-left: 10px; 908 | text-align: right; 909 | } 910 | .diff-tooltip__header__updown { 911 | align-items: center; 912 | display: inline-flex; 913 | flex: 1 1 auto; 914 | font-size: 75%; 915 | height: 100%; 916 | justify-content: flex-start; 917 | padding-left: 2px; 918 | position: absolute; 919 | right: 0; 920 | visibility: hidden; 921 | } 922 | .diff-tooltip__body { 923 | max-height: 250px; 924 | overflow: hidden; 925 | padding: 1px; 926 | position: relative; 927 | } 928 | .diff-tooltip__body__content { 929 | padding-bottom: 1px; 930 | } 931 | .diff-tooltip__body_overflow-top::before, 932 | .diff-tooltip__body_overflow-bottom::after { 933 | align-items: center; 934 | color: rgba(51, 51, 51, 0.7); 935 | content: "..."; 936 | display: flex; 937 | flex-direction: column; 938 | height: 26px; 939 | left: 0; 940 | position: absolute; 941 | width: 100%; 942 | z-index: 2; 943 | } 944 | .diff-tooltip__body_overflow-top::before { 945 | background: linear-gradient(to bottom, #fff, rgba(255, 255, 255, 0)); 946 | justify-content: flex-start; 947 | top: 0; 948 | } 949 | .diff-tooltip__body_overflow-bottom::after { 950 | background: linear-gradient(to top, #fff, rgba(255, 255, 255, 0)); 951 | justify-content: flex-end; 952 | bottom: 0; 953 | } 954 | .diff-tooltip__item { 955 | display: flex; 956 | justify-content: space-between; 957 | margin-right: 15px; 958 | min-width: 100px; 959 | position: relative; 960 | } 961 | .diff-tooltip__item_highlighted { 962 | background-color: rgba(241, 233, 255, 0.5); 963 | box-shadow: 0 0 0 1px #877aa1; 964 | z-index: 1; 965 | } 966 | .diff-tooltip__item__bg { 967 | align-items: center; 968 | display: inline-flex; 969 | height: 100%; 970 | justify-content: center; 971 | min-width: 3px; 972 | opacity: 0.6; 973 | position: absolute; 974 | z-index: 0; 975 | } 976 | .diff-tooltip__item__text { 977 | flex: 1 1 auto; 978 | overflow: hidden; 979 | padding: 2px 4px; 980 | text-overflow: ellipsis; 981 | white-space: nowrap; 982 | width: 100%; 983 | z-index: 1; 984 | } 985 | .diff-tooltip__item__value { 986 | flex: none; 987 | padding: 2px 4px 2px 30px; 988 | z-index: 1; 989 | } 990 | .diff-tooltip__item__updown { 991 | align-items: center; 992 | display: inline-flex; 993 | flex: 4; 994 | justify-content: flex-start; 995 | left: 100%; 996 | height: 100%; 997 | padding: 0 4px 0 4px; 998 | position: absolute; 999 | } 1000 | .diff-tooltip__item__updown_positive { 1001 | color: #4ca383; 1002 | } 1003 | .diff-tooltip__item__updown_negative { 1004 | color: #df6772; 1005 | } 1006 | .diff-tooltip__field__updown_positive { 1007 | color: #4ca383; 1008 | } 1009 | .diff-tooltip__field__updown_negative { 1010 | color: #df6772; 1011 | } 1012 | .interval-highlight__range { 1013 | shape-rendering: crispEdges; 1014 | } 1015 | .interval-highlight__range-start { 1016 | shape-rendering: crispEdges; 1017 | stroke: #b8aecb; 1018 | stroke-dasharray: 2 1; 1019 | } 1020 | .interval-highlight__range-end { 1021 | shape-rendering: crispEdges; 1022 | stroke: #b8aecb; 1023 | } 1024 | .interval-highlight__gradient-start { 1025 | stop-color: #c4b3e6; 1026 | stop-opacity: 0.02; 1027 | } 1028 | .interval-highlight__gradient-end { 1029 | stop-color: #c4b3e6; 1030 | stop-opacity: 0.2; 1031 | } 1032 | .diff-tooltip__item__bg.color20-1 { 1033 | background-color: #6FA1D9; 1034 | } 1035 | .diff-tooltip__item__bg.color20-2 { 1036 | background-color: #DF2B59; 1037 | } 1038 | .diff-tooltip__item__bg.color20-3 { 1039 | background-color: #66DA26; 1040 | } 1041 | .diff-tooltip__item__bg.color20-4 { 1042 | background-color: #4C3862; 1043 | } 1044 | .diff-tooltip__item__bg.color20-5 { 1045 | background-color: #E5B011; 1046 | } 1047 | .diff-tooltip__item__bg.color20-6 { 1048 | background-color: #3A3226; 1049 | } 1050 | .diff-tooltip__item__bg.color20-7 { 1051 | background-color: #CB461A; 1052 | } 1053 | .diff-tooltip__item__bg.color20-8 { 1054 | background-color: #C7CE23; 1055 | } 1056 | .diff-tooltip__item__bg.color20-9 { 1057 | background-color: #7FCDC2; 1058 | } 1059 | .diff-tooltip__item__bg.color20-10 { 1060 | background-color: #CCA1C8; 1061 | } 1062 | .diff-tooltip__item__bg.color20-11 { 1063 | background-color: #C84CCE; 1064 | } 1065 | .diff-tooltip__item__bg.color20-12 { 1066 | background-color: #54762E; 1067 | } 1068 | .diff-tooltip__item__bg.color20-13 { 1069 | background-color: #746BC9; 1070 | } 1071 | .diff-tooltip__item__bg.color20-14 { 1072 | background-color: #953441; 1073 | } 1074 | .diff-tooltip__item__bg.color20-15 { 1075 | background-color: #5C7A76; 1076 | } 1077 | .diff-tooltip__item__bg.color20-16 { 1078 | background-color: #C8BF87; 1079 | } 1080 | .diff-tooltip__item__bg.color20-17 { 1081 | background-color: #BFC1C3; 1082 | } 1083 | .diff-tooltip__item__bg.color20-18 { 1084 | background-color: #8E5C31; 1085 | } 1086 | .diff-tooltip__item__bg.color20-19 { 1087 | background-color: #71CE7B; 1088 | } 1089 | .diff-tooltip__item__bg.color20-20 { 1090 | background-color: #BE478B; 1091 | } 1092 | .tau-chart__print-block { 1093 | display: none; 1094 | } 1095 | .tau-chart__export { 1096 | float: right; 1097 | margin: 0 20px 0 0; 1098 | display: block; 1099 | text-indent: 20px; 1100 | overflow: hidden; 1101 | background-repeat: no-repeat; 1102 | background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+ZXhwb3J0PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiMwMDAiPjxwYXRoIGQ9Ik0xNyAxLjY3bC04LjMyOCA4LjM2Nkw4IDkuNSAxNi4zNTMgMUgxMlYwaDZ2NmgtMVYxLjY3eiIgb3BhY2l0eT0iLjgiLz48cGF0aCBkPSJNMCA1LjAxQzAgMy4zNDYgMS4zMzcgMiAzLjAxIDJIMTZ2MTIuOTljMCAxLjY2My0xLjMzNyAzLjAxLTMuMDEgMy4wMUgzLjAxQzEuMzQ2IDE4IDAgMTYuNjYzIDAgMTQuOTlWNS4wMXpNMTUgMTVDMTUgMTYuMTA1IDE0LjEwMyAxNyAxMi45OTQgMTdIMy4wMDZDMS44OTggMTcgMSAxNi4xMDMgMSAxNC45OTRWNS4wMDZDMSAzLjg5OCAxLjg4NyAzIDIuOTk4IDNIOVYyaDd2N2gtMXY2LjAwMnoiIG9wYWNpdHk9Ii40Ii8+PC9nPjwvZz48L3N2Zz4=); 1103 | width: 20px; 1104 | height: 20px; 1105 | color: transparent; 1106 | opacity: 0.6; 1107 | cursor: pointer; 1108 | text-decoration: none; 1109 | position: relative; 1110 | z-index: 2; 1111 | } 1112 | .tau-chart__export:hover { 1113 | opacity: 1; 1114 | text-decoration: none; 1115 | } 1116 | .tau-chart__export__list { 1117 | font-size: 11px; 1118 | margin: 0; 1119 | padding: 0; 1120 | } 1121 | .tau-chart__export__item { 1122 | overflow: hidden; 1123 | box-sizing: border-box; 1124 | } 1125 | .tau-chart__export__item > a { 1126 | display: block; 1127 | padding: 7px 15px; 1128 | color: inherit; 1129 | text-decoration: none; 1130 | cursor: pointer; 1131 | } 1132 | .tau-chart__export__item > a:hover, 1133 | .tau-chart__export__item > a:focus { 1134 | background: #EAF2FC; 1135 | outline: none; 1136 | box-shadow: none; 1137 | } 1138 | .tau-chart__legend { 1139 | padding: 20px 0 10px 10px; 1140 | position: relative; 1141 | margin-right: 30px; 1142 | width: 160px; 1143 | box-sizing: border-box; 1144 | } 1145 | .tau-chart__legend__wrap { 1146 | margin-bottom: 30px; 1147 | position: relative; 1148 | } 1149 | .tau-chart__legend__wrap:last-child { 1150 | margin-bottom: 0; 1151 | } 1152 | .tau-chart__legend__title { 1153 | margin: 0 0 10px 10px; 1154 | text-transform: capitalize; 1155 | font-weight: 600; 1156 | font-size: 13px; 1157 | } 1158 | .tau-chart__legend__reset { 1159 | margin-top: -4px; 1160 | position: absolute; 1161 | right: -25px; 1162 | top: 0; 1163 | z-index: 1; 1164 | } 1165 | .tau-chart__legend__reset.disabled { 1166 | display: none; 1167 | } 1168 | .tau-chart__legend__reset + .tau-chart__legend__title { 1169 | margin-right: 1.7em; 1170 | } 1171 | .tau-chart__legend__item { 1172 | padding: 10px 20px 8px 40px; 1173 | position: relative; 1174 | font-size: 13px; 1175 | line-height: 1.2em; 1176 | cursor: pointer; 1177 | } 1178 | .tau-chart__legend__item:hover { 1179 | background-color: rgba(189, 195, 205, 0.2); 1180 | } 1181 | .tau-chart__legend__item--size { 1182 | cursor: default; 1183 | } 1184 | .tau-chart__legend__item--size:hover { 1185 | background: none; 1186 | } 1187 | .tau-chart__legend__item .color-default { 1188 | background: #6FA1D9; 1189 | border-color: #6FA1D9; 1190 | } 1191 | .tau-chart__legend__item:disabled, 1192 | .tau-chart__legend__item.disabled { 1193 | color: #ccc; 1194 | } 1195 | .tau-chart__legend__item.disabled .tau-chart__legend__guide { 1196 | background: transparent; 1197 | } 1198 | .tau-chart__legend__guide { 1199 | position: absolute; 1200 | box-sizing: border-box; 1201 | width: 100%; 1202 | height: 100%; 1203 | left: 50%; 1204 | top: 50%; 1205 | transform: translate(-50%, -50%); 1206 | border: 1px solid transparent; 1207 | border-radius: 50%; 1208 | } 1209 | .tau-chart__legend__guide__wrap { 1210 | position: absolute; 1211 | top: calc((10px - 8px) + 0.6em); 1212 | left: 10px; 1213 | width: 16px; 1214 | height: 16px; 1215 | } 1216 | .tau-chart__legend__guide--size { 1217 | stroke: #6FA1D9; 1218 | fill: #6FA1D9; 1219 | } 1220 | .tau-chart__legend__guide--color__overlay { 1221 | background-color: transparent; 1222 | height: 36px; 1223 | left: -12px; 1224 | position: absolute; 1225 | top: -12px; 1226 | width: 36px; 1227 | } 1228 | .tau-chart__legend__guide--color::before { 1229 | content: ""; 1230 | display: none; 1231 | height: 2px; 1232 | left: 3px; 1233 | pointer-events: none; 1234 | position: absolute; 1235 | top: 6px; 1236 | width: 8px; 1237 | } 1238 | .tau-chart__legend__guide--color::after { 1239 | content: ""; 1240 | display: none; 1241 | height: 8px; 1242 | left: 6px; 1243 | pointer-events: none; 1244 | position: absolute; 1245 | top: 3px; 1246 | width: 2px; 1247 | } 1248 | .tau-chart__legend__item .tau-chart__legend__guide--color:hover::before, 1249 | .tau-chart__legend__item .tau-chart__legend__guide--color:hover::after { 1250 | background-color: #fff; 1251 | display: inline-block; 1252 | transform: rotate(45deg); 1253 | } 1254 | .tau-chart__legend__item.disabled .tau-chart__legend__guide--color:hover { 1255 | background: #fff; 1256 | } 1257 | .tau-chart__legend__item.disabled .tau-chart__legend__guide--color:hover::before, 1258 | .tau-chart__legend__item.disabled .tau-chart__legend__guide--color:hover::after { 1259 | background-color: #333; 1260 | transform: none; 1261 | } 1262 | .tau-chart__legend__size-wrapper, 1263 | .tau-chart__legend__gradient-wrapper { 1264 | box-sizing: border-box; 1265 | margin: 10px; 1266 | overflow: visible; 1267 | width: 100%; 1268 | } 1269 | .tau-chart__legend__size, 1270 | .tau-chart__legend__gradient { 1271 | overflow: visible; 1272 | } 1273 | .tau-chart__legend__size__item__circle.color-definite { 1274 | stroke: #cacaca; 1275 | fill: #cacaca; 1276 | } 1277 | .tau-chart__legend__size__item__circle.color-default-size { 1278 | stroke: #6FA1D9; 1279 | fill: #6FA1D9; 1280 | } 1281 | .tau-chart__legend__gradient__bar { 1282 | rx: 4px; 1283 | ry: 4px; 1284 | } 1285 | .tau-chart__legend__item .color20-1 { 1286 | background: #6FA1D9; 1287 | border: 1px solid #6FA1D9; 1288 | } 1289 | .tau-chart__legend__item.disabled .color20-1 { 1290 | background-color: transparent; 1291 | } 1292 | .tau-chart__legend__item .color20-2 { 1293 | background: #DF2B59; 1294 | border: 1px solid #DF2B59; 1295 | } 1296 | .tau-chart__legend__item.disabled .color20-2 { 1297 | background-color: transparent; 1298 | } 1299 | .tau-chart__legend__item .color20-3 { 1300 | background: #66DA26; 1301 | border: 1px solid #66DA26; 1302 | } 1303 | .tau-chart__legend__item.disabled .color20-3 { 1304 | background-color: transparent; 1305 | } 1306 | .tau-chart__legend__item .color20-4 { 1307 | background: #4C3862; 1308 | border: 1px solid #4C3862; 1309 | } 1310 | .tau-chart__legend__item.disabled .color20-4 { 1311 | background-color: transparent; 1312 | } 1313 | .tau-chart__legend__item .color20-5 { 1314 | background: #E5B011; 1315 | border: 1px solid #E5B011; 1316 | } 1317 | .tau-chart__legend__item.disabled .color20-5 { 1318 | background-color: transparent; 1319 | } 1320 | .tau-chart__legend__item .color20-6 { 1321 | background: #3A3226; 1322 | border: 1px solid #3A3226; 1323 | } 1324 | .tau-chart__legend__item.disabled .color20-6 { 1325 | background-color: transparent; 1326 | } 1327 | .tau-chart__legend__item .color20-7 { 1328 | background: #CB461A; 1329 | border: 1px solid #CB461A; 1330 | } 1331 | .tau-chart__legend__item.disabled .color20-7 { 1332 | background-color: transparent; 1333 | } 1334 | .tau-chart__legend__item .color20-8 { 1335 | background: #C7CE23; 1336 | border: 1px solid #C7CE23; 1337 | } 1338 | .tau-chart__legend__item.disabled .color20-8 { 1339 | background-color: transparent; 1340 | } 1341 | .tau-chart__legend__item .color20-9 { 1342 | background: #7FCDC2; 1343 | border: 1px solid #7FCDC2; 1344 | } 1345 | .tau-chart__legend__item.disabled .color20-9 { 1346 | background-color: transparent; 1347 | } 1348 | .tau-chart__legend__item .color20-10 { 1349 | background: #CCA1C8; 1350 | border: 1px solid #CCA1C8; 1351 | } 1352 | .tau-chart__legend__item.disabled .color20-10 { 1353 | background-color: transparent; 1354 | } 1355 | .tau-chart__legend__item .color20-11 { 1356 | background: #C84CCE; 1357 | border: 1px solid #C84CCE; 1358 | } 1359 | .tau-chart__legend__item.disabled .color20-11 { 1360 | background-color: transparent; 1361 | } 1362 | .tau-chart__legend__item .color20-12 { 1363 | background: #54762E; 1364 | border: 1px solid #54762E; 1365 | } 1366 | .tau-chart__legend__item.disabled .color20-12 { 1367 | background-color: transparent; 1368 | } 1369 | .tau-chart__legend__item .color20-13 { 1370 | background: #746BC9; 1371 | border: 1px solid #746BC9; 1372 | } 1373 | .tau-chart__legend__item.disabled .color20-13 { 1374 | background-color: transparent; 1375 | } 1376 | .tau-chart__legend__item .color20-14 { 1377 | background: #953441; 1378 | border: 1px solid #953441; 1379 | } 1380 | .tau-chart__legend__item.disabled .color20-14 { 1381 | background-color: transparent; 1382 | } 1383 | .tau-chart__legend__item .color20-15 { 1384 | background: #5C7A76; 1385 | border: 1px solid #5C7A76; 1386 | } 1387 | .tau-chart__legend__item.disabled .color20-15 { 1388 | background-color: transparent; 1389 | } 1390 | .tau-chart__legend__item .color20-16 { 1391 | background: #C8BF87; 1392 | border: 1px solid #C8BF87; 1393 | } 1394 | .tau-chart__legend__item.disabled .color20-16 { 1395 | background-color: transparent; 1396 | } 1397 | .tau-chart__legend__item .color20-17 { 1398 | background: #BFC1C3; 1399 | border: 1px solid #BFC1C3; 1400 | } 1401 | .tau-chart__legend__item.disabled .color20-17 { 1402 | background-color: transparent; 1403 | } 1404 | .tau-chart__legend__item .color20-18 { 1405 | background: #8E5C31; 1406 | border: 1px solid #8E5C31; 1407 | } 1408 | .tau-chart__legend__item.disabled .color20-18 { 1409 | background-color: transparent; 1410 | } 1411 | .tau-chart__legend__item .color20-19 { 1412 | background: #71CE7B; 1413 | border: 1px solid #71CE7B; 1414 | } 1415 | .tau-chart__legend__item.disabled .color20-19 { 1416 | background-color: transparent; 1417 | } 1418 | .tau-chart__legend__item .color20-20 { 1419 | background: #BE478B; 1420 | border: 1px solid #BE478B; 1421 | } 1422 | .tau-chart__legend__item.disabled .color20-20 { 1423 | background-color: transparent; 1424 | } 1425 | .tau-chart__filter__wrap { 1426 | padding: 20px 0 10px 10px; 1427 | margin-right: 30px; 1428 | width: 160px; 1429 | box-sizing: border-box; 1430 | } 1431 | .tau-chart__filter__wrap__title { 1432 | margin: 0 0 10px 10px; 1433 | text-transform: capitalize; 1434 | font-weight: 600; 1435 | font-size: 13px; 1436 | } 1437 | .tau-chart__filter__wrap rect { 1438 | fill: rgba(0, 0, 0, 0.2); 1439 | } 1440 | .tau-chart__filter__wrap .brush .overlay, 1441 | .tau-chart__filter__wrap .brush .handle { 1442 | opacity: 0; 1443 | } 1444 | .tau-chart__filter__wrap .brush .selection { 1445 | shape-rendering: crispEdges; 1446 | fill-opacity: 0.4; 1447 | fill: #0074FF; 1448 | } 1449 | .tau-chart__filter__wrap text.date-label { 1450 | text-anchor: middle; 1451 | font-size: 12px; 1452 | } 1453 | .tau-chart__filter__wrap text.date-label .common { 1454 | font-weight: 600; 1455 | } 1456 | .tau-chart__filter__wrap .resize line { 1457 | stroke: #000; 1458 | stroke-width: 1px; 1459 | shape-rendering: crispEdges; 1460 | } 1461 | .tau-chart__filter__wrap .resize.e text { 1462 | text-anchor: middle; 1463 | font-size: 12px; 1464 | } 1465 | .tau-chart__filter__wrap .resize.w text { 1466 | text-anchor: middle; 1467 | font-size: 12px; 1468 | } 1469 | .tau-chart__tooltip { 1470 | background: rgba(255, 255, 255, 0.9); 1471 | position: absolute; 1472 | top: 0; 1473 | left: 0; 1474 | max-width: none; 1475 | z-index: 900; 1476 | align-items: stretch; 1477 | display: flex; 1478 | flex-direction: column; 1479 | box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.005); 1480 | font-size: 11px; 1481 | font-family: Helvetica Neue, Segoe UI, Open Sans, Ubuntu, sans-serif; 1482 | /* Fade */ 1483 | } 1484 | .tau-chart__tooltip.fade { 1485 | opacity: 0; 1486 | transition: opacity 200ms ease-out; 1487 | } 1488 | .tau-chart__tooltip.fade.in { 1489 | opacity: 1; 1490 | transition-duration: 500ms; 1491 | } 1492 | .tau-chart__tooltip.top-right, 1493 | .tau-chart__tooltip.bottom-right { 1494 | margin-left: 8px; 1495 | } 1496 | .tau-chart__tooltip.top-left, 1497 | .tau-chart__tooltip.bottom-left { 1498 | margin-left: -8px; 1499 | } 1500 | .tau-chart__tooltip.top, 1501 | .tau-chart__tooltip.top-right, 1502 | .tau-chart__tooltip.top-left { 1503 | margin-top: 8px; 1504 | } 1505 | .tau-chart__tooltip__content { 1506 | box-sizing: border-box; 1507 | max-width: 500px; 1508 | min-width: 100px; 1509 | overflow: hidden; 1510 | padding: 15px 15px 10px 15px; 1511 | } 1512 | .tau-chart__tooltip__buttons { 1513 | background: #EBEEF1; 1514 | bottom: 100%; 1515 | box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.005); 1516 | display: flex; 1517 | flex-direction: row; 1518 | flex-wrap: wrap; 1519 | max-width: 500px; 1520 | min-width: 86px; 1521 | position: absolute; 1522 | width: 100%; 1523 | z-index: -1; 1524 | } 1525 | .tau-chart__tooltip__buttons::after { 1526 | background: linear-gradient(to bottom, #fff 50%, rgba(255, 255, 255, 0)); 1527 | content: ""; 1528 | display: block; 1529 | height: 8px; 1530 | left: 0; 1531 | pointer-events: none; 1532 | position: absolute; 1533 | top: 100%; 1534 | width: 100%; 1535 | } 1536 | .tau-chart__tooltip__button { 1537 | color: #65717F; 1538 | cursor: pointer; 1539 | display: inline-flex; 1540 | flex: 1 0 auto; 1541 | height: 0; 1542 | overflow: hidden; 1543 | transition: height 500ms; 1544 | } 1545 | .tau-chart__tooltip__button__wrap { 1546 | line-height: 26px; 1547 | padding: 0 15px; 1548 | } 1549 | .tau-chart__tooltip__button:hover { 1550 | background: #f5f7f8; 1551 | color: #333; 1552 | } 1553 | .tau-chart__tooltip__button .tau-icon-close-gray { 1554 | background-image: url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIzMHB4IiBoZWlnaHQ9IjMwcHgiIHZpZXdCb3g9IjAgMCAzMCAzMCI+PHBhdGggZmlsbD0iIzg0OTZBNyIgZD0iTTEwLDAuNzE1TDkuMjg1LDBMNSw0LjI4NUwwLjcxNSwwTDAsMC43MTVMNC4yODUsNUwwLDkuMjg1TDAuNzE1LDEwTDUsNS43MTVMOS4yODUsMTBMMTAsOS4yODVMNS43MTUsNUwxMCwwLjcxNXoiLz48L3N2Zz4=); 1555 | display: inline-block; 1556 | width: 12px; 1557 | height: 12px; 1558 | position: relative; 1559 | top: 3px; 1560 | margin-right: 5px; 1561 | } 1562 | .tau-chart__tooltip.stuck .tau-chart__tooltip__button { 1563 | height: 26px; 1564 | } 1565 | .tau-chart__tooltip.top .tau-chart__tooltip__buttons, 1566 | .tau-chart__tooltip.top-right .tau-chart__tooltip__buttons, 1567 | .tau-chart__tooltip.top-left .tau-chart__tooltip__buttons { 1568 | bottom: initial; 1569 | top: 100%; 1570 | } 1571 | .tau-chart__tooltip.top .tau-chart__tooltip__buttons__wrap, 1572 | .tau-chart__tooltip.top-right .tau-chart__tooltip__buttons__wrap, 1573 | .tau-chart__tooltip.top-left .tau-chart__tooltip__buttons__wrap { 1574 | position: relative; 1575 | top: calc(100% - 26px); 1576 | } 1577 | .tau-chart__tooltip.top .tau-chart__tooltip__buttons::after, 1578 | .tau-chart__tooltip.top-right .tau-chart__tooltip__buttons::after, 1579 | .tau-chart__tooltip.top-left .tau-chart__tooltip__buttons::after { 1580 | background: linear-gradient(to top, #fff 50%, rgba(255, 255, 255, 0)); 1581 | bottom: 100%; 1582 | top: initial; 1583 | } 1584 | .tau-chart__tooltip.top-right .tau-chart__tooltip__button__wrap, 1585 | .tau-chart__tooltip.top-left .tau-chart__tooltip__button__wrap { 1586 | position: relative; 1587 | top: calc(100% - 26px); 1588 | } 1589 | .tau-chart__tooltip__list { 1590 | display: table; 1591 | } 1592 | .tau-chart__tooltip__list__item { 1593 | display: table-row; 1594 | } 1595 | .tau-chart__tooltip__list__elem { 1596 | display: table-cell; 1597 | padding-bottom: 4px; 1598 | line-height: 1.3; 1599 | color: #000; 1600 | } 1601 | .tau-chart__tooltip__list__elem:not(:first-child) { 1602 | padding-left: 15px; 1603 | } 1604 | .tau-chart__tooltip__list__elem:first-child { 1605 | color: #8e8e8e; 1606 | } 1607 | .tau-chart__tooltip__gray-text { 1608 | color: #8e8e8e; 1609 | } 1610 | .tau-chart__tooltip-target { 1611 | cursor: pointer; 1612 | } 1613 | .tau-chart__tooltip-target .tau-chart__dot.tau-chart__highlighted, 1614 | .tau-chart__tooltip-target .tau-chart__bar.tau-chart__highlighted, 1615 | .tau-chart__tooltip-target .i-data-anchor.tau-chart__highlighted { 1616 | stroke: #333; 1617 | stroke-width: 1; 1618 | } 1619 | .tau-chart__tooltip-target .tau-chart__bar.tau-chart__highlighted { 1620 | shape-rendering: crispEdges; 1621 | } 1622 | .tau-chart__svg .tau-chart__trendline.color20-1 { 1623 | stroke: #357ac7; 1624 | } 1625 | .tau-chart__svg .tau-chart__trendline.color20-2 { 1626 | stroke: #a5193d; 1627 | } 1628 | .tau-chart__svg .tau-chart__trendline.color20-3 { 1629 | stroke: #47991a; 1630 | } 1631 | .tau-chart__svg .tau-chart__trendline.color20-4 { 1632 | stroke: #261c31; 1633 | } 1634 | .tau-chart__svg .tau-chart__trendline.color20-5 { 1635 | stroke: #9e790c; 1636 | } 1637 | .tau-chart__svg .tau-chart__trendline.color20-6 { 1638 | stroke: #0c0a08; 1639 | } 1640 | .tau-chart__svg .tau-chart__trendline.color20-7 { 1641 | stroke: #872f11; 1642 | } 1643 | .tau-chart__svg .tau-chart__trendline.color20-8 { 1644 | stroke: #888d18; 1645 | } 1646 | .tau-chart__svg .tau-chart__trendline.color20-9 { 1647 | stroke: #48b8a8; 1648 | } 1649 | .tau-chart__svg .tau-chart__trendline.color20-10 { 1650 | stroke: #b16fab; 1651 | } 1652 | .tau-chart__svg .tau-chart__trendline.color20-11 { 1653 | stroke: #9c2ca1; 1654 | } 1655 | .tau-chart__svg .tau-chart__trendline.color20-12 { 1656 | stroke: #2d3f19; 1657 | } 1658 | .tau-chart__svg .tau-chart__trendline.color20-13 { 1659 | stroke: #483eaa; 1660 | } 1661 | .tau-chart__svg .tau-chart__trendline.color20-14 { 1662 | stroke: #5c2028; 1663 | } 1664 | .tau-chart__svg .tau-chart__trendline.color20-15 { 1665 | stroke: #3b4e4c; 1666 | } 1667 | .tau-chart__svg .tau-chart__trendline.color20-16 { 1668 | stroke: #b0a353; 1669 | } 1670 | .tau-chart__svg .tau-chart__trendline.color20-17 { 1671 | stroke: #989b9e; 1672 | } 1673 | .tau-chart__svg .tau-chart__trendline.color20-18 { 1674 | stroke: #55371d; 1675 | } 1676 | .tau-chart__svg .tau-chart__trendline.color20-19 { 1677 | stroke: #3eb44b; 1678 | } 1679 | .tau-chart__svg .tau-chart__trendline.color20-20 { 1680 | stroke: #883063; 1681 | } 1682 | .tau-chart__svg .tau-chart__trendline.color-default { 1683 | stroke: #357ac7; 1684 | } 1685 | .tau-chart { 1686 | /* TrendLine */ 1687 | } 1688 | .tau-chart__trendlinepanel { 1689 | padding: 20px 0 20px 20px; 1690 | margin-right: 20px; 1691 | width: 160px; 1692 | box-sizing: border-box; 1693 | } 1694 | .tau-chart__trendlinepanel__title { 1695 | margin: 0 0 10px 0; 1696 | text-transform: capitalize; 1697 | font-weight: 600; 1698 | font-size: 13px; 1699 | } 1700 | .tau-chart__trendlinepanel__control { 1701 | width: 100%; 1702 | } 1703 | .tau-chart__trendlinepanel__error-message { 1704 | font-size: 11px; 1705 | line-height: 16px; 1706 | margin-left: 5px; 1707 | } 1708 | .tau-chart__trendlinepanel.applicable-false.hide-trendline-error, 1709 | .tau-chart__trendlinepanel.applicable-false .tau-chart__checkbox__input, 1710 | .tau-chart__trendlinepanel.applicable-false .tau-chart__trendlinepanel__control, 1711 | .tau-chart__trendlinepanel.applicable-false .tau-chart__checkbox__icon { 1712 | display: none; 1713 | } 1714 | .tau-chart__trendline { 1715 | stroke-dasharray: 4, 4; 1716 | } 1717 | -------------------------------------------------------------------------------- /inst/htmlwidgets/taucharts.js: -------------------------------------------------------------------------------- 1 | HTMLWidgets.widget({ 2 | 3 | name: 'taucharts', 4 | type: 'output', 5 | 6 | factory: function(el, width, height) { 7 | var chart = null 8 | var sheet_element = document.createElement('style'); 9 | sheet_element.id = el.id + '-style'; 10 | document.head.appendChild(sheet_element); 11 | 12 | return { 13 | renderValue: function(x) { 14 | 15 | var datasource = HTMLWidgets.dataframeToD3(x.datasource); 16 | 17 | // for debugging data/parameter issues- remove for production version 18 | // dbg_x = x ; 19 | 20 | // we have to use CSS styles for the chart object colors so we 21 | // create a new stylesheet for every chart on a page (since there could be many charts) 22 | // by creating a sheet we're also ensured it will exist 23 | // then we further ensure proper CSS rule targeting by using the element id 24 | // along with the color style 25 | var sheet = document.getElementById(el.id + '-style').sheet; 26 | 27 | if (x.forCSS !== null) { 28 | if (typeof(x.forCSS) === "string") { 29 | x.forCSS = [ x.forCSS ] ; 30 | } 31 | x.forCSS.map(function(v) { 32 | v = v.replace("{{ID}}", '#'+el.id+' '); 33 | sheet.insertRule(v, sheet.cssRules.length); 34 | }); 35 | } 36 | 37 | if (x.forFonts !== null) { 38 | if (typeof(x.forFonts) === "string") { 39 | x.forFonts = [ x.forFonts ] ; 40 | } 41 | x.forFonts.map(function(v) { 42 | var headID = document.getElementsByTagName("head")[0]; 43 | var cssNode = document.createElement('link'); 44 | cssNode.type = 'text/css'; 45 | cssNode.rel = 'stylesheet'; 46 | cssNode.href = v; 47 | cssNode.media = 'screen'; 48 | headID.appendChild(cssNode); 49 | }); 50 | } 51 | 52 | // work with plugins 53 | var plugins = []; 54 | if(typeof(x.plugins) !== "undefined" && x.plugins.length){ 55 | x.plugins.map( function(plugin) { 56 | if( plugin.type === "tooltip" ) { 57 | plugin.fields = Array.isArray(plugin.fields) ? plugin.fields : [plugin.fields]; 58 | if( plugin.formatters === null ) { 59 | tooltip = Taucharts.api.plugins.get('tooltip')( 60 | {fields: plugin.fields} 61 | ); 62 | } else { 63 | tooltip = Taucharts.api.plugins.get('tooltip')( 64 | {fields: plugin.fields, formatters: plugin.formatters} 65 | ); 66 | } 67 | plugins.push(tooltip); 68 | } 69 | 70 | if( plugin.type === "legend" ){ 71 | plugins.push(Taucharts.api.plugins.get('legend')()); 72 | } 73 | 74 | if( plugin.type === "trendline" ){ 75 | if (!Array.isArray(plugin.settings.models)){ 76 | plugin.settings.models = [plugin.settings.models]; 77 | } 78 | if (!Array.isArray(plugin.settings.type)){ 79 | plugin.settings.type = plugin.settings.type; 80 | } 81 | plugins.push(Taucharts.api.plugins.get('trendline')(plugin.settings)); 82 | } 83 | 84 | if( plugin.type === "quick-filter"){ 85 | plugins.push(Taucharts.api.plugins.get('quick-filter')(plugin.fields)); 86 | } 87 | 88 | if( plugin.type === "exportTo"){ 89 | plugins.push(Taucharts.api.plugins.get('export-to')( 90 | {cssPaths: plugin.cssPaths} 91 | )); 92 | } 93 | 94 | if( plugin.type === "annotations"){ 95 | plugins.push(Taucharts.api.plugins.get('annotations')( 96 | {items: HTMLWidgets.dataframeToD3(plugin.items)} 97 | )); 98 | } 99 | 100 | if( plugin.type === "box-whiskers"){ 101 | plugins.push(Taucharts.api.plugins.get('box-whiskers')( 102 | {flip: plugin.settings.flip, mode: plugin.settings.mode} 103 | )); 104 | } 105 | }); 106 | } 107 | // Non-categorical facets do nothing 108 | x.dimensions.facets = 'category'; 109 | // Use special guide if chart has facets 110 | if (x.x.constructor===Array || x.y.constructor===Array) { 111 | x.guide = [{}, x.guide] 112 | } 113 | 114 | var config = { 115 | data: datasource, 116 | type: x.type, 117 | size: x.size, 118 | guide: x.guide, 119 | x: x.x, 120 | y: x.y, 121 | color: x.color, 122 | dimensions: x.dimensions, 123 | plugins: plugins 124 | } 125 | 126 | // New chart 127 | if (!chart) chart = new Taucharts.Chart(config) 128 | // Chart update 129 | else chart.updateConfig(config); 130 | 131 | chart.renderTo('#'+el.id); 132 | 133 | // Update Shiny inputs, if applicable 134 | if (x.input) chart.on('elementclick', function (_, e) { 135 | Shiny.onInputChange(x.input, e.data) 136 | }) 137 | 138 | // set up a container for tasks to perform after completion 139 | // one example would be add callbacks for event handling 140 | // styling 141 | if (!(typeof x.tasks === "undefined") ){ 142 | if ( (typeof x.tasks.length === "undefined") || 143 | (typeof x.tasks === "function" ) ) { 144 | // handle a function not enclosed in array 145 | // should be able to remove once using jsonlite 146 | x.tasks = [x.tasks]; 147 | } 148 | x.tasks.map(function(t){ 149 | // for each tasks call the task with el supplied as `this` 150 | t.call({el:el,chart:chart}); 151 | }); 152 | } 153 | 154 | }, 155 | 156 | resize: function(width, height) { 157 | chart.refresh(); 158 | }, 159 | 160 | chart: chart 161 | } 162 | } 163 | }); 164 | -------------------------------------------------------------------------------- /inst/htmlwidgets/taucharts.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: d3 3 | version: 4.8.0 4 | src: htmlwidgets/lib/d3 5 | script: d3.min.js 6 | - name: tauCharts 7 | version: 2.2.1 8 | src: htmlwidgets/lib/taucharts 9 | script: tauCharts.min.js 10 | stylesheet: 11 | - tauCharts.min.css 12 | -------------------------------------------------------------------------------- /inst/shinyapps/tau01/server.R: -------------------------------------------------------------------------------- 1 | # AUTHOR: https://github.com/ThoDuyNguyen 2 | # VIA: https://github.com/hrbrmstr/taucharts/issues/1#issuecomment-127898024 3 | 4 | library(shiny) 5 | library(htmlwidgets) 6 | library(taucharts) 7 | 8 | shinyServer(function(input, output) { 9 | scatter_dat <- 10 | structure( 11 | list( 12 | team = c("d", "d", "d", "d", "l", "l", "l", "l", 13 | "k", "k", "k", "k"), 14 | cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L, 15 | 5L, 2L, 3L, 4L, 5L), 16 | effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 17 | 4L, 5L, 6L, 8L), 18 | count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L, 19 | 5L, 8L, 3L), 20 | priority = c( 21 | "low", "low", "medium", "high", "low", 22 | "low", "medium", "high", "low", "low", "medium", "high" 23 | ) 24 | ), 25 | .Names = c("team", 26 | "cycleTime", "effort", "count", "priority"), class = "data.frame", 27 | row.names = c(NA, 12L) 28 | ) 29 | 30 | line_dat <- 31 | structure( 32 | list( 33 | type = c( 34 | "us", "us", "us", "us", "us", "us", "bug", 35 | "bug", "bug", "bug", "bug" 36 | ), count = c(0L, 10L, 15L, 12L, 16L, 37 | 13L, 21L, 19L, 23L, 26L, 23L), date = c( 38 | "12-2013", "01-2014", 39 | "02-2014", "03-2014", "04-2014", "05-2014", "01-2014", "02-2014", 40 | "03-2014", "04-2014", "05-2014" 41 | ) 42 | ), .Names = c("type", "count", 43 | "date"), class = "data.frame", row.names = c(NA, 11L) 44 | ) 45 | 46 | bar_dat <- 47 | structure( 48 | list( 49 | team = c("d", "d", "d", "d", "l", "l", "l", "l", 50 | "k", "k", "k", "k"), 51 | cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L, 52 | 5L, 2L, 3L, 4L, 5L), 53 | effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 54 | 4L, 5L, 6L, 8L), 55 | count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L, 56 | 5L, 8L, 3L), 57 | priority = c( 58 | "low", "low", "medium", "high", "low", 59 | "low", "medium", "high", "low", "low", "medium", "high" 60 | ) 61 | ), .Names = c("team", 62 | "cycleTime", "effort", "count", "priority"), 63 | class = "data.frame", row.names = c(NA, 12L) 64 | ) 65 | 66 | car_dat <- 67 | structure( 68 | list( 69 | car = c( 70 | "Toyota Prius+", "Volvo S60", "BMV X5", 71 | "Infinity FX", "Mercedes Vito", "Peugeot 3008", "Subaru Forester", 72 | "Lexus RX", "Bentley Continental" 73 | ), co2 = c(96L, 135L, 197L, 74 | 238L, 203L, 155L, 186L, 233L, 246L), 75 | hp = c(99L, 150L, 306L, 76 | 238L, 95L, 120L, 150L, 188L, 507L), euroEco = c( 77 | "eco", "eco", 78 | "non-eco", "non-eco", "non-eco", "non-eco", "non-eco", "non-eco", 79 | "non-eco" 80 | ), power = c( 81 | "low", "normal", "high", "high", "low", 82 | "low", "normal", "normal", "high" 83 | ) 84 | ), .Names = c("car", "co2", 85 | "hp", "euroEco", "power"), 86 | class = "data.frame", row.names = c(NA, 9L) 87 | ) 88 | 89 | splom_dat <- 90 | structure( 91 | list( 92 | param1 = c( 93 | "hp", "hp", "hp", "co2", "co2", "co2", 94 | "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", 95 | "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", 96 | "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", 97 | "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", 98 | "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", 99 | "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp", 100 | "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2", 101 | "co2", "co2", "mpg", "mpg", "mpg" 102 | ), param2 = c( 103 | "hp", "co2", "mpg", 104 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 105 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", 106 | "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", 107 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 108 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", 109 | "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", 110 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 111 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg" 112 | ), value1 = c( 113 | 99, 114 | 99, 99, 96, 96, 96, 3.8, 3.8, 3.8, 150, 150, 150, 135, 135, 135, 115 | 7.4, 7.4, 7.4, 306, 306, 306, 197, 197, 197, 11.2, 11.2, 11.2, 116 | 238, 238, 238, 238, 238, 238, 11.2, 11.2, 11.2, 95, 95, 95, 203, 117 | 203, 203, 9.4, 9.4, 9.4, 120, 120, 120, 155, 155, 155, 9.2, 9.2, 118 | 9.2, 150, 150, 150, 186, 186, 186, 10.4, 10.4, 10.4, 188, 188, 119 | 188, 233, 233, 233, 13.3, 13.3, 13.3, 507, 507, 507, 246, 246, 120 | 246, 15.4, 15.4, 15.4 121 | ), value2 = c( 122 | 99, 96, 3.8, 99, 96, 3.8, 123 | 99, 96, 3.8, 150, 135, 7.4, 150, 135, 7.4, 150, 135, 7.4, 306, 124 | 197, 11.2, 306, 197, 11.2, 306, 197, 11.2, 238, 238, 11.2, 238, 125 | 238, 11.2, 238, 238, 11.2, 95, 203, 9.4, 95, 203, 9.4, 95, 203, 126 | 9.4, 120, 155, 9.2, 120, 155, 9.2, 120, 155, 9.2, 150, 186, 10.4, 127 | 150, 186, 10.4, 150, 186, 10.4, 188, 233, 13.3, 188, 233, 13.3, 128 | 188, 233, 13.3, 507, 246, 15.4, 507, 246, 15.4, 507, 246, 15.4 129 | ) 130 | ), .Names = c("param1", "param2", "value1", "value2"), class = "data.frame", row.names = c(NA, 81L) 131 | ) 132 | 133 | output$bar <- renderTaucharts({ 134 | tauchart(head(bar_dat, ceiling(nrow(bar_dat)*as.numeric(input$data)/3)), inputId = "click") %>% 135 | tau_bar("team", "effort", color = "priority") %>% 136 | tau_legend() %>% tau_tooltip() 137 | }) 138 | 139 | output$line <- renderTaucharts({ 140 | tauchart(head(line_dat, ceiling(nrow(line_dat)*as.numeric(input$data)/3)), inputId = "click") %>% 141 | tau_line("date", "count", color = "type") %>% 142 | tau_guide_x(label="Month") %>% 143 | tau_guide_y(label="Count of completed entities", label_padding=50) %>% 144 | tau_guide_padding(70, 70, 10, 10) %>% 145 | tau_legend() %>% 146 | tau_tooltip() 147 | }) 148 | 149 | output$click <- renderPrint(input$click) 150 | }) 151 | -------------------------------------------------------------------------------- /inst/shinyapps/tau01/ui.R: -------------------------------------------------------------------------------- 1 | # META: tau01 - TauCharts Shiny Example 01 2 | 3 | # AUTHOR: https://github.com/ThoDuyNguyen 4 | # VIA: https://github.com/hrbrmstr/taucharts/issues/1#issuecomment-127898024 5 | 6 | library(shiny) 7 | library(htmlwidgets) 8 | library(taucharts) 9 | 10 | shinyUI(fluidPage( 11 | 12 | # Application title 13 | titlePanel("TauCharts Demo"), 14 | 15 | # Sidebar with a slider input for number of bins 16 | sidebarPanel(width = 3, 17 | selectInput( 18 | "data", label = h4("Data available:"), 19 | choices = c("none"=0, "little"=1, "some"=2, "lots"=3), 20 | selected = 1 21 | ), 22 | helpText("Most recently clicked on:"), 23 | verbatimTextOutput("click")), 24 | mainPanel( 25 | tabsetPanel( 26 | tabPanel("bar", tauchartsOutput("bar")), 27 | tabPanel("line", tauchartsOutput("line")) 28 | ) 29 | ) 30 | )) 31 | -------------------------------------------------------------------------------- /man/as_tauchart.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/as_tauchart.r 3 | \name{as_tauchart} 4 | \alias{as_tauchart} 5 | \title{Turn a simple (single-geom) ggplot plot into an tauchart object} 6 | \usage{ 7 | as_tauchart(gg) 8 | } 9 | \arguments{ 10 | \item{gg}{ggplot object} 11 | } 12 | \value{ 13 | tauchart object 14 | } 15 | \description{ 16 | Takes a ggplot object that has a single geom (it can be geom_line, 17 | geom_point or geom_histogram) and converts it to it's tauchart counterpart. 18 | It will do it's best to identify plot labels, mapped size & color aesthetics, 19 | and x/y limits. 20 | } 21 | \details{ 22 | If there are aesthetic mappings, \code{as_tauchart} will automaticlly add 23 | a legend. 24 | 25 | Currently supports: 26 | 27 | \itemize{ 28 | \item \code{geom_point} 29 | \item \code{geom_line} 30 | \item \code{geom_bar} 31 | \item \code{geom_histogram} 32 | } 33 | } 34 | \note{ 35 | More aesthetic mappings are planned 36 | } 37 | \examples{ 38 | if (interactive()) { 39 | library(ggplot2) 40 | dat <- data.frame(year=seq(1790, 1970, 10), 41 | uspop=as.numeric(uspop)) 42 | set.seed(5689) 43 | data(movies, package="ggplot2") 44 | movies <- movies[sample(nrow(movies), 1000), ] 45 | 46 | gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_line() 47 | as_tauchart(gg) 48 | 49 | gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_point() 50 | as_tauchart(gg) 51 | 52 | gg <- ggplot(dplyr::count(movies, rating), aes(rating, n)) + geom_bar(stat="identity") 53 | as_tauchart(gg) 54 | 55 | gg <- ggplot(mtcars) + geom_point(aes(x=mpg, y=wt, color=cyl)) 56 | as_tauchart(gg) 57 | 58 | gg <- ggplot(mtcars, aes(x=mpg, y=wt, color=am, size=wt)) + geom_point() 59 | as_tauchart(gg) 60 | 61 | data(economics, package="ggplot2") 62 | gg <- ggplot(economics) + geom_line(aes(x=date, y=unemploy)) 63 | as_tauchart(gg) \%>\% tau_guide_x(tick_format="\%Y") 64 | 65 | gg <- ggplot(mtcars, aes(as.factor(cyl))) + geom_histogram() 66 | as_tauchart(gg) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /man/cars_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datasets.r 3 | \docType{data} 4 | \name{cars_data} 5 | \alias{cars_data} 6 | \title{Automobile statistics from 1997-2013} 7 | \format{A data frame with 135 rows and 7 variables} 8 | \usage{ 9 | data(cars_data) 10 | } 11 | \description{ 12 | This dataset contains statistics on cars released from 1997 through 2013. 13 | It consists of a data.frame containing the columns: 14 | 15 | \itemize{ 16 | \item \code{vehicle}: Vehicle model. 17 | \item \code{year}: Year vehicle released. 18 | \item \code{date}: Price (new) of vehicle at release year (USD). 19 | \item \code{accelrate}: Vehicle acceleration rate. 20 | \item \code{milespergallon}: Vehicle MPG 21 | \item \code{class}: Vehicle class (according to U.S. driver's license code) 22 | } 23 | } 24 | \note{ 25 | Last updated 2015-08-04. 26 | } 27 | \examples{ 28 | if (interactive()) { 29 | data(cars_data) 30 | tauchart(cars_data) \%>\% 31 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 32 | tau_legend() \%>\% 33 | tau_trendline() \%>\% 34 | tau_tooltip(c("vehicle", "year", "class", "price", "milespergallon")) 35 | } 36 | } 37 | \keyword{datasets} 38 | -------------------------------------------------------------------------------- /man/run_tau_app.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shiny.r 3 | \name{run_tau_app} 4 | \alias{run_tau_app} 5 | \title{Run a built-in example Shiny app} 6 | \usage{ 7 | run_tau_app(app_name = NULL) 8 | } 9 | \arguments{ 10 | \item{app_name}{name of built-in Shiny app to run (if \code{NULL} displays a list 11 | of built-in apps)} 12 | } 13 | \description{ 14 | When run without specifying \code{app_name}, this function will return 15 | a list of built-in TauCharts Shiny example applications. To run one of the 16 | built-in example applications, specify only the name in the \code{app_name} 17 | parameter and the function will display the full path to the app (making it 18 | easier to find and view the source) and then execute the app. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | # list the built-in apps 23 | 24 | run_tau_app() 25 | ## Available shiny example apps: 26 | ## ----------------------------- 27 | ## tau01 - TauCharts Shiny Example 01 28 | 29 | # run an app 30 | 31 | # run_tau_app("tau01") 32 | ## Running shiny app [tau01] from: 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /man/tau_add_css_rule.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rules.r 3 | \name{tau_add_css_rule} 4 | \alias{tau_add_css_rule} 5 | \title{Add a CSS rule to the rendered htmlwidget} 6 | \usage{ 7 | tau_add_css_rule(tau, rule, warn = TRUE) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{rule}{character vector of CSS rule(s) to add to the widget DOM} 13 | 14 | \item{warn}{show warnings for global CSS rules? (default: \code{TRUE})} 15 | } 16 | \value{ 17 | taucharts htmlwidget object 18 | } 19 | \description{ 20 | This function will add a CSS rule to a widget-created 21 | DOM stylesheet. \code{rule} should be a valid CSS rule as you 22 | would enter in a \code{} block. No checking is done 23 | to ensure validity. 24 | } 25 | \details{ 26 | Use \code{\{\{ID\}\}} (followed by a space) to target the CSS rule 27 | just to the widget vs the whole DOM. 28 | 29 | Vectorized over \code{rule} 30 | } 31 | \note{ 32 | This is for expert use only. You need to know quite a bit about the visualization 33 | and target DOM to effectively use this function. CSS rules without the \code{\{\{ID\}\}} 34 | are applied to the entire DOM. 35 | } 36 | \examples{ 37 | # change the default white tooltip to black 38 | 39 | if (interactive()) { 40 | make_black_tooltip <- function(tau) { 41 | tau \%>\% 42 | tau_add_css_rule( 43 | ".tau-chart__tooltip__gray-text { color: white; font-weight: bold; }") \%>\% 44 | tau_add_css_rule( 45 | ".tau-chart__tooltip__list__elem:first-child {color:white;font-weight:bold;}") \%>\% 46 | tau_add_css_rule( 47 | ".tau-chart__tooltip__exclude { color: white; }") \%>\% 48 | tau_add_css_rule( 49 | paste0(c(".tau-chart__tooltip__exclude:hover { color: #65717f; ", 50 | "background: linear-gradient(to right, rgba(255, 255, 255, 0) 100\%, ", 51 | "rgba(235, 238, 241, 0.9) 0\%); }"), collapse="\\n")) \%>\% 52 | tau_add_css_rule(".tau-chart__tooltip { background: black; color: white; }") 53 | } 54 | 55 | tauchart(mtcars) \%>\% 56 | tau_point("wt", "mpg", color="cyl") \%>\% 57 | tau_color_manual(c("blue", "maroon", "black")) \%>\% 58 | tau_tooltip() \%>\% 59 | make_black_tooltip() 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /man/tau_annotations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_annotations} 4 | \alias{tau_annotations} 5 | \title{Add a TauCharts annotations plugin} 6 | \usage{ 7 | tau_annotations(tau, annotation_df) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{annotation_df}{a data frame with the following columns: 13 | dim: the data dimension to annotate (i.e. name of data column) 14 | val: the value (axis intercept) of the annotation 15 | text: the text to be displayed at the annotation 16 | front: if the annotation should be at in "front" of or "behind" the other data points 17 | color: hex color for annotation} 18 | } 19 | \description{ 20 | Add a TauCharts annotations plugin 21 | } 22 | \examples{ 23 | data(cars_data) 24 | tauchart(cars_data) \%>\% 25 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 26 | tau_annotations(data.frame(dim = "price", val = 50000, 27 | text = "Whoa there!", position = "front", 28 | color = '#4300FF')) 29 | } 30 | \seealso{ 31 | \code{\link{cars_data}} dataset 32 | } 33 | -------------------------------------------------------------------------------- /man/tau_area.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_area} 4 | \alias{tau_area} 5 | \title{Create a TauCharts area chart} 6 | \usage{ 7 | tau_area(tau, x, y, color = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{color}{quoted name of \code{data} column to map color aesthetic to} 17 | } 18 | \description{ 19 | Create a TauCharts area chart 20 | } 21 | \examples{ 22 | data(economics, package="ggplot2") 23 | tauchart(economics) \%>\% 24 | tau_area("date", "unemploy") \%>\% 25 | tau_guide_x(tick_format="\%Y") 26 | 27 | # facets 28 | library(dplyr) 29 | library(tidyr) 30 | 31 | crimes <- gather(add_rownames(USArrests, "State"), Crime, Amount, -State) 32 | tauchart(crimes) \%>\% 33 | tau_area("State", c("Crime", "Amount"), "Crime") \%>\% 34 | tau_guide_y(auto_scale = FALSE) 35 | } 36 | \references{ 37 | \url{http://api.taucharts.com/basic/bar.html}, 38 | \url{http://api.taucharts.com/basic/horizontal-bar.html} 39 | } 40 | -------------------------------------------------------------------------------- /man/tau_bar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_bar} 4 | \alias{tau_bar} 5 | \title{Create a TauCharts bar chart (horizontal or vertical)} 6 | \usage{ 7 | tau_bar(tau, x, y, color = NULL, size = NULL, horizontal = FALSE) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{color}{quoted name of \code{data} column to map color aesthetic to} 17 | 18 | \item{size}{quoted name of \code{data} column to make size aesthetic to} 19 | 20 | \item{horizontal}{should the bar chart be horizontal? (default: \code{FALSE} (no))} 21 | } 22 | \description{ 23 | Create a TauCharts bar chart (horizontal or vertical) 24 | } 25 | \examples{ 26 | data(mpg, package="ggplot2") 27 | tauchart(dplyr::count(mpg, class)) \%>\% 28 | tau_bar("class", "n") 29 | 30 | # facets 31 | tauchart(dplyr::count(mpg, manufacturer, class)) \%>\% 32 | tau_bar("class", c("manufacturer", "n")) 33 | #facets 34 | mfclass <- dplyr::count(mpg, manufacturer, model, class) 35 | tauchart(mfclass) \%>\% 36 | tau_bar(c("manufacturer", "model"), "n") 37 | 38 | # ordered factors on x-axis 39 | mfclass$class <- factor(mfclass$class, 40 | levels=c("2seater", "subcompact", "compact", 41 | "midsize", "minivan", "suv", "pickup"), 42 | ordered=TRUE) 43 | tauchart(mfclass) \%>\% 44 | tau_bar(c("class", "manufacturer"), "n") 45 | } 46 | \references{ 47 | \url{http://api.taucharts.com/basic/line.html} 48 | } 49 | -------------------------------------------------------------------------------- /man/tau_boxplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_boxplot} 4 | \alias{tau_boxplot} 5 | \title{Create a TauCharts box plot (horizontal or vertical)} 6 | \usage{ 7 | tau_boxplot(tau, x, y, horizontal = FALSE, mode = "outliers-only") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{horizontal}{should the bar chart be horizontal? (default: \code{FALSE} (no))} 17 | 18 | \item{mode}{when to show scatter points? e.g. "hide-scatter", "show-scatter", "outliers-only"} 19 | } 20 | \description{ 21 | There is no option for color mappings as the tauCharts plugin does not support this yet. 22 | } 23 | \examples{ 24 | tauchart(mtcars) \%>\% 25 | tau_boxplot("gear", "mpg", mode="hide-scatter") \%>\% 26 | tau_guide_y(nice=FALSE) 27 | } 28 | -------------------------------------------------------------------------------- /man/tau_color_538.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_538} 4 | \alias{tau_color_538} 5 | \title{Use the "fivethirtyeight.com" palette used in the charts} 6 | \usage{ 7 | tau_color_538(tau, n = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of desired colors} 13 | } 14 | \description{ 15 | The standard fivethirtyeight.com palette for line plots is blue, red, green. 16 | } 17 | \examples{ 18 | tauchart(mtcars) \%>\% 19 | tau_point("wt", "mpg", color="cyl") \%>\% 20 | tau_color_538() 21 | } 22 | \references{ 23 | \url{http://api.taucharts.com/advanced/encoding.html} 24 | } 25 | \seealso{ 26 | \code{\link[ggthemes]{fivethirtyeight_pal}} 27 | } 28 | -------------------------------------------------------------------------------- /man/tau_color_brewer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_brewer} 4 | \alias{tau_color_brewer} 5 | \title{Use the ColorBrewer palette in the charts} 6 | \usage{ 7 | tau_color_brewer(tau, n = NULL, palette = "Set2") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of colors to generate (no checking is done to ensure the palette 13 | has \code{n} colors).} 14 | 15 | \item{palette}{ColorBrewer palette name. One of \code{"Set2"}, \code{"BrBG"}, 16 | \code{"PiYG"}, \code{"PRGn"}, \code{"PuOr"}, \code{"RdBu"}, \code{"RdGy"}, \code{"RdYlBu"}, 17 | \code{"RdYlGn"}, \code{"Spectral"}, \code{"Accent"}, \code{"Dark2"}, \code{"Paired"}, 18 | \code{"Pastel1"}, \code{"Pastel2"}, \code{"Set1"}, \code{"Set3"}, \code{"Blues"}, 19 | \code{"BuGn"}, \code{"BuPu"}, \code{"GnBu"}, \code{"Greens"}, \code{"Greys"}, \code{"Oranges"}, 20 | \code{"OrRd"}, \code{"PuBu"}, \code{"PuBuGn"}, \code{"PuRd"}, \code{"Purples"}, 21 | \code{"RdPu"}, \code{"Reds"}, \code{"YlGn"}, \code{"YlGnBu"}, \code{"YlOrBr"}, \code{"YlOrRd"}.} 22 | } 23 | \description{ 24 | Use the ColorBrewer palette in the charts 25 | } 26 | \note{ 27 | It is highly suggested that callers use the ColorBrewer qualitative palettes: 28 | ["Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set1", "Set2", "Set3"], 29 | especially if you are plotting categorical values (which you most liklely are 30 | since you're using this package). 31 | } 32 | \examples{ 33 | tauchart(mtcars) \%>\% 34 | tau_point("wt", "mpg", color="cyl") \%>\% 35 | tau_color_brewer(3, "Set3") 36 | } 37 | \references{ 38 | \url{http://api.taucharts.com/advanced/encoding.html} 39 | } 40 | -------------------------------------------------------------------------------- /man/tau_color_economist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_economist} 4 | \alias{tau_color_economist} 5 | \title{Use the "Economist" palette used in the charts} 6 | \usage{ 7 | tau_color_economist(tau, n = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of desired colors} 13 | } 14 | \description{ 15 | The hues in the palette are blues, grays, and greens. Red is not included in 16 | these palettes and should be used to indicate important data. 17 | } 18 | \examples{ 19 | tauchart(mtcars) \%>\% 20 | tau_point("wt", "mpg", color="cyl") \%>\% 21 | tau_color_economist() 22 | } 23 | \references{ 24 | \url{http://api.taucharts.com/advanced/encoding.html} 25 | } 26 | \seealso{ 27 | \code{\link[ggthemes]{economist_pal}} 28 | } 29 | -------------------------------------------------------------------------------- /man/tau_color_few.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_few} 4 | \alias{tau_color_few} 5 | \title{Use the "Few" palette used in the charts} 6 | \usage{ 7 | tau_color_few(tau, n = NULL, palette = "medium") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of desired colors} 13 | 14 | \item{palette}{name of Few palette. One of \code{"medium"}, \code{"dark"} or \code{"light"}} 15 | } 16 | \description{ 17 | Qualitative color palettes from Stephen Few, "Practical Rules for Using Color in Charts". 18 | } 19 | \examples{ 20 | tauchart(mtcars) \%>\% 21 | tau_point("wt", "mpg", color="cyl") \%>\% 22 | tau_color_few() 23 | } 24 | \references{ 25 | \url{http://api.taucharts.com/advanced/encoding.html} 26 | } 27 | \seealso{ 28 | \code{\link[ggthemes]{few_pal}} 29 | } 30 | -------------------------------------------------------------------------------- /man/tau_color_highcharts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_highcharts} 4 | \alias{tau_color_highcharts} 5 | \title{Use the HighchartsJS palette used in the charts} 6 | \usage{ 7 | tau_color_highcharts(tau, n = NULL, palette = "default") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of desired colors} 13 | 14 | \item{palette}{name of Few palette. One of \code{"default"} or \code{"darkunica"}} 15 | } 16 | \description{ 17 | Qualitative color palettes from Stephen Few, "Practical Rules for Using Color in Charts". 18 | } 19 | \examples{ 20 | tauchart(mtcars) \%>\% 21 | tau_point("wt", "mpg", color="cyl") \%>\% 22 | tau_color_highcharts() 23 | } 24 | \references{ 25 | \url{http://api.taucharts.com/advanced/encoding.html} 26 | } 27 | \seealso{ 28 | \code{\link[ggthemes]{hc_pal}} 29 | } 30 | -------------------------------------------------------------------------------- /man/tau_color_manual.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_manual} 4 | \alias{tau_color_manual} 5 | \title{Specify the colors used in the charts} 6 | \usage{ 7 | tau_color_manual(tau, values = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{values}{vector of colors, ideally names (e.g. "\code{black}") or 13 | hex-format (e.g. "\code{#ffeeaa}")} 14 | } 15 | \description{ 16 | Vector can be optionally named in order to give explicit color/value mapping. 17 | } 18 | \examples{ 19 | tauchart(mtcars) \%>\% 20 | tau_point("wt", "mpg", color="cyl") \%>\% 21 | tau_color_manual(c("blue", "maroon", "black")) 22 | 23 | tauchart(mtcars) \%>\% 24 | tau_point("wt", "mpg", color="cyl") \%>\% 25 | tau_color_manual(c(`4`="blue",`6`= "maroon",`8`= "black")) 26 | } 27 | \references{ 28 | \url{http://api.taucharts.com/advanced/encoding.html} 29 | } 30 | -------------------------------------------------------------------------------- /man/tau_color_tableau.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_tableau} 4 | \alias{tau_color_tableau} 5 | \title{Use the Tableau palette in the charts} 6 | \usage{ 7 | tau_color_tableau(tau, palette = "tableau20") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{palette}{Tableau palette name. One of \code{"tableau20"}, 13 | \code{"tableau10medium"}, \code{"gray5"}, \code{"colorblind10"}, 14 | \code{"purplegray12"}, \code{"bluered12"}, \code{"greenorange12"}, \code{"cyclic"}.} 15 | } 16 | \description{ 17 | Use the Tableau palette in the charts 18 | } 19 | \examples{ 20 | tauchart(mtcars) \%>\% 21 | tau_point("wt", "mpg", color="cyl") \%>\% 22 | tau_color_tableau() 23 | } 24 | \references{ 25 | \url{http://api.taucharts.com/advanced/encoding.html} 26 | } 27 | -------------------------------------------------------------------------------- /man/tau_color_wsj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colors.r 3 | \name{tau_color_wsj} 4 | \alias{tau_color_wsj} 5 | \title{Use the "Wall Street Journal" palette used in the charts} 6 | \usage{ 7 | tau_color_wsj(tau, n = NULL, palette = "rgby") 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{n}{number of desired colors} 13 | 14 | \item{palette}{name of Few palette. One of \code{"rgby"}, \code{"green_red"}, 15 | \code{"green_black"}, \code{"dem_rep"} or \code{"colors6"}} 16 | } 17 | \description{ 18 | A subset of the plethora of palettes used by the WSJ. 19 | } 20 | \examples{ 21 | tauchart(mtcars) \%>\% 22 | tau_point("wt", "mpg", color="cyl") \%>\% 23 | tau_color_wsj() 24 | } 25 | \references{ 26 | \url{http://api.taucharts.com/advanced/encoding.html} 27 | } 28 | \seealso{ 29 | \code{\link[ggthemes]{wsj_pal}} 30 | } 31 | -------------------------------------------------------------------------------- /man/tau_export_plugin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_export_plugin} 4 | \alias{tau_export_plugin} 5 | \title{Add a TauCharts export plugin} 6 | \usage{ 7 | tau_export_plugin(tau) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | } 12 | \description{ 13 | Add a TauCharts export plugin 14 | } 15 | \examples{ 16 | data(cars_data) 17 | tauchart(cars_data) \%>\% 18 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 19 | tau_export_plugin() 20 | } 21 | \seealso{ 22 | \code{\link{cars_data}} dataset 23 | } 24 | -------------------------------------------------------------------------------- /man/tau_guide_gridlines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/guides.r 3 | \name{tau_guide_gridlines} 4 | \alias{tau_guide_gridlines} 5 | \title{Control showing of axis gridlines} 6 | \usage{ 7 | tau_guide_gridlines(tau, show_x = TRUE, show_y = TRUE) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{show_x, show_y}{if \code{TRUE}, show the gridline} 13 | } 14 | \description{ 15 | Control showing of axis gridlines 16 | } 17 | \examples{ 18 | if (interactive()) { 19 | tauchart(mtcars) \%>\% 20 | tau_point("mpg", "wt") \%>\% 21 | tau_guide_gridlines(FALSE, FALSE) 22 | } 23 | } 24 | \references{ 25 | \url{http://api.taucharts.com/basic/guide.html} 26 | } 27 | -------------------------------------------------------------------------------- /man/tau_guide_padding.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/guides.r 3 | \name{tau_guide_padding} 4 | \alias{tau_guide_padding} 5 | \title{Set overall chart padding} 6 | \usage{ 7 | tau_guide_padding(tau, bottom = 0, left = 0, top = 0, right = 0) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{bottom, top, left, right}{amount of padding} 13 | } 14 | \description{ 15 | Set overall chart padding 16 | } 17 | \examples{ 18 | if (interactive()) { 19 | tauchart(mtcars) \%>\% 20 | tau_point("mpg", "wt") \%>\% 21 | tau_guide_padding(40, 40, 40, 40) 22 | } 23 | } 24 | \references{ 25 | \url{http://api.taucharts.com/basic/guide.html} 26 | } 27 | -------------------------------------------------------------------------------- /man/tau_guide_x.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/guides.r 3 | \name{tau_guide_x} 4 | \alias{tau_guide_x} 5 | \title{Control x-axis padding, label, scale & tick format} 6 | \usage{ 7 | tau_guide_x(tau, padding = NULL, label = NULL, label_padding = NULL, 8 | nice = NULL, auto_scale = NULL, tick_period = NULL, 9 | tick_format = NULL, min = NULL, max = NULL) 10 | } 11 | \arguments{ 12 | \item{tau}{taucharts object} 13 | 14 | \item{padding}{space between axis ticks and chart panel} 15 | 16 | \item{label}{text of label for axis (overrides default use of variable name)} 17 | 18 | \item{label_padding}{space between axis ticks and axis label (can be negative)} 19 | 20 | \item{nice}{Taucharts engine tries to make axis scale "nice" by trying to start measure-based scale from 0 and adds some margins to complete scale with "nice" numbers. For example, if original scale domain contains values [8, 20, ... 40], then axis will have ticks from 0 to 45. 21 | (default: \code{TRUE}, if min and max values are set: \code{FALSE}).} 22 | 23 | \item{auto_scale}{(Deprecated) auto-pick "best" scale for axis? (default: \code{TRUE} (yes))} 24 | 25 | \item{tick_period}{if axis is auto-determined to be a "period scale", 26 | this allows specification of the period size. See \code{References} for more 27 | information.} 28 | 29 | \item{tick_format}{can be any 30 | \href{https://github.com/mbostock/d3/wiki/Formatting#d3_format}{D3 format specifier}} 31 | 32 | \item{min, max}{manual minimum and maximum for the axis} 33 | } 34 | \description{ 35 | Control x-axis padding, label, scale & tick format 36 | } 37 | \examples{ 38 | if (interactive()) { 39 | tauchart(mtcars) \%>\% 40 | tau_point("mpg", "wt") \%>\% 41 | tau_guide_x(label="Miles/gallon", nice=FALSE) \%>\% 42 | tau_guide_y(label="Weight", nice=FALSE) 43 | } 44 | } 45 | \references{ 46 | \url{http://api.taucharts.com/basic/guide.html}, 47 | \url{https://github.com/mbostock/d3/wiki/Formatting#d3_format} 48 | } 49 | -------------------------------------------------------------------------------- /man/tau_guide_y.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/guides.r 3 | \name{tau_guide_y} 4 | \alias{tau_guide_y} 5 | \title{Control y-axis padding, label, scale & tick format} 6 | \usage{ 7 | tau_guide_y(tau, padding = NULL, label = NULL, label_padding = NULL, 8 | nice = NULL, auto_scale = NULL, tick_period = NULL, 9 | tick_format = NULL, min = NULL, max = NULL) 10 | } 11 | \arguments{ 12 | \item{tau}{taucharts object} 13 | 14 | \item{padding}{space between axis ticks and chart panel} 15 | 16 | \item{label}{text of label for axis (overrides default use of variable name)} 17 | 18 | \item{label_padding}{space between axis ticks and axis label (can be negative)} 19 | 20 | \item{nice}{Taucharts engine tries to make axis scale "nice" by trying to start measure-based scale from 0 and adds some margins to complete scale with "nice" numbers. For example, if original scale domain contains values [8, 20, ... 40], then axis will have ticks from 0 to 45. 21 | (default: \code{TRUE}, if min and max values are set: \code{FALSE}).} 22 | 23 | \item{auto_scale}{(Deprecated) auto-pick "best" scale for axis? (default: \code{TRUE} (yes))} 24 | 25 | \item{tick_period}{if axis is auto-determined to be a "period scale", 26 | this allows specification of the period size. See \code{References} for more 27 | information.} 28 | 29 | \item{tick_format}{can be any 30 | \href{https://github.com/mbostock/d3/wiki/Formatting#d3_format}{D3 format specifier}} 31 | 32 | \item{min, max}{manual minimum and maximum for the axis} 33 | } 34 | \description{ 35 | Control y-axis padding, label, scale & tick format 36 | } 37 | \examples{ 38 | if (interactive()) { 39 | tauchart(mtcars) \%>\% 40 | tau_point("mpg", "wt") \%>\% 41 | tau_guide_x(label="Miles/gallon", nice=FALSE) \%>\% 42 | tau_guide_y(label="Weight", nice=FALSE) 43 | } 44 | } 45 | \references{ 46 | \url{http://api.taucharts.com/basic/guide.html}, 47 | \url{https://github.com/mbostock/d3/wiki/Formatting#d3_format} 48 | } 49 | -------------------------------------------------------------------------------- /man/tau_legend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_legend} 4 | \alias{tau_legend} 5 | \title{Add a TauCharts legend} 6 | \usage{ 7 | tau_legend(tau) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | } 12 | \description{ 13 | Add a TauCharts legend 14 | } 15 | \examples{ 16 | data(cars_data) 17 | tauchart(cars_data) \%>\% 18 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 19 | tau_legend() 20 | } 21 | \seealso{ 22 | \code{\link{cars_data}} dataset 23 | } 24 | -------------------------------------------------------------------------------- /man/tau_line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_line} 4 | \alias{tau_line} 5 | \title{Create a TauCharts line chart} 6 | \usage{ 7 | tau_line(tau, x, y, color = NULL, size = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{color}{quoted name of \code{data} column to map color aesthetic to} 17 | 18 | \item{size}{quoted name of \code{data} column to make size aesthetic to} 19 | } 20 | \description{ 21 | Create a TauCharts line chart 22 | } 23 | \examples{ 24 | data(economics, package="ggplot2") 25 | tauchart(economics) \%>\% 26 | tau_line("date", "unemploy") \%>\% 27 | tau_guide_x(tick_format="\%Y") 28 | 29 | # facets 30 | library(dplyr) 31 | library(tidyr) 32 | 33 | crimes <- gather(add_rownames(USArrests, "State"), Crime, Amount, -State) 34 | tauchart(crimes) \%>\% 35 | tau_line("State", c("Crime", "Amount"), "Crime") \%>\% 36 | tau_guide_y(auto_scale = FALSE) 37 | } 38 | \references{ 39 | \url{http://api.taucharts.com/basic/bar.html}, 40 | \url{http://api.taucharts.com/basic/horizontal-bar.html} 41 | } 42 | -------------------------------------------------------------------------------- /man/tau_point.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_point} 4 | \alias{tau_point} 5 | \title{Create a TauCharts scatterplot} 6 | \usage{ 7 | tau_point(tau, x, y, color = NULL, size = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{color}{quoted name of \code{data} column to map color aesthetic to} 17 | 18 | \item{size}{quoted name of \code{data} column to make size aesthetic to} 19 | } 20 | \description{ 21 | Create a TauCharts scatterplot 22 | } 23 | \examples{ 24 | tauchart(mtcars) \%>\% tau_point("mpg", "wt") 25 | mtcars$cyl <- factor(mtcars$cyl) 26 | tauchart(mtcars) \%>\% tau_point("mpg", "wt", "cyl", "hp") 27 | } 28 | \references{ 29 | \url{http://api.taucharts.com/basic/scatterplot.html} 30 | } 31 | -------------------------------------------------------------------------------- /man/tau_quick_filter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_quick_filter} 4 | \alias{tau_quick_filter} 5 | \title{Add a TauCharts quick filter plugin} 6 | \usage{ 7 | tau_quick_filter(tau, fields = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{fields}{fields which should be shown in quick filter} 13 | } 14 | \description{ 15 | Add a TauCharts quick filter plugin 16 | } 17 | \examples{ 18 | data(cars_data) 19 | tauchart(cars_data) \%>\% 20 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 21 | tau_quick_filter(fields = c("price")) 22 | } 23 | \seealso{ 24 | \code{\link{cars_data}} dataset 25 | } 26 | -------------------------------------------------------------------------------- /man/tau_set_font.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fonts.r 3 | \name{tau_set_font} 4 | \alias{tau_set_font} 5 | \title{Set the font family for the TauCharts chart} 6 | \usage{ 7 | tau_set_font(tau, 8 | family = "OpenSans, 'Helvetica Neue', Helvetica, Arial, sans-serif", 9 | import_url = paste0(c("https://fonts.googleapis.com/css?family=Open+Sans:400,", 10 | "400italic,600,700,600italic,700italic,800,300,300italic,800italic"), collapse 11 | = "")) 12 | } 13 | \arguments{ 14 | \item{tau}{taucharts object} 15 | 16 | \item{family}{CSS \code{font-family} spec (just the comma-separated font names)} 17 | 18 | \item{import_url}{the \code{} href if the fonts come from an external source} 19 | } 20 | \value{ 21 | taucharts object 22 | } 23 | \description{ 24 | Set the font family (standard CSS \code{font-family} specification, comma-separated 25 | font names only) and an optional font CSS URL to load the font from. 26 | } 27 | \examples{ 28 | tauchart(mtcars) \%>\% 29 | tau_point("mpg", "wt", "cyl") \%>\% 30 | tau_legend() \%>\% 31 | tau_color_brewer() \%>\% 32 | tau_tooltip() \%>\% 33 | tau_set_font("Montserrat, sans-serif", 34 | "http://fonts.googleapis.com/css?family=Montserrat:400,700") 35 | } 36 | -------------------------------------------------------------------------------- /man/tau_stacked_bar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geoms.r 3 | \name{tau_stacked_bar} 4 | \alias{tau_stacked_bar} 5 | \title{Create a TauCharts stacked bar chart (experimental)} 6 | \usage{ 7 | tau_stacked_bar(tau, x, y, color = NULL, size = NULL, horizontal = FALSE) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{x}{quoted name of \code{data} column to use for x-axis values} 13 | 14 | \item{y}{quoted name of \code{data} column to use for y-axis values} 15 | 16 | \item{color}{quoted name of \code{data} column to map color aesthetic to. 17 | NOTE that the parameter to this is what really defines the stacking.} 18 | 19 | \item{size}{quoted name of \code{data} column to make size aesthetic to} 20 | 21 | \item{horizontal}{should the bar chart be horizontal? (default: \code{FALSE} (no))} 22 | } 23 | \description{ 24 | The API supports it but it's not documented at all 25 | } 26 | \examples{ 27 | data(mpg, package="ggplot2") 28 | tauchart(dplyr::count(mpg, class, drv)) \%>\% 29 | tau_stacked_bar("class", "n", "drv") \%>\% 30 | tau_guide_gridlines(FALSE, FALSE) \%>\% 31 | tau_tooltip() 32 | } 33 | \references{ 34 | \url{http://api.taucharts.com/basic/line.html} 35 | } 36 | -------------------------------------------------------------------------------- /man/tau_tasks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tasks.r 3 | \name{tau_tasks} 4 | \alias{tau_tasks} 5 | \title{Add post-render JavaScript tasks to taucharts} 6 | \usage{ 7 | tau_tasks(tau, task = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{task}{either a \code{character} or \code{\link[htmlwidgets]{JS}} 13 | representing a JavaScript function to run after a tauchart has 14 | been rendered. This provides the ability for advanced customization. 15 | The JavaScript function will be \code{call}ed so \code{this.el} will be 16 | the containing \code{div} element and \code{this.chart} will be the 17 | \code{taucharts} object.} 18 | } 19 | \description{ 20 | Add post-render JavaScript tasks to taucharts 21 | } 22 | \examples{ 23 | if (interactive()) { 24 | tauchart(mtcars) \%>\% 25 | tau_point("mpg", "wt") \%>\% 26 | tau_tasks("function(){alert('I drew a chart')}") \%>\% 27 | tau_tasks(htmlwidgets::JS( 28 | "function(){alert('Yep, I really did.')}" 29 | )) \%>\% 30 | tau_tasks( 31 | " 32 | function(){ 33 | d3.select(this.el).selectAll('.tau-chart__dot') 34 | .transition().style('opacity',0.1) 35 | .transition().style('opacity',0.9) 36 | .transition().style('opacity',0.1) 37 | .transition().style('opacity',0.9); 38 | } 39 | " 40 | ) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /man/tau_title.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/title.r 3 | \name{tau_title} 4 | \alias{tau_title} 5 | \title{Add a title to the tauchart plot} 6 | \usage{ 7 | tau_title(tau, title = "", div_css = "width:100\%", 8 | span_css = "font-weight:bold;margin:auto;text-align:center") 9 | } 10 | \arguments{ 11 | \item{tau}{taucharts object} 12 | 13 | \item{title}{title for the chart} 14 | 15 | \item{div_css}{style to apply to the surrounding \code{div}. You should probably set 16 | the width here.} 17 | 18 | \item{span_css}{CSS style to apply to the title \code{span}. The default is to center-align 19 | the text and using a bold font. Go. Crazy. 20 | Not tested in a Shiny context yet} 21 | } 22 | \value{ 23 | THIS DOES NOT RETURN AN \code{htmlwidget}!! It returns a \code{shiny.tag} 24 | class HTML (the widget is wrapped in a \code{
}). It should be the LAST 25 | call in a magrittr pipe chain or called to wrap a streamgraph object for 26 | output 27 | } 28 | \description{ 29 | This provides a hack-ish way to add a title to a tauchart. Heed the 30 | warning in \code{return} well. This is the last function you should use 31 | when building a \code{tauchart}.\cr 32 | \cr 33 | In interactive sessions this function uses \code{htmltools::html_print} to 34 | display the chart with title, otherwise it just returns the \code{shiny.tag}- 35 | classed object since that works well in R Markdown documents.\cr 36 | \cr 37 | This is most certainly a temporary hack. 38 | } 39 | \examples{ 40 | tauchart(mtcars) \%>\% 41 | tau_point("mpg", "wt") \%>\% 42 | tau_guide_y(auto_scale=FALSE) \%>\% 43 | tau_title("Some Really Good Plot Title", 44 | "font-weight:bold;margin:auto;text-align:center;font-size:24px; 45 | color:#7f7f7f;font-family:sans-serif") 46 | 47 | tauchart(mtcars) \%>\% 48 | tau_point("mpg", "wt") \%>\% 49 | tau_guide_y(auto_scale=FALSE) \%>\% 50 | tau_title("Some Really Good Plot Title", 51 | "font-weight:bold;margin:auto;text-align:right;font-size:24px; 52 | color:#7f7f7f;font-family:sans-serif") 53 | 54 | tauchart(mtcars, width="500px") \%>\% 55 | tau_point("mpg", "wt") \%>\% 56 | tau_guide_y(auto_scale=FALSE) \%>\% 57 | tau_title("Some Really Good Plot Title", 58 | "width:500px;font-weight:bold;margin:auto;text-align:left; 59 | font-size:24px;color:#7f7f7f;font-family:sans-serif") 60 | } 61 | -------------------------------------------------------------------------------- /man/tau_tooltip.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_tooltip} 4 | \alias{tau_tooltip} 5 | \title{Add a TauCharts tooltip} 6 | \usage{ 7 | tau_tooltip(tau, fields = NULL, formatters = NULL) 8 | } 9 | \arguments{ 10 | \item{tau}{taucharts object} 11 | 12 | \item{fields}{character vector of fields to display in the tooltip 13 | (default is to use all columns in \code{data})} 14 | 15 | \item{formatters}{a named list of options to format the tooltip values 16 | (see \url{https://api.taucharts.com/plugins/tooltip.html})} 17 | } 18 | \description{ 19 | Add a TauCharts tooltip 20 | } 21 | \examples{ 22 | data(cars_data) 23 | tauchart(cars_data) \%>\% 24 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 25 | tau_tooltip(c("vehicle", "year", "class", "price", "milespergallon")) 26 | 27 | tauchart(cars_data) \%>\% 28 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 29 | tau_tooltip( 30 | fields = c("vehicle", "year", "class", "price", "milespergallon"), 31 | formatters = list( 32 | milespergallon = list(label = "Miles per Gallon"), 33 | price = list(format = "3f"), 34 | vehicle = list(format = htmlwidgets::JS( 35 | "function(str) { 36 | return str.toUpperCase(); 37 | }") 38 | ) 39 | ) 40 | ) 41 | } 42 | \seealso{ 43 | \code{\link{cars_data}} dataset 44 | } 45 | -------------------------------------------------------------------------------- /man/tau_trendline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugins.R 3 | \name{tau_trendline} 4 | \alias{tau_trendline} 5 | \title{Add a TauCharts trendline} 6 | \usage{ 7 | tau_trendline(tau, type = NULL, hideError = FALSE, showPanel = TRUE, 8 | showTrend = TRUE, models = c("linear", "exponential", "logarithmic", 9 | "loess", "lastvalue", "polynomial", "power")) 10 | } 11 | \arguments{ 12 | \item{tau}{taucharts object} 13 | 14 | \item{type}{\code{character} Model representing default trend line to show. Must be 15 | one of models specified in models parameter. 16 | If unspecified, will use the first model specified in models.} 17 | 18 | \item{hideError}{\code{logical} to show errors.} 19 | 20 | \item{showPanel}{\code{logical} to show the panel next to the chart to allow a user 21 | to manipulate the trendlines. When \code{FALSE}, the trendlines will 22 | still appear though.} 23 | 24 | \item{showTrend}{\code{logical} to show the trendlines on initial display. If 25 | \code{showPanel = TRUE}, then the user will have the opportunity 26 | to add/delete the trendlines.} 27 | 28 | \item{models}{\code{character} or \code{vector} of \code{characters} for the models 29 | to show in the trendline panel if \code{showPanel = TRUE}. If you 30 | would like to change the order of the options, then you can do 31 | \code{models = c("logarithmic","exponential")}, and the first provided 32 | will be the initial model type used.} 33 | } 34 | \description{ 35 | Add a TauCharts trendline 36 | } 37 | \examples{ 38 | data(cars_data) 39 | tauchart(cars_data) \%>\% 40 | tau_point("milespergallon", c("class", "price"), color="class") \%>\% 41 | tau_trendline() 42 | } 43 | \seealso{ 44 | \code{\link{cars_data}} dataset 45 | } 46 | -------------------------------------------------------------------------------- /man/tauchart.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/taucharts.R 3 | \name{tauchart} 4 | \alias{tauchart} 5 | \title{Create a new TauChart} 6 | \usage{ 7 | tauchart(data, width = NULL, height = NULL, inputId = NULL) 8 | } 9 | \arguments{ 10 | \item{data}{\code{data.frame}-like or \code{xts} object} 11 | 12 | \item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, 13 | \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 14 | string and have \code{'px'} appended.} 15 | 16 | \item{inputId}{the input slot used to access the clicked point (for Shiny).} 17 | } 18 | \description{ 19 | Performs basic widget setup and returns an object suitable for 20 | use with the other \code{tau_} functions. 21 | } 22 | \examples{ 23 | tauchart(mtcars) \%>\% tau_point("mpg", "wt") 24 | } 25 | \references{ 26 | \url{http://api.taucharts.com/} 27 | } 28 | -------------------------------------------------------------------------------- /man/taucharts-exports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/taucharts-package.r 3 | \name{taucharts-exports} 4 | \alias{taucharts-exports} 5 | \alias{\%>\%} 6 | \alias{JS} 7 | \title{taucharts exported operators} 8 | \description{ 9 | The following functions are imported and then re-exported 10 | from the taucharts package to enable use of the magrittr 11 | pipe operator with no additional library calls 12 | } 13 | -------------------------------------------------------------------------------- /man/taucharts-shiny.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shiny.r 3 | \name{taucharts-shiny} 4 | \alias{taucharts-shiny} 5 | \alias{tauchartsOutput} 6 | \alias{renderTaucharts} 7 | \title{Shiny bindings for taucharts} 8 | \usage{ 9 | tauchartsOutput(outputId, width = "100\%", height = "400px") 10 | 11 | renderTaucharts(expr, env = parent.frame(), quoted = FALSE) 12 | } 13 | \arguments{ 14 | \item{outputId}{output variable to read from} 15 | 16 | \item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, 17 | \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 18 | string and have \code{'px'} appended.} 19 | 20 | \item{expr}{An expression that generates a taucharts} 21 | 22 | \item{env}{The environment in which to evaluate \code{expr}.} 23 | 24 | \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This 25 | is useful if you want to save an expression in a variable.} 26 | } 27 | \description{ 28 | Output and render functions for using taucharts within Shiny 29 | applications and interactive Rmd documents. 30 | } 31 | -------------------------------------------------------------------------------- /man/taucharts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/taucharts-package.r 3 | \docType{package} 4 | \name{taucharts} 5 | \alias{taucharts} 6 | \alias{taucharts-package} 7 | \title{An \code{htmlwidget} interface to the 8 | \href{http://www.taucharts.com/}{TauCharts} D3 chart library} 9 | \description{ 10 | An \code{htmlwidget} interface to the 11 | \href{http://www.taucharts.com/}{TauCharts} D3 chart library 12 | } 13 | \author{ 14 | Bob Rudis (@hrbrmstr), Kent Russell (@timelyportfolio) 15 | } 16 | -------------------------------------------------------------------------------- /taucharts.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageBuildArgs: --resave-data 22 | PackageCheckArgs: --as-cran 23 | PackageRoxygenize: rd,collate,namespace 24 | -------------------------------------------------------------------------------- /tauchartsrpub.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "TauCharts htmlwidget" 3 | author: "Bob Rudis (@hrbrmstr)" 4 | output: 5 | html_document: 6 | theme: cosmo 7 | --- 8 | 9 | ```{r setup, include=FALSE} 10 | knitr::opts_chunk$set(echo = TRUE) 11 | ``` 12 | 13 | An R [htmlwidget](http://htmlwidgets.org/) interface to [TauCharts](http://www.taucharts.com/). 14 | 15 | [On GitHub](http://github.com/hrbrmstr/taucharts) 16 | 17 | Re-create TauCharts web site examples, starting with the data needed for the charts: 18 | 19 | ```{r init} 20 | # devtools::install_github("hrbrmstr/taucharts") 21 | library(taucharts) 22 | 23 | scatter_dat <- structure(list(team = c("d", "d", "d", "d", "l", "l", "l", "l", 24 | "k", "k", "k", "k"), cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L, 25 | 5L, 2L, 3L, 4L, 5L), effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 26 | 4L, 5L, 6L, 8L), count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L, 27 | 5L, 8L, 3L), priority = c("low", "low", "medium", "high", "low", 28 | "low", "medium", "high", "low", "low", "medium", "high")), .Names = c("team", 29 | "cycleTime", "effort", "count", "priority"), class = "data.frame", row.names = c(NA, 12L)) 30 | 31 | line_dat <- structure(list(type = c("us", "us", "us", "us", "us", "us", "bug", 32 | "bug", "bug", "bug", "bug"), count = c(0L, 10L, 15L, 12L, 16L, 33 | 13L, 21L, 19L, 23L, 26L, 23L), date = c("12-2013", "01-2014", 34 | "02-2014", "03-2014", "04-2014", "05-2014", "01-2014", "02-2014", 35 | "03-2014", "04-2014", "05-2014")), .Names = c("type", "count", 36 | "date"), class = "data.frame", row.names = c(NA, 11L)) 37 | 38 | bar_dat <- structure(list(team = c("d", "d", "d", "d", "l", "l", "l", "l", 39 | "k", "k", "k", "k"), cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L, 40 | 5L, 2L, 3L, 4L, 5L), effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 41 | 4L, 5L, 6L, 8L), count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L, 42 | 5L, 8L, 3L), priority = c("low", "low", "medium", "high", "low", 43 | "low", "medium", "high", "low", "low", "medium", "high")), .Names = c("team", 44 | "cycleTime", "effort", "count", "priority"), class = "data.frame", row.names = c(NA, 12L)) 45 | 46 | car_dat <- structure(list(car = c("Toyota Prius+", "Volvo S60", "BMV X5", 47 | "Infinity FX", "Mercedes Vito", "Peugeot 3008", "Subaru Forester", 48 | "Lexus RX", "Bentley Continental"), co2 = c(96L, 135L, 197L, 49 | 238L, 203L, 155L, 186L, 233L, 246L), hp = c(99L, 150L, 306L, 50 | 238L, 95L, 120L, 150L, 188L, 507L), euroEco = c("eco", "eco", 51 | "non-eco", "non-eco", "non-eco", "non-eco", "non-eco", "non-eco", 52 | "non-eco"), power = c("low", "normal", "high", "high", "low", 53 | "low", "normal", "normal", "high")), .Names = c("car", "co2", 54 | "hp", "euroEco", "power"), class = "data.frame", row.names = c(NA, 9L)) 55 | 56 | splom_dat <- structure(list(param1 = c("hp", "hp", "hp", "co2", "co2", "co2", 57 | "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", 58 | "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", 59 | "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", 60 | "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", 61 | "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", 62 | "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp", 63 | "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2", 64 | "co2", "co2", "mpg", "mpg", "mpg"), param2 = c("hp", "co2", "mpg", 65 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 66 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", 67 | "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", 68 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 69 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", 70 | "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", 71 | "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", 72 | "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg"), value1 = c(99, 73 | 99, 99, 96, 96, 96, 3.8, 3.8, 3.8, 150, 150, 150, 135, 135, 135, 74 | 7.4, 7.4, 7.4, 306, 306, 306, 197, 197, 197, 11.2, 11.2, 11.2, 75 | 238, 238, 238, 238, 238, 238, 11.2, 11.2, 11.2, 95, 95, 95, 203, 76 | 203, 203, 9.4, 9.4, 9.4, 120, 120, 120, 155, 155, 155, 9.2, 9.2, 77 | 9.2, 150, 150, 150, 186, 186, 186, 10.4, 10.4, 10.4, 188, 188, 78 | 188, 233, 233, 233, 13.3, 13.3, 13.3, 507, 507, 507, 246, 246, 79 | 246, 15.4, 15.4, 15.4), value2 = c(99, 96, 3.8, 99, 96, 3.8, 80 | 99, 96, 3.8, 150, 135, 7.4, 150, 135, 7.4, 150, 135, 7.4, 306, 81 | 197, 11.2, 306, 197, 11.2, 306, 197, 11.2, 238, 238, 11.2, 238, 82 | 238, 11.2, 238, 238, 11.2, 95, 203, 9.4, 95, 203, 9.4, 95, 203, 83 | 9.4, 120, 155, 9.2, 120, 155, 9.2, 120, 155, 9.2, 150, 186, 10.4, 84 | 150, 186, 10.4, 150, 186, 10.4, 188, 233, 13.3, 188, 233, 13.3, 85 | 188, 233, 13.3, 507, 246, 15.4, 507, 246, 15.4, 507, 246, 15.4 86 | )), .Names = c("param1", "param2", "value1", "value2"), class = "data.frame", row.names = c(NA, 87 | 81L)) 88 | ``` 89 | 90 | Now, mimic a good chunk of section 5 (and some others) of the [TauCharts basic examples](http://api.taucharts.com/basic/index.html). Interestingly enough, faceted charts work without any real code changes: 91 | 92 | ```{r charts_1} 93 | tauchart(scatter_dat) %>% 94 | tau_point("cycleTime", "effort", "team", "count") 95 | ``` 96 | 97 | ### ordered factors! 98 | 99 | ```{r charts_ordered} 100 | scatter_dat %>% 101 | { 102 | data.frame( 103 | ., 104 | cycleTimeFactor =factor(.$cycleTime, 105 | levels=rev(unique(.$cycleTime)), 106 | ordered=TRUE) 107 | ) 108 | } %>% 109 | tauchart %>% 110 | tau_point("cycleTimeFactor", "effort", "team", "count") 111 | ``` 112 | 113 | ### custom colors! 114 | 115 | ```{r charts_2} 116 | tauchart(scatter_dat) %>% 117 | tau_point("cycleTime", "effort", "team", "count") %>% 118 | tau_color_manual(c("orange", "green", "black")) 119 | 120 | tauchart(line_dat) %>% 121 | tau_line("date", "count", "type") %>% 122 | tau_guide_x(label="Month") %>% 123 | tau_guide_y(label="Count of completed entities", label_padding=50) %>% 124 | tau_guide_padding(70, 70, 10, 10) 125 | 126 | tauchart(bar_dat) %>% tau_bar("team", "effort") 127 | 128 | tauchart(bar_dat) %>% tau_bar("team", "effort", "priority") 129 | 130 | tauchart(bar_dat) %>% tau_bar("effort", "team", horizontal=TRUE) 131 | 132 | tauchart(bar_dat) %>% tau_bar("effort", "team", "priority", horizontal=TRUE) 133 | ``` 134 | 135 | ### legendary! 136 | 137 | ```{r chart_leg} 138 | tauchart(car_dat) %>% 139 | tau_point("power", "co2", color="euroEco") %>% 140 | tau_legend() 141 | ``` 142 | 143 | ### tooltips! 144 | 145 | ```{r chart_tips} 146 | tauchart(car_dat) %>% 147 | tau_point("power", "co2", color="euroEco") %>% 148 | tau_legend() %>% 149 | tau_tooltip() 150 | ``` 151 | 152 | ### basic facets! 153 | 154 | ```{r charts_3} 155 | print(car_dat) 156 | 157 | tauchart(car_dat) %>% 158 | tau_point(c('euroEco', 'co2'), c('power', 'hp')) 159 | ``` 160 | 161 | ### scatterplot matrices! 162 | 163 | ```{r charts_4} 164 | tauchart(splom_dat) %>% 165 | tau_point(c("param1", "value1"), c("param2", "value2")) 166 | ``` 167 | 168 | ### trends! 169 | 170 | ```{r trends} 171 | tc <- tauchart(car_dat) %>% 172 | tau_point( "hp", c("euroEco","co2"), color = "euroEco" ) %>% 173 | tau_legend( ) %>% 174 | tau_tooltip( ) 175 | 176 | tc %>% 177 | tau_trendline( ) #using defaults 178 | 179 | tc %>% 180 | #type does not seem to work as expected 181 | # so use models instead to change default type or order of dropdown 182 | tau_trendline( models = c( "logarithmic", "exponential" ) ) 183 | 184 | tc %>% 185 | # start with unclicked TREND LINE 186 | tau_trendline( showTrend = FALSE ) 187 | 188 | tc %>% 189 | #take the fun away from the user 190 | tau_trendline( showPanel = FALSE ) 191 | ``` 192 | 193 | ## Now do some other things outside the examples 194 | 195 | ### customize y axis labels! 196 | 197 | ```{r custom_1} 198 | how_good <- structure(list( 199 | Ranking = structure( 200 | 1:5, .Label = c("Bottom", "Bellow Average", 201 | "Average", "Above Average", "Top"), class = "factor" 202 | ), Prob = c(30L, 10L, 15L, 40L, 5L)/100 203 | ), .Names = c("Ranking", "Prob"), row.names = c(NA,-5L), class = "data.frame") 204 | 205 | # NOTE my division by 100 in Prob above 206 | 207 | tauchart(how_good) %>% 208 | tau_bar(x="Ranking", y="Prob") %>% 209 | tau_guide_y(tick_format="%") 210 | ``` 211 | 212 | ### the whole shebang! 213 | 214 | ```{r shebang} 215 | data(cars_data) 216 | tauchart(cars_data) %>% 217 | tau_point("milespergallon", c("class", "price"), color="class") %>% 218 | tau_legend() %>% 219 | tau_trendline() %>% 220 | tau_tooltip(c("vehicle", "year", "class", "price", "milespergallon")) 221 | ``` 222 | 223 | ### custom CSS rules! 224 | 225 | ```{r custom_styles} 226 | make_black_tooltip <- function(tau) { 227 | tau %>% 228 | tau_add_css_rule(".tau-chart__tooltip { background: black; color: white; }") %>% 229 | tau_add_css_rule(".tau-chart__tooltip__exclude:hover { color: #65717f; background: linear-gradient(to right, rgba(255, 255, 255, 0) 100%, rgba(235, 238, 241, 0.9) 0%); }") %>% 230 | tau_add_css_rule(".tau-chart__tooltip__exclude { color: white; }") %>% 231 | tau_add_css_rule(".tau-chart__tooltip__list__elem { color: white; }") %>% 232 | tau_add_css_rule(".tau-chart__tooltip__list__elem:first-child { color: white; font-weight: bold; }") %>% 233 | tau_add_css_rule(".tau-chart__tooltip__gray-text { color: white; font-weight: bold; }") 234 | } 235 | 236 | tauchart(mtcars) %>% 237 | tau_point("wt", "mpg", color="cyl") %>% 238 | tau_color_manual(c("blue", "maroon", "black")) %>% 239 | tau_tooltip() %>% 240 | make_black_tooltip() 241 | ``` 242 | 243 | alternatively 244 | 245 | ```{r multi_styles} 246 | tauchart(mtcars) %>% 247 | tau_point("wt", "mpg", color="cyl") %>% 248 | tau_color_manual(c("blue", "maroon", "black")) %>% 249 | tau_tooltip() %>% 250 | tau_add_css_rule(c(".tau-chart__tooltip { background: black; color: white; }", 251 | ".tau-chart__tooltip__exclude:hover { color: #65717f; background: linear-gradient(to right, rgba(255, 255, 255, 0) 100%, rgba(235, 238, 241, 0.9) 0%); }", 252 | ".tau-chart__tooltip__exclude { color: white; }", 253 | ".tau-chart__tooltip__list__elem { color: white; }", 254 | ".tau-chart__tooltip__list__elem:first-child { color: white; font-weight: bold; }", 255 | ".tau-chart__tooltip__gray-text { color: white; font-weight: bold; }")) 256 | ``` 257 | 258 | FIN 259 | -------------------------------------------------------------------------------- /tests/test.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "test" 3 | output: 4 | html_document: 5 | theme: united 6 | --- 7 | 8 | ```{r setup, include=FALSE} 9 | library(taucharts) 10 | knitr::opts_chunk$set(echo = FALSE) 11 | testdata <- data.frame(date = seq(as.Date("2016-02-29") - 300, Sys.Date(), by = "day"), val = rnorm(43)) 12 | ``` 13 | 14 | # Tabs {.tabset} 15 | 16 | ## Tab One 17 | ```{r} 18 | tauchart(testdata) %>% 19 | tau_line("date", "val") %>% 20 | tau_guide_x(tick_format = "%b-%y") 21 | ``` 22 | 23 | ## Tab Two (test rescalaing issue) 24 | ```{r} 25 | tauchart(testdata) %>% 26 | tau_line("date", "val") %>% 27 | tau_guide_x(tick_format = "%b-%y") 28 | ``` 29 | 30 | ## Adjust viz size with chunk settings 31 | ### Super Small 32 | ```{r fig.width=2, fig.height=2} 33 | tauchart(testdata) %>% 34 | tau_line("date", "val") %>% 35 | tau_guide_x(tick_format = "%b-%y") 36 | ``` 37 | 38 | ### Super big 39 | ```{r fig.width=10, fig.height=10} 40 | tauchart(testdata) %>% 41 | tau_line("date", "val") %>% 42 | tau_guide_x(tick_format = "%b-%y") 43 | ``` 44 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(taucharts) 3 | 4 | test_check("taucharts") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-taucharts.R: -------------------------------------------------------------------------------- 1 | context("basic functionality") 2 | test_that("we can do something", { 3 | 4 | #expect_that(some_function(), is_a("data.frame")) 5 | 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/tests.R: -------------------------------------------------------------------------------- 1 | testdata <- data.frame(date = seq(as.Date("2016-02-29") - 300, as.Date("2016-02-29"), by = "day"), val = rnorm(43)) 2 | 3 | # Test selecting specific fields for quick filter 4 | tauchart(mtcars) %>% 5 | tau_point("mpg", "wt") %>% 6 | tau_quick_filter(fields = c("mpg", "wt")) 7 | 8 | # Double date scales currently result in confusing warning... 9 | testdate <- testdata 10 | testdate$date2 <- testdate$date 11 | tauchart(testdate) %>% 12 | tau_point("date", "date2") 13 | 14 | 15 | # Trendline default can be changed to exponential 16 | tauchart(mtcars) %>% 17 | tau_point("mpg", "wt") %>% 18 | tau_trendline(type = "exponential", models = c("lastvalue", "logarithmic", "exponential")) 19 | 20 | # Autoscale fails for time data 21 | tauchart(head(testdata, 6)) %>% 22 | tau_line("date", "val") %>% 23 | tau_guide_x(tick_format = "%b-%y", tick_period = 7) 24 | 25 | # width & height fail... 26 | tauchart(testdata, width = "100px", height = "100px") %>% 27 | tau_line("date", "val") 28 | 29 | # Tick period fails fails for time data 30 | tauchart(testdata) %>% 31 | tau_line("date", "val") %>% 32 | tau_guide_x(tick_format = "%b-%y", tick_period = 28) 33 | 34 | # Tick period fails fails for continuous data 35 | tauchart(testdata) %>% 36 | tau_line("val", "val") %>% 37 | tau_guide_x(tick_period = 50) 38 | 39 | # Tick period fails fails for continuous data 40 | tauchart(testdata) %>% 41 | tau_line("val", "val") %>% 42 | tau_export_plugin() 43 | --------------------------------------------------------------------------------