-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdefaults.js
66 lines (55 loc) · 1.66 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Copyright 2012-2020, 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 Lib = require('../../lib');
var subTypes = require('../scatter/subtypes');
var handleMarkerDefaults = require('../scatter/marker_defaults');
var attributes = require('./attributes');
module.exports = function supplyDefaults(
traceIn,
traceOut,
defaultColor,
layout
) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var len = handleLonLatDefaults(traceIn, traceOut, coerce);
if(!len) {
traceOut.visible = false;
return;
}
coerce('texttemplate');
coerce('hovertext');
coerce('hovertemplate');
coerce('mode');
coerce('below');
coerce('cluster.maxZoom');
coerce('cluster.radius');
coerce('cluster.steps');
coerce('cluster.stepSize');
coerce('cluster.stepColors');
if(subTypes.hasMarkers(traceOut)) {
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, {
noLine: true,
noSelect: true
});
var marker = traceOut.marker;
if(marker.symbol !== 'circle') {
if(Lib.isArrayOrTypedArray(marker.size)) marker.size = marker.size[0];
if(Lib.isArrayOrTypedArray(marker.color)) marker.color = marker.color[0];
}
}
};
function handleLonLatDefaults(traceIn, traceOut, coerce) {
var lon = coerce('lon') || [];
var lat = coerce('lat') || [];
var len = Math.min(lon.length, lat.length);
traceOut._length = len;
return len;
}