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

Function supplyDefaults

src/traces/pie/defaults.js:52–129  ·  view source on GitHub ↗
(traceIn, traceOut, defaultColor, layout)

Source from the content-addressed store, hash-verified

50}
51
52function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
53 function coerce(attr, dflt) {
54 return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
55 }
56
57 var labels = coerce('labels');
58 var values = coerce('values');
59
60 var res = handleLabelsAndValues(labels, values);
61 var len = res.len;
62 traceOut._hasLabels = res.hasLabels;
63 traceOut._hasValues = res.hasValues;
64
65 if (!traceOut._hasLabels && traceOut._hasValues) {
66 coerce('label0');
67 coerce('dlabel');
68 }
69
70 if (!len) {
71 traceOut.visible = false;
72 return;
73 }
74 traceOut._length = len;
75
76 handleMarkerDefaults(traceIn, traceOut, layout, coerce, true);
77
78 coerce('scalegroup');
79 // TODO: hole needs to be coerced to the same value within a scaleegroup
80
81 var textData = coerce('text');
82 var textTemplate = coerce('texttemplate');
83 coerce('texttemplatefallback');
84 var textInfo;
85 if (!textTemplate) textInfo = coerce('textinfo', Lib.isArrayOrTypedArray(textData) ? 'text+percent' : 'percent');
86
87 coerce('hovertext');
88 coerce('hovertemplate');
89 coerce('hovertemplatefallback');
90
91 if (textTemplate || (textInfo && textInfo !== 'none')) {
92 var textposition = coerce('textposition');
93 handleText(traceIn, traceOut, layout, coerce, textposition, {
94 moduleHasSelected: false,
95 moduleHasUnselected: false,
96 moduleHasConstrain: false,
97 moduleHasCliponaxis: false,
98 moduleHasTextangle: false,
99 moduleHasInsideanchor: false
100 });
101
102 var hasBoth = Array.isArray(textposition) || textposition === 'auto';
103 var hasOutside = hasBoth || textposition === 'outside';
104 if (hasOutside) {
105 coerce('automargin');
106 }
107
108 if (textposition === 'inside' || textposition === 'auto' || Array.isArray(textposition)) {
109 coerce('insidetextorientation');

Callers

nothing calls this directly

Calls 4

handleLabelsAndValuesFunction · 0.85
handleMarkerDefaultsFunction · 0.85
handleTextFunction · 0.85
coerceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…