Skip to content

Commit

Permalink
updated slope chart example
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed May 22, 2024
1 parent 8570889 commit 5f8389f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions data-raw/life_expectancy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------------------
Expand Down
Binary file modified data/life_expec.rda
Binary file not shown.
Binary file modified data/life_expec_long.rda
Binary file not shown.
10 changes: 7 additions & 3 deletions vignettes/apexcharter.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```


0 comments on commit 5f8389f

Please sign in to comment.