本文介绍了.gexf -format节点图可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了可视化节点图,看起来很棒。我尝试了一些例子,但无法显示我的图表。我使用了示例代码并尝试插入我的.gexf文件,但没有显示任何内容。这是我从中获取的内容:

To visualize a node graph Sigma.js looks fantastic. I tried some examples but can't get my graph to display. I used example code and tried to plug in my .gexf file, but nothing displays. This is what I took from the Sigma.js example :

function init() {
  // Instanciate sigma.js and customize rendering :
  var sigInst = sigma.init(document.getElementById('sigma-example')).drawingProperties({
    defaultLabelColor: '#fff',
    defaultLabelSize: 14,
    defaultLabelBGColor: '#fff',
    defaultLabelHoverColor: '#000',
    labelThreshold: 6,
    defaultEdgeType: 'curve'
  }).graphProperties({
    minNodeSize: 0.5,
    maxNodeSize: 5,
    minEdgeSize: 1,
    maxEdgeSize: 1
  }).mouseProperties({
    maxRatio: 32
  });

  // Parse a GEXF encoded file to fill the graph
  // (requires "sigma.parseGexf.js" to be included)
  sigInst.parseGexf('donornet.gexf');

  // Draw the graph :
  sigInst.draw();
}

if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", init, false);
} else {
  window.onload = init;
}

我将.gexf文件替换为我自己的donornet.gexf文件并保存作为donornet.js。然后我使用了这个中的代码(来自),我将其替换为我的donornet.js文件:

I replaced the .gexf file with my own donornet.gexf file and saved it as donornet.js. I then used code from this example (from Max De Marzi), which I replaced with my donornet.js file:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Donornet and Sigma.js Example</title>
    <script type="text/javascript" src="sigma.min.js"></script>
    <script type="text/javascript" src="sigma.parseGexf.js"></script>
    <script type="text/javascript" src="sigma.forceatlas2.js"></script>
    <link type="text/css" rel="stylesheet" href="neo_sigma.css"/>
  </head>
  <body>
    <h1>Donornet and Sigma.js Example</h1>
        <div class="buttons-container">
        <button class="btn" id="stop-layout">Stop Layout</button>
        <button class="btn" id="rescale-graph">Rescale Graph</button>
    </div>
        <div class="span12 sigma-parent" id="sigma-example-parent">
    <div class="sigma-expand" id="sigma-example"></div>
    </div>
    <script type="text/javascript" src="donornet.js"></script>
  </body>
</html>

所有文件都在同一个文件夹中。 parseGexf.js与donornet.js和donornet.gexf位于同一文件夹中。

All files are in the same folder. parseGexf.js is in the same folder as donornet.js and donornet.gexf.

推荐答案

您无需保存。 gexf文件为.js文件。只需将其保留为gexf文件并将其上载到脚本的文件夹中即可。删除< script src =donornet.js> 的行。尝试再次运行。如果它不起作用,也删除按钮div。查看的来源

You don't have to save .gexf file as a .js file. Just leave it as a gexf file and upload it into the script's folder. Remove the line with <script src="donornet.js">. Try to run again. If it doesn't work, also remove the buttons div. Check out the source on http://noduslabs.com/socialplayer/smmrussia/

这篇关于.gexf -format节点图可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 19:39