Line
Line plots connect one value per timestamp. Start with the series overview for identity and lifecycle.
Use Bar::from_value(time, value)
for a scalar. OHLC bars also work: the main series uses
ChartConfig::price_source,
which defaults to close; added line series always use close. A
Bar::whitespace
point leaves a gap. Do not encode a missing value as zero.
Choose ChartType::Line,
LineWithMarkers or StepLine. Steps run horizontally from the previous point
to the new point’s time, then vertically to its value.
Style and running result
Section titled “Style and running result”The scene extracts closes from the shared sample history into scalar bars and draws a marker at each one.
Zoom in to distinguish each scalar value and its connecting segment.
The interactive example needs JavaScript and WebAssembly. You can still use the chart setup alongside it.
use egui_charts::Chart;
pub fn line() -> Chart { use egui_charts::{ChartType, model::Bar, widget::SeriesId}; let mut chart = crate::first_chart::first_chart(); let values = chart .bars(SeriesId::MAIN) .iter() .map(|bar| Bar::from_value(bar.time, bar.close)) .collect(); chart.set_data(SeriesId::MAIN, values); chart.set_chart_type(ChartType::LineWithMarkers); chart.config_mut().show_volume = false; chart.config_mut().show_legend_volume = false; let mut params = chart.chart_type_params().clone(); params.styles.line_with_markers.width = 2.0; params.styles.marker_radius = 3.0; chart.set_chart_type_params(params); chart}The compiled setup is in series.rs.
ChartTypeStyles
keeps line, step_line and line_with_markers independent. Each
LinePlotStyle
sets colour, width, dash style and straight or curved connections. Step line
ignores curvature. marker_radius controls the point circles;
crosshair_marker_radius and last_price_animation control hover and last-price markers.
For an added series, use
SeriesOptions::color
and width. Added lines use solid straight segments, or steps for StepLine;
they do not expose the main line’s dash/curve options. Per-point
BarColors::color
colours the outgoing segment or marker. All three line types can be
added series.
Continue to area to fill beneath the line, or baseline to compare it with a reference.