Skip to content

Commit 4ebe22b

Browse files
committed
Update the book
1 parent 5ec4e14 commit 4ebe22b

File tree

9 files changed

+43
-22
lines changed

9 files changed

+43
-22
lines changed

code/2_11_timeseries.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1+
use chrono::{TimeZone, Utc};
12
use plotters::prelude::*;
2-
use chrono::{Utc, TimeZone};
33

44
fn main() {
5-
let root_area = BitMapBackend::new("images/2.11.png", (600, 400)).into_drawing_area();
6-
root_area.fill(&WHITE).unwrap();
5+
let root_area = BitMapBackend::new("images/2.11.png", (600, 400)).into_drawing_area();
6+
root_area.fill(&WHITE).unwrap();
77

8-
let start_date = Utc.ymd(2019, 10, 1);
9-
let end_date = Utc.ymd(2019, 10, 18);
8+
let start_date = Utc.ymd(2019, 10, 1);
9+
let end_date = Utc.ymd(2019, 10, 18);
1010

1111
let mut ctx = ChartBuilder::on(&root_area)
1212
.set_label_area_size(LabelAreaPosition::Left, 40)
1313
.set_label_area_size(LabelAreaPosition::Bottom, 40)
1414
.caption("MSFT daily close price", ("Arial", 40))
1515
.build_ranged(start_date..end_date, 130.0..145.0)
1616
.unwrap();
17-
18-
ctx.configure_mesh().draw().unwrap();
1917

20-
ctx.draw_series(
21-
LineSeries::new(
22-
(0..).zip(DATA.iter()).map(|(idx, price)| {
23-
let day = (idx / 5) * 7 + idx % 5 + 1;
24-
let date = Utc.ymd(2019,10, day);
25-
(date, *price)
26-
}),
27-
&BLUE,
28-
)
29-
).unwrap();
18+
ctx.configure_mesh().draw().unwrap();
3019

20+
ctx.draw_series(LineSeries::new(
21+
(0..).zip(DATA.iter()).map(|(idx, price)| {
22+
let day = (idx / 5) * 7 + idx % 5 + 1;
23+
let date = Utc.ymd(2019, 10, day);
24+
(date, *price)
25+
}),
26+
&BLUE,
27+
))
28+
.unwrap();
3129
}
3230
const DATA: [f64; 14] = [
3331
137.24, 136.37, 138.43, 137.41, 139.69, 140.41, 141.58, 139.55, 139.68, 139.10, 138.24, 135.67,
34-
137.12, 138.12
32+
137.12, 138.12,
3533
];

src/SUMMARY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Animation and realtime rendering](./basic/animate.md)
1111
- [Tweaking the figure](./tweak/overview.md)
1212
- [Layout tweak](./tweak/layout.md)
13+
- [Font, color and styles](./tweak/font_color_style.md)
1314
- [Axis, mesh and label tweaks](./tweak/aixs_mesh_labels.md)
1415
- [Relative sizing](./tweak/relative_sizing.md)
1516
- [Drawing APIs](./drawing/overview.md)
@@ -18,11 +19,13 @@
1819
- [Coordinate decorators](./drawing/coord_decorator.md)
1920
- [Elements](./drawing/elements.md)
2021
- [Drawing backends](./drawing/backends.md)
21-
- [Webassembly support](./wasm/overview.md)
22-
- [Canvas Drawing Backend](./wasm/canvas_backend.md)
22+
- [Targeting different backends](./backends/overview.md)
23+
- [HTML5 Canvas](./backends/canvas_backend.md)
24+
- [Framebuffer](./backends/fb.md)
2325
- [Performance](./perf/overview.md)
2426
- [Parallel Rendering with Bitmap Blit](./perf/parallel_blit.md)
2527
- [Inplace Parallel Rendering](./perf/inplace_rendering.md)
28+
- [Incremental Rendering](./perf/incremental_rendering.md)
2629
- [Extend Plotters](./extend/overview.md)
2730
- [Adding coordinate type](./extend/coord.md)
2831
- [Adding series types](./extend/series.md)

src/backends/canvas_backend.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# HTML5 Canvas

src/backends/fb.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Framebuffer

src/backends/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Targeting different backends

src/basic/basic_data_plotting.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,17 @@ Result image:
238238

239239
![2.11.png](../../images/2.11.png)
240240

241-
## Error bar
242-
## Heatmap
243241
## Customized series
242+
243+
Plotters allows you draw abitrary types of series, even the one isn't built into the Plotters crate.
244+
Plotters uses a really simple abstraction for a data series: An iterator of drawable elements.
245+
Thus if you can make your own series an iterator of drawable element, it's a valid data series and can be
246+
draw on a figure.
247+
248+
249+
250+
251+
244252
## Mutiple Data Series
245253

246254
By calling `draw_series` multiple time, Plotters is able to produce the multiple series plot.

src/intro/introduction.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ To try it yourself, please clone the book repo and use the following command to
1818
cargo run --bin <example-name>
1919
```
2020

21+
### FAQ List
22+
23+
1. Why the example just exits without any figure poping up?
24+
25+
You should be table to find the output under `images` directory under the user's guide repository.
26+
The filename for the output is the defined in the example code.
27+
2128
## API Docs
2229

2330
This book is a developer's guide for Plotters. You may also want the API reference, please go to [docs.rs](https://docs.rs/plotters).

src/perf/incremental_rendering.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Incremental Rendering

src/tweak/font_color_style.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Font, color and styles

0 commit comments

Comments
 (0)