Skip to content

Commit 965bcfb

Browse files
committed
fixes and test for checklist in #2508
1 parent 2a41f9e commit 965bcfb

File tree

4 files changed

+75
-7
lines changed

4 files changed

+75
-7
lines changed

src/plot_api/plot_api.js

-7
Original file line numberDiff line numberDiff line change
@@ -2467,13 +2467,6 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) {
24672467
return valObject.valType === 'data_array' || valObject.arrayOk;
24682468
}
24692469

2470-
// for transforms: look at _fullInput rather than the transform result, which often
2471-
// contains generated arrays.
2472-
var newFullInput = newContainer._fullInput;
2473-
var oldFullInput = oldContainer._fullInput;
2474-
if(newFullInput && newFullInput !== newContainer) newContainer = newFullInput;
2475-
if(oldFullInput && oldFullInput !== oldContainer) oldContainer = oldFullInput;
2476-
24772470
for(key in oldContainer) {
24782471
// short-circuit based on previous calls or previous keys that already maximized the pathway
24792472
if(flags.calc) return;

src/plot_api/plot_schema.js

+3
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ exports.getTraceValObject = function(trace, parts) {
266266
var moduleAttrs, valObject;
267267

268268
if(head === 'transforms') {
269+
if(parts.length === 1) {
270+
return baseAttributes.transforms;
271+
}
269272
var transforms = trace.transforms;
270273
if(!Array.isArray(transforms) || !transforms.length) return false;
271274
var tNum = parts[1];

src/plots/attributes.js

+8
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,13 @@ module.exports = {
156156
].join(' ')
157157
},
158158
editType: 'calc'
159+
},
160+
transforms: {
161+
_isLinkedToArray: 'transform',
162+
editType: 'calc',
163+
description: [
164+
'An array of operations that manipulate the trace data,',
165+
'for example filtering or sorting the data arrays.'
166+
].join(' ')
159167
}
160168
};

test/jasmine/tests/transform_groupby_test.js

+64
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,70 @@ describe('groupby', function() {
182182
.then(done);
183183
});
184184

185+
it('Plotly.react should work', function(done) {
186+
var data = Lib.extendDeep([], mockData0);
187+
data[0].marker = { size: 20 };
188+
189+
var gd = createGraphDiv();
190+
var dims = [4, 3];
191+
192+
Plotly.plot(gd, data).then(function() {
193+
assertStyle(dims,
194+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
195+
[1, 1]
196+
);
197+
198+
gd.data[0].marker.opacity = 0.4;
199+
// contrived test of relinkPrivateKeys
200+
// we'll have to do better if we refactor it to opt-in instead of catchall
201+
gd._fullData[0].marker._boo = 'here I am';
202+
return Plotly.react(gd, gd.data, gd.layout);
203+
}).then(function() {
204+
assertStyle(dims,
205+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
206+
[0.4, 0.4]
207+
);
208+
209+
expect(gd._fullData[0].marker.opacity).toEqual(0.4);
210+
expect(gd._fullData[1].marker.opacity).toEqual(0.4);
211+
expect(gd._fullData[0].marker._boo).toBe('here I am');
212+
213+
gd.data[0].marker.opacity = 1;
214+
return Plotly.react(gd, gd.data, gd.layout);
215+
}).then(function() {
216+
assertStyle(dims,
217+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
218+
[1, 1]
219+
);
220+
221+
expect(gd._fullData[0].marker.opacity).toEqual(1);
222+
expect(gd._fullData[1].marker.opacity).toEqual(1);
223+
224+
// edit just affects the first group
225+
gd.data[0].transforms[0].styles[0].value.marker.color = 'green';
226+
return Plotly.react(gd, gd.data, gd.layout);
227+
}).then(function() {
228+
assertStyle(dims,
229+
['rgb(0, 128, 0)', 'rgb(0, 0, 255)'],
230+
[1, 1]
231+
);
232+
233+
expect(gd._fullData[0].marker.opacity).toEqual(1);
234+
expect(gd._fullData[1].marker.opacity).toEqual(1);
235+
236+
// edit just affects the second group
237+
gd.data[0].transforms[0].styles[1].value.marker.color = 'red';
238+
return Plotly.react(gd, gd.data, gd.layout);
239+
}).then(function() {
240+
assertStyle(dims,
241+
['rgb(0, 128, 0)', 'rgb(255, 0, 0)'],
242+
[1, 1]
243+
);
244+
})
245+
.catch(failTest)
246+
.then(done);
247+
});
248+
185249
it('Plotly.extendTraces should work', function(done) {
186250
var data = Lib.extendDeep([], mockData0);
187251

0 commit comments

Comments
 (0)