Set chart area background color in rCharts/slidify/nvd3

久未见 提交于 2020-01-11 11:45:30

问题


For the following slidify deck,

---
title       : Foo
framework   : revealjs        # {io2012, html5slides, shower, dzslides, ...}
revealjs    : {theme: solarized}
highlighter : highlight.js  # {highlight.js, prettify, highlight}
hitheme     : tomorrow      # 
widgets     : []            # {mathjax, quiz, bootstrap}
mode        : selfcontained # {standalone, draft}
ext_widgets : [libraries/nvd3]
---
## NVD3 Plot Iframe
```{r nvd3plot2, results = 'asis', comment = NA, message = F, echo = F} 
require(rCharts)
n1 <- nPlot(mpg ~ wt, data = mtcars, type = 'scatterChart')
n1
```

I want to set the background color of the chart to white.

I can do this if I knit it and then edit the <style> block in the generated figure/nvd3plot2.html to add background-color: white;:

<style>
.rChart {
  display: block;
  margin-left: auto; 
  margin-right: auto;
  width: 800px;
  height: 400px;
  background-color: white;
}  
</style>

How do I do this from the .Rmd file?


回答1:


As indicated in my comment, a quick fix to get a white background is to add the following lines to your Rmd file

<style>iframe{background-color: white}</style>


来源:https://stackoverflow.com/questions/21081469/set-chart-area-background-color-in-rcharts-slidify-nvd3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!