ax_legend {apexcharter}R Documentation

Legend properties

Description

Legend properties

Usage

ax_legend(
  ax,
  show = NULL,
  position = NULL,
  showForSingleSeries = NULL,
  showForNullSeries = NULL,
  showForZeroSeries = NULL,
  horizontalAlign = NULL,
  fontSize = NULL,
  textAnchor = NULL,
  offsetY = NULL,
  offsetX = NULL,
  formatter = NULL,
  labels = NULL,
  markers = NULL,
  itemMargin = NULL,
  containerMargin = NULL,
  onItemClick = NULL,
  onItemHover = NULL,
  floating = NULL,
  ...
)

Arguments

ax

A apexcharts htmlwidget object.

show

Logical. Whether to show or hide the legend container.

position

Available position options for legend: "top", "right", "bottom", "left".

showForSingleSeries

Show legend even if there is just 1 series.

showForNullSeries

Allows you to hide a particular legend if it's series contains all null values.

showForZeroSeries

Allows you to hide a particular legend if it's series contains all 0 values.

horizontalAlign

Available options for horizontal alignment: "right", "center", "left".

fontSize

Sets the fontSize of legend text elements

textAnchor

The alignment of text relative to legend's drawing position

offsetY

Sets the top offset for legend container.

offsetX

Sets the left offset for legend container.

formatter

JS function. A custom formatter function to append additional text to the legend series names.

labels

List with two items "foreColor" (Custom text color for legend labels) and "useSeriesColors" (Logical, whether to use primary colors or not)

markers

List.

itemMargin

List with two items "horizontal" (Horizontal margin for individual legend item) and "vertical" (Vertical margin for individual legend item).

containerMargin

List with two items "top" (Top margin for the whole legend container) and "left" (Left margin for the whole legend container).

onItemClick

List with item "toggleDataSeries", logical, when clicked on legend item, it will toggle the visibility of the series in chart.

onItemHover

List with item "highlightDataSeries", logical, when hovered on legend item, it will highlight the paths of the hovered series in chart.

floating

Logical. The floating option will take out the legend from the chart area and make it float above the chart.

...

Additional parameters.

Value

A apexcharts htmlwidget object.

Note

See https://apexcharts.com/docs/options/legend/

Examples

data("mpg", package = "ggplot2")

# Legend position
apex(
  data = mpg,
  mapping = aes(x = manufacturer, fill = year)
) %>% 
  ax_legend(position = "right")

# hide legend
apex(
  data = mpg,
  mapping = aes(x = manufacturer, fill = year)
) %>% 
  ax_legend(show = FALSE)

[Package apexcharter version 0.2.0 Index]