visNetwork 中的完整画布图

问题描述

我正在 Power BI 中制作自定义视觉对象,为此我使用了 visNetwork。但是,我无法在整个画布中绘制结果。看看这里发生了什么:

plot result

这是我的代码

source('./r_files/flatten_HTML.r')

############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly");
libraryRequireInstall("visNetwork");
libraryRequireInstall("igraph")
####################################################

################### Actual code ####################
p <- Values

dados_gerais = read.csv("mypath.csv",header = TRUE,sep = ',',encoding = 'UTF-8')
nomes = unique(Values$source)
dados_filTrados = dados_gerais[dados_gerais$target %in% nomes,]

id = c(unique(Values$source),unique(Values$target),unique(dados_filTrados$source))
id = sort(id,decreasing = FALSE)
id = unique(id)
name_label = id
node_to = c(Values$target,dados_filTrados$target)
node_from = c(Values$source,dados_filTrados$source)

nodes = data.frame(id = id,title = paste0(name_label))
edges = data.frame(from = node_from,to = node_to,value = c(Values$edge_weight,dados_filTrados$edge_weight),arrows = rep("to",length(node_to)))

dados_peso = dados_gerais[dados_gerais$source %in% id,]
dados_peso = unique(dados_peso[c("source","source_weight")])
attach(dados_peso)
dados_peso = dados_peso[order(source),]
detach(dados_peso)


vis.nodes <- nodes
vis.nodes$size <- dados_peso$source_weight
vis.edges <- edges
vis.edges$color <- list(color = '#2B2B2B')

p <- visNetwork(vis.nodes,vis.edges,background = "#191B1D")%>%
  visIgraphLayout()%>%
  visOptions()
####################################################

############# Create and save widget ###############
internalSaveWidget(p,'out.html');
####################################################

我已经检查了宽度、高度、调整大小等参数。另外,我在文档中找不到任何相关内容

我不认为这是 Power BI 的问题,因为我在 R Studio 的绘图窗口中也得到了这个白边。此外,我在 Power BI(使用 Plotly)中制作了另一个自定义视觉效果效果很好。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)