Skip to content

Commit

Permalink
Expand the view to include the full width of the graph minimap (#992)
Browse files Browse the repository at this point in the history
Fixes scrolling over the full graph:
- issue #924
- Whenever a minimap is wider than the screen, the minimap will dictate the width of the graph viewer. 
- Previously the minimap's viewfinder was also much wider, and not everything indicated in the minimap's viewfinder could be shown in the available window.
  • Loading branch information
Joeytje50 authored Jun 20, 2023
1 parent 09900e5 commit cb656f7
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions activity_browser/static/javascript/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var max_edge_width = 40;

var globalWidth = null;
var globalHeight = null;
var globalMinWidth = null;

// initialize panCanvas (container actually displaying graph) globally, to enable node-info extraction on-click
var panCanvas = {};
Expand Down Expand Up @@ -70,9 +71,18 @@ d3.demo.canvas = function() {
minimapScale = 0.1; //reduced minimap scale to (help) prevent graph to exceed panel size

//introduced function to reset width/height according to new window sizes
updateDimensions = function() {
updateDimensions = function(minWidth) {
getWindowSize();
width = globalWidth*0.99;
if (arguments.length) {
if (minWidth < globalWidth * 0.99) {
minWidth = globalWidth * 0.99; // -1% to avoid using scroll bars when not necessary
} else {
globalMinWidth = minWidth + 20; // +20px to compensate for the scroll bar width
}
} else {
minWidth = globalMinWidth;
}
width = minWidth;
height = globalHeight*(is_sankey_mode?0.6:0.65);
}

Expand Down Expand Up @@ -232,11 +242,15 @@ d3.demo.canvas = function() {
// get panCanvas width here?
// pan to node (implement here)
minimap.render();

updateDimensions(minimap.width());
canvas.render();
canvas.reset();
};

/** RENDER **/
canvas.render = function() {
updateDimensions(); //added call to update window sizes
updateDimensions(); //added call to update window sizes
svgDefs
.select(".clipPath .background")
.attr("width", width)
Expand Down Expand Up @@ -407,7 +421,7 @@ d3.demo.minimap = function() {
d3.select(node).attr("transform", "translate(0,0)");
// keep the minimap's viewport (frame) sized to match the current visualization viewport dimensions
frame.select(".background")
.attr("width", width)
.attr("width", minimap.width())
.attr("height", height);
frame.node().parentNode.appendChild(frame.node());
};
Expand All @@ -422,7 +436,9 @@ d3.demo.minimap = function() {


minimap.width = function(value) {
if (!arguments.length) return width;
var bBox = this.node.getBBox();
var w = bBox.width * minimapScale;
if (!arguments.length) return w;
width = parseInt(value, 10);
return this;
};
Expand Down

0 comments on commit cb656f7

Please sign in to comment.