Struct tuirealm::tui::widgets::Chart[][src]

pub struct Chart<'a> { /* fields omitted */ }
Expand description

A widget to plot one or more dataset in a cartesian coordinate system

Examples

let datasets = vec![
    Dataset::default()
        .name("data1")
        .marker(symbols::Marker::Dot)
        .graph_type(GraphType::Scatter)
        .style(Style::default().fg(Color::Cyan))
        .data(&[(0.0, 5.0), (1.0, 6.0), (1.5, 6.434)]),
    Dataset::default()
        .name("data2")
        .marker(symbols::Marker::Braille)
        .graph_type(GraphType::Line)
        .style(Style::default().fg(Color::Magenta))
        .data(&[(4.0, 5.0), (5.0, 8.0), (7.66, 13.5)]),
];
Chart::new(datasets)
    .block(Block::default().title("Chart"))
    .x_axis(Axis::default()
        .title(Span::styled("X Axis", Style::default().fg(Color::Red)))
        .style(Style::default().fg(Color::White))
        .bounds([0.0, 10.0])
        .labels(["0.0", "5.0", "10.0"].iter().cloned().map(Span::from).collect()))
    .y_axis(Axis::default()
        .title(Span::styled("Y Axis", Style::default().fg(Color::Red)))
        .style(Style::default().fg(Color::White))
        .bounds([0.0, 10.0])
        .labels(["0.0", "5.0", "10.0"].iter().cloned().map(Span::from).collect()));
Run

Implementations

Set the constraints used to determine whether the legend should be shown or not.

Examples

let constraints = (
    Constraint::Ratio(1, 3),
    Constraint::Ratio(1, 4)
);
// Hide the legend when either its width is greater than 33% of the total widget width
// or if its height is greater than 25% of the total widget height.
let _chart: Chart = Chart::new(vec![])
    .hidden_legend_constraints(constraints);
Run

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Draws the current state of the widget in the given buffer. That the only method required to implement a custom widget. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.