add-shade | R Documentation |
add_shade()
allow to add a shaded area on specified range,
add_shade_weekend()
add a shadow on every week-end.
add_shade(ax, from, to, color = "#848484", opacity = 0.2, label = NULL, ...)
add_shade_weekend(ax, color = "#848484", opacity = 0.2, label = NULL, ...)
ax |
An |
from |
Vector of position to start shadow. |
to |
Vector of position to end shadow. |
color |
Color of the shadow. |
opacity |
Opacity of the shadow. |
label |
Add a label to the shade, use a |
... |
Additional arguments, see https://apexcharts.com/docs/options/annotations/ for possible options. |
An apexchart()
htmlwidget
object.
add_shade_weekend
only works if variable
used for x-axis is of class Date
or POSIXt
.
library(apexcharter)
data("consumption")
# specify from and to date
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade(from = "2020-01-06", to = "2020-01-20")
# you can add several shadows
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade(from = "2020-01-06", to = "2020-01-20") %>%
add_shade(from = "2020-02-04", to = "2020-02-10")
# or use a vector
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade(
from = c("2020-01-06", "2020-02-04"),
to = c("2020-01-20", "2020-02-10")
)
# Add a label
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade(
from = "2020-01-06", to = "2020-01-20",
label = "interesting period"
)
# add label with more options
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade(
from = "2020-01-06", to = "2020-01-20",
color = "firebrick",
label = label(
text = "something happened",
background = "firebrick",
color = "white",
fontWeight = "bold",
padding = c(3, 5, 3, 5)
)
)
# automatically add shadow on week-ends
apex(consumption, aes(date, value, group = type), "spline") %>%
add_shade_weekend()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.