Skip to content

Commit 2ac3605

Browse files
committed
Modify trace modules to work with registry
1 parent 7a22cff commit 2ac3605

File tree

15 files changed

+184
-205
lines changed

15 files changed

+184
-205
lines changed

src/traces/bar/index.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,8 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Bar = {};
1513

16-
Plots.register(Bar, 'bar',
17-
['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend'], {
18-
description: [
19-
'The data visualized by the span of the bars is set in `y`',
20-
'if `orientation` is set th *v* (the default)',
21-
'and the labels are set in `x`.',
22-
23-
'By setting `orientation` to *h*, the roles are interchanged.'
24-
].join(' ')
25-
}
26-
);
27-
2814
Bar.attributes = require('./attributes');
2915
Bar.layoutAttributes = require('./layout_attributes');
3016
Bar.supplyDefaults = require('./defaults');
@@ -37,4 +23,15 @@ Bar.plot = require('./plot');
3723
Bar.style = require('./style');
3824
Bar.hoverPoints = require('./hover');
3925

26+
Bar._categories = ['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend'];
27+
Bar._type = 'bar';
28+
Bar._meta = {
29+
description: [
30+
'The data visualized by the span of the bars is set in `y`',
31+
'if `orientation` is set th *v* (the default)',
32+
'and the labels are set in `x`.',
33+
'By setting `orientation` to *h*, the roles are interchanged.'
34+
].join(' ')
35+
};
36+
4037
module.exports = Bar;

src/traces/box/index.js

+19-21
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,8 @@
88

99
'use strict';
1010

11-
var Plots = require('../../plots/plots');
12-
1311
var Box = {};
1412

15-
Plots.register(Box, 'box',
16-
['cartesian', 'symbols', 'oriented', 'box', 'showLegend'], {
17-
description: [
18-
'In vertical (horizontal) box plots,',
19-
'statistics are computed using `y` (`x`) values.',
20-
'By supplying an `x` (`y`) array, one box per distinct x (y) value',
21-
'is drawn',
22-
'If no `x` (`y`) {array} is provided, a single box is drawn.',
23-
'That box position is then positioned with',
24-
'with `name` or with `x0` (`y0`) if provided.',
25-
'Each box spans from quartile 1 (Q1) to quartile 3 (Q3).',
26-
'The second quartile (Q2) is marked by a line inside the box.',
27-
'By default, the whiskers correspond to the box\' edges',
28-
'+/- 1.5 times the interquartile range (IQR = Q3-Q1),',
29-
'see *boxpoints* for other options.'
30-
].join(' ')
31-
}
32-
);
33-
3413
Box.attributes = require('./attributes');
3514
Box.layoutAttributes = require('./layout_attributes');
3615
Box.supplyDefaults = require('./defaults');
@@ -41,4 +20,23 @@ Box.plot = require('./plot');
4120
Box.style = require('./style');
4221
Box.hoverPoints = require('./hover');
4322

23+
Box._type = 'box';
24+
Box._categories = ['cartesian', 'symbols', 'oriented', 'box', 'showLegend'];
25+
Box._meta = {
26+
description: [
27+
'In vertical (horizontal) box plots,',
28+
'statistics are computed using `y` (`x`) values.',
29+
'By supplying an `x` (`y`) array, one box per distinct x (y) value',
30+
'is drawn',
31+
'If no `x` (`y`) {array} is provided, a single box is drawn.',
32+
'That box position is then positioned with',
33+
'with `name` or with `x0` (`y0`) if provided.',
34+
'Each box spans from quartile 1 (Q1) to quartile 3 (Q3).',
35+
'The second quartile (Q2) is marked by a line inside the box.',
36+
'By default, the whiskers correspond to the box\' edges',
37+
'+/- 1.5 times the interquartile range (IQR = Q3-Q1),',
38+
'see *boxpoints* for other options.'
39+
].join(' ')
40+
};
41+
4442
module.exports = Box;

src/traces/choropleth/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Choropleth = {};
1513

16-
Plots.register(Choropleth, 'choropleth', ['geo', 'noOpacity'], {
14+
Choropleth.attributes = require('./attributes');
15+
Choropleth.supplyDefaults = require('./defaults');
16+
Choropleth.colorbar = require('../heatmap/colorbar');
17+
Choropleth.calc = require('../surface/calc');
18+
Choropleth.plot = require('./plot').plot;
19+
20+
Choropleth._type = 'choropleth';
21+
Choropleth._categories = ['geo', 'noOpacity'];
22+
Choropleth._meta = {
1723
description: [
1824
'The data that describes the choropleth value-to-color mapping',
1925
'is set in `z`.',
2026
'The geographic locations corresponding to each value in `z`',
2127
'are set in `locations`.'
2228
].join(' ')
23-
});
24-
25-
Choropleth.attributes = require('./attributes');
26-
Choropleth.supplyDefaults = require('./defaults');
27-
Choropleth.colorbar = require('../heatmap/colorbar');
28-
Choropleth.calc = require('../surface/calc');
29-
Choropleth.plot = require('./plot').plot;
29+
};
3030

3131
module.exports = Choropleth;

src/traces/contour/index.js

+15-22
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,29 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Contour = {};
1513

16-
Plots.register(Contour, 'contour',
17-
['cartesian', '2dMap', 'contour'], {
18-
description: [
19-
'The data from which contour lines are computed is set in `z`.',
20-
'Data in `z` must be a {2D array} of numbers.',
21-
22-
'Say that `z` has N rows and M columns, then by default,',
23-
'these N rows correspond to N y coordinates',
24-
'(set in `y` or auto-generated) and the M columns',
25-
'correspond to M x coordinates (set in `x` or auto-generated).',
26-
'By setting `transpose` to *true*, the above behavior is flipped.'
27-
].join(' ')
28-
});
29-
3014
Contour.attributes = require('./attributes');
31-
3215
Contour.supplyDefaults = require('./defaults');
33-
3416
Contour.calc = require('./calc');
35-
3617
Contour.plot = require('./plot');
37-
3818
Contour.style = require('./style');
39-
4019
Contour.colorbar = require('./colorbar');
41-
4220
Contour.hoverPoints = require('./hover');
4321

22+
Contour._type = 'contour';
23+
Contour._categories = ['cartesian', '2dMap', 'contour'];
24+
Contour._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.',
28+
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+
};
36+
4437
module.exports = Contour;

src/traces/heatmap/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Heatmap = {};
1513

16-
Plots.register(Heatmap, 'heatmap', ['cartesian', '2dMap'], {
14+
Heatmap.attributes = require('./attributes');
15+
Heatmap.supplyDefaults = require('./defaults');
16+
Heatmap.calc = require('./calc');
17+
Heatmap.plot = require('./plot');
18+
Heatmap.colorbar = require('./colorbar');
19+
Heatmap.style = require('./style');
20+
Heatmap.hoverPoints = require('./hover');
21+
22+
Heatmap._type = 'heatmap';
23+
Heatmap._categories = ['cartesian', '2dMap'];
24+
Heatmap._meta = {
1725
description: [
1826
'The data that describes the heatmap value-to-color mapping',
1927
'is set in `z`.',
@@ -38,14 +46,6 @@ Plots.register(Heatmap, 'heatmap', ['cartesian', '2dMap'], {
3846
'In the case where `z` is a 1D {array}, the x and y coordinates must be',
3947
'provided in `x` and `y` respectively to form data triplets.'
4048
].join(' ')
41-
});
42-
43-
Heatmap.attributes = require('./attributes');
44-
Heatmap.supplyDefaults = require('./defaults');
45-
Heatmap.calc = require('./calc');
46-
Heatmap.plot = require('./plot');
47-
Heatmap.colorbar = require('./colorbar');
48-
Heatmap.style = require('./style');
49-
Heatmap.hoverPoints = require('./hover');
49+
};
5050

5151
module.exports = Heatmap;

src/traces/histogram/index.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
/**
1513
* Histogram has its own attribute, defaults and calc steps,
1614
* but uses bar's plot to display
@@ -27,18 +25,6 @@ var Plots = require('../../plots/plots');
2725

2826
var Histogram = {};
2927

30-
Plots.register(Histogram, 'histogram',
31-
['cartesian', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'], {
32-
description: [
33-
'The sample data from which statistics are computed is set in `x`',
34-
'for vertically spanning histograms and',
35-
'in `y` for horizontally spanning histograms.',
36-
'Binning options are set `xbins` and `ybins` respectively',
37-
'if no aggregation data is provided.'
38-
].join(' ')
39-
}
40-
);
41-
4228
Histogram.attributes = require('./attributes');
4329
Histogram.layoutAttributes = require('../bar/layout_attributes');
4430
Histogram.supplyDefaults = require('./defaults');
@@ -50,4 +36,16 @@ Histogram.style = require('../bar/style');
5036
Histogram.colorbar = require('../scatter/colorbar');
5137
Histogram.hoverPoints = require('../bar/hover');
5238

39+
Histogram._type = 'histogram';
40+
Histogram._categories = ['cartesian', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'];
41+
Histogram._meta = {
42+
description: [
43+
'The sample data from which statistics are computed is set in `x`',
44+
'for vertically spanning histograms and',
45+
'in `y` for horizontally spanning histograms.',
46+
'Binning options are set `xbins` and `ybins` respectively',
47+
'if no aggregation data is provided.'
48+
].join(' ')
49+
};
50+
5351
module.exports = Histogram;

src/traces/histogram2d/index.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,8 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Histogram2D = {};
1513

16-
Plots.register(Histogram2D, 'histogram2d',
17-
['cartesian', '2dMap', 'histogram'], {
18-
hrName: 'histogram_2d',
19-
description: [
20-
'The sample data from which statistics are computed is set in `x`',
21-
'and `y` (where `x` and `y` represent marginal distributions,',
22-
'binning is set in `xbins` and `ybins` in this case)',
23-
'or `z` (where `z` represent the 2D distribution and binning set,',
24-
'binning is set by `x` and `y` in this case).',
25-
'The resulting distribution is visualized as a heatmap.'
26-
].join(' ')
27-
}
28-
);
29-
3014
Histogram2D.attributes = require('./attributes');
3115
Histogram2D.supplyDefaults = require('./defaults');
3216
Histogram2D.calc = require('../heatmap/calc');
@@ -35,4 +19,18 @@ Histogram2D.colorbar = require('../heatmap/colorbar');
3519
Histogram2D.style = require('../heatmap/style');
3620
Histogram2D.hoverPoints = require('../heatmap/hover');
3721

22+
Histogram2D._type = 'histogram2d';
23+
Histogram2D._categories = ['cartesian', '2dMap', 'histogram'];
24+
Histogram2D._meta = {
25+
hrName: 'histogram_2d',
26+
description: [
27+
'The sample data from which statistics are computed is set in `x`',
28+
'and `y` (where `x` and `y` represent marginal distributions,',
29+
'binning is set in `xbins` and `ybins` in this case)',
30+
'or `z` (where `z` represent the 2D distribution and binning set,',
31+
'binning is set by `x` and `y` in this case).',
32+
'The resulting distribution is visualized as a heatmap.'
33+
].join(' ')
34+
};
35+
3836
module.exports = Histogram2D;

src/traces/histogram2dcontour/index.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,8 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Histogram2dContour = {};
1513

16-
Plots.register(Histogram2dContour, 'histogram2dcontour',
17-
['cartesian', '2dMap', 'contour', 'histogram'], {
18-
hrName: 'histogram_2d_contour',
19-
description: [
20-
'The sample data from which statistics are computed is set in `x`',
21-
'and `y` (where `x` and `y` represent marginal distributions,',
22-
'binning is set in `xbins` and `ybins` in this case)',
23-
'or `z` (where `z` represent the 2D distribution and binning set,',
24-
'binning is set by `x` and `y` in this case).',
25-
'The resulting distribution is visualized as a contour plot.'
26-
].join(' ')
27-
}
28-
);
29-
3014
Histogram2dContour.attributes = require('./attributes');
3115
Histogram2dContour.supplyDefaults = require('./defaults');
3216
Histogram2dContour.calc = require('../contour/calc');
@@ -35,4 +19,18 @@ Histogram2dContour.style = require('../contour/style');
3519
Histogram2dContour.colorbar = require('../contour/colorbar');
3620
Histogram2dContour.hoverPoints = require('../contour/hover');
3721

22+
Histogram2dContour._type = 'histogram2dcontour';
23+
Histogram2dContour._categories = ['cartesian', '2dMap', 'contour', 'histogram'];
24+
Histogram2dContour._meta = {
25+
hrName: 'histogram_2d_contour',
26+
description: [
27+
'The sample data from which statistics are computed is set in `x`',
28+
'and `y` (where `x` and `y` represent marginal distributions,',
29+
'binning is set in `xbins` and `ybins` in this case)',
30+
'or `z` (where `z` represent the 2D distribution and binning set,',
31+
'binning is set by `x` and `y` in this case).',
32+
'The resulting distribution is visualized as a contour plot.'
33+
].join(' ')
34+
};
35+
3836
module.exports = Histogram2dContour;

src/traces/mesh3d/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
1412
var Mesh3D = {};
1513

16-
Plots.register(Mesh3D, 'mesh3d', ['gl3d'], {
14+
Mesh3D.attributes = require('./attributes');
15+
Mesh3D.supplyDefaults = require('./defaults');
16+
Mesh3D.colorbar = require('../heatmap/colorbar');
17+
Mesh3D.plot = require('./convert');
18+
19+
Mesh3D._type = 'mesh3d',
20+
Mesh3D._categories = ['gl3d'];
21+
Mesh3D._meta = {
1722
description: [
1823
'Draws sets of triangles with coordinates given by',
1924
'three 1-dimensional arrays in `x`, `y`, `z` and',
@@ -22,11 +27,6 @@ Plots.register(Mesh3D, 'mesh3d', ['gl3d'], {
2227
'(3) the Alpha-shape algorithm or',
2328
'(4) the Convex-hull algorithm'
2429
].join(' ')
25-
});
26-
27-
Mesh3D.attributes = require('./attributes');
28-
Mesh3D.supplyDefaults = require('./defaults');
29-
Mesh3D.colorbar = require('../heatmap/colorbar');
30-
Mesh3D.plot = require('./convert');
30+
};
3131

3232
module.exports = Mesh3D;

0 commit comments

Comments
 (0)