diff --git a/src/components/drawing/index.js b/src/components/drawing/index.js index c22ef1b37c3..448ce644ce4 100644 --- a/src/components/drawing/index.js +++ b/src/components/drawing/index.js @@ -296,8 +296,11 @@ var TEXTOFFSETSIGN = {start:1, end:-1, middle:0, bottom:1, top:-1}, LINEEXPAND = 1.3; drawing.textPointStyle = function(s, trace) { s.each(function(d){ - var p = d3.select(this); - if(!d.tx && !trace.text) { + var p = d3.select(this), + text = d.tx || trace.text; + if(!text || Array.isArray(text)) { + // isArray test handles the case of (intentionally) missing + // or empty text within a text array p.remove(); return; } @@ -320,7 +323,7 @@ drawing.textPointStyle = function(s, trace) { fontSize, d.tc || trace.textfont.color) .attr('text-anchor',h) - .text(d.tx || trace.text) + .text(text) .call(Plotly.util.convertToTspans); var pgroup = d3.select(this.parentNode), tspans = p.selectAll('tspan.line'), diff --git a/test/image/baselines/text_chart_arrays.png b/test/image/baselines/text_chart_arrays.png index 1b40abfb14e..9c5e580cdbf 100644 Binary files a/test/image/baselines/text_chart_arrays.png and b/test/image/baselines/text_chart_arrays.png differ diff --git a/test/image/mocks/text_chart_arrays.json b/test/image/mocks/text_chart_arrays.json index 885a0e87b56..3fa728c52ea 100644 --- a/test/image/mocks/text_chart_arrays.json +++ b/test/image/mocks/text_chart_arrays.json @@ -85,6 +85,25 @@ ], "type": "scatter", "uid": "f8361c" + }, + { + "x": [ + 0, + 1, + 2 + ], + "y": [ + 1.5, + 1.5, + 1.5 + ], + "mode": "text", + "name": "missing text", + "text": [ + "a", + "", + "b" + ] } ], "layout": {