|
| 1 | +function getNeo4jCredentials() { |
| 2 | + return { |
| 3 | + serverUrl: "bolt://localhost:7687", |
| 4 | + serverUser: "neo4j", |
| 5 | + serverPassword: document.getElementById("neo4j-server-password").value, |
| 6 | + }; |
| 7 | +} |
| 8 | + |
| 9 | +function getConfiguration(credentials, visConfiguration, containerId = "visualizations") { |
| 10 | + return { |
| 11 | + containerId: containerId, |
| 12 | + neo4j: credentials, |
| 13 | + visConfig: visConfiguration, |
| 14 | + // Note: "defaultLabelConfig" is used instead of named label configs: { NameOfTheLabel: {...}, ...} |
| 15 | + // The reason for that is that neovis.js takes the first label that is returned by Neo4j. |
| 16 | + // If there are multiple Labels this is not stable to use. |
| 17 | + // Since we only expect one type of labels here (homogenous graph) we can simply use the default label config. |
| 18 | + // Reference: https://github.com/neo4j-contrib/neovis.js/blob/cef0aa16d647ffe0fd9ca457bcffa6e0cb7c55c8/src/neovis.ts#L524 |
| 19 | + defaultLabelConfig: { |
| 20 | + [NeoVis.NEOVIS_ADVANCED_CONFIG]: { |
| 21 | + function: { |
| 22 | + // Print all properties for the title (when nodes are clicked) |
| 23 | + title: NeoVis.objectToTitleHtml, |
| 24 | + // Use "fileName" as label. Remove leading slash, trailing ".jar", version number and a trailing word like "Final". |
| 25 | + label: (node) => |
| 26 | + node.properties.fileName |
| 27 | + .replace("/", "") |
| 28 | + .replace(".jar", "") |
| 29 | + .replace(/[\d\.\-\_v]+\w+$/gm, "") + |
| 30 | + "(" + |
| 31 | + node.properties.maxDistanceFromSource + |
| 32 | + ")", |
| 33 | + }, |
| 34 | + }, |
| 35 | + }, |
| 36 | + relationships: { |
| 37 | + DEPENDS_ON: { |
| 38 | + label: false, |
| 39 | + value: "weight", |
| 40 | + [NeoVis.NEOVIS_ADVANCED_CONFIG]: { |
| 41 | + function: { |
| 42 | + title: NeoVis.objectToTitleHtml, |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + initialCypher: |
| 48 | + "MATCH (artifact:Artifact)-[dependency:DEPENDS_ON*0..1]->(dependent:Artifact) WHERE artifact.topologicalSortIndex >= 0 AND dependent.topologicalSortIndex >= 0 AND artifact <> dependent RETURN artifact,dependency,dependent ORDER BY dependent.topologicalSortIndex, artifact.topologicalSortIndex SKIP toInteger($startIndex) LIMIT toInteger($blockSize)", |
| 49 | + }; |
| 50 | +} |
| 51 | + |
| 52 | +function draw() { |
| 53 | + const config = getConfiguration(getNeo4jCredentials(), hierarchicalHexagons()); |
| 54 | + paginatedGraphVisualization({ containerElementId: "visualizations", neoVizConfiguration: config }); |
| 55 | +} |
0 commit comments