8000 sunburst: consider empty text string as valid text for texttemplate · plotly/plotly.js@6e613d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e613d2

Browse files
committed
sunburst: consider empty text string as valid text for texttemplate
1 parent b5f0316 commit 6e613d2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/traces/sunburst/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ function formatSliceLabel(pt, trace, fullLayout) {
718718
obj.color = cdi.color;
719719
}
720720
var ptTx = Lib.castOption(trace, cdi.i, 'text');
721-
if(Lib.isValidTextValue(ptTx)) obj.text = ptTx;
721+
if(Lib.isValidTextValue(ptTx) || ptTx === '') obj.text = ptTx;
722722
obj.customdata = Lib.castOption(trace, cdi.i, 'customdata');
723723
return Lib.texttemplateString(txt, obj, fullLayout._d3locale, obj, trace._meta || {});
724724
}

test/jasmine/tests/sunburst_test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,4 +1251,14 @@ describe('Test sunburst texttemplate:', function() {
12511251
[['txt: %{label}', '%{text}', 'value: %{value}'], ['txt: Eve', '2', 'value: 13', '', '']],
12521252
['%{color}', ['rgba(0,0,0,0)', '#1f77b4', '#ff7f0e', '#1f77b4', '#1f77b4']]
12531253
]);
1254+
1255+
// Check for empty string
1256+
checkTextTemplate([{
1257+
'type': 'sunburst',
1258+
'labels': ['Alpha', 'Bravo'],
1259+
'parents': ['', 'Alpha'],
1260+
'text': ['description', '']
1261+
}], 'g.slicetext', [
1262+
['%{label} %{text}', ['Alpha description', 'Bravo ']]
1263+
]);
12541264
});

0 commit comments

Comments
 (0)
0