-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdefaults.js
49 lines (38 loc) · 1.46 KB
/
defaults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
var Lib = require('../../lib');
var handleXYDefaults = require('./xy_defaults');
var handleABDefaults = require('./ab_defaults');
var attributes = require('./attributes');
var colorAttrs = require('../../components/color/attributes');
module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
traceOut._clipPathId = 'clip' + traceOut.uid + 'carpet';
var defaultColor = coerce('color', colorAttrs.defaultLine);
Lib.coerceFont(coerce, 'font');
coerce('carpet');
handleABDefaults(traceIn, traceOut, fullLayout, coerce, defaultColor);
if(!traceOut.a || !traceOut.b) {
traceOut.visible = false;
return;
}
if(traceOut.a.length < 3) {
traceOut.aaxis.smoothing = 0;
}
if(traceOut.b.length < 3) {
traceOut.baxis.smoothing = 0;
}
// NB: the input is x/y arrays. You should know that the *first* dimension of x and y
// corresponds to b and the second to a. This sounds backwards but ends up making sense
// the important part to know is that when you write y[j][i], j goes from 0 to b.length - 1
// and i goes from 0 to a.length - 1.
var validData = handleXYDefaults(traceIn, traceOut, coerce);
if(!validData) {
traceOut.visible = false;
}
if(traceOut._cheater) {
coerce('cheaterslope');
}
coerce('zorder');
};