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

another way to handle sizing of glyphs | get interactivity #10

Open
timelyportfolio opened this issue Mar 26, 2015 · 1 comment
Open

Comments

@timelyportfolio
Copy link
Contributor

For anyone that wants the graphic to be responsive or potentially interactive, I thought it might be helpful to demo this little bit of code. Resize the browser or viewer to see the effect.

library(waffle)
library(extrafont)
library(gridSVG)
library(XML)
library(htmltools)
library(pipeR)

# slightly more complex example
parts <- c(`Un-breached\nUS Population`=(318-11-79), `Premera`=11, `Anthem`=79)
library(extrafont)
waffle(parts/10, rows=3, colors=c("#969696", "#1879bf", "#009bda"),
       use_glyph="medkit", size=8)

grid.export(name=NULL) %>>%
  (.$svg) %>>%
  (~{xmlAttrs(.)["width"]="100%"} ) %>>%
  (~{xmlAttrs(.)["height"]="100%"} ) %>>%
  saveXML %>>%
  HTML %>>%
  html_print
@timelyportfolio
Copy link
Contributor Author

I made a quick gist to demo http://bl.ocks.org/timelyportfolio/7a39d6593b9e6c470ff3

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

No branches or pull requests

1 participant