diff --git a/demo/src/plot_demo.rs b/demo/src/plot_demo.rs index a7825e0..50a4ce6 100644 --- a/demo/src/plot_demo.rs +++ b/demo/src/plot_demo.rs @@ -976,7 +976,7 @@ impl ChartsDemo { .map(|(x, f)| Bar::new(x, f * 10.0).width(0.1)) .collect(), ) - .color(Color32::LIGHT_BLUE); + .default_color(Color32::LIGHT_BLUE); if !self.vertical { chart = chart.horizontal(); diff --git a/egui_plot/src/items/mod.rs b/egui_plot/src/items/mod.rs index ce7533c..5af263b 100644 --- a/egui_plot/src/items/mod.rs +++ b/egui_plot/src/items/mod.rs @@ -1240,7 +1240,7 @@ pub struct BarChart { base: PlotItemBase, pub(super) bars: Vec, - pub(super) default_color: Color32, + default_color: Color32, /// A custom element formatter pub(super) element_formatter: Option String>>, @@ -1262,7 +1262,7 @@ impl BarChart { /// It can be overridden at the bar level (see [[`Bar`]]). /// Default is `Color32::TRANSPARENT` which means a color will be auto-assigned. #[inline] - pub fn color(mut self, color: impl Into) -> Self { + pub fn default_color(mut self, color: impl Into) -> Self { let plot_color = color.into(); self.default_color = plot_color; for b in &mut self.bars { @@ -1398,8 +1398,7 @@ pub struct BoxPlot { base: PlotItemBase, pub(super) boxes: Vec, - pub(super) default_color: Color32, - pub(super) name: String, + default_color: Color32, /// A custom element formatter pub(super) element_formatter: Option String>>, @@ -1412,7 +1411,6 @@ impl BoxPlot { base: PlotItemBase::new(name.into()), boxes, default_color: Color32::TRANSPARENT, - name: String::new(), element_formatter: None, } } @@ -1422,7 +1420,7 @@ impl BoxPlot { /// It can be overridden at the element level (see [`BoxElem`]). /// Default is `Color32::TRANSPARENT` which means a color will be auto-assigned. #[inline] - pub fn color(mut self, color: impl Into) -> Self { + pub fn default_color(mut self, color: impl Into) -> Self { let plot_color = color.into(); self.default_color = plot_color; for box_elem in &mut self.boxes { @@ -1478,10 +1476,6 @@ impl PlotItem for BoxPlot { // nothing to do } - fn name(&self) -> &str { - self.name.as_str() - } - fn color(&self) -> Color32 { self.default_color } diff --git a/egui_plot/src/plot_ui.rs b/egui_plot/src/plot_ui.rs index dfa05d7..8d7fabd 100644 --- a/egui_plot/src/plot_ui.rs +++ b/egui_plot/src/plot_ui.rs @@ -224,8 +224,8 @@ impl<'a> PlotUi<'a> { } // Give the elements an automatic color if no color has been assigned. - if box_plot.default_color == Color32::TRANSPARENT { - box_plot = box_plot.color(self.auto_color()); + if box_plot.color() == Color32::TRANSPARENT { + box_plot = box_plot.default_color(self.auto_color()); } self.items.push(Box::new(box_plot)); } @@ -237,8 +237,8 @@ impl<'a> PlotUi<'a> { } // Give the elements an automatic color if no color has been assigned. - if chart.default_color == Color32::TRANSPARENT { - chart = chart.color(self.auto_color()); + if chart.color() == Color32::TRANSPARENT { + chart = chart.default_color(self.auto_color()); } self.items.push(Box::new(chart)); }