Skip to content

Commit bce5add

Browse files
committed
Merge branch 'master' into pie_title
2 parents 97cc9bb + 7714aa6 commit bce5add

File tree

14 files changed

+278
-38
lines changed

14 files changed

+278
-38
lines changed

src/components/legend/get_legend_data.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ module.exports = function getLegendData(calcdata, opts) {
5959
label: labelj,
6060
color: cd[j].color,
6161
i: cd[j].i,
62-
trace: trace
62+
trace: trace,
63+
pts: cd[j].pts
6364
});
6465

6566
slicesShown[lgroup][labelj] = true;

src/plot_api/validate.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,23 @@ function crawl(objIn, objOut, schema, list, base, path) {
281281

282282
// the 'full' layout schema depends on the traces types presents
283283
function fillLayoutSchema(schema, dataOut) {
284+
var layoutSchema = schema.layout.layoutAttributes;
285+
284286
for(var i = 0; i < dataOut.length; i++) {
285-
var traceType = dataOut[i].type,
286-
traceLayoutAttr = schema.traces[traceType].layoutAttributes;
287+
var traceOut = dataOut[i];
288+
var traceSchema = schema.traces[traceOut.type];
289+
var traceLayoutAttr = traceSchema.layoutAttributes;
287290

288291
if(traceLayoutAttr) {
289-
Lib.extendFlat(schema.layout.layoutAttributes, traceLayoutAttr);
292+
if(traceOut.subplot) {
293+
Lib.extendFlat(layoutSchema[traceSchema.attributes.subplot.dflt], traceLayoutAttr);
294+
} else {
295+
Lib.extendFlat(layoutSchema, traceLayoutAttr);
296+
}
290297
}
291298
}
292299

293-
return schema.layout.layoutAttributes;
300+
return layoutSchema;
294301
}
295302

296303
// validation error codes

src/plots/polar/legacy/area_attributes.js

+44-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,53 @@
1010

1111
var scatterAttrs = require('../../../traces/scatter/attributes');
1212
var scatterMarkerAttrs = scatterAttrs.marker;
13+
var extendFlat = require('../../../lib/extend').extendFlat;
14+
15+
var deprecationWarning = [
16+
'Area traces are deprecated!',
17+
'Please switch to the *barpolar* trace type.'
18+
].join(' ');
1319

1420
module.exports = {
15-
r: scatterAttrs.r,
16-
t: scatterAttrs.t,
21+
r: extendFlat({}, scatterAttrs.r, {
22+
description: [
23+
deprecationWarning,
24+
'Sets the radial coordinates',
25+
'for legacy polar chart only.'
26+
].join(' ')
27+
}),
28+
t: extendFlat({}, scatterAttrs.t, {
29+
description: [
30+
deprecationWarning,
31+
'Sets the angular coordinates',
32+
'for legacy polar chart only.'
33+
].join(' ')
34+
}),
1735
marker: {
18-
color: scatterMarkerAttrs.color,
19-
size: scatterMarkerAttrs.size,
20-
symbol: scatterMarkerAttrs.symbol,
21-
opacity: scatterMarkerAttrs.opacity,
36+
color: extendFlat({}, scatterMarkerAttrs.color, {
37+
description: [
38+
deprecationWarning,
39+
scatterMarkerAttrs.color.description
40+
].join(' ')
41+
}),
42+
size: extendFlat({}, scatterMarkerAttrs.size, {
43+
description: [
44+
deprecationWarning,
45+
scatterMarkerAttrs.size.description
46+
].join(' ')
47+
}),
48+
symbol: extendFlat({}, scatterMarkerAttrs.symbol, {
49+
description: [
50+
deprecationWarning,
51+
scatterMarkerAttrs.symbol.description
52+
].join(' ')
53+
}),
54+
opacity: extendFlat({}, scatterMarkerAttrs.opacity, {
55+
description: [
56+
deprecationWarning,
57+
scatterMarkerAttrs.opacity.description
58+
].join(' ')
59+
}),
2260
editType: 'calc'
2361
}
2462
};

src/plots/polar/legacy/axis_attributes.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ var axesAttrs = require('../../cartesian/layout_attributes');
1313
var extendFlat = require('../../../lib/extend').extendFlat;
1414
var overrideAll = require('../../../plot_api/edit_types').overrideAll;
1515

16+
var deprecationWarning = [
17+
'Legacy polar charts are deprecated!',
18+
'Please switch to *polar* subplots.'
19+
].join(' ');
20+
1621
var domainAttr = extendFlat({}, axesAttrs.domain, {
1722
description: [
1823
'Polar chart subplots are not supported yet.',
@@ -26,6 +31,7 @@ function mergeAttrs(axisName, nonCommonAttrs) {
2631
valType: 'boolean',
2732
role: 'style',
2833
description: [
34+
deprecationWarning,
2935
'Determines whether or not the line bounding this',
3036
axisName, 'axis',
3137
'will be shown on the figure.'
@@ -35,6 +41,7 @@ function mergeAttrs(axisName, nonCommonAttrs) {
3541
valType: 'boolean',
3642
role: 'style',
3743
description: [
44+
deprecationWarning,
3845
'Determines whether or not the',
3946
axisName, 'axis ticks',
4047
'will feature tick labels.'
@@ -45,6 +52,7 @@ function mergeAttrs(axisName, nonCommonAttrs) {
4552
values: ['horizontal', 'vertical'],
4653
role: 'style',
4754
description: [
55+
deprecationWarning,
4856
'Sets the orientation (from the paper perspective)',
4957
'of the', axisName, 'axis tick labels.'
5058
].join(' ')
@@ -54,31 +62,36 @@ function mergeAttrs(axisName, nonCommonAttrs) {
5462
min: 0,
5563
role: 'style',
5664
description: [
65+
deprecationWarning,
5766
'Sets the length of the tick lines on this', axisName, 'axis.'
5867
].join(' ')
5968
},
6069
tickcolor: {
6170
valType: 'color',
6271
role: 'style',
6372
description: [
73+
deprecationWarning,
6474
'Sets the color of the tick lines on this', axisName, 'axis.'
6575
].join(' ')
6676
},
6777
ticksuffix: {
6878
valType: 'string',
6979
role: 'style',
7080
description: [
81+
deprecationWarning,
7182
'Sets the length of the tick lines on this', axisName, 'axis.'
7283
].join(' ')
7384
},
7485
endpadding: {
7586
valType: 'number',
76-
role: 'style'
87+
role: 'style',
88+
description: deprecationWarning,
7789
},
7890
visible: {
7991
valType: 'boolean',
8092
role: 'info',
8193
description: [
94+
deprecationWarning,
8295
'Determines whether or not this axis will be visible.'
8396
].join(' ')
8497
}
@@ -97,6 +110,7 @@ module.exports = overrideAll({
97110
{ valType: 'number' }
98111
],
99112
description: [
113+
deprecationWarning,
100114
'Defines the start and end point of this radial axis.'
101115
].join(' ')
102116
},
@@ -105,6 +119,7 @@ module.exports = overrideAll({
105119
valType: 'number',
106120
role: 'style',
107121
description: [
122+
deprecationWarning,
108123
'Sets the orientation (an angle with respect to the origin)',
109124
'of the radial axis.'
110125
].join(' ')
@@ -120,6 +135,7 @@ module.exports = overrideAll({
120135
{ valType: 'number', dflt: 360 }
121136
],
122137
description: [
138+
deprecationWarning,
123139
'Defines the start and end point of this angular axis.'
124140
].join(' ')
125141
},
@@ -133,16 +149,18 @@ module.exports = overrideAll({
133149
values: ['clockwise', 'counterclockwise'],
134150
role: 'info',
135151
description: [
136-
'For polar plots only.',
137-
'Sets the direction corresponding to positive angles.'
152+
deprecationWarning,
153+
'Sets the direction corresponding to positive angles',
154+
'in legacy polar charts.'
138155
].join(' ')
139156
},
140157
orientation: {
141158
valType: 'angle',
142159
role: 'info',
143160
description: [
144-
'For polar plots only.',
145-
'Rotates the entire polar by the given angle.'
161+
deprecationWarning,
162+
'Rotates the entire polar by the given angle',
163+
'in legacy polar charts.'
146164
].join(' ')
147165
}
148166
}

src/traces/barpolar/hover.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var Fx = require('../../components/fx');
1212
var Lib = require('../../lib');
1313
var getTraceColor = require('../bar/hover').getTraceColor;
14+
var fillHoverText = require('../scatter/fill_hover_text');
1415
var makeHoverPointText = require('../scatterpolar/hover').makeHoverPointText;
1516
var isPtInsidePolygon = require('../../plots/polar/helpers').isPtInsidePolygon;
1617

@@ -58,7 +59,8 @@ module.exports = function hoverPoints(pointData, xval, yval) {
5859
pointData.y0 = pointData.y1 = cdi.ct[1];
5960

6061
var _cdi = Lib.extendFlat({}, cdi, {r: cdi.s, theta: cdi.p});
61-
pointData.extraText = makeHoverPointText(_cdi, trace, subplot);
62+
fillHoverText(cdi, trace, pointData);
63+
makeHoverPointText(_cdi, trace, subplot, pointData);
6264
pointData.color = getTraceColor(trace, cdi);
6365
pointData.xLabelVal = pointData.yLabelVal = undefined;
6466

src/traces/barpolar/layout_defaults.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@
1111
var Lib = require('../../lib');
1212
var attrs = require('./layout_attributes');
1313

14-
module.exports = function(layoutIn, layoutOut) {
15-
var subplotIds = layoutOut._subplots.polar;
14+
module.exports = function(layoutIn, layoutOut, fullData) {
15+
var subplotsDone = {};
1616
var sp;
1717

1818
function coerce(attr, dflt) {
1919
return Lib.coerce(layoutIn[sp] || {}, layoutOut[sp], attrs, attr, dflt);
2020
}
2121

22-
for(var i = 0; i < subplotIds.length; i++) {
23-
sp = subplotIds[i];
24-
coerce('barmode');
25-
coerce('bargap');
22+
for(var i = 0; i < fullData.length; i++) {
23+
var trace = fullData[i];
24+
if(trace.type === 'barpolar' && trace.visible === true) {
25+
sp = trace.subplot;
26+
if(!subplotsDone[sp]) {
27+
coerce('barmode');
28+
coerce('bargap');
29+
subplotsDone[sp] = 1;
30+
}
31+
}
2632
}
2733
};

src/traces/scatter/attributes.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,20 @@ module.exports = {
544544
valType: 'data_array',
545545
editType: 'calc',
546546
description: [
547-
'For legacy polar chart only.',
548-
'Please switch to *scatterpolar* trace type.',
549-
'Sets the radial coordinates.'
547+
'r coordinates in scatter traces are deprecated!',
548+
'Please switch to the *scatterpolar* trace type.',
549+
'Sets the radial coordinates',
550+
'for legacy polar chart only.'
550551
].join('')
551552
},
552553
t: {
553554
valType: 'data_array',
554555
editType: 'calc',
555556
description: [
556-
'For legacy polar chart only.',
557-
'Please switch to *scatterpolar* trace type.',
558-
'Sets the angular coordinates.'
557+
't coordinates in scatter traces are deprecated!',
558+
'Please switch to the *scatterpolar* trace type.',
559+
'Sets the angular coordinates',
560+
'for legacy polar chart only.'
559561
].join('')
560562
}
561563
};

src/traces/scatterpolar/hover.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ function hoverPoints(pointData, xval, yval, hovermode) {
3131

3232
newPointData.xLabelVal = undefined;
3333
newPointData.yLabelVal = undefined;
34-
newPointData.extraText = makeHoverPointText(cdi, trace, subplot);
34+
makeHoverPointText(cdi, trace, subplot, newPointData);
3535

3636
return scatterPointData;
3737
}
3838

39-
function makeHoverPointText(cdi, trace, subplot) {
39+
function makeHoverPointText(cdi, trace, subplot, pointData) {
4040
var radialAxis = subplot.radialAxis;
4141
var angularAxis = subplot.angularAxis;
4242
var hoverinfo = cdi.hi || trace.hoverinfo;
@@ -50,7 +50,7 @@ function makeHoverPointText(cdi, trace, subplot) {
5050
text.push(ax._hovertitle + ': ' + Axes.tickText(ax, val, 'hover').text);
5151
}
5252

53-
if(parts.indexOf('all') !== -1) parts = ['r', 'theta'];
53+
if(parts.indexOf('all') !== -1) parts = ['r', 'theta', 'text'];
5454
if(parts.indexOf('r') !== -1) {
5555
textPart(radialAxis, radialAxis.c2l(cdi.r));
5656
}
@@ -61,8 +61,12 @@ function makeHoverPointText(cdi, trace, subplot) {
6161
angularAxis.thetaunit === 'degrees' ? Lib.rad2deg(theta) : theta
6262
);
6363
}
64+
if(parts.indexOf('text') !== -1 && pointData.text) {
65+
text.push(pointData.text);
66+
delete pointData.text;
67+
}
6468

65-
return text.join('<br>');
69+
pointData.extraText = text.join('<br>');
6670
}
6771

6872
module.exports = {

src/traces/scatterpolargl/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function hoverPoints(pointData, xval, yval, hovermode) {
165165

166166
newPointData.xLabelVal = undefined;
167167
newPointData.yLabelVal = undefined;
168-
newPointData.extraText = makeHoverPointText(cdi, trace, subplot);
168+
makeHoverPointText(cdi, trace, subplot, newPointData);
169169

170170
return scatterPointData;
171171
}

0 commit comments

Comments
 (0)