Skip to content

Commit

Permalink
tests of histogram hover label range format, and log-negative format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Oct 23, 2017
1 parent 51ad8c2 commit 3aa03f7
Showing 1 changed file with 127 additions and 5 deletions.
132 changes: 127 additions & 5 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ describe('hover info', function() {
});
});

describe('\'hover info for x/y/z traces', function() {
function _hover(gd, xpx, ypx) {
Fx.hover(gd, { xpx: xpx, ypx: ypx }, 'xy');
Lib.clearThrottle();
}
function _hover(gd, xpx, ypx) {
Fx.hover(gd, { xpx: xpx, ypx: ypx }, 'xy');
Lib.clearThrottle();
}

describe('\'hover info for x/y/z traces', function() {
it('should display correct label content', function(done) {
var gd = createGraphDiv();

Expand Down Expand Up @@ -501,6 +501,128 @@ describe('hover info', function() {
});
});

describe('hover info for negative data on a log axis', function() {
it('shows negative data even though it is infinitely off-screen', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{x: [1, 2, 3], y: [1, -5, 10]}], {
yaxis: {type: 'log'},
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({
nums: '\u22125', // unicode minus
axis: '2'
});
})
.catch(fail)
.then(done);
});
});

describe('histogram hover info', function() {
it('shows the data range when bins have multiple values', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
x: [0, 2, 3, 4, 5, 6, 7],
xbins: {start: -0.5, end: 8.5, size: 3},
type: 'histogram'
}], {
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({
nums: '3',
axis: '3 - 5'
});
})
.catch(fail)
.then(done);
});

it('shows the exact data when bins have single values', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
// even though the data aren't regularly spaced, each bin only has
// one data value in it so we see exactly that value
x: [0, 0, 3.3, 3.3, 3.3, 7, 7],
xbins: {start: -0.5, end: 8.5, size: 3},
type: 'histogram'
}], {
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({
nums: '3',
axis: '3.3'
});
})
.catch(fail)
.then(done);
});
});

describe('histogram2d hover info', function() {
it('shows the data range when bins have multiple values', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
x: [0, 2, 3, 4, 5, 6, 7],
y: [1, 3, 4, 5, 6, 7, 8],
xbins: {start: -0.5, end: 8.5, size: 3},
ybins: {start: 0.5, end: 9.5, size: 3},
type: 'histogram2d'
}], {
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({
nums: 'x: 3 - 5\ny: 4 - 6\nz: 3'
});
})
.catch(fail)
.then(done);
});

it('shows the exact data when bins have single values', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
x: [0, 0, 3.3, 3.3, 3.3, 7, 7],
y: [2, 2, 4.2, 4.2, 4.2, 8.8, 8.8],
xbins: {start: -0.5, end: 8.5, size: 3},
ybins: {start: 0.5, end: 9.5, size: 3},
type: 'histogram2d'
}], {
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 200);
assertHoverLabelContent({
nums: 'x: 3.3\ny: 4.2\nz: 3'
});
})
.catch(fail)
.then(done);
});
});

describe('hoverformat', function() {
var data = [{
x: [1, 2, 3],
Expand Down

0 comments on commit 3aa03f7

Please sign in to comment.