Skip to content

Commit bca4a70

Browse files
committed
unified hoverlabel: test waterfall symbol
1 parent c0e1bf7 commit bca4a70

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/components/legend/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ module.exports = function style(s, gd, legend) {
291291
function styleWaterfalls(d) {
292292
var trace = d[0].trace;
293293

294-
if(d[0]._distinct && d[0].trace[d[0].dir]) {
294+
if(d[0]._distinct && d[0].dir && trace[d[0].dir] && trace[d[0].dir].marker) {
295295
var cont = d[0].trace[d[0].dir].marker;
296296
d[0].mc = cont.color;
297297
d[0].mlw = cont.line.width;

test/jasmine/tests/hover_label_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,8 @@ describe('hovermode: (x|y)unified', function() {
36993699
var hoverLayer = d3.select('g.hoverlayer');
37003700
var hover = hoverLayer.select('g.legend');
37013701
var traces = hover.selectAll('g.traces');
3702+
expect(traces.size()).toBe(exp.length);
3703+
37023704
traces.each(function(d, i) {
37033705
var pts = d3.select(this).selectAll('g.legendpoints path');
37043706
pts.each(function() {
@@ -3923,6 +3925,31 @@ describe('hovermode: (x|y)unified', function() {
39233925
.then(done);
39243926
});
39253927

3928+
it('should style waterfall symbols correctly', function(done) {
3929+
var mock = require('@mocks/waterfall_custom.json');
3930+
var mockCopy = Lib.extendDeep({}, mock);
3931+
mockCopy.layout.hovermode = 'x unified';
3932+
Plotly.newPlot(gd, mockCopy)
3933+
.then(function(gd) {
3934+
_hover(gd, {xval: 4});
3935+
assertSymbol([
3936+
['rgb(255, 65, 54)', '0px', '']
3937+
]);
3938+
return Plotly.restyle(gd, {
3939+
'decreasing.marker.line.width': 5,
3940+
'decreasing.marker.line.color': 'violet'
3941+
});
3942+
})
3943+
.then(function(gd) {
3944+
_hover(gd, {xval: 4});
3945+
assertSymbol([
3946+
['rgb(255, 65, 54)', '5px', 'rgb(238, 130, 238)']
3947+
]);
3948+
})
3949+
.catch(failTest)
3950+
.then(done);
3951+
});
3952+
39263953
it('label should have color of paper_bgcolor', function(done) {
39273954
var mockCopy = Lib.extendDeep({}, mock);
39283955
var bgcolor = 'rgb(15, 200, 85)';

0 commit comments

Comments
 (0)