10000 Hover bugs #1575 and #1600 by etpinard · Pull Request #1627 · plotly/plotly.js · GitHub
[go: up one dir, main page]

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 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
fixes #1600 - allow z cartesian traces to have a name hover label
  • Loading branch information
etpinard committed Apr 26, 2017
commit cf61dc2f167ea2ca8704a0cf30cecd1985a071e6
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
46 changes: 46 additions & 0 deletions test/jasmine/tests/hover_label_test.js
47CA
Original file line number Diff line number Diff line change
Expand Up @@ -444,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
0