Skip to content

Commit 59abfa2

Browse files
committed
Refactor Java artifact dependencies visualization
1 parent a4598e3 commit 59abfa2

File tree

4 files changed

+64
-50
lines changed

4 files changed

+64
-50
lines changed

graph-visualization/artifactDependenciesGraph/artifactDependenciesGraph.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

graph-visualization/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ div {
33
height: 100vh;
44
}
55

6+
div.vis-tooltip {
7+
font-size: 4px;
8+
overflow-y: auto;
9+
}
10+
611
.indexedVisualization {
712
margin-top: 10px;
813
margin-left: 10px;

graph-visualization/artifactDependenciesGraph/artifactDependenciesGraph.html renamed to graph-visualization/java-artifact-dependencies/graphVisualizationJavaArtifactDependencies.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88

9-
<title>Graph Visualization with neovis.js</title>
9+
<title>Java Artifact Dependencies Graph Visualization with neovis.js</title>
1010

11-
<link rel="stylesheet" href="./../index.css">
1211
<script src="./../node_modules/neovis.js/dist/neovis.js"></script>
1312
<script type="text/javascript" src="./../vis-configuration-presets.js"></script>
1413
<script type="text/javascript" src="./../visualization-pagination.js"></script>
15-
<script type="text/javascript" src="artifactDependenciesGraph.js"></script>
14+
<script type="text/javascript" src="graphVisualizationJavaArtifactDependencies.js"></script>
15+
16+
<link rel="stylesheet" href="./../index.css">
1617
</head>
1718

1819
<body">
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)