Skip to content

Commit 68e3569

Browse files
Support dual-series plots for Trailing Mean and Trailing CV (#6963)
* Support dual series for trailing mean and CV plots * Prep for merge
1 parent b55ea12 commit 68e3569

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

core/webapp/vis/src/internal/D3Renderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,6 @@ LABKEY.vis.internal.D3Renderer = function(plot) {
25022502

25032503
if (geom.dashed) {
25042504
layer.selectAll('path').style("stroke-dasharray", ("3, 3"));
2505-
layer.selectAll('path').style("stroke-dasharray", ("3, 3"));
25062505
}
25072506

25082507
bindMouseEvents(pathSel, geom, layer);

core/webapp/vis/src/plot.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ boxPlot.render();
15731573
* For LeveyJennings, the range is +/- 3 standard deviations from a mean.
15741574
* For MovingRange, the range is [0, 3.268*mean(mR)].
15751575
* For CUSUM, the range is [0, +5].
1576-
* @description This helper will take the input data and generate a sequencial x-axis so that all data points are the same distance apart.
1576+
* @description This helper will take the input data and generate a sequential x-axis so that all data points are the same distance apart.
15771577
* @param {Object} config An object that contains the following properties
15781578
* @param {String} [config.renderTo] The id of the div/span to insert the svg element into.
15791579
* @param {String} [config.qcPlotType] Specifies the plot type to be one of "LeveyJennings", "CUSUM", "MovingRange". Defaults to "LeveyJennings".
@@ -1622,6 +1622,14 @@ boxPlot.render();
16221622
* Used by CUSUM only.
16231623
* @param {String} [config.properties.negativeValueRight] The data property name for the value to be plotted on the right y-axis for CUSUM-.
16241624
* Used by CUSUM only.
1625+
* @param {String} [config.properties.TrailingMean] The data property name for the moving range value to be plotted on the left y-axis.
1626+
* Used by TrailingMean.
1627+
* @param {String} [config.properties.TrailingMeanRight] The data property name for the moving range to be plotted on the right y-axis.
1628+
* Used by TrailingMean.
1629+
* @param {String} [config.properties.TrailingCV] The data property name for the moving range value to be plotted on the left y-axis.
1630+
* Used by TrailingCV.
1631+
* @param {String} [config.properties.TrailingCVRight] The data property name for the moving range to be plotted on the right y-axis.
1632+
* Used by TrailingCV.
16251633
* @param {String} [config.properties.xTickLabel] The data property name for the x-axis tick label.
16261634
* @param {Number} [config.properties.xTickTagIndex] (Optional) The index/value of the x-axis label to be tagged (i.e. class="xticktag").
16271635
* @param {Boolean} [config.properties.showTrendLine] (Optional) Whether or not to show a line connecting the data points. Default false.
@@ -1760,7 +1768,11 @@ boxPlot.render();
17601768
// also, pull out the meanStdDev data for the unique x-axis values and calculate average values for the (LJ) trend line data
17611769
var tickLabelMap = {}, index = -1, distinctColorValues = [], meanStdDevData = [],
17621770
groupedTrendlineData = [], groupedTrendlineSeriesData = {},
1763-
hasYRightMetric = config.properties.valueRight || config.properties.positiveValueRight || config.properties.valueRightMR;
1771+
hasYRightMetric = config.properties.valueRight ||
1772+
config.properties.positiveValueRight ||
1773+
config.properties.valueRightMR ||
1774+
config.properties.TrailingMeanRight ||
1775+
config.properties.TrailingCVRight;
17641776

17651777
var convertToPercentDeviation = function(value, mean) {
17661778
var calc = Math.round(((value / mean) * 100) * 100) / 100;
@@ -1893,10 +1905,14 @@ boxPlot.render();
18931905
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingMean) {
18941906
valProp = config.properties["TrailingMean"];
18951907
valRightProp = config.properties["TrailingMeanRight"]
1908+
sdProp = "stddevTrailingMean";
1909+
meanProp = "meanTrailingMean";
18961910
}
18971911
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingCV) {
18981912
valProp = config.properties["TrailingCV"];
18991913
valRightProp = config.properties["TrailingCVRight"]
1914+
sdProp = "stddevTrailingCV";
1915+
meanProp = "meanTrailingCV";
19001916
}
19011917
else {
19021918
meanProp = config.properties["mean"] || "mean";
@@ -2020,7 +2036,10 @@ boxPlot.render();
20202036
row[meanProp] = 0;
20212037
}
20222038

2023-
if (!config.properties.valueRight && !config.properties.valueRightMR) {
2039+
if (!config.properties.valueRight &&
2040+
!config.properties.valueRightMR &&
2041+
!config.properties.TrailingMeanRight &&
2042+
!config.properties.TrailingCVRight) {
20242043

20252044
if (!config.properties.yAxisDomain) {
20262045
config.properties.yAxisDomain = [0, 0];
@@ -2089,11 +2108,11 @@ boxPlot.render();
20892108
}
20902109
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingMean) {
20912110
plotValueName = config.properties.TrailingMean;
2092-
plotValueNameRight = config.properties.negativeValueRight;
2111+
plotValueNameRight = config.properties.TrailingMeanRight;
20932112
}
20942113
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingCV) {
20952114
plotValueName = config.properties.TrailingCV;
2096-
plotValueNameRight = config.properties.negativeValueRight;
2115+
plotValueNameRight = config.properties.TrailingCVRight;
20972116
}
20982117

20992118
addValueToTrendLineData(dataArr, seqValue, arrKey, plotValueName, row[plotValueName], 'sum1', 'count1');
@@ -2501,6 +2520,7 @@ boxPlot.render();
25012520
geom: new LABKEY.vis.Geom.Path({
25022521
opacity: 1,
25032522
size: 1.5,
2523+
// TODO - differentiate left and right
25042524
dashed: config.qcPlotType == LABKEY.vis.TrendingLinePlotType.CUSUM && !negativeCusum,
25052525
color: config.properties.lineColor
25062526
}),
@@ -2712,7 +2732,7 @@ boxPlot.render();
27122732
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingMean) {
27132733
if (hasYRightMetric) {
27142734
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yLeft', config.properties.TrailingMean, 0)));
2715-
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yRight', config.properties.valueRightTrailingMean, 1)));
2735+
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yRight', config.properties.TrailingMeanRight, 1)));
27162736
}
27172737
else {
27182738
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yLeft', config.properties.TrailingMean)));
@@ -2721,7 +2741,7 @@ boxPlot.render();
27212741
else if (config.qcPlotType === LABKEY.vis.TrendingLinePlotType.TrailingCV) {
27222742
if (hasYRightMetric) {
27232743
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yLeft', config.properties.TrailingCV, 0)));
2724-
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yRight', config.properties.valueRightTrailingCV, 1)));
2744+
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yRight', config.properties.TrailingCVRight, 1)));
27252745
}
27262746
else {
27272747
config.layers.push(new LABKEY.vis.Layer(getPointLayerConfig('yLeft', config.properties.TrailingCV)));

0 commit comments

Comments
 (0)