emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* capture htmlwidgets for export - a pattern in search of a new :results type???
@ 2015-07-28 19:29 Cook, Malcolm
  2015-07-28 21:34 ` Charles C. Berry
  0 siblings, 1 reply; 3+ messages in thread
From: Cook, Malcolm @ 2015-07-28 19:29 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

I have been playing with exporting htmlwidgets [1] generated in R code-blocks.

[1] http://www.htmlwidgets.org/  and

Here is a worked example that exports to html

	#+BEGIN_SRC R :session *R* :exports both :results html 
	library(htmlwidgets)
	library(d3heatmap)
	widget<-d3heatmap(mtcars, scale="column", colors="Blues")
	saveWidget(widget,'d3heatmap_widget.html')
	print('<iframe height=700px width=700px src=./d3heatmap_widget.html></iframe>')
	#+END_SRC
	#+RESULTS:
	#+BEGIN_HTML
	<iframe height=700px width=700px src=./d3heatmap_widget.html></iframe>
	#+END_HTML

After doing a few of these, a pattern emerges:  using ':results html' in the code bock header, and the last 2 lines of:
	saveWidget(...)
	print('<iframe ... ')

I think this pattern motivates considering developing support for "htmlwidget" as a new :results type (in addition to 'raw, org, html, latex, code, pp, drawer') 

It could be used in combination with :file and understood by the R/org "glue" and exporters.

Allowing to write, instead of the above, something like:

	#+BEGIN_SRC R :session *R* :exports both :file d3heatmap_widget.html :results htmlwidget :height 700 :width 700
	library(htmlwidgets)
	library(d3heatmap)
	d3heatmap(mtcars, scale="column", colors="Blues")
	#+END_SRC
	#+RESULTS:
	file: d3heatmap_widget.html

The org-to-R glue would have to behave somewhat similarly to how graphics are currently handled, however, instead of "printing" the value to the :file, the value would need to be saveWidget-ed.

And, similar to image handling, the exported value would be "in-lined" into the html, wrapped in an iframe (I presume).

Perhaps there is  a better or more useful abstraction.

Or a better workaround than simply following the pattern when needed (which is not too hard anyway).

Any ideas along these lines?

Thanks

Malcolm Cook
mec@stowers.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-29  0:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28 19:29 capture htmlwidgets for export - a pattern in search of a new :results type??? Cook, Malcolm
2015-07-28 21:34 ` Charles C. Berry
2015-07-29  0:08   ` Cook, Malcolm

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).