Closed Rokshan2016 closed 2 years ago
sigma.js requires the following information to draw the nodes:
id
x
y
and for the edges
id
source
target
Hence your JSON file needs to be in the following format
{"edges":[],
"nodes": [
{"size": 3,
"y": 60.0,
"x": 114.0,
"id": "a"
},
{"size": 3,
"y": 78.0,
"x": 127.0,
"id": "b"
},
{"size": 3,
"y": 91.0,
"x": 53.0,
"id": "c"
},
{"size": 3,
"y": 107.0,
"x": 108.0,
"id": "d"
}
{"size": 2,
"y": 120.0,
"x": 108.0,
"id": "e"
}],
"edges": [
{"size": 3,
"id": 0,
"source": "e",
"target": "c",
},
{"size": 3,
"id": 1,
"source": "a",
"target": "e",
},
{"size": 3,
"id": 2,
"source": "d",
"target": "a",
},
{"size": 3,
"id": 3,
"source": "b",
"target": "c",
},
{"size": 3,
"id": 4,
"source": "a",
"target": "b",
}]
}
Hi , Thanks for the reply . I am using Guava graph to which is creating the x, y automatically. But the graph is quiet not understandable. { "nodes": [ { "id": "faf193dc-7950-4994-990b-cc5b977631b7", "label": "Patientfaf193dc-7950-4994-990b-cc5b977631b7", "x": 148, "y": 81, "size": 3 }, { "id": "b38b2a1c-e464-47ed-9f37-736e2e75b377", "label": "Encounterb38b2a1c-e464-47ed-9f37-736e2e75b377", "x": 85, "y": 53, "size": 3 }, { "id": "81ac7bc9-4df1-4ca2-92e6-7f1aca4ee806", "label": "Observation81ac7bc9-4df1-4ca2-92e6-7f1aca4ee806", "x": 163, "y": 165, "size": 3 }, { "id": "45b21c31-b89d-41ec-b57c-e28c3319832c", "label": "Encounter45b21c31-b89d-41ec-b57c-e28c3319832c", "x": 182, "y": 197, "size": 3 }, { "id": "1e2faa60-caf2-4267-be8d-3b532801690a", "label": "Encounter1e2faa60-caf2-4267-be8d-3b532801690a", "x": 61, "y": 82, "size": 3 }, { "id": "73b3a93c-3281-4a2b-aff8-6d9b488dc86d", "label": "Observation73b3a93c-3281-4a2b-aff8-6d9b488dc86d", "x": 55, "y": 178, "size": 3 }, { "id": "cab8f15a-196e-46f2-b8ad-1399d7d195dd", "label": "Encountercab8f15a-196e-46f2-b8ad-1399d7d195dd", "x": 62, "y": 125, "size": 3 }, { "id": "dc13d7a5-f742-4909-80d7-540f7534aed4", "label": "Observationdc13d7a5-f742-4909-80d7-540f7534aed4", "x": 192, "y": 170, "size": 3 }, { "id": "c71a150e-05bc-41c6-8ed5-dee65b5224e5", "label": "Observationc71a150e-05bc-41c6-8ed5-dee65b5224e5", "x": 119, "y": 139, "size": 3 }, { "id": "1b245013-421d-4c55-a055-3d5340cd04b5", "label": "Observation1b245013-421d-4c55-a055-3d5340cd04b5", "x": 90, "y": 65, "size": 3 }, { "id": "4ef89164-0613-41e5-a00b-fba7d3619d4c", "label": "Encounter4ef89164-0613-41e5-a00b-fba7d3619d4c", "x": 162, "y": 165, "size": 3 }, { "id": "937820be-bef8-420e-bdb8-fef6edf76f90", "label": "Observation937820be-bef8-420e-bdb8-fef6edf76f90", "x": 91, "y": 138, "size": 3 }, { "id": "4a2ba8e0-5cb1-4271-9a8b-6cfd9fdf8306", "label": "Observation4a2ba8e0-5cb1-4271-9a8b-6cfd9fdf8306", "x": 36, "y": 144, "size": 3 }, { "id": "53ac247d-6488-4fe6-95f2-3df5d51e735c", "label": "Observation53ac247d-6488-4fe6-95f2-3df5d51e735c", "x": 49, "y": 81, "size": 3 }, { "id": "6e9369d3-8252-40b8-8ee2-ef3a9a4f1568", "label": "Observation6e9369d3-8252-40b8-8ee2-ef3a9a4f1568", "x": 18, "y": 173, "size": 3 }, { "id": "RES77591", "label": "ProcedureRES77591", "x": 188, "y": 57, "size": 3 }, { "id": "RES77585", "label": "ProcedureRES77585", "x": 92, "y": 100, "size": 3 }, { "id": "790feb1e-20f8-415d-8e68-7229a6fee7c4", "label": "Observation790feb1e-20f8-415d-8e68-7229a6fee7c4", "x": 1, "y": 125, "size": 3 }, { "id": "dd625a8b-b4d8-4f69-8106-32028a6d2950", "label": "Observationdd625a8b-b4d8-4f69-8106-32028a6d2950", "x": 15, "y": 63, "size": 3 }, { "id": "f1e6c08e-4227-471f-8c80-3341ac1ef525", "label": "Observationf1e6c08e-4227-471f-8c80-3341ac1ef525", "x": 80, "y": 109, "size": 3 }, { "id": "RES77581", "label": "ImmunizationRES77581", "x": 127, "y": 198, "size": 3 }, { "id": "RES77578", "label": "ImmunizationRES77578", "x": 55, "y": 159, "size": 3 }, { "id": "RES77593", "label": "ImmunizationRES77593", "x": 145, "y": 23, "size": 3 }, { "id": "RES77583", "label": "ImmunizationRES77583", "x": 7, "y": 135, "size": 3 }, { "id": "RES77596", "label": "ImmunizationRES77596", "x": 78, "y": 64, "size": 3 }, { "id": "RES77589", "label": "ImmunizationRES77589", "x": 76, "y": 133, "size": 3 }
Is there any way I can configure the x and y ?
What do you mean? I guess you want to apply a layout algorithm so you can see nodes position themselves in space so you can read the graph correctly. Is that it?
Yes. Actually if you see my previous json, i am putting X and Y values randomly. I want my graph should be like a proper tree structure. e.g
Actually I am getting like this
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi , I have a Json like this , it is basically bundle of resources like Patient, Observation , Encounter, I want to show the relationship in graph using sigma.js. But sigma json parser does not understand this, how can I create the nodes and edge , so it can understand
Appreciate any help!
{ "resourceType": "Bundle", "id": "8fb44fa0-84db-4f2c-910d-e997931b16a1", "meta": { "lastUpdated": "2018-07-06T11:05:30.151-04:00" }, "type": "searchset", "total": 42, "link": [ { "relation": "self", "url": "https://r3.smarthealthit.org/Patient/faf193dc-7950-4994-990b-cc5b977631b7/$everything?_format=json" } ], "entry": [ { "fullUrl": "https://r3.smarthealthit.org/Patient/faf193dc-7950-4994-990b-cc5b977631b7", "resource": { "resourceType": "Patient", "id": "faf193dc-7950-4994-990b-cc5b977631b7", "meta": { "versionId": "2", "lastUpdated": "2018-04-25T02:45:18.835-04:00", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-PersonOfRecord" ], "tag": [ { "system": "https://smarthealthit.org/tags", "code": "synthea-7-2017" } ] }, "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Generated by <a href=\"https://github.com/synthetichealth/synthea\">Synthea. Version identifier: 1a8d765a5375bf72f3b7a92001940d05a6f21189