Set chart area background color in rCharts/slidify/nvd3
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>
Render rCharts in slides from Slidify
All instructions below assume that you have the dev
branch of the packages installed (slidify, slidifyLibraries and rCharts). You can accomplish this using install_github
.
pkgs <- c("slidify", "slidifyLibraries", "rCharts")
devtools::install_github(pkgs, "ramnathv", ref = "dev")
There are two ways to include an rCharts
viz in your slidify document, and the deck below illustrates both ways. If you print a plot in a code chunk, as you would do so in the R console, slidify automatically detects that you are running it in a knitr session and as a result save the resulting html to an iframe and embed it in the deck. Alternately, you can specify the chart inline, in which case you have to use n1$show("inline")
and also include ext_widgets: {rCharts: libraries/nvd3}
in your YAML front matter.
The iframe method is the default and the recommended method to avoid conflicts between various javascript files and css. The inline method does work well for several rCharts libraries, but make sure to check before you use.
---
title : rCharts Integration
ext_widgets : {rCharts: libraries/nvd3}
mode: selfcontained
---
## NVD3 Plot Inline
```{r nvd3plot, results = 'asis', comment = NA, message = F, echo = F}
require(rCharts)
n1 <- nPlot(mpg ~ wt, data = mtcars, type = 'scatterChart')
n1$show('inline')
```
---
## NVD3 Plot Iframe
```{r nvd3plot2, results = 'asis', comment = NA, message = F, echo = F}
require(rCharts)
n1 <- nPlot(mpg ~ wt, data = mtcars, type = 'scatterChart')
n1
```
R. doing cool plot, no X labels
To get the labels like "Jan/15" you need to pass the dates through strptime
to get them into time since epoch and then through strftime
to get them formatted accordingly. No need to multiply the dates by 1000 etc.
For your case, let me know if the following works out. You can read more about the formatting of dates by doing ?strptime
and ?strftime
in R
REPL.
x$dmy = strftime(strptime(x$YYYYMM, format = "%m/%d/%Y"), format = "%b/%y")
myplot <- hPlot(COUNT ~ dmy, data=x, type="line")
myplot
Not sure how to change the background color in rcharts
Related Topics
Why Does Changing a CSS Class Name Break The Styles
Command-Line Argument as Var in Sass, for Hardcoded Cdn Url's on Compile
Angular Materials Won't Apply Styles to Components
How to Achieve This Visual Using CSS
P Tags Appearing Lower in Firefox Than in Internet Explorer, Using CSS
How to Animate an Ellipsis with CSS Animations
HTML Formatted Email Not Showing Up at All in Gmail But Is in Other Mail Clients
<Hr> Inside Container with Display Flex Become Corrupted
CSS Footer Position Stick to Bottom of Browser
Succinct Way of Specifying Two or More Values for an Attribute in CSS Selector
@Font-Face Does Not Work Properly for Italic/Bold Fonts
Apply a Class and an Attribute Selector
Extension Content Script (Js/Or CSS) Is Not Applying
CSS Can't Seem to Set Height to 100% of Parent Container
Using CSS How to Change Only The 2Nd Column of a Table
Browser Developer Tools: What Is The Position of The HTML Element