diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js
index 2d7115819..0a4714c76 100644
--- a/client/app/scripts/charts/nodes-chart.js
+++ b/client/app/scripts/charts/nodes-chart.js
@@ -19,9 +19,9 @@ const MARGINS = {
bottom: 0
};
-// make sure circular layouts lots of nodes spread out
-const radiusDensity = d3.scale.sqrt()
- .domain([12, 2]).range([3, 4]).clamp(true);
+// make sure circular layouts a bit denser with 3-6 nodes
+const radiusDensity = d3.scale.threshold()
+ .domain([3, 6]).range([2.5, 3.5, 3]);
const NodesChart = React.createClass({
@@ -30,10 +30,11 @@ const NodesChart = React.createClass({
nodes: {},
edges: {},
nodeScale: d3.scale.linear(),
- translate: [0, 0],
+ shiftTranslate: [0, 0],
panTranslate: [0, 0],
scale: 1,
hasZoomed: false,
+ autoShifted: false,
maxNodesExceeded: false
};
},
@@ -48,8 +49,7 @@ const NodesChart = React.createClass({
.scaleExtent([0.1, 2])
.on('zoom', this.zoomed);
- d3.select('.canvas')
- .on('click', this.handleBackgroundClick)
+ d3.select('.nodes-chart svg')
.call(this.zoom);
},
@@ -60,6 +60,7 @@ const NodesChart = React.createClass({
// wipe node states when showing different topology
if (nextProps.topologyId !== this.props.topologyId) {
_.assign(state, {
+ autoShifted: false,
nodes: {},
edges: {}
});
@@ -72,7 +73,7 @@ const NodesChart = React.createClass({
_.assign(state, this.restoreLayout(state));
}
if (nextProps.selectedNodeId) {
- this.centerSelectedNode(nextProps, state);
+ _.assign(state, this.centerSelectedNode(nextProps, state));
}
this.setState(state);
@@ -81,8 +82,7 @@ const NodesChart = React.createClass({
componentWillUnmount: function() {
// undoing .call(zoom)
- d3.select('.canvas')
- .on('click', null)
+ d3.select('.nodes-chart svg')
.on('mousedown.zoom', null)
.on('onwheel', null)
.on('onmousewheel', null)
@@ -90,18 +90,6 @@ const NodesChart = React.createClass({
.on('touchstart.zoom', null);
},
- getTopologyFingerprint: function(topology) {
- const fingerprint = [];
-
- _.each(topology, function(node) {
- fingerprint.push(node.id);
- if (node.adjacency) {
- fingerprint.push(node.adjacency.join(','));
- }
- });
- return fingerprint.join(';');
- },
-
renderGraphNodes: function(nodes, scale) {
const hasSelectedNode = this.props.selectedNodeId && this.props.nodes.has(this.props.selectedNodeId);
const adjacency = hasSelectedNode ? AppStore.getAdjacentNodes(this.props.selectedNodeId) : null;
@@ -170,7 +158,7 @@ const NodesChart = React.createClass({
// only animate shift behavior, not panning
const panTranslate = this.state.panTranslate;
- const shiftTranslate = this.state.translate;
+ const shiftTranslate = this.state.shiftTranslate;
let translate = panTranslate;
let wasShifted = false;
if (shiftTranslate[0] !== panTranslate[0] || shiftTranslate[1] !== panTranslate[1]) {
@@ -186,7 +174,7 @@ const NodesChart = React.createClass({
Too many nodes to show in the browser.
We're working on it, but for now, try a different view?
-