Skip to content

Commit aec8848

Browse files
authored
Merge pull request #603 from wangjiawen2013/next-release-devel
pie chart supports RGBAColor
2 parents a7a3f89 + 0dace11 commit aec8848

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plotters/src/element/pie.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
element::{Drawable, PointCollection},
3-
style::{IntoFont, RGBColor, TextStyle, BLACK},
3+
style::{IntoFont, RGBAColor, TextStyle, BLACK},
44
};
55
use plotters_backend::{BackendCoord, DrawingBackend, DrawingErrorKind};
66
use std::{error::Error, f64::consts::PI, fmt::Display};
@@ -24,7 +24,7 @@ pub struct Pie<'a, Coord, Label: Display> {
2424
center: &'a Coord, // cartesian coord
2525
radius: &'a f64,
2626
sizes: &'a [f64],
27-
colors: &'a [RGBColor],
27+
colors: &'a [RGBAColor],
2828
labels: &'a [Label],
2929
total: f64,
3030
start_radian: f64,
@@ -40,7 +40,7 @@ impl<'a, Label: Display> Pie<'a, (i32, i32), Label> {
4040
center: &'a (i32, i32),
4141
radius: &'a f64,
4242
sizes: &'a [f64],
43-
colors: &'a [RGBColor],
43+
colors: &'a [RGBAColor],
4444
labels: &'a [Label],
4545
) -> Self {
4646
// fold iterator to pre-calculate total from given slice sizes
@@ -69,7 +69,7 @@ impl<'a, Label: Display> Pie<'a, (i32, i32), Label> {
6969
/// Default is set to start at 0, which is aligned on the x axis.
7070
/// ```
7171
/// use plotters::prelude::*;
72-
/// let mut pie = Pie::new(&(50,50), &10.0, &[50.0, 25.25, 20.0, 5.5], &[RED, BLUE, GREEN, WHITE], &["Red", "Blue", "Green", "White"]);
72+
/// let mut pie = Pie::new(&(50,50), &10.0, &[50.0, 25.25, 20.0, 5.5], &[RED.to_rgba(), BLUE.to_rgba(), GREEN.to_rgba(), WHITE.to_rgba()], &["Red", "Blue", "Green", "White"]);
7373
/// pie.start_angle(-90.0); // retract to a right angle, so it starts aligned to a vertical Y axis.
7474
/// ```
7575
pub fn start_angle(&mut self, start_angle: f64) {

0 commit comments

Comments
 (0)