dreamRs / apexcharter

:bar_chart: R Htmlwidget for ApexCharts.js
https://dreamrs.github.io/apexcharter
Other
138 stars 15 forks source link

Mixed/Combo charts when using apex() function to create series #58

Open bergatronic opened 2 years ago

bergatronic commented 2 years ago

Hi all,

It does not seem possible to create a series-specific chart type when using the apex() function to map a data frame into series.

Is there some way to use the aes() function to accomplish this?

I have tried to add a "type" mapping in the aes() function but it seems to be ignored

Below is a small reproducible example. I create a stacked area chart and I want to put a point to display the combined total value.

data <- tibble::tibble(x = runif(10), y = runif(10), total = x + y, x_axis = 1:10) %>% 
  dplyr::mutate(dplyr::across(c(x,y,total), cumsum)) %>% 
  tidyr::pivot_longer(names_to = "series", values_to = "value", cols = c(x,y,total)) %>%
  dplyr::arrange(series) %>%
  dplyr::mutate(series_type = ifelse(series == "total", "scatter", "area"))

library(apexcharter)
apex(data, aes(x = x_axis, y = value, group = series, type = series_type)) %>% 
  ax_chart(stacked = TRUE)