MCPcopy Index your code
hub / github.com/plotly/plotly.js / plot

Function plot

src/traces/pie/plot.js:22–325  ·  view source on GitHub ↗
(gd, cdModule)

Source from the content-addressed store, hash-verified

20var isValidTextValue = require('../../lib').isValidTextValue;
21
22function plot(gd, cdModule) {
23 var isStatic = gd._context.staticPlot;
24
25 var fullLayout = gd._fullLayout;
26 var gs = fullLayout._size;
27
28 clearMinTextSize('pie', fullLayout);
29
30 prerenderTitles(cdModule, gd);
31 layoutAreas(cdModule, gs);
32
33 var plotGroups = Lib.makeTraceGroups(fullLayout._pielayer, cdModule, 'trace').each(function (cd) {
34 var plotGroup = d3.select(this);
35 var cd0 = cd[0];
36 var trace = cd0.trace;
37
38 setCoords(cd);
39
40 // TODO: miter might look better but can sometimes cause problems
41 // maybe miter with a small-ish stroke-miterlimit?
42 plotGroup.attr('stroke-linejoin', 'round');
43
44 plotGroup.each(function () {
45 var slices = d3.select(this).selectAll('g.slice').data(cd);
46
47 slices.enter().append('g').classed('slice', true);
48 slices.exit().remove();
49
50 var quadrants = [
51 [[], []], // y<0: x<0, x>=0
52 [[], []] // y>=0: x<0, x>=0
53 ];
54 var hasOutsideText = false;
55
56 slices.each(function (pt, i) {
57 if (pt.hidden) {
58 d3.select(this).selectAll('path,g').remove();
59 return;
60 }
61
62 // to have consistent event data compared to other traces
63 pt.pointNumber = pt.i;
64 pt.curveNumber = trace.index;
65
66 quadrants[pt.pxmid[1] < 0 ? 0 : 1][pt.pxmid[0] < 0 ? 0 : 1].push(pt);
67
68 var cx = cd0.cx;
69 var cy = cd0.cy;
70 var sliceTop = d3.select(this);
71 var slicePath = sliceTop.selectAll('path.surface').data([pt]);
72
73 slicePath
74 .enter()
75 .append('path')
76 .classed('surface', true)
77 .style({ 'pointer-events': isStatic ? 'none' : 'all' });
78
79 sliceTop.call(attachFxHandlers, gd, cd);

Callers

nothing calls this directly

Calls 15

clearMinTextSizeFunction · 0.85
prerenderTitlesFunction · 0.85
layoutAreasFunction · 0.85
formatSliceLabelFunction · 0.85
transformOutsideTextFunction · 0.85
transformInsideTextFunction · 0.85
computeTransformFunction · 0.85
recordMinTextSizeFunction · 0.85
positionTitleInsideFunction · 0.85
positionTitleOutsideFunction · 0.85
scootLabelsFunction · 0.85
plotTextLinesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…