dreamRs / apexcharter

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

Feature request: New chart type - box plots #66

Closed pozlepster closed 1 year ago

pozlepster commented 1 year ago

Hi,

if possible, it would be very useful to introduce a new chart type for box plots. Thank you.

Best wishes

pvictor commented 1 year ago

Hello, You mean support boxplot in apex() function ? Because otherwise you can already do boxplots, there just an issue if you try to plot several outliers for a same category.

Here's an example to plot a basic boxplot :

library(apexcharter)
data("mpg", package = "ggplot2")
boxed <- boxplot(hwy ~ class, data = mpg)

apexchart() %>% 
  ax_chart(type = "boxPlot") %>% 
  ax_xaxis(type = "categories", categories = boxed$names) %>%
  ax_series(
    list(
      name = "boxes",
      type = "boxPlot",
      data = lapply(
        X = seq_along(boxed$names),
        FUN = function(i) {
          list(
            x = i,
            y = c(
              boxed$stats[1, i],
              boxed$stats[2, i],
              boxed$stats[3, i],
              boxed$stats[4, i],
              boxed$stats[5, i]
            )
          )
        }
      )
    )
  )

Victor

pozlepster commented 1 year ago

Yes I meant it would be great to support boxplot in apex(). :)

pozlepster commented 1 year ago

I see boxplots have been implemented in the new version of the package, do you maybe have the timeline for the release of v.0.4.1 ? Thanks for all your great work. :)

pvictor commented 1 year ago

Hello, I think there's still an issue with outliers (when there are several points for one category) but yes I can release on CRAN soon anyway.

pvictor commented 1 year ago

On CRAN now :)