pub struct ChartState {
pub version: u32,
pub bar_spacing: Css,
pub right_offset: f64,
pub crosshair_mode: CrosshairMode,
pub panes: Vec<PaneState>,
pub drawings: Vec<SavedDrawing>,
}Expand description
Saved view, layout and drawings of a chart.
§Examples
use ferrochart_core::chart::{SeriesData, SeriesOptions};
use ferrochart_core::drawing::{Anchor, DrawingData};
use ferrochart_core::frame::SeriesKind;
use ferrochart_core::testing::random_walk;
use ferrochart_core::{Chart, ChartOptions};
// The host sets up a chart: series and data.
let setup = || -> Result<Chart, ferrochart_core::Error> {
let mut chart = Chart::new(ChartOptions::default());
let id = chart.add_series(chart.main_pane(), SeriesKind::Candlestick, SeriesOptions::default())?;
chart.set_data(id, SeriesData::Ohlc(random_walk(1, 100, 0, 60_000)?))?;
Ok(chart)
};
let mut chart = setup()?;
let pane = chart.main_pane();
chart.drawings().add(pane, &DrawingData::new("horizontal_line", vec![Anchor { time: 0, price: 100.0 }]))?;
chart.time_scale().set_bar_spacing(12.0);
let state = chart.save_state();
// Later: the same setup, then the saved state.
let mut restored = setup()?;
restored.load_state(state.clone())?;
assert_eq!(restored.save_state(), state);Fields§
§version: u32Format version (STATE_VERSION).
bar_spacing: CssBar spacing.
right_offset: f64Empty space right of the last bar, in bars.
crosshair_mode: CrosshairModeCrosshair mode.
panes: Vec<PaneState>Panes, top to bottom.
drawings: Vec<SavedDrawing>Drawings, bottom to top.
Trait Implementations§
Source§impl Clone for ChartState
impl Clone for ChartState
Source§impl Debug for ChartState
impl Debug for ChartState
Source§impl PartialEq for ChartState
impl PartialEq for ChartState
impl StructuralPartialEq for ChartState
Auto Trait Implementations§
impl Forget for ChartState
impl Freeze for ChartState
impl Move 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