Skip to content

Commit 3b104b1

Browse files
committed
drop pathbar.opacity and modify depthfade description
1 parent 481f660 commit 3b104b1

File tree

7 files changed

+30
-119
lines changed

7 files changed

+30
-119
lines changed

src/traces/treemap/attributes.js

+8-20
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ module.exports = {
145145
editType: 'style',
146146
role: 'style',
147147
description: [
148-
'Fades headers towards the background. Background color with opacity of 0.75',
149-
'is used as the destination fading color.',
150-
'When `marker.colors` are not set within the trace it is defaulted to *false*;',
151-
'otherwise it is defaulted to *true*.',
152-
'The *reversed* option could be used to invert the direction of fade',
153-
'in which the top elements within hierarchy drawn with fully saturated colors',
154-
'while the leaves would be faded towards the background color',
155-
'This option is not available when a `colorscale` is present.'
148+
'Determines if the sector colors are faded towards',
149+
'the background from the leaves up to the headers.',
150+
'This option is unavailable when a `colorscale` is present,',
151+
'defaults to false when `marker.colors` is set,',
152+
'but otherwise defaults to true.',
153+
'When set to *reversed*, the fading direction is inverted,',
154+
'that is the top elements within hierarchy are drawn with fully saturated colors',
155+
'while the leaves are faded towards the background color.'
156156
].join(' ')
157157
},
158158

@@ -222,18 +222,6 @@ module.exports = {
222222
].join(' ')
223223
},
224224

225-
opacity: {
226-
valType: 'number',
227-
editType: 'style',
228-
role: 'style',
229-
min: 0,
230-
dflt: 1,
231-
description: [
232-
'Sets the opacity of the pathbar.',
233-
'This option is not available when a `colorscale` is present.'
234-
].join(' ')
235-
},
236-
237225
textfont: extendFlat({}, pieAttrs.textfont, {
238226
description: 'Sets the font used inside `pathbar`.'
239227
}),

src/traces/treemap/defaults.js

-3
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
8989

9090
if(withColorscale) {
9191
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
92-
} else {
93-
coerce('pathbar.opacity');
9492
}
9593

9694
traceOut._hovered = {
9795
marker: {
98-
opacity: 1,
9996
line: {
10097
width: 2,
10198
color: Color.contrast(layout.paper_bgcolor)

src/traces/treemap/style.js

+22-30
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,32 @@ function styleOne(s, pt, trace, opts) {
4343
} else {
4444
var isRoot = helpers.isHierarchyRoot(pt);
4545

46-
if(!trace._hasColorscale) {
47-
if(pt.onPathbar) {
48-
// Combining colors with the background color.
49-
// Better not to have transparent segments.
50-
// Also this helps pathbar texts appear nicely below previous segments.
51-
fillColor = Color.combine(Color.addOpacity(trace._backgroundColor, 1 - trace.pathbar.opacity), fillColor);
52-
} else {
53-
var depthfade = trace.marker.depthfade;
54-
if(depthfade) {
55-
var fadedColor = Color.combine(Color.addOpacity(trace._backgroundColor, 0.75), fillColor);
56-
var n;
46+
if(!trace._hasColorscale && !pt.onPathbar) {
47+
var depthfade = trace.marker.depthfade;
48+
if(depthfade) {
49+
var fadedColor = Color.combine(Color.addOpacity(trace._backgroundColor, 0.75), fillColor);
50+
var n;
5751

58-
if(depthfade === true) {
59-
var maxDepth = helpers.getMaxDepth(trace);
60-
if(isFinite(maxDepth)) {
61-
if(helpers.isLeaf(pt)) {
62-
n = 0;
63-
} else {
64-
n = (trace._maxVisibleLayers) - (pt.data.depth - trace._entryDepth);
65-
}
52+
if(depthfade === true) {
53+
var maxDepth = helpers.getMaxDepth(trace);
54+
if(isFinite(maxDepth)) {
55+
if(helpers.isLeaf(pt)) {
56+
n = 0;
6657
} else {
67-
n = pt.data.height + 1;
58+
n = (trace._maxVisibleLayers) - (pt.data.depth - trace._entryDepth);
6859
}
69-
} else { // i.e. case of depthfade === 'reversed'
70-
n = pt.data.depth - trace._entryDepth;
71-
if(!trace._atRootLevel) n++;
60+
} else {
61+
n = pt.data.height + 1;
7262
}
63+
} else { // i.e. case of depthfade === 'reversed'
64+
n = pt.data.depth - trace._entryDepth;
65+
if(!trace._atRootLevel) n++;
66+
}
7367

74-
if(n > 0) {
75-
for(var i = 0; i < n; i++) {
76-
var ratio = 0.5 * i / n;
77-
fillColor = Color.combine(Color.addOpacity(fadedColor, ratio), fillColor);
78-
}
68+
if(n > 0) {
69+
for(var i = 0; i < n; i++) {
70+
var ratio = 0.5 * i / n;
71+
fillColor = Color.combine(Color.addOpacity(fadedColor, ratio), fillColor);
7972
}
8073
}
8174
}
@@ -92,8 +85,7 @@ function styleOne(s, pt, trace, opts) {
9285

9386
s.style('stroke-width', lineWidth)
9487
.call(Color.fill, fillColor)
95-
.call(Color.stroke, lineColor)
96-
.style('opacity', null);
88+
.call(Color.stroke, lineColor);
9789
}
9890

9991
module.exports = {
-13 Bytes
Loading
-430 Bytes
Loading

test/image/mocks/treemap_textposition.json

-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"name": "bottom left textposition",
77
"textposition": "bottom left",
88
"pathbar": {
9-
"opacity": 0.5,
109
"side": "bottom",
1110
"textfont": {
1211
"size": 12,
@@ -115,7 +114,6 @@
115114
"name": "bottom center textposition",
116115
"textposition": "bottom center",
117116
"pathbar": {
118-
"opacity": 0.5,
119117
"textfont": {
120118
"size": 12,
121119
"family": "Times New Roman"
@@ -225,7 +223,6 @@
225223
"name": "bottom right textposition",
226224
"textposition": "bottom right",
227225
"pathbar": {
228-
"opacity": 0.5,
229226
"side": "bottom",
230227
"textfont": {
231228
"size": 12,
@@ -656,7 +653,6 @@
656653
"name": "top left textposition",
657654
"textposition": "top left",
658655
"pathbar": {
659-
"opacity": 0.5,
660656
"textfont": {
661657
"size": 12,
662658
"family": "Times New Roman"
@@ -767,7 +763,6 @@
767763
"name": "top center textposition",
768764
"textposition": "top center",
769765
"pathbar": {
770-
"opacity": 0.5,
771766
"side": "bottom",
772767
"textfont": {
773768
"size": 12,
@@ -878,7 +873,6 @@
878873
"name": "top right textposition",
879874
"textposition": "top right",
880875
"pathbar": {
881-
"opacity": 0.5,
882876
"textfont": {
883877
"size": 12,
884878
"family": "Times New Roman"

test/jasmine/tests/treemap_test.js

-60
Original file line numberDiff line numberDiff line change
@@ -1196,66 +1196,6 @@ describe('Test treemap restyle:', function() {
11961196
.then(done);
11971197
});
11981198

1199-
it('should be able to restyle *pathbar.opacity*', function(done) {
1200-
var mock = {
1201-
data: [{
1202-
type: 'treemap',
1203-
labels: ['Root', 'A', 'B', 'b', ],
1204-
parents: ['', 'Root', 'Root', 'B'],
1205-
level: 'b'
1206-
}]
1207-
};
1208-
1209-
function _assert(msg, exp) {
1210-
return function() {
1211-
var layer = d3.select(gd).select('.treemaplayer');
1212-
1213-
var opacities = [];
1214-
var fillColors = [];
1215-
layer.selectAll('path.surface').each(function() {
1216-
opacities.push(this.style.opacity);
1217-
fillColors.push(this.style.fill);
1218-
});
1219-
1220-
expect(opacities).toEqual(exp[0], msg);
1221-
expect(fillColors).toEqual(exp[1], msg);
1222-
1223-
// editType:style
1224-
if(msg !== 'base') {
1225-
expect(Plots.doCalcdata).toHaveBeenCalledTimes(0);
1226-
expect(gd._fullData[0]._module.plot).toHaveBeenCalledTimes(0);
1227-
}
1228-
};
1229-
}
1230-
1231-
Plotly.plot(gd, mock)
1232-
.then(_assert('base', [
1233-
['', '', ''], // opacity
1234-
['rgb(255, 127, 14)', 'rgb(255, 127, 14)', 'rgb(255, 255, 255)'] // fill
1235-
]))
1236-
.then(function() {
1237-
spyOn(Plots, 'doCalcdata').and.callThrough();
1238-
spyOn(gd._fullData[0]._module, 'plot').and.callThrough();
1239-
})
1240-
.then(_restyle({'pathbar.opacity': 0.2}))
1241-
.then(_assert('lower pathbar.opacity', [
1242-
['', '', ''], // opacity
1243-
['rgb(255, 127, 14)', 'rgb(255, 229, 207)', 'rgb(255, 255, 255)'] // fill
1244-
]))
1245-
.then(_restyle({'pathbar.opacity': 0.8}))
1246-
.then(_assert('raise pathbar.opacity', [
1247-
['', '', ''], // opacity
1248-
['rgb(255, 127, 14)', 'rgb(255, 153, 62)', 'rgb(255, 255, 255)'] // fill
1249-
]))
1250-
.then(_restyle({'pathbar.opacity': null}))
1251-
.then(_assert('back to dflt', [
1252-
['', '', ''], // opacity
1253-
['rgb(255, 127, 14)', 'rgb(255, 127, 14)', 'rgb(255, 255, 255)'] // fill
1254-
]))
1255-
.catch(failTest)
1256-
.then(done);
1257-
});
1258-
12591199
it('should be able to restyle *textinfo*', function(done) {
12601200
var mock = {
12611201
data: [{

0 commit comments

Comments
 (0)