Skip to content

Commit f101aec

Browse files
committed
fix(pie): cycle stroke.colors across slices instead of indexing off the end
Pie/donut/polarArea data is a single series, so a user-supplied `stroke.colors` shorter than the slice count was not padded by the theme engine (unlike fill colors, which already cycle via pushExtraColors). The per-slice draw indexed `lineColorArr[i]` directly, so only slice 0 got the requested color and the remaining slices fell back to a grey default — e.g. `stroke: { colors: ['#fff'] }` left all but the first border grey. Cycle the array with `lineColorArr[i % length]` so a single color borders every slice, matching fill-color behaviour. Backward compatible: callers passing a full-length array still hit `[i]`; an empty array stays undefined.
1 parent 25c8202 commit f101aec

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/charts/Pie.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,15 @@ class Pie {
303303

304304
const elPath = graphics.drawPath({
305305
d: path,
306+
// Pie/donut/polarArea data is a single series, so a user-supplied
307+
// `stroke.colors` shorter than the slice count is NOT padded by the
308+
// theme engine (unlike fill colors, which cycle). Without this, only
309+
// slice 0 gets the requested color and the rest fall back to a grey
310+
// default. Cycle the array — matching fill-color behaviour — so a
311+
// single `stroke.colors: ['#fff']` borders every slice as expected.
306312
stroke: Array.isArray(this.lineColorArr)
307-
? this.lineColorArr[i]
313+
? this.lineColorArr[i] ??
314+
this.lineColorArr[i % this.lineColorArr.length]
308315
: this.lineColorArr,
309316
strokeWidth: 0,
310317
fill: pathFill,

0 commit comments

Comments
 (0)