Skip to content

Commit 73fd580

Browse files
authored
Merge pull request #5956 from plotly/smith-prototype
Introduce `smith` subplot and `scattersmith` trace type
2 parents c35da03 + cfa96e5 commit 73fd580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+5041
-649
lines changed

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Plotly.register([
5050
require('./scatterpolar'),
5151
require('./scatterpolargl'),
5252
require('./barpolar'),
53+
require('./scattersmith'),
5354

5455
// transforms
5556
require('./aggregate'),

lib/scattersmith.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = require('../src/traces/scattersmith');

src/components/modebar/manage.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function getButtonGroups(gd) {
110110
var hasTernary = fullLayout._has('ternary');
111111
var hasMapbox = fullLayout._has('mapbox');
112112
var hasPolar = fullLayout._has('polar');
113+
var hasSmith = fullLayout._has('smith');
113114
var hasSankey = fullLayout._has('sankey');
114115
var allAxesFixed = areAllAxesFixed(fullLayout);
115116
var hasUnifiedHoverLabel = isUnifiedHover(fullLayout.hovermode);
@@ -152,7 +153,7 @@ function getButtonGroups(gd) {
152153
var resetGroup = [];
153154
var dragModeGroup = [];
154155

155-
if((hasCartesian || hasGL2D || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) {
156+
if((hasCartesian || hasGL2D || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar + hasSmith > 1) {
156157
// graphs with more than one plot types get 'union buttons'
157158
// which reset the view or toggle hover labels across all subplots.
158159
hoverGroup = ['toggleHover'];
@@ -175,7 +176,7 @@ function getButtonGroups(gd) {
175176
} else if(hasSankey) {
176177
hoverGroup = ['hoverClosestCartesian', 'hoverCompareCartesian'];
177178
resetGroup = ['resetViewSankey'];
178-
} else { // hasPolar, hasTernary
179+
} else { // hasPolar, hasSmith, hasTernary
179180
// always show at least one hover icon.
180181
hoverGroup = ['toggleHover'];
181182
}

src/plot_api/plot_api.js

+3
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,9 @@ function makePlotFramework(gd) {
37293729
// single polar layer for the whole plot
37303730
fullLayout._polarlayer = fullLayout._paper.append('g').classed('polarlayer', true);
37313731

3732+
// single smith layer for the whole plot
3733+
fullLayout._smithlayer = fullLayout._paper.append('g').classed('smithlayer', true);
3734+
37323735
// single ternary layer for the whole plot
37333736
fullLayout._ternarylayer = fullLayout._paper.append('g').classed('ternarylayer', true);
37343737

src/plots/cartesian/axes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ function formatDate(ax, out, hover, extraPrecision) {
14621462
dateStr += '<br>' + headStr;
14631463
} else {
14641464
var isInside = insideTicklabelposition(ax);
1465-
var side = ax._realSide || ax.side; // polar mocks the side of the radial axis
1465+
var side = ax._trueSide || ax.side; // polar mocks the side of the radial axis
14661466
if(
14671467
(!isInside && side === 'top') ||
14681468
(isInside && side === 'bottom')
@@ -3269,7 +3269,7 @@ axes.drawLabels = function(gd, ax, opts) {
32693269
var pad = !isAligned ? 0 :
32703270
(ax.tickwidth || 0) + 2 * TEXTPAD;
32713271

3272-
var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory';
3272+
var rotate90 = (tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory' || ax._name === 'realaxis';
32733273

32743274
// any overlap at all - set 30 degrees or 90 degrees
32753275
for(i = 0; i < lbbArray.length - 1; i++) {

src/plots/cartesian/set_convert.js

+1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ module.exports = function setConvert(ax, fullLayout) {
449449

450450
if(ax.type === 'date') dflt = Lib.dfltRange(ax.calendar);
451451
else if(axLetter === 'y') dflt = constants.DFLTRANGEY;
452+
else if(ax._name === 'realaxis') dflt = [0, 1];
452453
else dflt = opts.dfltRange || constants.DFLTRANGEX;
453454

454455
// make sure we don't later mutate the defaults

src/plots/cartesian/tick_label_defaults.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
2727
size: font.size,
2828
color: dfltFontColor
2929
});
30-
coerce('tickangle');
30+
31+
if(!options.noAng) coerce('tickangle');
3132

3233
if(axType !== 'category') {
3334
var tickFormat = coerce('tickformat');
@@ -41,7 +42,7 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
4142
delete containerOut.tickformatstops;
4243
}
4344

44-
if(!tickFormat && axType !== 'date') {
45+
if(!options.noExp && !tickFormat && axType !== 'date') {
4546
coerce('showexponent', showAttrDflt);
4647
coerce('exponentformat');
4748
coerce('minexponent');

src/plots/cartesian/tick_mark_defaults.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var layoutAttributes = require('./layout_attributes');
88
/**
99
* options: inherits outerTicks from axes.handleAxisDefaults
1010
*/
11-
module.exports = function handleTickDefaults(containerIn, containerOut, coerce, options) {
11+
module.exports = function handleTickMarkDefaults(containerIn, containerOut, coerce, options) {
1212
var tickLen = Lib.coerce2(containerIn, containerOut, layoutAttributes, 'ticklen');
1313
var tickWidth = Lib.coerce2(containerIn, containerOut, layoutAttributes, 'tickwidth');
1414
var tickColor = Lib.coerce2(containerIn, containerOut, layoutAttributes, 'tickcolor', containerOut.color);

src/plots/polar/layout_defaults.js

+31-32
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
6262

6363
coerceAxis('uirevision', contOut.uirevision);
6464

65-
var dfltColor;
66-
var dfltFontColor;
67-
68-
if(visible) {
69-
dfltColor = coerceAxis('color');
70-
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : opts.font.color;
71-
}
72-
7365
// We don't want to make downstream code call ax.setScale,
7466
// as both radial and angular axes don't have a set domain.
7567
// Furthermore, angular axes don't have a set range.
@@ -91,18 +83,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
9183

9284
coerceAxis('range');
9385
axOut.cleanRange('range', {dfltRange: [0, 1]});
94-
95-
if(visible) {
96-
coerceAxis('side');
97-
coerceAxis('angle', sector[0]);
98-
99-
coerceAxis('title.text');
100-
Lib.coerceFont(coerceAxis, 'title.font', {
101-
family: opts.font.family,
102-
size: Lib.bigFont(opts.font.size),
103-
color: dfltFontColor
104-
});
105-
}
10686
break;
10787

10888
case 'angularaxis':
@@ -142,20 +122,27 @@ function handleDefaults(contIn, contOut, coerce, opts) {
142122
});
143123

144124
if(visible) {
125+
var dfltColor;
126+
var dfltFontColor;
127+
var dfltFontSize;
128+
var dfltFontFamily;
129+
var font = opts.font || {};
130+
131+
dfltColor = coerceAxis('color');
132+
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : font.color;
133+
dfltFontSize = font.size;
134+
dfltFontFamily = font.family;
135+
145136
handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
146-
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type);
147-
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
137+
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
138+
font: {
139+
color: dfltFontColor,
140+
size: dfltFontSize,
141+
family: dfltFontFamily
142+
}
143+
});
148144

149-
var showTickLabels = coerceAxis('showticklabels');
150-
if(showTickLabels) {
151-
Lib.coerceFont(coerceAxis, 'tickfont', {
152-
family: opts.font.family,
153-
size: opts.font.size,
154-
color: dfltFontColor
155-
});
156-
coerceAxis('tickangle');
157-
coerceAxis('tickformat');
158-
}
145+
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
159146

160147
handleLineGridDefaults(axIn, axOut, coerceAxis, {
161148
dfltColor: dfltColor,
@@ -170,6 +157,18 @@ function handleDefaults(contIn, contOut, coerce, opts) {
170157
});
171158

172159
coerceAxis('layer');
160+
161+
if(axName === 'radialaxis') {
162+
coerceAxis('side');
163+
coerceAxis('angle', sector[0]);
164+
165+
coerceAxis('title.text');
166+
Lib.coerceFont(coerceAxis, 'title.font', {
167+
color: dfltFontColor,
168+
size: Lib.bigFont(dfltFontSize),
169+
family: dfltFontFamily
170+
});
171+
}
173172
}
174173

175174
if(axType !== 'category') coerceAxis('hoverformat');

0 commit comments

Comments
 (0)