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§
- Bars
InRange - The bars of a series inside a range of logical indices, from
Chart::bars_in_logical_range. - BoxZoom
State - Tracks an active box-zoom selection.
- Chart
- Interactive financial chart widget for egui.
- Chart
Builder - Fluent builder for a
Chart. - Chart
Image - A complete offscreen frame for an egui renderer, at one pixel per point.
Upload
textures_delta.set, drawprimitivesover transparent black atsize, 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 inImageExportOptions::texturesbefore drawing. - Chart
Layout - Container state for up to sixteen host-owned charts. Supply charts in stable slot order.
- Chart
Layout Rects - Pre-computed layout rectangles for the chart’s sub-regions.
- Chart
Pointer - 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.
- Chart
Snapshot - 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::snapshotand apply it withChart::restore. The trading and alert settings of the settings dialog belong to the host and are not part of it. - Chart
Sync Options - Independent synchronization switches within each layout group.
- Data
Table - The loaded bars and visible study plots as text, aligned by chart time: what
Chart::export_csv(withcsv) writes and the chart data table lists. - Elastic
Bounce State - Tracks elastic bounce-back animation when the user scrolls past chart edges.
- Image
Export Options - Image options shared by the export dialog and offscreen rendering.
- Image
Request - An image drawing waiting for its picture, from
ChartEvent::ImageRequested. - Indicator
Coord Params - Coordinate parameters for aligning indicator panes with the main chart.
- Indicator
Pane - A separate-pane indicator panel rendered via direct egui painting.
- Indicator
Pane Config - Configuration for an indicator panel’s visual appearance and behavior.
- Kinetic
Scroll State - Tracks kinetic (momentum-based) scrolling after a flick gesture.
- Legend
- An in-pane legend. Historical readout data and current quotes are supplied independently.
- Legend
Status - A host-supplied status mark. Its text and colours carry no built-in market meaning.
- PaneId
- Identifies a pane of a chart.
PaneId::MAINis the price pane;Chart::add_paneandChart::panesreturn the others. An id stays valid until its pane is removed and is never reused by the chart. - Pane
Interaction - Layout and interaction results from rendering one interactive indicator pane.
- Pane
Options - Behaviour and colours of the separators between panes, set with
Chart::with_pane_optionsorChart::pane_options_mut. - Price
Line Id - Handle of a price line added with
Chart::add_price_line. - Rendered
Indicator Pane - Information about a rendered indicator pane, used for hit testing and coordinate mapping.
- Saved
Annotations - The markers and price lines of one bar series of a
ChartSnapshot. - Saved
Layout - A named arrangement of charts: the
ChartLayoutModeand aChartSnapshotof each chart, as kept inStoreKind::Layoutsdocuments. - Saved
Pane - One pane of a
ChartSnapshot. - Saved
Series - One bar series added with
Chart::add_seriesto aChartSnapshot, without its bars.Chart::restoreadds it again with a new id: supply its bars throughChart::set_dataonChart::restored_series_idofid, or setfedto reconnect its symbol or spread to the chart feed. - Saved
Study - One study of a
ChartSnapshot. - Series
Id - Identifier shared by bar series, the volume series and studies.
- Series
Options - Display settings of a host-fed bar series.
- Shortcut
Map - Editable bindings shared by input dispatch, menus and shortcut help.
- Study
Value - One visible study plot’s value at the selected bar. Missing or warming-up values stay absent.
- Value
Formatters - 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.0means 5%. - Visible
Time Range - 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. - Watermark
Line - One line of text of a
Watermark.
Enums§
- Chart
Element Id - Identifies any selectable element across the entire chart.
- Chart
Event - A notification for the host. Existing selection and action polling APIs remain independent.
- Chart
Layout Mode - 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.
- Data
Operation - An accepted host data operation, reported by
ChartEvent::DataOperation. Update times are the incoming timestamps, matched using the chart’s bar slots. - Drawing
Error - Why
Chart::create_drawingorChart::set_drawing_pointschanged nothing. - Export
Error - Why
Chart::export_image,Chart::export_png(withpng-export) orChart::export_svgmade no image. - Mismatch
Direction - Which bar
Chart::bar_index_atfinds for a time no bar opens at. - Pointer
Kind - The device behind a
ChartPointer. - Pointer
Target - The object under the pointer of a
ChartPointer. - Quote
Side - The quote control clicked by the user. The host decides how to handle the intent.
- Restore
Error - Why
Chart::restoredid not show a snapshot. - Right
Click Target - The object a right-click landed on, with the data needed to position and populate a context menu.
- Shortcut
Request - A shortcut that needs the host’s dialogs, layout or clipboard.
- Study
Action - An action on the zero-based study index in a legend’s study slice.
- Visual
Order - 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.