【问题标题】:Why is the layout of a graph from visnetwork in html too small为什么html中visnetwork的图形布局太小
【发布时间】:2018-05-09 09:36:02
【问题描述】:

当我渲染下面的 example-Rmd 时,它看起来像这样(使用 Chrome,与 Firefox 没有真正的区别):

这个图太小了,如果我看我需要的“真实”图,高度太小,高宽比更差。

这是一个可重现的示例

---
title: "Untitled"
author: "author"
date: "9 Mai 2018"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Example

Here is a line of text...................................................................................................................................................................................................................................................................

```{r echo=FALSE}
require(visNetwork, quietly = TRUE)
# minimal example
nodes <- data.frame(id = 1:20)
edges <- data.frame(from = sample(c(1:20), 10), to = sample(c(1:20), 10))
visNetwork(nodes, edges, width = "100%", height = "100%") %>%
                               visNodes() %>%
                               visOptions(highlightNearest = TRUE) %>%
                               visInteraction(navigationButtons = TRUE, 
                                              dragNodes = FALSE,
                                              dragView = FALSE, zoomView = FALSE) %>%
                               visEdges(arrows = 'to')
```

Here is another line of text....................................................................................................................................................................................................................................................................

【问题讨论】:

    标签: html r r-markdown visnetwork


    【解决方案1】:

    我希望使用一些块选项来修复它,例如 out.heightfig.height,但由于某种原因他们没有。

    但是,您可以为小部件本身设置一个固定高度,只需将一个数字传递给将被解释为像素的 height 参数:

    ```{r echo=FALSE}
    require(visNetwork, quietly = TRUE)
    # minimal example
    nodes <- data.frame(id = 1:20)
    edges <- data.frame(from = sample(c(1:20), 10), to = sample(c(1:20), 10))
    visNetwork(nodes, edges, width = "100%", height = 700) %>%
                                   visNodes() %>%
                                   visOptions(highlightNearest = TRUE) %>%
                                   visInteraction(navigationButtons = TRUE, 
                                                  dragNodes = FALSE,
                                                  dragView = FALSE, zoomView = FALSE) %>%
                                   visEdges(arrows = 'to')
    ```
    

    【讨论】:

    • 酷!我搜索了一年,但找不到任何东西! :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 2016-08-21
    • 1970-01-01
    相关资源
    最近更新 更多