Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples in Docs of DashedLineSeries #616

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion plotters/src/series/line_series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,43 @@ impl<DB: DrawingBackend, Coord> LineSeries<DB, Coord> {
}
}

/// 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<I: Iterator + Clone, Size: SizeDesc> {
points: I,
size: Size,
Expand Down
Loading