Skip to content

Commit 473643c

Browse files
committed
AJ-proof latest additions
1 parent a72ce55 commit 473643c

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

src/plot_api/plot_api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,11 @@ function _relayout(gd, aobj) {
19461946

19471947
// clear polar view initial stash for radial range so that
19481948
// value get recomputed in correct units
1949-
if(Array.isArray(fullLayout._subplots.polar) && fullLayout._subplots.polar.length && fullLayout[p.parts[0]]) {
1949+
if(Array.isArray(fullLayout._subplots.polar) &&
1950+
fullLayout._subplots.polar.length &&
1951+
fullLayout[p.parts[0]] &&
1952+
p.parts[1] === 'radialaxis'
1953+
) {
19501954
delete fullLayout[p.parts[0]]._subplot.viewInitial['radialaxis.range'];
19511955
}
19521956

src/plots/polar/layout_attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ var angularAxisAttrs = {
213213
role: 'info',
214214
description: [
215215
'Sets that start position (in degrees) of the angular axis',
216-
'By default, polar subplots will `direction` set to *counterclockwise*',
216+
'By default, polar subplots with `direction` set to *counterclockwise*',
217217
'get a `rotation` of *0*',
218218
'which corresponds to due East (like what mathematicians prefer).',
219219
'In turn, polar with `direction` set to *clockwise* get a rotation of *90*',

test/image/baselines/polar_fills.png

848 Bytes
Loading

test/image/mocks/polar_fills.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
"fill": "toself",
2222
"hoveron": "fills",
2323
"subplot": "polar2"
24+
}, {
25+
"type": "scatterpolar",
26+
"mode": "markers",
27+
"r": [5, 1, 1.5, 4, 5],
28+
"theta": [0, 270, 180, 90, 0],
29+
"fill": "toself",
30+
"hoveron": "fills",
31+
"subplot": "polar2"
2432
}],
2533
"layout": {
2634
"polar": {

test/jasmine/tests/polar_test.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,24 @@ describe('Test relayout on polar subplots:', function() {
237237
Plotly.plot(gd, fig).then(function() {
238238
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
239239
.toBeCloseToArray([0, 11.225]);
240+
expect(gd._fullLayout.polar.radialaxis.range)
241+
.toBeCloseToArray([0, 11.225]);
240242

241243
return Plotly.relayout(gd, 'polar.radialaxis.type', 'log');
242244
})
243245
.then(function() {
244246
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
245247
.toBeCloseToArray([-0.53, 1.158]);
248+
expect(gd._fullLayout.polar.radialaxis.range)
249+
.toBeCloseToArray([-0.53, 1.158]);
246250

247251
return Plotly.relayout(gd, 'polar.radialaxis.type', 'linear');
248252
})
249253
.then(function() {
250254
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
251255
.toBeCloseToArray([0, 11.225]);
256+
expect(gd._fullLayout.polar.radialaxis.range)
257+
.toBeCloseToArray([0, 11.225]);
252258
})
253259
.catch(fail)
254260
.then(done);
@@ -570,10 +576,10 @@ describe('Test polar interactions:', function() {
570576
mouseEvent('mouseout', pos[0], pos[1]);
571577
}
572578

573-
function _click(pos) {
579+
function _click(pos, opts) {
574580
eventData = '';
575581
gd._mouseDownTime = 0;
576-
click(pos[0], pos[1]);
582+
click(pos[0], pos[1], opts);
577583
}
578584

579585
function _doubleClick(pos) {
@@ -582,6 +588,24 @@ describe('Test polar interactions:', function() {
582588
return doubleClick(pos[0], pos[1]);
583589
}
584590

591+
var modClickOpts = {
592+
altKey: true,
593+
ctrlKey: true, // this makes it effectively into a right-click
594+
metaKey: true,
595+
shiftKey: true,
596+
button: 0,
597+
cancelContext: true
598+
};
599+
600+
var rightClickOpts = {
601+
altKey: false,
602+
ctrlKey: false,
603+
metaKey: false,
604+
shiftKey: false,
605+
button: 2,
606+
cancelContext: true
607+
};
608+
585609
it('should trigger hover/unhover/click/doubleclick events', function(done) {
586610
var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json'));
587611
var ptPos = [250, 200];
@@ -645,6 +669,32 @@ describe('Test polar interactions:', function() {
645669
plotly_relayout: 1
646670
}, 'after doubleclick');
647671
})
672+
.then(function() { _click(ptPos, modClickOpts); })
673+
.then(function() {
674+
_assert([{
675+
r: 3.26,
676+
theta: 68.08
677+
}], {
678+
plotly_hover: 2,
679+
plotly_unhover: 1,
680+
plotly_click: 4,
681+
plotly_doubleclick: 1,
682+
plotly_relayout: 1
683+
}, 'after modified click');
684+
})
685+
.then(function() { _click(ptPos, rightClickOpts); })
686+
.then(function() {
687+
_assert([{
688+
r: 3.26,
689+
theta: 68.08
690+
}], {
691+
plotly_hover: 2,
692+
plotly_unhover: 1,
693+
plotly_click: 5,
694+
plotly_doubleclick: 1,
695+
plotly_relayout: 1
696+
}, 'after right click');
697+
})
648698
.catch(fail)
649699
.then(done);
650700
});

0 commit comments

Comments
 (0)