Skip to content

Commit b212086

Browse files
committed
#30a PR feedback: not expose scene id and use axis names. Plus: test the data structure of the callback.
1 parent e467c88 commit b212086

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,19 @@ proto.updateFx = function(options) {
271271

272272
var relayoutCallback = function(scene) {
273273

274-
var update = {},
275-
xrange = scene.xaxis.range,
274+
var xrange = scene.xaxis.range,
276275
yrange = scene.yaxis.range;
277276

278277
// Update the layout on the DIV
279278
scene.graphDiv.layout.xaxis.range = xrange.slice(0);
280279
scene.graphDiv.layout.yaxis.range = yrange.slice(0);
281280

282281
// Make a meaningful value to be passed on to the possible 'plotly_relayout' subscriber(s)
283-
update[scene.id] = { // scene.camera has no many useful projection or scale information
284-
lastInputTime: scene.camera.lastInputTime, // helps determine which one is the latest input (if async)
285-
xrange: xrange.slice(0),
286-
yrange: yrange.slice(0)
282+
var update = { // scene.camera has no many useful projection or scale information
283+
lastInputTime: scene.camera.lastInputTime // helps determine which one is the latest input (if async)
287284
};
285+
update[scene.xaxis._name] = xrange.slice();
286+
update[scene.yaxis._name] = yrange.slice();
288287

289288
scene.graphDiv.emit('plotly_relayout', update);
290289
};

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,15 @@ describe('Test gl plot interactions', function() {
310310

311311
setTimeout(function() {
312312

313-
expect(relayoutCallback).toHaveBeenCalledTimes(6); // X and back; Y and back; XY and back
313+
// callback count expectation: X and back; Y and back; XY and back
314+
expect(relayoutCallback).toHaveBeenCalledTimes(6);
315+
316+
// a callback value structure and contents check
317+
expect(relayoutCallback).toHaveBeenCalledWith(jasmine.objectContaining({
318+
lastInputTime: jasmine.any(Number),
319+
xaxis: [jasmine.any(Number), jasmine.any(Number)],
320+
yaxis: [jasmine.any(Number), jasmine.any(Number)]
321+
}));
314322

315323
done();
316324

0 commit comments

Comments
 (0)