Skip to content

Commit dcdcf71

Browse files
committed
cosmo working
1 parent 57a3ced commit dcdcf71

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

web-app/src/components/RegistryMetaKG.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
import axios from 'axios';
7070
7171
import EntityPill from './EntityPill.vue';
72-
import SimpleNetwork from './SimpleNetworkSigma.vue';
72+
import SimpleNetwork from './SimpleNetworkCosmoGraph.vue';
7373
7474
export default {
7575
name: 'RegistryMetaKG',
@@ -130,24 +130,24 @@ export default {
130130
nodes.add(hit.object);
131131
nodes.add(hit.subject);
132132
edges.push({
133-
group: 'edges',
134-
data: {
133+
// group: 'edges',
134+
// data: {
135135
id: Math.floor(100000 + Math.random() * 900000),
136136
source: hit.subject,
137137
target: hit.object,
138-
}
138+
// }
139139
});
140140
});
141141
142142
nodeData = [...nodes].map((node) => {
143143
return {
144-
group: 'nodes',
145-
data: {
144+
// group: 'nodes',
145+
// data: {
146146
weight: nodeWeight[node] + 100,
147147
id: node,
148-
name: node[0],
148+
// name: node[0],
149149
color: self.$store.getters.getEntityColor(node)
150-
}
150+
// }
151151
};
152152
});
153153
this.networkData = {
Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<template>
2-
<canvas class="metakg-cosmo" :id="'sn' + badgeID"/>
2+
<div :id="'cosmo' + badgeID" class="cosmo">
3+
4+
</div>
35
</template>
46

57
<script>
@@ -21,33 +23,36 @@ export default {
2123
},
2224
methods: {
2325
drawSigma(){
24-
console.log('Cosmo')
25-
26-
const nodes = [
27-
{ id: '1', color: '#88C6FF' },
28-
{ id: '2', color: '#FF99D2' },
29-
{ id: '3', color: [227,17,108, 1] }, // Faster than providing a hex value
30-
]
31-
32-
const links = [
33-
{ source: '1', target: '2' },
34-
{ source: '1', target: '3' },
35-
{ source: '2', target: '3' },
36-
]
37-
const canvas = document.createElement('canvas')
38-
document.body.appendChild(canvas)
26+
let cosmograph = null;
27+
const canvas = document.getElementById('cosmo' + this.badgeID)
3928
const config = {
40-
nodeColor: d => d.color,
41-
nodeSize: 20,
29+
nodeColor: n => n.color,
30+
nodeSize: (n, i) => n.weight/50 < 10 ? 10 : n.weight/50,
4231
linkWidth: 2,
32+
onClick: (n) =>{
33+
if (cosmograph && n?.id) {
34+
cosmograph.selectNode({id: n.id}, true)
35+
}else{
36+
cosmograph?.unselectNodes();
37+
}
38+
},
39+
curvedLinks: true,
40+
initialZoomLevel: 3,
41+
disableSimulation: true,
42+
hoveredNodeLabelColor: 'white',
43+
showDynamicLabels: false,
44+
scaleNodesOnZoom: false,
45+
linkWidth: .5,
46+
linkArrowsSizeScale: 1,
47+
linkVisibilityDistance: [400, 1000]
48+
4349
}
4450
4551
// Create a Cosmograph instance with the canvas element
46-
const cosmograph = new Cosmograph(canvas, config)
52+
cosmograph = new Cosmograph(canvas, config)
4753
4854
// Set the data
49-
cosmograph.setData(nodes, links)
50-
console.log(cosmograph)
55+
cosmograph.setData(this.nodes, this.edges)
5156
}
5257
},
5358
mounted: function () {
@@ -57,10 +62,9 @@ const links = [
5762
</script>
5863
5964
<style scoped>
60-
61-
.metakg-cosmo {
65+
.cosmo {
6266
width: 300px;
6367
height: 300px;
64-
border: solid yellow 2px;
68+
border: solid rgb(42, 42, 42) 2px;
6569
}
6670
</style>

0 commit comments

Comments
 (0)