Skip to content

Commit 7e4d8ab

Browse files
authored
Merge pull request #845 from plotly/registry-use-component
Add registry of component modules
2 parents 7e2448e + 489513b commit 7e4d8ab

Some content is hidden

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

47 files changed

+631
-518
lines changed

src/components/annotations/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
var Plotly = require('../../plotly');
1313

14+
exports.moduleType = 'component';
15+
16+
exports.name = 'annotations';
1417

1518
exports.ARROWPATHS = require('./arrow_paths');
1619

src/components/colorbar/draw.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var tinycolor = require('tinycolor2');
1414

1515
var Plotly = require('../../plotly');
1616
var Plots = require('../../plots/plots');
17+
var Registry = require('../../registry');
1718
var Axes = require('../../plots/cartesian/axes');
1819
var dragElement = require('../dragelement');
1920
var Lib = require('../../lib');
@@ -437,7 +438,7 @@ module.exports = function draw(gd, id) {
437438
function drawTitle(titleClass, titleOpts) {
438439
var trace = getTrace(),
439440
propName;
440-
if(Plots.traceIs(trace, 'markerColorscale')) {
441+
if(Registry.traceIs(trace, 'markerColorscale')) {
441442
propName = 'marker.colorbar.title';
442443
}
443444
else propName = 'colorbar.title';

src/components/drawing/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
var d3 = require('d3');
1313
var isNumeric = require('fast-isnumeric');
1414

15-
var Plots = require('../../plots/plots');
15+
var Registry = require('../../registry');
1616
var Color = require('../color');
1717
var Colorscale = require('../colorscale');
1818
var Lib = require('../../lib');
@@ -183,7 +183,7 @@ drawing.pointStyle = function(s, trace) {
183183

184184
// only scatter & box plots get marker path and opacity
185185
// bars, histograms don't
186-
if(Plots.traceIs(trace, 'symbols')) {
186+
if(Registry.traceIs(trace, 'symbols')) {
187187
var sizeFn = makeBubbleSizeFn(trace);
188188

189189
s.attr('d', function(d) {

src/components/errorbars/calc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
var isNumeric = require('fast-isnumeric');
1313

14-
var Plots = require('../../plots/plots');
14+
var Registry = require('../../registry');
1515
var Axes = require('../../plots/cartesian/axes');
1616

1717
var makeComputeError = require('./compute_error');
@@ -24,7 +24,7 @@ module.exports = function calc(gd) {
2424
var calcTrace = calcdata[i],
2525
trace = calcTrace[0].trace;
2626

27-
if(!Plots.traceIs(trace, 'errorBarsOK')) continue;
27+
if(!Registry.traceIs(trace, 'errorBarsOK')) continue;
2828

2929
var xa = Axes.getFromId(gd, trace.xaxis),
3030
ya = Axes.getFromId(gd, trace.yaxis);

src/components/errorbars/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
var isNumeric = require('fast-isnumeric');
1212

13-
var Plots = require('../../plots/plots');
13+
var Registry = require('../../registry');
1414
var Lib = require('../../lib');
1515

1616
var attributes = require('./attributes');
@@ -70,6 +70,6 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) {
7070
if(!opts.inherit || !containerOut[copyAttr]) {
7171
coerce('color', defaultColor);
7272
coerce('thickness');
73-
coerce('width', Plots.traceIs(traceOut, 'gl3d') ? 0 : 4);
73+
coerce('width', Registry.traceIs(traceOut, 'gl3d') ? 0 : 4);
7474
}
7575
};

src/components/images/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var attributes = require('./attributes');
1515

1616

1717
module.exports = {
18+
moduleType: 'component',
19+
name: 'images',
1820
draw: draw,
1921
layoutAttributes: attributes,
2022
supplyLayoutDefaults: supplyLayoutDefaults

src/components/legend/defaults.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
'use strict';
1111

12+
var Registry = require('../../registry');
1213
var Lib = require('../../lib');
13-
var Plots = require('../../plots/plots');
1414

1515
var attributes = require('./attributes');
16+
var basePlotLayoutAttributes = require('../../plots/layout_attributes');
1617
var helpers = require('./helpers');
1718

1819

@@ -33,10 +34,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
3334
if(helpers.legendGetsTrace(trace)) {
3435
visibleTraces++;
3536
// always show the legend by default if there's a pie
36-
if(Plots.traceIs(trace, 'pie')) visibleTraces++;
37+
if(Registry.traceIs(trace, 'pie')) visibleTraces++;
3738
}
3839

39-
if((Plots.traceIs(trace, 'bar') && layoutOut.barmode === 'stack') ||
40+
if((Registry.traceIs(trace, 'bar') && layoutOut.barmode === 'stack') ||
4041
['tonextx', 'tonexty'].indexOf(trace.fill) !== -1) {
4142
defaultOrder = helpers.isGrouped({traceorder: defaultOrder}) ?
4243
'grouped+reversed' : 'reversed';
@@ -53,7 +54,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
5354
}
5455

5556
var showLegend = Lib.coerce(layoutIn, layoutOut,
56-
Plots.layoutAttributes, 'showlegend', visibleTraces > 1);
57+
basePlotLayoutAttributes, 'showlegend', visibleTraces > 1);
5758

5859
if(showLegend === false) return;
5960

src/components/legend/draw.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var d3 = require('d3');
1414
var Plotly = require('../../plotly');
1515
var Lib = require('../../lib');
1616
var Plots = require('../../plots/plots');
17+
var Registry = require('../../registry');
1718
var dragElement = require('../dragelement');
1819
var Drawing = require('../drawing');
1920
var Color = require('../color');
@@ -108,7 +109,7 @@ module.exports = function draw(gd) {
108109
traces.call(style)
109110
.style('opacity', function(d) {
110111
var trace = d[0].trace;
111-
if(Plots.traceIs(trace, 'pie')) {
112+
if(Registry.traceIs(trace, 'pie')) {
112113
return hiddenSlices.indexOf(d[0].label) !== -1 ? 0.5 : 1;
113114
} else {
114115
return trace.visible === 'legendonly' ? 0.5 : 1;
@@ -337,7 +338,7 @@ function drawTexts(g, gd) {
337338
var legendItem = g.data()[0][0],
338339
fullLayout = gd._fullLayout,
339340
trace = legendItem.trace,
340-
isPie = Plots.traceIs(trace, 'pie'),
341+
isPie = Registry.traceIs(trace, 'pie'),
341342
traceIndex = trace.index,
342343
name = isPie ? legendItem.label : trace.name;
343344

@@ -400,7 +401,7 @@ function setupTraceToggle(g, gd) {
400401
tracei,
401402
newVisible;
402403

403-
if(Plots.traceIs(trace, 'pie')) {
404+
if(Registry.traceIs(trace, 'pie')) {
404405
var thisLabel = legendItem.label,
405406
thisLabelIndex = hiddenSlices.indexOf(thisLabel);
406407

src/components/legend/get_legend_data.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
13-
12+
var Registry = require('../../registry');
1413
var helpers = require('./helpers');
1514

1615

@@ -49,7 +48,7 @@ module.exports = function getLegendData(calcdata, opts) {
4948

5049
if(!helpers.legendGetsTrace(trace) || !trace.showlegend) continue;
5150

52-
if(Plots.traceIs(trace, 'pie')) {
51+
if(Registry.traceIs(trace, 'pie')) {
5352
if(!slicesShown[lgroup]) slicesShown[lgroup] = {};
5453

5554
for(j = 0; j < cd.length; j++) {

src/components/legend/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
'use strict';
1111

12-
var Plots = require('../../plots/plots');
12+
var Registry = require('../../registry');
1313

1414

1515
exports.legendGetsTrace = function legendGetsTrace(trace) {
16-
return trace.visible && Plots.traceIs(trace, 'showLegend');
16+
return trace.visible && Registry.traceIs(trace, 'showLegend');
1717
};
1818

1919
exports.isGrouped = function isGrouped(legendLayout) {

0 commit comments

Comments
 (0)