View source: R/amStackedBarChart.R
amStackedBarChart | R Documentation |
Create a HTML widget displaying a stacked bar chart.
amStackedBarChart( data, data2 = NULL, category, stacks, seriesNames = NULL, colors = NULL, hline = NULL, yLimits = NULL, expandY = 5, valueFormatter = "#.", chartTitle = NULL, theme = NULL, animated = TRUE, tooltip = NULL, threeD = 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 |
stacks |
a list of stacks; a stack is a character vector of the form
|
seriesNames |
names of the series variables (the variables which appear
in the stacks), to appear in the legend; |
colors |
colors of the bars; |
hline |
an optional horizontal line to add to the chart; it must be a
named list of the form |
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 in the cursor tooltips if
|
chartTitle |
chart title, it can be |
theme |
theme, |
animated |
Boolean, whether to animate the rendering of the graphic |
tooltip |
settings of the tooltips; |
threeD |
logical, whether to render the columns in 3D |
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 |
library(rAmCharts4) dat <- data.frame( year = c("2004", "2005", "2006"), europe = c(10, 15, 20), asia = c( 9, 10, 13), africa = c( 5, 6, 8), meast = c( 7, 8, 12), namerica = c(12, 15, 19), samerica = c(10, 16, 14) ) dat2 <- data.frame( year = c("2004", "2005", "2006"), europe = c( 7, 12, 16), asia = c( 8, 13, 10), africa = c( 7, 7, 10), meast = c( 8, 6, 14), namerica = c(10, 17, 17), samerica = c(12, 18, 17) ) stacks <- list( c("europe", "namerica"), c("asia", "africa", "meast", "samerica") ) seriesNames <- list( europe = "Europe", namerica = "North America", asia = "Asia", africa = "Africa", meast = "Middle East", samerica = "South America" ) amStackedBarChart( dat, data2 = dat2, category = "year", stacks = stacks, seriesNames = seriesNames, yLimits = c(0, 60), chartTitle = amText( "Stacked bar chart", fontFamily = "Trebuchet MS", fontSize = 30, fontWeight = "bold" ), xAxis = "Year", yAxis = "A quantity...", theme = "kelly", button = amButton("Update", position = 1), height = 450 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.