Legend properties
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, ...)
ax | A |
---|---|
show | Logical. Whether to show or hide the legend container. |
position | Available position options for legend: |
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: |
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 |
markers | List. |
itemMargin | List with two items |
containerMargin | List with two items |
onItemClick | List with item |
onItemHover | List with item |
floating | Logical. The floating option will take out the legend from the chart area and make it float above the chart. |
... | Additional parameters. |
A apexcharts
htmlwidget
object.
See https://apexcharts.com/docs/options/legend/
library(dplyr) data("mpg", package = "ggplot2") # Legend position apex( data = count(mpg, manufacturer, year), mapping = aes(x = manufacturer, y = n, fill = year) ) %>% ax_legend(position = "right") # hide legend apex( data = count(mpg, manufacturer, year), mapping = aes(x = manufacturer, y = n, fill = year) ) %>% ax_legend(show = FALSE)