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

CSS style in r2d3 call influencing entire RMarkdown document #23

Closed
zmeers opened this issue May 3, 2018 · 2 comments · Fixed by #27
Closed

CSS style in r2d3 call influencing entire RMarkdown document #23

zmeers opened this issue May 3, 2018 · 2 comments · Fixed by #27
Assignees

Comments

@zmeers
Copy link

zmeers commented May 3, 2018

Hello,

First of all, thank you for creating R2D3!

I have an issue with the CSS styling in a r2d3 call affecting the entire HTML output of my R Markdown file. For example, I wrapped a r3d3 function and included it in my own package. When I created the vignette for my pkgdown site, the HTML output for that vignette uses the fonts in the CSS style embedded in the r2d3 call. (See https://usstudiescentre.github.io/ussc/articles/rollcall.html for an explanation of what I mean. The rest of the website uses the standard pkgdown CSS style.) I don't want this to happen. I'd like to contain the CSS style in the r2d3 call to that particular code chunk. Is this possible?

Thanks.

@jjallaire
Copy link
Member

Yes. If you qualify your styles with .r2d3 then they should be scoped to only affect your visualization. For example, here's a re-write of the CSS for the circlepacking example that does this:

.r2d3 circle {
  fill: rgb(31, 119, 180);
  fill-opacity: .25;
  stroke: rgb(31, 119, 180);
  stroke-width: 1px;
}

.r2d3 .leaf circle {
  fill: #ff7f0e;
  fill-opacity: 1;
}

.r2d3 text {
  font: sans-serif;
  text-anchor: middle;
}

@javierluraschi Could we do this for all of the examples that use CSS then regenerate the site?

We should also add a note about this to the docs.

@jjallaire
Copy link
Member

I think we should address this issue before submitting to CRAN.

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

Successfully merging a pull request may close this issue.

3 participants