2

当我使用时,visLayout(hierarchical = TRUE)我得到以下图片,我认为这是错误的:

在此处输入图像描述

随着visLayout(hierarchical = FALSE)我得到(正确的)图片:

在此处输入图像描述

这是一个错误还是我错过了什么?可重现的例子:

nodes <- structure(list(id = 1:4, label = c("node1", "node2", "node3", "node4"),
                        value = c(0.3, 0.3, 0.3, 0.3),
                        title = c("node1", "node2", "node3", "node4")),
                   .Names = c("id", "label", "value", "title"),
                   row.names = c(NA, -4L),
                   class = "data.frame")

edges <- structure(list(from = 1:4,
                        to = c(2L, 3L, 4L, 1L),
                        arrows = c("to", "to", "to", "to")),
                   .Names = c("from", "to", "arrows"),
                   row.names = c(NA, -4L),
                   class = "data.frame")

visNetwork(nodes, edges, height = "100%", width = "100%") %>%
  visOptions(highlightNearest = TRUE) %>%
  visLayout(hierarchical = TRUE) %>%
  visInteraction(navigationButtons = TRUE)

visNetwork(nodes, edges, height = "100%", width = "100%") %>%
  visOptions(highlightNearest = TRUE) %>%
  visInteraction(navigationButtons = TRUE)
4

1 回答 1

1

我认为这是一个布局问题:
从节点 4 到 1 的边缘绘制在节点下方。因此,节点 1 和节点 2 之间似乎有一个双向箭头..

这就是为什么在圆形布局中一切都如您所愿。

于 2018-01-10T04:37:09.860 回答