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

Function handleDefaults

src/plots/polar/layout_defaults.js:24–237  ·  view source on GitHub ↗
(contIn, contOut, coerce, opts)

Source from the content-addressed store, hash-verified

22var axisNames = constants.axisNames;
23
24function handleDefaults(contIn, contOut, coerce, opts) {
25 var bgColor = coerce('bgcolor');
26 opts.bgColor = Color.combine(bgColor, opts.paper_bgcolor);
27
28 var sector = coerce('sector');
29 coerce('hole');
30
31 // could optimize, subplotData is not always needed!
32 var subplotData = getSubplotData(opts.fullData, constants.name, opts.id);
33 var layoutOut = opts.layoutOut;
34 var axName;
35
36 function coerceAxis(attr, dflt) {
37 return coerce(axName + '.' + attr, dflt);
38 }
39
40 for(var i = 0; i < axisNames.length; i++) {
41 axName = axisNames[i];
42
43 if(!Lib.isPlainObject(contIn[axName])) {
44 contIn[axName] = {};
45 }
46
47 var axIn = contIn[axName];
48 var axOut = Template.newContainer(contOut, axName);
49 axOut._id = axOut._name = axName;
50 axOut._attr = opts.id + '.' + axName;
51 axOut._traceIndices = subplotData.map(function(t) { return t.index; });
52
53 var dataAttr = constants.axisName2dataArray[axName];
54 var axType = handleAxisTypeDefaults(axIn, axOut, coerceAxis, subplotData, dataAttr, opts);
55
56 handleCategoryOrderDefaults(axIn, axOut, coerceAxis, {
57 axData: subplotData,
58 dataAttr: dataAttr
59 });
60
61 var visible = coerceAxis('visible');
62 setConvert(axOut, contOut, layoutOut);
63
64 coerceAxis('uirevision', contOut.uirevision);
65
66 // We don't want to make downstream code call ax.setScale,
67 // as both radial and angular axes don't have a set domain.
68 // Furthermore, angular axes don't have a set range.
69 //
70 // Mocked domains and ranges are set by the polar subplot instances,
71 // but Axes.findExtremes uses the sign of _m to determine which padding value
72 // to use.
73 //
74 // By setting, _m to 1 here, we make Axes.findExtremes think that
75 // range[1] > range[0], and vice-versa for `autorange: 'reversed'` below.
76 axOut._m = 1;
77
78 switch(axName) {
79 case 'radialaxis':
80 coerceAxis('minallowed');
81 coerceAxis('maxallowed');

Callers

nothing calls this directly

Calls 3

handleAxisTypeDefaultsFunction · 0.85
coerceAxisFunction · 0.70
coerceFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…