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
- Bind a
Datasetwithx_fieldandy_fields, or pass inlineserieswith alignedx_axiscategories. - Set
show_markers: trueon series when points are sparse; useconnect_nullsto bridge missing values. - Inferred x-axes use
crate::DomainLimit::Strictby default — override viaAxisDef.domain_limit. - Leave
skip_animationunset to honor reduced-motion; path draw animation runs on enter/update otherwise. - Wrap the chart in a native element with
data-testidfor E2E hooks.
§Best Practices
§Do’s
- Prefer
crate::AreaChartwhen filled volume or stacked composition matters more than the stroke alone. - Set
connect_nulls: trueon 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-legendandcharts-tooltip. - Do not put
data-testidon the component itself — wrap with a native element.
§Related previews
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
- dataset:
Dataset- Tabular data source.
- x_field:
impl Into<String>- Category field key when using dataset.
- y_fields:
Vec<String>- Value field keys when using dataset.
- binding:
ChartFieldBinding- Explicit field binding (alternative to x_field/y_fields).
- series:
Vec<SeriesDef>- Inline or explicit series definitions.
- x_axis:
Vec<AxisDef>- X-axis definitions.
- y_axis:
Vec<AxisDef>- Y-axis definitions.
- width:
f64- Chart width in pixels.
- height:
f64- Chart height in pixels.
- margin:
PlotInset- Plot inset between SVG border and plot area.
- grid:
GridConfig- Background grid configuration.
- loading:
bool- Whether the chart is loading.
- skip_animation:
bool- Skip enter/update animations.
- motion:
ChartMotion- Chart motion configuration.
- highlight_scope:
HighlightScope- Highlight and fade scope.
- axis_highlight:
AxisHighlightConfig- Axis highlight configuration.
- legend:
LegendConfig- Legend configuration.
- tooltip:
TooltipConfig- Tooltip configuration.
- charts_theme:
OrbitalChartsTheme- Chart theme extension.
- palette:
OrbitalChartPalette- Color palette override.
- on_item_click:
Callback<(ChartItemId,), ()>- Fired when a mark is clicked.
- on_axis_click:
Callback<(AxisClickData,), ()>- Fired when a category band is clicked.
- on_legend_click:
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:
Vec<ZoomWindow>- Controlled zoom state.
- on_zoom_change:
Callback<(Vec<ZoomWindow>,), ()>- Fired when zoom changes.
- class:
impl Into<MaybeProp<String>>- Optional CSS class on the root element.
- children:
Children- Composition children (e.g.
LinePlot, [ReferenceLine]).
- Composition children (e.g.
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: ChartFeaturesOpt-in capability flags.
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
impl LineChartProps
Sourcepub fn builder() -> LineChartPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for LineChartProps
impl !Sync for LineChartProps
impl !UnwindSafe for LineChartProps
impl Freeze for LineChartProps
impl Send for LineChartProps
impl Unpin for LineChartProps
impl UnsafeUnpin for LineChartProps
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
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) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<El, T, Marker> IntoElementMaybeSignal<T, Marker> for Elwhere
El: IntoElementMaybeSignalType<T, Marker>,
impl<El, T, Marker> IntoElementMaybeSignal<T, Marker> for Elwhere
El: IntoElementMaybeSignalType<T, Marker>,
fn into_element_maybe_signal(self) -> ElementMaybeSignal<T>
Source§impl<T, Js> IntoElementMaybeSignalType<T, Element> for Js
impl<T, Js> IntoElementMaybeSignalType<T, Element> for Js
fn into_element_maybe_signal_type(self) -> ElementMaybeSignalType<T>
Source§impl<El, T, Marker> IntoElementsMaybeSignal<T, Marker> for Elwhere
El: IntoElementsMaybeSignalType<T, Marker>,
impl<El, T, Marker> IntoElementsMaybeSignal<T, Marker> for Elwhere
El: IntoElementsMaybeSignalType<T, Marker>,
fn into_elements_maybe_signal(self) -> ElementsMaybeSignal<T>
Source§impl<T, Js> IntoElementsMaybeSignalType<T, Element> for Js
impl<T, Js> IntoElementsMaybeSignalType<T, Element> for Js
fn into_elements_maybe_signal_type(self) -> ElementsMaybeSignalType<T>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more