Skip to content

Commit d539b7f

Browse files
klmp200imperosol
authored andcommitted
poc: improve galaxy rendering
1 parent 67bdbfd commit d539b7f

1 file changed

Lines changed: 32 additions & 12 deletions

File tree

galaxy/static/bundled/galaxy/galaxy-index.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,17 @@ exportToHtml("loadGalaxy", async (config: GalaxyConfig) => {
7373
width: 0.1,
7474
},
7575
},
76+
{
77+
selector: ".direct",
78+
style: {
79+
width: "5px",
80+
"line-color": "red",
81+
},
82+
},
7683
],
7784
layout: {
7885
name: "d3-force",
79-
animate: false,
86+
animate: true,
8087
fit: false,
8188
ungrabifyWhileSimulating: true,
8289
fixedAfterDragging: true,
@@ -93,24 +100,37 @@ exportToHtml("loadGalaxy", async (config: GalaxyConfig) => {
93100
return 1 / Math.max(1, link?.value);
94101
},
95102

103+
linkIterations: 10,
104+
96105
manyBodyStrength: (node) => {
97106
return node?.mass;
98107
},
99108

100-
stop: () => {
109+
// manyBodyDistanceMin: 500,
110+
collideRadius: () => {
111+
return 50;
112+
},
113+
114+
ready: (e) => {
115+
// Center on current user node at the start of the simulation
116+
// Color all direct paths from that citizen to it's neighbor
117+
const citizen = e.cy.nodes(`#${config.nodeId}`)[0];
118+
citizen.addClass("focused");
119+
citizen.connectedEdges().addClass("direct");
120+
e.cy.center(citizen);
121+
},
122+
123+
tick: () => {
124+
// Center on current user node during simulation
125+
const citizen = cy.nodes(`#${config.nodeId}`)[0];
126+
cy.center(citizen);
127+
},
128+
129+
stop: (e) => {
101130
// Disable user grabbing of nodes
102131
// This has to be disabled after the simulation is done
103132
// Otherwise the simulation can't move nodes
104-
cy.autolock(true);
105-
106-
// Center on current user node
107-
for (const node of cy.nodes()) {
108-
if (node.id() === `${config.nodeId}`) {
109-
node.addClass("focused");
110-
cy.center(node);
111-
break;
112-
}
113-
}
133+
e.cy.autolock(true);
114134
},
115135
} as D3ForceLayoutOptions,
116136
});

0 commit comments

Comments
 (0)