From 9a3d761cbde705204db64bc7e70e2defc02f2c64 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 19 Jun 2023 18:52:53 +0000 Subject: Change getSampleTableData function to include a includeNAs parameter This is so the export function can show all rows, including ones with no value. Previously it only fetched the rows with values (which is fine for correlations/mapping, but not export). --- .../wqflask/static/new/javascript/show_trait.js | 61 ++++++++++++---------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 0f923181..90c6015c 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -1072,7 +1072,7 @@ switchQNormData = function() { }; $('#qnorm').click(switchQNormData); -getSampleTableData = function(tableName, attributesAsList) { +getSampleTableData = function(tableName, attributesAsList, includeNAs=false) { var samples = []; if ($('#' + tableName).length){ @@ -1110,38 +1110,41 @@ getSampleTableData = function(tableName, attributesAsList) { sampleName = $.trim(nameNodes[_j].childNodes[0].textContent) if (isNumber(sampleVal) && sampleVal !== "") { sampleVal = parseFloat(sampleVal); - if (typeof varNodes == 'undefined'){ - sampleVar = null; + } else { + sampleVal = 'x' + } + if (typeof varNodes == 'undefined'){ + sampleVar = null; + } else { + sampleVar = varNodes[_j].childNodes[0].value; + if (isNumber(sampleVar)) { + sampleVar = parseFloat(sampleVar); } else { - sampleVar = varNodes[_j].childNodes[0].value; - if (isNumber(sampleVar)) { - sampleVar = parseFloat(sampleVar); - } else { - sampleVar = null; - } + sampleVar = 'x'; } - if (typeof nNodes == 'undefined'){ - sampleN = null; + } + if (typeof nNodes == 'undefined'){ + sampleN = null; + } else { + sampleN = nNodes[_j].childNodes[0].value; + if (isNumber(sampleN)) { + sampleN = parseInt(sampleN); } else { - sampleN = nNodes[_j].childNodes[0].value; - if (isNumber(sampleN)) { - sampleN = parseInt(sampleN); - } else { - sampleN = null; - } - } - - rowDict = { - name: sampleName, - value: sampleVal, - se: sampleVar, - num_cases: sampleN + sampleN = 'x'; } + } - for (_k = 0; _k < attributeNodes.length; _k++){ - rowDict[attributesAsList[_k]] = attributeNodes[_k][_j].textContent; - } + rowDict = { + name: sampleName, + value: sampleVal, + se: sampleVar, + num_cases: sampleN + } + for (_k = 0; _k < attributeNodes.length; _k++){ + rowDict[attributesAsList[_k]] = attributeNodes[_k][_j].textContent; + } + if (includeNAs || sampleVal != 'x') { samples.push(rowDict) } } @@ -1157,8 +1160,8 @@ exportSampleTableData = function() { }); sample_data = {}; - sample_data.primary_samples = getSampleTableData('samples_primary', attributesAsList); - sample_data.other_samples = getSampleTableData('samples_other', attributesAsList); + sample_data.primary_samples = getSampleTableData('samples_primary', attributesAsList, true); + sample_data.other_samples = getSampleTableData('samples_other', attributesAsList, true); sample_data.attributes = attributesAsList; json_sample_data = JSON.stringify(sample_data); $('input[name=export_data]').val(json_sample_data); -- cgit v1.2.3