Skip to contents

Initialize a chart with three main parameters : data, mapping and type of chart.

Usage

apex(
  data,
  mapping,
  type = "column",
  ...,
  auto_update = TRUE,
  synchronize = NULL,
  serie_name = NULL,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

data

Default dataset to use for chart. If not already a data.frame, it will be coerced to with as.data.frame.

mapping

Default list of aesthetic mappings to use for chart

type

Specify the chart type. Available options, with the aesthetics they use (x and y unless stated otherwise, fill, colour or group can be used to create several series):

  • Bars: "column" (vertical bars), "bar" (horizontal bars). If y is not provided, observations are counted.

  • Lines: "line", "spline", "step", "slope" (two values of x for each group).

  • Areas: "area", "area-spline", "area-step", "streamgraph", "rangeArea" (x, ymin and ymax).

  • Ranges: "rangeBar" and "timeline" (x, start and end), "dumbbell" (y, x and xend).

  • Circular: "pie", "donut", "polarArea", "radialBar" (x for labels and y for values), "radar".

  • Points: "scatter", "bubble" (x, y and size or z; "scatter" is converted to "bubble" if size is used).

  • Matrices: "heatmap" (x, y and fill or colour for values), "treemap".

  • Distributions: "boxplot" and "violin" (a categorical and a numeric variable).

  • Financial: "candlestick" (x, open, high, low and close), "waterfall" (x and y for the amount of each step, optionally subtotal and total, two logical aesthetics to add running total bars, see waterfall_opts() to customize colors).

...

Other arguments passed on to methods. Not currently used.

auto_update

In Shiny application, update existing chart rather than generating new one. Can be TRUE/FALSE or use config_update() for more control.

synchronize

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

serie_name

Name for the serie displayed in tooltip, only used for single serie.

width, height

A numeric input in pixels.

elementId

Use an explicit element ID for the widget.

Value

An apexchart() htmlwidget object.

Examples

library(ggplot2)
library(apexcharter)

# make a barchart with a frequency table
data("mpg", package = "ggplot2")
apex(mpg, aes(manufacturer), type = "bar")
# timeseries data("economics", package = "ggplot2") apex( data = economics, mapping = aes(x = date, y = uempmed), type = "line" )
# you can add option to apex result : apex( data = economics, mapping = aes(x = date, y = uempmed), type = "line" ) %>% ax_stroke(width = 1) %>% ax_yaxis(min = 0, decimalsInFloat = 0)
# with group variable data("economics_long", package = "ggplot2") apex( data = economics_long, mapping = aes(x = date, y = value01, group = variable), type = "line" )