Create a box with a sparkline
spark_box(
data,
title = NULL,
subtitle = NULL,
color = "#2E93fA",
background = "#FFF",
type = c("area", "line", "spline", "column"),
synchronize = NULL,
title_style = NULL,
subtitle_style = NULL,
width = NULL,
height = NULL,
elementId = NULL
)
A data.frame
-like object with at least two columns,
first is mapped to x-axis, second to y-axis.
Title to display in the box.
Subtitle to display in the box.
Color of the chart.
Background color of the box.
Type of chart, currently type supported are :
"area"
(default), "line"
, "spline"
, "column"
.
Give a common id to charts to synchronize them (tooltip and zoom).
A list
of named attributes to style
the title / subtitle, possible values are fontSize
,
fontWeight
, fontFamily
, color
.
A numeric input in pixels.
Use an explicit element ID for the widget.
An apexcharts
htmlwidget
object.
In Shiny use sparkBoxOutput
/ renderSparkBox
to render boxes, see example.
Boxes have CSS class "apexcharter-spark-box"
if you need more styling.
library(apexcharter)
spark_data <- data.frame(
date = Sys.Date() + 1:20,
var1 = round(rnorm(20, 50, 10)),
var2 = round(rnorm(20, 50, 10)),
var3 = round(rnorm(20, 50, 10))
)
spark_box(
data = spark_data,
title = mean(spark_data$var1),
subtitle = "Variable 1"
)
# In Shiny
if (interactive()) {
run_sparkbox_demo()
}