apexcharter/examples/ax_chart.R

72 lines
1.1 KiB
R
Raw Normal View History

2021-01-15 10:53:51 +01:00
library(apexcharter)
2019-11-26 14:44:59 +01:00
data("diamonds", package = "ggplot2")
2020-03-03 19:34:07 +01:00
## Stack bar type
# default is dodge
apex(
2021-01-15 10:53:51 +01:00
data = diamonds,
mapping = aes(x = cut, fill = color)
2020-03-03 19:34:07 +01:00
)
# stack
2019-11-26 14:44:59 +01:00
apex(
2021-01-15 10:53:51 +01:00
data = diamonds,
mapping = aes(x = cut, fill = color)
2019-11-26 14:44:59 +01:00
) %>%
ax_chart(stacked = TRUE)
2020-03-03 19:34:07 +01:00
# stack filled
2019-11-26 14:44:59 +01:00
apex(
2021-01-15 10:53:51 +01:00
data = diamonds,
mapping = aes(x = cut, fill = color)
2019-11-26 14:44:59 +01:00
) %>%
ax_chart(stacked = TRUE, stackType = "100%")
2020-03-03 19:34:07 +01:00
# Toolbar --------------------------------------
# Hide the toolbar
2019-11-26 14:44:59 +01:00
apex(
2021-01-15 10:53:51 +01:00
data = diamonds,
mapping = aes(x = cut, fill = color)
2019-11-26 14:44:59 +01:00
) %>%
ax_chart(toolbar = list(show = FALSE))
2020-03-03 19:34:07 +01:00
# 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)
)