Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7e41625
Removed reference to Plotly
mdtusz Jan 8, 2016
b716568
Removed more references to Plotly
mdtusz Jan 11, 2016
d639a93
Change `module` to `_module`
mdtusz Jan 11, 2016
356d0af
Change `Plotly.Lib` to `Lib`
mdtusz Jan 11, 2016
7a22cff
Modify trace modules to all follow the same format, exporing `plot`
mdtusz Jan 12, 2016
2ac3605
Modify trace modules to work with registry
mdtusz Jan 13, 2016
6e53762
Update tests to require trace modules directly
mdtusz Jan 13, 2016
46b83d8
Modify index and plotly to have register func and traces registered
mdtusz Jan 13, 2016
23519f0
Require pie trace module directly
mdtusz Jan 13, 2016
71db785
Plot register function warns instead of throwing error
mdtusz Jan 13, 2016
06640b4
Update plotting calls to work agnostically using registered modules
mdtusz Jan 13, 2016
4507ec5
Fix eslint warnings for multiple var declarations
mdtusz Jan 13, 2016
6bd4c5b
Removed reference to Plotly
mdtusz Jan 8, 2016
b4793c1
Removed more references to Plotly
mdtusz Jan 11, 2016
48b3803
Change `module` to `_module`
mdtusz Jan 11, 2016
5a2da5c
Change `Plotly.Lib` to `Lib`
mdtusz Jan 11, 2016
4fe8440
Modify trace modules to all follow the same format, exporing `plot`
mdtusz Jan 12, 2016
e46373e
Modify trace modules to work with registry
mdtusz Jan 13, 2016
a7fda91
Update tests to require trace modules directly
mdtusz Jan 13, 2016
43156a3
Modify index and plotly to have register func and traces registered
mdtusz Jan 13, 2016
03232e0
Require pie trace module directly
mdtusz Jan 13, 2016
28def12
Plot register function warns instead of throwing error
mdtusz Jan 13, 2016
f831b66
Update plotting calls to work agnostically using registered modules
mdtusz Jan 13, 2016
4994256
Fix eslint warnings for multiple var declarations
mdtusz Jan 13, 2016
6dd9a41
Fix undefined reference
mdtusz Jan 13, 2016
823ae72
Merge branch 'agnostic-geo-trace' of github.com:plotly/plotly.js into…
mdtusz Jan 13, 2016
75dc282
Change fields used by module registry
mdtusz Jan 14, 2016
b8864eb
Require styleOne directly
mdtusz Jan 14, 2016
5f26169
Use Object.keys instead of for-in
mdtusz Jan 14, 2016
a693bb2
Change register function and add test
mdtusz Jan 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modify trace modules to work with registry
  • Loading branch information
mdtusz committed Jan 13, 2016
commit 2ac3605eb4da33f0aa3fcb698afda9228ab96597
25 changes: 11 additions & 14 deletions src/traces/bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,8 @@

'use strict';

var Plots = require('../../plots/plots');

var Bar = {};

Plots.register(Bar, 'bar',
['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend'], {
description: [
'The data visualized by the span of the bars is set in `y`',
'if `orientation` is set th *v* (the default)',
'and the labels are set in `x`.',

'By setting `orientation` to *h*, the roles are interchanged.'
].join(' ')
}
);

Bar.attributes = require('./attributes');
Bar.layoutAttributes = require('./layout_attributes');
Bar.supplyDefaults = require('./defaults');
Expand All @@ -37,4 +23,15 @@ Bar.plot = require('./plot');
Bar.style = require('./style');
Bar.hoverPoints = require('./hover');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much cleaner than my exports. stack. 🍻


Bar._categories = ['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend'];
Bar._type = 'bar';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used name (e.g. here) to name to the plot modules.

Though traces are identified by type. Not sure what's best.

Bar._meta = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor point, do we need these _?

None of the trace modules are public (as in standalone objects that users could use directly). Why do need to make a distinction between e.g the plot method and the categories properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I used the _ mainly because they're static properties that should only really be used by register, whereas the other parts vary from module to module and get used elsewhere, but we could go either way. Up to you.

description: [
'The data visualized by the span of the bars is set in `y`',
'if `orientation` is set th *v* (the default)',
'and the labels are set in `x`.',
'By setting `orientation` to *h*, the roles are interchanged.'
].join(' ')
};

module.exports = Bar;
40 changes: 19 additions & 21 deletions src/traces/box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,8 @@

'use strict';

var Plots = require('../../plots/plots');

var Box = {};

Plots.register(Box, 'box',
['cartesian', 'symbols', 'oriented', 'box', 'showLegend'], {
description: [
'In vertical (horizontal) box plots,',
'statistics are computed using `y` (`x`) values.',
'By supplying an `x` (`y`) array, one box per distinct x (y) value',
'is drawn',
'If no `x` (`y`) {array} is provided, a single box is drawn.',
'That box position is then positioned with',
'with `name` or with `x0` (`y0`) if provided.',
'Each box spans from quartile 1 (Q1) to quartile 3 (Q3).',
'The second quartile (Q2) is marked by a line inside the box.',
'By default, the whiskers correspond to the box\' edges',
'+/- 1.5 times the interquartile range (IQR = Q3-Q1),',
'see *boxpoints* for other options.'
].join(' ')
}
);

Box.attributes = require('./attributes');
Box.layoutAttributes = require('./layout_attributes');
Box.supplyDefaults = require('./defaults');
Expand All @@ -41,4 +20,23 @@ Box.plot = require('./plot');
Box.style = require('./style');
Box.hoverPoints = require('./hover');

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

module.exports = Box;
20 changes: 10 additions & 10 deletions src/traces/choropleth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@

'use strict';

var Plots = require('../../plots/plots');

var Choropleth = {};

Plots.register(Choropleth, 'choropleth', ['geo', 'noOpacity'], {
Choropleth.attributes = require('./attributes');
Choropleth.supplyDefaults = require('./defaults');
Choropleth.colorbar = require('../heatmap/colorbar');
Choropleth.calc = require('../surface/calc');
Choropleth.plot = require('./plot').plot;

Choropleth._type = 'choropleth';
Choropleth._categories = ['geo', 'noOpacity'];
Choropleth._meta = {
description: [
'The data that describes the choropleth value-to-color mapping',
'is set in `z`.',
'The geographic locations corresponding to each value in `z`',
'are set in `locations`.'
].join(' ')
});

Choropleth.attributes = require('./attributes');
Choropleth.supplyDefaults = require('./defaults');
Choropleth.colorbar = require('../heatmap/colorbar');
Choropleth.calc = require('../surface/calc');
Choropleth.plot = require('./plot').plot;
};

module.exports = Choropleth;
37 changes: 15 additions & 22 deletions src/traces/contour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,29 @@

'use strict';

var Plots = require('../../plots/plots');

var Contour = {};

Plots.register(Contour, 'contour',
['cartesian', '2dMap', 'contour'], {
description: [
'The data from which contour lines are computed is set in `z`.',
'Data in `z` must be a {2D array} of numbers.',

'Say that `z` has N rows and M columns, then by default,',
'these N rows correspond to N y coordinates',
'(set in `y` or auto-generated) and the M columns',
'correspond to M x coordinates (set in `x` or auto-generated).',
'By setting `transpose` to *true*, the above behavior is flipped.'
].join(' ')
});

Contour.attributes = require('./attributes');

Contour.supplyDefaults = require('./defaults');

Contour.calc = require('./calc');

Contour.plot = require('./plot');

Contour.style = require('./style');

Contour.colorbar = require('./colorbar');

Contour.hoverPoints = require('./hover');

Contour._type = 'contour';
Contour._categories = ['cartesian', '2dMap', 'contour'];
Contour._meta = {
description: [
'The data from which contour lines are computed is set in `z`.',
'Data in `z` must be a {2D array} of numbers.',

'Say that `z` has N rows and M columns, then by default,',
'these N rows correspond to N y coordinates',
'(set in `y` or auto-generated) and the M columns',
'correspond to M x coordinates (set in `x` or auto-generated).',
'By setting `transpose` to *true*, the above behavior is flipped.'
].join(' ')
};

module.exports = Contour;
24 changes: 12 additions & 12 deletions src/traces/heatmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@

'use strict';

var Plots = require('../../plots/plots');

var Heatmap = {};

Plots.register(Heatmap, 'heatmap', ['cartesian', '2dMap'], {
Heatmap.attributes = require('./attributes');
Heatmap.supplyDefaults = require('./defaults');
Heatmap.calc = require('./calc');
Heatmap.plot = require('./plot');
Heatmap.colorbar = require('./colorbar');
Heatmap.style = require('./style');
Heatmap.hoverPoints = require('./hover');

Heatmap._type = 'heatmap';
Heatmap._categories = ['cartesian', '2dMap'];
Heatmap._meta = {
description: [
'The data that describes the heatmap value-to-color mapping',
'is set in `z`.',
Expand All @@ -38,14 +46,6 @@ Plots.register(Heatmap, 'heatmap', ['cartesian', '2dMap'], {
'In the case where `z` is a 1D {array}, the x and y coordinates must be',
'provided in `x` and `y` respectively to form data triplets.'
].join(' ')
});

Heatmap.attributes = require('./attributes');
Heatmap.supplyDefaults = require('./defaults');
Heatmap.calc = require('./calc');
Heatmap.plot = require('./plot');
Heatmap.colorbar = require('./colorbar');
Heatmap.style = require('./style');
Heatmap.hoverPoints = require('./hover');
};

module.exports = Heatmap;
26 changes: 12 additions & 14 deletions src/traces/histogram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

'use strict';

var Plots = require('../../plots/plots');

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

var Histogram = {};

Plots.register(Histogram, 'histogram',
['cartesian', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'], {
description: [
'The sample data from which statistics are computed is set in `x`',
'for vertically spanning histograms and',
'in `y` for horizontally spanning histograms.',
'Binning options are set `xbins` and `ybins` respectively',
'if no aggregation data is provided.'
].join(' ')
}
);

Histogram.attributes = require('./attributes');
Histogram.layoutAttributes = require('../bar/layout_attributes');
Histogram.supplyDefaults = require('./defaults');
Expand All @@ -50,4 +36,16 @@ Histogram.style = require('../bar/style');
Histogram.colorbar = require('../scatter/colorbar');
Histogram.hoverPoints = require('../bar/hover');

Histogram._type = 'histogram';
Histogram._categories = ['cartesian', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'];
Histogram._meta = {
description: [
'The sample data from which statistics are computed is set in `x`',
'for vertically spanning histograms and',
'in `y` for horizontally spanning histograms.',
'Binning options are set `xbins` and `ybins` respectively',
'if no aggregation data is provided.'
].join(' ')
};

module.exports = Histogram;
30 changes: 14 additions & 16 deletions src/traces/histogram2d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,8 @@

'use strict';

var Plots = require('../../plots/plots');

var Histogram2D = {};

Plots.register(Histogram2D, 'histogram2d',
['cartesian', '2dMap', 'histogram'], {
hrName: 'histogram_2d',
description: [
'The sample data from which statistics are computed is set in `x`',
'and `y` (where `x` and `y` represent marginal distributions,',
'binning is set in `xbins` and `ybins` in this case)',
'or `z` (where `z` represent the 2D distribution and binning set,',
'binning is set by `x` and `y` in this case).',
'The resulting distribution is visualized as a heatmap.'
].join(' ')
}
);

Histogram2D.attributes = require('./attributes');
Histogram2D.supplyDefaults = require('./defaults');
Histogram2D.calc = require('../heatmap/calc');
Expand All @@ -35,4 +19,18 @@ Histogram2D.colorbar = require('../heatmap/colorbar');
Histogram2D.style = require('../heatmap/style');
Histogram2D.hoverPoints = require('../heatmap/hover');

Histogram2D._type = 'histogram2d';
Histogram2D._categories = ['cartesian', '2dMap', 'histogram'];
Histogram2D._meta = {
hrName: 'histogram_2d',
description: [
'The sample data from which statistics are computed is set in `x`',
'and `y` (where `x` and `y` represent marginal distributions,',
'binning is set in `xbins` and `ybins` in this case)',
'or `z` (where `z` represent the 2D distribution and binning set,',
'binning is set by `x` and `y` in this case).',
'The resulting distribution is visualized as a heatmap.'
].join(' ')
};

module.exports = Histogram2D;
30 changes: 14 additions & 16 deletions src/traces/histogram2dcontour/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,8 @@

'use strict';

var Plots = require('../../plots/plots');

var Histogram2dContour = {};

Plots.register(Histogram2dContour, 'histogram2dcontour',
['cartesian', '2dMap', 'contour', 'histogram'], {
hrName: 'histogram_2d_contour',
description: [
'The sample data from which statistics are computed is set in `x`',
'and `y` (where `x` and `y` represent marginal distributions,',
'binning is set in `xbins` and `ybins` in this case)',
'or `z` (where `z` represent the 2D distribution and binning set,',
'binning is set by `x` and `y` in this case).',
'The resulting distribution is visualized as a contour plot.'
].join(' ')
}
);

Histogram2dContour.attributes = require('./attributes');
Histogram2dContour.supplyDefaults = require('./defaults');
Histogram2dContour.calc = require('../contour/calc');
Expand All @@ -35,4 +19,18 @@ Histogram2dContour.style = require('../contour/style');
Histogram2dContour.colorbar = require('../contour/colorbar');
Histogram2dContour.hoverPoints = require('../contour/hover');

Histogram2dContour._type = 'histogram2dcontour';
Histogram2dContour._categories = ['cartesian', '2dMap', 'contour', 'histogram'];
Histogram2dContour._meta = {
hrName: 'histogram_2d_contour',
description: [
'The sample data from which statistics are computed is set in `x`',
'and `y` (where `x` and `y` represent marginal distributions,',
'binning is set in `xbins` and `ybins` in this case)',
'or `z` (where `z` represent the 2D distribution and binning set,',
'binning is set by `x` and `y` in this case).',
'The resulting distribution is visualized as a contour plot.'
].join(' ')
};

module.exports = Histogram2dContour;
18 changes: 9 additions & 9 deletions src/traces/mesh3d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@

'use strict';

var Plots = require('../../plots/plots');

var Mesh3D = {};

Plots.register(Mesh3D, 'mesh3d', ['gl3d'], {
Mesh3D.attributes = require('./attributes');
Mesh3D.supplyDefaults = require('./defaults');
Mesh3D.colorbar = require('../heatmap/colorbar');
Mesh3D.plot = require('./convert');

Mesh3D._type = 'mesh3d',
Mesh3D._categories = ['gl3d'];
Mesh3D._meta = {
description: [
'Draws sets of triangles with coordinates given by',
'three 1-dimensional arrays in `x`, `y`, `z` and',
Expand All @@ -22,11 +27,6 @@ Plots.register(Mesh3D, 'mesh3d', ['gl3d'], {
'(3) the Alpha-shape algorithm or',
'(4) the Convex-hull algorithm'
].join(' ')
});

Mesh3D.attributes = require('./attributes');
Mesh3D.supplyDefaults = require('./defaults');
Mesh3D.colorbar = require('../heatmap/colorbar');
Mesh3D.plot = require('./convert');
};

module.exports = Mesh3D;
Loading