Skip to content

Commit 8cab8a6

Browse files
committed
Changed to get height working in notebook cell. May not be mimimal. Untested in larger app, might break stuff.
1 parent 88829c4 commit 8cab8a6

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/components/convo-explorer/D3Map.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ export const D3Map: React.FC<D3MapProps> = ({
112112
// State to trigger re-calculation of radius on resize
113113
const [resizeCounter, forceUpdate] = React.useReducer(x => x + 1, 0);
114114

115+
const wrapperRef = React.useRef<HTMLDivElement>(null);
116+
const [containerSize, setContainerSize] = React.useState({ width: "100%", height: 400 });
117+
118+
// Measure size once mounted
119+
React.useEffect(() => {
120+
if (!wrapperRef.current) return;
121+
const rect = wrapperRef.current.getBoundingClientRect();
122+
setContainerSize({ width: rect.width, height: rect.height });
123+
}, []);
124+
115125
// Initialize selectedPipeline when pipeline options become available
116126
React.useEffect(() => {
117127
if (currentPipelineOptions.length > 0 && !selectedPipeline) {
@@ -302,8 +312,8 @@ export const D3Map: React.FC<D3MapProps> = ({
302312
});
303313
}
304314

305-
const width = window.innerWidth;
306-
const height = window.innerHeight;
315+
const width = containerSize.width;
316+
const height = containerSize.height;
307317
const margin = 20;
308318

309319
const dataWidth = xExtent[1] - xExtent[0];
@@ -341,7 +351,7 @@ export const D3Map: React.FC<D3MapProps> = ({
341351
React.useEffect(() => {
342352
if (!svgRef.current) return;
343353
const svg = d3.select(svgRef.current);
344-
svg.attr("width", window.innerWidth).attr("height", window.innerHeight);
354+
svg.attr("width", containerSize.width).attr("height", containerSize.height);
345355

346356
if (!containerRef.current) {
347357
containerRef.current = svg.append("g");
@@ -737,7 +747,7 @@ export const D3Map: React.FC<D3MapProps> = ({
737747
}
738748

739749
return (
740-
<div className="relative w-screen h-screen">
750+
<div ref={wrapperRef} style={{ width: "100%", height: 400, position: "relative" }}>
741751
<svg ref={svgRef} className="w-screen h-screen block bg-gray-100" />
742752

743753
{/* Pipeline Selector - unified for both Kedro and static projections */}

0 commit comments

Comments
 (0)