Skip to content

Commit d5fd040

Browse files
committed
fix a couple text-rendering bug
- get correct inside text contrasted color - fix text position for concentric circle sector
1 parent 66b45ab commit d5fd040

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

src/traces/sunburst/plot.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = function plot(gd, cdmodule) {
100100
pt.xmid = (pt.x0 + pt.x1) / 2;
101101
pt.pxmid = rx2px(pt.rpx1, pt.xmid);
102102
pt.midangle = -(pt.xmid - Math.PI / 2);
103-
pt.halfangle = 0.5 * Math.min(Lib.angleDelta(pt.x0, pt.x1), Math.PI);
103+
pt.halfangle = 0.5 * Math.min(Lib.angleDelta(pt.x0, pt.x1) || Math.PI, Math.PI);
104104
pt.ring = 1 - (pt.rpx0 / pt.rpx1);
105105
pt.rInscribed = getInscribedRadiusFraction(pt, trace);
106106
quadrants[pt.pxmid[1] < 0 ? 0 : 1][pt.pxmid[0] < 0 ? 0 : 1].push(pt);
@@ -137,8 +137,8 @@ module.exports = function plot(gd, cdmodule) {
137137
'text-anchor': 'middle'
138138
})
139139
.call(Drawing.font, isRoot || textPosition === 'outside' ?
140-
determineOutsideTextFont(trace, pt, gd._fullLayout.font) :
141-
determineInsideTextFont(trace, pt, gd._fullLayout.font))
140+
determineOutsideTextFont(trace, pt, fullLayout.font) :
141+
determineInsideTextFont(trace, pt, fullLayout.font))
142142
.call(svgTextUtils.convertToTspans, gd);
143143

144144
// position the text relative to the slice
@@ -419,7 +419,8 @@ function formatSliceLabel(pt, trace, fullLayout) {
419419
}
420420

421421
function determineOutsideTextFont(trace, pt, layoutFont) {
422-
var ptNumber = pt.data.data.i;
422+
var cdi = pt.data.data;
423+
var ptNumber = cdi.i;
423424

424425
var color = Lib.castOption(trace, ptNumber, 'outsidetextfont.color') ||
425426
Lib.castOption(trace, ptNumber, 'textfont.color') ||
@@ -441,7 +442,8 @@ function determineOutsideTextFont(trace, pt, layoutFont) {
441442
}
442443

443444
function determineInsideTextFont(trace, pt, layoutFont) {
444-
var ptNumber = pt.data.data.i;
445+
var cdi = pt.data.data;
446+
var ptNumber = cdi.i;
445447

446448
var customColor = Lib.castOption(trace, ptNumber, 'insidetextfont.color');
447449
if(!customColor && trace._input.textfont) {
@@ -462,7 +464,7 @@ function determineInsideTextFont(trace, pt, layoutFont) {
462464
layoutFont.size;
463465

464466
return {
465-
color: customColor || Color.contrast(pt.color),
467+
color: customColor || Color.contrast(cdi.color),
466468
family: family,
467469
size: size
468470
};
5.9 KB
Loading
75 Bytes
Loading
3.05 KB
Loading
34.7 KB
Loading
57 Bytes
Loading
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"data": [
3+
{
4+
"type": "sunburst",
5+
"labels": ["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
6+
"parents": ["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
7+
"level": "Awan",
8+
"domain": {"x": [0, 0.5]}
9+
},
10+
{
11+
"type": "sunburst",
12+
"labels": ["Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
13+
"parents": ["Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
14+
"maxdepth": 2,
15+
"domain": {"x": [0.5, 1]}
16+
}
17+
],
18+
"layout": {
19+
"sunburstcolorway": ["#8dd3c7", "#ffffb3", "#bebada", "#fb8072", "#80b1d3", "#fdb462", "#b3de69"]
20+
}
21+
}

0 commit comments

Comments
 (0)