Using plotly.js within Labkey | Will Holtz | 2016-01-30 08:50 | |||||||||||||||||||||||||||||||||
Status: Closed | |||||||||||||||||||||||||||||||||||
I've been trying to use plotly.js within Labkey with the hope of generating interactive plots. I thought the easiest route to achieving this would be to create an R report with Labkey that contains a knitr document and then in that knitr document, use the R plotly library to generate the interactive plots. Finally, I'd like to use Rserve to make all this run faster, but that is an aside at this point. My reasoning for going through R, rather than directly using the plotly javascript library, was not wanting to have to transform the data coming from Labkey into the format required by plotly.js. Additionally, using the plotly R library means that I can create my plots using ggplot2 (which I am already well versed in) and then automatically convert them to plotly plots (via ggplotly). I also could have skipped the knitr step, and directly used the plotly R library within an R view, but it isn't clear to me how to get the plotly R library to output javascript/HTML that Labkey could display. I'm guessing this is possible -- it just wasn't clear to me. So, using the Lakbey>R report>knitr>plotly approach yields a document that contains "<!–html_preserve–>" tags flanking where the plot should be. Between the html_preserve tags is a bunch of json containing the data for the plot, but I don't see the javascript for the actual plot generation. Some Googling has revealed that knitr is generating the html_preserve tags and it has something to do with escaping other HTML tags. This thread https://github.com/rstudio/rmarkdown/issues/326 indicates that this HTML escaping behavior can be modified by passing options to md_extentions in knitr. I tried including the YAML header with md_extensions options in my Rmd file that generates my R report, but it appears that Labkey does not process the header as such. I spent a few minutes looking at the Labkey R report generation java code and couldn't find exactly how knitr is getting called. Has anyone else gotten interactive plots with plotly.js working within Labkey? It would be a big win for the Labkey community to be able to easily leverage all the power of plotly. Any thoughts or pointers are appreciated. thanks, -Will |
|||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||