Skip to content

Commit 99d64f1

Browse files
committed
[apperance] fix edge color when using node's color
Fix #190
1 parent f5cd542 commit 99d64f1

File tree

1 file changed

+7
-12
lines changed
  • packages/gephi-lite/src/core/appearance

1 file changed

+7
-12
lines changed

packages/gephi-lite/src/core/appearance/utils.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export function makeGetColor<
140140
T extends { itemType: "nodes"; displayData: NodeDisplayData } | { itemType: "edges"; displayData: EdgeDisplayData },
141141
>(
142142
itemType: T["itemType"],
143-
{ nodeData, edgeData, nodeRenderingData, fullGraph }: GraphDataset,
143+
{ nodeData, edgeData, fullGraph }: GraphDataset,
144144
{ dynamicNodeData, dynamicEdgeData }: DynamicItemData,
145145
{ nodesColor, edgesColor, nodesShadingColor, edgesShadingColor }: AppearanceState,
146146
getters?: VisualGetters,
@@ -194,20 +194,15 @@ export function makeGetColor<
194194
? (id?: string) => id && fullGraph.source(id)
195195
: (id?: string) => id && fullGraph.target(id);
196196

197-
if (getNodeColor && nodesColor.type !== "data")
197+
if (getNodeColor) {
198+
const nodesValues = mergeStaticDynamicData(nodeData, dynamicNodeData);
198199
getColor = (_, edgeId?: string) => {
199200
const node = nodeForColor(edgeId);
200-
return node ? getNodeColor(itemsValues[node]) : DEFAULT_NODE_COLOR;
201+
return node ? getNodeColor(nodesValues[node]) : DEFAULT_NODE_COLOR;
201202
};
202-
else if (nodesColor.type === "data")
203-
// special case when node are colored by data have to reach nodeRenderingData instead of normal getNodeColor
204-
getColor = (_, edgeId?: string) => {
205-
const node = nodeForColor(edgeId);
206-
return node && nodeRenderingData[node] && nodeRenderingData[node].color
207-
? nodeRenderingData[node].color || DEFAULT_NODE_COLOR
208-
: DEFAULT_NODE_COLOR;
209-
};
210-
else getColor = () => DEFAULT_EDGE_COLOR;
203+
} else {
204+
getColor = () => DEFAULT_EDGE_COLOR;
205+
}
211206
}
212207

213208
if (getColor && shadingDef) {

0 commit comments

Comments
 (0)