From 70fa33074886cff7ca93128805b1a2f0ff2cd7ad Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Fri, 14 Nov 2025 11:49:07 +0800 Subject: [PATCH] plot: Rename `Label` and `Axis` include `Plot` prefix (#1597) ## Breaking changes ```diff - Label::new() + PlotLabel::new() - Axis::new() + PlotAxis::new() ``` This is to avoid naming conflicts with `gpui` and `gpui-component`. --- crates/ui/src/chart/area_chart.rs | 4 ++-- crates/ui/src/chart/bar_chart.rs | 4 ++-- crates/ui/src/chart/line_chart.rs | 4 ++-- crates/ui/src/plot/axis.rs | 10 +++++----- crates/ui/src/plot/label.rs | 6 +++--- crates/ui/src/plot/mod.rs | 4 ++-- crates/ui/src/plot/shape/bar.rs | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/ui/src/chart/area_chart.rs b/crates/ui/src/chart/area_chart.rs index 45e7bb82..78398c8c 100644 --- a/crates/ui/src/chart/area_chart.rs +++ b/crates/ui/src/chart/area_chart.rs @@ -8,7 +8,7 @@ use crate::{ plot::{ scale::{Scale, ScaleLinear, ScalePoint, Sealed}, shape::Area, - Axis, AxisText, Grid, Plot, StrokeStyle, AXIS_GAP, + AxisText, Grid, Plot, PlotAxis, StrokeStyle, AXIS_GAP, }, ActiveTheme, PixelsExt, }; @@ -142,7 +142,7 @@ where } }); - Axis::new() + PlotAxis::new() .x(height) .x_label(x_label) .stroke(cx.theme().border) diff --git a/crates/ui/src/chart/bar_chart.rs b/crates/ui/src/chart/bar_chart.rs index 21036950..31fb79d7 100644 --- a/crates/ui/src/chart/bar_chart.rs +++ b/crates/ui/src/chart/bar_chart.rs @@ -9,7 +9,7 @@ use crate::{ label::Text, scale::{Scale, ScaleBand, ScaleLinear, Sealed}, shape::Bar, - Axis, AxisText, Grid, Plot, AXIS_GAP, + PlotAxis, AxisText, Grid, Plot, AXIS_GAP, }, ActiveTheme, PixelsExt, }; @@ -125,7 +125,7 @@ where } }); - Axis::new() + PlotAxis::new() .x(height) .x_label(x_label) .stroke(cx.theme().border) diff --git a/crates/ui/src/chart/line_chart.rs b/crates/ui/src/chart/line_chart.rs index c9a03b9d..2b52b32d 100644 --- a/crates/ui/src/chart/line_chart.rs +++ b/crates/ui/src/chart/line_chart.rs @@ -8,7 +8,7 @@ use crate::{ plot::{ scale::{Scale, ScaleLinear, ScalePoint, Sealed}, shape::Line, - Axis, AxisText, Grid, Plot, StrokeStyle, AXIS_GAP, + AxisText, Grid, Plot, PlotAxis, StrokeStyle, AXIS_GAP, }, ActiveTheme, PixelsExt, }; @@ -134,7 +134,7 @@ where } }); - Axis::new() + PlotAxis::new() .x(height) .x_label(x_label) .stroke(cx.theme().border) diff --git a/crates/ui/src/plot/axis.rs b/crates/ui/src/plot/axis.rs index 76fb4330..a743719f 100644 --- a/crates/ui/src/plot/axis.rs +++ b/crates/ui/src/plot/axis.rs @@ -3,7 +3,7 @@ use gpui::{ Window, }; -use super::{label::Label, label::Text, label::TEXT_GAP, label::TEXT_SIZE, origin_point}; +use super::{label::PlotLabel, label::Text, label::TEXT_GAP, label::TEXT_SIZE, origin_point}; pub const AXIS_GAP: f32 = 18.; @@ -38,17 +38,17 @@ impl AxisText { } #[derive(Default)] -pub struct Axis { +pub struct PlotAxis { x: Option, - x_label: Label, + x_label: PlotLabel, show_x_axis: bool, y: Option, - y_label: Label, + y_label: PlotLabel, show_y_axis: bool, stroke: Hsla, } -impl Axis { +impl PlotAxis { pub fn new() -> Self { Self { show_x_axis: true, diff --git a/crates/ui/src/plot/label.rs b/crates/ui/src/plot/label.rs index 25fae840..0dfc708b 100644 --- a/crates/ui/src/plot/label.rs +++ b/crates/ui/src/plot/label.rs @@ -56,7 +56,7 @@ impl Text { } } -impl From for Label +impl From for PlotLabel where I: Iterator, { @@ -66,9 +66,9 @@ where } #[derive(Default)] -pub struct Label(Vec); +pub struct PlotLabel(Vec); -impl Label { +impl PlotLabel { pub fn new(items: Vec) -> Self { Self(items) } diff --git a/crates/ui/src/plot/mod.rs b/crates/ui/src/plot/mod.rs index 94b74fc9..806e41eb 100644 --- a/crates/ui/src/plot/mod.rs +++ b/crates/ui/src/plot/mod.rs @@ -13,9 +13,9 @@ use gpui::{point, px, App, Bounds, IntoElement, Path, PathBuilder, Pixels, Point use crate::PixelsExt; -pub use axis::{Axis, AxisText, AXIS_GAP}; +pub use axis::{AxisText, PlotAxis, AXIS_GAP}; pub use grid::Grid; -pub use label::Label; +pub use label::PlotLabel; pub trait Plot: IntoElement { fn paint(&mut self, bounds: Bounds, window: &mut Window, cx: &mut App); diff --git a/crates/ui/src/plot/shape/bar.rs b/crates/ui/src/plot/shape/bar.rs index fde45ef2..3cfd62fa 100644 --- a/crates/ui/src/plot/shape/bar.rs +++ b/crates/ui/src/plot/shape/bar.rs @@ -1,7 +1,7 @@ use gpui::{fill, point, px, App, Bounds, Hsla, PaintQuad, Pixels, Point, Window}; use crate::plot::{ - label::{Label, Text, TEXT_GAP, TEXT_HEIGHT}, + label::{PlotLabel, Text, TEXT_GAP, TEXT_HEIGHT}, origin_point, }; @@ -93,7 +93,7 @@ impl Bar { self } - fn path(&self, bounds: &Bounds) -> (Vec, Label) { + fn path(&self, bounds: &Bounds) -> (Vec, PlotLabel) { let origin = bounds.origin; let mut graph = vec![]; let mut labels = vec![]; @@ -136,7 +136,7 @@ impl Bar { } } - (graph, Label::new(labels)) + (graph, PlotLabel::new(labels)) } /// Paint the Bar.