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

rCharts, polyCharts #1

Open
gyansinha opened this issue Apr 20, 2013 · 4 comments
Open

rCharts, polyCharts #1

gyansinha opened this issue Apr 20, 2013 · 4 comments

Comments

@gyansinha
Copy link

Hi Ramnath:

You are doing great work in this area. Quick question for you - i installed the rCharts package and tried a test plot but 'printChart' sets up the server at port 8100 but the web browser is unable to display anything.

Do I need to install anything else, like the polyCharts library in addition to rCharts, or is it all self-contained and there's something else going on.

Thanks

@ramnathv
Copy link
Owner

Can you post a reproducible example of the chart you are trying to reproduce?

@gyansinha
Copy link
Author

Hi:

Here it is:

require(fImport)
require(rCharts)


fff.raw <- fredImport('BAMLH0A2HYB')
fff.df <- fff.raw@data
fff.df <- data.frame(obsdate=as.Date(rownames(fff.raw@data)),fff.raw@data)
p <- rPlot(BAMLH0A2HYB ~ obsdate, data=fff.df)
p$show()

I get " Listening on port 8100 .." and a redirect to the browser - but nothing displays.

My sessionInfo is below:

> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.0.0

@ramnathv
Copy link
Owner

You need to specify chart type. The following code works for me

p1 <- rPlot(BAMLH0A2HYB ~ obsdate, data=fff.df, type = 'line')
p1

For time series charts, I would recommend NVD3, which has a nice lineWithFocusChart. Date handling is a little tricky between R and JS, and we are working to make it easier. But for now, you will have to handle it on the JS side as shown here.

fff.df2 <- transform(fff.df, 
  obsdate = as.double(as.POSIXct(as.Date(obsdate, origin="1970-01-01")))*1000
)
n1 <- nPlot(BAMLH0A2HYB ~ obsdate, data=fff.df2, type = 'lineWithFocusChart')
n1$xAxis(tickFormat = "#! function(d){
  return d3.time.format('%x')(new Date(d))
}        
!#")
n1

You can also try out MorrisJS (mPlot), which provides a nice hover effect for dates. Dates have to be characters, so you need to do some transformation within R.

fff.df3 <- transform(fff.df, obsdate = as.character(obsdate))
m1 <- mPlot(x = 'obsdate', y = list('BAMLH0A2HYB'), data = fff.df3, type = 'Line')
m1$set(pointSize = 0)
m1

@ramnathv
Copy link
Owner

ramnathv commented May 7, 2013

Did you manage to check this?

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

2 participants