Opened 9 years ago

Closed 6 years ago

# The radius of pie chart is different when labelOffset is set with a negative number and there is only one slice.

Reported by: Owned by: cjolif undecided 1.13 Charting 1.8.3

### Description

In Pie.js, when labelOffset is a negative value, r is re-calculated.

```if(this.opt.labelOffset < 0){
r = Math.min(rx - 2 * shift, ry - size) + this.opt.labelOffset;
}
```

With this condition, when there is only one slice, circle.r is used as a radius.

```if(slice >= 1){
// whole pie
specialFill = this._plotFill(theme.series.fill, dim, offsets);
specialFill = this._shapeFill(specialFill,
{
x: circle.cx - circle.r, y: circle.cy - circle.r,
width: 2 * circle.r, height: 2 * circle.r
});
specialFill = this._pseudoRadialFill(specialFill, {x: circle.cx, y: circle.cy}, circle.r);
var shape = s.createCircle(circle).setFill(specialFill).setStroke(theme.series.stroke);
this.dyn.push({fill: specialFill, stroke: theme.series.stroke});

if(events){
o = {
element: "slice",
index:   i,
run:     this.run,
shape:   shape,
x:       i,
y:       typeof v == "number" ? v : v.y,
cx:      circle.cx,
cy:      circle.cy,
cr:      r
};
this._connectEvents(o);
eventSeries[i] = o;
}
return false;	// we continue because we want to collect null data points for legend
}
```

When drawing fans, r is used as a radius.

### comment:1 follow-up:  2 Changed 9 years ago by bill

Component: DojoX Drawing → Charting

You meant for this to be filed against Charting, not dojox/drawing, right?

### comment:2 in reply to:  1 Changed 9 years ago by [email protected]…

Yes this bug is against Charting. Thanks for clarification!

You meant for this to be filed against Charting, not dojox/drawing, right?

### comment:3 Changed 9 years ago by cjolif

Owner: set to cjolif new → assigned defect → enhancement

I think this is (unfortunately?) kind of "on purpose". Indeed when there is single slice even if you have a negative labelOffset the single label is always drawn inside. I agree this could be different. I have just mixed feelings about changing that now as it stayed like that for years. At least seems more like a enhancement than a fix to me.

Note also that even if labelOffset was taken into account the resulting radius would not necessarily be exactly the same in single slice or multiple slices because it also take the labels size into account.

### comment:4 Changed 6 years ago by dylan

Milestone: tbd → 1.12 → patchwelcome assigned → closed

Given that no one has shown interest in creating a patch in the past 2+ years, I'm closing this as patchwelcome.

Note: See TracTickets for help on using tickets.