Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hc_add_series.list #68

Closed
jbkunst opened this issue Apr 8, 2016 · 3 comments
Closed

hc_add_series.list #68

jbkunst opened this issue Apr 8, 2016 · 3 comments
Milestone

Comments

@jbkunst
Copy link
Owner

jbkunst commented Apr 8, 2016

Usually I have a data frame which generate various series. So I do something like:

dss <- df %>% 
  arrange(name, year) %>% 
  group_by(name) %>% 
  do(dss = list(
    name = first(.$name),
    id = first(.$state),
    data = .[[sprintf("%s_per_100k", varname)]],
    color = ifelse(first(.$name) == "District of Columbia", "red", NA)
  )) %>% 
  .$dss

hc_tms <- highchart() %>%
  hc_chart(...) %>% 
  hc_colors(...) %>% 

hc_tms$x$hc_opts$series <- dss # NO!
hc_tms

I will be something like:

hc_tms %>% 
   hc_add_series(dss)

where dss is a list of lists.

@AKLLaursen
Copy link

I've been doing the same, when writing function wrappers of highcharter plots, where I want the number of series in the plot to be dynamic. Making hc_add_series() take a list as an argument would be a very elegant solution.

@jbkunst jbkunst added this to the v0.4.0 milestone Apr 12, 2016
@jbkunst
Copy link
Owner Author

jbkunst commented Apr 15, 2016

Ok, finally I implemented the hc_add_series_list. Examples here: http://rpubs.com/jbkunst/hc_add_series_list

Hope it helps.

I was expecting make a method hc_add_series (hc_add_series.list, hc_add_series.ts, hc_add_series.string, hc_add_series.numeric), but the problem the first argument is the highcarts object and not the type of the data. In the future I'll think how to do this more elegant ;).

@AKLLaursen
Copy link

Awesome! Thanks a lot for all the good work. Your package is awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants