InteractiveLegend

Trait InteractiveLegend 

Source
pub trait InteractiveLegend<C: PixelColor>: Legend<C> {
    type Event;
    type Response;

    // Required methods
    fn handle_event(
        &mut self,
        event: Self::Event,
        viewport: Rectangle,
    ) -> ChartResult<Self::Response>;
    fn hit_test(&self, point: Point, viewport: Rectangle) -> Option<usize>;
    fn toggle_entry(&mut self, index: usize) -> ChartResult<()>;
    fn selected_entry(&self) -> Option<usize>;
    fn set_selected_entry(&mut self, index: Option<usize>);
}
Expand description

Trait for legends that support interactive features

Required Associated Types§

Source

type Event

Event type for legend interactions

Source

type Response

Response type for legend interactions

Required Methods§

Source

fn handle_event( &mut self, event: Self::Event, viewport: Rectangle, ) -> ChartResult<Self::Response>

Handle an interaction event

§Arguments
  • event - The interaction event
  • viewport - The legend viewport
Source

fn hit_test(&self, point: Point, viewport: Rectangle) -> Option<usize>

Check if a point is within a legend entry

§Arguments
  • point - The point to check
  • viewport - The legend viewport
Source

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

Toggle the visibility of an entry

Source

fn selected_entry(&self) -> Option<usize>

Get the currently selected entry index

Source

fn set_selected_entry(&mut self, index: Option<usize>)

Set the selected entry

Implementors§