#[non_exhaustive]pub struct Line<T, Y> {
pub name: RwSignal<String>,
pub colour: RwSignal<Option<Colour>>,
pub gradient: RwSignal<Option<ColourScheme>>,
pub width: RwSignal<f64>,
pub interpolation: RwSignal<Interpolation>,
pub marker: Marker,
/* private fields */
}Expand description
Draws a line on the chart.
§Simple example
With no legend names, lines can be a simple closure:
let series = Series::new(|data: &MyData| data.x)
.line(|data: &MyData| data.y1)
.line(|data: &MyData| data.y2);See this in action with the tick labels example.
§Example
However, we can also set the name of the line which a legend can show:
let series = Series::new(|data: &MyData| data.x)
.line(Line::new(|data: &MyData| data.y1).with_name("pears"))
.line(Line::new(|data: &MyData| data.y2).with_name("apples"));See this in action with the legend example.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: RwSignal<String>Name of the line. Used in the legend.
colour: RwSignal<Option<Colour>>Colour of the line. If not set, the next colour in the series will be used.
gradient: RwSignal<Option<ColourScheme>>Use a linear gradient (colour scheme) for the line. Default is None with fallback to the line colour.
width: RwSignal<f64>Width of the line.
interpolation: RwSignal<Interpolation>Interpolation method of the line, aka line smoothing (or not). Describes how the line is drawn between two points. Default is Interpolation::Monotone.
marker: MarkerMarker at each point on the line.
Implementations§
Source§impl<T, Y> Line<T, Y>
impl<T, Y> Line<T, Y>
Sourcepub fn new(get_y: impl Fn(&T) -> Y + Send + Sync + 'static) -> Selfwhere
Y: Tick,
pub fn new(get_y: impl Fn(&T) -> Y + Send + Sync + 'static) -> Selfwhere
Y: Tick,
Create a new line. The get_y function is used to extract the Y value from your struct.
See the module documentation for examples.
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set the name of the line. Used in the legend.
Sourcepub fn with_colour(self, colour: impl Into<Option<Colour>>) -> Self
pub fn with_colour(self, colour: impl Into<Option<Colour>>) -> Self
Set the colour of the line. If not set, the next colour in the series will be used.
Sourcepub fn with_gradient(self, scheme: impl Into<ColourScheme>) -> Self
pub fn with_gradient(self, scheme: impl Into<ColourScheme>) -> Self
Use a colour scheme for the line. Interpolated in SVG by the browser, overrides Colour. Default is None with fallback to the line colour.
Suggested use with LINEAR_GRADIENT or DIVERGING_GRADIENT (for data with a zero value).
Sourcepub fn with_width(self, width: impl Into<f64>) -> Self
pub fn with_width(self, width: impl Into<f64>) -> Self
Set the width of the line.
Sourcepub fn with_interpolation(self, interpolation: impl Into<Interpolation>) -> Self
pub fn with_interpolation(self, interpolation: impl Into<Interpolation>) -> Self
Set the interpolation method of the line.
Sourcepub fn with_marker(self, marker: impl Into<Marker>) -> Self
pub fn with_marker(self, marker: impl Into<Marker>) -> Self
Set the marker at each point on the line.
Trait Implementations§
Auto Trait Implementations§
impl<T, Y> Freeze for Line<T, Y>
impl<T, Y> !RefUnwindSafe for Line<T, Y>
impl<T, Y> Send for Line<T, Y>
impl<T, Y> Sync for Line<T, Y>
impl<T, Y> Unpin for Line<T, Y>
impl<T, Y> !UnwindSafe for Line<T, Y>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more