updated slope chart example
This commit is contained in:
parent
85708897b0
commit
5f8389ff34
|
@ -1,5 +1,5 @@
|
|||
Package: apexcharter
|
||||
Version: 0.4.3
|
||||
Version: 0.4.3.9000
|
||||
Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library
|
||||
Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'.
|
||||
'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API.
|
||||
|
|
|
@ -16,9 +16,11 @@ life_expec_long <- life_expec_long[year %in% c(1972, 2007), list(country, year,
|
|||
life_expec_long <- life_expec_long[country %in% c("Botswana", "Ghana", "Iran", "Liberia", "Malaysia", "Mexico",
|
||||
"Nigeria", "Pakistan", "Philippines", "Zambia")]
|
||||
life_expec_long[, country := as.character(country)]
|
||||
life_expec_long[, lifeExp := round(lifeExp, 1)]
|
||||
life_expec <- dcast(life_expec_long, country ~ year, value.var = "lifeExp")
|
||||
life_expec[, type := fifelse(`1972` > `2007`, "decreased", "increased")]
|
||||
|
||||
life_expec_long <- melt(data = life_expec, id.vars = c("country", "type"), variable.name = "year", value.name = "lifeExp")
|
||||
|
||||
|
||||
# Use data ----------------------------------------------------------------
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -347,16 +347,20 @@ data("life_expec_long", package = "apexcharter")
|
|||
|
||||
apex(
|
||||
life_expec_long,
|
||||
mapping = aes(x = as.character(year), y = lifeExp, fill = country),
|
||||
mapping = aes(x = year, y = lifeExp, fill = country),
|
||||
type = "slope",
|
||||
height = "700px"
|
||||
) %>%
|
||||
ax_colors("#112466") %>%
|
||||
ax_chart(animations = list(enabled = FALSE)) %>%
|
||||
# aurora nord12 = #d08770 / aurora nord14 = #a3be8c -> darken colorspace::darken(, amount = 0.3)
|
||||
ax_colors(ifelse(unique(life_expec_long[, c("country", "type")])$type == "decreased", "#955945", "#6A8354")) %>%
|
||||
ax_labs(
|
||||
title = "Life expectancy : 1972 vs. 2007",
|
||||
subtitle = "Data from Gapminder dataset",
|
||||
x = "Life expectancy at birth, in years"
|
||||
)
|
||||
) %>%
|
||||
# ax_dataLabels(enabled = FALSE) %>% # show or note the labels + values
|
||||
ax_xaxis(position = "bottom")
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue