Skip to main content

ChartLayout

Struct ChartLayout 

Source
pub struct ChartLayout {
    pub mode: ChartLayoutMode,
    pub sync: ChartSyncOptions,
    /* private fields */
}
Expand description

Container state for up to sixteen host-owned charts. Supply charts in stable slot order.

Each chart keeps its own feed, settings, scales, studies and drawings. An unnamed group synchronizes with other unnamed charts; named groups are isolated. Save this state and the charts through host storage as needed. Synchronization includes supplied slots hidden by a grid preset. The container does not acquire data or persist it. Charts that keep their drawings in the same storage (Chart::set_storage) read the drawings of their symbol again after another of them wrote them, in any group.

use egui_charts::widget::{Chart, ChartLayout, ChartLayoutMode};
let mut a = Chart::new(egui_charts::model::BarData::new());
let mut b = Chart::new(egui_charts::model::BarData::new());
let mut layout = ChartLayout::default();
layout.mode = ChartLayoutMode::TwoHorizontal;
layout.show(ui, &mut [&mut a, &mut b]);

Fields§

§mode: ChartLayoutMode

The selected grid or tab preset.

§sync: ChartSyncOptions

Synchronization controls, applied within each group.

Implementations§

Source§

impl ChartLayout

Source

pub fn active(&self) -> usize

Active chart slot, clamped to supplied charts by Self::show.

Source

pub fn set_active(&mut self, index: usize)

Selects a chart slot and focuses its canvas when shown; out-of-range indices are ignored.

Source

pub fn set_sync_group(&mut self, index: usize, group: Option<String>)

Assigns a named synchronization group; None restores the unnamed group.

Source

pub fn sync_group(&self, index: usize) -> Option<&str>

The group assigned to a slot, or None for the unnamed group or an invalid slot.

Source

pub fn set_detached(&mut self, index: usize, detached: bool)

Detaches a chart into an immediate viewport. Backends without native multi-window support embed the viewport. Closing it returns the chart to its grid or tab.

Source

pub fn is_detached(&self, index: usize) -> bool

Whether a chart is detached.

Source

pub fn apply_date_range( &self, charts: &mut [&mut Chart], range: VisibleTimeRange, )

Fits an explicit date selection to the active chart, or its synchronization group when sync_date_range is enabled. Call after the charts have rendered at their sizes.

Source

pub fn show(&mut self, ui: &mut Ui, charts: &mut [&mut Chart]) -> Response

Shows the preset and synchronizes its charts. Click or scroll a panel to activate it. Its corner menu offers detachment and named groups. The active border is painted inside the chart; stacked charts have a two-point gap and side-by-side charts meet at their edge. Extra charts remain owned by the host and are not painted by a grid preset.

Source

pub fn visible_chart_rects( &self, rect: Rect, count: usize, ) -> Vec<(usize, Rect)>

The slot and rectangle of each visible chart inside rect, for an image export. Uses the on-screen arrangement, omitting detached and hidden slots and tab controls. count is the number of charts the host owns, including the active one.

Source§

impl ChartLayout

Source

pub fn set_replay_time( &self, charts: &mut [&mut Chart], source: usize, time: Option<DateTime<Utc>>, )

Sets one replay cutoff on the source slot’s synchronization group, including hidden slots. Other groups keep their own sessions. Call for every cursor move and with None to exit; each chart windows its own host-supplied history at its own interval.

Trait Implementations§

Source§

impl Clone for ChartLayout

Source§

fn clone(&self) -> ChartLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ChartLayout

Source§

fn default() -> ChartLayout

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.