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
impl Axis
Sourcepub fn hours(from: TimeOfDay, to: TimeOfDay) -> Self
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.
Sourcepub fn weekdays(first: Weekday, count: usize) -> Self
pub fn weekdays(first: Weekday, count: usize) -> Self
count weekdays from first on, wrapping after Sunday.
Sourcepub fn months(first: u8, count: usize) -> Self
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.
Sourcepub fn labels(labels: impl IntoIterator<Item = impl Into<String>>) -> Self
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.
Trait Implementations§
impl Eq for Axis
impl StructuralPartialEq for Axis
Source§impl<Msg: 'static> Widget<Msg> for Axis
impl<Msg: 'static> Widget<Msg> for Axis
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool
fn event(&self, _cx: &mut EventCx<'_, Msg>, _event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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