");
// Sort by frequency so we print higher frequencies later, and can bump them further down the track to prevent
// overlaps
spotList.sort(function(a, b) { return a.freq - b.freq; });
var lastSpotEmDownBand = -999;
// Iterate through the spots list
spotList.forEach(s => {
// Work out how far down the div to draw it
var percentDownBand = (s.freq - band.start_freq) / (band.end_freq - band.start_freq) * 0.97; // not 100% due to fudge, the first and last dashes are not exactly at the top and bottom of the div as some space is needed for text
var emDownBand = percentDownBand * BAND_COLUMN_HEIGHT_EM;
if (emDownBand < lastSpotEmDownBand + 1.6) {
emDownBand = lastSpotEmDownBand + 1.6; // Prevent overlap
}
lastSpotEmDownBand = emDownBand;
// Calculate how many px down the band div the label appears, and store it with the spot, so we can use it
// later for drawing the lines.
var pxDownBandLabel = (emDownBand * BAND_COLUMN_FONT_SIZE) + (0.015 * BAND_COLUMN_HEIGHT_PX);
s["pxDownBandLabel"] = pxDownBandLabel;
// Add spot div to DOM
bandSpotsDiv.append(`
`);
});
// Work out how tall the canvas should be. Normally this is matching the normal band column height, but if some
// spots have gone off the end of the band markers and stretched their div, we need to resize the canvas to
// match, otherwise we have nowhere to draw their connecting lines.
var canvasHeight = Math.max(BAND_COLUMN_HEIGHT_PX, (lastSpotEmDownBand+1.6) * BAND_COLUMN_FONT_SIZE);
// Draw horizontal or diagonal lines to join up the "real" frequency with where the spot div ended up
var bandLinesCanvas = $(`