Open-EO / openeo-r-client

R client package for working with openEO backends

Home Page:https://open-eo.github.io/openeo-r-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide Vue Components in R markdown and Jupyter

flahn opened this issue · comments

Title Provide Vue Components in R markdown and Jupyter
Date 2021-11-11
Issue #91
Category Visualisation, Reporting
Description Interactive Vue Components based on java srcipt are available in openEO. They allow interactive rendering of process graphs, collections, process descriptions, etc. They are already integrated in the python client. The integration into the R-Client unifiese the user experience accross the clients (python, webeditor, R) by reusing the same visualization tools. It is favourable to have the widgets working in RStudio Viewer, Rmarkdown and when running R in Jupyter Notebooks.
Dependencies Vue Components (https://github.com/Open-EO/openeo-vue-components), RStudio, Rmarkdown, Jupyter
Links Visualization of COGs
Priority High
Impact High

I've checked some docs and there seem to be different options for Jupyter and RMarkdown:

  1. jupyter: https://irkernel.github.io/docs/repr/0.9/ which is using repr_html as in Python
  2. jupyter: https://github.com/IRkernel/IRkernel where you can use IRdisplay::display_html
        if (getOption('jupyter.in_kernel')) {
          IRdisplay::display_html('<hr><p>Test!</p><hr>')
        }
  3. rmarkdown: Use hmltools, knitr::knit_print or so

To be clarified: Does one method work for all environments?

Here's some code from experiments that seems to work for jupyter and rstudio notebooks, but doesn't show anything in knitr:

        html_output = paste('<p>Connected to <a href="',private$host,'" target="_blank">',private$host,'</a></p><p><small>TODO... (env: ~env~)</small></p>', sep = '')
        if (isTRUE(getOption('jupyter.in_kernel'))) {
          IRdisplay::display_html(sub('~env~', 'jupyter', html_output))
        }
        else if (isTRUE(getOption('rstudio.notebook.executing'))) {
          print(htmltools::HTML(sub('~env~', 'rstudio', html_output)))
        }
        else if (isTRUE(getOption('knitr.in.progress')) && knitr::is_html_output() == TRUE) {
          knitr::asis_output(htmltools::HTML(sub('~env~', 'knitr', html_output))) # doesn't work 
        }
        else {
          cat("Connected to service: ",private$host,"\n")
          cat("Please check the terms of service (terms_of_service()) and the privacy policy (privacy_policy()). By further usage of this service, you acknowledge and agree to those terms and policies.\n")

          if (!hostInfo[hostInfo$url == private$host,]$production) {
            message("Warning: Connected host is not production-ready. Unexpected errors might occur.")
          }
        }

Jupyter:
image

RStudio NB:
image

I will provide a fix in a minute in a separate PR towards your ui-component branch. Maybe have a look at #110. When we are not setting an id for the UDP manually, then nothing is printed.