-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathmarker_defaults.js
61 lines (48 loc) · 1.87 KB
/
marker_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
/**
* 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 Color = require('../../components/color');
var hasColorscale = require('../../components/colorscale/has_colorscale');
var colorscaleDefaults = require('../../components/colorscale/defaults');
var subTypes = require('./subtypes');
// common to 'scatter', 'scatter3d', 'scattergeo' and 'scattergl'
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
var isBubble = subTypes.isBubble(traceIn),
lineColor = !Array.isArray(traceIn.line) ? (traceIn.line || {}).color : undefined,
defaultMLC;
if(lineColor) defaultColor = lineColor;
coerce('marker.symbol');
coerce('marker.opacity', isBubble ? 0.7 : 1);
coerce('marker.size');
coerce('marker.color', defaultColor);
if(hasColorscale(traceIn, 'marker')) {
colorscaleDefaults(
traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'}
);
}
// if there's a line with a different color than the marker, use
// that line color as the default marker line color
// mostly this is for transparent markers to behave nicely
if(lineColor && (traceOut.marker.color !== lineColor)) {
defaultMLC = lineColor;
}
else if(isBubble) defaultMLC = Color.background;
else defaultMLC = Color.defaultLine;
coerce('marker.line.color', defaultMLC);
if(hasColorscale(traceIn, 'marker.line')) {
colorscaleDefaults(
traceIn, traceOut, layout, coerce, {prefix: 'marker.line.', cLetter: 'c'}
);
}
coerce('marker.line.width', isBubble ? 1 : 0);
if(isBubble) {
coerce('marker.sizeref');
coerce('marker.sizemin');
coerce('marker.sizemode');
}
};