mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(sankey): incorrect nodeValues (#33431)
Co-authored-by: richardfn <richard.fogaca@appsilon.com>
This commit is contained in:
committed by
GitHub
parent
8013b32f0e
commit
38868f9ff4
@@ -73,13 +73,25 @@ export default function transformProps(
|
||||
}));
|
||||
|
||||
// stores a map with the total values for each node considering the links
|
||||
const nodeValues = new Map<string, number>();
|
||||
const incomingFlows = new Map<string, number>();
|
||||
const outgoingFlows = new Map<string, number>();
|
||||
const allNodeNames = new Set<string>();
|
||||
|
||||
links.forEach(link => {
|
||||
const { source, target, value } = link;
|
||||
const sourceValue = nodeValues.get(source) || 0;
|
||||
const targetValue = nodeValues.get(target) || 0;
|
||||
nodeValues.set(source, sourceValue + value);
|
||||
nodeValues.set(target, targetValue + value);
|
||||
allNodeNames.add(source);
|
||||
allNodeNames.add(target);
|
||||
incomingFlows.set(target, (incomingFlows.get(target) || 0) + value);
|
||||
outgoingFlows.set(source, (outgoingFlows.get(source) || 0) + value);
|
||||
});
|
||||
|
||||
const nodeValues = new Map<string, number>();
|
||||
|
||||
allNodeNames.forEach(nodeName => {
|
||||
const totalIncoming = incomingFlows.get(nodeName) || 0;
|
||||
const totalOutgoing = outgoingFlows.get(nodeName) || 0;
|
||||
|
||||
nodeValues.set(nodeName, Math.max(totalIncoming, totalOutgoing));
|
||||
});
|
||||
|
||||
const tooltipFormatter = (params: CallbackDataParams) => {
|
||||
|
||||
Reference in New Issue
Block a user