View source: R/amRadialBarChart.R
amRadialBarChart | R Documentation |
Create a HTML widget displaying a radial bar chart.
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 )
data |
a dataframe |
data2 |
|
category |
name of the column of |
values |
name(s) of the column(s) of |
valueNames |
names of the values variables, to appear in the legend;
|
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; |
expandY |
if |
valueFormatter |
a
number formatting string;
it is used to format the values displayed on the chart if
|
chartTitle |
chart title, it can be |
theme |
theme, |
animated |
Boolean, whether to animate the rendering of the graphic |
draggable |
|
tooltip |
settings of the tooltips; |
columnStyle |
settings of the columns; |
bullets |
settings of the bullets; |
alwaysShowBullets |
logical, whether to always show the bullets;
if |
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.
|
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; |
columnWidth |
column width, a percentage of the cell width; set to 100
for a simple bar chart and use |
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 |
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 |
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 |
caption |
|
image |
option to include an image at a corner of the chart;
|
button |
|
cursor |
option to add a cursor on the chart; |
width |
the width of the chart, e.g. |
height |
the height of the chart, e.g. |
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 |
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.