Learn R Programming

apexcharter (version 0.3.0)

spark_box: Create a box with a sparkline

Description

Create a box with a sparkline

Usage

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
)

Arguments

data

A data.frame-like object with at least two columns, first is mapped to x-axis, second to y-axis.

title

Title to display in the box.

subtitle

Subtitle to display in the box.

color

Color of the chart.

background

Background color of the box.

type

Type of chart, currently type supported are : "area" (default), "line", "spline", "column".

synchronize

Give a common id to charts to synchronize them (tooltip and zoom).

title_style, subtitle_style

A list of named attributes to style the title / subtitle, possible values are fontSize, fontWeight, fontFamily, color.

width, height

A numeric input in pixels.

elementId

Use an explicit element ID for the widget.

Value

An apexcharts htmlwidget object.

Examples

Run this code
# NOT RUN {
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()
}

# }

Run the code above in your browser using DataLab