pub struct ChartState { /* private fields */ }Expand description
Backend chart state – owns bar data, time-scale coordinate system, price auto-scaling logic, and zoom history.
This is the pure-logic layer with no UI or rendering dependencies. The UI
layer reads from ChartState to determine what to draw and writes back
interaction results (scroll, zoom, data updates).
§Example
use egui_charts::model::{BarData, ChartState};
let data = BarData::new();
let state = ChartState::new(data);
assert!(state.visible_data().is_empty());Implementations§
Source§impl ChartState
impl ChartState
Sourcepub fn time_scale_mut(&mut self) -> &mut TimeScale
pub fn time_scale_mut(&mut self) -> &mut TimeScale
Get mutable reference to time scale
Sourcepub fn time_scale(&self) -> &TimeScale
pub fn time_scale(&self) -> &TimeScale
Get reference to time scale
Sourcepub fn visible_data(&self) -> &[Bar]
pub fn visible_data(&self) -> &[Bar]
Get visible data based on current time scale
Sourcepub fn visible_range(&self) -> (usize, usize)
pub fn visible_range(&self) -> (usize, usize)
Get visible data range indices
Sourcepub fn set_price_auto_scale(&mut self, enabled: bool)
pub fn set_price_auto_scale(&mut self, enabled: bool)
Enable/disable price auto-scaling
Sourcepub fn set_price_range(&mut self, min: f64, max: f64)
pub fn set_price_range(&mut self, min: f64, max: f64)
Set manual price range
Sourcepub fn price_range(&self) -> (f64, f64)
pub fn price_range(&self) -> (f64, f64)
Get price range (auto-calculated or manual)
Sourcepub fn is_price_auto_scale(&self) -> bool
pub fn is_price_auto_scale(&self) -> bool
Check if price auto-scaling is enabled
Sourcepub fn push_zoom_state(&mut self)
pub fn push_zoom_state(&mut self)
Save current zoom state to history
Sourcepub fn pop_zoom_state(&mut self) -> bool
pub fn pop_zoom_state(&mut self) -> bool
Restore previous zoom state (zoom out button)
Sourcepub fn clear_zoom_history(&mut self)
pub fn clear_zoom_history(&mut self)
Clear zoom history
Sourcepub fn has_zoom_history(&self) -> bool
pub fn has_zoom_history(&self) -> bool
Check if there are zoom states to restore
Trait Implementations§
Source§impl Clone for ChartState
impl Clone for ChartState
Source§fn clone(&self) -> ChartState
fn clone(&self) -> ChartState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ChartState
impl RefUnwindSafe for ChartState
impl Send for ChartState
impl Sync for ChartState
impl Unpin for ChartState
impl UnsafeUnpin for ChartState
impl UnwindSafe for ChartState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more