Skip to content

Commit 8690ee7

Browse files
authored
Merge pull request #2698 from plotly/scatter3d-scalar-hovertext-fix
Fix scatter3d scalar hovertext handling
2 parents ece927f + 70d5240 commit 8690ee7

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/traces/scatter3d/convert.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,33 @@ proto.handlePick = function(selection) {
5050
(selection.object === this.linePlot ||
5151
selection.object === this.delaunayMesh ||
5252
selection.object === this.textMarkers ||
53-
selection.object === this.scatterPlot)) {
53+
selection.object === this.scatterPlot)
54+
) {
55+
var ind = selection.index = selection.data.index;
56+
5457
if(selection.object.highlight) {
5558
selection.object.highlight(null);
5659
}
5760
if(this.scatterPlot) {
5861
selection.object = this.scatterPlot;
5962
this.scatterPlot.highlight(selection.data);
6063
}
64+
65+
selection.textLabel = '';
6166
if(this.textLabels) {
62-
if(this.textLabels[selection.data.index] !== undefined) {
63-
selection.textLabel = this.textLabels[selection.data.index];
67+
if(Array.isArray(this.textLabels)) {
68+
if(this.textLabels[ind] || this.textLabels[ind] === 0) {
69+
selection.textLabel = this.textLabels[ind];
70+
}
6471
} else {
6572
selection.textLabel = this.textLabels;
6673
}
6774
}
68-
else selection.textLabel = '';
6975

70-
var selectIndex = selection.index = selection.data.index;
7176
selection.traceCoordinate = [
72-
this.data.x[selectIndex],
73-
this.data.y[selectIndex],
74-
this.data.z[selectIndex]
77+
this.data.x[ind],
78+
this.data.y[ind],
79+
this.data.z[ind]
7580
];
7681

7782
return true;

test/jasmine/tests/gl3d_plot_interact_test.js

+5
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ describe('@gl Test gl3d plots', function() {
203203
.then(function() {
204204
assertHoverText(null, null, null, 'Clementine');
205205

206+
return Plotly.restyle(gd, 'hovertext', 'HEY');
207+
})
208+
.then(function() {
209+
assertHoverText(null, null, null, 'HEY');
210+
206211
return Plotly.restyle(gd, 'hoverinfo', 'z');
207212
})
208213
.then(function() {

0 commit comments

Comments
 (0)