```
use std::{
    error::Error,
    io,
    time::{Duration, Instant},
};
use tui::widgets::Sparkline;
use tui::widgets::{Block, Borders};
use tui::Frame;

use crossterm::{
    event::{self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode},
    execute,
    terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
// use learn_tui::draw_test;
use tui::{
    backend::{Backend, CrosstermBackend},
    Terminal,
};

fn main() -> Result<(), Box<dyn Error>> {
    enable_raw_mode()?;
    let mut stdout = io::stdout();
    execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
    let backend = CrosstermBackend::new(stdout);
    let mut terminal = Terminal::new(backend)?;

    let res = draw_sparkline(&mut terminal);

    disable_raw_mode()?;
    execute!(
        terminal.backend_mut(),
        LeaveAlternateScreen,
        DisableMouseCapture
    )?;

    terminal.show_cursor()?;
    if let Err(err) = res {
        println!("{:?}", err);
    }

    Ok(())
}
pub fn draw_sparkline<B: Backend>(terminal: &mut Terminal<B>) -> io::Result<()> {
    let rate = Duration::from_millis(200);
    let mut last_trick = Instant::now();
    loop {
        terminal.draw(sparkline)?;
        let timeout = last_trick
            .elapsed()
            .checked_sub(rate)
            .unwrap_or_else(|| Duration::from_millis(0));
        if event::poll(timeout)? {
            if let CEvent::Key(key) = event::read()? {
                if let KeyCode::Char('q') = key.code {
                    return Ok(());
                }
            }
        }
        if last_trick.elapsed() > rate {
            last_trick = Instant::now();
        }
    }
}

fn sparkline<B: Backend>(f: &mut Frame<B>) {
    let sparkline = Sparkline::default()
        .block(Block::default().title("Block").borders(Borders::ALL))
        .data(&[1, 3, 52, 1, 9, 10]);
    f.render_widget(sparkline, f.size())
}
```
```
use crossterm::{
    event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
    execute,
    terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use std::{
    error::Error,
    io,
    time::{Duration, Instant},
};
use tui::{
    backend::{Backend, CrosstermBackend},
    layout::{Constraint, Direction, Layout},
    style::{Color, Modifier, Style},
    widgets::{BarChart, Block, Borders},
    Frame, Terminal,
};

struct App<'a> {
    data: Vec<(&'a str, u64)>,
}

impl<'a> App<'a> {
    fn new() -> App<'a> {
        App {
            data: vec! The response should be in all capital letters.
user