Skip to content

Add support for (hover) 'text' in mesh3d traces #2327

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 5 commits into from
Feb 6, 2018
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
13 changes: 11 additions & 2 deletions src/traces/surface/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,18 @@ var attrs = module.exports = overrideAll({
},

text: {
valType: 'data_array',
description: 'Sets the text elements associated with each z value.'
valType: 'string',
role: 'info',
dflt: '',
arrayOk: true,
editType: 'calc',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh this is in an overrideAll so you don't need editType - which I think applies to a few more of the additions in this PR too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

(I see you 🔪 some editType lines, just not the one I made the comment directly on 😅 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Fixed in -> 13a3ecf

description: [
'Sets the text elements associated with each z value.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
},

surfacecolor: {
valType: 'data_array',
description: [
Expand Down
7 changes: 5 additions & 2 deletions src/traces/surface/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ proto.handlePick = function(selection) {
];

var text = this.data.text;
if(text && text[selectIndex[1]] && text[selectIndex[1]][selectIndex[0]] !== undefined) {
if(Array.isArray(text) && text[selectIndex[1]] && text[selectIndex[1]][selectIndex[0]] !== undefined) {
selection.textLabel = text[selectIndex[1]][selectIndex[0]];
} else if(text) {
selection.textLabel = text;
} else {
selection.textLabel = '';
}
else selection.textLabel = '';

selection.data.dataCoordinate = selection.dataCoordinate.slice();

Expand Down
5 changes: 5 additions & 0 deletions test/jasmine/tests/gl3d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ describe('Test gl3d plots', function() {
.then(_hover)
.then(function() {
assertHoverText(null, null, null, 'one two');

return Plotly.restyle(gd, 'text', 'yo!');
})
.then(function() {
assertHoverText(null, null, null, 'yo!');
})
.then(done);
});
Expand Down