Skip to content

Commit 161af7e

Browse files
committed
sub Plots[method] -> Registry[method]
1 parent 4a3f254 commit 161af7e

File tree

22 files changed

+79
-76
lines changed

22 files changed

+79
-76
lines changed

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');
@@ -436,7 +437,7 @@ module.exports = function draw(gd, id) {
436437
function drawTitle(titleClass, titleOpts) {
437438
var trace = getTrace(),
438439
propName;
439-
if(Plots.traceIs(trace, 'markerColorscale')) {
440+
if(Registry.traceIs(trace, 'markerColorscale')) {
440441
propName = 'marker.colorbar.title';
441442
}
442443
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/legend/defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
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');
1616
var basePlotLayoutAttributes = require('../../plots/layout_attributes');
@@ -34,10 +34,10 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
3434
if(helpers.legendGetsTrace(trace)) {
3535
visibleTraces++;
3636
// always show the legend by default if there's a pie
37-
if(Plots.traceIs(trace, 'pie')) visibleTraces++;
37+
if(Registry.traceIs(trace, 'pie')) visibleTraces++;
3838
}
3939

40-
if((Plots.traceIs(trace, 'bar') && layoutOut.barmode === 'stack') ||
40+
if((Registry.traceIs(trace, 'bar') && layoutOut.barmode === 'stack') ||
4141
['tonextx', 'tonexty'].indexOf(trace.fill) !== -1) {
4242
defaultOrder = helpers.isGrouped({traceorder: defaultOrder}) ?
4343
'grouped+reversed' : 'reversed';

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) {

src/components/legend/style.js

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

1212
var d3 = require('d3');
1313

14+
var Registry = require('../../registry');
1415
var Lib = require('../../lib');
15-
var Plots = require('../../plots/plots');
1616
var Drawing = require('../drawing');
1717
var Color = require('../color');
1818

@@ -165,7 +165,7 @@ function styleBars(d) {
165165
markerLine = marker.line || {},
166166
barpath = d3.select(this).select('g.legendpoints')
167167
.selectAll('path.legendbar')
168-
.data(Plots.traceIs(trace, 'bar') ? [d] : []);
168+
.data(Registry.traceIs(trace, 'bar') ? [d] : []);
169169
barpath.enter().append('path').classed('legendbar', true)
170170
.attr('d', 'M6,6H-6V-6H6Z')
171171
.attr('transform', 'translate(20,0)');
@@ -187,7 +187,7 @@ function styleBoxes(d) {
187187
var trace = d[0].trace,
188188
pts = d3.select(this).select('g.legendpoints')
189189
.selectAll('path.legendbox')
190-
.data(Plots.traceIs(trace, 'box') && trace.visible ? [d] : []);
190+
.data(Registry.traceIs(trace, 'box') && trace.visible ? [d] : []);
191191
pts.enter().append('path').classed('legendbox', true)
192192
// if we want the median bar, prepend M6,0H-6
193193
.attr('d', 'M6,6H-6V-6H6Z')
@@ -210,7 +210,7 @@ function stylePies(d) {
210210
var trace = d[0].trace,
211211
pts = d3.select(this).select('g.legendpoints')
212212
.selectAll('path.legendpie')
213-
.data(Plots.traceIs(trace, 'pie') && trace.visible ? [d] : []);
213+
.data(Registry.traceIs(trace, 'pie') && trace.visible ? [d] : []);
214214
pts.enter().append('path').classed('legendpie', true)
215215
.attr('d', 'M6,6H-6V-6H6Z')
216216
.attr('transform', 'translate(20,0)');

src/plot_api/plot_api.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Lib = require('../lib');
1818
var Events = require('../lib/events');
1919
var Queue = require('../lib/queue');
2020

21+
var Registry = require('../registry');
2122
var Plots = require('../plots/plots');
2223
var Fx = require('../plots/cartesian/graph_interact');
2324
var Polar = require('../plots/polar');
@@ -262,7 +263,7 @@ Plotly.plot = function(gd, data, layout, config) {
262263
isVisible = (trace.visible === true),
263264
uid = trace.uid;
264265

265-
if(!isVisible || !Plots.traceIs(trace, '2dMap')) {
266+
if(!isVisible || !Registry.traceIs(trace, '2dMap')) {
266267
fullLayout._paper.selectAll(
267268
'.hm' + uid +
268269
',.contour' + uid +
@@ -705,7 +706,7 @@ function cleanData(data, existingData) {
705706
if(trace.error_y && 'opacity' in trace.error_y) {
706707
var dc = Color.defaults,
707708
yeColor = trace.error_y.color ||
708-
(Plots.traceIs(trace, 'bar') ? Color.defaultLine : dc[tracei % dc.length]);
709+
(Registry.traceIs(trace, 'bar') ? Color.defaultLine : dc[tracei % dc.length]);
709710
trace.error_y.color = Color.addOpacity(
710711
Color.rgb(yeColor),
711712
Color.opacity(yeColor) * trace.error_y.opacity);
@@ -715,7 +716,7 @@ function cleanData(data, existingData) {
715716
// convert bardir to orientation, and put the data into
716717
// the axes it's eventually going to be used with
717718
if('bardir' in trace) {
718-
if(trace.bardir === 'h' && (Plots.traceIs(trace, 'bar') ||
719+
if(trace.bardir === 'h' && (Registry.traceIs(trace, 'bar') ||
719720
trace.type.substr(0, 9) === 'histogram')) {
720721
trace.orientation = 'h';
721722
swapXYData(trace);
@@ -745,11 +746,11 @@ function cleanData(data, existingData) {
745746
if(trace.yaxis) trace.yaxis = Plotly.Axes.cleanId(trace.yaxis, 'y');
746747

747748
// scene ids scene1 -> scene
748-
if(Plots.traceIs(trace, 'gl3d') && trace.scene) {
749+
if(Registry.traceIs(trace, 'gl3d') && trace.scene) {
749750
trace.scene = Plots.subplotsRegistry.gl3d.cleanId(trace.scene);
750751
}
751752

752-
if(!Plots.traceIs(trace, 'pie')) {
753+
if(!Registry.traceIs(trace, 'pie')) {
753754
if(Array.isArray(trace.textposition)) {
754755
trace.textposition = trace.textposition.map(cleanTextPosition);
755756
}
@@ -759,11 +760,11 @@ function cleanData(data, existingData) {
759760
}
760761

761762
// fix typo in colorscale definition
762-
if(Plots.traceIs(trace, '2dMap')) {
763+
if(Registry.traceIs(trace, '2dMap')) {
763764
if(trace.colorscale === 'YIGnBu') trace.colorscale = 'YlGnBu';
764765
if(trace.colorscale === 'YIOrRd') trace.colorscale = 'YlOrRd';
765766
}
766-
if(Plots.traceIs(trace, 'markerColorscale') && trace.marker) {
767+
if(Registry.traceIs(trace, 'markerColorscale') && trace.marker) {
767768
var cont = trace.marker;
768769
if(cont.colorscale === 'YIGnBu') cont.colorscale = 'YlGnBu';
769770
if(cont.colorscale === 'YIOrRd') cont.colorscale = 'YlOrRd';
@@ -1607,7 +1608,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
16071608
'marker.line.showscale', 'marker.line.cauto', 'marker.line.autocolorscale', 'marker.line.reversescale'
16081609
];
16091610
for(i = 0; i < traces.length; i++) {
1610-
if(Plots.traceIs(gd._fullData[traces[i]], 'box')) {
1611+
if(Registry.traceIs(gd._fullData[traces[i]], 'box')) {
16111612
recalcAttrs.push('name');
16121613
break;
16131614
}
@@ -1850,7 +1851,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
18501851

18511852
// super kludgy - but if all pies are gone we won't remove them otherwise
18521853
fullLayout._pielayer.selectAll('g.trace').remove();
1853-
} else if(Plots.traceIs(cont, 'cartesian')) {
1854+
} else if(Registry.traceIs(cont, 'cartesian')) {
18541855
Lib.nestedProperty(cont, 'marker.colors')
18551856
.set(Lib.nestedProperty(cont, 'marker.color').get());
18561857
//look for axes that are no longer in use and delete them
@@ -1926,7 +1927,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
19261927
for(i = 0; i < traces.length; i++) {
19271928
var trace = gd.data[traces[i]];
19281929

1929-
if(Plots.traceIs(trace, 'cartesian')) {
1930+
if(Registry.traceIs(trace, 'cartesian')) {
19301931
addToAxlist(trace.xaxis || 'x');
19311932
addToAxlist(trace.yaxis || 'y');
19321933

@@ -1954,7 +1955,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
19541955
axLetter = axId.charAt(0),
19551956
axAttr = axLetter + 'axis';
19561957
for(var j = 0; j < gd.data.length; j++) {
1957-
if(Plots.traceIs(gd.data[j], 'cartesian') &&
1958+
if(Registry.traceIs(gd.data[j], 'cartesian') &&
19581959
(gd.data[j][axAttr] || axLetter) === axId) {
19591960
continue axisLoop;
19601961
}
@@ -2017,7 +2018,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
20172018
var trace = cd[0].trace,
20182019
cb = cd[0].t.cb;
20192020

2020-
if(Plots.traceIs(trace, 'contour')) {
2021+
if(Registry.traceIs(trace, 'contour')) {
20212022
cb.line({
20222023
width: trace.contours.showlines !== false ?
20232024
trace.line.width : 0,
@@ -2026,7 +2027,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
20262027
cb._opts.line.color : trace.line.color
20272028
});
20282029
}
2029-
if(Plots.traceIs(trace, 'markerColorscale')) {
2030+
if(Registry.traceIs(trace, 'markerColorscale')) {
20302031
cb.options(trace.marker.colorbar)();
20312032
}
20322033
else cb.options(trace.colorbar)();

0 commit comments

Comments
 (0)