diff --git a/src/components/GaphView.tsx b/src/components/GaphView.tsx index fba23e1..c9a3a9e 100644 --- a/src/components/GaphView.tsx +++ b/src/components/GaphView.tsx @@ -28,7 +28,8 @@ export const GraphViewComponent: React.FC = ({ }); const [searchLabel, setSearchLabel] = useState(''); const [highlightNode, setHighlightNode] = useState(null); - const [hoveredNode, setHoveredNode] = useState(null); // Define hoveredNode state + // const [hoveredNode, setHoveredNode] = useState(null); + const NODE_RADIUS = 4; const fgRef = useRef, LinkObject>>(); @@ -166,78 +167,83 @@ export const GraphViewComponent: React.FC = ({ const graphContainerRef = useRef(null); return ( -
-
- setSearchLabel(e.target.value)} - onKeyPress={handleKeyPress} - placeholder="Enter node label" - /> - -
-
- {data ? ( - setHoveredNode(node ? node : null)} // onNodeHover implementation - linkCurvature={0.15} - nodeCanvasObject={(node, ctx, globalScale) => { - const label = node.label; - const fontSize = 12 / globalScale; - ctx.font = `${fontSize}px Sans-Serif`; - ctx.fillStyle = 'black'; - ctx.textAlign = 'center'; - ctx.textBaseline = 'top'; - - const xCoord = node.x as number; - const yCoord = node.y as number; - ctx.fillText(label, xCoord, yCoord + 5); - - // Draw cross in the center of the canvas TODO: Remove this - const canvasWidth = - graphContainerRef.current?.clientWidth ?? ctx.canvas.width; - - const canvasHeight = - graphContainerRef.current?.clientHeight ?? ctx.canvas.height; - const crossSize = 10; - - // Vertical line of the cross - ctx.beginPath(); - ctx.moveTo(canvasWidth / 2, canvasHeight / 2 - crossSize); - ctx.lineTo(canvasWidth / 2, canvasHeight / 2 + crossSize); - ctx.strokeStyle = 'blue'; - ctx.lineWidth = 1.5; - ctx.stroke(); - - // Horizontal line of the cross - ctx.beginPath(); - ctx.moveTo(canvasWidth / 2 - crossSize, canvasHeight / 2); - ctx.lineTo(canvasWidth / 2 + crossSize, canvasHeight / 2); - ctx.strokeStyle = 'blue'; - ctx.lineWidth = 1.5; - ctx.stroke(); - - paintRing(node, ctx); - }} - nodeCanvasObjectMode={node => - highlightNode && node.id === highlightNode.id ? 'before' : 'after' - } - linkDirectionalArrowLength={3.5} - linkDirectionalArrowRelPos={1} + <> +
+
+ setSearchLabel(e.target.value)} + onKeyPress={handleKeyPress} + placeholder="Enter node label" /> - ) : ( -
Search for a term
- )} + +
+
+ {data ? ( + d.type} + // onNodeHover={node => setHoveredNode(node ? node : null)} + linkCurvature={0.15} + nodeCanvasObject={(node, ctx, globalScale) => { + const label = node.label; + const fontSize = 12 / globalScale; + ctx.font = `${fontSize}px Sans-Serif`; + ctx.fillStyle = 'black'; + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + + const xCoord = node.x as number; + const yCoord = node.y as number; + ctx.fillText(label, xCoord, yCoord + 5); + + // Draw cross in the center of the canvas TODO: Remove this + const canvasWidth = + graphContainerRef.current?.clientWidth ?? ctx.canvas.width; + + const canvasHeight = + graphContainerRef.current?.clientHeight ?? ctx.canvas.height; + const crossSize = 10; + + // Vertical line of the cross + ctx.beginPath(); + ctx.moveTo(canvasWidth / 2, canvasHeight / 2 - crossSize); + ctx.lineTo(canvasWidth / 2, canvasHeight / 2 + crossSize); + ctx.strokeStyle = 'blue'; + ctx.lineWidth = 1.5; + ctx.stroke(); + + // Horizontal line of the cross + ctx.beginPath(); + ctx.moveTo(canvasWidth / 2 - crossSize, canvasHeight / 2); + ctx.lineTo(canvasWidth / 2 + crossSize, canvasHeight / 2); + ctx.strokeStyle = 'blue'; + ctx.lineWidth = 1.5; + ctx.stroke(); + + paintRing(node, ctx); + }} + nodeCanvasObjectMode={node => + highlightNode && node.id === highlightNode.id + ? 'before' + : 'after' + } + linkDirectionalArrowLength={3.5} + linkDirectionalArrowRelPos={1} + /> + ) : ( +
Search for a term
+ )} +
- {hoveredNode && ( + {/* {hoveredNode && (
{hoveredNode.label}: {hoveredNode.description}
- )} -
+ )} */} + ); }; diff --git a/style/layout.css b/style/layout.css index bcc70fd..8ad0624 100644 --- a/style/layout.css +++ b/style/layout.css @@ -226,11 +226,11 @@ bottom: 10px; left: 10px !important; /* Position the infobox on the left */ right: auto; /* Ensure the right positioning is removed */ + pointer-events: none; background-color: white; padding: 10px; border: 1px solid blue; display: block; width: 200px; word-wrap: break-word; - z-index: 1000; /* Ensure it appears above other elements */ } \ No newline at end of file