diff --git a/webapp/TargetedMS/js/QCPlotHelperBase.js b/webapp/TargetedMS/js/QCPlotHelperBase.js index 11fb334b3..c616b8d2e 100644 --- a/webapp/TargetedMS/js/QCPlotHelperBase.js +++ b/webapp/TargetedMS/js/QCPlotHelperBase.js @@ -332,21 +332,17 @@ Ext4.define("LABKEY.targetedms.QCPlotHelperBase", { Ext4.Object.each(this.guideSetDataMap, function(guideSetId, guideSetData) { // for truncating out of range guideset data find first index of plotDate ending at guideset.trainingEnd - if (plotData.guideSetId === guideSetId && plotData.inGuideSetTrainingRange && guideSetData.TrainingEnd <= this.startDate) { + if (plotData.guideSetId == guideSetId && plotData.inGuideSetTrainingRange && guideSetData.TrainingEnd <= this.startDate) { this.filterPoints[frag][plotData.MetricId]['filterPointsFirstIndex'] = j + 1; - // ReferenceRangeSeries is used to separate series plotData['ReferenceRangeSeries'] = "GuideSet"; } - else { - plotData['ReferenceRangeSeries'] = "InRange"; - } - }, this); - // for truncating out of range guideset data find last index of plotData starting from this.startDate + // Mark the last index to truncate as j-1 (the point just before the user range starts), + // so the first in-range data point is NOT included in the removed gap. if (plotData.fullDate >= this.startDate) { - if (!this.filterPoints[frag][plotData.MetricId]['filterPointsLastIndex']) { - this.filterPoints[frag][plotData.MetricId]['filterPointsLastIndex'] = j; + if (this.filterPoints[frag][plotData.MetricId]['filterPointsLastIndex'] === undefined) { + this.filterPoints[frag][plotData.MetricId]['filterPointsLastIndex'] = j - 1; } } } @@ -392,6 +388,16 @@ Ext4.define("LABKEY.targetedms.QCPlotHelperBase", { renderPlots: function() { if (this.filterQCPoints) { this.truncateOutOfRangeQCPoints(); + // Recompute showDataPoints based on post-truncation counts, since the gap between the + // reference guide set and the user's date range was removed and the remaining set may + // be well under the threshold. + var maxPointsPerSeries = 0; + for (var i = 0; i < this.precursors.length; i++) { + if (this.fragmentPlotData[this.precursors[i]]) { + maxPointsPerSeries = Math.max(this.fragmentPlotData[this.precursors[i]].data.length, maxPointsPerSeries); + } + } + this.showDataPoints = maxPointsPerSeries <= LABKEY.targetedms.QCPlotHelperBase.maxPointsPerSeries; } // do not persist plot options in qc folder if changed after coming through experimental folder link if (!this.showExpRunRange) { @@ -434,7 +440,7 @@ Ext4.define("LABKEY.targetedms.QCPlotHelperBase", { Ext4.Object.each(this.fragmentPlotData, function(label, fragmentData) { // traverse plotData backwards from firstIndex to lastIndex and // remove them from the array - if (this.filterQCPoints && this.filterPoints) { + if (this.filterQCPoints && this.filterPoints && this.filterPoints[label]) { // when we're plotting two different metrics at the same time, then we // have repeated dates (from oldest to newest for metric 1, and then oldest to newest for metric 2, all in the same array).