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

Debugging: Rstudio D3 Preview with Full R Code #81

Open
ChrisWoodsSays opened this issue Jun 14, 2020 · 1 comment
Open

Debugging: Rstudio D3 Preview with Full R Code #81

ChrisWoodsSays opened this issue Jun 14, 2020 · 1 comment

Comments

@ChrisWoodsSays
Copy link

ChrisWoodsSays commented Jun 14, 2020

I have some D3 code running from R (which creates and then provides the data to D3 using the data parameter) via R2D3 and its mostly working, but I need to use the browser console to understand what is happening with certain variables within the D3 element.

I can see the instructions below which show how to preview the D3 code from within Rstudio and a browser but the data passed is very simple, i.e.

// !preview r2d3 data=c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20)

https://rstudio.github.io/r2d3/articles/development_and_debugging.html

How do I run a more full R script to collate the data and import libraries (that are then referred to in dependencies) and then use R2D3 in such a way that I can use the browser debugger in a way similar to how the very simple example does.

@jlfsjunior
Copy link

I think that this package is no longer maintained, so you might not get an official reply from the development team.

I believe what you are asking is related to the usage of r2d3::r2d3 function, described here. r2d3 does some default data transformation from R to js, which is described in the documentation. I don't use the preview version, but I imagined it just something the "RStudio D3 preview add-on" uses to invoke the function I am pointing out.

As of using the browser developer tools for debugging, I recommend you to redefine console in javascript in order to log it there instead of using r2d3 default (that displays it in the browser window instead). This can be done (if el is your container element, svg or div) via:

var console = d3.window(el.node()).console;

Hope that can help!

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