Skip to content

Commit 803d5a7

Browse files
committed
add test to lock issue 4716
1 parent 6ee556c commit 803d5a7

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/jasmine/tests/hover_spikeline_test.js

+63
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,69 @@ describe('spikeline hover', function() {
465465
.then(done, done.fail);
466466
});
467467

468+
it('could select the closest scatter point inside bar', function(done) {
469+
Plotly.newPlot(gd, {
470+
data: [{
471+
type: 'scatter',
472+
marker: { color: 'green' },
473+
x: [
474+
-1,
475+
0,
476+
0.5,
477+
1
478+
],
479+
y: [
480+
0.1,
481+
0.2,
482+
0.25,
483+
0.3
484+
]
485+
},
486+
{
487+
type: 'bar',
488+
marker: { color: 'blue' },
489+
x: [
490+
-1,
491+
-0.2,
492+
1
493+
],
494+
y: [
495+
1,
496+
2,
497+
0.5
498+
]
499+
}],
500+
layout: {
501+
hovermode: 'x',
502+
xaxis: { showspikes: true },
503+
yaxis: { showspikes: true },
504+
showlegend: false,
505+
width: 500,
506+
height: 500,
507+
margin: {
508+
t: 50,
509+
b: 50,
510+
l: 50,
511+
r: 50,
512+
}
513+
}
514+
})
515+
.then(function() {
516+
var lines;
517+
518+
_hover({xpx: 200, ypx: 200});
519+
lines = d3SelectAll('line.spikeline');
520+
expect(lines.size()).toBe(4);
521+
expect(lines[0][1].getAttribute('stroke')).toBe('blue');
522+
523+
_hover({xpx: 200, ypx: 350});
524+
lines = d3SelectAll('line.spikeline');
525+
expect(lines.size()).toBe(4);
526+
expect(lines[0][1].getAttribute('stroke')).toBe('green');
527+
})
528+
.then(done, done.fail);
529+
});
530+
468531
it('correctly responds to setting the spikedistance to 0 by disabling ' +
469532
'the search for points to draw the spikelines', function(done) {
470533
var _mock = makeMock('toaxis', 'closest');

0 commit comments

Comments
 (0)