Skip to main content

Axis

Struct Axis 

Source
pub struct Axis { /* private fields */ }
Expand description

A row of labels along the edge of a chart: hours of a day, weekdays, months, or names of your own.

Hours are placed by time: a label starts in the cell its clock time falls in, the way a Timeline places a block, so an axis under a strip of the same range reads straight down. Weekdays, months and names of your own are placed in slots: the width is shared out into one slot per label, with gap empty cells between slots, and each label is centred in its slot. A vertical BarChart shares its width out the same way, so an axis with the chart’s gap stands under its bars.

Names come from the active language — quvyta.date.weekday-long-*, weekday-*, month-*, month-short-*, and quvyta.time.clock and hour for times — never from the source.

Labels never collide and are never cut. Weekdays and months write every name in full while all of them fit, then every name in its short form, then the short form of every second, third, … name. Hours take the finest step whose labels fit — a quarter hour, half an hour, an hour, then 2, 3, 4, 6, 12 hours and a day, always on round clock times — in the long form (09:30), and fall back to the short form (09) only when the long one leaves fewer than two labels, which gives a reader no scale. At least one cell stays empty between two labels, and a label that would run past the right edge is left out rather than cut. An area too narrow for a single label writes nothing.

An axis is text only, so it reads the same in every glyph mode; it takes no focus and sends no messages.

Style keys: axis (fg).

Implementations§

Source§

impl Axis

Source

pub fn hours(from: TimeOfDay, to: TimeOfDay) -> Self

The hours from from to to: into the next day when to is not after from, a whole day when the two are the same.

Source

pub fn weekdays(first: Weekday, count: usize) -> Self

count weekdays from first on, wrapping after Sunday.

Source

pub fn months(first: u8, count: usize) -> Self

count months from first on (1 for January to 12 for December), wrapping after December. A first outside 1 to 12 is taken as the nearest month.

Source

pub fn labels(labels: impl IntoIterator<Item = impl Into<String>>) -> Self

Names of your own, one slot each, e.g. the weeks of a quarter. A name with no room in the active width is left out, never cut.

Source

pub fn gap(self, cells: u16) -> Self

Empty cells between two slots; none by default. Give it the gap of the chart above so the labels stand under its bars. Hours are placed by time and have no slots, so they ignore it.

Trait Implementations§

Source§

impl Clone for Axis

Source§

fn clone(&self) -> Axis

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 Debug for Axis

Source§

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

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

impl Eq for Axis

Source§

impl PartialEq for Axis

Source§

fn eq(&self, other: &Axis) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Axis

Source§

impl<Msg: 'static> Widget<Msg> for Axis

Source§

fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size

The size the widget wants when it may use up to available.
Source§

fn paint(&self, cx: &mut PaintCx<'_>, area: Rect)

Draws the widget into area.
Source§

fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)

Draws the widget’s overlay after the whole view was painted, when it asked for one with PaintCx::request_overlay. anchor is the area the widget was painted in.
Source§

fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool

Handles input. Returns true when the event was used; unused key and scroll events bubble to the parent widget.
Source§

fn focusable(&self) -> bool

Whether the widget can take keyboard focus.
Source§

fn children(&self) -> &[Node<Msg>]

Child nodes, for widgets that contain other widgets.
Source§

fn children_mut(&mut self) -> &mut [Node<Msg>]

Mutable child nodes, used to assign ids.

Auto Trait Implementations§

§

impl Freeze for Axis

§

impl RefUnwindSafe for Axis

§

impl Send for Axis

§

impl Sync for Axis

§

impl Unpin for Axis

§

impl UnsafeUnpin for Axis

§

impl UnwindSafe for Axis

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.