Skip to content

Commit 0366caa

Browse files
committed
Merge pull request #187 from plotly/rm-Pie-from-plot-routine
Remove explict dependency on Pie module from plot routine
2 parents f11f116 + be2e6c9 commit 0366caa

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/plot_api/plot_api.js

+20-14
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ var Queue = require('../lib/queue');
2121
var Plots = require('../plots/plots');
2222
var Fx = require('../plots/cartesian/graph_interact');
2323

24-
var Pie = require('../traces/pie');
25-
2624
var Color = require('../components/color');
2725
var Drawing = require('../components/drawing');
2826
var ErrorBars = require('../components/errorbars');
@@ -268,12 +266,16 @@ Plotly.plot = function(gd, data, layout, config) {
268266

269267
function getCdModule(cdSubplot, _module) {
270268
var cdModule = [];
271-
var i, cd, trace;
272-
for (i = 0; i < cdSubplot.length; i++) {
273-
cd = cdSubplot[i];
274-
trace = cd[0].trace;
275-
if (trace._module === _module && trace.visible === true) cdModule.push(cd);
269+
270+
for(var i = 0; i < cdSubplot.length; i++) {
271+
var cd = cdSubplot[i];
272+
var trace = cd[0].trace;
273+
274+
if((trace._module === _module) && (trace.visible === true)) {
275+
cdModule.push(cd);
276+
}
276277
}
278+
277279
return cdModule;
278280
}
279281

@@ -301,7 +303,7 @@ Plotly.plot = function(gd, data, layout, config) {
301303

302304
for (i = 0; i < subplots.length; i++) {
303305
subplot = subplots[i];
304-
subplotInfo = gd._fullLayout._plots[subplot];
306+
subplotInfo = fullLayout._plots[subplot];
305307
cdSubplot = getCdSubplot(calcdata, subplot);
306308
cdError = [];
307309

@@ -312,7 +314,8 @@ Plotly.plot = function(gd, data, layout, config) {
312314

313315
for(j = 0; j < modules.length; j++) {
314316
_module = modules[j];
315-
if(!_module.plot) continue;
317+
318+
if(!_module.plot && (_module.name === 'pie')) continue;
316319

317320
// plot all traces of this type on this subplot at once
318321
cdModule = getCdModule(cdSubplot, _module);
@@ -326,16 +329,19 @@ Plotly.plot = function(gd, data, layout, config) {
326329
}
327330

328331
// finally do all error bars at once
329-
if(gd._fullLayout._hasCartesian) {
332+
if(fullLayout._hasCartesian) {
330333
ErrorBars.plot(gd, subplotInfo, cdError);
331334
Lib.markTime('done ErrorBars');
332335
}
333336
}
334337

335-
// now draw stuff not on subplots (ie, pies)
336-
// TODO: gotta be a better way to handle this
337-
var cdPie = getCdModule(calcdata, Pie);
338-
if(cdPie.length) Pie.plot(gd, cdPie);
338+
// now draw stuff not on subplots (ie, only pies at the moment)
339+
if(fullLayout._hasPie) {
340+
var Pie = Plots.getModule('pie');
341+
var cdPie = getCdModule(calcdata, Pie);
342+
343+
if(cdPie.length) Pie.plot(gd, cdPie);
344+
}
339345

340346
// styling separate from drawing
341347
Plots.style(gd);

src/plots/plots.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ plots.register = function(_module, thisType, categoriesIn, meta) {
5252
}
5353

5454
modules[thisType] = {
55-
module: _module,
55+
_module: _module,
5656
categories: categoryObj
5757
};
5858

@@ -79,7 +79,7 @@ plots.getModule = function(trace) {
7979

8080
var _module = modules[getTraceType(trace)];
8181
if(!_module) return false;
82-
return _module.module;
82+
return _module._module;
8383
};
8484

8585

@@ -678,7 +678,7 @@ plots.supplyLayoutModuleDefaults = function(layoutIn, layoutOut, fullData) {
678678
// trace module layout defaults
679679
var traceTypes = Object.keys(modules);
680680
for(i = 0; i < traceTypes.length; i++) {
681-
_module = modules[allTypes[i]].module;
681+
_module = modules[allTypes[i]]._module;
682682

683683
if(_module.supplyLayoutDefaults) {
684684
_module.supplyLayoutDefaults(layoutIn, layoutOut, fullData);

0 commit comments

Comments
 (0)