From b244d813a9792c3e88821e96cee8b61c07fb893b Mon Sep 17 00:00:00 2001 From: Chris Simoes Date: Wed, 1 Nov 2023 12:00:40 -0400 Subject: [PATCH] fixing histogram when management factors are present --- .../stackedObservationPhenotypeHistogram.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/js/source/legacy/d3/graphers/stackedObservationPhenotypeHistogram.js b/js/source/legacy/d3/graphers/stackedObservationPhenotypeHistogram.js index 59edaebdda..c19171176b 100644 --- a/js/source/legacy/d3/graphers/stackedObservationPhenotypeHistogram.js +++ b/js/source/legacy/d3/graphers/stackedObservationPhenotypeHistogram.js @@ -35,7 +35,24 @@ } var histLoc = d3.select(loc); var header = data[0]; - var traitName = header[header.length-(header[header.length-1]!="notes"?1:2)]; + + // var traitName = header[header.length-(header[header.length-1]!="notes"?1:2)]; + + // Find the index of the "notes" column + var notesIndex = header.indexOf("notes"); + + if (notesIndex !== -1 && notesIndex > 0) { + // Get the column before "notes" + var traitName = header[notesIndex - 1]; + } else { + // Handle the case where "notes" is the first column or not found + var traitName = null; // You can use a default value or handle this case as needed + } + + + // The `traitName` variable contains the column before "notes" or null if "notes" is the first column or not found + console.log(traitName); + var observations = data.slice(1).map(function(d){ var o = {};