Skip to content

Commit 3753125

Browse files
committed
try more useless refs to input container in full trace
- move traceOut.index and traceOut._input assignments out of supplyTraceDefaults for clarity - 'index' ref -> index in user data (as before) - '_input' ref -> trace in user data (as before) - '_expandedIndex' ref -> index in fullData - '_expandedInput' ref -> full trace after transform, before 2nd trace dflts
1 parent 86f7687 commit 3753125

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/plots/plots.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -647,29 +647,33 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout) {
647647
}
648648

649649
for(var i = 0; i < dataIn.length; i++) {
650-
var trace = dataIn[i];
651-
652-
var fullTrace = plots.supplyTraceDefaults(trace, cnt, layout);
653-
654-
// keep track of pre-transform _input
655-
var traceIn = fullTrace._input;
650+
var trace = dataIn[i],
651+
fullTrace = plots.supplyTraceDefaults(trace, cnt, layout);
656652

657653
if(fullTrace.transforms && fullTrace.transforms.length) {
658654
var expandedTraces = applyTransforms(fullTrace, dataOut, layout);
659655

660656
for(var j = 0; j < expandedTraces.length; j++) {
661-
var expandedTrace = expandedTraces[j];
662-
var fullExpandedTrace = plots.supplyTraceDefaults(expandedTrace, cnt, layout);
657+
var expandedTrace = expandedTraces[j],
658+
fullExpandedTrace = plots.supplyTraceDefaults(expandedTrace, cnt, layout);
659+
660+
// add info about parent data trace
661+
fullExpandedTrace.index = i;
662+
fullExpandedTrace._input = trace;
663+
fullExpandedTrace._fullInput = fullTrace;
663664

664-
// copy refs
665-
fullExpandedTrace._input = traceIn;
666-
fullExpandedTrace._fullTransforms = fullTrace.transforms;
667-
fullExpandedTrace._index = i;
665+
// add info about the expanded data
666+
fullExpandedTrace._expandedIndex = cnt;
667+
fullExpandedTrace._expandedInput = expandedTrace;
668668

669669
pushModule(fullExpandedTrace);
670670
}
671671
}
672672
else {
673+
fullTrace.index = i;
674+
fullTrace._input = trace;
675+
fullTrace._expandedIndex = cnt;
676+
673677
pushModule(fullTrace);
674678
}
675679
}
@@ -690,8 +694,6 @@ plots.supplyTraceDefaults = function(traceIn, traceIndex, layout) {
690694
plots.subplotsRegistry[subplotType].attributes, subplotAttr);
691695
}
692696

693-
// module-independent attributes
694-
traceOut.index = traceIndex;
695697
var visible = coerce('visible');
696698

697699
coerce('type');
@@ -740,9 +742,6 @@ plots.supplyTraceDefaults = function(traceIn, traceIndex, layout) {
740742
supplyTransformDefaults(traceIn, traceOut, layout);
741743
}
742744

743-
// reference back to the input object for convenience
744-
traceOut._input = traceIn;
745-
746745
return traceOut;
747746
};
748747

test/jasmine/tests/transforms_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('one-to-one transforms:', function() {
9595
}]);
9696

9797
// keep ref to full transforms array
98-
expect(dataOut[0]._fullTransforms).toEqual([{
98+
expect(dataOut[0]._fullInput.transforms).toEqual([{
9999
type: 'filter',
100100
operation: '>',
101101
value: 0,
@@ -107,7 +107,7 @@ describe('one-to-one transforms:', function() {
107107

108108
// TODO do we really need this ???
109109
// set _index w.r.t. user data
110-
expect(dataOut[0]._index).toEqual(0);
110+
expect(dataOut[0].index).toEqual(0);
111111
});
112112

113113
it('Plotly.plot should plot the transform trace', function(done) {

0 commit comments

Comments
 (0)