amPercentageBarChart: HTML widget displaying a 100% stacked bar chart

View source: R/amPercentageBarChart.R

amPercentageBarChartR Documentation

HTML widget displaying a 100% stacked bar chart

Description

Create a HTML widget displaying a 100% stacked bar chart.

Usage

amPercentageBarChart(
  data,
  category,
  values,
  valueNames = NULL,
  hline = NULL,
  chartTitle = NULL,
  theme = NULL,
  animated = TRUE,
  backgroundColor = NULL,
  xAxis = NULL,
  yAxis = NULL,
  scrollbarX = FALSE,
  scrollbarY = FALSE,
  legend = TRUE,
  caption = NULL,
  image = NULL,
  width = NULL,
  height = NULL,
  export = FALSE,
  chartId = NULL,
  elementId = NULL
)

Arguments

data

a dataframe

category

name of the column of data to be used on the category axis

values

names of the columns of data to be used on the value axis

valueNames

names of the values variables, to appear in the legend; NULL to use values as names, otherwise a named list of the form list(value1 = "ValueName1", value2 = "ValueName2", ...) where value1, value2, ... are the column names given in values and "ValueName1", "ValueName2", ... are the desired names to appear in the legend; these names also appear in the tooltips.

hline

an optional horizontal line to add to the chart; it must be a named list of the form list(value = h, line = settings) where h is the "intercept" and settings is a list of settings created with amLine

chartTitle

chart title, it can be NULL or FALSE for no title, a character string, a list of settings created with amText, or a list with two fields: text, a list of settings created with amText, and align, can be "left", "right" or "center"

theme

theme, NULL or one of "dataviz", "material", "kelly", "dark", "moonrisekingdom", "frozen", "spiritedaway", "patterns", "microchart"

animated

Boolean, whether to animate the rendering of the graphic

backgroundColor

a color for the chart background; a color can be given by the name of a R color, the name of a CSS color, e.g. "rebeccapurple" or "fuchsia", an HEX code like "#ff009a", a RGB code like "rgb(255,100,39)", or a HSL code like "hsl(360,11,255)"

xAxis

settings of the category axis given as a list, or just a string for the axis title; the list of settings has three possible fields: a field title, a list of settings for the axis title created with amText, a field labels, a list of settings for the axis labels created with amAxisLabels, and a field adjust, a number defining the vertical adjustment of the axis (in pixels)

yAxis

settings of the value axis given as a list, or just a string for the axis title; the list of settings has five possible fields: a field title, a list of settings for the axis title created with amText, a field labels, a list of settings for the axis labels created with amAxisLabels, a field adjust, a number defining the horizontal adjustment of the axis (in pixels), a field gridLines, a list of settings for the grid lines created with amLine and a field breaks to control the axis breaks, an R object created with amAxisBreaks

scrollbarX

logical, whether to add a scrollbar for the category axis

scrollbarY

logical, whether to add a scrollbar for the value axis

legend

either a logical value, whether to display the legend, or a list of settings for the legend created with amLegend

caption

NULL or FALSE for no caption, a formatted text created with amText, or a list with two fields: text, a list created with amText, and align, can be "left", "right" or "center"

image

option to include an image at a corner of the chart; NULL or FALSE for no image, otherwise a named list with four possible fields: the field image (required) is a list created with amImage, the field position can be "topleft", "topright", "bottomleft" or "bottomright", the field hjust defines the horizontal adjustment, and the field vjust defines the vertical adjustment

width

the width of the chart, e.g. "600px" or "80%"; ignored if the chart is displayed in Shiny, in which case the width is given in amChart4Output

height

the height of the chart, e.g. "400px"; ignored if the chart is displayed in Shiny, in which case the height is given in amChart4Output

export

logical, whether to enable the export menu

chartId

a HTML id for the chart

elementId

a HTML id for the container of the chart; ignored if the chart is displayed in Shiny, in which case the id is given by the Shiny id

Examples

library(rAmCharts4)

dat <- data.frame(
  category = c("A", "B", "C"),
  v1 = c(1, 2, 3),
  v2 = c(9, 5, 7)
)

amPercentageBarChart(
  dat,
  category = "category",
  values = c("v1", "v2"),
  valueNames = c("Value1", "Value2"),
  yAxis = "Percentage",
  theme = "dataviz",
  legend = amLegend(position = "right")
)

rAmCharts4 documentation built on Sept. 22, 2022, 5:05 p.m.