Skip to main content

Module widget

Module widget 

Source
Expand description

Interactive charts, events, panes, layouts and export.

Keep a Chart across frames and call Chart::show from your egui UI callback. Construct it from BarData, or use ChartBuilder to configure an instrument, interval and optional Datafeed.

§Updating data

Merge each live bar into its series. The chart updates studies when it next draws; use Chart::set_data to replace a series’ history.

use egui_charts::{Chart, model::{Bar, BarData}, widget::SeriesId};

let mut chart = Chart::new(BarData::default());
let bar = Bar::new("2024-01-01T00:00:00Z".parse().unwrap(),
                   100.0, 102.0, 99.0, 101.0, 50.0);
chart.update(SeriesId::MAIN, bar);
chart.show(ui);

§Host integration

Read ChartEvent values with Chart::drain_events for host legends, inspection and application actions. ChartLayout arranges multiple charts and synchronizes their viewports and crosshairs by timestamp.

Studies added with Chart::add_indicator are calculated and drawn by the chart. Built-in studies require the studies feature; drawing tools require drawings. Toolbars and dialogs in ui are separate components placed and connected by the host.

Re-exports§

pub use crate::chart::primitives::PriceAxisLabel;
pub use crate::chart::primitives::Primitive;
pub use crate::chart::primitives::PrimitiveId;
pub use crate::chart::primitives::PrimitivePass;
pub use crate::chart::primitives::PrimitiveView;
pub use crate::chart::primitives::TimeAxisLabel;

Modules§

settings
Editable and serializable chart display settings.

Structs§

BarsInRange
The bars of a series inside a range of logical indices, from Chart::bars_in_logical_range.
BoxZoomState
Tracks an active box-zoom selection.
Chart
Interactive financial chart widget for egui.
ChartBuilder
Fluent builder for a Chart.
ChartImage
A complete offscreen frame for an egui renderer, at one pixel per point. Upload textures_delta.set, draw primitives over transparent black at size, then release the textures. The host owns GPU readback, PNG encoding and file/clipboard delivery. This uses its own texture namespace; render with a dedicated egui renderer. Hosts must also bind any user textures referenced by their image sources whose pixels were not supplied in ImageExportOptions::textures before drawing.
ChartLayout
Container state for up to sixteen host-owned charts. Supply charts in stable slot order.
ChartLayoutRects
Pre-computed layout rectangles for the chart’s sub-regions.
ChartPointer
A chart cursor position with the data a host legend, tooltip or context action reads. Identical whitespace slots compare equal, including their colours and host payloads.
ChartSnapshot
What a chart shows and how: everything a user sets on it, without the bars, which come from the host’s feed. Take one with Chart::snapshot and apply it with Chart::restore. The trading and alert settings of the settings dialog belong to the host and are not part of it.
ChartSyncOptions
Independent synchronization switches within each layout group.
DataTable
The loaded bars and visible study plots as text, aligned by chart time: what Chart::export_csv (with csv) writes and the chart data table lists.
ElasticBounceState
Tracks elastic bounce-back animation when the user scrolls past chart edges.
ImageExportOptions
Image options shared by the export dialog and offscreen rendering.
ImageRequest
An image drawing waiting for its picture, from ChartEvent::ImageRequested.
IndicatorCoordParams
Coordinate parameters for aligning indicator panes with the main chart.
IndicatorPane
A separate-pane indicator panel rendered via direct egui painting.
IndicatorPaneConfig
Configuration for an indicator panel’s visual appearance and behavior.
KineticScrollState
Tracks kinetic (momentum-based) scrolling after a flick gesture.
Legend
An in-pane legend. Historical readout data and current quotes are supplied independently.
LegendStatus
A host-supplied status mark. Its text and colours carry no built-in market meaning.
PaneId
Identifies a pane of a chart. PaneId::MAIN is the price pane; Chart::add_pane and Chart::panes return the others. An id stays valid until its pane is removed and is never reused by the chart.
PaneInteraction
Layout and interaction results from rendering one interactive indicator pane.
PaneOptions
Behaviour and colours of the separators between panes, set with Chart::with_pane_options or Chart::pane_options_mut.
PriceLineId
Handle of a price line added with Chart::add_price_line.
RenderedIndicatorPane
Information about a rendered indicator pane, used for hit testing and coordinate mapping.
SavedAnnotations
The markers and price lines of one bar series of a ChartSnapshot.
SavedLayout
A named arrangement of charts: the ChartLayoutMode and a ChartSnapshot of each chart, as kept in StoreKind::Layouts documents.
SavedPane
One pane of a ChartSnapshot.
SavedSeries
One bar series added with Chart::add_series to a ChartSnapshot, without its bars. Chart::restore adds it again with a new id: supply its bars through Chart::set_data on Chart::restored_series_id of id, or set fed to reconnect its symbol or spread to the chart feed.
SavedStudy
One study of a ChartSnapshot.
SeriesId
Identifier shared by bar series, the volume series and studies.
SeriesOptions
Display settings of a host-fed bar series.
ShortcutMap
Editable bindings shared by input dispatch, menus and shortcut help.
StudyValue
One visible study plot’s value at the selected bar. Missing or warming-up values stay absent.
ValueFormatters
Host number formatters shared by legends and tooltips. Missing entries retain the renderer’s instrument precision and built-in formatting. Prices use instrument units; percentages use percentage points, so 5.0 means 5%.
VisibleTimeRange
UTC timestamps at the left and right edges of a chart’s plot.
Watermark
An image and lines of text painted behind the series, stacked in that order and aligned together in the price pane; see Chart::set_watermark.
WatermarkLine
One line of text of a Watermark.

Enums§

ChartElementId
Identifies any selectable element across the entire chart.
ChartEvent
A notification for the host. Existing selection and action polling APIs remain independent.
ChartLayoutMode
Multi-chart arrangement. Changing presets retains the host’s hidden charts. Charts fill a preset in slot order, row by row from the top; presets with a large chart at the left or right fill column by column from the left.
DataOperation
An accepted host data operation, reported by ChartEvent::DataOperation. Update times are the incoming timestamps, matched using the chart’s bar slots.
DrawingError
Why Chart::create_drawing or Chart::set_drawing_points changed nothing.
ExportError
Why Chart::export_image, Chart::export_png (with png-export) or Chart::export_svg made no image.
MismatchDirection
Which bar Chart::bar_index_at finds for a time no bar opens at.
PointerKind
The device behind a ChartPointer.
PointerTarget
The object under the pointer of a ChartPointer.
QuoteSide
The quote control clicked by the user. The host decides how to handle the intent.
RestoreError
Why Chart::restore did not show a snapshot.
RightClickTarget
The object a right-click landed on, with the data needed to position and populate a context menu.
ShortcutRequest
A shortcut that needs the host’s dialogs, layout or clipboard.
StudyAction
An action on the zero-based study index in a legend’s study slice.
VisualOrder
A change of a study’s place in the draw order of its pane, where each item is drawn over the ones before it. In the main pane the price series is one of the items.