Skip to content

Commit

Permalink
calculate max group size
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlawrenceklein committed Jul 6, 2021
1 parent d3e08e9 commit 428c203
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions anvio/data/interactive/js/genomeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Settings vars
// TODO migrate below variables to kvp in state
var state = {};
var stateData = {};
var spacing = 30; // vertical spacing between genomes
var showLabels = true; // show genome labels?
var genomeLabelSize = 15; // font size of genome labels
Expand All @@ -38,7 +38,7 @@
var showScale = true; // show nt scale?
var scaleInterval = 100; // nt scale intervals
var scaleFactor = 1; // widths of all objects are scaled by this value to zoom in/out

var alignToGC = null;

var arrowStyle = 1; // gene arrow cosmetics. 1 (default) = 'inspect-page', 2 = thicker arrows, 3 = pentagon
Expand All @@ -53,7 +53,7 @@ var genomeData;
$(document).ready(function() {
initData();
// loadState();
processState('default', {}) // lifted here until loadState is hooked in from backend
processState('default', stateData) // lifted here until loadState is hooked in from backend
loadAll();
});

Expand Down Expand Up @@ -166,7 +166,7 @@ function processState(stateName, stateData){
'gcContent' : gcContent
}
stateData['additional-data-layers'].push(additionalDataObject)
}
}

if(stateData['genome-order-method']){
stateData['genome-order-method'].forEach(orderMethod => {
Expand All @@ -189,6 +189,7 @@ function loadAll() {

// Find max length genome
calculateMaxGenomeLength()
calculateSpacingForGroups()

var scaleWidth = canvas.getWidth();
var scaleHeight = 200;
Expand Down Expand Up @@ -849,6 +850,14 @@ function calculateMaxGenomeLength(){
}
}

function calculateSpacingForGroups(){ // to be used for setting vertical spacing
let maxGroupSize = 1; // default, as each group will always have at minimum a 'genome' layer
stateData['additional-data-layers'].map(group => {
Object.keys(group).length > maxGroupSize ? maxGroupSize = Object.keys(group).length : null
})
return maxGroupSize
}

var fixHelperModified = function(e, tr) { // ripped from utils.js instead of importing the whole file
var $originals = tr.children();
var $helper = tr.clone();
Expand Down

0 comments on commit 428c203

Please sign in to comment.