Expand description
Interactive financial charts for egui, using your historical and streaming data.
Chart provides price and volume panes, pan and zoom, crosshairs and live bar
updates on native and WebAssembly targets. Optional features add built-in studies,
drawing tools, order flow visualizations and application UI such as toolbars,
replay controls, trading panels and dialogs. The host supplies market data,
external accounts and durable storage through the crate’s contracts.
§Quick start
Enable widget for a chart without application UI or built-in studies:
egui-charts = { git = "https://github.com/userFRM/egui-charts", branch = "main", default-features = false, features = ["widget"] }Create the chart once with bars ordered from oldest to newest, then call
Chart::show in your egui UI callback each frame:
use egui_charts::{Chart, model::{Bar, BarData}};
let bars = vec![
Bar::new("2024-01-01T00:00:00Z".parse().unwrap(),
100.0, 102.0, 99.0, 101.0, 1_000.0),
Bar::new("2024-01-01T00:01:00Z".parse().unwrap(),
101.0, 103.0, 100.0, 102.0, 1_200.0),
];
let mut chart = Chart::new(BarData::from_bars(bars));
chart.show(ui);For live data, merge bars with Chart::update(widget::SeriesId::MAIN, bar).
data::Datafeed supports paged history and streaming bars, trades and depth;
attach a feed with ChartBuilder::with_feed. Feed methods return promptly,
answer requests through data::Reply and push updates through data::Sink.
A symbol identifies the host’s instrument; setting it does not fetch data without
a feed. See the guide for complete integration examples.
§API map
| Module | Use it for |
|---|---|
widget | Chart, ChartBuilder, events, panes, chart layouts, replay and export |
model | Bars, instruments, intervals, chart types, price transforms and host data records |
data | Historical and streaming data contracts, aggregation and order flow data |
studies | The Indicator extension point, calculation helpers and built-in studies |
drawings | Drawing tools, selection, undo and timestamp-based persistence |
scales | Price ranges, coordinate mapping, axis ticks and label formatting |
config | Chart appearance and interaction options |
services | Host storage, symbol search, quotes, alerts, signals and broker contracts |
strategies | Strategies that trade on closed bars and the backtest engine that runs them |
theme, tokens, styles | Theme presets, design tokens and UI styling helpers |
ui, ui_kit | Chart controls and reusable UI components placed in the host’s layout |
icons | Embedded SVG icons |
localization | Host translations scoped to an egui context |
prelude | Common types and traits for chart integration |
§Feature flags
The defaults are ui, locales, timezones, csv and png-export. With default-features = false,
the data model, scales, feed and service contracts, tokens and study extension
points are available without an egui dependency.
| Feature | Default | Enables |
|---|---|---|
widget | via ui | The chart widget, rendering, configuration, themes, styling and localization |
drawings | via ui | Drawing tools, interaction, undo and persistence; enables widget |
studies | via ui | Built-in studies, IndicatorFactory and study templates; usable without egui |
alert-engine | off | services::AlertEngine, an Alerts service that evaluates alerts on the bars the host feeds it; needs no egui |
detectors | off | services::OrderFlowDetectors, a Signals service that finds order-flow events in the trades and depth the host feeds it; needs no egui |
strategies | off | strategies::Backtest, which runs a Strategy over bars and returns a StrategyReport; needs no egui |
icons | via ui | Embedded SVG icons and their pixel-aligned loader; enables widget |
ui | on | Toolbars, panels, dialogs and ui_kit; enables icons, studies, drawings, csv and png-export |
locales | on | Localized month and weekday names and AM/PM markers through chrono; otherwise English |
timezones | on | IANA zones and daylight-saving rules through chrono-tz; otherwise UTC, system local time and fixed offsets |
csv | on | CSV import/export for bars, strategy reports and chart data; enabled by ui |
png-export | on | CPU PNG export and image textures embedded in SVG export; enables widget, enabled by ui |
serde | off | Serialize and Deserialize for theme::Theme |
Without default features, enable csv to use CSV methods; JSON I/O stays available.
Enable png-export for PNG methods and textured SVG output. Without it, SVG
exports text and vector geometry and returns ExportError::Unsupported for image
textures; renderer frames from Chart::export_image remain available.
With icons alone, the chart installs only its embedded icon loader. General SVG
images require ui or an image loader installed by the host.
§Application integration
Keep a chart across frames so its viewport, studies and drawings persist. Application UI components return actions for the host to apply. The crate does not connect to a market data provider on its own.
Apply theme::apply_to_egui at startup and after changing the theme. It installs
the bundled font and applies UI colors and spacing. Use
localization::set_translator for UI text; the host owns translation resources
and additional fonts. Chart date and number labels use the chart’s formatters.
The guide covers historical and streaming data, custom studies, drawing
persistence, synchronized charts and host strategy and script results.
§API compatibility
The 0.3 release line uses egui 0.37. Use a compatible egui version in your host
so types such as egui::Ui agree across the dependency graph. Before 1.0,
breaking API changes require a minor release; afterward they require a major
release. An incompatible upgrade of exposed egui types is a breaking change.
Construct extensible options with their constructors or Default, then assign
public fields. Include a fallback arm when matching a #[non_exhaustive] enum.
Re-exports§
pub use model::ChartType;pub use widget::Chart;pub use widget::ChartBuilder;pub use widget::RightClickTarget;
Modules§
- chart
- Rendering and geometry helpers for chart composition.
- config
- Appearance and interaction options for the chart widget.
- data
- Historical and streaming market data contracts, aggregation and order flow data.
- drawings
- Drawing tools and annotations anchored to chart coordinates.
- guide
- Builder guide
- icons
- Embedded SVG icons for chart controls and host UI.
- localization
- Host-supplied UI translations, scoped to an egui context.
- model
- Data types for bars, instruments, chart styles, trading and host analytics.
- prelude
- Common types and extension traits for embedding a chart.
- scales
- Price ranges, coordinate transforms, axis ticks and label formatting.
- services
- Services a host supplies, each through a small trait. Charts consume
Marks,SignalsandPostsand keep their drawings inStorage, symbol choosers consumeSymbolSearch, the alerts panelAlerts, the watchlistQuotes, the notifications panelNotificationsand the chats panelChats.SettingsStoreand the layout menu keep settings and layouts inStorage; other contracts define the host side of the assembled terminal.PaperAccountis a ready-madeBrokerthat simulates an account, andAlertEngine, with thealert-enginefeature, anAlertsservice that evaluates alerts on the bars the host feeds it.OrderFlowDetectors, with thedetectorsfeature, is aSignalsservice that finds order-flow events in the trades and depth the host feeds it. - strategies
- Strategies over historical and live bars, and the
Backtestengine that runs them. - studies
- Technical indicators, calculation helpers and study presentation.
- styles
- UI sizing, typography, icon sizes and keyboard focus helpers.
- theme
- Theme: the colours and scales of the UI and the chart.
- tokens
- Design tokens: default spacing, sizing, rounding, stroke, shadow and engine colour values. UI chrome reads the applied theme.
- ui
- Chart toolbars, panels, dialogs and trading controls for host applications.
- ui_kit
- Reusable UI components for building chart interfaces.
- widget
- Interactive charts, events, panes, layouts and export.
Macros§
- icon_
from_ path - Macro to embed an SVG icon at compile time.