Skip to content

Commit 3178b2e

Browse files
committed
update polar for Plotly.react compatibility
1 parent 4b98be6 commit 3178b2e

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

src/plots/polar/layout_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8787
switch(axName) {
8888
case 'radialaxis':
8989
var autoRange = coerceAxis('autorange', !axOut.isValidRange(axIn.range));
90+
axIn.autorange = autoRange;
9091
if(autoRange) coerceAxis('rangemode');
9192
if(autoRange === 'reversed') axOut._m = -1;
9293

src/traces/scatterpolar/calc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function calc(gd, trace) {
2626
var angularAxis = fullLayout[subplotId].angularaxis;
2727
var rArray = radialAxis.makeCalcdata(trace, 'r');
2828
var thetaArray = angularAxis.makeCalcdata(trace, 'theta');
29-
var len = rArray.length;
29+
var len = trace._length;
3030
var cd = new Array(len);
3131

3232
function c2rad(v) {
@@ -53,6 +53,7 @@ module.exports = function calc(gd, trace) {
5353
if(angularAxis.type !== 'linear') {
5454
angularAxis.autorange = true;
5555
Axes.expand(angularAxis, thetaArray);
56+
delete angularAxis.autorange;
5657
}
5758

5859
calcColorscale(trace);

src/traces/scatterpolar/defaults.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3434
return;
3535
}
3636

37-
if(len < r.length) traceOut.r = r.slice(0, len);
38-
if(len < theta.length) traceOut.theta = theta.slice(0, len);
37+
traceOut._length = len;
3938

4039
coerce('thetaunit');
4140
coerce('mode', len < PTS_LINESONLY ? 'lines+markers' : 'lines');

src/traces/scatterpolargl/defaults.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3232
return;
3333
}
3434

35-
if(len < r.length) traceOut.r = r.slice(0, len);
36-
if(len < theta.length) traceOut.theta = theta.slice(0, len);
35+
traceOut._length = len;
3736

3837
coerce('thetaunit');
3938
coerce('mode', len < PTS_LINESONLY ? 'lines+markers' : 'lines');

src/traces/scatterpolargl/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ function calc(container, trace) {
2626
var thetaArray = angularAxis.makeCalcdata(trace, 'theta');
2727
var stash = {};
2828

29+
if(trace._length < rArray.length) rArray = rArray.slice(0, trace._length);
30+
if(trace._length < thetaArray.length) thetaArray = thetaArray.slice(0, trace._length);
31+
2932
calcColorscales(trace);
3033

3134
stash.r = rArray;
@@ -36,6 +39,7 @@ function calc(container, trace) {
3639
if(angularAxis.type !== 'linear') {
3740
angularAxis.autorange = true;
3841
Axes.expand(angularAxis, thetaArray);
42+
delete angularAxis.autorange;
3943
}
4044

4145
return [{x: false, y: false, t: stash, trace: trace}];

test/jasmine/tests/scatterpolar_test.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,28 @@ describe('Test scatterpolar trace defaults:', function() {
1818
ScatterPolar.supplyDefaults(traceIn, traceOut, '#444', layout || {});
1919
}
2020

21-
it('should truncate *r* when longer than *theta*', function() {
21+
it('should not truncate *r* when longer than *theta*', function() {
22+
// this is handled at the calc step now via _length.
2223
_supply({
2324
r: [1, 2, 3, 4, 5],
2425
theta: [1, 2, 3]
2526
});
2627

27-
expect(traceOut.r).toEqual([1, 2, 3]);
28+
expect(traceOut.r).toEqual([1, 2, 3, 4, 5]);
2829
expect(traceOut.theta).toEqual([1, 2, 3]);
30+
expect(traceOut._length).toBe(3);
2931
});
3032

31-
it('should truncate *theta* when longer than *r*', function() {
33+
it('should not truncate *theta* when longer than *r*', function() {
34+
// this is handled at the calc step now via _length.
3235
_supply({
3336
r: [1, 2, 3],
3437
theta: [1, 2, 3, 4, 5]
3538
});
3639

3740
expect(traceOut.r).toEqual([1, 2, 3]);
38-
expect(traceOut.theta).toEqual([1, 2, 3]);
41+
expect(traceOut.theta).toEqual([1, 2, 3, 4, 5]);
42+
expect(traceOut._length).toBe(3);
3943
});
4044
});
4145

0 commit comments

Comments
 (0)