ramnathv/rCharts — pull request #351 by timelyportfolio (2014-02-12 15:57:31+00:00)
Title: adds y2Axis for nvd3 ; issue #349

```
## {title: Line with Focus Chart }
ecm <- reshape2::melt(economics[,c('date', 'uempmed', 'psavert')], id = 'date')
p7 <- nPlot(value ~ date, group = 'variable', data = ecm, type = 'lineWithFocusChart')
#test format dates on the xAxis
#also good test of javascript functions as parameters
#dates from R to JSON will come over as number of days since 1970-01-01
#so convert to milliseconds 86400000 in a day and then format with d3
#on lineWithFocusChart type xAxis will also set x2Axis unless it is specified
p7$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Date( d * 86400000 ));}!#" )
#test xAxis also sets x2Axis
p7
#now test setting x2Axis to something different
#test format dates on the x2Axis
#test to show %Y format which is different than xAxis
p7$x2Axis( tickFormat="#!function(d) {return d3.time.format('%Y')(new Date( d * 86400000 ));}!#" )
p7
#test set xAxis again to make sure it does not override set x2Axis
p7$xAxis( NULL, replace = T)
p7

#now do the same to demo y2Axis formatting
#like x2Axis above
p7$yAxis( tickFormat="#!function(d) {return d3.format(',.2%')(d / 100);}!#" )
p7
#set y2Axis to override the copied yAxis
p7$y2Axis( tickFormat="#!function(d) {return d3.format('.3f')(d / 100);}!#" )
p7
#test set yAxis again to make sure it does not override set y2Axis
p7$yAxis( NULL, replace = T)
p7
```