Commit 102d63eb authored by Maxime Chazalviel's avatar Maxime Chazalviel

update zoom buttons position

parent 404e39e4
......@@ -1178,7 +1178,7 @@ metExploreD3.GraphNetwork = {
}, 200);
},
rescale : function(panel){
rescale : function(panel, func){
var mask = metExploreD3.createLoadMask("Rescaling graph", panel);
metExploreD3.showMask(mask);
......@@ -1271,6 +1271,7 @@ metExploreD3.GraphNetwork = {
scaleViz.setZoomScale(scale);
metExploreD3.hideMask(mask);
if (func) func();
}), scale);
});
},
......
......@@ -1071,74 +1071,23 @@ metExploreD3.GraphNode = {
metExploreD3.displayMessage("Warning", 'The node "' + selectedVal + '" doesn\'t exist.')
}
else {
metExploreD3.GraphNetwork.rescale("viz", function(){
var scaleViz = metExploreD3.getScaleById("viz");
var zoom = scaleViz.getZoom();
var scaleViz = metExploreD3.getScaleById("viz");
var zoom = scaleViz.getZoom();
d3.select("#viz").select("#D3viz").select("#graphComponent")
.transition()
.duration(750)
.attr("transform", "translate(0,0)scale(1)")
.each(function () {
zoom.translateBy( d3.select("#viz").select("#D3viz"),0 ,0);
zoom.scaleBy(d3.select("#viz").select("#D3viz"),1);
scaleViz.setZoomScale(1);
var maxX = -100000;
var maxY = -100000;
var minX = 100000;
var minY = 100000;
selected.each(
function (aSelectedNode) {
if (maxX < aSelectedNode.x)
maxX = aSelectedNode.x;
if (maxY < aSelectedNode.y)
maxY = aSelectedNode.y;
if (minX > aSelectedNode.x)
minX = aSelectedNode.x;
if (minY > aSelectedNode.y)
minY = aSelectedNode.y;
});
var dx = maxX - minX,
dy = maxY - minY;
var rectPanel = d3.select("#viz").select("#D3viz").node().getBoundingClientRect();
var width = parseInt(metExploreD3.GraphPanel.getWidth("viz").replace("px", ""));
var height = parseInt(metExploreD3.GraphPanel.getHeight("viz").replace("px", ""));
// var scale = 1;
var scale = (Math.min(height / dy, width / dx)) * 0.7;
var transX = scale * (rectPanel.left - minX);
var transY = scale * (rectPanel.top - minY);
d3.select("#viz").select("#D3viz").select("#graphComponent")
.transition()
.duration(750)
.attr("transform", "translate(" + transX + "," + transY + ")scale(" + scale + ")")
.each(function () {
metExploreD3.GraphLink.tick("viz", scale);
metExploreD3.GraphNode.tick("viz");
metExploreD3.hideMask(mask);
});
zoom.translateBy( d3.select("#viz").select("#D3viz"),transX ,transY);
zoom.scaleBy(d3.select("#viz").select("#D3viz"), scale);
scaleViz.setZoomScale(scale);
d3.select("#viz").select("#D3viz").select("#graphComponent")
.transition()
.duration(750)
.attr("transform", "translate(0,0)scale(1)")
.each(function () {
selected.each(
function (aSelectedNode) {
_MyThisGraphNode.highlightANode(aSelectedNode, 'viz');
selected.each(
function (aSelectedNode) {
_MyThisGraphNode.highlightANode(aSelectedNode, 'viz');
});
});
metExploreD3.hideMask(mask);
});
});
});
}
},
......
......@@ -88,6 +88,8 @@ metExploreD3.GraphPanel = {
// Redefine Zoom and brush
var h = parseInt(metExploreD3.GraphPanel.getHeight(panel));
var w = parseInt(metExploreD3.GraphPanel.getWidth(panel));
var scaleZ = scale.getZoomScale();
metExploreD3.GraphNetwork.zoomListener
.scaleExtent([ 0.01, 30 ])
......@@ -97,7 +99,7 @@ metExploreD3.GraphPanel = {
var transform = d3.zoomTransform(d3.select("#viz").select("#D3viz").node());
scale.getZoom().scaleTo(d3.select("#"+panel).select("#D3viz"), scaleZ);
scale.getZoom().translateTo(d3.select("#"+panel).select("#D3viz"), transform.x/2, transform.y/2);
scale.getZoom().translateTo(d3.select("#"+panel).select("#D3viz"), transform.x, transform.y);
scale.setScale(scaleZ, 1, metExploreD3.GraphNetwork.zoomListener);
......@@ -129,10 +131,11 @@ metExploreD3.GraphPanel = {
var h = $("#"+panel).height();
var w = $("#"+panel).width();
console.log(d3.select("#"+panel).select("#D3viz").select("#buttonZoomIn"));
if(d3.select("#"+panel).select("#D3viz").select("#buttonZoomIn")[0]!=null
&& d3.select("#"+panel).select("#D3viz").select("#buttonZoomOut")[0]!=null
&& d3.select("#"+panel).select("#D3viz").select("#buttonHand")[0]!=null)
if(d3.select("#"+panel).select("#D3viz").select("#buttonZoomIn").node()!=null
&& d3.select("#"+panel).select("#D3viz").select("#buttonZoomOut").node()!=null
&& d3.select("#"+panel).select("#D3viz").select("#buttonHand").node()!=null)
{
var x = d3
.select("#"+panel)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment