forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.js
56 lines (45 loc) · 1.5 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
'use strict';
var d3 = require('@plotly/d3');
var Color = require('../../components/color');
var Lib = require('../../lib');
var resizeText = require('../bar/uniform_text').resizeText;
var Drawing = require('../../components/drawing');
function style(gd) {
var s = gd._fullLayout._sunburstlayer.selectAll('.trace');
resizeText(gd, s, 'sunburst');
s.each(function(cd) {
var gTrace = d3.select(this);
var cd0 = cd[0];
var trace = cd0.trace;
gTrace.style('opacity', trace.opacity);
gTrace.selectAll('path.surface').each(function(pt) {
d3.select(this).call(styleOne, pt, trace, gd);
});
});
}
function styleOne(s, pt, trace, gd) {
var cdi = pt.data.data;
var isLeaf = !pt.children;
var ptNumber = cdi.i;
var lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine;
var lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0;
if(gd && ptNumber >= 0) {
pt.i = cdi.i;
var marker = trace.marker;
if(marker.pattern) {
if(!marker.colors || !marker.pattern.shape) marker.color = cdi.color;
} else {
marker.color = cdi.color;
}
Drawing.pointStyle(s, trace, gd, pt);
} else {
Color.fill(s, cdi.color);
}
s.style('stroke-width', lineWidth)
.call(Color.stroke, lineColor)
.style('opacity', isLeaf ? trace.leaf.opacity : null);
}
module.exports = {
style: style,
styleOne: styleOne
};