Moved dep graph to creature form, improved style

This commit is contained in:
Stefan Zermatten
2023-05-29 13:18:27 +02:00
parent 16d3ea9d53
commit b402fdf517
3 changed files with 66 additions and 37 deletions

View File

@@ -120,6 +120,18 @@
{{ libraryWriteError }} {{ libraryWriteError }}
</p> </p>
</form-section> </form-section>
<form-section name="Debug">
<v-btn
data-id="dependency-graph-button"
text
@click="showDependencyGraph"
>
<v-icon left>
mdi-graph
</v-icon>
Dependency Graph
</v-btn>
</form-section>
</form-sections> </form-sections>
</div> </div>
</template> </template>
@@ -267,6 +279,15 @@ export default {
this.dirty = true; this.dirty = true;
this.updateAllowedLibraryCollections(); this.updateAllowedLibraryCollections();
}, },
showDependencyGraph() {
this.$store.commit('pushDialogStack', {
component: 'dependency-graph-dialog',
elementId: 'dependency-graph-button',
data: {
creatureId: this.model._id,
},
});
},
}, },
}; };
</script> </script>

View File

@@ -55,13 +55,6 @@
</v-icon> Delete </v-icon> Delete
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item @click="showDependencyGraph">
<v-list-item-title>
<v-icon left>
mdi-graph
</v-icon> Dependency Graph
</v-list-item-title>
</v-list-item>
<v-list-item @click="showCharacterForm"> <v-list-item @click="showCharacterForm">
<v-list-item-title> <v-list-item-title>
<v-icon left> <v-icon left>
@@ -244,15 +237,6 @@ export default {
} }
}); });
}, },
showDependencyGraph() {
this.$store.commit('pushDialogStack', {
component: 'dependency-graph-dialog',
elementId: 'creature-menu',
data: {
creatureId: this.creatureId,
},
});
},
unshareWithMe() { unshareWithMe() {
updateUserSharePermissions.call({ updateUserSharePermissions.call({
docRef: { docRef: {

View File

@@ -60,15 +60,16 @@ export default {
// Convert ngraph to cytoscape // Convert ngraph to cytoscape
// Convert Nodes // Convert Nodes
const nodes = []; const nodes = [];
console.log(this.computation);
const loopNodes = getLoopNodes(this.computation); const loopNodes = getLoopNodes(this.computation);
this.computation.dependencyGraph.forEachNode(function (node) { this.computation.dependencyGraph.forEachNode(function (node) {
nodes.push({ nodes.push({
data: { data: {
id: node.id, id: node.id,
label: getNodeName(node) || node.id, label: getNodeName(node) || node.id,
variable: !node.data, variable: !node.data?.type,
inLoop: loopNodes.includes(node.id), inLoop: loopNodes.includes(node.id),
propId: node.data?._id,
prop: node.data,
}, },
}); });
}); });
@@ -80,9 +81,7 @@ export default {
target: link.fromId, target: link.fromId,
source: link.toId, source: link.toId,
linkType: link.data, linkType: link.data,
inLoop: loopNodes.includes(link.fromId) && loopNodes.includes(link.toId) inLoop: loopNodes.includes(link.fromId) && loopNodes.includes(link.toId),
},
scratch: {
}, },
}) })
//{ data: { source: 'n0', target: 'n1' } } //{ data: { source: 'n0', target: 'n1' } }
@@ -97,18 +96,23 @@ export default {
name: 'klay', name: 'klay',
nodeDimensionsIncludeLabels: false, nodeDimensionsIncludeLabels: false,
klay: { klay: {
// direction: 'RIGHT', addUnnecessaryBendpoints: false,
aspectRatio: 1.6,
direction: 'RIGHT',
edgeRouting: 'ORTHOGONAL', //'ORTHOGONAL', edgeRouting: 'ORTHOGONAL', //'ORTHOGONAL',
edgeSpacingFactor: 0.5,
feedbackEdges: true, feedbackEdges: true,
compactComponents: true, inLayerSpacingFactor: 1.0,
layoutHierarchy: true, layoutHierarchy: true,
mergeEdges: true, linearSegmentsDeflectionDampening: 0.3,
// mergeHierarchyCrossingEdges: true, compactComponents: true,
mergeEdges: false,
mergeHierarchyCrossingEdges: false,
nodeLayering: 'NETWORK_SIMPLEX',
nodePlacement: 'LINEAR_SEGMENTS', //default 'BRANDES_KOEPF' nodePlacement: 'LINEAR_SEGMENTS', //default 'BRANDES_KOEPF'
spacing: 20,//20, spacing: 20,//20,
edgeSpacingFactor: 2.0, //0.5,
thoroughness: 12,//7, thoroughness: 12,//7,
separateConnectedComponents: false, separateConnectedComponents: true,
}, },
}, },
@@ -117,37 +121,56 @@ export default {
selector: 'node', selector: 'node',
style: { style: {
'content': 'data(label)', 'content': 'data(label)',
//'text-opacity': 0.5, //'text-opacity': 0.8,
'text-valign': 'bottom', 'text-valign': 'center',
'text-halign': 'center', 'text-halign': 'center',
'background-color': '#11479e', 'background-color': '#303030',
'text-background-color': '#303030',
'color': '#fff',
//'text-outline-color': '#888', //'text-outline-color': '#888',
//'text-outline-width': 3, //'text-outline-width': 3,
'text-background-opacity': 1, 'text-background-opacity': 1,
'text-background-color': '#888',
'text-background-shape': 'roundrectangle', 'text-background-shape': 'roundrectangle',
'shape': 'round-rectangle' 'text-background-padding': 2,
'shape': 'round-rectangle',
'width': 80,
'height': 20,
'compound-sizing-wrt-labels': 'include',
'font-family': '"Roboto",sans-serif',
} }
}, { }, {
selector: ele => ele.data().variable, selector: ele => ele.data().variable,
style: {
'color': '#f44336',
'font-family': 'monospace',
}
}, {
selector: ele => !!ele.data().propId,
style: { style: {
'background-color': '#B71C1C', 'background-color': '#B71C1C',
'text-background-color': '#B71C1C',
} }
}, { }, {
selector: 'edge', selector: 'edge',
style: { style: {
'width': 4, 'width': 4,
'target-arrow-shape': 'triangle-backcurve', 'target-arrow-shape': 'triangle-backcurve',
'line-color': '#9dbaea', 'color': '#fff',
'target-arrow-color': '#9dbaea', 'text-opacity': 0.8,
'curve-style': 'unbundled-bezier', 'line-color': '#555',
'target-arrow-color': '#555',
'curve-style': 'unbundled-bezier',//'unbundled-bezier',
'label': 'data(linkType)', 'label': 'data(linkType)',
'text-rotation': 'autorotate', 'text-rotation': 'autorotate',
'source-endpoint': 'outside-to-line-or-label',
'target-endpoint': 'outside-to-line-or-label',
} }
}, { }, {
selector: ele => ele.data().inLoop, selector: ele => ele.data().inLoop,
style: { style: {
'color': '#fff',
'background-color': '#FF6D00', 'background-color': '#FF6D00',
'text-background-color': '#FF6D00',
'line-color': '#FF6D00', 'line-color': '#FF6D00',
'target-arrow-color': '#FF6D00', 'target-arrow-color': '#FF6D00',
} }
@@ -161,11 +184,11 @@ export default {
}); });
this.cytoscape.on('tap', 'node', function(evt){ this.cytoscape.on('tap', 'node', function(evt){
var node = evt.target; var node = evt.target;
console.log( 'tapped node', node.data() ); console.log( node.data() );
}); });
this.cytoscape.on('tap', 'edge', function(evt){ this.cytoscape.on('tap', 'edge', function(evt){
var edge = evt.target; var edge = evt.target;
console.log( 'tapped edge', edge ); console.log( edge.data() );
}); });
}, },
meteor: { meteor: {
@@ -182,6 +205,7 @@ export default {
.graph-container { .graph-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #151515;
} }
.graph-container svg { .graph-container svg {