pub struct Chart<M> { /* private fields */ }Expand description
A chart of a ChartModel: its panes stacked top to bottom on one horizontal axis,
labelled under the lowest, each scaled to what it shows.
It shows the newest span of the data and moves with it as data arrives. The user zooms
with the wheel or the up and down keys (around the pointer, or at the newest data while
following it), pans by dragging, with a sideways scroll or with the left and right keys,
and goes back to the newest data with a double click, End, or by panning past it; Home
goes to the oldest. A view the user moved stays over the data as it changes (data
trimmed away moves it along). A crosshair follows the pointer with its values, written a
digit finer than the labels (with_label_chars for room). It
reports ActionKind::Changed when the user moved the view.
Painting allocates nothing once the label characters are cached; what the model’s
series cost is up to them (this crate’s series functions allocate nothing). Change the
data through model_mut from an Ui::update
on the chart, which repaints it. Give it Chart::style.
Implementations§
Source§impl<M: ChartModel> Chart<M>
impl<M: ChartModel> Chart<M>
Sourcepub fn new(model: M, span: f64) -> Self
pub fn new(model: M, span: f64) -> Self
A chart of model showing its newest span of x (an hour is 3600.0 on a time
axis), following new data.
Sourcepub fn with_label_chars(self, chars: u16) -> Self
pub fn with_label_chars(self, chars: u16) -> Self
The chart with room for y labels of chars characters (8 unless told otherwise).
Sourcepub fn style() -> Style
pub fn style() -> Style
A chart filling its parent’s free space, allowed to be small, and clipping.
Sourcepub fn model_mut(&mut self, cx: &mut EventCx<'_>) -> &mut M
pub fn model_mut(&mut self, cx: &mut EventCx<'_>) -> &mut M
The data, to change (from an Ui::update on the chart): the
chart repaints.
Sourcepub fn x_axis(&self) -> Option<Axis>
pub fn x_axis(&self) -> Option<Axis>
What part of the horizontal axis shows, or None while there is no data.
Sourcepub fn is_following(&self) -> bool
pub fn is_following(&self) -> bool
Whether the chart moves with new data.
Trait Implementations§
Source§impl<M: ChartModel + 'static> Widget for Chart<M>
impl<M: ChartModel + 'static> Widget for Chart<M>
Source§fn layout(&mut self, cx: &mut LayoutCx<'_>, _size: Size)
fn layout(&mut self, cx: &mut LayoutCx<'_>, _size: Size)
Source§fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
Source§fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
event. An event the widget does not handle goes on to its parent.Source§fn accepts_focus(&self) -> bool
fn accepts_focus(&self) -> bool
Source§fn accessibility(&self, _cx: &PaintCx<'_>, node: &mut AccessNode)
fn accessibility(&self, _cx: &PaintCx<'_>, node: &mut AccessNode)
node, which starts as a
Role::Group with the widget’s rectangle. Called only while
assistive technology is listening; it may allocate.Source§fn measure(&mut self, cx: &mut LayoutCx<'_>, constraints: Constraints) -> Size
fn measure(&mut self, cx: &mut LayoutCx<'_>, constraints: Constraints) -> Size
constraints, for a widget without children (one
with children is sized by its style and its children). Physical pixels.