# Import
NRX02_raw <-
  statgl_url("NRX02", lang = language) %>%
  statgl_fetch(
    "account name" = c("LBNPTOT", "LLONTOT"),
    units          = "L",
    time           = px_all(),
    .col_code      = TRUE
    ) %>% 
  as_tibble()
NRX02 <- 
  NRX02_raw %>% 
  spread(`account name`, value) %>% 
  rename(BNP = 3, lon = 4) %>% 
  mutate(
    value = lon / BNP,
    time = time %>% as.numeric()
    )
NRX02 %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    color = units
  )) +
  geom_line(size = 2) +
  scale_y_continuous(labels  = scales::percent_format(
     scale = 100, 
     accuracy = 1, 
     big.mark = ".",
     decimal.mark = ","
    )) +
  theme_statgl() +
  scale_color_statgl() +
  theme(legend.position = "none") +
  labs(
    title    = sdg10$figs$fig1$title[language],
    x        = " ",
    y        = " ",
    caption  = sdg10$figs$fig1$cap[language]
  )# Import
INXIU101_raw <-
  statgl_url("INXIU101", lang = language) %>% 
  statgl_fetch(indicator = 0:1,
               time      = px_all(),
               .col_code = TRUE) %>% 
  as_tibble()
INXIU101 <-
  INXIU101_raw %>% 
  filter(indicator == unique(INXIU101_raw[[1]])[1]) %>% 
  mutate(time = time %>% make_date())
INXIU101 %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    color = indicator
  )) +
  geom_line(size = 2) +
  scale_color_statgl() +
  theme_statgl() +
  theme(legend.position = "none") +
  labs(
    title = unique(INXIU101_raw[[1]])[1],
    subtitle = sdg10$figs$fig2$sub[language],
    x        = " ",
    y        = sdg10$figs$fig2$y_lab[language],
    color    = sdg10$figs$fig2$color[language],
    caption  = sdg10$figs$fig2$cap[language]
  )INXPI403_raw <- 
  statgl_url("INXPI403", lang = language) |> 
  statgl_fetch(
    "Decile: Palma ratio" = 0,
    time                  = px_all(),
    .col_code             = T
  ) |> 
  as_tibble()
INXPI403 <- 
  INXPI403_raw |> 
  mutate(time = time |> make_date())
INXPI403 |> 
  ggplot(aes(
    x     = time,
    y     = value,
    color = "Decile: Palma ratio"
  )) +
  geom_line(size = 2) +
  scale_color_statgl() +
  theme_statgl() +
  theme(legend.position = "none") +
  labs(
    title    = unique(INXPI403_raw[[1]])[1],
    subtitle = sdg10$figs$fig3$sub[language],
    x        = " ",
    y        = sdg10$figs$fig3$y_lab[language],
    caption  = sdg10$figs$fig3$cap[language]
  )# Transform
INXIU101 <-
  INXIU101_raw %>% 
  filter(indicator == unique(INXIU101_raw[[1]])[2]) %>% 
  mutate(time = time %>% make_date())
# Plot
INXIU101 %>% 
  ggplot(aes(
    x     = time,
    y     = value,
    color = indicator
  )) +
  geom_line(size = 2) +
  scale_y_continuous(labels = scales::unit_format(
    suffix = " ",
    big.mark = ".",
    decimal.mark = ","
  )) +
  scale_color_statgl() +
  theme_statgl() +
  theme(legend.position = "none") +
  labs(
    title = unique(INXIU101_raw[[1]])[2],
    subtitle = sdg10$figs$fig4$sub[language],
    x = " ",
    y = sdg10$figs$fig4$y_lab[language],
    caption = sdg10$figs$fig4$cap[language]
  )# NÅET HERTIL!!!
# Import
SOX004_raw <-
  statgl_url("SOX004", lang = language) %>% 
  statgl_fetch(
    "unit"    = "Antal",
    "type"    = 10,
    "time"    = px_all(),
    .col_code = TRUE
    ) %>% 
  as_tibble()
# Transform
SOX004 <- 
  SOX004_raw %>% 
  mutate(
    time  = time %>% make_date(),
    value = value / 1000
  )
# Plot
SOX004 %>% 
  ggplot(aes(
    x    = time,
    y    = value,
    fill = unit
  )) +
  geom_col() +
  theme_statgl() + 
  scale_fill_statgl() +
  theme(legend.position = "none") +
  labs(
    title    = SOX004[[2]][1],
    subtitle = sdg10$figs$fig5$sub[language],
    x        = " ",
    y        = sdg10$figs$fig5$y_lab[language],
    fill     = " ",
    caption  = sdg10$figs$fig5$cap[language]
  )SOXFPE1_raw <- 
  "SOXFPE1" %>% 
  statgl_url() %>% 
  statgl_fetch() %>% 
  as_tibble()
SOXFPE1_raw %>% 
  ggplot(aes(
    x = time,
    y = value,
    fill = time
  )) +
  geom_col() +
  theme_statgl() +
  scale_y_continuous(breaks = scales::pretty_breaks()) +
  scale_x_discrete(breaks = scales::pretty_breaks()) +
  scale_fill_statgl() +
  theme(legend.position = "none") +
  labs(
    title    = sdg10$figs$fig6$title[language],
    x        = " ",
    y        = " ",
    caption  = sdg10$figs$fig6$cap[language]
  )