Skip to content

Commit 4529fe9

Browse files
authored
Merge pull request #3804 from plotly/trace-indices
Refactor traces index exports
2 parents 54fe6e9 + 48e2461 commit 4529fe9

File tree

28 files changed

+664
-736
lines changed

28 files changed

+664
-736
lines changed

Diff for: src/traces/box/index.js

+34-36
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,39 @@
88

99
'use strict';
1010

11-
var Box = {};
11+
module.exports = {
12+
attributes: require('./attributes'),
13+
layoutAttributes: require('./layout_attributes'),
14+
supplyDefaults: require('./defaults').supplyDefaults,
15+
crossTraceDefaults: require('./defaults').crossTraceDefaults,
16+
supplyLayoutDefaults: require('./layout_defaults').supplyLayoutDefaults,
17+
calc: require('./calc'),
18+
crossTraceCalc: require('./cross_trace_calc').crossTraceCalc,
19+
plot: require('./plot').plot,
20+
style: require('./style').style,
21+
styleOnSelect: require('./style').styleOnSelect,
22+
hoverPoints: require('./hover').hoverPoints,
23+
eventData: require('./event_data'),
24+
selectPoints: require('./select'),
1225

13-
Box.attributes = require('./attributes');
14-
Box.layoutAttributes = require('./layout_attributes');
15-
Box.supplyDefaults = require('./defaults').supplyDefaults;
16-
Box.crossTraceDefaults = require('./defaults').crossTraceDefaults;
17-
Box.supplyLayoutDefaults = require('./layout_defaults').supplyLayoutDefaults;
18-
Box.calc = require('./calc');
19-
Box.crossTraceCalc = require('./cross_trace_calc').crossTraceCalc;
20-
Box.plot = require('./plot').plot;
21-
Box.style = require('./style').style;
22-
Box.styleOnSelect = require('./style').styleOnSelect;
23-
Box.hoverPoints = require('./hover').hoverPoints;
24-
Box.eventData = require('./event_data');
25-
Box.selectPoints = require('./select');
26-
27-
Box.moduleType = 'trace';
28-
Box.name = 'box';
29-
Box.basePlotModule = require('../../plots/cartesian');
30-
Box.categories = ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'boxLayout', 'zoomScale'];
31-
Box.meta = {
32-
description: [
33-
'In vertical (horizontal) box plots,',
34-
'statistics are computed using `y` (`x`) values.',
35-
'By supplying an `x` (`y`) array, one box per distinct x (y) value',
36-
'is drawn',
37-
'If no `x` (`y`) {array} is provided, a single box is drawn.',
38-
'That box position is then positioned with',
39-
'with `name` or with `x0` (`y0`) if provided.',
40-
'Each box spans from quartile 1 (Q1) to quartile 3 (Q3).',
41-
'The second quartile (Q2) is marked by a line inside the box.',
42-
'By default, the whiskers correspond to the box\' edges',
43-
'+/- 1.5 times the interquartile range (IQR = Q3-Q1),',
44-
'see *boxpoints* for other options.'
45-
].join(' ')
26+
moduleType: 'trace',
27+
name: 'box',
28+
basePlotModule: require('../../plots/cartesian'),
29+
categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'boxLayout', 'zoomScale'],
30+
meta: {
31+
description: [
32+
'In vertical (horizontal) box plots,',
33+
'statistics are computed using `y` (`x`) values.',
34+
'By supplying an `x` (`y`) array, one box per distinct x (y) value',
35+
'is drawn',
36+
'If no `x` (`y`) {array} is provided, a single box is drawn.',
37+
'That box position is then positioned with',
38+
'with `name` or with `x0` (`y0`) if provided.',
39+
'Each box spans from quartile 1 (Q1) to quartile 3 (Q3).',
40+
'The second quartile (Q2) is marked by a line inside the box.',
41+
'By default, the whiskers correspond to the box\' edges',
42+
'+/- 1.5 times the interquartile range (IQR: Q3-Q1),',
43+
'see *boxpoints* for other options.'
44+
].join(' ')
45+
}
4646
};
47-
48-
module.exports = Box;

Diff for: src/traces/carpet/index.js

+21-24
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,29 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

12-
var Carpet = {};
13-
14-
Carpet.attributes = require('./attributes');
15-
Carpet.supplyDefaults = require('./defaults');
16-
Carpet.plot = require('./plot');
17-
Carpet.calc = require('./calc');
18-
Carpet.animatable = true;
19-
Carpet.isContainer = true; // so carpet traces get `calc` before other traces
11+
module.exports = {
12+
attributes: require('./attributes'),
13+
supplyDefaults: require('./defaults'),
14+
plot: require('./plot'),
15+
calc: require('./calc'),
16+
animatable: true,
17+
isContainer: true, // so carpet traces get `calc` before other traces
2018

21-
Carpet.moduleType = 'trace';
22-
Carpet.name = 'carpet';
23-
Carpet.basePlotModule = require('../../plots/cartesian');
24-
Carpet.categories = ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable', 'noMultiCategory'];
25-
Carpet.meta = {
26-
description: [
27-
'The data describing carpet axis layout is set in `y` and (optionally)',
28-
'also `x`. If only `y` is present, `x` the plot is interpreted as a',
29-
'cheater plot and is filled in using the `y` values.',
19+
moduleType: 'trace',
20+
name: 'carpet',
21+
basePlotModule: require('../../plots/cartesian'),
22+
categories: ['cartesian', 'svg', 'carpet', 'carpetAxis', 'notLegendIsolatable', 'noMultiCategory'],
23+
meta: {
24+
description: [
25+
'The data describing carpet axis layout is set in `y` and (optionally)',
26+
'also `x`. If only `y` is present, `x` the plot is interpreted as a',
27+
'cheater plot and is filled in using the `y` values.',
3028

31-
'`x` and `y` may either be 2D arrays matching with each dimension matching',
32-
'that of `a` and `b`, or they may be 1D arrays with total length equal to',
33-
'that of `a` and `b`.'
34-
].join(' ')
29+
'`x` and `y` may either be 2D arrays matching with each dimension matching',
30+
'that of `a` and `b`, or they may be 1D arrays with total length equal to',
31+
'that of `a` and `b`.'
32+
].join(' ')
33+
}
3534
};
36-
37-
module.exports = Carpet;

Diff for: src/traces/choropleth/index.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,30 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

12-
var Choropleth = {};
13-
14-
Choropleth.attributes = require('./attributes');
15-
Choropleth.supplyDefaults = require('./defaults');
16-
Choropleth.colorbar = require('../heatmap/colorbar');
17-
Choropleth.calc = require('./calc');
18-
Choropleth.plot = require('./plot');
19-
Choropleth.style = require('./style').style;
20-
Choropleth.styleOnSelect = require('./style').styleOnSelect;
21-
Choropleth.hoverPoints = require('./hover');
22-
Choropleth.eventData = require('./event_data');
23-
Choropleth.selectPoints = require('./select');
11+
module.exports = {
12+
attributes: require('./attributes'),
13+
supplyDefaults: require('./defaults'),
14+
colorbar: require('../heatmap/colorbar'),
15+
calc: require('./calc'),
16+
plot: require('./plot'),
17+
style: require('./style').style,
18+
styleOnSelect: require('./style').styleOnSelect,
19+
hoverPoints: require('./hover'),
20+
eventData: require('./event_data'),
21+
selectPoints: require('./select'),
2422

25-
Choropleth.moduleType = 'trace';
26-
Choropleth.name = 'choropleth';
27-
Choropleth.basePlotModule = require('../../plots/geo');
28-
Choropleth.categories = ['geo', 'noOpacity'];
29-
Choropleth.meta = {
30-
description: [
31-
'The data that describes the choropleth value-to-color mapping',
32-
'is set in `z`.',
33-
'The geographic locations corresponding to each value in `z`',
34-
'are set in `locations`.'
35-
].join(' ')
23+
moduleType: 'trace',
24+
name: 'choropleth',
25+
basePlotModule: require('../../plots/geo'),
26+
categories: ['geo', 'noOpacity'],
27+
meta: {
28+
description: [
29+
'The data that describes the choropleth value-to-color mapping',
30+
'is set in `z`.',
31+
'The geographic locations corresponding to each value in `z`',
32+
'are set in `locations`.'
33+
].join(' ')
34+
}
3635
};
37-
38-
module.exports = Choropleth;

Diff for: src/traces/contour/index.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,31 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

12-
var Contour = {};
13-
14-
Contour.attributes = require('./attributes');
15-
Contour.supplyDefaults = require('./defaults');
16-
Contour.calc = require('./calc');
17-
Contour.plot = require('./plot').plot;
18-
Contour.style = require('./style');
19-
Contour.colorbar = require('./colorbar');
20-
Contour.hoverPoints = require('./hover');
11+
module.exports = {
12+
attributes: require('./attributes'),
13+
supplyDefaults: require('./defaults'),
14+
calc: require('./calc'),
15+
plot: require('./plot').plot,
16+
style: require('./style'),
17+
colorbar: require('./colorbar'),
18+
hoverPoints: require('./hover'),
2119

22-
Contour.moduleType = 'trace';
23-
Contour.name = 'contour';
24-
Contour.basePlotModule = require('../../plots/cartesian');
25-
Contour.categories = ['cartesian', 'svg', '2dMap', 'contour', 'showLegend'];
26-
Contour.meta = {
27-
description: [
28-
'The data from which contour lines are computed is set in `z`.',
29-
'Data in `z` must be a {2D array} of numbers.',
20+
moduleType: 'trace',
21+
name: 'contour',
22+
basePlotModule: require('../../plots/cartesian'),
23+
categories: ['cartesian', 'svg', '2dMap', 'contour', 'showLegend'],
24+
meta: {
25+
description: [
26+
'The data from which contour lines are computed is set in `z`.',
27+
'Data in `z` must be a {2D array} of numbers.',
3028

31-
'Say that `z` has N rows and M columns, then by default,',
32-
'these N rows correspond to N y coordinates',
33-
'(set in `y` or auto-generated) and the M columns',
34-
'correspond to M x coordinates (set in `x` or auto-generated).',
35-
'By setting `transpose` to *true*, the above behavior is flipped.'
36-
].join(' ')
29+
'Say that `z` has N rows and M columns, then by default,',
30+
'these N rows correspond to N y coordinates',
31+
'(set in `y` or auto-generated) and the M columns',
32+
'correspond to M x coordinates (set in `x` or auto-generated).',
33+
'By setting `transpose` to *true*, the above behavior is flipped.'
34+
].join(' ')
35+
}
3736
};
38-
39-
module.exports = Contour;

Diff for: src/traces/contourcarpet/index.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,25 @@
88

99
'use strict';
1010

11-
var ContourCarpet = {};
11+
module.exports = {
12+
attributes: require('./attributes'),
13+
supplyDefaults: require('./defaults'),
14+
colorbar: require('../contour/colorbar'),
15+
calc: require('./calc'),
16+
plot: require('./plot'),
17+
style: require('../contour/style'),
1218

13-
ContourCarpet.attributes = require('./attributes');
14-
ContourCarpet.supplyDefaults = require('./defaults');
15-
ContourCarpet.colorbar = require('../contour/colorbar');
16-
ContourCarpet.calc = require('./calc');
17-
ContourCarpet.plot = require('./plot');
18-
ContourCarpet.style = require('../contour/style');
19-
20-
ContourCarpet.moduleType = 'trace';
21-
ContourCarpet.name = 'contourcarpet';
22-
ContourCarpet.basePlotModule = require('../../plots/cartesian');
23-
ContourCarpet.categories = ['cartesian', 'svg', 'carpet', 'contour', 'symbols', 'showLegend', 'hasLines', 'carpetDependent'];
24-
ContourCarpet.meta = {
25-
hrName: 'contour_carpet',
26-
description: [
27-
'Plots contours on either the first carpet axis or the',
28-
'carpet axis with a matching `carpet` attribute. Data `z`',
29-
'is interpreted as matching that of the corresponding carpet',
30-
'axis.'
31-
].join(' ')
19+
moduleType: 'trace',
20+
name: 'contourcarpet',
21+
basePlotModule: require('../../plots/cartesian'),
22+
categories: ['cartesian', 'svg', 'carpet', 'contour', 'symbols', 'showLegend', 'hasLines', 'carpetDependent'],
23+
meta: {
24+
hrName: 'contour_carpet',
25+
description: [
26+
'Plots contours on either the first carpet axis or the',
27+
'carpet axis with a matching `carpet` attribute. Data `z`',
28+
'is interpreted as matching that of the corresponding carpet',
29+
'axis.'
30+
].join(' ')
31+
}
3232
};
33-
34-
module.exports = ContourCarpet;

Diff for: src/traces/contourgl/index.js

+17-20
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var overrideAll = require('../../plot_api/edit_types').overrideAll;
1312

14-
var ContourGl = {};
15-
16-
ContourGl.attributes = overrideAll(require('../contour/attributes'), 'calc', 'nested');
17-
ContourGl.supplyDefaults = require('../contour/defaults');
18-
ContourGl.colorbar = require('../contour/colorbar');
19-
20-
ContourGl.calc = require('../contour/calc');
21-
ContourGl.plot = require('./convert');
22-
23-
ContourGl.moduleType = 'trace';
24-
ContourGl.name = 'contourgl';
25-
ContourGl.basePlotModule = require('../../plots/gl2d');
26-
ContourGl.categories = ['gl', 'gl2d', '2dMap'];
27-
ContourGl.meta = {
28-
description: [
29-
'WebGL contour (beta)'
30-
].join(' ')
13+
module.exports = {
14+
attributes: overrideAll(require('../contour/attributes'), 'calc', 'nested'),
15+
supplyDefaults: require('../contour/defaults'),
16+
colorbar: require('../contour/colorbar'),
17+
18+
calc: require('../contour/calc'),
19+
plot: require('./convert'),
20+
21+
moduleType: 'trace',
22+
name: 'contourgl',
23+
basePlotModule: require('../../plots/gl2d'),
24+
categories: ['gl', 'gl2d', '2dMap'],
25+
meta: {
26+
description: [
27+
'WebGL contour (beta)'
28+
].join(' ')
29+
}
3130
};
32-
33-
module.exports = ContourGl;

0 commit comments

Comments
 (0)