amRadialBarChart {rAmCharts4}R Documentation

HTML widget displaying a radial bar chart

Description

Create a HTML widget displaying a radial bar chart.

Usage

amRadialBarChart(
  data,
  data2 = NULL,
  category,
  values,
  valueNames = NULL,
  showValues = TRUE,
  innerRadius = 50,
  yLimits = NULL,
  expandY = 5,
  valueFormatter = "#.",
  chartTitle = NULL,
  theme = NULL,
  animated = TRUE,
  draggable = FALSE,
  tooltip = NULL,
  columnStyle = NULL,
  bullets = NULL,
  alwaysShowBullets = FALSE,
  backgroundColor = NULL,
  cellWidth = NULL,
  columnWidth = NULL,
  xAxis = NULL,
  yAxis = NULL,
  scrollbarX = FALSE,
  scrollbarY = FALSE,
  legend = NULL,
  caption = NULL,
  image = NULL,
  button = NULL,
  cursor = FALSE,
  width = NULL,
  height = NULL,
  export = FALSE,
  chartId = NULL,
  elementId = NULL
)

Arguments

data

a dataframe

data2

NULL or a dataframe used to update the data with the button; its column names must include the column names of data given in values, it must have the same number of rows as data and its rows must be in the same order as those of data

category

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

values

name(s) of the column(s) 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 can also appear in the tooltips: they are substituted to the string {name} in the formatting string passed on to the tooltip (see the second example of amBarChart)

showValues

logical, whether to display the values on the chart

innerRadius

inner radius of the chart, a percentage (between 0 and 100 theoretically, but in practice it should be between 30 and 70)

yLimits

range of the y-axis, a vector of two values specifying the lower and the upper limits of the y-axis; NULL for default values

expandY

if yLimits = NULL, a percentage of the range of the y-axis used to expand this range

valueFormatter

a number formatting string; it is used to format the values displayed on the chart if showValues = TRUE, the values displayed in the cursor tooltips if cursor = TRUE, the labels of the y-axis unless you specify your own formatter in the labels field of the list passed on to the yAxis option, and the values displayed in the tooltips unless you specify your own tooltip text (see the first example for the way to set a number formatter in the tooltip text)

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

draggable

TRUE/FALSE to enable/disable dragging of all bars, otherwise a named list of the form list(value1 = TRUE, value2 = FALSE, ...) to enable/disable the dragging for each bar corresponding to a column given in values

tooltip

settings of the tooltips; NULL for default, FALSE for no tooltip, otherwise a named list of the form list(value1 = settings1, value2 = settings2, ...) where settings1, settings2, ... are lists created with amTooltip; this can also be a single list of settings that will be applied to each series, or a just a string for the text to display in the tooltip

columnStyle

settings of the columns; NULL for default, otherwise a named list of the form list(value1 = settings1, value2 = settings2, ...) where settings1, settings2, ... are lists created with amColumn; this can also be a single list of settings that will be applied to each column

bullets

settings of the bullets; NULL for default, otherwise a named list of the form list(value1 = settings1, value2 = settings2, ...) where settings1, settings2, ... are lists created with amCircle, amTriangle or amRectangle; this can also be a single list of settings that will be applied to each series

alwaysShowBullets

logical, whether to always show the bullets; if FALSE, the bullets are shown only on hovering a column

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. "lime" or "fuchsia", an HEX code like "#ff009a", a RGB code like "rgb(255,100,39)", or a HSL code like "hsl(360,11,255)"

cellWidth

cell width in percent; for a simple bar chart, this is the width of the columns; for a grouped bar chart, this is the width of the clusters of columns; NULL for the default value

columnWidth

column width, a percentage of the cell width; set to 100 for a simple bar chart and use cellWidth to control the width of the columns; for a grouped bar chart, this controls the spacing between the columns within a cluster of columns; NULL for the default value

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 amAxisLabelsCircular, 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

button

NULL for the default, FALSE for no button, or a list of settings created with amButton; this button is used to replace the current data with data2

cursor

option to add a cursor on the chart; FALSE for no cursor, TRUE for a cursor with default settings for the tooltips, or a list of settings created with amTooltip to set the style of the tooltips, or a list with three possible fields: a field tooltip, a list of tooltip settings created with amTooltip, a field extraTooltipPrecision, an integer, the number of additional decimals to display in the tooltips, and a field modifier, which defines a modifier for the values displayed in the tooltips; a modifier is some JavaScript code given a string, which performs a modification of a string named text, e.g. modifier = "text = '>>>' + text;"

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

# a grouped radial bar chart ####

set.seed(666)
dat <- data.frame(
  country = c("USA", "China", "Japan", "Germany", "UK", "France"),
  visits = c(3025, 1882, 1809, 1322, 1122, 1114),
  income = rpois(6, 25),
  expenses = rpois(6, 20)
)

amRadialBarChart(
  data = dat, data2 = dat,
  width = "600px", height = "600px",
  category = "country",
  values = c("income", "expenses"),
  valueNames = list(income = "Income", expenses = "Expenses"),
  showValues = FALSE,
  tooltip = amTooltip(
    textColor = "white",
    backgroundColor = "#101010",
    borderColor = "silver"
  ),
  draggable = TRUE,
  backgroundColor = "#30303d",
  columnStyle = list(
    income = amColumn(
      color = "darkmagenta",
      strokeColor = "#cccccc",
      strokeWidth = 2
    ),
    expenses = amColumn(
      color = "darkred",
      strokeColor = "#cccccc",
      strokeWidth = 2
    )
  ),
  chartTitle = "Income and expenses per country",
  xAxis = list(
    labels = amAxisLabelsCircular(
      radius = -82, relativeRotation = 90
    )
  ),
  yAxis = list(
    labels = amAxisLabels(color = "orange"),
    gridLines = amLine(color = "whitesmoke", width = 1, opacity = 0.4),
    breaks = amAxisBreaks(values = seq(0, 40, by = 10))
  ),
  yLimits = c(0, 40),
  valueFormatter = "#.#",
  caption = amText(
    text = "Year 2018",
    fontFamily = "Impact",
    fontSize = 18
  ),
  theme = "dark")


# just for fun ####

dat <- data.frame(
  cluster = letters[1:6],
  y1 = rep(10, 6),
  y2 = rep(8, 6),
  y3 = rep(6, 6),
  y4 = rep(4, 6),
  y5 = rep(2, 6),
  y6 = rep(4, 6),
  y7 = rep(6, 6),
  y8 = rep(8, 6),
  y9 = rep(10, 6)
)

amRadialBarChart(
  data = dat,
  width = "500px", height = "500px",
  innerRadius = 10,
  category = "cluster", values = paste0("y", 1:9),
  showValues = FALSE,
  tooltip = FALSE, draggable = FALSE,
  backgroundColor = "black",
  columnStyle = amColumn(strokeWidth = 1, strokeColor = "white"),
  cellWidth = 96,
  xAxis = list(labels = FALSE),
  yAxis = list(labels = FALSE, gridLines = FALSE),
  yLimits = c(0, 10),
  legend = FALSE,
  theme = "kelly")

[Package rAmCharts4 version 1.6.0 Index]