-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathxy_defaults.js
33 lines (26 loc) · 903 Bytes
/
xy_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
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var is1D = require('../../lib').is1D;
module.exports = function handleXYDefaults(traceIn, traceOut, coerce) {
var x = coerce('x');
var hasX = x && x.length;
var y = coerce('y');
var hasY = y && y.length;
if(!hasX && !hasY) return false;
traceOut._cheater = !x;
if((!hasX || is1D(x)) && (!hasY || is1D(y))) {
var len = hasX ? x.length : Infinity;
if(hasY) len = Math.min(len, y.length);
if(traceOut.a && traceOut.a.length) len = Math.min(len, traceOut.a.length);
if(traceOut.b && traceOut.b.length) len = Math.min(len, traceOut.b.length);
traceOut._length = len;
}
else traceOut._length = null;
return true;
};