jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
717 stars 147 forks source link

ggplot2 aes grouping functionality #776

Closed dmacoritto closed 3 months ago

dmacoritto commented 1 year ago

Hello dear highcharter fans,

I am writing here as I think a key feature of ggplot2 is missing in highchart (and highcharter).

A key function in ggplot2 is the possibility to group data on two (or more) different aspects: per shape and per color for instance. I have tried to replicate that behavior with highcharter but did not manage to find how I could do it (it seems to me this is not possible). For instance, the code below gives me a chart with two legends in ggplot2.

library(tidyverse)

data("diamonds")

diamonds%>%
  head(100)%>%
  ggplot(aes(x = price, y = carat, color = clarity, size = cut))+
  geom_point()

In highchart, I could not do it. This, for example, throws an error:


hchart(object = diamonds%>%head(100),
       type = "scatter",
       mapping = hcaes(x = price, y = carat, group = c(clarity, cut)))

This problem also holds when adding other variables in aes. For instance, in ggplot2, we could add shape, size, linetype, etc. in the aes argument. That would be great if this feature could be available in highcharts.

Also, if there is a workaround solution, I would be very happy if someone could share it.

Regards

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.