pub struct Legend { /* private fields */ }Expand description
The names behind the tones of a chart: a patch of colour and the name it stands for.
The n-th name takes the theme’s n-th series tone
(Theme::series_color), which is how every chart picks
its tones, so a legend beside a chart names the same colours the chart drew. A legend is not
decoration: in a stacked bar or a tinted grid the meaning of a tone lives nowhere else, and
the theme carries only five series tones, so a sixth series shares the first one’s tone and
the name is the only thing that tells them apart.
tones pins each name to a tone of the palette instead of its position, the
same index its series was given with Series::tone, so a category
keeps its colour however many others are named beside it.
Names lie in a row and wrap onto further rows when the area is too narrow; vertical puts
each on its own row. A name that does not fit is cut with …. The swatch is two cells of
colour, never a bracketed marker, and it works the same in every glyph mode because it is
made of colour rather than characters.
Style keys: legend (fg for the names).
Implementations§
Source§impl Legend
impl Legend
Sourcepub fn new(names: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn new(names: impl IntoIterator<Item = impl Into<String>>) -> Self
A legend naming the series of a chart, in the order the chart draws them.
Sourcepub fn tones(self, tones: impl IntoIterator<Item = usize>) -> Self
pub fn tones(self, tones: impl IntoIterator<Item = usize>) -> Self
The palette index of every name, in the order of the names: the n-th name takes the
theme’s tones[n]-th series tone. A name past the end of tones keeps the tone of its
position.
Trait Implementations§
impl Eq for Legend
impl StructuralPartialEq for Legend
Source§impl<Msg: 'static> Widget<Msg> for Legend
impl<Msg: 'static> Widget<Msg> for Legend
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 Legend
impl RefUnwindSafe for Legend
impl Send for Legend
impl Sync for Legend
impl Unpin for Legend
impl UnsafeUnpin for Legend
impl UnwindSafe for Legend
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