-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathstyle.js
60 lines (44 loc) · 1.55 KB
/
style.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
/**
* Copyright 2012-2017, 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 d3 = require('d3');
var Drawing = require('../../components/drawing');
var heatmapStyle = require('../heatmap/style');
var makeColorMap = require('./make_color_map');
module.exports = function style(gd) {
var contours = d3.select(gd).selectAll('g.contour');
contours.style('opacity', function(d) {
return d.trace.opacity;
});
contours.each(function(d) {
var c = d3.select(this),
trace = d.trace,
contours = trace.contours,
line = trace.line,
cs = contours.size || 1,
start = contours.start;
var colorMap = makeColorMap(trace);
c.selectAll('g.contourlevel').each(function(d) {
d3.select(this).selectAll('path')
.call(Drawing.lineGroupStyle,
line.width,
contours.coloring === 'lines' ? colorMap(d.level) : line.color,
line.dash);
});
var firstFill;
c.selectAll('g.contourfill path')
.style('fill', function(d) {
if(firstFill === undefined) firstFill = d.level;
return colorMap(d.level + 0.5 * cs);
});
if(firstFill === undefined) firstFill = start;
c.selectAll('g.contourbg path')
.style('fill', colorMap(firstFill - 0.5 * cs));
});
heatmapStyle(gd);
};