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>
impl<'a> ChartDataView<'a>
Sourcepub fn empty() -> ChartDataView<'static>
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());Sourcepub fn generation(&self, id: SeriesId) -> Option<u64>
pub fn generation(&self, id: SeriesId) -> Option<u64>
Current data generation of a series, None for unknown ids.
Sourcepub fn changes_since(&self, id: SeriesId, since_gen: u64) -> DataDelta
pub fn changes_since(&self, id: SeriesId, since_gen: u64) -> DataDelta
What changed in a series since generation since_gen. Unknown ids
give Full.
Sourcepub fn ohlc(&self, id: SeriesId, level: u8) -> Option<OhlcLevelView<'a>>
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.
Sourcepub fn point_colors(&self, id: SeriesId) -> Option<(i64, &'a [u32])>
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.
Sourcepub fn custom(&self, id: SeriesId) -> Option<&'a dyn CustomSeries>
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.
Sourcepub fn custom_index(&self, id: SeriesId, point: usize) -> Option<f64>
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).
Sourcepub fn time_index(&self) -> &'a TimeIndex
pub fn time_index(&self) -> &'a TimeIndex
The global time index.