#49 feat: reemplazar cytoscape por vis-network con semantica de certeza en graficos de provenance

This commit is contained in:
2026-08-16 01:41:27 -05:00
parent 58b42d956b
commit 2967ea4f4d
18 changed files with 732 additions and 593 deletions

View File

@@ -0,0 +1,45 @@
/**
* Adapta el modelo de grafo de provenance ({ id, kind, label, image, entity }
* y { from, to, certain }) al formato de vis-network, incluyendo la semántica
* de certeza: arista cierta = sólida, arista dudosa = discontinua.
*/
const COLORS = {
product: '#26a69a',
supplier: '#42a5f5',
organization: '#ffb74d',
municipality: '#66bb6a',
department: '#5c6bc0',
country: '#ab47bc',
junction: '#78909c',
}
export function toVisNodes (nodes) {
return nodes.map(node => {
const color = COLORS[node.kind] || '#cfd8dc'
const { image, ...rest } = node
if (node.kind === 'junction') {
return { ...rest, shape: 'dot', color, size: 10, label: '' }
}
if (image) {
return { ...rest, image, shape: 'circularImage', borderWidth: 2 }
}
return { ...rest, shape: 'dot', color, borderWidth: 2 }
})
}
export function toVisEdges (edges) {
return edges.map(edge => ({
from: edge.from,
to: edge.to,
dashes: !edge.certain,
}))
}
export const chartOptions = {
nodes: { font: { size: 13, color: '#263238' } },
edges: { color: { color: '#546e7a' } },
physics: {
barnesHut: { gravitationalConstant: -4000, springLength: 120, springConstant: 0.02 },
},
}