Skip to main content

ChartDataView

Struct ChartDataView 

Source
pub struct ChartDataView<'a> { /* private fields */ }
Expand description

Read-only view of the chart data for renderers.

§Examples

use ferrochart_core::{Chart, ChartOptions};
use ferrochart_core::chart::{SeriesData, SeriesOptions};
use ferrochart_core::data::DataDelta;
use ferrochart_core::frame::SeriesKind;
use ferrochart_core::testing::random_walk;

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)?))?;

let view = chart.data_view();
assert_eq!(view.changes_since(id, 0), DataDelta::Full); // never synced
let synced = view.generation(id).unwrap();
assert_eq!(view.changes_since(id, synced), DataDelta::None);
assert_eq!(view.ohlc(id, 0).unwrap().len(), 100);

Implementations§

Source§

impl<'a> ChartDataView<'a>

Source

pub fn empty() -> ChartDataView<'static>

A view without series, for frames that only hold immediate primitives (ferrochart-plot).

use ferrochart_core::chart::ChartDataView;
use ferrochart_core::data::SeriesId;

let view = ChartDataView::empty();
assert_eq!(view.generation(SeriesId(1)), None);
assert!(view.time_index().is_empty());
Source

pub fn generation(&self, id: SeriesId) -> Option<u64>

Current data generation of a series, None for unknown ids.

Source

pub fn changes_since(&self, id: SeriesId, since_gen: u64) -> DataDelta

What changed in a series since generation since_gen. Unknown ids give Full.

Source

pub fn ohlc(&self, id: SeriesId, level: u8) -> Option<OhlcLevelView<'a>>

Data of one level (0 = original, >= 2 = LOD). Value series appear as bars with open == high == low == close == value at level 0 and (first, max, min, last) per bucket at LOD levels; NaN values are gaps.

Source

pub fn point_colors(&self, id: SeriesId) -> Option<(i64, &'a [u32])>

Per-point colors of a value series (RGBA8, 0 = the series color) and the logical index of the first one. Level 0 only.

Source

pub fn custom(&self, id: SeriesId) -> Option<&'a dyn CustomSeries>

The plugin of a custom series, for native renderers to read its data (downcast with as &dyn Any); None for other series.

Source

pub fn custom_index(&self, id: SeriesId, point: usize) -> Option<f64>

Fractional logical index of point point of custom series id (its slot, or its time interpolated between slots for AxisMode::Overlay), without SeriesOptions::shift (which is in CustomDraw::x_transform).

Source

pub fn time_index(&self) -> &'a TimeIndex

The global time index.

Trait Implementations§

Source§

impl<'a> Clone for ChartDataView<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for ChartDataView<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ChartDataView<'a>

§

impl<'a> !Send for ChartDataView<'a>

§

impl<'a> !Sync for ChartDataView<'a>

§

impl<'a> !UnwindSafe for ChartDataView<'a>

§

impl<'a> Forget for ChartDataView<'a>

§

impl<'a> Freeze for ChartDataView<'a>

§

impl<'a> Move for ChartDataView<'a>

§

impl<'a> Unpin for ChartDataView<'a>

§

impl<'a> UnsafeUnpin for ChartDataView<'a>

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
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.