Skip to content

Commit a7b6074

Browse files
committed
use constant _hoverd.marker.line.width - improve a treemap mock and use a darker color
1 parent fdd69e7 commit a7b6074

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

src/traces/sunburst/fx.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
180180

181181
if(isTreemap) {
182182
var slice = sliceTop.select('path.surface');
183-
opts.styleOne(slice, pt, traceNow, true);
183+
opts.styleOne(slice, pt, traceNow, {
184+
hovered: true
185+
});
184186
}
185187

186188
trace._hasHoverEvent = true;
@@ -211,7 +213,9 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
211213

212214
if(isTreemap) {
213215
var slice = sliceTop.select('path.surface');
214-
opts.styleOne(slice, pt, traceNow, false);
216+
opts.styleOne(slice, pt, traceNow, {
217+
hovered: false
218+
});
215219
}
216220
};
217221

src/traces/treemap/defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4848
}
4949

5050
coerce('tiling.flip');
51-
var tilingPad = coerce('tiling.pad');
51+
coerce('tiling.pad');
5252

5353
var text = coerce('text');
5454
coerce('texttemplate');
@@ -90,8 +90,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
9090

9191
traceOut._hovered = {
9292
marker: {
93+
opacity: 1,
9394
line: {
94-
width: Math.max(tilingPad, 2),
95+
width: 2,
9596
color: Color.contrast(layout.paper_bgcolor)
9697
}
9798
}

src/traces/treemap/draw_ancestors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) {
130130
isTransitioning: gd._transitioning
131131
});
132132

133-
slicePath.call(styleOne, pt, trace);
133+
slicePath.call(styleOne, pt, trace, {
134+
hovered: false
135+
});
134136

135137
var sliceTextGroup = Lib.ensureSingle(sliceTop, 'g', 'slicetext');
136138
var sliceText = Lib.ensureSingle(sliceTextGroup, 'text', '', function(s) {

src/traces/treemap/draw_descendants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
128128
})
129129
.call(helpers.setSliceCursor, gd, { isTransitioning: gd._transitioning });
130130

131-
slicePath.call(styleOne, pt, trace);
131+
slicePath.call(styleOne, pt, trace, {
132+
hovered: false
133+
});
132134

133135
var sliceTextGroup = Lib.ensureSingle(sliceTop, 'g', 'slicetext');
134136
var sliceText = Lib.ensureSingle(sliceTextGroup, 'text', '', function(s) {

src/traces/treemap/style.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ function style(gd) {
2121
gTrace.style('opacity', trace.opacity);
2222

2323
gTrace.selectAll('path.surface').each(function(pt) {
24-
d3.select(this).call(styleOne, pt, trace);
24+
d3.select(this).call(styleOne, pt, trace, {
25+
hovered: false
26+
});
2527
});
2628
});
2729
}
2830

29-
function styleOne(s, pt, trace, hovered) {
31+
function styleOne(s, pt, trace, opts) {
3032
var cdi = pt.data.data;
3133
var ptNumber = cdi.i;
3234
var lineColor;
3335
var lineWidth;
3436
var opacity;
3537

36-
if(hovered) {
38+
if((opts || {}).hovered) {
3739
lineColor = trace._hovered.marker.line.color;
3840
lineWidth = trace._hovered.marker.line.width;
39-
opacity = 1;
41+
opacity = trace._hovered.marker.opacity;
4042
} else {
4143
lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine;
4244
lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0;
8.9 KB
Loading

test/image/mocks/treemap_textposition.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@
977977
"layout": {
978978
"width": 1200,
979979
"height": 1200,
980+
"paper_bgcolor": "#210",
980981
"annotations": [
981982
{
982983
"showarrow": false,

0 commit comments

Comments
 (0)