Skip to content

Fixup rangebreaks l2p and p2l functions #4699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 29, 2020
Prev Previous commit
add new hover tests
  • Loading branch information
archmoj committed Mar 29, 2020
commit ff5db2b87ef28afea7780200e8c2bcac85160b6f
138 changes: 138 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,75 @@ describe('Hover on axes with rangebreaks', function() {
.then(done);
});

it('should work when rangebreaks are present on x-axis (reversed range)', function(done) {
Plotly.plot(gd, [{
mode: 'lines', // i.e. no autorange padding
x: [
'1970-01-01 00:00:00.000',
'1970-01-01 00:00:00.010',
'1970-01-01 00:00:00.050',
'1970-01-01 00:00:00.090',
'1970-01-01 00:00:00.095',
'1970-01-01 00:00:00.100',
'1970-01-01 00:00:00.150',
'1970-01-01 00:00:00.190',
'1970-01-01 00:00:00.200'
]
}], {
xaxis: {
autorange: 'reversed',
rangebreaks: [
{bounds: [
'1970-01-01 00:00:00.011',
'1970-01-01 00:00:00.089'
]},
{bounds: [
'1970-01-01 00:00:00.101',
'1970-01-01 00:00:00.189'
]}
]
},
width: 400,
height: 400,
margin: {l: 10, t: 10, b: 10, r: 10},
hovermode: 'x'
})
.then(function() {
gd.on('plotly_hover', function(d) {
eventData = d.points[0];
});
})
.then(function() { _hover(11, 11); })
.then(function() {
_assert('leftmost interval', {
nums: '8',
axis: 'Jan 1, 1970, 00:00:00.2',
x: '1970-01-01 00:00:00.2',
y: 8
});
})
.then(function() { _hover(200, 200); })
.then(function() {
_assert('middle interval', {
nums: '4',
axis: 'Jan 1, 1970, 00:00:00.095',
x: '1970-01-01 00:00:00.095',
y: 4
});
})
.then(function() { _hover(388, 388); })
.then(function() {
_assert('rightmost interval', {
nums: '0',
axis: 'Jan 1, 1970',
x: '1970-01-01',
y: 0
});
})
.catch(failTest)
.then(done);
});

it('should work when rangebreaks are present on y-axis using hovermode x (case of bar and autorange reversed)', function(done) {
Plotly.plot(gd, [{
type: 'bar',
Expand Down Expand Up @@ -2924,6 +2993,75 @@ describe('Hover on axes with rangebreaks', function() {
.catch(failTest)
.then(done);
});

it('should work when rangebreaks are present on y-axis (reversed range)', function(done) {
Plotly.plot(gd, [{
mode: 'lines', // i.e. no autorange padding
y: [
'1970-01-01 00:00:00.000',
'1970-01-01 00:00:00.010',
'1970-01-01 00:00:00.050',
'1970-01-01 00:00:00.090',
'1970-01-01 00:00:00.095',
'1970-01-01 00:00:00.100',
'1970-01-01 00:00:00.150',
'1970-01-01 00:00:00.190',
'1970-01-01 00:00:00.200'
]
}], {
yaxis: {
autorange: 'reversed',
rangebreaks: [
{bounds: [
'1970-01-01 00:00:00.011',
'1970-01-01 00:00:00.089'
]},
{bounds: [
'1970-01-01 00:00:00.101',
'1970-01-01 00:00:00.189'
]}
]
},
width: 400,
height: 400,
margin: {l: 10, t: 10, b: 10, r: 10},
hovermode: 'y'
})
.then(function() {
gd.on('plotly_hover', function(d) {
eventData = d.points[0];
});
})
.then(function() { _hover(388, 30); })
.then(function() {
_assert('topmost interval', {
nums: '0',
axis: 'Jan 1, 1970',
x: 0,
y: '1970-01-01'
});
})
.then(function() { _hover(200, 200); })
.then(function() {
_assert('middle interval', {
nums: '4',
axis: 'Jan 1, 1970, 00:00:00.095',
x: 4,
y: '1970-01-01 00:00:00.095'
});
})
.then(function() { _hover(11, 370); })
.then(function() {
_assert('bottom interval', {
nums: '8',
axis: 'Jan 1, 1970, 00:00:00.2',
x: 8,
y: '1970-01-01 00:00:00.2'
});
})
.catch(failTest)
.then(done);
});
});

describe('hover updates', function() {
Expand Down