Merge "Add unselect node in Entity Graph"
This commit is contained in:
@@ -49,6 +49,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$on('unselectNode', function(event) {
|
||||||
|
_this.selectedItem = undefined;
|
||||||
|
_this.model.selected = {};
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.$on('graphItemClicked', function (event, data) {
|
$scope.$on('graphItemClicked', function (event, data) {
|
||||||
data.timezone = timezone;
|
data.timezone = timezone;
|
||||||
data.dateFormat = dateFormat;
|
data.dateFormat = dateFormat;
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ function hzEntitiesGraph() {
|
|||||||
node,
|
node,
|
||||||
link,
|
link,
|
||||||
linksMap,
|
linksMap,
|
||||||
content;
|
content,
|
||||||
|
mouseDownX,
|
||||||
|
mouseDownY;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var p = $('.panel.panel-primary');
|
var p = $('.panel.panel-primary');
|
||||||
@@ -65,8 +67,6 @@ function hzEntitiesGraph() {
|
|||||||
.filter(function(d, i){ return this.classList.contains("node"); })
|
.filter(function(d, i){ return this.classList.contains("node"); })
|
||||||
.selectAll("circle");
|
.selectAll("circle");
|
||||||
|
|
||||||
//console.log('all nodes: ', allNodes.length);
|
|
||||||
|
|
||||||
allNodes
|
allNodes
|
||||||
.transition()
|
.transition()
|
||||||
.duration(200)
|
.duration(200)
|
||||||
@@ -133,6 +133,20 @@ function hzEntitiesGraph() {
|
|||||||
|
|
||||||
svg.call(zoom);
|
svg.call(zoom);
|
||||||
|
|
||||||
|
svg.on('mousedown', function() {
|
||||||
|
mouseDownX = d3.event.clientX;
|
||||||
|
mouseDownY = d3.event.clientY;
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.on('mouseup', function() {
|
||||||
|
var x = d3.event.clientX,
|
||||||
|
y = d3.event.clientY;
|
||||||
|
if (x === mouseDownX && y === mouseDownY) {
|
||||||
|
// means click rather than drag
|
||||||
|
svgClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var svg_g = svg.append('g')
|
var svg_g = svg.append('g')
|
||||||
.attr('width', '100%')
|
.attr('width', '100%')
|
||||||
.attr('height', '100%')
|
.attr('height', '100%')
|
||||||
@@ -534,6 +548,40 @@ function hzEntitiesGraph() {
|
|||||||
force.start();
|
force.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setAllNodesHighlight() {
|
||||||
|
svg_g.selectAll('.node')
|
||||||
|
.classed('selected', function(d) {
|
||||||
|
return d.high;
|
||||||
|
})
|
||||||
|
.select('circle')
|
||||||
|
.style('stroke-width', function(d) {
|
||||||
|
return d.high ? (Math.max(d.highDepth + 1, 1) * 2) : null;
|
||||||
|
})
|
||||||
|
|
||||||
|
svg_g.selectAll('.link').classed('selected', function(d) {
|
||||||
|
return d.source.high && d.target.high;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function svgClick() {
|
||||||
|
scope.selected = undefined;
|
||||||
|
svg_g.selectAll('.node')
|
||||||
|
.classed('selected', false);
|
||||||
|
|
||||||
|
_.each(scope.data.nodes, function(node) {
|
||||||
|
node.high = false;
|
||||||
|
node.highDepth = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
_.each(scope.data.links, function(link) {
|
||||||
|
link.high = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
setAllNodesHighlight();
|
||||||
|
|
||||||
|
scope.$emit('unselectNode');
|
||||||
|
}
|
||||||
|
|
||||||
function nodeClick(d) {
|
function nodeClick(d) {
|
||||||
scope.selected = d;
|
scope.selected = d;
|
||||||
//scope.itemSelected(scope.selected);
|
//scope.itemSelected(scope.selected);
|
||||||
@@ -568,18 +616,7 @@ function hzEntitiesGraph() {
|
|||||||
link.high = false;
|
link.high = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
svg_g.selectAll('.node')
|
setAllNodesHighlight();
|
||||||
.classed('selected', function(d) {
|
|
||||||
return d.high;
|
|
||||||
})
|
|
||||||
.select('circle')
|
|
||||||
.style('stroke-width', function(d) {
|
|
||||||
return d.high ? (Math.max(d.highDepth + 1, 1) * 2) : null;
|
|
||||||
})
|
|
||||||
|
|
||||||
svg_g.selectAll('.link').classed('selected', function(d) {
|
|
||||||
return d.source.high && d.target.high;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNone(d) {
|
function selectNone(d) {
|
||||||
|
|||||||
Reference in New Issue
Block a user