Closed KmolYuan closed 8 months ago
A flexible line style that can insert custom markers at equal intervals and supports shifting.
plotters::series::line_series::DottedLineSeries
plotters::element::basic_shapes::DottedPathElement
Options in fn new(...) -> Self:
fn new(...) -> Self
points
shift
spacing
func
impl Fn(BackendCoord) -> Marker + 'static
Marker: IntoDynElement<'static, DB, BackendCoord>
let mk_f = |c| Circle::new(c, 3, BLACK); chart .draw_series(DottedLineSeries::new(points, /*shift*/ 0, /*spacing*/ 20, mk_f))? .label("Legend Text") .legend(move |c| { EmptyElement::at(c) + DottedPathElement::new([(gap, 0), (font - gap, 0)], 0, 20, mk_f) });
Left: point distance less than spacing Right: point distance greater than spacing
Combined with the new dashed-line style! ๐ (#483)
chart.draw_series(DashedLineSeries::new(points.clone(), 30, 16, color))?; let dot_size = color.stroke_width / 2; let mk_f = move |c| Circle::new(c, dot_size, color.filled()); chart .draw_series(DottedLineSeries::new(points, 30 + 8, 30 + 16, mk_f))? .label("Legend Text") .legend(move |c| { let points = [(gap, 0), (font - gap, 0)]; EmptyElement::at(c) + DashedPathElement::new(points, 30, 16, color) + DottedPathElement::new(points, 30 + 8, 30 + 16, mk_f) });
A flexible line style that can insert custom markers at equal intervals and supports shifting.
295 #321 #324 #483
New Types
plotters::series::line_series::DottedLineSeries
plotters::element::basic_shapes::DottedPathElement
Options in
fn new(...) -> Self
:points
: The iterator of the pointsshift
: The shift of the first markerspacing
: The spacing between markersfunc
: The marker function (Similar to the legend function, already mapped coordinatesimpl Fn(BackendCoord) -> Marker + 'static
whereMarker: IntoDynElement<'static, DB, BackendCoord>
)Examples
Basic Example
Left: point distance less than spacing Right: point distance greater than spacing
Dash-dotted Line Example
Combined with the new dashed-line style! ๐ (#483)
Left: point distance less than spacing Right: point distance greater than spacing