Skip to content

Commit b2970cb

Browse files
committed
Merge pull request #31 from plotly/blank-text
Fix for blank elements in a text array
2 parents 4c45bee + f0db8cf commit b2970cb

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/components/drawing/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,11 @@ var TEXTOFFSETSIGN = {start:1, end:-1, middle:0, bottom:1, top:-1},
296296
LINEEXPAND = 1.3;
297297
drawing.textPointStyle = function(s, trace) {
298298
s.each(function(d){
299-
var p = d3.select(this);
300-
if(!d.tx && !trace.text) {
299+
var p = d3.select(this),
300+
text = d.tx || trace.text;
301+
if(!text || Array.isArray(text)) {
302+
// isArray test handles the case of (intentionally) missing
303+
// or empty text within a text array
301304
p.remove();
302305
return;
303306
}
@@ -320,7 +323,7 @@ drawing.textPointStyle = function(s, trace) {
320323
fontSize,
321324
d.tc || trace.textfont.color)
322325
.attr('text-anchor',h)
323-
.text(d.tx || trace.text)
326+
.text(text)
324327
.call(Plotly.util.convertToTspans);
325328
var pgroup = d3.select(this.parentNode),
326329
tspans = p.selectAll('tspan.line'),
1.48 KB
Loading

test/image/mocks/text_chart_arrays.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@
8585
],
8686
"type": "scatter",
8787
"uid": "f8361c"
88+
},
89+
{
90+
"x": [
91+
0,
92+
1,
93+
2
94+
],
95+
"y": [
96+
1.5,
97+
1.5,
98+
1.5
99+
],
100+
"mode": "text",
101+
"name": "missing text",
102+
"text": [
103+
"a",
104+
"",
105+
"b"
106+
]
88107
}
89108
],
90109
"layout": {

0 commit comments

Comments
 (0)