MCPcopy
hub / github.com/plotly/plotly.js / handleDefaults

Function handleDefaults

src/plots/smith/layout_defaults.js:28–136  ·  view source on GitHub ↗
(contIn, contOut, coerce, opts)

Source from the content-addressed store, hash-verified

26}, String);
27
28function handleDefaults(contIn, contOut, coerce, opts) {
29 var bgColor = coerce('bgcolor');
30 opts.bgColor = Color.combine(bgColor, opts.paper_bgcolor);
31
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 visible = coerceAxis('visible');
54
55 axOut.type = 'linear';
56 setConvertCartesian(axOut, layoutOut);
57
58 handlePrefixSuffixDefaults(axIn, axOut, coerceAxis, axOut.type);
59
60 if(visible) {
61 var isRealAxis = axName === 'realaxis';
62 if(isRealAxis) coerceAxis('side');
63
64 if(isRealAxis) {
65 coerceAxis('tickvals');
66 } else {
67 var imagTickvalsDflt = makeImagDflt(
68 contOut.realaxis.tickvals ||
69 layoutAttributes.realaxis.tickvals.dflt
70 );
71
72 coerceAxis('tickvals', imagTickvalsDflt);
73 }
74
75 // TODO: handle this case outside supply defaults step
76 if(Lib.isTypedArray(axOut.tickvals)) axOut.tickvals = Array.from(axOut.tickvals);
77
78 var dfltColor;
79 var dfltFontColor;
80 var dfltFontSize;
81 var dfltFontFamily;
82 var font = opts.font || {};
83
84 if(visible) {
85 dfltColor = coerceAxis('color');

Callers

nothing calls this directly

Calls 2

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…