Skip to content

Commit 0027f53

Browse files
committed
add legacy deprecation warnings
1 parent 86204a6 commit 0027f53

File tree

4 files changed

+59
-23
lines changed

4 files changed

+59
-23
lines changed

src/plot_api/plot_api.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ Plotly.plot = function(gd, data, layout, config) {
144144

145145
var fullLayout = gd._fullLayout;
146146

147-
// Polar plots
148-
if(data && data[0] && data[0].r) return plotPolar(gd, data, layout);
147+
// Legacy polar plots
148+
if(!fullLayout._has('polar') && data && data[0] && data[0].r) {
149+
Lib.warn('Legacy polar charts are deprecated!');
150+
return plotPolar(gd, data, layout);
151+
}
149152

150153
// so we don't try to re-call Plotly.plot from inside
151154
// legend and colorbar, if margins changed

src/traces/scatter/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,17 @@ module.exports = {
477477
valType: 'data_array',
478478
editType: 'calc',
479479
description: [
480-
'For polar chart only.',
480+
'For legacy polar chart only.',
481+
'Please switch to *scatterpolar* trace type.',
481482
'Sets the radial coordinates.'
482483
].join('')
483484
},
484485
t: {
485486
valType: 'data_array',
486487
editType: 'calc',
487488
description: [
488-
'For polar chart only.',
489+
'For legacy polar chart only.',
490+
'Please switch to *scatterpolar* trace type.',
489491
'Sets the angular coordinates.'
490492
].join('')
491493
},

test/jasmine/tests/plot_interact_test.js

-19
Original file line numberDiff line numberDiff line change
@@ -464,25 +464,6 @@ describe('Test plot structure', function() {
464464
});
465465
});
466466
});
467-
468-
describe('polar plots', function() {
469-
var mock = require('@mocks/polar_scatter.json');
470-
471-
beforeEach(function(done) {
472-
Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done);
473-
});
474-
475-
it('has as many *mark dot* nodes as there are points', function() {
476-
var nodes = d3.selectAll('path.mark.dot');
477-
478-
var Npts = 0;
479-
mock.data.forEach(function(trace) {
480-
Npts += trace.r.length;
481-
});
482-
483-
expect(nodes.size()).toEqual(Npts);
484-
});
485-
});
486467
});
487468

488469
describe('plot svg clip paths', function() {

test/jasmine/tests/polar_test.js

+50
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
1+
var Plotly = require('@lib');
12
var Lib = require('@src/lib');
23
var Polar = require('@src/plots/polar');
34

5+
var createGraphDiv = require('../assets/create_graph_div');
6+
var destroyGraphDiv = require('../assets/destroy_graph_div');
7+
var fail = require('../assets/fail_test');
8+
9+
describe('Test legacy polar plots logs:', function() {
10+
var gd;
11+
12+
beforeEach(function() {
13+
spyOn(Lib, 'warn');
14+
gd = createGraphDiv();
15+
});
16+
17+
afterEach(destroyGraphDiv);
18+
19+
var specs = [{
20+
name: 'legacy polar scatter traces',
21+
data: [{
22+
r: [1, 2, 3],
23+
t: [1, 2, 3]
24+
}]
25+
}, {
26+
name: 'legacy polar bar traces',
27+
data: [{
28+
type: 'bar',
29+
r: [1, 2, 3],
30+
t: [1, 2, 3]
31+
}]
32+
}, {
33+
name: 'legacy area traces',
34+
data: [{
35+
type: 'area',
36+
r: [1, 2, 3],
37+
t: [1, 2, 3]
38+
}]
39+
}];
40+
41+
specs.forEach(function(s) {
42+
it('should log deprecation warning on ' + s.name, function(done) {
43+
Plotly.plot(gd, s.data)
44+
.then(function() {
45+
expect(Lib.warn).toHaveBeenCalledTimes(1);
46+
expect(Lib.warn).toHaveBeenCalledWith('Legacy polar charts are deprecated!');
47+
})
48+
.catch(fail)
49+
.then(done);
50+
});
51+
});
52+
});
53+
454
describe('Test polar plots defaults:', function() {
555
var layoutOut;
656

0 commit comments

Comments
 (0)