#49 feat: graficos de provenance en columnas por nivel y aristas deduplicadas

This commit is contained in:
2026-08-16 02:21:41 -05:00
parent 2967ea4f4d
commit 5c91e66429
6 changed files with 166 additions and 25 deletions

View File

@@ -14,17 +14,49 @@ const COLORS = {
junction: '#78909c',
}
const PRODUCT_SPACING = 110
const COLUMN_X = {
product: -240,
junction: -120,
supplier: 0,
organization: 240,
municipality: 240,
department: 480,
}
export function toVisNodes (nodes) {
const products = nodes.filter(node => node.kind === 'product')
const productY = new Map()
products.forEach((node, index) => {
productY.set(node.entity.id, (index - (products.length - 1) / 2) * PRODUCT_SPACING)
})
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: '' }
return {
...rest,
shape: 'dot',
color,
size: 10,
label: '',
x: COLUMN_X.junction,
y: productY.get(node.entity.id),
fixed: { x: true, y: true },
}
}
if (image) {
return { ...rest, image, shape: 'circularImage', borderWidth: 2 }
const base = image
? { ...rest, image, shape: 'circularImage', borderWidth: 2 }
: { ...rest, shape: 'dot', color, borderWidth: 2 }
if (node.kind === 'product') {
return {
...base,
x: COLUMN_X.product,
y: productY.get(node.entity.id),
fixed: { x: true, y: true },
}
}
return { ...rest, shape: 'dot', color, borderWidth: 2 }
return { ...base, x: COLUMN_X[node.kind], fixed: { x: true, y: false } }
})
}