Skip to content

Commit f110d06

Browse files
committed
Remove category coordinate
1 parent 1403de2 commit f110d06

File tree

6 files changed

+15
-225
lines changed

6 files changed

+15
-225
lines changed

examples/boxplot.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4242
.map(|(k, v)| (k.0.clone(), k.1.clone(), Quartiles::new(&v)))
4343
.collect();
4444

45-
let category = Category::new(
46-
"Host",
47-
dataset
48-
.iter()
49-
.unique_by(|x| x.0.clone())
50-
.sorted_by(|a, b| b.2.median().partial_cmp(&a.2.median()).unwrap())
51-
.map(|x| x.0.clone())
52-
.collect(),
53-
);
45+
let host_list:Vec<_> = dataset
46+
.iter()
47+
.unique_by(|x| x.0.clone())
48+
.sorted_by(|a, b| b.2.median().partial_cmp(&a.2.median()).unwrap())
49+
.map(|x| x.0.clone())
50+
.collect();
5451

5552
let mut colors = (0..).map(Palette99::pick);
5653
let mut offsets = (-12..).step_by(24);
@@ -75,21 +72,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7572
.caption("Ping Boxplot", ("sans-serif", 20).into_font())
7673
.build_ranged(
7774
values_range.start - 1.0..values_range.end + 1.0,
78-
category.range(),
75+
host_list[..].into_centric()
7976
)?;
8077

8178
chart
8279
.configure_mesh()
8380
.x_desc("Ping, ms")
84-
.y_desc(category.name())
85-
.y_labels(category.len())
81+
.y_desc("Host")
82+
.y_labels(host_list.len())
8683
.line_style_2(&WHITE)
8784
.draw()?;
8885

8986
for (label, (values, style, offset)) in &series {
9087
chart
9188
.draw_series(values.iter().map(|x| {
92-
Boxplot::new_horizontal(category.get(&x.0).unwrap(), &x.1)
89+
Boxplot::new_horizontal(CentricValues::CenterOf(&x.0), &x.1)
9390
.width(20)
9491
.whisker_width(0.5)
9592
.style(style)
@@ -133,8 +130,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
133130

134131
chart.configure_mesh().line_style_2(&WHITE).draw()?;
135132
chart.draw_series(vec![
136-
Boxplot::new_vertical(CentricValues::Exact(&"a"), &quartiles_a),
137-
Boxplot::new_vertical(CentricValues::Exact(&"b"), &quartiles_b),
133+
Boxplot::new_vertical(CentricValues::CenterOf(&"a"), &quartiles_a),
134+
Boxplot::new_vertical(CentricValues::CenterOf(&"b"), &quartiles_b),
138135
])?;
139136

140137
let mut chart = ChartBuilder::on(&right)

src/coord/category.rs

Lines changed: 0 additions & 204 deletions
This file was deleted.

src/coord/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Also, the ranged axis can be deserted, and this is required by the histogram ser
2222
*/
2323
use plotters_backend::BackendCoord;
2424

25-
mod category;
2625
#[cfg(feature = "chrono")]
2726
mod datetime;
2827
mod discrete;
@@ -53,8 +52,6 @@ pub use group_by::{GroupBy, ToGroupByRange};
5352
use std::rc::Rc;
5453
use std::sync::Arc;
5554

56-
pub use category::Category;
57-
5855
/// The trait that translates some customized object to the backend coordinate
5956
pub trait CoordTranslate {
6057
type From;

src/element/boxplot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<K, O: BoxplotOrient<K, f32>> Boxplot<K, O> {
177177
}
178178
}
179179

180-
impl<'a, K: 'a + Clone, O: BoxplotOrient<K, f32>> PointCollection<'a, (O::XType, O::YType)>
180+
impl<'a, K: Clone, O: BoxplotOrient<K, f32>> PointCollection<'a, (O::XType, O::YType)>
181181
for &'a Boxplot<K, O>
182182
{
183183
type Borrow = (O::XType, O::YType);

src/element/errorbar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<K, V> ErrorBar<K, V, ErrorBarOrientH<K, V>> {
9494
}
9595
}
9696

97-
impl<'a, K: 'a + Clone, V: 'a + Clone, O: ErrorBarOrient<K, V>>
97+
impl<'a, K: Clone, V: Clone, O: ErrorBarOrient<K, V>>
9898
PointCollection<'a, (O::XType, O::YType)> for &'a ErrorBar<K, V, O>
9999
{
100100
type Borrow = (O::XType, O::YType);

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ pub mod prelude {
708708

709709
// Coordinates
710710
pub use crate::coord::{
711-
Category, CoordTranslate, GroupBy, IntoCentric, IntoPartialAxis, LogCoord, LogRange,
711+
CoordTranslate, GroupBy, IntoCentric, IntoPartialAxis, LogCoord, LogRange,
712712
LogScalable, Ranged, RangedCoord, RangedCoordf32, RangedCoordf64, RangedCoordi32,
713713
RangedCoordi64, RangedCoordu32, RangedCoordu64, ToGroupByRange, CentricValues,
714714
};

0 commit comments

Comments
 (0)