Axis scale for date/time data
scale-date.RdAxis scale for date/time data
Usage
v_scale_x_date(
  vc,
  name = NULL,
  date_breaks = NULL,
  date_labels = NULL,
  date_labels_tooltip = date_labels,
  min = NULL,
  max = NULL,
  ...,
  position = "bottom"
)
v_scale_y_date(
  vc,
  name = NULL,
  date_breaks = NULL,
  date_labels = NULL,
  date_labels_tooltip = date_labels,
  min = NULL,
  max = NULL,
  ...,
  position = "left"
)
v_scale_x_datetime(
  vc,
  name = NULL,
  date_breaks = NULL,
  date_labels = NULL,
  date_labels_tooltip = date_labels,
  tz = NULL,
  min = NULL,
  max = NULL,
  ...,
  position = "bottom"
)
v_scale_y_datetime(
  vc,
  name = NULL,
  date_breaks = NULL,
  date_labels = NULL,
  date_labels_tooltip = date_labels,
  tz = NULL,
  min = NULL,
  max = NULL,
  ...,
  position = "left"
)Arguments
- vc
- An htmlwidget created with - vchart()or specific chart's type function.
- name
- Title for the axis. 
- date_breaks
- One of: - A single - numericvalue giving the number of breaks.
- A string giving the distance between breaks like "2 weeks", or "10 years". 
- A Date/POSIXct vector giving positions of breaks. 
 
- date_labels
- The format to be applied on Date/POSIXct in the labels, see - format_date_dayjs().
- date_labels_tooltip
- The format to be applied on Date/POSIXct in the tooltip, see - format_date_dayjs().
- min
- Minimum value on the axis. 
- max
- Maximum value on the axis. 
- ...
- Additional parameters for the axis. 
- position
- Position of the axis. 
- tz
- The timezone. 
Value
A vchart() htmlwidget object.
Examples
library(vchartr)
# Add a title to the axis
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(name = "Date")
# Specify number of labels
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(date_breaks = 5)
# Specify intervals between labels
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(date_breaks = "2 years")
# Format labels
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(date_labels = "MM-YYYY")
# Other format for labels
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(date_labels = "MMM YYYY")
# Format labels with locale
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(
    date_labels = format_date_dayjs("MMMM YY", locale = "fr")
  )
# Different formats in labels and tootlip
vchart(eco2mix) %>%
  v_line(aes(date, solar)) %>%
  v_scale_x_date(
    date_labels = "YYYY-MM",
    date_labels_tooltip = "MMMM YYYY"
  )