svglite is a handy package, but inserting an "id" on a polygon (for instance) becomes a bit tricky. Giving lines/points/paths/etc custom id's would greatly increase the potential for neat data visualizations using custom CSS and/or javascript. With my limited experience, I've created an svg from either svglite or ggsave, then use the xml2 package to get the id's in there. That might sound easy enough...but in actuality it was kind of a pain (to me at least...).
I'm not sure the best way, but workflows such as this would be awesome:
svglite(tmp1)
plot(x, y, id="cats")
lines(x, z, id="cows")
dev.off()
The svg output would now allow me to set linewidths and colors and whatnot on "cows" and "cats" in the CSS. I could also make some javascript functions that depend on the Id.
Maybe to get real fancy....we could also set javascript functions or CSS style directly in the R code too.
This is something our group has struggled with and we're excited to hear the best way to go. Maybe there already is a perfectly acceptable way to do this, in which case I'd be super-happy to hear it!
I think a similar strategy is used by ggiraph, relying on the rvg graphics device. I believe one can add IDs to ggplot elements by adding a data_id aesthetic to the ggplot.
svglite
is a handy package, but inserting an "id" on a polygon (for instance) becomes a bit tricky. Giving lines/points/paths/etc custom id's would greatly increase the potential for neat data visualizations using custom CSS and/or javascript. With my limited experience, I've created an svg from eithersvglite
orggsave
, then use thexml2
package to get the id's in there. That might sound easy enough...but in actuality it was kind of a pain (to me at least...).I'm not sure the best way, but workflows such as this would be awesome:
or....
The svg output would now allow me to set linewidths and colors and whatnot on "cows" and "cats" in the CSS. I could also make some javascript functions that depend on the Id.
Maybe to get real fancy....we could also set javascript functions or CSS style directly in the R code too.
This is something our group has struggled with and we're excited to hear the best way to go. Maybe there already is a perfectly acceptable way to do this, in which case I'd be super-happy to hear it!