chore(react): reintroduce force configuration

This commit is contained in:
Elian Doran 2025-10-04 13:58:29 +03:00
parent 656b234740
commit 5efe05490d
No known key found for this signature in database
2 changed files with 9 additions and 8 deletions

View file

@ -62,10 +62,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
this.graph = new ForceGraph(this.$container[0])
// Rendering code was here
const nodeLinkRatio = data.nodes.length / data.links.length;
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
const charge = -20 / magnifiedRatio;
const boundedCharge = Math.min(-3, charge);
let distancevalue = 40; // default value for the link force of the nodes
this.$widget.find(".fixnodes-type-switcher input").on("change", async (e) => {
@ -75,10 +71,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
this.renderData(data);
});
this.graph.d3Force("center")?.strength(0.2);
this.graph.d3Force("charge")?.strength(boundedCharge);
this.graph.d3Force("charge")?.distanceMax(1000);
this.renderData(data);
}

View file

@ -176,6 +176,15 @@ export function setupRendering(graph: ForceGraph, { note, noteId, themeStyle, wi
.linkCanvasObjectMode(() => "after");
}
// Forces
const nodeLinkRatio = notesAndRelations.nodes.length / notesAndRelations.links.length;
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
const charge = -20 / magnifiedRatio;
const boundedCharge = Math.min(-3, charge);
graph.d3Force("center")?.strength(0.2);
graph.d3Force("charge")?.strength(boundedCharge);
graph.d3Force("charge")?.distanceMax(1000);
// Zoom to notes
if (widgetMode === "ribbon" && note?.type !== "search") {
setTimeout(() => {