fix: Force-Graph zeigt nichts — Edges sind Index-basiert, nicht ID-basiert
Backend liefert edges als {a: 0, b: 1, sim: ...} mit Indizes in der
nodes-Liste. d3.forceLink mappt per id-Lookup und fand 'drucksache' als
Lookup-Key nicht. Folge: keine Links, Force-Sim degeneriert ohne Layout.
Fix: Index-Strings als id verwenden.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d72a6f30df
commit
60db39d5b3
@ -285,15 +285,21 @@ function renderClusterGraph(cl) {
|
||||
return map[f] || '#888';
|
||||
};
|
||||
|
||||
const nodes = rawNodes.map(n => ({
|
||||
id: n.drucksache,
|
||||
// Edges sind Index-basiert (a/b sind Positionen in rawNodes).
|
||||
// d3.forceLink mappt per id-Lookup → wir nutzen den Index als id-String.
|
||||
const nodes = rawNodes.map((n, i) => ({
|
||||
id: String(i),
|
||||
drucksache: n.drucksache,
|
||||
title: n.title || n.titel || n.drucksache,
|
||||
bundesland: n.bundesland || '',
|
||||
fraktion: (n.fraktionen && n.fraktionen[0]) || '',
|
||||
score: n.gwoe_score != null ? parseFloat(n.gwoe_score) : 5,
|
||||
}));
|
||||
const links = rawEdges.map(e => ({ source: e.a, target: e.b, sim: e.sim || 0.5 }));
|
||||
const links = rawEdges.map(e => ({
|
||||
source: String(e.a),
|
||||
target: String(e.b),
|
||||
sim: e.sim || 0.5,
|
||||
}));
|
||||
|
||||
const svg = d3.select(container).append('svg')
|
||||
.attr('width', width).attr('height', height)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user