Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit d7ba315

Browse files
fix(forcedirected.js): size of the graph computed from props
fix #7246
1 parent e83c0da commit d7ba315

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/superset-ui-legacy-plugin-chart-force-directed/src/ForceDirected.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ const propTypes = {
3737

3838
/* Modified from http://bl.ocks.org/d3noob/5141278 */
3939
function ForceDirected(element, props) {
40-
const { data, width, height, linkLength = 200, charge = -500 } = props;
40+
const { data, linkLength = 200, charge = -500 } = props;
41+
let { width, height } = props;
4142

42-
let w = window.innerWidth;
43-
let h = window.innerHeight;
4443
const minZoom = 0.1;
4544
const maxZoom = 7;
4645
const div = d3.select(element);
@@ -123,12 +122,12 @@ function ForceDirected(element, props) {
123122

124123
force
125124
.size([
126-
force.size()[0] + (innerWidth - w) / zoom.scale(),
127-
force.size()[1] + (innerHeight - h) / zoom.scale(),
125+
force.size()[0] + (innerWidth - width) / zoom.scale(),
126+
force.size()[1] + (innerHeight - height) / zoom.scale(),
128127
])
129128
.resume();
130-
w = innerWidth;
131-
h = innerHeight;
129+
width = innerWidth;
130+
height = innerHeight;
132131
}
133132

134133
// build the arrow.

0 commit comments

Comments
 (0)