Skip to content

Commit dd1296a

Browse files
authored
Merge pull request #616 from robertosw/master
Examples in Docs of DashedLineSeries
2 parents 80a4d60 + d0191d6 commit dd1296a

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

plotters/src/series/line_series.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,43 @@ impl<DB: DrawingBackend, Coord> LineSeries<DB, Coord> {
8686
}
8787
}
8888

89-
/// A dashed line series, map an iterable object to the dashed line element.
89+
/// A dashed line series, map an iterable object to the dashed line element. Can be used to draw simple dashed and dotted lines.
90+
///
91+
/// If you want to use more complex shapes as points in the line, you can use `plotters::series::line_series::DottedLineSeries`.
92+
///
93+
/// # Examples
94+
///
95+
/// Dashed line:
96+
/// ```Rust
97+
/// chart_context
98+
/// .draw_series(DashedLineSeries::new(
99+
/// data_series,
100+
/// 5, /* size = length of dash */
101+
/// 10, /* spacing */
102+
/// ShapeStyle {
103+
/// color: BLACK.mix(1.0),
104+
/// filled: false,
105+
/// stroke_width: 1,
106+
/// },
107+
/// ))
108+
/// .unwrap();
109+
/// ```
110+
///
111+
/// Dotted line: (keep `size` and `stroke_width` the same to achieve dots)
112+
/// ```Rust
113+
/// chart_context
114+
/// .draw_series(DashedLineSeries::new(
115+
/// data_series,
116+
/// 1, /* size = length of dash */
117+
/// 4, /* spacing, best to keep this at least 1 larger than size */
118+
/// ShapeStyle {
119+
/// color: BLACK.mix(1.0),
120+
/// filled: false,
121+
/// stroke_width: 1,
122+
/// },
123+
/// ))
124+
/// .unwrap();
125+
/// ```
90126
pub struct DashedLineSeries<I: Iterator + Clone, Size: SizeDesc> {
91127
points: I,
92128
size: Size,

0 commit comments

Comments
 (0)