# NOT RUN {
# a simple horizontal bar chart ####
dat <- data.frame(
country = c("USA", "China", "Japan", "Germany", "UK", "France"),
visits = c(3025, 1882, 1809, 1322, 1122, 1114)
)
amHorizontalBarChart(
data = dat, data2 = dat,
width = "600px", height = "550px",
category = "country", values = "visits",
draggable = TRUE,
tooltip = "[font-style:italic #ffff00]{valueX}[/]",
chartTitle =
amText(text = "Visits per country", fontSize = 22, color = "orangered"),
xAxis = list(
title = amText(text = "Country", color = "maroon"),
gridLines = amLine(opacity = 0.4, width = 1, dash = "3,1")
),
yAxis = list(title = amText(text = "Visits", color = "maroon")),
xLimits = c(0, 4000),
valueFormatter = "#,###",
caption = amText(text = "Year 2018", color = "red"),
theme = "moonrisekingdom")
# a grouped horizontal 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)
)
amHorizontalBarChart(
data = dat,
width = "700px",
category = "country",
values = c("income", "expenses"),
valueNames = list(income = "Income", expenses = "Expenses"),
tooltip = amTooltip(
text = "[bold]{name}:\n{valueX}[/]",
textColor = "white",
backgroundColor = "#101010",
borderColor = "silver"
),
draggable = list(income = TRUE, expenses = FALSE),
backgroundColor = "#30303d",
columnStyle = list(
income = amColumn(
color = "darkmagenta",
strokeColor = "#cccccc",
strokeWidth = 2
),
expenses = amColumn(
color = "darkred",
strokeColor = "#cccccc",
strokeWidth = 2
)
),
chartTitle = amText(text = "Income and expenses per country"),
yAxis = list(title = amText(text = "Country")),
xAxis = list(
title = amText(text = "Income and expenses"),
gridLines = amLine(color = "whitesmoke", width = 1, opacity = 0.4)
),
xLimits = c(0, 41),
valueFormatter = "#.#",
caption = amText(text = "Year 2018"),
theme = "dark")
# }
Run the code above in your browser using DataLab