Legend

Trait Legend 

Source
pub trait Legend<C: PixelColor> {
    type Entry: LegendEntry<C>;

    // Required methods
    fn entries(&self) -> &[Self::Entry];
    fn entries_mut(&mut self) -> &mut [Self::Entry];
    fn add_entry(&mut self, entry: Self::Entry) -> ChartResult<()>;
    fn remove_entry(&mut self, index: usize) -> ChartResult<()>;
    fn clear_entries(&mut self);
    fn position(&self) -> LegendPosition;
    fn set_position(&mut self, position: LegendPosition);
    fn orientation(&self) -> LegendOrientation;
    fn set_orientation(&mut self, orientation: LegendOrientation);
    fn calculate_size(&self) -> Size;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn visible_entry_count(&self) -> usize { ... }
}
Expand description

Main trait for legend implementations

Required Associated Types§

Source

type Entry: LegendEntry<C>

The type of legend entries this legend contains

Required Methods§

Source

fn entries(&self) -> &[Self::Entry]

Get all legend entries

Source

fn entries_mut(&mut self) -> &mut [Self::Entry]

Get mutable access to legend entries

Source

fn add_entry(&mut self, entry: Self::Entry) -> ChartResult<()>

Add a new entry to the legend

Source

fn remove_entry(&mut self, index: usize) -> ChartResult<()>

Remove an entry by index

Source

fn clear_entries(&mut self)

Clear all entries

Source

fn position(&self) -> LegendPosition

Get the legend position

Source

fn set_position(&mut self, position: LegendPosition)

Set the legend position

Source

fn orientation(&self) -> LegendOrientation

Get the legend orientation

Source

fn set_orientation(&mut self, orientation: LegendOrientation)

Set the legend orientation

Source

fn calculate_size(&self) -> Size

Calculate the required size for this legend

Provided Methods§

Source

fn is_empty(&self) -> bool

Check if the legend is empty

Source

fn visible_entry_count(&self) -> usize

Get the number of visible entries

Implementors§