-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathxy_defaults.js
48 lines (40 loc) · 1.32 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright 2012-2016, 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 Registry = require('../../registry');
module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) {
var len,
x = coerce('x'),
y = coerce('y');
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout);
if(x) {
if(y) {
len = Math.min(x.length, y.length);
// TODO: not sure we should do this here... but I think
// the way it works in calc is wrong, because it'll delete data
// which could be a problem eg in streaming / editing if x and y
// come in at different times
// so we need to revisit calc before taking this out
if(len < x.length) traceOut.x = x.slice(0, len);
if(len < y.length) traceOut.y = y.slice(0, len);
}
else {
len = x.length;
coerce('y0');
coerce('dy');
}
}
else {
if(!y) return 0;
len = traceOut.y.length;
coerce('x0');
coerce('dx');
}
return len;
};