The link below talks about how you can build a hook into plotly using the gets3methods
call with to.basic
. However, this only works for geoms that that be broken down into simpler geoms (geom_line
to geom_path
). For geom_text_repel
I'm not sure that possible.
It goes on to mention that you have to create a custom method for the geom2trace
. How would one go about doing this? I'm new to the S3 data guidelines and doing something like this, so I'm not exactly sure where to even start here.
If I run the methods(geom2trace)
I get:
> methods(geom2trace)
[1] geom2trace.default* geom2trace.GeomBar* geom2trace.GeomBlank* geom2trace.GeomBoxplot* geom2trace.GeomErrorbar*
[6] geom2trace.GeomErrorbarh* geom2trace.GeomPath* geom2trace.GeomPoint* geom2trace.GeomPolygon* geom2trace.GeomText*
[11] geom2trace.GeomTile*
see '?methods' for accessing help and source code
and I see a geom2trace.GeomText
which seems like something that is needed here.
Any guidance here would be a huge help in me trying to create an interactive wordcloud! Happy to share the outcome of this project as well.
In more complicated cases, where your custom geom can not be converted to a lower level geom, a custom method for the geom2trace() generic is required (methods(geom2trace) lists all the basic geoms that we natively support). This method should involve a conversion from a data frame to a list-like object conforming to the plotly.js figure reference.
https://plotly-book.cpsievert.me/translating-custom-ggplot2-geoms.html