diff --git a/src/plots/cartesian/graph_interact.js b/src/plots/cartesian/graph_interact.js
index b84eb742273..ea28207d0eb 100644
--- a/src/plots/cartesian/graph_interact.js
+++ b/src/plots/cartesian/graph_interact.js
@@ -933,7 +933,7 @@ function createHoverText(hoverData, opts) {
else if(d.yLabel===undefined) text = d.xLabel;
else text = '('+d.xLabel+', '+d.yLabel+')';
- if(d.text) text += (text ? '
' : '') + d.text;
+ if(d.text && !Array.isArray(d.text)) text += (text ? '
' : '') + d.text;
// if 'text' is empty at this point,
// put 'name' in main label and don't show secondary label
diff --git a/test/jasmine/tests/hover_label_test.js b/test/jasmine/tests/hover_label_test.js
index ee1395464ba..55ae4642b07 100644
--- a/test/jasmine/tests/hover_label_test.js
+++ b/test/jasmine/tests/hover_label_test.js
@@ -257,7 +257,7 @@ describe('hover info', function() {
};
beforeEach(function() {
- this. gd = createGraphDiv();
+ this.gd = createGraphDiv();
});
it('should display the correct format when ticklabels true', function() {
@@ -281,4 +281,49 @@ describe('hover info', function() {
expect(hovers.select('text')[0][0].textContent).toEqual('0.23');
});
});
+
+ describe('textmode', function() {
+
+ var data = [{
+ x: [1,2,3,4],
+ y: [2,3,4,5],
+ mode: 'text',
+ hoverinfo: 'text',
+ text: ['test', null, 42, undefined]
+ }],
+ layout = {
+ width: 600,
+ height: 400
+ };
+
+ beforeEach(function(done) {
+ Plotly.plot(createGraphDiv(), data, layout).then(done);
+ });
+
+ it('should show text labels', function() {
+ mouseEvent('mousemove', 115, 310);
+ var hovers = d3.selectAll('g.hovertext');
+ expect(hovers.size()).toEqual(1);
+ expect(hovers.select('text')[0][0].textContent).toEqual('test');
+ });
+
+ it('should show number labels', function() {
+ mouseEvent('mousemove', 370, 180);
+ var hovers = d3.selectAll('g.hovertext');
+ expect(hovers.size()).toEqual(1);
+ expect(hovers.select('text')[0][0].textContent).toEqual('42');
+ });
+
+ it('should not show null text labels', function() {
+ mouseEvent('mousemove', 236, 246);
+ var hovers = d3.selectAll('g.hovertext');
+ expect(hovers.size()).toEqual(0);
+ });
+
+ it('should not show undefined text labels', function() {
+ mouseEvent('mousemove', 500, 115);
+ var hovers = d3.selectAll('g.hovertext');
+ expect(hovers.size()).toEqual(0);
+ });
+ });
});