簡體   English   中英

我需要推薦結構以使用 Cytoscape js

[英]I need recommendation for structure to use Cytoscape js

我們正在使用 Cytoscape + neo4j + spring 引導 + REST。 我們嘗試使用某些格式傳遞到前端,但效果不佳。 所以尋找最好的結構來使用 Cytoscape js。

======== 稍后添加。 例如,來自 neo4j apoc export json 查詢的響應如下:

{
      "application": {
        "type": "node",
        "id": "hhj354",
        "labels": [
          "Application"
        ],
        "properties": {
          "appid": "A90378",
          "name": "hkjgj",
          "status": "In Production"
        }
      },
      "changes": [
        {
          "node": {
            "type": "node",
            "id": "fdsf324",
            "labels": [
              "Change"
            ],
            "properties": {
              "type": "gjhk",
              "startdate": "2019-11-21 02:11:32"
            }
          },
          "group": "2019-11",
          "relation": sfd
        },
        {
          "node": {
            "type": "node",
            "id": "fdsf324",
            "labels": [
              "Change"
            ],
            "properties": {
              "type": "gjhk",
              "startdate": "2019-11-21 02:11:32"
            }
          },
          "group": "2019-11",
          "relation": sfd
        },
        {
          "node": {
            "type": "node",
            "id": "fdsf324",
            "labels": [
              "Change"
            ],
            "properties": {
              "type": "gjhk",
              "startdate": "2019-11-21 02:11:32"
            }
          },
          "group": "2019-11",
          "relation": 453
        }
      ]
    }

我需要一些詳細的解析代碼。 只要足夠短,后端或前端的解析都可以。

提前致謝。

就我而言,前端應該盡可能少地進行計算。 因此,嘗試發送 JSON 盡可能接近cytoscape.js規范中指定的格式

圖的基本思想是它由節點組成,這些元素(如cytoscape所稱)具有可以幫助您以更簡單的方式 select 的 ID。

后端無需計算

如果你想使用內置 format.json from CALL apoc.export.json.all("all.json",{useTypes:true})那么你將不得不在前端進行一些轉換:

responseJson => {
    responseJson.map(element => {
        return {
        group: element.type,
        data : {
            id: `${element.type}${element.id}`,
            myFavouriteProperty: element.property
        }
    }
}

暫無
暫無

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

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