Skip to content

Commit 5916a72

Browse files
committed
display falsy zero number
1 parent d6da48e commit 5916a72

File tree

5 files changed

+88
-5
lines changed

5 files changed

+88
-5
lines changed

src/traces/pie/calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function calc(gd, trace) {
100100
thisText = hasLabel ? [pt.label] : [];
101101
if(hasText) {
102102
var texti = helpers.getFirstFilled(trace.text, pt.pts);
103-
if(texti) thisText.push(texti);
103+
if(texti || texti === 0) thisText.push(texti);
104104
}
105105
if(hasValue) thisText.push(helpers.formatPieValue(pt.v, separators));
106106
if(hasPercent) thisText.push(helpers.formatPiePercent(pt.v / vTotal, separators));

src/traces/pie/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ function attachFxHandlers(sliceTop, gd, cd) {
352352
if(hoverinfo && hoverinfo.indexOf('label') !== -1) thisText.push(pt.label);
353353
pt.text = helpers.castOption(trace2.hovertext || trace2.text, pt.pts);
354354
if(hoverinfo && hoverinfo.indexOf('text') !== -1) {
355-
var texti = pt.text;
356-
if(texti) thisText.push(texti);
355+
var tx = pt.text;
356+
if(tx || tx === 0) thisText.push(tx);
357357
}
358358
pt.value = pt.v;
359359
pt.valueLabel = helpers.formatPieValue(pt.v, separators);

src/traces/sunburst/plot.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,10 @@ function attachFxHandlers(sliceTop, gd, cd) {
578578
}
579579

580580
hoverPt.text = _cast('hovertext') || _cast('text');
581-
if(hasFlag('text') && hoverPt.text) thisText.push(hoverPt.text);
581+
if(hasFlag('text')) {
582+
var tx = hoverPt.text;
583+
if(tx || tx === 0) thisText.push(tx);
584+
}
582585

583586
Fx.loneHover({
584587
trace: traceNow,
@@ -736,7 +739,7 @@ function formatSliceLabel(pt, trace, fullLayout) {
736739

737740
if(hasFlag('text')) {
738741
var tx = Lib.castOption(trace, cdi.i, 'text');
739-
if(tx) thisText.push(tx);
742+
if(tx || tx === 0) thisText.push(tx);
740743
}
741744

742745
return thisText.join('<br>');
Loading
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"data": [
3+
{
4+
"name": "pie",
5+
"type": "pie",
6+
"labels": ["A", "B", "C", "D", "E", "F", "G"],
7+
"values": [7, 6, 5, 4, 3, 2, 1],
8+
"text": [null, "", "0", 0, 1, true, false],
9+
"textinfo": "label+text+value",
10+
"domain": {
11+
"x": [0, 0.48],
12+
"y": [0.52, 1]
13+
}
14+
},
15+
{
16+
"name": "sunburst",
17+
"type": "sunburst",
18+
"parents": ["", "A", "B", "C", "D", "E", "F"],
19+
"labels": ["A", "B", "C", "D", "E", "F", "G"],
20+
"values": [7, 6, 5, 4, 3, 2, 1],
21+
"text": [null, "", "0", 0, 1, true, false],
22+
"textinfo": "label+text+value",
23+
"domain": {
24+
"x": [0.52, 1],
25+
"y": [0, 0.48]
26+
}
27+
},
28+
{
29+
"name": "funnel",
30+
"type": "funnel",
31+
"y": ["A", "B", "C", "D", "E", "F", "G"],
32+
"x": [7, 6, 5, 4, 3, 2, 1],
33+
"text": [null, "", "0", 0, 1, true, false],
34+
"textinfo": "label+text+value"
35+
},
36+
{
37+
"name": "waterfall",
38+
"type": "waterfall",
39+
"x": ["A", "B", "C", "D", "E", "F", "G"],
40+
"y": [5, -4, 3, -2, 1, null, 3.14],
41+
"measure": ["r", "r", "r", "r", "r", "t", "a"],
42+
"text": [null, "", "0", 0, 1, true, false],
43+
"textinfo": "label+text+final",
44+
"textposition": "auto",
45+
"xaxis": "x2",
46+
"yaxis": "y2"
47+
}
48+
],
49+
"layout": {
50+
"width": 800,
51+
"height": 800,
52+
"dragmode": "pan",
53+
"xaxis": {
54+
"domain": [
55+
0,
56+
0.48
57+
]
58+
},
59+
"xaxis2": {
60+
"anchor": "y2",
61+
"domain": [
62+
0.52,
63+
1
64+
]
65+
},
66+
"yaxis": {
67+
"domain": [
68+
0,
69+
0.48
70+
]
71+
},
72+
"yaxis2": {
73+
"anchor": "x2",
74+
"domain": [
75+
0.52,
76+
1
77+
]
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)