【问题标题】:.gexf -format node graph visualization.gexf - 格式节点图可视化
【发布时间】:2012-06-05 02:13:11
【问题描述】:

可视化节点图Sigma.js 看起来很棒。我尝试了一些示例,但无法显示我的图表。我使用示例代码并尝试插入我的 .gexf 文件,但没有显示任何内容。这是我从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;
}

我用自己的donornet.gexf 文件替换了.gexf 文件,并将其保存为donornet.js。然后我使用了来自example(来自Max De Marzi)的代码,我用我的donornet.js 文件替换了它:

<!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 位于同一文件夹中。

【问题讨论】:

    标签: javascript sigma.js


    【解决方案1】:

    您不必将 .gexf 文件另存为 .js 文件。只需将其保留为 gexf 文件并将其上传到脚本的文件夹即可。删除带有&lt;script src="donornet.js"&gt; 的行。尝试再次运行。如果它不起作用,还删除按钮 div。查看http://noduslabs.com/socialplayer/smmrussia/上的源代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-15
      • 2014-09-27
      • 2018-12-07
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 2014-03-30
      • 2015-06-06
      相关资源
      最近更新 更多