Skip to content

Commit e836f33

Browse files
committed
Merge the log scale change
2 parents aa5b9fb + 6bdc2eb commit e836f33

File tree

14 files changed

+222
-101
lines changed

14 files changed

+222
-101
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ optional = true
2424
default_features = false
2525

2626
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
27-
rusttype = { version = "0.8.2", optional = true }
27+
ttf-parser = { version = "0.8.2", optional = true }
2828
lazy_static = { version = "1.4.0", optional = true }
29+
pathfinder_geometry = { version = "0.5.1", optional = true }
2930
font-kit = { version = "0.7.0", optional = true }
3031

3132
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.image]
@@ -81,7 +82,7 @@ point_series = []
8182
surface_series = []
8283

8384
# Font implemnetation
84-
ttf = ["font-kit", "rusttype", "lazy_static"]
85+
ttf = ["font-kit", "ttf-parser", "lazy_static", "pathfinder_geometry"]
8586

8687
# Misc
8788
datetime = ["chrono"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
171171
.margin(5)
172172
.x_label_area_size(30)
173173
.y_label_area_size(30)
174-
.build_ranged(-1f32..1f32, -0.1f32..1f32)?;
174+
.build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
175175

176176
chart.configure_mesh().draw()?;
177177

@@ -215,7 +215,7 @@ let figure = evcxr_figure((640, 480), |root| {
215215
.margin(5)
216216
.x_label_area_size(30)
217217
.y_label_area_size(30)
218-
.build_ranged(-1f32..1f32, -0.1f32..1f32)?;
218+
.build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
219219
220220
chart.configure_mesh().draw()?;
221221

doc-template/examples/quick_start.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
77
.margin(5)
88
.x_label_area_size(30)
99
.y_label_area_size(30)
10-
.build_ranged(-1f32..1f32, -0.1f32..1f32)?;
10+
.build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
1111

1212
chart.configure_mesh().draw()?;
1313

doc-template/readme.template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let figure = evcxr_figure((640, 480), |root| {
6868
.margin(5)
6969
.x_label_area_size(30)
7070
.y_label_area_size(30)
71-
.build_ranged(-1f32..1f32, -0.1f32..1f32)?;
71+
.build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
7272
7373
chart.configure_mesh().draw()?;
7474

examples/3d-plot.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4747
.draw()?;
4848
Ok(())
4949
}
50+
#[test]
51+
fn entry_point() {
52+
main().unwrap()
53+
}

examples/3d-plot2.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4242

4343
Ok(())
4444
}
45+
#[test]
46+
fn entry_point() {
47+
main().unwrap()
48+
}

examples/tick_control.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct CountryData {
1919
fn main() -> Result<(), Box<dyn std::error::Error>> {
2020
let root =
2121
SVGBackend::new("plotters-doc-data/tick_control.svg", (1024, 768)).into_drawing_area();
22-
2322
root.fill(&WHITE)?;
2423

2524
let (upper, lower) = root.split_vertically(750);
@@ -80,3 +79,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8079

8180
Ok(())
8281
}
82+
#[test]
83+
fn entry_point() {
84+
main().unwrap()
85+
}

src/chart/context.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,10 @@ impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged> ChartContext<'a, DB, Cartesia
302302
.iter()
303303
.map(|(_, text)| {
304304
if orientation.0 > 0 && orientation.1 == 0 && tick_size >= 0 {
305-
let ((x0, _), (x1, _)) = label_style
306-
.font
307-
.layout_box(text)
308-
.unwrap_or(((0, 0), (0, 0)));
309-
x1 - x0
305+
self.drawing_area
306+
.estimate_text_size(text, &label_style)
307+
.map(|(w, _)| w)
308+
.unwrap_or(0) as i32
310309
} else {
311310
// Don't ever do the layout estimationfor the drawing area that is either not
312311
// the right one or the tick mark is inward.

src/chart/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use plotters_backend::DrawingBackend;
2121
/// let chart = ChartBuilder::on(&area[0])
2222
/// .caption("Incremental Example", ("sans-serif", 20))
2323
/// .set_all_label_area_size(30)
24-
/// .build_ranged(0..10, 0..10)
24+
/// .build_cartesian_2d(0..10, 0..10)
2525
/// .expect("Unable to build ChartContext");
2626
/// // Draw the first frame at this point
2727
/// area[0].present().expect("Present");

src/coord/ranged1d/combinators/ckps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ where
103103
///let mut buffer = vec![0;1024*768*3];
104104
/// let root = BitMapBackend::with_buffer(&mut buffer, (1024, 768)).into_drawing_area();
105105
/// let mut chart = ChartBuilder::on(&root)
106-
/// .build_ranged(
106+
/// .build_cartesian_2d(
107107
/// (0..100).with_key_points(vec![1,20,50,90]), // <= This line will make the plot shows 4 tick marks at 1, 20, 50, 90
108108
/// 0..10
109109
/// ).unwrap();
@@ -143,7 +143,7 @@ where
143143
///let mut buffer = vec![0;1024*768*3];
144144
/// let root = BitMapBackend::with_buffer(&mut buffer, (1024, 768)).into_drawing_area();
145145
/// let mut chart = ChartBuilder::on(&root)
146-
/// .build_ranged(
146+
/// .build_cartesian_2d(
147147
/// (0..100).with_key_point_func(|n| (0..100 / n as i32).map(|x| x * 100 / n as i32).collect()),
148148
/// 0..10
149149
/// ).unwrap();

0 commit comments

Comments
 (0)