Skip to content

Hover bugs #1575 and #1600 #1627

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 2 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ function createHoverText(hoverData, opts) {
// to get custom 'name' labels pass cleanPoint
if(d.nameOverride !== undefined) d.name = d.nameOverride;

if(d.name && d.zLabelVal === undefined) {
if(d.name) {
// strip out our pseudo-html elements from d.name (if it exists at all)
name = svgTextUtils.plainText(d.name || '');

Expand Down
53 changes: 48 additions & 5 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ var fail = require('../assets/fail_test');
describe('hover info', function() {
'use strict';

var mock = require('@mocks/14.json'),
evt = {
clientX: mock.layout.width / 2,
clientY: mock.layout.height / 2
};
var mock = require('@mocks/14.json');
var evt = { xpx: 355, ypx: 150 };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... making this test suite more robust. Previously, it relied on this fallback to get the hover pixel position.


afterEach(destroyGraphDiv);

Expand Down Expand Up @@ -447,7 +444,53 @@ describe('hover info', function() {

done();
});
});
});

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

function _assert(nameLabel, lines) {
expect(d3.select('g.axistext').size()).toEqual(0, 'no common label');

var sel = d3.select('g.hovertext');
expect(sel.select('text.name').html()).toEqual(nameLabel, 'name label');
sel.select('text.nums').selectAll('tspan').each(function(_, i) {
expect(d3.select(this).html()).toEqual(lines[i], 'lines ' + i);
});
}

it('should display correct label content', function(done) {
var gd = createGraphDiv();

Plotly.plot(gd, [{
type: 'heatmap',
y: [0, 1],
z: [[1, 2, 3], [2, 2, 1]],
name: 'one',
}, {
type: 'heatmap',
y: [2, 3],
z: [[1, 2, 3], [2, 2, 1]],
name: 'two'
}], {
width: 500,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0}
})
.then(function() {
_hover(gd, 250, 100);
_assert('two', ['x: 1', 'y: 3', 'z: 2']);
})
.then(function() {
_hover(gd, 250, 300);
_assert('one', ['x: 1', 'y: 1', 'z: 2']);
})
.catch(fail)
.then(done);
});
});

Expand Down