Refactor graph label handling to extract labels directly from graph data

- Remove redundant label caching logic
- Add graphLabels state to graph store
This commit is contained in:
yangdx
2025-03-12 07:15:54 +08:00
parent dad36e948f
commit b9e22ef64d
3 changed files with 27 additions and 30 deletions

View File

@@ -205,6 +205,21 @@ const useLightrangeGraph = () => {
state.setSigmaGraph(createSigmaGraph(data))
data?.buildDynamicMap()
state.setRawGraph(data)
// Extract labels from graph data
if (data) {
const labelSet = new Set<string>(['*'])
for (const node of data.nodes) {
if (node.labels && Array.isArray(node.labels)) {
for (const label of node.labels) {
labelSet.add(label)
}
}
}
state.setGraphLabels(Array.from(labelSet).sort())
} else {
state.setGraphLabels(['*'])
}
})
}
} else {