Skip to content

Commit 11679de

Browse files
committed
fix: cannot read getBoundingClientRect of undefined
fixes chrisbateman#15
1 parent a7860db commit 11679de

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/shared/createVisualization.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ export default function createVisualization({svgElement, root, onHover, onUnhove
6565

6666

6767
var svgWrapper = vis[0][0];
68+
6869
var visHeight = svgWrapper.getBoundingClientRect().height;
6970

70-
var topPadding = (svgWrapper.getBoundingClientRect().top + window.scrollY) - (svgWrapper.offsetParent.getBoundingClientRect().top + window.scrollY);
71+
var topPadding = (svgWrapper.getBoundingClientRect().top + window.scrollY) - (d3.select('.chart')[0][0].getBoundingClientRect().top + window.scrollY);
7172

7273
d3.select(svgElement).attr('height', visHeight);
7374
vis.attr('transform', `translate(${chartSize / 2}, ${(chartSize / 2) - topPadding})`);

0 commit comments

Comments
 (0)