Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

Insert R visNetwork HTML from RMarkdown into SharePoint?

I used RMarkdown to create an HTML file that contains an interactive visNetwork chart. When I open the .HTML file into Chrome, I have the expected chart interactivity (node selection, mouseover, drag..). However, when I upload the .HTML file into a company-internal SharePoint site, the visNetwork chart is not displayed.

Is there a way to insert this HTML into a SharePoint template page that is part of the site while maintaining chart interactivty? PDF or MS-Word format is not desirable and porting it over to RShiny is also not practical at this time.

We are not permitted to link from SharePoint to an external file (for example, I cannot load the file onto GitHub pages or other external site and provide a URL on the SharePoint page) due to confidential content. I can't even link to a non-SharePoint server on the company network - the content must be part of the SharePoint site itself. Ideally I want to upload the file without modification because this chart and ones similar to it will be updated on a regular basis.

Here is example .Rmd that can be knit to HTML.

---
title: "Test visNetwork Embed"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(visNetwork)
```
# Description
A simple visNetwork rendered to HTML from .Rmd file

```{r visnetwork, echo=FALSE}
nodes <- data.frame(id = c("A", "B", "C", "D" ))
edges <- data.frame(from = c("A", "A", "C", "D" ),
                    to   = c("B", "C", "D", "" ))

visNetwork(nodes, edges) %>%
  visOptions(
    highlightNearest = list( enabled = TRUE, 
                             hover   = TRUE),
    nodesIdSelection = TRUE ) 

```

Cheers!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Proposed solution - tested in same tenant as Tim:

  • Rename the extension HTML into ASPX
  • Upload the file in the SharePoint document library (or in the Pages library with SharePoint Designer)
  • Click on the file & check rendering is working as expected
  • Copy the URL to the file
  • Create a new page with a page viewer web part & use the URL to the doc copied previously as source

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.7k users

...