From 81fa9c07cf25a76e09a3b43e372ffa36ae40a84e Mon Sep 17 00:00:00 2001 From: Mark W <24956497+ndg63276@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:06:44 +0100 Subject: [PATCH] LIMS-140: Fix pia_estimated_d_min display on VMXi grid scans (#678) * LIMS-140: Fix pia_estimated_d_min display on VMXi grid scans * LIMS-140: Clear up inverting of data * Apply suggestions from code review Co-authored-by: Guilherme Francisco --------- Co-authored-by: Mark Williams Co-authored-by: Guilherme Francisco --- client/src/js/modules/dc/views/gridplot.js | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/client/src/js/modules/dc/views/gridplot.js b/client/src/js/modules/dc/views/gridplot.js index ea9c0acd4..8dd2b2252 100644 --- a/client/src/js/modules/dc/views/gridplot.js +++ b/client/src/js/modules/dc/views/gridplot.js @@ -70,6 +70,7 @@ define(['jquery', 'marionette', this.statusesLoaded = false this.listenTo(options.imagestatuses, 'sync', this.setStatues, this) this.noHeatMapResult = [] + this.invertHeatMap = false this._ready = [] @@ -130,6 +131,8 @@ define(['jquery', 'marionette', loadAttachment: function() { var a = this.attachments.findWhere({ 'DATACOLLECTIONFILEATTACHMENTID': this.ui.ty2.val() }) + var selectedOption = this.ui.ty2.find('option:selected').text() + this.invertHeatMap = selectedOption === 'pia_estimated_d_min' if (a) { if (!a.get('DATA')) { var self = this @@ -411,12 +414,15 @@ define(['jquery', 'marionette', if (d.length > 0) { let max = 0 + let power = this.invertHeatMap ? -1 : 1 + let val = 0 _.each(d, function(v) { - if (v[1] > max) max = v[1] + val = Math.pow(v[1], power) + if (val > max) max = val }) max = max === 0 ? 1 : max - if (this.getOption('padMax') && max < 10) max = max * 50 + if (this.getOption('padMax') && max < 10 && !this.invertHeatMap) max = max * 50 var sw = (this.perceivedw-(this.offset_w*this.scale))/this.grid.get('STEPS_X') var sh = (this.perceivedh-(this.offset_h*this.scale))/this.grid.get('STEPS_Y') @@ -427,6 +433,7 @@ define(['jquery', 'marionette', var data = [] _.each(d, function(v) { var k = v[0] - 1 + val = Math.pow(v[1], power) // Account for vertical grid scans let xstep, ystep, x, y @@ -454,7 +461,10 @@ define(['jquery', 'marionette', } // Dont zero values < 1 if data is scaled to max==1 - data.push({ x: x, y: y, value: v[1] < 1 && max > 1 ? 0 : v[1], + data.push({ + x: x, + y: y, + value: val < 1 && max > 1 ? 0 : val, radius: radius }) @@ -514,7 +524,16 @@ define(['jquery', 'marionette', _getVal: function(pos) { var val = null - const d = Number(this.ui.ty.val()) > -1 ? this.distl.get('data')[Number(this.ui.ty.val())] : [] + let d = [] + if (this.ui.ty.is(":visible")) { + d = Number(this.ui.ty.val()) > -1 ? this.distl.get('data')[Number(this.ui.ty.val())] : [] + } + if (this.ui.ty2.is(":visible")) { + let a = this.attachments.findWhere({ 'DATACOLLECTIONFILEATTACHMENTID': this.ui.ty2.val() }) + if (a && a.get('DATA')) { + d = a.get('DATA') + } + } _.each(d, function(v) { // 1 indexed array if (v[0] === pos+1) {