簡體   English   中英

Sigma.js學習和示例

[英]Sigma.js learning and examples

我想發現sigma.js,因此可以在項目中使用它。 我已經知道了d3的一些知識,但是通過在Internet上搜索,人們提到sigma對於圖更好,例如,在圖數據庫中,sigma可能更好。 但是我進行了搜索,但是找不到關於sigma或任何教程的大量文檔。 甚至jacomy網站上的示例都不存在。 有人可以建議我從哪里開始以學習sigma.js嗎?

我在該項目的GitHub上找到了一些教程:

https://github.com/jacomyal/sigma.js/tree/master/examples

同樣在此網站中:

http://thewhyaxis.info/hairball/

這是官方頁面:

http://sigmajs.org/


例如,從官方教程頁面上可以看到,下面是一個簡單的示例:

對於數據

{
  "nodes": [
    {
      "id": "n0",
      "label": "A node",
      "x": 0,
      "y": 0,
      "size": 3
    },
    {
      "id": "n1",
      "label": "Another node",
      "x": 3,
      "y": 1,
      "size": 2
    },
    {
      "id": "n2",
      "label": "And a last one",
      "x": 1,
      "y": 3,
      "size": 1
    }
  ],
  "edges": [
    {
      "id": "e0",
      "source": "n0",
      "target": "n1"
    },
    {
      "id": "e1",
      "source": "n1",
      "target": "n2"
    },
    {
      "id": "e2",
      "source": "n2",
      "target": "n0"
    }
  ]
}

對於html

  <!DOCTYPE HTML>
    <html>
    <head>
    <style type="text/css">
      #container {
        max-width: 400px;
        height: 400px;
        margin: auto;
      }
    </style>
    </head>
    <body>
    <div id="container"></div>
    <script src="sigma.min.js"></script>
    <script src="sigma.parsers.json.min.js"></script>
    <script>
      sigma.parsers.json('data.json', {
        container: 'container',
        settings: {
          defaultNodeColor: '#ec5148'
        }
      });
    </script>
    </body>
    </html>

這將導致:

在此處輸入圖片說明

這是一個非常簡單的示例: Github示例

sigma.js github存儲庫的Wiki也非常詳細: Sigma.js – Wiki

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM