davidgohel / ggiraph

make 'ggplot' graphics interactive

Home Page:https://davidgohel.github.io/ggiraph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add interactive version for ggpath::geom_from_path

IcaroBernardes opened this issue · comments

The geom_from_path from ggpath allows the user to add images into ggplot. I added images to a ggiraph plot of mine, but it did not become interactive as other geom's.

I solved the issue locally by loading the support functions of the package (ipar.R, layer_interactive.R, utils_ggplot2.R and utils.R) and creating the function below:

geom_from_path_interactive <- function(...)
{layer_interactive(ggpath::geom_from_path, ...)}

GeomInteractiveFromPath <- ggproto(
"GeomInteractiveFromPath",
GeomFromPath,
default_aes = add_default_interactive_aes(GeomFromPath),
parameters = interactive_geom_parameters,
draw_key = interactive_geom_draw_key,
draw_panel = function(data, panel_params, coord, ..., .ipar = IPAR_NAMES) {
zz <- GeomFromPath$draw_panel(data, panel_params, coord, ...)
coords <- coord$transform(data, panel_params)
add_interactive_attrs(zz, coords, ipar = .ipar)
}
)

As you can see, it's nothing too fancy. It's a simple copy of other geom's interactive versions. Do you think it would be possible to add it to the package?