Skip to content

Axes.draw w/o getBoundingClientRect + many axis automargin fixes #4165

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 15 commits into from
Sep 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add spikeline tests
- covering cases where `ax._subplotsWith.length > 1`
  and ax in question isn't at extremity of graph
- covering cases for `anchor:'free'` axes
- make other test use `Plotly.plot` instead of `newPlot`,
  to not purge the graph twice.
  • Loading branch information
etpinard committed Sep 4, 2019
commit 16542f3d29ad994bc2c99fd27f18d18fbe05a5bc
114 changes: 114 additions & 0 deletions test/jasmine/tests/hover_spikeline_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,120 @@ describe('spikeline hover', function() {
.then(done);
});

it('draws lines up to x-axis position', function(done) {
Plotly.plot(gd, [
{ y: [1, 2, 1] },
{ y: [2, 1, 2], yaxis: 'y2' }
], {
// here the x-axis is drawn at the middle of the graph
xaxis: { showspike: true, spikemode: 'toaxis' },
yaxis: { domain: [0.5, 1] },
yaxis2: { anchor: 'x', domain: [0, 0.5] },
width: 400,
height: 400
})
.then(function() {
_hover({xval: 1, yval: 2});
// from "y" of x-axis up to "y" of pt
_assert([[189, 210.5, 189, 109.25]], []);
})
.then(function() { return Plotly.relayout(gd, 'xaxis.spikemode', 'across'); })
.then(function() {
_hover({xval: 1, yval: 2});
// from "y" of xy subplot top, down to "y" xy2 subplot bottom
_assert([[189, 100, 189, 320]], []);
})
.catch(failTest)
.then(done);
});

it('draws lines up to y-axis position - anchor free case', function(done) {
Plotly.plot(gd, [
{ y: [1, 2, 1] },
{ y: [2, 1, 2], xaxis: 'x2' }
], {
yaxis: { domain: [0.5, 1] },
xaxis2: {
anchor: 'free', position: 0, overlaying: 'x',
showspikes: true, spikemode: 'across'
},
width: 400,
height: 400,
showlegend: false
})
.then(function() {
_hover({xval: 0, yval: 2}, 'x2y');
// from "y" of pt, down to "y" of x2 axis
_assert([[95.75, 100, 95.75, 320]], []);
})
.then(function() { return Plotly.relayout(gd, 'xaxis2.position', 0.6); })
.then(function() {
_hover({xval: 0, yval: 2}, 'x2y');
// from "y" of pt, down to "y" of x axis (which is further down)
_assert([[95.75, 100, 95.75, 210]], []);
})
.catch(failTest)
.then(done);
});

it('draws lines up to y-axis position', function(done) {
Plotly.plot(gd, [
{ y: [1, 2, 1] },
{ y: [2, 1, 2], xaxis: 'x2' }
], {
// here the y-axis is drawn at the middle of the graph,
// with xy subplot to the right and xy2 to the left
yaxis: { showspike: true, spikemode: 'toaxis' },
xaxis: { domain: [0.5, 1] },
xaxis2: { anchor: 'y', domain: [0, 0.5] },
width: 400,
height: 400,
showlegend: false
})
.then(function() {
_hover({xval: 1, yval: 2});
// from "x" of y-axis to "x" of pt
_assert([[199.5, 114.75, 260, 114.75]], []);
})
.then(function() { return Plotly.relayout(gd, 'yaxis.spikemode', 'across'); })
.then(function() {
_hover({xval: 1, yval: 2});
// from "x" at xy2 subplot left, to "x" at xy subplot right
_assert([[80, 114.75, 320, 114.75]], []);
})
.catch(failTest)
.then(done);
});

it('draws lines up to y-axis position - anchor free case', function(done) {
Plotly.plot(gd, [
{ y: [1, 2, 1] },
{ y: [2, 1, 2], yaxis: 'y2' }
], {
xaxis: { domain: [0.5, 1] },
yaxis2: {
anchor: 'free', position: 0, overlaying: 'y',
showspikes: true, spikemode: 'across'
},
width: 400,
height: 400,
showlegend: false
})
.then(function() {
_hover({xval: 0, yval: 2}, 'xy2');
// from "x" of y2 axis to "x" of pt
_assert([[80, 114.75, 320, 114.75]], []);
})
.then(function() { return Plotly.relayout(gd, 'yaxis2.position', 0.6); })
.then(function() {
_hover({xval: 0, yval: 2}, 'xy2');
// from "x" of y axis (which is further left) to "x" of pt
_assert([[200, 114.75, 320, 114.75]], []);
})
.catch(failTest)
.then(done);
});

it('draws lines and markers on enabled axes in the spikesnap "cursor" mode', function(done) {
var _mock = makeMock('toaxis', 'x');

Expand Down