├── LICENSE ├── .Rbuildignore ├── .gitignore ├── inst ├── htmlwidgets │ ├── lib │ │ ├── jquery.sparkline │ │ │ ├── jquery.sparkline.css │ │ │ ├── package.json │ │ │ ├── README.md │ │ │ └── jquery.sparkline.min.js │ │ └── jquery │ │ │ ├── jquery-AUTHORS.txt │ │ │ └── jquery.min.js │ ├── sparkline.yaml │ └── sparkline.js └── examples │ ├── examples_dplyr.R │ ├── examples_dependencies.r │ ├── examples_composite.R │ └── sparkline_histogram.R ├── NAMESPACE ├── man ├── html_dependency_sparkline.Rd ├── sparkline.Rd ├── sparkline-shiny.Rd ├── spk_add_deps.Rd ├── spk_chr.Rd └── spk_composite.Rd ├── cran-comments.md ├── sparkline.Rproj ├── vignettes └── intro_sparkline.Rmd ├── DESCRIPTION ├── R ├── composite.R ├── helpers.R └── sparkline.R ├── CONDUCT.md └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2016 2 | COPYRIGHT HOLDER: Ramnath Vaidyanathan 3 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^CONDUCT\.md$ 4 | ^cran-comments\.md$ 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | inst/doc 5 | inst/examples/*_files/*.* 6 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/jquery.sparkline/jquery.sparkline.css: -------------------------------------------------------------------------------- 1 | .jqstooltip { 2 | -webkit-box-sizing: content-box; 3 | -moz-box-sizing: content-box; 4 | box-sizing: content-box; 5 | } 6 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(html_dependency_sparkline) 4 | export(renderSparkline) 5 | export(sparkline) 6 | export(sparklineOutput) 7 | export(spk_add_deps) 8 | export(spk_chr) 9 | export(spk_composite) 10 | import(htmltools) 11 | import(htmlwidgets) 12 | -------------------------------------------------------------------------------- /inst/htmlwidgets/sparkline.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: jquery 3 | version: 1.11.3 4 | src: "htmlwidgets/lib/jquery" 5 | script: jquery.min.js 6 | - name: jquery-sparkline 7 | version: 2.1.2 8 | src: "htmlwidgets/lib/jquery.sparkline" 9 | script: jquery.sparkline.js 10 | stylesheet: jquery.sparkline.css 11 | -------------------------------------------------------------------------------- /man/html_dependency_sparkline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{html_dependency_sparkline} 4 | \alias{html_dependency_sparkline} 5 | \title{An HTML dependency for sparkline} 6 | \usage{ 7 | html_dependency_sparkline() 8 | } 9 | \description{ 10 | An HTML dependency for sparkline 11 | } 12 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | Resumbission 1 2 | 3 | *switching back to Ramnath as maintainer. 4 | 5 | ## Test environments 6 | * local Windows 10 install, R 3.3.1 7 | * rhub check_for_cran() 8 | 9 | ## R CMD check results 10 | 11 | 0 errors | 0 warnings | 1 note 12 | 13 | * This is a new release. 14 | 15 | ## Reverse dependencies 16 | 17 | This is a new release, so there are no reverse dependencies. 18 | -------------------------------------------------------------------------------- /sparkline.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /inst/examples/examples_dplyr.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | #spk_chr works well with dplyr summarise 3 | 4 | library(dplyr) 5 | library(sparkline) 6 | library(formattable) 7 | 8 | mtcars %>% 9 | group_by(cyl) %>% 10 | summarise( 11 | hp = spk_chr( 12 | hp, type="box", 13 | chartRangeMin=0, chartRangeMax=max(mtcars$hp) 14 | ), 15 | mpg = spk_chr( 16 | mpg, type="box", 17 | chartRangeMin=0, chartRangeMax=max(mtcars$mpg) 18 | ) 19 | ) %>% 20 | formattable() %>% 21 | formattable::as.htmlwidget() %>% 22 | spk_add_deps() 23 | } 24 | -------------------------------------------------------------------------------- /inst/examples/examples_dependencies.r: -------------------------------------------------------------------------------- 1 | # use spk_add_deps with other htmlwidgets 2 | 3 | library(sparkline) 4 | library(formattable) 5 | 6 | fw <- as.htmlwidget( 7 | formattable( 8 | data.frame( 9 | id = c("a", "b"), 10 | sparkline = c( 11 | spk_chr(runif(10,0,10), type="bar"), 12 | spk_chr(runif(10,0,5), type="bar") 13 | ), 14 | stringsAsFactors = FALSE 15 | ) 16 | ) 17 | ) 18 | 19 | spk_add_deps(fw) 20 | 21 | # use spk_add_deps with htmltools/shiny tags 22 | 23 | library(sparkline) 24 | library(htmltools) 25 | 26 | div <- tags$div( 27 | spk_chr(1:10, type="bar") 28 | ) 29 | 30 | spk_add_deps(div) 31 | -------------------------------------------------------------------------------- /vignettes/intro_sparkline.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "jquery Sparkline HTML Widget" 3 | author: "Ramnath Vaidyanathan" 4 | date: "July 18, 2014" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Introduction to Sparkline} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r} 13 | library(htmlwidgets) 14 | library(sparkline) 15 | set.seed(1234) 16 | x = rnorm(10) 17 | y = rnorm(10) 18 | ``` 19 | 20 | 21 | Inline line graphs `r sparkline(x)` 22 | 23 | Bar charts `r sparkline(abs(x), type = 'bar')` negative values: `r sparkline(x, type = 'bar')` 24 | 25 | ### Include in tables 26 | 27 | | Stock | Sparkline | Boxplot 28 | |-------|-------------------|-------- 29 | | x | `r sparkline(x)` | `r sparkline(x, type ='box')` 30 | | y | `r sparkline(y)` | `r sparkline(y, type ='box')` 31 | -------------------------------------------------------------------------------- /man/sparkline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparkline.R 3 | \name{sparkline} 4 | \alias{sparkline} 5 | \title{Interactive Sparklines} 6 | \usage{ 7 | sparkline(values, ..., width = 60, height = 20, elementId = NULL, 8 | renderSelector = NULL) 9 | } 10 | \arguments{ 11 | \item{values}{\code{vector} of values to visualize} 12 | 13 | \item{...}{additional options passed to \code{jquery.sparkline}; see 14 | \href{http://omnipotent.net/jquery.sparkline/#common}{jquery.sparkline docs}} 15 | 16 | \item{height, width}{height and width of sparkline htmlwidget 17 | specified in any valid \code{CSS} size unit.} 18 | 19 | \item{elementId}{\code{string} id as a valid \code{CSS} element id.} 20 | 21 | \item{renderSelector}{\code{string} as \code{CSS} selector to render 22 | in a DOM element other than the \code{htmlwidget} container} 23 | } 24 | \description{ 25 | Create interactive sparklines for inline visualization. 26 | } 27 | 28 | -------------------------------------------------------------------------------- /inst/examples/examples_composite.R: -------------------------------------------------------------------------------- 1 | library(sparkline) 2 | 3 | sl1 <- sparkline( 4 | c(5,4,5,-2,0,3), 5 | type='bar', 6 | barColor="#aaf", 7 | chartRangeMin=-5, 8 | chartRangeMax=10, 9 | # set an id that will make it easier to refer 10 | # in the next sparkline 11 | elementId="sparkline-for-composite" 12 | ) 13 | 14 | sl2 <- sparkline( 15 | c(4,1,5,7,9,9,8,7,6,6,4,7,8,4,3,2,2,5,6,7), 16 | type="line", 17 | fillColor = FALSE, 18 | lineColor ='red', 19 | chartRangeMin = -5, 20 | chartRangeMax = 10 21 | ) 22 | 23 | # add sparkline as a composite 24 | spk_composite(sl1, sl2) 25 | 26 | # add values and options as a composite 27 | spk_composite( 28 | sl1, 29 | values=c(4,1,5,7,9,9,8,7,6,6,4,7,8,4,3,2,2,5,6,7), 30 | options = list( 31 | type="line", 32 | fillColor = FALSE, 33 | lineColor ='red', 34 | chartRangeMin = -5, 35 | chartRangeMax = 10 36 | ) 37 | ) 38 | 39 | # add combination of sparkline and options as a composite 40 | spk_composite( 41 | sl1, 42 | sl2, 43 | options = list( 44 | type="box" 45 | ) 46 | ) 47 | -------------------------------------------------------------------------------- /man/sparkline-shiny.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparkline.R 3 | \name{sparkline-shiny} 4 | \alias{renderSparkline} 5 | \alias{sparkline-shiny} 6 | \alias{sparklineOutput} 7 | \title{Shiny bindings for sparkline} 8 | \usage{ 9 | sparklineOutput(outputId, width = "60px", height = "20px") 10 | 11 | renderSparkline(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 sparkline} 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 sparkline within Shiny 29 | applications and interactive Rmd documents. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/spk_add_deps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{spk_add_deps} 4 | \alias{spk_add_deps} 5 | \title{Add Sparkline Dependencies to Tag or 'htmlwidget'} 6 | \usage{ 7 | spk_add_deps(tag_htmlwidget = NULL) 8 | } 9 | \arguments{ 10 | \item{tag_htmlwidget}{\code{shiny.tag} or \code{htmlwidget} to which 11 | you would like to add \code{sparkline} dependencies} 12 | } 13 | \value{ 14 | \code{shiny.tag} or \code{htmlwidget} 15 | } 16 | \description{ 17 | Add Sparkline Dependencies to Tag or 'htmlwidget' 18 | } 19 | \examples{ 20 | # use spk_add_deps with other htmlwidgets 21 | 22 | library(sparkline) 23 | library(formattable) 24 | 25 | fw <- as.htmlwidget( 26 | formattable( 27 | data.frame( 28 | id = c("a", "b"), 29 | sparkline = c( 30 | spk_chr(runif(10,0,10), type="bar"), 31 | spk_chr(runif(10,0,5), type="bar") 32 | ), 33 | stringsAsFactors = FALSE 34 | ) 35 | ) 36 | ) 37 | 38 | spk_add_deps(fw) 39 | 40 | # use spk_add_deps with htmltools/shiny tags 41 | 42 | library(sparkline) 43 | library(htmltools) 44 | 45 | div <- tags$div( 46 | spk_chr(1:10, type="bar") 47 | ) 48 | 49 | spk_add_deps(div) 50 | } 51 | 52 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: sparkline 2 | Type: Package 3 | Title: 'jQuery' Sparkline 'htmlwidget' 4 | Version: 2.0 5 | Date: 2016-11-10 6 | Authors@R: c( 7 | person("Ramnath", "Vaidyanathan", email = "ramnath.vaidya@gmail.com", role = c("aut", "cre")), 8 | person("Kent", "Russell", email = "kent.russell@timelyportfolio.com", role = c("aut", "ctb")), 9 | person("Gareth", "Watts", role = c("aut", "cph"), comment = "jquery.sparkline library in htmlwidgets/lib, https://github.com/gwatts/jquery.sparkline"), 10 | person(family = "jQuery Foundation", role = "cph", comment = "jQuery library"), 11 | person(family = "jQuery contributors", role = c("ctb", "cph"), 12 | comment = "jQuery library; authors listed in inst/htmlwidgets/lib/jquery/jquery-AUTHORS.txt" 13 | ) 14 | ) 15 | Maintainer: Ramnath Vaidyanathan 16 | Description: Include interactive sparkline charts 17 | in 18 | all R contexts with the convenience of 'htmlwidgets'. 19 | Imports: 20 | htmltools, 21 | htmlwidgets (>= 0.8) 22 | Suggests: 23 | formattable, 24 | knitr, 25 | rmarkdown, 26 | shiny 27 | License: MIT + file LICENSE 28 | RoxygenNote: 5.0.1 29 | VignetteBuilder: knitr 30 | -------------------------------------------------------------------------------- /R/composite.R: -------------------------------------------------------------------------------- 1 | #' Add a Composite to an Existing Sparkline 2 | #' 3 | #' @param sparkline \code{\link{sparkline}} to which we would like to add 4 | #' a composite. 5 | #' @param sparklineToAdd \code{\link{sparkline}} to add to another \code{\link{sparkline}} 6 | #' @param ... extra arguments to modify \code{sparklineToAdd} or define a \code{\link{sparkline}}. 7 | #' 8 | #' @return \code{\link{sparkline}} object 9 | #' @export 10 | #' 11 | #' @example inst/examples/examples_composite.R 12 | spk_composite <- function(sparkline=NULL, sparklineToAdd=NULL, ...){ 13 | stopifnot( 14 | !is.null(sparkline), 15 | inherits(sparkline,"sparkline") 16 | ) 17 | 18 | sparkline_options <- list() 19 | 20 | # if a sparkline is provided to add 21 | # then get its values and options 22 | if(!is.null(sparklineToAdd)) { 23 | sparkline_options <- list( 24 | values = sparklineToAdd$x$values, 25 | options = sparklineToAdd$x$options 26 | ) 27 | } 28 | 29 | # if ... are provided 30 | # then use these for values and options 31 | if(length(list(...)) > 0) { 32 | sparkline_options <- utils::modifyList(sparkline_options,list(...)) 33 | } 34 | 35 | sparkline_options$options$composite <- TRUE 36 | sparkline$x$composites[[length(sparkline$x$composites)+1]] <- sparkline_options 37 | return(sparkline) 38 | } 39 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/jquery.sparkline/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sparkline", 3 | "title": "jQuery Sparkline", 4 | "description": "Easily generate small, inline sparkline charts directly in the browser", 5 | "keywords": ["canvas", "charts", "graphics", "graphing", "graphs", "sparklines", "ui", "vml"], 6 | "banner": "/* jquery.sparkline 2.1.3 - http://omnipotent.net/jquery.sparkline/ \n Licensed under the New BSD License - see above site for details */\n", 7 | "version": "2.1.4", 8 | "repository": "git@github.com:relayfoods/jquery.sparkline.git", 9 | "author": { 10 | "name": "Gareth Watts", 11 | "url": "http://gwatts.com/" 12 | }, 13 | "licenses": [{ 14 | "type": "BSD-3-Clause", 15 | "url": "http://opensource.org/licenses/BSD-3-Clause" 16 | }], 17 | "bugs": "https://github.com/gwatts/jquery.sparkline/issues", 18 | "homepage": "http://omnipotent.net/jquery.sparkline/", 19 | "demo": "http://omnipotent.net/jquery.sparkline/", 20 | "docs": "http://omnipotent.net/jquery.sparkline/#s-docs", 21 | "download": "http://omnipotent.net/jquery.sparkline/#s-download", 22 | "dependencies": { 23 | "jquery": ">=2.1.4" 24 | }, 25 | "devDependencies": { 26 | "grunt": "~0.4.5", 27 | "grunt-contrib-jshint": "~0.11.3", 28 | "grunt-contrib-uglify": "~0.9.2", 29 | "grunt-contrib-watch": "~0.6.1", 30 | "grunt-contrib-concat": "~0.5.1" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /R/helpers.R: -------------------------------------------------------------------------------- 1 | #' Add Sparkline Dependencies to Tag or 'htmlwidget' 2 | #' 3 | #' @param tag_htmlwidget \code{shiny.tag} or \code{htmlwidget} to which 4 | #' you would like to add \code{sparkline} dependencies 5 | #' 6 | #' @return \code{shiny.tag} or \code{htmlwidget} 7 | #' @export 8 | #' 9 | #' @example inst/examples/examples_dependencies.R 10 | 11 | spk_add_deps <- function(tag_htmlwidget = NULL) { 12 | stopifnot( 13 | !is.null(tag_htmlwidget), 14 | inherits(tag_htmlwidget,c("htmlwidget", "shiny.tag", "shiny.tag.list", 15 | "html")) 16 | ) 17 | 18 | # if tag use attachDependencies 19 | if (inherits(tag_htmlwidget, c("shiny.tag", "shiny.tag.list", "html"))) { 20 | return( 21 | htmltools::attachDependencies( 22 | tag_htmlwidget, 23 | spk_dependencies() 24 | ) 25 | ) 26 | } 27 | 28 | # if htmlwidget then append to $dependencies 29 | if(inherits(tag_htmlwidget, "htmlwidget")) { 30 | deps <- tag_htmlwidget$dependencies 31 | tag_htmlwidget$dependencies <- c( 32 | deps, 33 | spk_dependencies() 34 | ) 35 | tag_htmlwidget 36 | } 37 | } 38 | 39 | #' @keywords internal 40 | spk_dependencies <- function(){ 41 | htmlwidgets::getDependency(name="sparkline", package="sparkline") 42 | } 43 | 44 | #' An HTML dependency for sparkline 45 | #' 46 | #' @description An HTML dependency for sparkline 47 | #' 48 | #' @export 49 | html_dependency_sparkline <- spk_dependencies 50 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/jquery.sparkline/README.md: -------------------------------------------------------------------------------- 1 | jQuery Sparklines 2 | ================= 3 | 4 | This jQuery plugin makes it easy to generate a number of different types 5 | of sparklines directly in the browser, using online a line of two of HTML 6 | and Javascript. 7 | 8 | The plugin has no dependencies other than jQuery and works with all modern 9 | browsers and also Internet Explorer 6 and later (excanvas is not required 10 | for IE support). 11 | 12 | See the [jQuery Sparkline project page](http://omnipotent.net/jquery.sparkline/) 13 | for live examples and documentation. 14 | 15 | ## License 16 | 17 | Released under the New BSD License 18 | 19 | (c) Splunk, Inc 2012 20 | 21 | 22 | ## About this fork 23 | 24 | * The intent of this fork is to build the Javascript files with Grunt 0.4 and to check the built files into the repo. 25 | * The min file is minified using [UglifyJS](https://github.com/mishoo/UglifyJS) with default settings. 26 | * Checking in built files is [not what the original author wants](https://github.com/gwatts/jquery.sparkline/pull/77) in his repo. 27 | * So why does this fork do that? Well, the built files will then be available to developers who use jquery.sparkline and use Bower for dependency management and Grunt to pluck the files they need in their project. This lets the developer avoid having to run Grunt in dependency directories (eg, node_modules) before running their own builds. 28 | * In order to allow for tag level targeting via Bower, new tags will be made, starting at 2.1.3 29 | -------------------------------------------------------------------------------- /man/spk_chr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparkline.R 3 | \name{spk_chr} 4 | \alias{spk_chr} 5 | \title{Character Version of Sparklines} 6 | \usage{ 7 | spk_chr(values, ..., width = 60, height = 20, elementId = NULL, 8 | renderSelector = NULL) 9 | } 10 | \arguments{ 11 | \item{values}{\code{vector} of values to visualize} 12 | 13 | \item{...}{additional options passed to \code{jquery.sparkline}; see 14 | \href{http://omnipotent.net/jquery.sparkline/#common}{jquery.sparkline docs}} 15 | 16 | \item{width}{height and width of sparkline htmlwidget 17 | specified in any valid \code{CSS} size unit.} 18 | 19 | \item{height}{height and width of sparkline htmlwidget 20 | specified in any valid \code{CSS} size unit.} 21 | 22 | \item{elementId}{\code{string} id as a valid \code{CSS} element id.} 23 | 24 | \item{renderSelector}{\code{string} as \code{CSS} selector to render 25 | in a DOM element other than the \code{htmlwidget} container} 26 | } 27 | \description{ 28 | Create a character version ofinteractive sparklines 29 | for use with other 'htmlwidgets' or tags. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | #spk_chr works well with dplyr summarise 34 | 35 | library(dplyr) 36 | library(sparkline) 37 | library(formattable) 38 | 39 | mtcars \%>\% 40 | group_by(cyl) \%>\% 41 | summarise( 42 | hp = spk_chr( 43 | hp, type="box", 44 | chartRangeMin=0, chartRangeMax=max(mtcars$hp) 45 | ), 46 | mpg = spk_chr( 47 | mpg, type="box", 48 | chartRangeMin=0, chartRangeMax=max(mtcars$mpg) 49 | ) 50 | ) \%>\% 51 | formattable() \%>\% 52 | formattable::as.htmlwidget() \%>\% 53 | spk_add_deps() 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/sparkline)](https://cran.r-project.org/package=sparkline) 2 | 3 | ## Sparkline 4 | 5 | This is an R package that provides support for [jquery sparkline](http://omnipotent.net/jquery.sparkline/#s-about) as a [htmlwidget](http://htmlwidgets.org). 6 | 7 | ### Installation 8 | 9 | `sparkline` is on CRAN, so you can `install.packages("sparkline")`. 10 | 11 | For the latest development version, please use `devtools::install_github("sparkline"). 12 | 13 | ```r 14 | library(devtools) 15 | install_github('htmlwidgets/sparkline') 16 | ``` 17 | 18 | ### Usage 19 | 20 | The API is designed to be simple. 21 | 22 | ```r 23 | x = rnorm(20) 24 | sparkline(x) 25 | sparkline(x, type = 'bar') 26 | sparkline(x, type = 'box') 27 | ``` 28 | 29 | You can also use it in an R Markdown document. 30 | 31 | 32 | --- 33 | title: "jquery Sparkline HTML Widget" 34 | author: "Ramnath Vaidyanathan" 35 | date: "July 18, 2014" 36 | output: html_document 37 | --- 38 | 39 | ```{r} 40 | library(htmlwidgets) 41 | library(sparkline) 42 | set.seed(1234) 43 | x = rnorm(10) 44 | y = rnorm(10) 45 | ``` 46 | 47 | 48 | Inline line graphs `r sparkline(x)` 49 | 50 | Bar charts `r sparkline(abs(x), type = 'bar')` negative values: `r sparkline(x, type = 'bar')` 51 | 52 | | Stock | Sparkline | Boxplot 53 | |-------|-------------------|-------- 54 | | x | `r sparkline(x)` | `r sparkline(x, type ='box')` 55 | | y | `r sparkline(y)` | `r sparkline(y, type ='box')` 56 | 57 | ![sparkline](http://i.imgur.com/B99qnBj.png) 58 | 59 | 60 | ### Code of Conduct 61 | 62 | Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. 63 | -------------------------------------------------------------------------------- /man/spk_composite.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/composite.R 3 | \name{spk_composite} 4 | \alias{spk_composite} 5 | \title{Add a Composite to an Existing Sparkline} 6 | \usage{ 7 | spk_composite(sparkline = NULL, sparklineToAdd = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{sparkline}{\code{\link{sparkline}} to which we would like to add 11 | a composite.} 12 | 13 | \item{sparklineToAdd}{\code{\link{sparkline}} to add to another \code{\link{sparkline}}} 14 | 15 | \item{...}{extra arguments to modify \code{sparklineToAdd} or define a \code{\link{sparkline}}.} 16 | } 17 | \value{ 18 | \code{\link{sparkline}} object 19 | } 20 | \description{ 21 | Add a Composite to an Existing Sparkline 22 | } 23 | \examples{ 24 | library(sparkline) 25 | 26 | sl1 <- sparkline( 27 | c(5,4,5,-2,0,3), 28 | type='bar', 29 | barColor="#aaf", 30 | chartRangeMin=-5, 31 | chartRangeMax=10, 32 | # set an id that will make it easier to refer 33 | # in the next sparkline 34 | elementId="sparkline-for-composite" 35 | ) 36 | 37 | sl2 <- sparkline( 38 | c(4,1,5,7,9,9,8,7,6,6,4,7,8,4,3,2,2,5,6,7), 39 | type="line", 40 | fillColor = FALSE, 41 | lineColor ='red', 42 | chartRangeMin = -5, 43 | chartRangeMax = 10 44 | ) 45 | 46 | # add sparkline as a composite 47 | spk_composite(sl1, sl2) 48 | 49 | # add values and options as a composite 50 | spk_composite( 51 | sl1, 52 | values=c(4,1,5,7,9,9,8,7,6,6,4,7,8,4,3,2,2,5,6,7), 53 | options = list( 54 | type="line", 55 | fillColor = FALSE, 56 | lineColor ='red', 57 | chartRangeMin = -5, 58 | chartRangeMax = 10 59 | ) 60 | ) 61 | 62 | # add combination of sparkline and options as a composite 63 | spk_composite( 64 | sl1, 65 | sl2, 66 | options = list( 67 | type="box" 68 | ) 69 | ) 70 | } 71 | 72 | -------------------------------------------------------------------------------- /inst/htmlwidgets/sparkline.js: -------------------------------------------------------------------------------- 1 | HTMLWidgets.widget({ 2 | name: "sparkline", 3 | type: "output", 4 | factory: function(el, width, height) { 5 | 6 | var instance = {}; 7 | 8 | return { 9 | 10 | renderValue: function(data) { 11 | 12 | $(el).empty(); 13 | 14 | // if renderTag provided then we will do three things 15 | // 1. set height and width to 0 and display none 16 | // 2. set our el to the render tag if available 17 | // 3. set height and width options to null 18 | if(data.renderSelector && $(data.renderSelector).length){ 19 | $(el).css({ 20 | 'height': '0', 21 | 'width': '0', 22 | 'display': 'none' 23 | }); 24 | el = data.renderSelector; 25 | // set height and width to null 26 | // this might be confusing and need to be reverted 27 | data.options.height = null; 28 | data.options.width = null; 29 | } 30 | $(el).sparkline(data.values, data.options); 31 | 32 | // experimental addComposite function in R 33 | // will add composites to data.composites 34 | if(data.composites) { 35 | if(!Array.isArray(data.composites)) { 36 | data.composites = [data.composites]; 37 | } 38 | data.composites.map( function(spk) { 39 | $(el).sparkline(spk.values,spk.options); 40 | }); 41 | } 42 | 43 | instance.data = data; 44 | }, 45 | 46 | resize: function(width, height) { 47 | 48 | // not sure what to do in the event of resize 49 | // I think nothing for now 50 | // but will need to get a feel for use cases 51 | // where this is important such as slides, flexdashboard, tabset 52 | this.renderValue(instance.data); 53 | 54 | } 55 | 56 | }; 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /inst/examples/sparkline_histogram.R: -------------------------------------------------------------------------------- 1 | library(sparkline) 2 | library(htmltools) 3 | 4 | # plot the histogram of iris petal length 5 | # as a sparkline bar 6 | sparkline( 7 | hist(iris$Petal.Length,plot=FALSE)$counts, 8 | type = "bar" 9 | ) 10 | 11 | # now split by species and plot the histograms 12 | # in a tagList by species for comparison 13 | browsable( 14 | tagList( 15 | tags$h1("Iris Petal Length by Species"), 16 | lapply( 17 | split(iris, iris$Species), 18 | function(species){ 19 | hpl_iris <- hist(iris$Petal.Length, plot=FALSE) 20 | hpl <- hist(species$Petal.Length, breaks = hpl_iris$breaks, plot=FALSE) 21 | tags$div( 22 | tags$h3(species[1,]$Species), 23 | sparkline( 24 | hpl$counts, 25 | type = "bar", 26 | zeroColor = "lightgray", 27 | chartRangeMin = 0, 28 | chartRangeMax = 50 29 | ) 30 | ) 31 | } 32 | ) 33 | ) 34 | ) 35 | 36 | # however, more than likely we might like to plot 37 | # histograms for each of the variables as a sparkline 38 | # bar, and in this case, a table will provide a nice 39 | # layout for the histograms 40 | library(formattable) 41 | library(dplyr) 42 | library(purrr) 43 | library(tibble) 44 | # get histograms for each of the columns on the entire set 45 | # so we can use breaks for consistent histograms by species 46 | hist_iris <- iris %>% 47 | as_tibble() %>% 48 | select(-Species) %>% 49 | summarize_each( 50 | funs( 51 | list(hist(., plot=FALSE)) 52 | ) 53 | ) 54 | 55 | split(iris, iris$Species) %>% 56 | lapply( 57 | function(species){ 58 | mapply( 59 | function(x, breaks){ 60 | hist(x, breaks=breaks, plot=FALSE) 61 | }, 62 | species %>% select(-Species), 63 | hist_iris %>% 64 | lapply(function(column){column[[1]]$breaks}) 65 | ) 66 | } 67 | ) %>% 68 | map(function(x) x["counts",]) %>% 69 | bind_rows() %>% 70 | mutate(variable = colnames(iris)[1:4]) %>% 71 | select(variable, everything()) %>% 72 | formattable( 73 | list( 74 | area(col=2:4) ~ function(x){ 75 | lapply(x,function(xx){ 76 | as.character(as.tags( 77 | sparkline(xx,type = "bar", chartRangeMin = 0, chartRangeMax = 50, zeroColor = "lightgray") 78 | )) 79 | }) 80 | } 81 | ) 82 | ) %>% 83 | formattable::as.htmlwidget() %>% 84 | tagList() %>% 85 | attachDependencies(htmlwidgets:::widget_dependencies("sparkline","sparkline")) %>% 86 | browsable() -------------------------------------------------------------------------------- /R/sparkline.R: -------------------------------------------------------------------------------- 1 | #' Interactive Sparklines 2 | #' 3 | #' Create interactive sparklines for inline visualization. 4 | #' 5 | #' @param values \code{vector} of values to visualize 6 | #' @param ... additional options passed to \code{jquery.sparkline}; see 7 | #' \href{http://omnipotent.net/jquery.sparkline/#common}{jquery.sparkline docs} 8 | #' @param height,width height and width of sparkline htmlwidget 9 | #' specified in any valid \code{CSS} size unit. 10 | #' @param elementId \code{string} id as a valid \code{CSS} element id. 11 | #' @param renderSelector \code{string} as \code{CSS} selector to render 12 | #' in a DOM element other than the \code{htmlwidget} container 13 | #' 14 | #' @import htmlwidgets 15 | #' @export 16 | sparkline <- function(values, ..., width = 60, height = 20, 17 | elementId = NULL, renderSelector = NULL){ 18 | params = list( 19 | values = values, 20 | options = list(..., height = height, width = width), 21 | width = width , height = height, 22 | renderSelector = renderSelector 23 | ) 24 | params = Filter(Negate(is.null), params) 25 | htmlwidgets::createWidget('sparkline', params, 26 | width = width, 27 | height = height, 28 | sizingPolicy = htmlwidgets::sizingPolicy( 29 | viewer.fill = FALSE 30 | ), 31 | elementId = elementId 32 | ) 33 | } 34 | 35 | #' Character Version of Sparklines 36 | #' 37 | #' Create a character version ofinteractive sparklines 38 | #' for use with other 'htmlwidgets' or tags. 39 | #' 40 | #' @inheritParams sparkline 41 | #' 42 | #' @import htmlwidgets htmltools 43 | #' @export 44 | #' 45 | #' @example inst/examples/examples_dplyr.R 46 | 47 | spk_chr <- function(values, ..., width = 60, height = 20, 48 | elementId = NULL, renderSelector = NULL){ 49 | htmltools::HTML(as.character( 50 | as.tags( 51 | sparkline( 52 | values = values, 53 | ..., 54 | width = width, 55 | height = height, 56 | elementId = elementId, 57 | renderSelector = renderSelector 58 | ) 59 | ) 60 | )) 61 | } 62 | 63 | sparkline_html <- function(id, style, class, ...){ 64 | htmltools::tags$span(id = id, class = class) 65 | } 66 | 67 | #' Shiny bindings for sparkline 68 | #' 69 | #' Output and render functions for using sparkline within Shiny 70 | #' applications and interactive Rmd documents. 71 | #' 72 | #' @param outputId output variable to read from 73 | #' @param width,height Must be a valid CSS unit (like \code{'100\%'}, 74 | #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 75 | #' string and have \code{'px'} appended. 76 | #' @param expr An expression that generates a sparkline 77 | #' @param env The environment in which to evaluate \code{expr}. 78 | #' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This 79 | #' is useful if you want to save an expression in a variable. 80 | #' 81 | #' @name sparkline-shiny 82 | #' 83 | #' @export 84 | sparklineOutput <- function(outputId, width = "60px", height = "20px") { 85 | htmlwidgets::shinyWidgetOutput(outputId, "sparkline", width, height) 86 | } 87 | 88 | #' @rdname sparkline-shiny 89 | #' @export 90 | renderSparkline <- function(expr, env = parent.frame(), quoted = FALSE) { 91 | if (!quoted) { expr <- substitute(expr) } # force quoted 92 | htmlwidgets::shinyRenderWidget(expr, sparklineOutput, env, quoted = TRUE) 93 | } 94 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/jquery/jquery-AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Authors ordered by first contribution. 2 | 3 | John Resig 4 | Gilles van den Hoven 5 | Michael Geary 6 | Stefan Petre 7 | Yehuda Katz 8 | Corey Jewett 9 | Klaus Hartl 10 | Franck Marcia 11 | Jörn Zaefferer 12 | Paul Bakaus 13 | Brandon Aaron 14 | Mike Alsup 15 | Dave Methvin 16 | Ed Engelhardt 17 | Sean Catchpole 18 | Paul Mclanahan 19 | David Serduke 20 | Richard D. Worth 21 | Scott González 22 | Ariel Flesler 23 | Jon Evans 24 | TJ Holowaychuk 25 | Michael Bensoussan 26 | Robert Katić 27 | Louis-Rémi Babé 28 | Earle Castledine 29 | Damian Janowski 30 | Rich Dougherty 31 | Kim Dalsgaard 32 | Andrea Giammarchi 33 | Mark Gibson 34 | Karl Swedberg 35 | Justin Meyer 36 | Ben Alman 37 | James Padolsey 38 | David Petersen 39 | Batiste Bieler 40 | Alexander Farkas 41 | Rick Waldron 42 | Filipe Fortes 43 | Neeraj Singh 44 | Paul Irish 45 | Iraê Carvalho 46 | Matt Curry 47 | Michael Monteleone 48 | Noah Sloan 49 | Tom Viner 50 | Douglas Neiner 51 | Adam J. Sontag 52 | Dave Reed 53 | Ralph Whitbeck 54 | Carl Fürstenberg 55 | Jacob Wright 56 | J. Ryan Stinnett 57 | unknown 58 | temp01 59 | Heungsub Lee 60 | Colin Snover 61 | Ryan W Tenney 62 | Pinhook 63 | Ron Otten 64 | Jephte Clain 65 | Anton Matzneller 66 | Alex Sexton 67 | Dan Heberden 68 | Henri Wiechers 69 | Russell Holbrook 70 | Julian Aubourg 71 | Gianni Alessandro Chiappetta 72 | Scott Jehl 73 | James Burke 74 | Jonas Pfenniger 75 | Xavi Ramirez 76 | Jared Grippe 77 | Sylvester Keil 78 | Brandon Sterne 79 | Mathias Bynens 80 | Timmy Willison 81 | Corey Frang 82 | Digitalxero 83 | Anton Kovalyov 84 | David Murdoch 85 | Josh Varner 86 | Charles McNulty 87 | Jordan Boesch 88 | Jess Thrysoee 89 | Michael Murray 90 | Lee Carpenter 91 | Alexis Abril 92 | Rob Morgan 93 | John Firebaugh 94 | Sam Bisbee 95 | Gilmore Davidson 96 | Brian Brennan 97 | Xavier Montillet 98 | Daniel Pihlstrom 99 | Sahab Yazdani 100 | avaly 101 | Scott Hughes 102 | Mike Sherov 103 | Greg Hazel 104 | Schalk Neethling 105 | Denis Knauf 106 | Timo Tijhof 107 | Steen Nielsen 108 | Anton Ryzhov 109 | Shi Chuan 110 | Berker Peksag 111 | Toby Brain 112 | Matt Mueller 113 | Justin 114 | Daniel Herman 115 | Oleg Gaidarenko 116 | Richard Gibson 117 | Rafaël Blais Masson 118 | cmc3cn <59194618@qq.com> 119 | Joe Presbrey 120 | Sindre Sorhus 121 | Arne de Bree 122 | Vladislav Zarakovsky 123 | Andrew E Monat 124 | Oskari 125 | Joao Henrique de Andrade Bruni 126 | tsinha 127 | Matt Farmer 128 | Trey Hunner 129 | Jason Moon 130 | Jeffery To 131 | Kris Borchers 132 | Vladimir Zhuravlev 133 | Jacob Thornton 134 | Chad Killingsworth 135 | Nowres Rafid 136 | David Benjamin 137 | Uri Gilad 138 | Chris Faulkner 139 | Elijah Manor 140 | Daniel Chatfield 141 | Nikita Govorov 142 | Wesley Walser 143 | Mike Pennisi 144 | Markus Staab 145 | Dave Riddle 146 | Callum Macrae 147 | Benjamin Truyman 148 | James Huston 149 | Erick Ruiz de Chávez 150 | David Bonner 151 | Akintayo Akinwunmi 152 | MORGAN 153 | Ismail Khair 154 | Carl Danley 155 | Mike Petrovich 156 | Greg Lavallee 157 | Daniel Gálvez 158 | Sai Lung Wong 159 | Tom H Fuertes 160 | Roland Eckl 161 | Jay Merrifield 162 | Allen J Schmidt Jr 163 | Jonathan Sampson 164 | Marcel Greter 165 | Matthias Jäggli 166 | David Fox 167 | Yiming He 168 | Devin Cooper 169 | Paul Ramos 170 | Rod Vagg 171 | Bennett Sorbo 172 | Sebastian Burkhard 173 | nanto 174 | Danil Somsikov 175 | Ryunosuke SATO 176 | Jean Boussier 177 | Adam Coulombe 178 | Andrew Plummer 179 | Mark Raddatz 180 | Dmitry Gusev 181 | Michał Gołębiowski 182 | Nguyen Phuc Lam 183 | Tom H Fuertes 184 | Brandon Johnson 185 | Jason Bedard 186 | Kyle Robinson Young 187 | Renato Oliveira dos Santos 188 | Chris Talkington 189 | Eddie Monge 190 | Terry Jones 191 | Jason Merino 192 | Jeremy Dunck 193 | Chris Price 194 | Amey Sakhadeo 195 | Anthony Ryan 196 | Dominik D. Geyer 197 | George Kats 198 | Lihan Li 199 | Ronny Springer 200 | Marian Sollmann 201 | Corey Frang 202 | Chris Antaki 203 | Noah Hamann 204 | David Hong 205 | Jakob Stoeck 206 | Christopher Jones 207 | Forbes Lindesay 208 | John Paul 209 | S. Andrew Sheppard 210 | Leonardo Balter 211 | Roman Reiß 212 | Benjy Cui 213 | Rodrigo Rosenfeld Rosas 214 | John Hoven 215 | Christian Kosmowski 216 | Liang Peng 217 | TJ VanToll 218 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/jquery.sparkline/jquery.sparkline.min.js: -------------------------------------------------------------------------------- 1 | /* jquery.sparkline 2.1.3 - http://omnipotent.net/jquery.sparkline/ 2 | Licensed under the New BSD License - see above site for details */ 3 | !function(a,b,c){!function(a){"function"==typeof define&&define.amd?define("jquery.sparkline",["jquery"],a):jQuery&&!jQuery.fn.sparkline&&a(jQuery)}(function(d){"use strict";var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N={},O=0;e=function(){return{common:{type:"line",lineColor:"#00f",fillColor:"#cdf",defaultPixelsPerValue:3,width:"auto",height:"auto",composite:!1,tagValuesAttribute:"values",tagOptionsPrefix:"spark",enableTagOptions:!1,enableHighlight:!0,highlightLighten:1.4,tooltipSkipNull:!0,tooltipPrefix:"",tooltipSuffix:"",disableHiddenCheck:!1,numberFormatter:!1,numberDigitGroupCount:3,numberDigitGroupSep:",",numberDecimalMark:".",disableTooltips:!1,disableInteraction:!1},line:{spotColor:"#f80",highlightSpotColor:"#5f5",highlightLineColor:"#f22",refLineColor:"#f22",spotRadius:1.5,minSpotColor:"#f80",maxSpotColor:"#f80",lineWidth:1,normalRangeMin:c,normalRangeMax:c,normalRangeColor:"#ccc",drawNormalOnTop:!1,chartRangeMin:c,chartRangeMax:c,chartRangeMinX:c,chartRangeMaxX:c,tooltipFormat:new g(' {{prefix}}{{y}}{{suffix}}')},bar:{barColor:"#3366cc",negBarColor:"#f44",stackedBarColor:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],zeroColor:c,nullColor:c,zeroAxis:!0,barWidth:4,barSpacing:1,chartRangeMax:c,chartRangeMin:c,chartRangeClip:!1,colorMap:c,tooltipFormat:new g(' {{prefix}}{{value}}{{suffix}}')},timeline:{width:120,height:3,lineColor:"#6792c6",fillColor:"#bad7fb",orientation:"horizontal",timeMarkInterval:0,begin:new Date(2e3,1,1,0,0),finish:new Date(2e3,1,1,23,59),init:function(a){return{begin:new Date(a.begin),finish:new Date(a.finish),title:a.title,color:a.color}},tooltipFormat:new g(' {{title}}: {{begin}} / {{finish}}')},tristate:{barWidth:4,barSpacing:1,posBarColor:"#6f6",negBarColor:"#f44",zeroBarColor:"#999",colorMap:{},tooltipFormat:new g(' {{prefix}}{{value:map}}{{suffix}}'),tooltipValueLookups:{map:{"-1":"Loss",0:"Draw",1:"Win"}}},discrete:{lineHeight:"auto",thresholdColor:c,thresholdValue:0,chartRangeMax:c,chartRangeMin:c,chartRangeClip:!1,tooltipFormat:new g("{{prefix}}{{value}}{{suffix}}")},bullet:{targetColor:"#f33",targetWidth:3,performanceColor:"#33f",rangeColors:["#d3dafe","#a8b6ff","#7f94ff"],base:c,tooltipFormat:new g("{{fieldkey:fields}} - {{value}}"),tooltipValueLookups:{fields:{r:"Range",p:"Performance",t:"Target"}}},pie:{offset:0,sliceColors:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],borderWidth:0,borderColor:"#000",tooltipFormat:new g(' {{prefix}}{{value}} ({{percent.1}}%){{suffix}}')},stack:{offset:0,sliceColors:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],borderWidth:0,borderColor:"#000",tooltipFormat:new g(' {{value}} ({{percent.1}}%)')},box:{raw:!1,boxLineColor:"#000",boxFillColor:"#cdf",whiskerColor:"#000",outlierLineColor:"#333",outlierFillColor:"#fff",medianColor:"#f00",showOutliers:!0,outlierIQR:1.5,spotRadius:1.5,target:c,targetColor:"#4a2",chartRangeMax:c,chartRangeMin:c,tooltipFormat:new g("{{field:fields}}: {{value}}"),tooltipFormatFieldlistKey:"field",tooltipValueLookups:{fields:{lq:"Lower Quartile",med:"Median",uq:"Upper Quartile",lo:"Left Outlier",ro:"Right Outlier",lw:"Left Whisker",rw:"Right Whisker"}}}}};var P="-webkit-box-sizing: content-box !important;-moz-box-sizing: content-box !important;box-sizing: content-box !important;";G='.jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;'+P+"}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}.jqstooltip:before, .jqstooltip:after { "+P+"}",f=function(){var a,b;return a=function(){this.init.apply(this,arguments)},arguments.length>1?(arguments[0]?(a.prototype=d.extend(new arguments[0],arguments[arguments.length-1]),a._super=arguments[0].prototype):a.prototype=arguments[arguments.length-1],arguments.length>2&&(b=Array.prototype.slice.call(arguments,1,-1),b.unshift(a.prototype),d.extend.apply(d,b))):a.prototype=arguments[0],a.prototype.cls=a,a},d.SPFormatClass=g=f({fre:/\{\{([\w.]+?)(:(.+?))?\}\}/g,precre:/(\w+)\.(\d+)/,init:function(a,b){this.format=a,this.fclass=b},render:function(a,b,d){var e,f,g,h,i,j=this,k=a;return this.format.replace(this.fre,function(){var a;return f=arguments[1],g=arguments[3],e=j.precre.exec(f),e?(i=e[2],f=e[1]):i=!1,h=k[f],h===c?"":g&&b&&b[g]?(a=b[g],a.get?b[g].get(h)||h:b[g][h]||h):(n(h)&&(h=d.get("numberFormatter")?d.get("numberFormatter")(h):s(h,i,d.get("numberDigitGroupCount"),d.get("numberDigitGroupSep"),d.get("numberDecimalMark"))),h)})}}),d.spformat=function(a,b){return new g(a,b)},h=function(a,b,c){return ac?c:a},i=function(a){var b,c;if(0===a.length%2){var d,e;c=a.length/2,d=a[c-1],e=a[c],b=(d+e)/2}else c=parseInt(a.length/2),b=a[c];return{m:b,idx:c}},j=function(a,b){var c,d,e;if(d=i(a),2===b)c=d.m;else{var f=[];if(e=d.m,null!=e){var g=0;if(1===b){for(;gd.idx;)f[g]=a[h],g++,h--;f.length||(f=[a[a.length-1]])}}d=i(f),c=d.m}return c},k=function(a){var b;switch(a){case"undefined":a=c;break;case"null":a=null;break;case"true":a=!0;break;case"false":a=!1;break;default:b=parseFloat(a),a==b&&(a=b)}return a},l=function(a){var b,c=[];for(b=a.length;b--;)c[b]=k(a[b]);return c},m=function(a,b){var c,d,e=[];for(c=0,d=a.length;c0;h-=c)a.splice(h,0,e);return a.join("")},o=function(a,b,c){var d;for(d=b.length;d--;)if((!c||null!==b[d])&&b[d]!==a)return!1;return!0},p=function(a){var b,c=0;for(b=a.length;b--;)c+="number"==typeof a[b]?a[b]:0;return c},r=function(a){return d.isArray(a)?a:[a]},q=function(b){var c,d;if(a.createStyleSheet)try{return void(a.createStyleSheet().cssText=b)}catch(e){d=!0}c=a.createElement("style"),c.type="text/css",a.getElementsByTagName("head")[0].appendChild(c),d?a.styleSheets[a.styleSheets.length-1].cssText=b:c["string"==typeof a.body.style.WebkitAppearance?"innerText":"innerHTML"]=b},d.fn.simpledraw=function(b,e,f,g){var h,i;if(f&&(h=this.data("_jqs_vcanvas")))return h;if(d.fn.sparkline.canvas===!1)return!1;if(d.fn.sparkline.canvas===c){var j=a.createElement("canvas");if(j.getContext&&j.getContext("2d"))d.fn.sparkline.canvas=function(a,b,c,d){return new K(a,b,c,d)};else{if(!a.namespaces||a.namespaces.v)return d.fn.sparkline.canvas=!1,!1;a.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML"),d.fn.sparkline.canvas=function(a,b,c,d){return new L(a,b,c)}}}return b===c&&(b=d(this).innerWidth()),e===c&&(e=d(this).innerHeight()),h=d.fn.sparkline.canvas(b,e,this,g),i=d(this).data("_jqs_mhandler"),i&&i.registerCanvas(h),h},d.fn.cleardraw=function(){var a=this.data("_jqs_vcanvas");a&&a.reset()},d.RangeMapClass=t=f({init:function(a){var b,c,d=[];for(b in a)a.hasOwnProperty(b)&&"string"==typeof b&&b.indexOf(":")>-1&&(c=b.split(":"),c[0]=0===c[0].length?-(1/0):parseFloat(c[0]),c[1]=0===c[1].length?1/0:parseFloat(c[1]),c[2]=a[b],d.push(c));this.map=a,this.rangelist=d||!1},get:function(a){var b,d,e,f=this.rangelist;if((e=this.map[a])!==c)return e;if(f)for(b=f.length;b--;)if(d=f[b],d[0]<=a&&d[1]>=a)return d[2];return c}}),d.range_map=function(a){return new t(a)},u=f({init:function(a,b){var c=d(a);this.$el=c,this.options=b,this.currentPageX=0,this.currentPageY=0,this.el=a,this.splist=[],this.tooltip=null,this.over=!1,this.displayTooltips=!b.get("disableTooltips"),this.highlightEnabled=!b.get("disableHighlight")},registerSparkline:function(a){this.splist.push(a),this.over&&this.updateDisplay()},registerCanvas:function(a){var b=d(a.canvas);this.canvas=a,this.$canvas=b,b.mouseenter(d.proxy(this.mouseenter,this)),b.mouseleave(d.proxy(this.mouseleave,this)),b.click(d.proxy(this.mouseclick,this))},reset:function(a){this.splist=[],this.tooltip&&a&&(this.tooltip.remove(),this.tooltip=c)},mouseclick:function(a){var b=d.Event("sparklineClick");b.originalEvent=a,b.sparklines=this.splist,this.$el.trigger(b)},mouseenter:function(b){d(a.body).unbind("mousemove.jqs"),d(a.body).bind("mousemove.jqs",d.proxy(this.mousemove,this)),this.over=!0,this.currentPageX=b.pageX,this.currentPageY=b.pageY,this.currentEl=b.target,!this.tooltip&&this.displayTooltips&&(this.tooltip=new v(this.options),this.tooltip.updatePosition(b.pageX,b.pageY)),this.updateDisplay()},mouseleave:function(){d(a.body).unbind("mousemove.jqs");var b,c,e=this.splist,f=e.length,g=!1;for(this.over=!1,this.currentEl=null,this.tooltip&&(this.tooltip.remove(),this.tooltip=null),c=0;c