| lt_sparkline | R Documentation |
Render a per-row series of numbers as a small inline SVG line or bar chart (a
sparkline). The series for each row can come from a single list-column (each
element a numeric vector) or from several numeric columns read across the
row. Like lt_errorbar(), it is lightweight: only the numbers travel to the
client and the SVG is drawn in the browser, so an interactive table
(lt_interactive()) draws only the rows on the current page.
lt_sparkline(
x,
columns,
type = c("line", "bar"),
limits = NULL,
color = NULL,
width = 120,
height = 20,
hide = TRUE
)
x |
An |
columns |
The column(s) holding each row's series. Either a single
list-column (a one-sided formula |
type |
|
limits |
Numeric |
color |
CSS color for the line or bars (defaults to the stylesheet's). |
width, height |
Pixel size of each cell's SVG. |
hide |
If |
x with the sparkline column recorded.
# a list-column: each cell is a numeric vector
d = data.frame(city = c("A", "B", "C"))
d$temp = list(c(3, 5, 8, 6, 9), c(1, 2, 2, 4, 3), c(7, 6, 5, 6, 8))
lt(d) |> lt_sparkline(~ temp)
# several columns read across the row, as bars on a shared scale
m = data.frame(name = c("X", "Y"), q1 = c(2, 5), q2 = c(4, 3),
q3 = c(6, 7), q4 = c(5, 2))
lt(m) |> lt_sparkline(~ q1 + q2 + q3 + q4, type = "bar", limits = c(0, 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.