bupaverse / processanimateR

Token replay animation for process maps created with processmapR by using SVG animations (SMIL) and the htmlwidget package.
https://bupaverse.github.io/processanimateR/
Other
66 stars 11 forks source link

Adding legends to process map animations #6

Closed czucchet closed 6 years ago

czucchet commented 6 years ago

Hi,

Firstly, supermegacool package!

Is there the ability to add a legend when colors are added(haven't been able to find anything so far)?

For instance, the following gives me different colors for each respective employee, but is there a way to show which color each employee has been assigned to within the animation?

animate_process(add_token_color(patients, "employee", "color", color_mapping = scales::col_factor("Set3", patients$employee)), animation_mode = "relative", token_color = "color")

Thanks!!

fmannhardt commented 6 years ago

Hi, sorry for the delayed answer. It would be a great feature to add. In fact, I should change the animation to be build step by step similar to a ggplot2 chart. Maybe it could somehow be integrated since I am already using the functions from the 'scales' package for colors.

I did not find a standalone method to get a legend from a color scale in R. Will put that on the ideas for the next release.

fmannhardt commented 6 years ago

Added a legend feature in 7f14307e36ce6e1b0f74834e820d8ff7a480b292 It is based on d3-scales and d3-legends: https://github.com/susielu/d3-legend This will replace the custom add_token_color and add_token_size functions based on ggplot scales. So far I tried to keep it backward compatible, but in a future version this needs to be cleaned up. The animate_process method gets way too many parameters.

Let me know the legend works for you.

czucchet commented 6 years ago

Hi there,

Tested out the legend and it works really well - keep up the awesome work!

Thanks :)