# NOT RUN {
# a simple bar chart ####
dat <- data.frame(
country = c("USA", "China", "Japan", "Germany", "UK", "France"),
visits = c(3025, 1882, 1809, 1322, 1122, 1114)
)
amBarChart(
data = dat, data2 = dat,
width = "600px",
category = "country", values = "visits",
draggable = TRUE,
tooltip =
"[bold font-style:italic #ffff00]{valueY.value.formatNumber('#,###.')}[/]",
chartTitle =
amText(text = "Visits per country", fontSize = 22, color = "orangered"),
xAxis = list(title = amText(text = "Country", color = "maroon")),
yAxis = list(
title = amText(text = "Visits", color = "maroon"),
gridLines = amLine(color = "orange", width = 1, opacity = 0.4)
),
yLimits = c(0, 4000),
valueFormatter = "#,###.",
caption = amText(text = "Year 2018", color = "red"),
theme = "material")
# bar chart with individual images in the bullets ####
dat <- data.frame(
language = c("Python", "Julia", "Java"),
users = c(10000, 2000, 5000),
href = c(
tinyIcon("python", "transparent"),
tinyIcon("julia", "transparent"),
tinyIcon("java", "transparent")
)
)
amBarChart(
data = dat,
width = "700px",
category = "language",
values = "users",
valueNames = list(users = "#users"),
showValues = FALSE,
tooltip = amTooltip(
text = "{name}: [bold]valueY[/]",
textColor = "white",
backgroundColor = "#101010",
borderColor = "silver"
),
draggable = FALSE,
backgroundColor = "seashell",
bullets = amCircle(
radius = 30,
color = "white",
strokeWidth = 4,
image = amImage(
href = "inData:href",
width = 50, height = 50
)
),
alwaysShowBullets = TRUE,
xAxis = list(title = amText(text = "Programming language")),
yAxis = list(
title = amText(text = "# users"),
gridLines = amLine(color = "orange", width = 1, opacity = 0.4)
),
yLimits = c(0, 12000),
valueFormatter = "#.",
theme = "material")
# a grouped 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)
)
amBarChart(
data = dat,
width = "700px",
category = "country",
values = c("income", "expenses"),
valueNames = list(income = "Income", expenses = "Expenses"),
tooltip = amTooltip(
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"),
xAxis = list(title = amText(text = "Country")),
yAxis = list(
title = amText(text = "Income and expenses"),
gridLines = amLine(color = "whitesmoke", width = 1, opacity = 0.4),
breaks = amAxisBreaks(values = seq(0, 45, by = 5))
),
yLimits = c(0, 45),
valueFormatter = "#.#",
caption = amText(text = "Year 2018"),
theme = "dark")
# }
Run the code above in your browser using DataLab