Skip to main content

Chart

Struct Chart 

Source
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>

Source

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.

Source

pub fn with_label_chars(self, chars: u16) -> Self

The chart with room for y labels of chars characters (8 unless told otherwise).

Source

pub fn style() -> Style

A chart filling its parent’s free space, allowed to be small, and clipping.

Source

pub fn model(&self) -> &M

The data.

Source

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.

Source

pub fn x_axis(&self) -> Option<Axis>

What part of the horizontal axis shows, or None while there is no data.

Source

pub fn is_following(&self) -> bool

Whether the chart moves with new data.

Source

pub fn follow(&mut self, cx: &mut EventCx<'_>)

Shows the newest data again, as wide a part as now, and follows it.

Source

pub fn show(&mut self, cx: &mut EventCx<'_>, x: Axis)

Shows x (within what the data allows), following new data if it reaches past the newest.

Trait Implementations§

Source§

impl<M: Debug> Debug for Chart<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: ChartModel + 'static> Widget for Chart<M>

Source§

fn layout(&mut self, cx: &mut LayoutCx<'_>, _size: Size)

Layout decided the widget’s size: re-wrap text or recompute anything that depends on it. Called after every layout pass that changed the size.
Source§

fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)

Paints the widget below its children.
Source§

fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled

Handles event. An event the widget does not handle goes on to its parent.
Source§

fn accepts_focus(&self) -> bool

Whether the widget takes keyboard focus, by click or by Tab.
Source§

fn accessibility(&self, _cx: &PaintCx<'_>, node: &mut AccessNode)

Describes the widget to assistive technology: fills 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

The size the widget wants within constraints, for a widget without children (one with children is sized by its style and its children). Physical pixels.
Source§

fn paint_over(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)

Paints the widget over its children: scroll bars, focus rings, overlays.
Source§

fn focus_on_press(&self) -> bool

Whether a press on the widget, or on a widget inside it that takes no focus, focuses it (if it accepts focus). A container reachable by Tab, such as a dock’s tab list, says no, so clicks on its contents do not focus it; it can still ask for focus itself.
Source§

fn access_action( &mut self, cx: &mut EventCx<'_>, request: &AccessRequest<'_>, ) -> Handled

Does what assistive technology asks (only actions the widget’s node lists are asked of it). Focus and scrolling into view are done for every widget; a request the widget does not handle goes on to its parent if it is a scroll.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Chart<M>

§

impl<M> !UnwindSafe for Chart<M>

§

impl<M> Freeze for Chart<M>
where M: Freeze,

§

impl<M> Send for Chart<M>
where M: Send,

§

impl<M> Sync for Chart<M>
where M: Sync,

§

impl<M> Unpin for Chart<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for Chart<M>
where M: UnsafeUnpin,

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> ErasedDestructor for T
where T: 'static,

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, 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.