amGaugeChart {rAmCharts4}R Documentation

HTML widget displaying a gauge chart

Description

Create a HTML widget displaying a gauge chart.

Usage

amGaugeChart(
  score,
  minScore,
  maxScore,
  scorePrecision = 0,
  gradingData,
  innerRadius = 70,
  labelsRadius = (100 - innerRadius)/2,
  axisLabelsRadius = 19,
  chartFontSize = 11,
  labelsFont = amFont(fontSize = "2em", fontWeight = "bold"),
  axisLabelsFont = amFont(fontSize = "1.2em"),
  scoreFont = amFont(fontSize = "6em"),
  scoreLabelFont = amFont(fontSize = "2em"),
  hand = amHand(innerRadius = 45, width = 8, color = "slategray", strokeColor = "black"),
  gridLines = FALSE,
  chartTitle = NULL,
  theme = NULL,
  animated = TRUE,
  backgroundColor = NULL,
  caption = NULL,
  image = NULL,
  width = NULL,
  height = NULL,
  export = FALSE,
  chartId = NULL,
  elementId = NULL
)

Arguments

score

gauge value, a number between minScore and maxScore

minScore

minimal score

maxScore

maximal score

scorePrecision

an integer, the number of decimals of the score to be displayed

gradingData

data for the gauge, a dataframe with three required columns: label, lowScore, and highScore, and an optional column color; if the column color is not present, then the colors will be derived from the theme

innerRadius

inner radius of the gauge given as a percentage, between 0 (the gauge has no width) and 100 (the gauge is a semi-disk)

labelsRadius

radius for the labels given as a percentage; use the default value to get centered labels

axisLabelsRadius

radius for the axis labels given as a percentage

chartFontSize

reference font size, a numeric value, the font size in pixels; this font size has an effect only if you use the relative CSS unit em for other font sizes

labelsFont

a list of settings for the font of the labels created with amFont, but the font size must be given in pixels or in em CSS units (no other units are accepted)

axisLabelsFont

a list of settings for the font of the axis labels created with amFont

scoreFont

a list of settings for the font of the score created with amFont

scoreLabelFont

a list of settings for the font of the score label created with amFont

hand

a list of settings for the hand of the gauge created with amHand

gridLines

a list of settings for the grid lines created with amLine, or a logical value: FALSE for no grid lines, TRUE for default grid lines

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; it can be given by the name of a R color, the name of a CSS color, e.g. "aqua" or "indigo", an HEX code like "#ff009a", a RGB code like "rgb(255,100,39)", or a HSL code like "hsl(360,11,255)"

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

Note

In Shiny, you can change the score of a gauge chart with the help of updateAmGaugeChart.

Examples

library(rAmCharts4)

gradingData <- data.frame(
  label = c("Slow", "Moderate", "Fast"),
  color = c("blue", "green", "red"),
  lowScore = c(0, 100/3, 200/3),
  highScore = c(100/3, 200/3, 100)
)

amGaugeChart(
  score = 40, minScore = 0, maxScore = 100, gradingData = gradingData
)

[Package rAmCharts4 version 1.6.0 Index]