Skip to content

Commit 3b61529

Browse files
committed
change label color with background color
1 parent d6f4196 commit 3b61529

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/Graph.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Graph: React.FC<GraphProps> = ({ graphData, width, height }) => {
2121
const [switchOn, setSwitchOn] = useState<boolean>(false);
2222

2323
const fgRef = useRef<any>(null);
24+
const labelColor = switchOn ? "#000000" : "#ffffff"; // Black on white background, white on dark
2425

2526
const handleClick = useCallback(
2627
(node: NodeObject) => {
@@ -96,8 +97,8 @@ const Graph: React.FC<GraphProps> = ({ graphData, width, height }) => {
9697
graphData={graphData}
9798
width={graphWidth}
9899
height={graphHeight}
99-
nodeLabel={(node: NodeObject) => `${node.label || node.id}`}
100-
linkLabel={(d: LinkObject) => `${d.label}`}
100+
nodeLabel={(node: NodeObject) => `<span style="color: ${labelColor}">${node.label || node.id}</span>`}
101+
linkLabel={(d: LinkObject) => `<span style="color: ${labelColor}">${d.label}</span>`}
101102
linkDirectionalArrowLength={7}
102103
linkDirectionalArrowRelPos={1}
103104
linkCurvature={0.3}

0 commit comments

Comments
 (0)