Skip to content

Commit b46d26b

Browse files
committed
include final points of the wedges
1 parent 8f39a5e commit b46d26b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plotters/src/element/pie.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,22 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
152152
points.push(coord);
153153
offset_theta += radian_increment;
154154
}
155+
// final point of the wedge may not fall exactly on a radian, so add it extra
156+
let final_coord = theta_to_ordinal_coord(*self.radius, theta_final, self.center);
157+
points.push(final_coord);
158+
155159
if self.donut_hole > 0.0 {
156160
while offset_theta >= slice_start {
157161
let coord = theta_to_ordinal_coord(self.donut_hole, offset_theta, self.center);
158162
points.push(coord);
159163
offset_theta -= radian_increment;
160164
}
165+
// final point of the wedge may not fall exactly on a radian, so add it extra
166+
let final_coord_inner =
167+
theta_to_ordinal_coord(self.donut_hole, slice_start, self.center);
168+
points.push(final_coord_inner);
161169
}
162-
// final point of the wedge may not fall exactly on a radian, so add it extra
163-
if self.donut_hole == 0.0 {
164-
let final_coord = theta_to_ordinal_coord(*self.radius, theta_final, self.center);
165-
points.push(final_coord);
166-
}
170+
167171
// next wedge calculation will start from previous wedges's last radian
168172
offset_theta = theta_final;
169173

0 commit comments

Comments
 (0)