Skip to main content

LineChartProps

Struct LineChartProps 

Source
pub struct LineChartProps {
Show 29 fields pub dataset: Option<Dataset>, pub x_field: Option<String>, pub y_fields: Option<Vec<String>>, pub binding: Option<ChartFieldBinding>, pub series: Option<Vec<SeriesDef>>, pub x_axis: Option<Vec<AxisDef>>, pub y_axis: Option<Vec<AxisDef>>, pub width: Option<f64>, pub height: Option<f64>, pub margin: Option<PlotInset>, pub grid: Option<GridConfig>, pub loading: Option<bool>, pub skip_animation: Option<bool>, pub motion: Option<ChartMotion>, pub highlight_scope: Option<HighlightScope>, pub axis_highlight: Option<AxisHighlightConfig>, pub legend: Option<LegendConfig>, pub tooltip: Option<TooltipConfig>, pub charts_theme: Option<OrbitalChartsTheme>, pub palette: Option<OrbitalChartPalette>, pub on_item_click: Option<Callback<(ChartItemId,), ()>>, pub on_axis_click: Option<Callback<(AxisClickData,), ()>>, pub on_legend_click: Option<Callback<(String,), ()>>, pub features: ChartFeatures, pub keyboard_navigation: bool, pub zoom: Option<Vec<ZoomWindow>>, pub on_zoom_change: Option<Callback<(Vec<ZoomWindow>,), ()>>, pub class: MaybeProp<String>, pub children: Option<Children>,
}
Expand description

Props for the LineChart component.

Show change over a continuous dimension — time, index, or ordered categories.

Use line charts when the story is about trend and rate of change, not category totals. Bind a shared Dataset via x_field and y_fields, or pass inline series and axis definitions for demos.

§When to use

  • Revenue, throughput, or KPI trends across months or quarters.
  • Multiple series on one axis when metrics share the same x dimension.
  • Threshold annotations via composition children such as [ReferenceLine].

§Usage

  1. Bind a Dataset with x_field and y_fields, or pass inline series with aligned x_axis categories.
  2. Set show_markers: true on series when points are sparse; use connect_nulls to bridge missing values.
  3. Inferred x-axes use crate::DomainLimit::Strict by default — override via AxisDef.domain_limit.
  4. Leave skip_animation unset to honor reduced-motion; path draw animation runs on enter/update otherwise.
  5. Wrap the chart in a native element with data-testid for E2E hooks.

§Best Practices

§Do’s

  • Prefer crate::AreaChart when filled volume or stacked composition matters more than the stroke alone.
  • Set connect_nulls: true on a series when null cells should not break the stroke.
  • Add [ReferenceLine] children for targets or limits instead of drawing ad-hoc SVG.

§Don’ts

  • Do not use lines for unordered categories — prefer crate::BarChart.
  • Do not duplicate legend/tooltip demos here; link to charts-legend and charts-tooltip.
  • Do not put data-testid on the component itself — wrap with a native element.

Cross-cutting UX: charts-legend, charts-tooltip, charts-highlighting, charts-label, charts-styling, charts-zoom-pan.

§Examples

§Two-series line chart

Compare two metrics that share the same time axis. Markers are off by default; set show_markers: true when sparse points need visible marks. Enable legend and tooltip (see cross-cutting previews) for exploration.

use crate::LineChart;
use crate::preview::fixtures::{cost_series, full_grid, quarter_x_axis, revenue_series, revenue_y_axis};
view! {
    <div data-testid="line-chart-preview">
        <LineChart
            series=vec![revenue_series(), cost_series()]
            x_axis=vec![quarter_x_axis()]
            y_axis=vec![revenue_y_axis()]
            grid=full_grid()
            width=560.0
            height=320.0
        />
    </div>
}

§Connect nulls across gaps

Missing values (f64::NAN or null dataset cells) break the stroke by default. Set connect_nulls: true on the series to bridge gaps — useful for sparse telemetry feeds.

use crate::LineChart;
use crate::preview::fixtures::{full_grid, quarter_x_axis, revenue_y_axis, sparse_revenue_series};
view! {
    <div data-testid="line-chart-connect-nulls-preview">
        <LineChart
            series=vec![sparse_revenue_series()]
            x_axis=vec![quarter_x_axis()]
            y_axis=vec![revenue_y_axis()]
            grid=full_grid()
            width=560.0
            height=320.0
        />
    </div>
}

§Reference line

Horizontal threshold via [ReferenceLine] composition child. Place the line after LinePlot so it renders above the stroke; use when targets or limits must stay visible on resize.

use crate::LineChart;
use crate::preview::fixtures::{cost_series, full_grid, quarter_x_axis, revenue_series, revenue_y_axis};
use crate::{LinePlot, ReferenceLine, ReferenceLineLabelAlign};
view! {
    <div data-testid="line-chart-reference-preview">
        <LineChart
            series=vec![revenue_series(), cost_series()]
            x_axis=vec![quarter_x_axis()]
            y_axis=vec![revenue_y_axis()]
            grid=full_grid()
            width=560.0
            height=320.0
        >
            <LinePlot />
            <ReferenceLine y=520_000.0 label="Target" label_align=ReferenceLineLabelAlign::Middle />
        </LineChart>
    </div>
}

§Optional Props

Fields§

§dataset: Option<Dataset>

Tabular data source.

§x_field: Option<String>

Category field key when using dataset.

§y_fields: Option<Vec<String>>

Value field keys when using dataset.

§binding: Option<ChartFieldBinding>

Explicit field binding (alternative to x_field/y_fields).

§series: Option<Vec<SeriesDef>>

Inline or explicit series definitions.

§x_axis: Option<Vec<AxisDef>>

X-axis definitions.

§y_axis: Option<Vec<AxisDef>>

Y-axis definitions.

§width: Option<f64>

Chart width in pixels.

§height: Option<f64>

Chart height in pixels.

§margin: Option<PlotInset>

Plot inset between SVG border and plot area.

§grid: Option<GridConfig>

Background grid configuration.

§loading: Option<bool>

Whether the chart is loading.

§skip_animation: Option<bool>

Skip enter/update animations.

§motion: Option<ChartMotion>

Chart motion configuration.

§highlight_scope: Option<HighlightScope>

Highlight and fade scope.

§axis_highlight: Option<AxisHighlightConfig>

Axis highlight configuration.

§legend: Option<LegendConfig>

Legend configuration.

§tooltip: Option<TooltipConfig>

Tooltip configuration.

§charts_theme: Option<OrbitalChartsTheme>

Chart theme extension.

§palette: Option<OrbitalChartPalette>

Color palette override.

§on_item_click: Option<Callback<(ChartItemId,), ()>>

Fired when a mark is clicked.

§on_axis_click: Option<Callback<(AxisClickData,), ()>>

Fired when a category band is clicked.

§on_legend_click: Option<Callback<(String,), ()>>

Fired when a legend entry is clicked.

§features: ChartFeatures

Opt-in capability flags.

§keyboard_navigation: bool

Enable arrow-key navigation between marks (CH-22). Keyboard zoom (CH-24) is deferred.

§zoom: Option<Vec<ZoomWindow>>

Controlled zoom state.

§on_zoom_change: Option<Callback<(Vec<ZoomWindow>,), ()>>

Fired when zoom changes.

§class: MaybeProp<String>

Optional CSS class on the root element.

§children: Option<Children>

Composition children (e.g. LinePlot, [ReferenceLine]).

Implementations§

Source§

impl LineChartProps

Source

pub fn builder() -> LineChartPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building LineChartProps. On the builder, call .dataset(...)(optional), .x_field(...)(optional), .y_fields(...)(optional), .binding(...)(optional), .series(...)(optional), .x_axis(...)(optional), .y_axis(...)(optional), .width(...)(optional), .height(...)(optional), .margin(...)(optional), .grid(...)(optional), .loading(...)(optional), .skip_animation(...)(optional), .motion(...)(optional), .highlight_scope(...)(optional), .axis_highlight(...)(optional), .legend(...)(optional), .tooltip(...)(optional), .charts_theme(...)(optional), .palette(...)(optional), .on_item_click(...)(optional), .on_axis_click(...)(optional), .on_legend_click(...)(optional), .features(...)(optional), .keyboard_navigation(...)(optional), .zoom(...)(optional), .on_zoom_change(...)(optional), .class(...)(optional), .children(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of LineChartProps.

Trait Implementations§

Source§

impl Props for LineChartProps

Source§

type Builder = LineChartPropsBuilder

Source§

fn builder() -> Self::Builder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<El, T, Marker> IntoElementMaybeSignal<T, Marker> for El
where El: IntoElementMaybeSignalType<T, Marker>,

Source§

impl<T, Js> IntoElementMaybeSignalType<T, Element> for Js
where T: From<Js> + Clone,

Source§

impl<El, T, Marker> IntoElementsMaybeSignal<T, Marker> for El
where El: IntoElementsMaybeSignalType<T, Marker>,

Source§

impl<T, Js> IntoElementsMaybeSignalType<T, Element> for Js
where T: From<Js> + Clone,

Source§

impl<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> SerializableKey for T

Source§

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more