rstudio / r2d3

R Interface to D3 Visualizations
https://rstudio.github.io/r2d3
Other
517 stars 103 forks source link

REPL for D3 / JavaSript? #32

Open vnijs opened 6 years ago

vnijs commented 6 years ago

r2d3 looks really interesting. I'm curious if Rstudio is perhaps planning a REPL for javascript, similar to the REPL for python in reticulate?

jjallaire commented 6 years ago

I believe that the V8 package has an embedded JS REPL: https://cran.r-project.org/web/packages/V8/index.html

One question I'd have is what you'd expect the REPL to do (i.e. would it need to interact with JS running in the Viewer pane, etc.). I've found that for D3 the snippets of code required to accomplishing things might not fit that well in a REPL (i.e. might require a few lines of code so be better off in a script editor or notebook cell).

vnijs commented 6 years ago

I hadn't thought about V8. I will take a closer look but at first glance it seems that you would have to write R-code with JS strings or source a JS file.

I guess I would like to be able to write and test JS interactively the way we can with R and Python in Rstudio. You can of course open a browser console and type there but that is a lot less convenient than having code in an editor and using CMD+return to execute one or more lines of code. Being able to send (with CMD-return) JS code to the console in the Rstudio Viewer or an Rstudio Window would already be very convenient I think.

Perhaps something like the ijavascript kernel in jupyter with an option to "send" to a Viewer, Window, or Browser console

vnijs commented 6 years ago

So similar to this sublime text addin ... but then in Rstudio: https://github.com/acarabott/chromeREPL

nstrayer commented 5 years ago

For this what I like to do is add a debugger statement to my script near the end of the current progress and then fiddle in the browser's javascript source pane directly. Chrome and Co have done a ton of work making the dev-tools work well so you get a similar write-then-run by writing the code inline with the source. Another thing to look at would be to dump your source data to a json or csv file and then hop over to an observable notebook to build code then dump back into your script.

screen shot 2019-02-07 at 11 17 43 am

Hopefully that's of some help!