Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a616237

Browse files
committed
try .
1 parent b655cb0 commit a616237

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

src/plot_api/plot_api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,8 @@ Plotly.plot = function(gd, data, layout, config) {
277277
if(fullLayout._hasGL3D) plotRegistry.gl3d.plot(gd);
278278
if(fullLayout._hasGeo) plotRegistry.geo.plot(gd);
279279
if(fullLayout._hasGL2D) plotRegistry.gl2d.plot(gd);
280-
if(fullLayout._hasCartesian || fullLayout._hasPie) {
281-
plotRegistry.cartesian.plot(gd);
282-
}
280+
if(fullLayout._hasCartesian) plotRegistry.cartesian.plot(gd);
281+
if(fullLayout._hasPie) plotRegistry.pie.plot(gd);
283282
if(fullLayout._hasTernary) plotRegistry.ternary.plot(gd);
284283

285284
// clean up old scenes that no longer have associated data

src/plots/cartesian/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,11 @@ exports.plot = function(gd) {
7878
// skip over non-cartesian trace modules
7979
if(_module.basePlotModule.name !== 'cartesian') continue;
8080

81-
// skip over pies, there are drawn below
82-
if(_module.name === 'pie') continue;
83-
8481
// plot all traces of this type on this subplot at once
8582
var cdModule = getCdModule(cdSubplot, _module);
8683
_module.plot(gd, subplotInfo, cdModule);
8784

8885
Lib.markTime('done ' + (cdModule[0] && cdModule[0][0].trace.type));
8986
}
9087
}
91-
92-
// now draw stuff not on subplots (ie, only pies at the moment)
93-
if(fullLayout._hasPie) {
94-
var Pie = Plots.getModule('pie');
95-
var cdPie = getCdModule(calcdata, Pie);
96-
97-
if(cdPie.length) Pie.plot(gd, cdPie);
98-
}
99-
};
100-
101-
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
102-
if(oldFullLayout._hasPie && !newFullLayout._hasPie) {
103-
oldFullLayout._pielayer.selectAll('g.trace').remove();
104-
}
10588
};

src/traces/pie/base_plot.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var Plots = require('../../plots/plots');
12+
13+
14+
exports.name = 'pie';
15+
16+
// exports.attr = 'geo';
17+
// exports.idRoot = 'geo';
18+
// exports.idRegex = /^geo([2-9]|[1-9][0-9]+)?$/;
19+
// exports.attrRegex = /^geo([2-9]|[1-9][0-9]+)?$/;
20+
21+
exports.plot = function(gd) {
22+
var Pie = Plots.getModule('pie');
23+
var cdPie = getCdModule(gd.calcdata, Pie);
24+
25+
if(cdPie.length) Pie.plot(gd, cdPie);
26+
};
27+
28+
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
29+
if(oldFullLayout._hasPie && !newFullLayout._hasPie) {
30+
oldFullLayout._pielayer.selectAll('g.trace').remove();
31+
}
32+
};
33+
34+
function getCdModule(calcdata, _module) {
35+
var cdModule = [];
36+
37+
for(var i = 0; i < calcdata.length; i++) {
38+
var cd = calcdata[i];
39+
var trace = cd[0].trace;
40+
41+
if((trace._module === _module) && (trace.visible === true)) {
42+
cdModule.push(cd);
43+
}
44+
}
45+
46+
return cdModule;
47+
}

src/traces/pie/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ Pie.styleOne = require('./style_one');
2121

2222
Pie.moduleType = 'trace';
2323
Pie.name = 'pie';
24-
Pie.basePlotModule = require('../../plots/cartesian');
24+
Pie.basePlotModule = require('./base_plot');
2525
Pie.categories = ['pie', 'showLegend'];
26-
Pie.layoutCategories = ['pie'];
2726
Pie.meta = {
2827
description: [
2928
'A data visualized by the sectors of the pie is set in `values`.',

0 commit comments

Comments
 (0)