ax_chart: Chart parameters

Description Usage Arguments Value Examples

View source: R/apex-utils.R

Description

Chart parameters

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
ax_chart(
  ax,
  type = NULL,
  stacked = NULL,
  stackType = NULL,
  defaultLocale = NULL,
  locales = NULL,
  animations = NULL,
  background = NULL,
  foreColor = NULL,
  dropShadow = NULL,
  events = NULL,
  offsetX = NULL,
  offsetY = NULL,
  selection = NULL,
  sparkline = NULL,
  toolbar = NULL,
  zoom = NULL,
  width = NULL,
  height = NULL,
  ...
)

Arguments

ax

A apexcharts htmlwidget object.

type

Specify the chart type. Available Options: "bar", "column", "line", "pie", "donut", "radialBar", "scatter", "bubble", "heatmap".

stacked

Logical. Enables stacked option for axis charts.

stackType

When stacked, should the stacking be percentage based or normal stacking. Available options: "normal" or "100%".

defaultLocale

Locale to use : "ca", "cs", "de", "el", "en", "es", "fi", "fr", "he", "hi", "hr", "hy", "id", "it", "ko", "lt", "nb", "nl", "pl", "pt-br", "pt", "ru", "se", "sk", "sl", "th", "tr", "ua".

locales

Array of custom locales parameters.

animations

A list of parameters.

background

Background color for the chart area. If you want to set background with css, use .apexcharts-canvas to set it.

foreColor

Sets the text color for the chart. Defaults to #373d3f.

dropShadow

A list of parameters. See https://apexcharts.com/docs/options/chart/dropshadow/.

events

See events_opts.

offsetX

Sets the left offset for chart.

offsetY

Sets the top offset for chart.

selection

A list of parameters.

sparkline

List. Sparkline hides all the elements of the charts other than the primary paths. Helps to visualize data in small areas. .

toolbar

A list of parameters. See https://apexcharts.com/docs/options/chart/toolbar/.

zoom

A list of parameters. See https://apexcharts.com/docs/options/chart/zoom/.

width

Width of the chart.

height

Height of the chart.

...

Additional parameters.

Value

A apexcharts htmlwidget object.

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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
library(apexcharter)
data("diamonds", package = "ggplot2")

##  Stack bar type
# default is dodge
apex(
  data = diamonds,
  mapping = aes(x = cut, fill = color)
)

# stack
apex(
  data = diamonds,
  mapping = aes(x = cut, fill = color)
) %>%
  ax_chart(stacked = TRUE)

# stack filled
apex(
  data = diamonds,
  mapping = aes(x = cut, fill = color)
) %>%
  ax_chart(stacked = TRUE, stackType = "100%")




# Toolbar --------------------------------------

# Hide the toolbar
apex(
  data = diamonds,
  mapping = aes(x = cut, fill = color)
) %>%
  ax_chart(toolbar = list(show = FALSE))

# Hide download buttons
data("economics", package = "ggplot2")
apex(
  data = economics,
  mapping = aes(x = date, y = pce), 
  type = "line"
) %>%
  ax_chart(
    toolbar = list(tools= list(download = FALSE))
  )



# Zoom -----------------------------------------

# Disable
apex(
  data = economics,
  mapping = aes(x = date, y = pce), 
  type = "line"
) %>%
  ax_chart(
    zoom = list(enabled = FALSE)
  )


# Auto-scale Y axis
apex(
  data = economics,
  mapping = aes(x = date, y = pce), 
  type = "line"
) %>%
  ax_chart(
    zoom = list(autoScaleYaxis = TRUE)
  )

# Localization ---------------------------------


# Use included localization config
dat <- data.frame(
  x = Sys.Date() + 1:20,
  y = sample.int(20, 20)
)

# French
apex(dat, aes(x, y), "line") %>% 
  ax_chart(defaultLocale = "fr")

# Italian
apex(dat, aes(x, y), "line") %>% 
  ax_chart(defaultLocale = "it")



# Custom config
apex(dat, aes(x, y), "line") %>% 
  ax_chart(locales = list(
    list(
      name = "en", # override 'en' locale
      options = list(
        toolbar = list(
          exportToSVG = "GET SVG",
          exportToPNG = "GET PNG"
        )
      )
    )
  ))

apexcharter documentation built on May 11, 2021, 5:05 p.m.