spk_add_deps: Add Sparkline Dependencies to Tag or 'htmlwidget'

Description Usage Arguments Value Examples

View source: R/helpers.R

Description

Add Sparkline Dependencies to Tag or 'htmlwidget'

Usage

1
spk_add_deps(tag_htmlwidget = NULL)

Arguments

tag_htmlwidget

shiny.tag or htmlwidget to which you would like to add sparkline dependencies

Value

shiny.tag or htmlwidget

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# use spk_add_deps with other htmlwidgets

library(sparkline)
library(formattable)

fw <- as.htmlwidget(
  formattable(
    data.frame(
      id = c("a", "b"),
      sparkline = c(
        spk_chr(runif(10,0,10), type="bar"),
        spk_chr(runif(10,0,5), type="bar")
      ),
      stringsAsFactors = FALSE
    )
  )
)

spk_add_deps(fw)

# use spk_add_deps with htmltools/shiny tags

library(sparkline)
library(htmltools)

div <- tags$div(
  spk_chr(1:10, type="bar")
)

spk_add_deps(div)

Example output

<div><span id="htmlwidget-22da08e0dc713e07d9dc" class="sparkline html-widget"></span>
<script type="application/json" data-for="htmlwidget-22da08e0dc713e07d9dc">{"x":{"values":[1,2,3,4,5,6,7,8,9,10],"options":{"type":"bar","height":20,"width":60},"width":60,"height":20},"evals":[],"jsHooks":[]}</script></div>

sparkline documentation built on May 2, 2019, 11:02 a.m.