From d0191d64395d364a7bfca15e6e5da22906bf4eac Mon Sep 17 00:00:00 2001 From: Robert Oswald <47303535+robertosw@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:11:55 +0200 Subject: [PATCH] Examples in Docs of DashedLineSeries --- plotters/src/series/line_series.rs | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/plotters/src/series/line_series.rs b/plotters/src/series/line_series.rs index 55c58f7b..ed92d56f 100644 --- a/plotters/src/series/line_series.rs +++ b/plotters/src/series/line_series.rs @@ -86,7 +86,43 @@ impl LineSeries { } } -/// A dashed line series, map an iterable object to the dashed line element. +/// A dashed line series, map an iterable object to the dashed line element. Can be used to draw simple dashed and dotted lines. +/// +/// If you want to use more complex shapes as points in the line, you can use `plotters::series::line_series::DottedLineSeries`. +/// +/// # Examples +/// +/// Dashed line: +/// ```Rust +/// chart_context +/// .draw_series(DashedLineSeries::new( +/// data_series, +/// 5, /* size = length of dash */ +/// 10, /* spacing */ +/// ShapeStyle { +/// color: BLACK.mix(1.0), +/// filled: false, +/// stroke_width: 1, +/// }, +/// )) +/// .unwrap(); +/// ``` +/// +/// Dotted line: (keep `size` and `stroke_width` the same to achieve dots) +/// ```Rust +/// chart_context +/// .draw_series(DashedLineSeries::new( +/// data_series, +/// 1, /* size = length of dash */ +/// 4, /* spacing, best to keep this at least 1 larger than size */ +/// ShapeStyle { +/// color: BLACK.mix(1.0), +/// filled: false, +/// stroke_width: 1, +/// }, +/// )) +/// .unwrap(); +/// ``` pub struct DashedLineSeries { points: I, size: Size,